List:Commits« Previous MessageNext Message »
From:Tatjana Azundris Nuernberg Date:August 19 2011 5:55am
Subject:bzr push into mysql-trunk branch (tatjana.nuernberg:3271 to 3272) WL#5706
View as plain text  
 3272 Tatjana Azundris Nuernberg	2011-08-19
      WL#5706
      
      split rewrite tests as suggested by Horst

    added:
      mysql-test/r/rewrite_slow_log.result
      mysql-test/t/rewrite_slow_log.test
    renamed:
      mysql-test/r/rewrite.result => mysql-test/r/rewrite_general_log.result
      mysql-test/t/rewrite.test => mysql-test/t/rewrite_general_log.test
    modified:
      mysql-test/r/rewrite_general_log.result
      mysql-test/t/rewrite_general_log.test
 3271 Tatjana Azundris Nuernberg	2011-08-18 [merge]
      manual merge

    removed:
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result.THIS
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result.THIS
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result.THIS
      mysql-test/suite/perfschema/r/schema_lc0.result.THIS
      mysql-test/suite/perfschema/r/schema_lc1.result.THIS
      mysql-test/suite/perfschema/r/schema_lc2.result.THIS
    added:
      client/mysql_plugin.c
      mysql-test/include/daemon_example_bad_format.ini
      mysql-test/include/daemon_example_bad_soname.ini
      mysql-test/r/multi_plugin_load.result
      mysql-test/r/multi_plugin_load_add.result
      mysql-test/r/multi_plugin_load_add2.result
      mysql-test/r/mysql_plugin.result
      mysql-test/r/optimizer_bug12837084.result
      mysql-test/suite/innodb/r/innodb_bug59733.result
      mysql-test/suite/innodb/r/innodb_corrupt_bit.result
      mysql-test/suite/innodb/t/innodb_bug59733.test
      mysql-test/suite/innodb/t/innodb_corrupt_bit.test
      mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result
      mysql-test/suite/sys_vars/r/innodb_flush_neighbors_basic.result
      mysql-test/suite/sys_vars/r/innodb_force_load_corrupted_basic.result
      mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result
      mysql-test/suite/sys_vars/r/innodb_lru_scan_depth_basic.result
      mysql-test/suite/sys_vars/t/ignore_db_dirs_basic-master.opt
      mysql-test/suite/sys_vars/t/ignore_db_dirs_basic.test
      mysql-test/suite/sys_vars/t/innodb_flush_neighbors_basic.test
      mysql-test/suite/sys_vars/t/innodb_force_load_corrupted_basic.test
      mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test
      mysql-test/suite/sys_vars/t/innodb_lru_scan_depth_basic.test
      mysql-test/t/multi_plugin_load-master.opt
      mysql-test/t/multi_plugin_load.test
      mysql-test/t/multi_plugin_load_add-master.opt
      mysql-test/t/multi_plugin_load_add.test
      mysql-test/t/multi_plugin_load_add2-master.opt
      mysql-test/t/multi_plugin_load_add2.test
      mysql-test/t/mysql_plugin-master.opt
      mysql-test/t/mysql_plugin.test
      mysql-test/t/optimizer_bug12837084.test
      plugin/daemon_example/daemon_example.ini
    modified:
      client/CMakeLists.txt
      include/my_base.h
      include/my_global.h
      mysql-test/collections/default.experimental
      mysql-test/include/join_cache.inc
      mysql-test/include/plugin.defs
      mysql-test/include/range.inc
      mysql-test/mysql-test-run.pl
      mysql-test/r/derived.result
      mysql-test/r/explain.result
      mysql-test/r/func_gconcat.result
      mysql-test/r/grant2.result
      mysql-test/r/group_by.result
      mysql-test/r/heap.result
      mysql-test/r/index_merge_myisam.result
      mysql-test/r/information_schema.result
      mysql-test/r/innodb_explain_non_select_none.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_mrr_all.result
      mysql-test/r/innodb_mrr_cost_all.result
      mysql-test/r/join_cache_jcl0.result
      mysql-test/r/join_cache_jcl1.result
      mysql-test/r/join_cache_jcl2.result
      mysql-test/r/join_cache_jcl3.result
      mysql-test/r/join_cache_jcl4.result
      mysql-test/r/join_cache_jcl5.result
      mysql-test/r/join_cache_jcl6.result
      mysql-test/r/join_cache_jcl7.result
      mysql-test/r/join_cache_jcl8.result
      mysql-test/r/myisam_explain_non_select_none.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/myisam_mrr_all.result
      mysql-test/r/myisam_mrr_cost_all.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/range_all.result
      mysql-test/r/range_icp.result
      mysql-test/r/range_icp_mrr.result
      mysql-test/r/range_mrr.result
      mysql-test/r/range_mrr_cost.result
      mysql-test/r/range_none.result
      mysql-test/r/row.result
      mysql-test/r/sp_trans.result
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_none.result
      mysql-test/r/view.result
      mysql-test/suite/funcs_1/datadict/datadict_priv.inc
      mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
      mysql-test/suite/funcs_1/r/processlist_priv_ps.result
      mysql-test/suite/innodb/r/innodb_monitor.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb_buffer_pool_load-master.opt
      mysql-test/suite/opt_trace/r/bugs_no_prot_none.result
      mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result
      mysql-test/suite/opt_trace/r/charset.result
      mysql-test/suite/opt_trace/r/general2_no_prot.result
      mysql-test/suite/opt_trace/r/general2_ps_prot.result
      mysql-test/suite/opt_trace/r/general_no_prot_none.result
      mysql-test/suite/opt_trace/r/general_ps_prot_none.result
      mysql-test/suite/opt_trace/r/range_no_prot.result
      mysql-test/suite/opt_trace/r/range_ps_prot.result
      mysql-test/suite/opt_trace/r/security_no_prot.result
      mysql-test/suite/opt_trace/r/security_ps_prot.result
      mysql-test/suite/rpl/r/rpl_heartbeat.result
      mysql-test/suite/rpl/t/rpl_heartbeat.test
      mysql-test/suite/sys_vars/r/all_vars.result
      mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result
      mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result
      mysql-test/suite/sys_vars/t/all_vars.test
      mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_basic.test
      mysql-test/suite/sys_vars/t/innodb_fast_shutdown_basic.test
      mysql-test/suite/sys_vars/t/innodb_file_per_table_basic.test
      mysql-test/suite/sys_vars/t/innodb_io_capacity_basic.test
      mysql-test/suite/sys_vars/t/innodb_lock_wait_timeout_basic.test
      mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_basic.test
      mysql-test/t/derived.test
      mysql-test/t/grant2.test
      mysql-test/t/group_by.test
      mysql-test/t/heap.test
      mysql-test/t/information_schema.test
      mysql-test/t/join.test
      mysql-test/t/sp_trans.test
      mysys/my_handler_errors.h
      plugin/daemon_example/CMakeLists.txt
      sql/authors.h
      sql/field.h
      sql/handler.cc
      sql/handler.h
      sql/item_cmpfunc.cc
      sql/item_subselect.cc
      sql/item_sum.cc
      sql/key.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/opt_explain.cc
      sql/opt_range.cc
      sql/opt_range.h
      sql/opt_sum.cc
      sql/records.cc
      sql/records.h
      sql/share/errmsg-utf8.txt
      sql/sql_alter.cc
      sql/sql_base.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_cursor.cc
      sql/sql_derived.cc
      sql/sql_derived.h
      sql/sql_insert.cc
      sql/sql_join_cache.cc
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_list.h
      sql/sql_parse.cc
      sql/sql_plugin.cc
      sql/sql_plugin.h
      sql/sql_prepare.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_show.cc
      sql/sql_show.h
      sql/sql_test.cc
      sql/sql_union.cc
      sql/sql_update.cc
      sql/sql_view.cc
      sql/sql_yacc.yy
      sql/structs.h
      sql/sys_vars.cc
      sql/table.cc
      sql/table.h
      storage/heap/hp_hash.c
      storage/innobase/btr/btr0btr.c
      storage/innobase/btr/btr0cur.c
      storage/innobase/btr/btr0pcur.c
      storage/innobase/btr/btr0sea.c
      storage/innobase/buf/buf0buf.c
      storage/innobase/buf/buf0flu.c
      storage/innobase/buf/buf0lru.c
      storage/innobase/buf/buf0rea.c
      storage/innobase/dict/dict0crea.c
      storage/innobase/dict/dict0dict.c
      storage/innobase/dict/dict0load.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/ibuf/ibuf0ibuf.c
      storage/innobase/include/btr0btr.h
      storage/innobase/include/btr0btr.ic
      storage/innobase/include/buf0buf.h
      storage/innobase/include/buf0buf.ic
      storage/innobase/include/buf0flu.h
      storage/innobase/include/buf0lru.h
      storage/innobase/include/buf0types.h
      storage/innobase/include/db0err.h
      storage/innobase/include/dict0boot.h
      storage/innobase/include/dict0dict.h
      storage/innobase/include/dict0dict.ic
      storage/innobase/include/dict0mem.h
      storage/innobase/include/dict0priv.ic
      storage/innobase/include/dict0types.h
      storage/innobase/include/ibuf0ibuf.ic
      storage/innobase/include/srv0mon.h
      storage/innobase/include/srv0srv.h
      storage/innobase/include/sync0sync.h
      storage/innobase/include/trx0sys.h
      storage/innobase/log/log0log.c
      storage/innobase/pars/pars0opt.c
      storage/innobase/read/read0read.c
      storage/innobase/row/row0ins.c
      storage/innobase/row/row0merge.c
      storage/innobase/row/row0mysql.c
      storage/innobase/row/row0purge.c
      storage/innobase/row/row0sel.c
      storage/innobase/row/row0uins.c
      storage/innobase/row/row0umod.c
      storage/innobase/row/row0upd.c
      storage/innobase/srv/srv0mon.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/sync/sync0sync.c
      storage/innobase/trx/trx0sys.c
      storage/innobase/ut/ut0ut.c
      support-files/mysql.spec.sh
      unittest/gunit/sql_list-t.cc
=== modified file 'mysql-test/include/plugin.defs'
--- a/mysql-test/include/plugin.defs	2011-08-18 09:39:24 +0000
+++ b/mysql-test/include/plugin.defs	2011-08-18 18:05:45 +0000
@@ -40,4 +40,5 @@ ha_archive         storage/archive    AR
 ha_blackhole       storage/blackhole  BLACKHOLE_PLUGIN
 ha_federated       storage/federated  FEDERATED_PLUGIN
 mypluglib          plugin/fulltext    SIMPLE_PARSER
+adt_null           plugin/audit_null  AUDIT_NULL
 libdaemon_example  plugin/daemon_example DAEMONEXAMPLE

=== added file 'mysql-test/r/audit_plugin.result'
--- a/mysql-test/r/audit_plugin.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/audit_plugin.result	2011-08-17 15:11:11 +0000
@@ -0,0 +1,23 @@
+INSTALL PLUGIN audit_null SONAME 'adt_null.<expected_extension>';
+ERROR HY000: Can't find symbol 'audit_null' in library
+INSTALL PLUGIN null_audit SONAME 'adt_null.<expected_extension>';
+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
+ERROR 42S01: Table 't1' already exists
+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
+SELECT * FROM t1;
+c1	c2
+1	a
+2	b
+3	c
+SELECT * FROM t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+DROP TABLE t1;
+SHOW STATUS LIKE 'audit_null_called';
+Variable_name	Value
+Audit_null_called	<expected_number_of_calls>
+UNINSTALL PLUGIN audit_null;
+ERROR 42000: PLUGIN audit_null does not exist
+UNINSTALL PLUGIN null_audit;
+Warnings:
+Warning	1620	Plugin is busy and will be uninstalled on shutdown

=== modified file 'mysql-test/r/log_state.result'
--- a/mysql-test/r/log_state.result	2011-02-10 11:13:41 +0000
+++ b/mysql-test/r/log_state.result	2011-08-17 14:07:07 +0000
@@ -24,7 +24,7 @@ select * from mysql.general_log;
 event_time	user_host	thread_id	server_id	command_type	argument
 TIMESTAMP	USER_HOST	#	1	Query	create table t1(f1 int)
 TIMESTAMP	USER_HOST	#	1	Query	select * from mysql.general_log
-TIMESTAMP	USER_HOST	#	1	Query	set global general_log= OFF
+TIMESTAMP	USER_HOST	#	1	Query	SET GLOBAL general_log='OFF'
 set global general_log= ON;
 flush logs;
 show global variables

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2011-02-22 05:37:44 +0000
+++ b/mysql-test/r/log_tables.result	2011-08-17 14:07:07 +0000
@@ -127,7 +127,7 @@ test
 ÔÅÓÔ
 select * from mysql.general_log;
 event_time	user_host	thread_id	server_id	command_type	argument
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set names binary
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET NAMES 'binary'
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select _koi8r'\xD4\xC5\xD3\xD4' as test
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
 set names utf8;
@@ -137,7 +137,7 @@ create table bug16905 (s char(15) charac
 insert into bug16905 values ('новое');
 select * from mysql.general_log;
 event_time	user_host	thread_id	server_id	command_type	argument
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set names utf8
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET NAMES 'utf8'
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table bug16905 (s char(15) character set utf8 default 'пусто')
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	insert into bug16905 values ('новое')
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
@@ -221,22 +221,22 @@ set global general_log='ON';
 set global slow_query_log='ON';
 select * from mysql.general_log;
 event_time	user_host	thread_id	server_id	command_type	argument
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set names utf8
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET NAMES 'utf8'
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table bug16905 (s char(15) character set utf8 default 'пусто')
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	insert into bug16905 values ('новÐrom mysql.general_log
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	drop table bug16905
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	truncate table mysql.slow_log
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set session long_query_time=1
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET SESSION long_query_time=1
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select sleep(2)
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.slow_log
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set @@session.long_query_time = @saved_long_query_time
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET SESSION long_query_time=(@saved_long_query_time)
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	alter table mysql.general_log engine=myisam
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	alter table mysql.slow_log engine=myisam
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	drop table mysql.general_log
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	drop table mysql.slow_log
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set global general_log='OFF'
-TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set global slow_query_log='ON'
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET GLOBAL general_log='OFF'
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SET GLOBAL slow_query_log='ON'
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
 flush logs;
 lock tables mysql.general_log WRITE;
@@ -674,112 +674,13 @@ execute long_query using @lparam;
 set global general_log = off;
 select command_type, argument from mysql.general_log where thread_id = @thread_id;
 command_type	argument
-Query	set global general_log = on
-Query	set @lparam = "000 001 002 003 004 005 006 007 008 009"
-              "010 011 012 013 014 015 016 017 018 019"
-              "020 021 022 023 024 025 026 027 028 029"
-              "030 031 032 033 034 035 036 037 038 039"
-              "040 041 042 043 044 045 046 047 048 049"
-              "050 051 052 053 054 055 056 057 058 059"
-              "060 061 062 063 064 065 066 067 068 069"
-              "070 071 072 073 074 075 076 077 078 079"
-              "080 081 082 083 084 085 086 087 088 089"
-              "090 091 092 093 094 095 096 097 098 099"
-              "100 101 102 103 104 105 106 107 108 109"
-              "110 111 112 113 114 115 116 117 118 119"
-              "120 121 122 123 124 125 126 127 128 129"
-              "130 131 132 133 134 135 136 137 138 139"
-              "140 141 142 143 144 145 146 147 148 149"
-              "150 151 152 153 154 155 156 157 158 159"
-              "160 161 162 163 164 165 166 167 168 169"
-              "170 171 172 173 174 175 176 177 178 179"
-              "180 181 182 183 184 185 186 187 188 189"
-              "190 191 192 193 194 195 196 197 198 199"
-              "200 201 202 203 204 205 206 207 208 209"
-              "210 211 212 213 214 215 216 217 218 219"
-              "220 221 222 223 224 225 226 227 228 229"
-              "230 231 232 233 234 235 236 237 238 239"
-              "240 241 242 243 244 245 246 247 248 249"
-              "250 251 252 253 254 255 256 257 258 259"
-              "260 261 262 263 264 265 266 267 268 269"
-              "270 271 272 273 274 275 276 277 278 279"
-              "280 281 282 283 284 285 286 287 288 289"
-              "290 291 292 293 294 295 296 297 298 299"
-              "300 301 302 303 304 305 306 307 308 309"
-              "310 311 312 313 314 315 316 317 318 319"
-              "320 321 322 323 324 325 326 327 328 329"
-              "330 331 332 333 334 335 336 337 338 339"
-              "340 341 342 343 344 345 346 347 348 349"
-              "350 351 352 353 354 355 356 357 358 359"
-              "360 361 362 363 364 365 366 367 368 369"
-              "370 371 372 373 374 375 376 377 378 379"
-              "380 381 382 383 384 385 386 387 388 389"
-              "390 391 392 393 394 395 396 397 398 399"
-              "400 401 402 403 404 405 406 407 408 409"
-              "410 411 412 413 414 415 416 417 418 419"
-              "420 421 422 423 424 425 426 427 428 429"
-              "430 431 432 433 434 435 436 437 438 439"
-              "440 441 442 443 444 445 446 447 448 449"
-              "450 451 452 453 454 455 456 457 458 459"
-              "460 461 462 463 464 465 466 467 468 469"
-              "470 471 472 473 474 475 476 477 478 479"
-              "480 481 482 483 484 485 486 487 488 489"
-              "490 491 492 493 494 495 496 497 498 499"
-              "500 501 502 503 504 505 506 507 508 509"
-              "510 511 512 513 514 515 516 517 518 519"
-              "520 521 522 523 524 525 526 527 528 529"
-              "530 531 532 533 534 535 536 537 538 539"
-              "540 541 542 543 544 545 546 547 548 549"
-              "550 551 552 553 554 555 556 557 558 559"
-              "560 561 562 563 564 565 566 567 568 569"
-              "570 571 572 573 574 575 576 577 578 579"
-              "580 581 582 583 584 585 586 587 588 589"
-              "590 591 592 593 594 595 596 597 598 599"
-              "600 601 602 603 604 605 606 607 608 609"
-              "610 611 612 613 614 615 616 617 618 619"
-              "620 621 622 623 624 625 626 627 628 629"
-              "630 631 632 633 634 635 636 637 638 639"
-              "640 641 642 643 644 645 646 647 648 649"
-              "650 651 652 653 654 655 656 657 658 659"
-              "660 661 662 663 664 665 666 667 668 669"
-              "670 671 672 673 674 675 676 677 678 679"
-              "680 681 682 683 684 685 686 687 688 689"
-              "690 691 692 693 694 695 696 697 698 699"
-              "700 701 702 703 704 705 706 707 708 709"
-              "710 711 712 713 714 715 716 717 718 719"
-              "720 721 722 723 724 725 726 727 728 729"
-              "730 731 732 733 734 735 736 737 738 739"
-              "740 741 742 743 744 745 746 747 748 749"
-              "750 751 752 753 754 755 756 757 758 759"
-              "760 761 762 763 764 765 766 767 768 769"
-              "770 771 772 773 774 775 776 777 778 779"
-              "780 781 782 783 784 785 786 787 788 789"
-              "790 791 792 793 794 795 796 797 798 799"
-              "800 801 802 803 804 805 806 807 808 809"
-              "810 811 812 813 814 815 816 817 818 819"
-              "820 821 822 823 824 825 826 827 828 829"
-              "830 831 832 833 834 835 836 837 838 839"
-              "840 841 842 843 844 845 846 847 848 849"
-              "850 851 852 853 854 855 856 857 858 859"
-              "860 861 862 863 864 865 866 867 868 869"
-              "870 871 872 873 874 875 876 877 878 879"
-              "880 881 882 883 884 885 886 887 888 889"
-              "890 891 892 893 894 895 896 897 898 899"
-              "900 901 902 903 904 905 906 907 908 909"
-              "910 911 912 913 914 915 916 917 918 919"
-              "920 921 922 923 924 925 926 927 928 929"
-              "930 931 932 933 934 935 936 937 938 939"
-              "940 941 942 943 944 945 946 947 948 949"
-              "950 951 952 953 954 955 956 957 958 959"
-              "960 961 962 963 964 965 966 967 968 969"
-              "970 971 972 973 974 975 976 977 978 979"
-              "980 981 982 983 984 985 986 987 988 989"
-              "990 991 992 993 994 995 996 997 998 999"
+Query	SET GLOBAL general_log='ON'
+Query	SET (@lparam:='000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 018 019020 021 022 023 024 025 026 027 028 029030 031 032 033 034 035 036 037 038 039040 041 042 043 044 045 046 047 048 049050 051 052 053 054 055 056 057 058 059060 061 062 063 064 065 066 067 068 069070 071 072 073 074 075 076 077 078 079080 081 082 083 084 085 086 087 088 089090 091 092 093 094 095 096 097 098 099100 101 102 103 104 105 106 107 108 109110 111 112 113 114 115 116 117 118 119120 121 122 123 124 125 126 127 128 129130 131 132 133 134 135 136 137 138 139140 141 142 143 144 145 146 147 148 149150 151 152 153 154 155 156 157 158 159160 161 162 163 164 165 166 167 168 169170 171 172 173 174 175 176 177 178 179180 181 182 183 184 185 186 187 188 189190 191 192 193 194 195 196 197 198 199200 201 202 203 204 205 206 207 208 209210 211 212 213 214 215 216 217 218 219220 221 222 223 224 225 226 227 228 229230 231 232 233 234 235 236 237 238 239240 241 242 243 244 245 246 247 248 249250 251 252 253 254 255 256 257 258 259260 261 262 263 264 265 266 267 268 269270 271 272 273 274 275 276 277 278 279280 281 282 283 284 285 286 287 288 289290 291 292 293 294 295 296 297 298 299300 301 302 303 304 305 306 307 308 309310 311 312 313 314 315 316 317 318 319320 321 322 323 324 325 326 327 328 329330 331 332 333 334 335 336 337 338 339340 341 342 343 344 345 346 347 348 349350 351 352 353 354 355 356 357 358 359360 361 362 363 364 365 366 367 368 369370 371 372 373 374 375 376 377 378 379380 381 382 383 384 385 386 387 388 389390 391 392 393 394 395 396 397 398 399400 401 402 403 404 405 406 407 408 409410 411 412 413 414 415 416 417 418 419420 421 422 423 424 425 426 427 428 429430 431 432 433 434 435 436 437 438 439440 441 442 443 444 445 446 447 448 449450 451 452 453 454 455 456 457 458 459460 461 462 463 464 465 466 467 468 469470 471 472 473 474 475 476 477 478 479480 481 482 483 484 485 486 487 488 489490 491 492 493 494 495 496 497 498 499500 501 502 503 504 505 506 507 508 509510 511 512 513 514 515 516 517 518 519520 521 522 523 524 525 526 527 528 529530 531 532 533 534 535 536 537 538 539540 541 542 543 544 545 546 547 548 549550 551 552 553 554 555 556 557 558 559560 561 562 563 564 565 566 567 568 569570 571 572 573 574 575 576 577 578 579580 581 582 583 584 585 586 587 588 589590 591 592 593 594 595 596 597 598 599600 601 602 603 604 605 606 607 608 609610 611 612 613 614 615 616 617 618 619620 621 622 623 624 625 626 627 628 629630 631 632 633 634 635 636 637 638 639640 641 642 643 644 645 646 647 648 649650 651 652 653 654 655 656 657 658 659660 661 662 663 664 665 666 667 668 669670 671 672 673 674 675 676 677 678 679680 681 682 683 684 685 686 687 688 689690 691 692 693 694 695 696 697 698 699700 701 702 703 704 705 706 707 708 709710 711 712 713 714 715 716 717 718 719720 721 722 723 724 725 726 727 728 729730 731 732 733 734 735 736 737 738 739740 741 742 743 744 745 746 747 748 749750 751 752 753 754 755 756 757 758 759760 761 762 763 764 765 766 767 768 769770 771 772 773 774 775 776 777 778 779780 781 782 783 784 785 786 787 788 789790 791 792 793 794 795 796 797 798 799800 801 802 803 804 805 806 807 808 809810 811 812 813 814 815 816 817 818 819820 821 822 823 824 825 826 827 828 829830 831 832 833 834 835 836 837 838 839840 841 842 843 844 845 846 847 848 849850 851 852 853 854 855 856 857 858 859860 861 862 863 864 865 866 867 868 869870 871 872 873 874 875 876 877 878 879880 881 882 883 884 885 886 887 888 889890 891 892 893 894 895 896 897 898 899900 901 902 903 904 905 906 907 908 909910 911 912 913 914 915 916 917 918 919920 921 922 923 924 925 926 927 928 929930 931 932 933 934 935 936 937 938 939940 941 942 943 944 945 946 947 948 949950 951 952 953 954 955 956 957 958 959960 961 962 963 964 965 966 967 968 969970 971 972 973 974 975 976 977 978 979980 981 982 983 984 985 986 987 988 989990 991 992 993 994 995 996 997 998 999')
 Query	prepare long_query from "select ? as long_query"
 Prepare	select ? as long_query
 Query	execute long_query using @lparam
 Execute	select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 018 019020 021 022 023 024 025 026 027 028 029030 031 032 033 034 035 036 037 038 039040 041 042 043 044 045 046 047 048 049050 051 052 053 054 055 056 057 058 059060 061 062 063 064 065 066 067 068 069070 071 072 073 074 075 076 077 078 079080 081 082 083 084 085 086 087 088 089090 091 092 093 094 095 096 097 098 099100 101 102 103 104 105 106 107 108 109110 111 112 113 114 115 116 117 118 119120 121 122 123 124 125 126 127 128 129130 131 132 133 134 135 136 137 138 139140 141 142 143 144 145 146 147 148 149150 151 152 153 154 155 156 157 158 159160 161 162 163 164 165 166 167 168 169170 171 172 173 174 175 176 177 178 179180 181 182 183 184 185 186 187 188 189190 191 192 193 194 195 196 197 198 199200 201 202 203 204 205 206 207 208 209210 211 212 213 214 215 216 217 218 219220 221 222 223 224 225 226 227 228 229230 231 232 233 234 235 236 237 238 239240 241 242 243 244 245 246 247 248 249250 251 252 253 254 255 256 257 258 259260 261 262 263 264 265 266 267 268 269270 271 272 273 274 275 276 277 278 279280 281 282 283 284 285 286 287 288 289290 291 292 293 294 295 296 297 298 299300 301 302 303 304 305 306 307 308 309310 311 312 313 314 315 316 317 318 319320 321 322 323 324 325 326 327 328 329330 331 332 333 334 335 336 337 338 339340 341 342 343 344 345 346 347 348 349350 351 352 353 354 355 356 357 358 359360 361 362 363 364 365 366 367 368 369370 371 372 373 374 375 376 377 378 379380 381 382 383 384 385 386 387 388 389390 391 392 393 394 395 396 397 398 399400 401 402 403 404 405 406 407 408 409410 411 412 413 414 415 416 417 418 419420 421 422 423 424 425 426 427 428 429430 431 432 433 434 435 436 437 438 439440 441 442 443 444 445 446 447 448 449450 451 452 453 454 455 456 457 458 459460 461 462 463 464 465 466 467 468 469470 471 472 473 474 475 476 477 478 479480 481 482 483 484 485 486 487 488 489490 491 492 493 494 495 496 497 498 499500 501 502 503 504 505 506 507 508 509510 511 512 513 514 515 516 517 518 519520 521 522 523 524 525 526 527 528 529530 531 532 533 534 535 536 537 538 539540 541 542 543 544 545 546 547 548 549550 551 552 553 554 555 556 557 558 559560 561 562 563 564 565 566 567 568 569570 571 572 573 574 575 576 577 578 579580 581 582 583 584 585 586 587 588 589590 591 592 593 594 595 596 597 598 599600 601 602 603 604 605 606 607 608 609610 611 612 613 614 615 616 617 618 619620 621 622 623 624 625 626 627 628 629630 631 632 633 634 635 636 637 638 639640 641 642 643 644 645 646 647 648 649650 651 652 653 654 655 656 657 658 659660 661 662 663 664 665 666 667 668 669670 671 672 673 674 675 676 677 678 679680 681 682 683 684 685 686 687 688 689690 691 692 693 694 695 696 697 698 699700 701 702 703 704 705 706 707 708 709710 711 712 713 714 715 716 717 718 719720 721 722 723 724 725 726 727 728 729730 731 732 733 734 735 736 737 738 739740 741 742 743 744 745 746 747 748 749750 751 752 753 754 755 756 757 758 759760 761 762 763 764 765 766 767 768 769770 771 772 773 774 775 776 777 778 779780 781 782 783 784 785 786 787 788 789790 791 792 793 794 795 796 797 798 799800 801 802 803 804 805 806 807 808 809810 811 812 813 814 815 816 817 818 819820 821 822 823 824 825 826 827 828 829830 831 832 833 834 835 836 837 838 839840 841 842 843 844 845 846 847 848 849850 851 852 853 854 855 856 857 858 859860 861 862 863 864 865 866 867 868 869870 871 872 873 874 875 876 877 878 879880 881 882 883 884 885 886 887 888 889890 891 892 893 894 895 896 897 898 899900 901 902 903 904 905 906 907 908 909910 911 912 913 914 915 916 917 918 919920 921 922 923 924 925 926 927 928 929930 931 932 933 934 935 936 937 938 939940 941 942 943 944 945 946 947 948 949950 951 952 953 954 955 956 957 958 959960 961 962 963 964 965 966 967 968 969970 971 972 973 974 975 976 977 978 979980 981 982 983 984 985 986 987 988 989990 991 992 993 994 995 996 997 998 999' as long_query
-Query	set global general_log = off
+Query	SET GLOBAL general_log='off'
 deallocate prepare long_query;
 set global general_log = @old_general_log;
 DROP TABLE IF EXISTS log_count;

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2011-08-18 08:31:08 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2011-08-18 18:05:45 +0000
@@ -258,6 +258,9 @@ The following options may be given as th
  --log-queries-not-using-indexes 
  Log queries that are executed without benefit of any
  index to the slow log if it is open
+ --log-raw           Log to general log before any rewriting of the query. For
+ use in debugging, not production as sensitive information
+ may be logged.
  --log-short-format  Don't log extra information to update and slow-query
  logs.
  --log-slave-updates Tells the slave to log the updates from the slave thread
@@ -875,6 +878,7 @@ log-error 
 log-isam myisam.log
 log-output FILE
 log-queries-not-using-indexes FALSE
+log-raw FALSE
 log-short-format FALSE
 log-slave-updates FALSE
 log-slow-admin-statements FALSE

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2011-08-18 08:31:08 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2011-08-18 18:05:45 +0000
@@ -257,6 +257,9 @@ The following options may be given as th
  --log-queries-not-using-indexes 
  Log queries that are executed without benefit of any
  index to the slow log if it is open
+ --log-raw           Log to general log before any rewriting of the query. For
+ use in debugging, not production as sensitive information
+ may be logged.
  --log-short-format  Don't log extra information to update and slow-query
  logs.
  --log-slave-updates Tells the slave to log the updates from the slave thread
@@ -878,6 +881,7 @@ log-error 
 log-isam myisam.log
 log-output FILE
 log-queries-not-using-indexes FALSE
+log-raw FALSE
 log-short-format FALSE
 log-slave-updates FALSE
 log-slow-admin-statements FALSE

=== modified file 'mysql-test/r/plugin_auth.result'
--- a/mysql-test/r/plugin_auth.result	2011-07-07 09:45:10 +0000
+++ b/mysql-test/r/plugin_auth.result	2011-08-17 14:07:07 +0000
@@ -4,6 +4,10 @@ FROM INFORMATION_SCHEMA.PLUGINS WHERE PL
 PLUGIN_STATUS	ACTIVE
 PLUGIN_TYPE	AUTHENTICATION
 PLUGIN_DESCRIPTION	plugin API test plugin
+SET @old_log_output=          @@global.log_output;
+SET @old_general_log=         @@global.general_log;
+SET GLOBAL log_output =       'TABLE';
+SET GLOBAL general_log=       'ON';
 CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
 CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
 SELECT plugin,authentication_string FROM mysql.user WHERE User='plug';
@@ -227,9 +231,23 @@ SELECT @@LOCAL.external_user;
 @@LOCAL.external_user
 'plug'@'%'
 # in connection default
+WL#5706 -- show the above got logged/rewritten correctly
+SELECT argument FROM mysql.general_log WHERE argument LIKE CONCAT('% IDENTIFIED ','WITH%');
+argument
+CREATE USER 'plug'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+GRANT INSERT ON `TEST`.* TO 'grant_user'@'%' IDENTIFIED WITH 'test_plugin_server'
+CREATE USER 'Ÿ'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+GRANT ALL PRIVILEGES ON `test_grant_db`.* TO 'new_grant_user'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+GRANT ALL PRIVILEGES ON `test_grant_db`.* TO 'plug'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+GRANT ALL PRIVILEGES ON `test_grant_db`.* TO 'plug_dest'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+CREATE USER 'grant_plug'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'grant_plug_dest'
+CREATE USER 'plug'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+CREATE USER 'plug'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
 ## cleanup
 DROP USER plug;
 DROP USER plug_dest;
+SET GLOBAL log_output=  @old_log_output;
+SET GLOBAL general_log= @old_general_log;
 ## END @@external_user tests
 #
 #  Bug #56798 : Wrong credentials assigned when using a proxy user.

=== added file 'mysql-test/r/rewrite_general_log.result'
--- a/mysql-test/r/rewrite_general_log.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/rewrite_general_log.result	2011-08-19 00:45:28 +0000
@@ -0,0 +1,62 @@
+TRUNCATE TABLE mysql.general_log;
+--------------- general log ---------------------------------------
+SET @old_log_output=          @@global.log_output;
+SET @old_general_log=         @@global.general_log;
+SET @old_general_log_file=    @@global.general_log_file;
+SET GLOBAL general_log_file = '.../log/rewrite_general.log';
+SET GLOBAL log_output =       'FILE,TABLE';
+SET GLOBAL general_log=       'ON';
+set character set 'hebrew';
+set charset default,@dummy='A';
+set names 'latin1',@dummy='B';
+set names 'latin1' collate 'latin1_german2_ci';
+set names default,@dummy='c';
+GRANT ALL on *.* TO test_user1 IDENTIFIED BY 'azundris1';
+CREATE USER test_user2 IDENTIFIED BY 'azundris2';
+CHANGE MASTER TO MASTER_PASSWORD='azundris3';
+CREATE USER 'test_user4'@'localhost';
+SET PASSWORD FOR 'test_user4'@'localhost' = PASSWORD('azundris4');
+SET GLOBAL general_log=       'OFF';
+DROP USER 'test_user4'@'localhost';
+DROP USER test_user2;
+DROP USER test_user1;
+CREATE TABLE test_log (argument TEXT);
+LOAD DATA LOCAL INFILE '.../log/rewrite_general.log'
+     INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
+This line should be followed by two SELECTs with empty result sets
+SELECT argument FROM test_log WHERE argument LIKE CONCAT('%azun','dris%');
+argument
+SELECT argument FROM mysql.general_log WHERE argument LIKE CONCAT('%azun','dris%');
+argument
+Show that we logged stuff at all:
+------ from file ------
+SELECT TRIM(LEADING '\t' FROM MID(argument,LOCATE('Query',argument)+5)) FROM test_log WHERE argument LIKE '%PASSWORD %';
+TRIM(LEADING '\t' FROM MID(argument,LOCATE('Query',argument)+5))
+GRANT ALL PRIVILEGES ON *.* TO 'test_user1'@'%' IDENTIFIED BY PASSWORD '*8D15E74BC850D11573A52BE84B504DD0BA40C1E3'
+CREATE USER 'test_user2'@'%' IDENTIFIED BY PASSWORD '*A142844DBF024D282D88FE19CB4D3FA13B1E96E0'
+CHANGE MASTER TO MASTER_PASSWORD = <secret>
+SET PASSWORD FOR `test_user4`@`localhost`=<secret>
+------ from table ------
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%PASSWORD %';
+argument
+GRANT ALL PRIVILEGES ON *.* TO 'test_user1'@'%' IDENTIFIED BY PASSWORD '*8D15E74BC850D11573A52BE84B504DD0BA40C1E3'
+CREATE USER 'test_user2'@'%' IDENTIFIED BY PASSWORD '*A142844DBF024D282D88FE19CB4D3FA13B1E96E0'
+CHANGE MASTER TO MASTER_PASSWORD = <secret>
+SET PASSWORD FOR `test_user4`@`localhost`=<secret>
+------ done ------
+------ rewrite ------
+SELECT argument FROM mysql.general_log WHERE argument LIKE 'SET CHARACTER SET %';
+argument
+SET CHARACTER SET 'hebrew'
+SET CHARACTER SET DEFAULT,(@dummy:='A')
+SELECT argument FROM mysql.general_log WHERE argument LIKE 'SET NAMES %';
+argument
+SET NAMES 'latin1',(@dummy:='B')
+SET NAMES 'latin1' COLLATE 'latin1_german2_ci'
+SET NAMES DEFAULT,(@dummy:='c')
+------ done ------ see log_tables.test for more proof! :)
+DROP TABLE test_log;
+SET GLOBAL general_log_file=  @old_general_log_file;
+SET GLOBAL general_log=       @old_general_log;
+SET GLOBAL log_output=        @old_log_output;
+End of 5.6 tests!

=== added file 'mysql-test/r/rewrite_slow_log.result'
--- a/mysql-test/r/rewrite_slow_log.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/rewrite_slow_log.result	2011-08-19 00:45:28 +0000
@@ -0,0 +1,61 @@
+TRUNCATE TABLE mysql.slow_log;
+SET @old_log_output=          @@global.log_output;
+SET @old_slow_query_log=      @@global.slow_query_log;
+SET @old_slow_query_log_file= @@global.slow_query_log_file;
+SET @old_long_query_time=     @@global.long_query_time;
+SET GLOBAL slow_query_log_file= '.../log/rewrite_slow.log';
+SET GLOBAL log_output =       'FILE,TABLE';
+SET GLOBAL slow_query_log=    'ON';
+SET SESSION long_query_time=  0;
+GRANT ALL on *.* TO test_user1 IDENTIFIED BY 'azundris1';
+CREATE USER test_user2 IDENTIFIED BY 'azundris2';
+CHANGE MASTER TO MASTER_PASSWORD='azundris3';
+CHANGE MASTER TO MASTER_CONNECT_RETRY = 1, MASTER_HEARTBEAT_PERIOD = 1.01,
+MASTER_LOG_FILE = 'master_log_name', MASTER_LOG_POS = 0,
+MASTER_SSL = 0, MASTER_SSL_CA = 'ca_file_name',
+MASTER_SSL_CAPATH = 'ca_directory_name',
+MASTER_SSL_CERT = 'cert_file_name', MASTER_SSL_KEY = 'key_file_name',
+MASTER_SSL_CIPHER = 'cipher_list', MASTER_SSL_VERIFY_SERVER_CERT = 0,
+IGNORE_SERVER_IDS = (99,100);
+CHANGE MASTER TO MASTER_CONNECT_RETRY = 1, MASTER_HEARTBEAT_PERIOD = 1.01,
+MASTER_LOG_FILE = '', MASTER_LOG_POS = 0,
+MASTER_SSL = 0, MASTER_SSL_CA = '',
+MASTER_SSL_CAPATH = '',
+MASTER_SSL_CERT = '', MASTER_SSL_KEY = '',
+MASTER_SSL_CIPHER = '', MASTER_SSL_VERIFY_SERVER_CERT = 0,
+IGNORE_SERVER_IDS = ( );
+CREATE USER 'test_user4'@'localhost';
+SET PASSWORD FOR 'test_user4'@'localhost' = PASSWORD('azundris4');
+SET SESSION long_query_time=  @old_long_query_time;
+SET GLOBAL slow_query_log='OFF';
+DROP USER 'test_user4'@'localhost';
+DROP USER test_user2;
+DROP USER test_user1;
+CREATE TABLE test_log (sql_text TEXT);
+LOAD DATA LOCAL INFILE '.../log/rewrite_slow.log'
+     INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
+This line should be followed by two SELECTs with empty result sets
+SELECT sql_text FROM test_log WHERE sql_text LIKE CONCAT('%azun','dris%');
+sql_text
+SELECT sql_text FROM mysql.slow_log WHERE sql_text LIKE CONCAT('%azun','dris%');
+sql_text
+------ from file ------
+SELECT sql_text FROM test_log WHERE sql_text like '%PASSWORD %';
+sql_text
+GRANT ALL PRIVILEGES ON *.* TO 'test_user1'@'%' IDENTIFIED BY PASSWORD '*8D15E74BC850D11573A52BE84B504DD0BA40C1E3';
+CREATE USER 'test_user2'@'%' IDENTIFIED BY PASSWORD '*A142844DBF024D282D88FE19CB4D3FA13B1E96E0';
+CHANGE MASTER TO MASTER_PASSWORD = <secret>;
+SET PASSWORD FOR `test_user4`@`localhost`=<secret>;
+------ from table ------
+SELECT sql_text FROM mysql.slow_log WHERE sql_text like '%PASSWORD %';
+sql_text
+GRANT ALL PRIVILEGES ON *.* TO 'test_user1'@'%' IDENTIFIED BY PASSWORD '*8D15E74BC850D11573A52BE84B504DD0BA40C1E3'
+CREATE USER 'test_user2'@'%' IDENTIFIED BY PASSWORD '*A142844DBF024D282D88FE19CB4D3FA13B1E96E0'
+CHANGE MASTER TO MASTER_PASSWORD = <secret>
+SET PASSWORD FOR `test_user4`@`localhost`=<secret>
+------ done ------
+DROP TABLE test_log;
+SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
+SET GLOBAL slow_query_log=      @old_slow_query_log;
+SET GLOBAL log_output=          @old_log_output;
+End of 5.6 tests!

=== added file 'mysql-test/suite/binlog/r/binlog_rewrite.result'
--- a/mysql-test/suite/binlog/r/binlog_rewrite.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_rewrite.result	2011-08-17 14:07:07 +0000
@@ -0,0 +1,63 @@
+RESET MASTER;
+CREATE USER user1@localhost IDENTIFIED BY 'secret';
+CREATE USER user2@localhost IDENTIFIED BY 'secret';
+SET PASSWORD FOR user1@localhost = PASSWORD('secret');
+# Test the password is encrypted in binary log
+# when granting privileges on tables.
+GRANT UPDATE ON *.* TO user1@localhost IDENTIFIED BY 'secret' WITH GRANT OPTION;
+GRANT UPDATE ON *.* /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+GRANT UPDATE ON *.* /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before require*/REQUIRE SSL/*after require*/ /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+GRANT UPDATE ON *.* TO user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2';
+REVOKE UPDATE ON *.* FROM user1@localhost, user2@localhost;
+# Test the password is encrypted in binary log
+# when granting privileges on procedure.
+CREATE PROCEDURE p1() SQL SECURITY INVOKER SELECT 1;
+GRANT EXECUTE ON PROCEDURE p1 TO user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before with*/ WITH MAX_QUERIES_PER_HOUR 90;
+GRANT EXECUTE ON PROCEDURE p1 /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before require*/REQUIRE SSL/*after require*/ /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+GRANT EXECUTE ON PROCEDURE p1 TO user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2';
+REVOKE EXECUTE ON PROCEDURE p1 FROM user1@localhost, user2@localhost;
+# Test the password is encrypted in binary log
+# when granting privileges on function.
+CREATE FUNCTION f1() RETURNS INT RETURN 123;
+GRANT EXECUTE ON FUNCTION f1 /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret' /*!10000 , user2@localhost IDENTIFIED BY 'secret2' */ /*!99999 THIS_WOULD_BREAK */ /*before require*/REQUIRE SSL/*after require*/ /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+REVOKE EXECUTE ON FUNCTION f1 FROM user1@localhost, user2@localhost;
+DROP USER user1@localhost, user2@localhost;
+DROP FUNCTION f1;
+DROP PROCEDURE p1;
+GRANT ALL on *.* TO test_user1 IDENTIFIED BY 'azundris1';
+CREATE USER test_user2 IDENTIFIED BY 'azundris2';
+CHANGE MASTER TO MASTER_PASSWORD='azundris3';
+CREATE USER 'test_user4'@'localhost';
+SET PASSWORD FOR 'test_user4'@'localhost' = PASSWORD('azundris4');
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7'
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'user2'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7'
+master-bin.000001	#	Query	#	#	use `test`; SET PASSWORD FOR 'user1'@'localhost'='*14E65567ABDB5135D0CFD9A70B3032C179A49EE7'
+master-bin.000001	#	Query	#	#	use `test`; GRANT UPDATE ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7' WITH GRANT OPTION
+master-bin.000001	#	Query	#	#	use `test`; GRANT UPDATE ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F' WITH MAX_QUERIES_PER_HOUR 90
+master-bin.000001	#	Query	#	#	use `test`; GRANT UPDATE ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F' REQUIRE SSL WITH MAX_QUERIES_PER_HOUR 90
+master-bin.000001	#	Query	#	#	use `test`; GRANT UPDATE ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F'
+master-bin.000001	#	Query	#	#	use `test`; REVOKE UPDATE ON *.* FROM user1@localhost, user2@localhost
+master-bin.000001	#	Query	#	#	use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
+    SQL SECURITY INVOKER
+SELECT 1
+master-bin.000001	#	Query	#	#	use `test`; GRANT EXECUTE ON PROCEDURE `test`.`p1` TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F' WITH MAX_QUERIES_PER_HOUR 90
+master-bin.000001	#	Query	#	#	use `test`; GRANT EXECUTE ON PROCEDURE `test`.`p1` TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F' REQUIRE SSL WITH MAX_QUERIES_PER_HOUR 90
+master-bin.000001	#	Query	#	#	use `test`; GRANT EXECUTE ON PROCEDURE `test`.`p1` TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F'
+master-bin.000001	#	Query	#	#	use `test`; REVOKE EXECUTE ON PROCEDURE p1 FROM user1@localhost, user2@localhost
+master-bin.000001	#	Query	#	#	use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
+RETURN 123
+master-bin.000001	#	Query	#	#	use `test`; GRANT EXECUTE ON FUNCTION `test`.`f1` TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7','user2'@'localhost' IDENTIFIED BY PASSWORD '*305D7BCA9D65D8D5C4677F05CD2EA2EBE350158F' REQUIRE SSL WITH MAX_QUERIES_PER_HOUR 90
+master-bin.000001	#	Query	#	#	use `test`; REVOKE EXECUTE ON FUNCTION f1 FROM user1@localhost, user2@localhost
+master-bin.000001	#	Query	#	#	use `test`; DROP USER user1@localhost, user2@localhost
+master-bin.000001	#	Query	#	#	use `test`; DROP FUNCTION f1
+master-bin.000001	#	Query	#	#	use `test`; DROP PROCEDURE p1
+master-bin.000001	#	Query	#	#	use `test`; GRANT ALL PRIVILEGES ON *.* TO 'test_user1'@'%' IDENTIFIED BY PASSWORD '*8D15E74BC850D11573A52BE84B504DD0BA40C1E3'
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'test_user2'@'%' IDENTIFIED BY PASSWORD '*A142844DBF024D282D88FE19CB4D3FA13B1E96E0'
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'test_user4'@'localhost'
+master-bin.000001	#	Query	#	#	use `test`; SET PASSWORD FOR 'test_user4'@'localhost'='*F62B91C8AD3D5D0BBF02A761A179EA3A66B060EC'
+DROP USER 'test_user4'@'localhost';
+DROP USER test_user2;
+DROP USER test_user1;
+End of 5.6 tests!

=== added file 'mysql-test/suite/binlog/t/binlog_rewrite.test'
--- a/mysql-test/suite/binlog/t/binlog_rewrite.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_rewrite.test	2011-08-17 14:07:07 +0000
@@ -0,0 +1,67 @@
+#
+# WL#5706/Bug#58712/Bug#11746378
+# Encrypt or remove passwords from slow, query, and binary logs
+# (see sql/sql_rewrite.cc for bulk of implementation)
+#
+
+-- source include/have_log_bin.inc
+
+RESET MASTER;
+
+#--------------- bin log -------------------------------------------
+
+# misc rewrites.
+
+# Show that when we completely re-synthesize commands,
+# we get all the particles right!
+
+CREATE USER user1@localhost IDENTIFIED BY 'secret';
+CREATE USER user2@localhost IDENTIFIED BY 'secret';
+SET PASSWORD FOR user1@localhost = PASSWORD('secret');
+
+--echo # Test the password is encrypted in binary log
+--echo # when granting privileges on tables.
+GRANT UPDATE ON *.* TO user1@localhost IDENTIFIED BY 'secret' WITH GRANT OPTION;
+GRANT UPDATE ON *.* /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+GRANT UPDATE ON *.* /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before require*/REQUIRE SSL/*after require*/ /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+GRANT UPDATE ON *.* TO user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2';
+REVOKE UPDATE ON *.* FROM user1@localhost, user2@localhost;
+
+--echo # Test the password is encrypted in binary log
+--echo # when granting privileges on procedure.
+CREATE PROCEDURE p1() SQL SECURITY INVOKER SELECT 1;
+GRANT EXECUTE ON PROCEDURE p1 TO user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before with*/ WITH MAX_QUERIES_PER_HOUR 90;
+GRANT EXECUTE ON PROCEDURE p1 /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2' /*before require*/REQUIRE SSL/*after require*/ /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+GRANT EXECUTE ON PROCEDURE p1 TO user1@localhost IDENTIFIED BY 'secret', user2@localhost IDENTIFIED BY 'secret2';
+REVOKE EXECUTE ON PROCEDURE p1 FROM user1@localhost, user2@localhost;
+
+--echo # Test the password is encrypted in binary log
+--echo # when granting privileges on function.
+CREATE FUNCTION f1() RETURNS INT RETURN 123;
+GRANT EXECUTE ON FUNCTION f1 /*before to*/TO/*after to*/ user1@localhost IDENTIFIED BY 'secret' /*!10000 , user2@localhost IDENTIFIED BY 'secret2' */ /*!99999 THIS_WOULD_BREAK */ /*before require*/REQUIRE SSL/*after require*/ /*before with*/WITH/*after with*/MAX_QUERIES_PER_HOUR 90;
+REVOKE EXECUTE ON FUNCTION f1 FROM user1@localhost, user2@localhost;
+
+DROP USER user1@localhost, user2@localhost;
+DROP FUNCTION f1;
+DROP PROCEDURE p1;
+
+# 1.1.1.1
+GRANT ALL on *.* TO test_user1 IDENTIFIED BY 'azundris1';
+
+# 1.1.1.2
+CREATE USER test_user2 IDENTIFIED BY 'azundris2';
+
+# 1.1.1.3
+CHANGE MASTER TO MASTER_PASSWORD='azundris3';
+
+# 1.1.1.4
+CREATE USER 'test_user4'@'localhost';
+SET PASSWORD FOR 'test_user4'@'localhost' = PASSWORD('azundris4');
+
+--source include/show_binlog_events.inc
+
+DROP USER 'test_user4'@'localhost';
+DROP USER test_user2;
+DROP USER test_user1;
+
+--echo End of 5.6 tests!

=== modified file 'mysql-test/suite/rpl/r/rpl_do_grant.result'
--- a/mysql-test/suite/rpl/r/rpl_do_grant.result	2010-12-21 12:19:48 +0000
+++ b/mysql-test/suite/rpl/r/rpl_do_grant.result	2011-08-17 14:07:07 +0000
@@ -239,7 +239,7 @@ revoke all privileges, grant option from
 ERROR HY000: Can't revoke all privileges for one or more of the requested users
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; grant all on *.* to foo@"1.2.3.4"
+master-bin.000001	#	Query	#	#	use `test`; GRANT ALL PRIVILEGES ON *.* TO 'foo'@'1.2.3.4'
 include/check_slave_no_error.inc
 DROP USER foo@"1.2.3.4";
 

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result	2011-08-17 14:07:07 +0000
@@ -137,7 +137,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(ddl_case) VALUES (32)
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
-master-bin.000001	#	Query	#	#	use `test`; GRANT ALL ON *.* TO 'user'@'localhost'
+master-bin.000001	#	Query	#	#	use `test`; GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'
 -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
 
 -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-

=== modified file 'mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result'
--- a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result	2011-08-17 14:07:07 +0000
@@ -147,7 +147,7 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
-master-bin.000001	#	Query	#	#	use `test`; GRANT ALL ON *.* TO 'user'@'localhost'
+master-bin.000001	#	Query	#	#	use `test`; GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'
 -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
 
 -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-

=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
--- a/mysql-test/suite/rpl/r/rpl_sp.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_sp.result	2011-08-17 14:07:07 +0000
@@ -432,7 +432,7 @@ master-bin.000001	#	Query	#	#	use `mysql
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `foo3`()
     DETERMINISTIC
 insert into t1 values (15)
-master-bin.000001	#	Query	#	#	use `mysqltest1`; grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1
+master-bin.000001	#	Query	#	#	use `mysqltest1`; GRANT EXECUTE, CREATE ROUTINE ON `mysqltest1`.* TO 'zedjzlcsjhd'@'127.0.0.1'
 master-bin.000001	#	Query	#	#	use `mysqltest1`; grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1
 master-bin.000001	#	Query	#	#	use `mysqltest1`; grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` PROCEDURE `foo4`()
@@ -732,7 +732,7 @@ CREATE DEFINER=`root`@`localhost` PROCED
 insert into t1 values (15)
 /*!*/;
 SET TIMESTAMP=t/*!*/;
-grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1
+GRANT EXECUTE, CREATE ROUTINE ON `mysqltest1`.* TO 'zedjzlcsjhd'@'127.0.0.1'
 /*!*/;
 SET TIMESTAMP=t/*!*/;
 grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result	2011-08-17 14:07:07 +0000
@@ -137,7 +137,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(ddl_case) VALUES (32)
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
-master-bin.000001	#	Query	#	#	use `test`; GRANT ALL ON *.* TO 'user'@'localhost'
+master-bin.000001	#	Query	#	#	use `test`; GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'
 -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
 
 -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-

=== modified file 'mysql-test/suite/rpl/r/rpl_user.result'
--- a/mysql-test/suite/rpl/r/rpl_user.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_user.result	2011-08-17 14:07:07 +0000
@@ -45,8 +45,8 @@ Host	User
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'foo'@'fakehost'
-master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'foo'@'fakehost', 'bar'@'fakehost'
-master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'foo1'@'fakehost' IDENTIFIED BY PASSWORD '*6EAC5249D53050AE649BDB0CC4B85D1AE90CA16E', 'foo2'@'fakehost' IDENTIFIED BY PASSWORD '*1111111111111111111111111111111111111111', 'foo3'@'fakehost'
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'foo'@'fakehost','bar'@'fakehost'
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'foo1'@'fakehost' IDENTIFIED BY PASSWORD '*6EAC5249D53050AE649BDB0CC4B85D1AE90CA16E','foo2'@'fakehost' IDENTIFIED BY PASSWORD '*1111111111111111111111111111111111111111','foo3'@'fakehost'
 master-bin.000001	#	Query	#	#	use `test`; rename user 'foo'@'fakehost' to 'foofoo'@'fakehost'
 master-bin.000001	#	Query	#	#	use `test`; rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost'
 master-bin.000001	#	Query	#	#	use `test`; drop user 'foofoo'@'fakehost'

=== modified file 'mysql-test/suite/rpl/t/rpl_grant_plugin.test'
--- a/mysql-test/suite/rpl/t/rpl_grant_plugin.test	2011-02-15 10:57:05 +0000
+++ b/mysql-test/suite/rpl/t/rpl_grant_plugin.test	2011-08-17 14:07:07 +0000
@@ -29,7 +29,7 @@
 -- sync_slave_with_master
 -- connection master
 
---let $query= GRANT ALL ON test.* TO 'b59708_user2'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'CN=analyst, OU=division1, O=oracle, C=US'
+--let $query= GRANT ALL PRIVILEGES ON `test`.* TO 'b59708_user2'@'%' IDENTIFIED WITH 'test_plugin_server' AS 'CN=analyst, OU=division1, O=oracle, C=US'
 --let $binlog_position= query_get_value("SHOW MASTER STATUS", Position, 1)
 --eval $query
 --let $logged_query= query_get_value(SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_position , Info, 1)

=== added file 'mysql-test/t/audit_plugin-master.opt'
--- a/mysql-test/t/audit_plugin-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/audit_plugin-master.opt	2011-08-17 15:11:11 +0000
@@ -0,0 +1,2 @@
+$AUDIT_NULL_OPT
+

=== added file 'mysql-test/t/audit_plugin.test'
--- a/mysql-test/t/audit_plugin.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/audit_plugin.test	2011-08-17 15:11:11 +0000
@@ -0,0 +1,71 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2 of
+# the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301  USA
+
+# Test for WL#3771 (audit null plugin)
+# Created by HHunger 2009-09-02
+#
+
+--source include/not_embedded.inc
+
+# Adjustment to the OS dependent extension of shared libraries.
+let $expected_extension= so;
+if(`SELECT CONVERT(@@version_compile_os USING latin1)
+           IN ("Win32","Win64","Windows")`)
+{
+   let $expected_extension= dll;
+}
+
+# Adjustment to the fact that protocols which lead to the use
+# of prepared statements cause that a higher number of
+# plugin calls gets counted.
+let $expected_calls= 21;
+if(`SELECT $PS_PROTOCOL > 0`)
+{
+   let $expected_calls= 46;
+}
+if(`SELECT $SP_PROTOCOL > 0`)
+{
+   let $expected_calls= 66;
+}
+if(`SELECT $CURSOR_PROTOCOL > 0`)
+{
+   let $expected_calls= 48;
+}
+if(`SELECT $VIEW_PROTOCOL > 0`)
+{
+   let $expected_calls= 30;
+}
+
+--replace_result $expected_extension  <expected_extension>
+--error ER_CANT_FIND_DL_ENTRY
+eval INSTALL PLUGIN audit_null SONAME 'adt_null.$expected_extension';
+--replace_result $expected_extension <expected_extension>
+eval INSTALL PLUGIN null_audit SONAME 'adt_null.$expected_extension';
+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 (c1 INT, c2 CHAR(20));
+INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
+SELECT * FROM t1;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t2;
+DROP TABLE t1;
+--replace_result $expected_calls <expected_number_of_calls>
+SHOW STATUS LIKE 'audit_null_called';
+--error ER_SP_DOES_NOT_EXIST
+UNINSTALL PLUGIN audit_null;
+UNINSTALL PLUGIN null_audit;
+

=== modified file 'mysql-test/t/plugin_auth.test'
--- a/mysql-test/t/plugin_auth.test	2011-07-07 09:45:10 +0000
+++ b/mysql-test/t/plugin_auth.test	2011-08-17 14:07:07 +0000
@@ -6,6 +6,12 @@ CALL mtr.add_suppression("Plugin test_pl
 query_vertical SELECT PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_DESCRIPTION
   FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='test_plugin_server';
 
+SET @old_log_output=          @@global.log_output;
+SET @old_general_log=         @@global.general_log;
+
+SET GLOBAL log_output =       'TABLE';
+SET GLOBAL general_log=       'ON';
+
 CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
 CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
 
@@ -299,9 +305,15 @@ connection default;
 --echo # in connection default
 disconnect plug_con;
 
+--echo WL#5706 -- show the above got logged/rewritten correctly
+SELECT argument FROM mysql.general_log WHERE argument LIKE CONCAT('% IDENTIFIED ','WITH%');
+
 --echo ## cleanup
 DROP USER plug;
 DROP USER plug_dest;
+
+SET GLOBAL log_output=  @old_log_output;
+SET GLOBAL general_log= @old_general_log;
 --echo ## END @@external_user tests
 
 --echo #

=== added file 'mysql-test/t/rewrite_general_log.test'
--- a/mysql-test/t/rewrite_general_log.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/rewrite_general_log.test	2011-08-19 00:45:28 +0000
@@ -0,0 +1,83 @@
+#
+# WL#5706/Bug#58712/Bug#11746378
+# Encrypt or remove passwords from slow, query, and binary logs
+# (see sql/sql_rewrite.cc for bulk of implementation)
+#
+
+# make sure we start with a clean slate. log_tables.test says this is OK.
+TRUNCATE TABLE mysql.general_log;
+
+--echo --------------- general log ---------------------------------------
+
+SET @old_log_output=          @@global.log_output;
+SET @old_general_log=         @@global.general_log;
+SET @old_general_log_file=    @@global.general_log_file;
+
+--replace_result $MYSQLTEST_VARDIR ...
+eval SET GLOBAL general_log_file = '$MYSQLTEST_VARDIR/log/rewrite_general.log';
+SET GLOBAL log_output =       'FILE,TABLE';
+SET GLOBAL general_log=       'ON';
+
+# SET NAMES / SET CHARSET
+# keep these in lower case we can tell them from the upper case rewrites!
+set character set 'hebrew';
+set charset default,@dummy='A';
+set names 'latin1',@dummy='B';
+set names 'latin1' collate 'latin1_german2_ci';
+set names default,@dummy='c';
+
+# 1.1.1.1
+GRANT ALL on *.* TO test_user1 IDENTIFIED BY 'azundris1';
+
+# 1.1.1.2
+CREATE USER test_user2 IDENTIFIED BY 'azundris2';
+
+# 1.1.1.3
+CHANGE MASTER TO MASTER_PASSWORD='azundris3';
+
+# 1.1.1.4
+CREATE USER 'test_user4'@'localhost';
+SET PASSWORD FOR 'test_user4'@'localhost' = PASSWORD('azundris4');
+
+# clean-up
+SET GLOBAL general_log=       'OFF';
+
+DROP USER 'test_user4'@'localhost';
+DROP USER test_user2;
+DROP USER test_user1;
+
+# show general-logging to file is correct
+CREATE TABLE test_log (argument TEXT);
+--replace_result $MYSQLTEST_VARDIR ...
+eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/log/rewrite_general.log'
+     INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
+
+# all passwords ('azundris%') must have been obfuscated -> empty result set
+--echo This line should be followed by two SELECTs with empty result sets
+--replace_regex /.*Query	*//i
+SELECT argument FROM test_log WHERE argument LIKE CONCAT('%azun','dris%');
+
+# same for logging to table
+SELECT argument FROM mysql.general_log WHERE argument LIKE CONCAT('%azun','dris%');
+
+--echo Show that we logged stuff at all:
+--echo ------ from file ------
+SELECT TRIM(LEADING '\t' FROM MID(argument,LOCATE('Query',argument)+5)) FROM test_log WHERE argument LIKE '%PASSWORD %';
+--echo ------ from table ------
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%PASSWORD %';
+--echo ------ done ------
+
+--echo ------ rewrite ------
+SELECT argument FROM mysql.general_log WHERE argument LIKE 'SET CHARACTER SET %';
+SELECT argument FROM mysql.general_log WHERE argument LIKE 'SET NAMES %';
+--echo ------ done ------ see log_tables.test for more proof! :)
+
+DROP TABLE test_log;
+
+--remove_file $MYSQLTEST_VARDIR/log/rewrite_general.log
+
+SET GLOBAL general_log_file=  @old_general_log_file;
+SET GLOBAL general_log=       @old_general_log;
+SET GLOBAL log_output=        @old_log_output;
+
+--echo End of 5.6 tests!

=== added file 'mysql-test/t/rewrite_slow_log.test'
--- a/mysql-test/t/rewrite_slow_log.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/rewrite_slow_log.test	2011-08-19 00:45:28 +0000
@@ -0,0 +1,96 @@
+#
+# WL#5706/Bug#58712/Bug#11746378
+# Encrypt or remove passwords from slow, query, and binary logs
+# (see sql/sql_rewrite.cc for bulk of implementation)
+#
+
+--source include/not_windows.inc
+
+# make sure we start with a clean slate. log_tables.test says this is OK.
+TRUNCATE TABLE mysql.slow_log;
+
+SET @old_log_output=          @@global.log_output;
+SET @old_slow_query_log=      @@global.slow_query_log;
+SET @old_slow_query_log_file= @@global.slow_query_log_file;
+
+SET @old_long_query_time=     @@global.long_query_time;
+
+--replace_result $MYSQLTEST_VARDIR ...
+eval SET GLOBAL slow_query_log_file= '$MYSQLTEST_VARDIR/log/rewrite_slow.log';
+SET GLOBAL log_output =       'FILE,TABLE';
+SET GLOBAL slow_query_log=    'ON';
+
+# The answer is obvious: log everything!
+SET SESSION long_query_time=  0;
+
+# Show that obfuscation applies to the slow log at all.
+# If one applies, they all do, and we've already demonstrated the individual
+# obfuscations above for the general log.
+
+# 1.1.1.1
+GRANT ALL on *.* TO test_user1 IDENTIFIED BY 'azundris1';
+
+# 1.1.1.2
+CREATE USER test_user2 IDENTIFIED BY 'azundris2';
+
+# 1.1.1.3
+--disable_warnings
+CHANGE MASTER TO MASTER_PASSWORD='azundris3';
+CHANGE MASTER TO MASTER_CONNECT_RETRY = 1, MASTER_HEARTBEAT_PERIOD = 1.01,
+  MASTER_LOG_FILE = 'master_log_name', MASTER_LOG_POS = 0,
+  MASTER_SSL = 0, MASTER_SSL_CA = 'ca_file_name',
+  MASTER_SSL_CAPATH = 'ca_directory_name',
+  MASTER_SSL_CERT = 'cert_file_name', MASTER_SSL_KEY = 'key_file_name',
+  MASTER_SSL_CIPHER = 'cipher_list', MASTER_SSL_VERIFY_SERVER_CERT = 0,
+  IGNORE_SERVER_IDS = (99,100);
+# cleanup
+CHANGE MASTER TO MASTER_CONNECT_RETRY = 1, MASTER_HEARTBEAT_PERIOD = 1.01,
+  MASTER_LOG_FILE = '', MASTER_LOG_POS = 0,
+  MASTER_SSL = 0, MASTER_SSL_CA = '',
+  MASTER_SSL_CAPATH = '',
+  MASTER_SSL_CERT = '', MASTER_SSL_KEY = '',
+  MASTER_SSL_CIPHER = '', MASTER_SSL_VERIFY_SERVER_CERT = 0,
+  IGNORE_SERVER_IDS = ( );
+--enable_warnings
+
+# 1.1.1.4
+CREATE USER 'test_user4'@'localhost';
+SET PASSWORD FOR 'test_user4'@'localhost' = PASSWORD('azundris4');
+
+SET SESSION long_query_time=  @old_long_query_time;
+
+# clean-up
+SET GLOBAL slow_query_log='OFF';
+
+DROP USER 'test_user4'@'localhost';
+DROP USER test_user2;
+DROP USER test_user1;
+
+# show slow-logging to file is correct
+CREATE TABLE test_log (sql_text TEXT);
+--replace_result $MYSQLTEST_VARDIR ...
+eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/log/rewrite_slow.log'
+     INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
+
+# all passwords ('azundris%') must have been obfuscated -> empty result set
+--echo This line should be followed by two SELECTs with empty result sets
+SELECT sql_text FROM test_log WHERE sql_text LIKE CONCAT('%azun','dris%');
+
+# same for logging to table
+SELECT sql_text FROM mysql.slow_log WHERE sql_text LIKE CONCAT('%azun','dris%');
+
+--echo ------ from file ------
+SELECT sql_text FROM test_log WHERE sql_text like '%PASSWORD %'; 
+--echo ------ from table ------
+SELECT sql_text FROM mysql.slow_log WHERE sql_text like '%PASSWORD %';
+--echo ------ done ------
+
+DROP TABLE test_log;
+
+--remove_file $MYSQLTEST_VARDIR/log/rewrite_slow.log
+
+SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
+SET GLOBAL slow_query_log=      @old_slow_query_log;
+SET GLOBAL log_output=          @old_log_output;
+
+--echo End of 5.6 tests!

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2011-07-22 07:21:40 +0000
+++ b/sql/CMakeLists.txt	2011-08-17 14:07:07 +0000
@@ -129,6 +129,7 @@ SET(SQL_SHARED_SOURCES
   sql_profile.cc
   sql_reload.cc
   sql_rename.cc 
+  sql_rewrite.cc
   sql_select.cc
   sql_servers.cc
   sql_show.cc

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-08-18 08:31:08 +0000
+++ b/sql/mysqld.cc	2011-08-18 18:05:45 +0000
@@ -351,7 +351,7 @@ static mysql_cond_t COND_thread_cache, C
 /* Global variables */
 
 bool opt_bin_log, opt_ignore_builtin_innodb= 0;
-my_bool opt_log, opt_slow_log;
+my_bool opt_log, opt_slow_log, opt_log_raw;
 ulonglong log_output_options;
 my_bool opt_log_queries_not_using_indexes= 0;
 bool opt_error_log= IF_WIN(1,0);
@@ -6252,6 +6252,11 @@ struct my_option my_long_options[]=
   {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
    &myisam_log_filename, &myisam_log_filename, 0, GET_STR,
    OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"log-raw", 0,
+   "Log to general log before any rewriting of the query. For use in debugging, not production as "
+   "sensitive information may be logged.",
+   &opt_log_raw, &opt_log_raw,
+   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0 },
   {"log-short-format", 0,
    "Don't log extra information to update and slow-query logs.",
    &opt_short_log_format, &opt_short_log_format,

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-08-18 08:31:08 +0000
+++ b/sql/mysqld.h	2011-08-18 18:05:45 +0000
@@ -94,7 +94,7 @@ extern CHARSET_INFO *character_set_files
 extern MY_BITMAP temp_pool;
 extern bool 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;
+extern my_bool opt_log, opt_slow_log, opt_log_raw;
 extern my_bool opt_backup_history_log;
 extern my_bool opt_backup_progress_log;
 extern ulonglong log_output_options;

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2011-07-28 10:54:44 +0000
+++ b/sql/set_var.cc	2011-08-17 14:07:07 +0000
@@ -34,7 +34,7 @@
 #include "tztime.h"     // my_tz_find, my_tz_SYSTEM, struct Time_zone
 #include "sql_acl.h"    // SUPER_ACL
 #include "sql_select.h" // free_underlaid_joins
-#include "sql_show.h"   // make_default_log_name
+#include "sql_show.h"   // make_default_log_name, append_identifier
 #include "sql_view.h"   // updatable_views_with_limit_typelib
 #include "lock.h"                               // lock_global_read_lock,
                                                 // make_global_read_lock_block_commit,
@@ -668,6 +668,27 @@ int set_var::update(THD *thd)
   return value ? var->update(thd, this) : var->set_default(thd, type);
 }
 
+/**
+  Self-print assignment
+
+  @param   str    string buffer to append the partial assignment to
+*/
+void set_var::print(THD *thd, String *str)
+{
+  str->append(type == OPT_GLOBAL ? "GLOBAL " : "SESSION ");
+  if (base.length)
+  {
+    str->append(base.str, base.length);
+    str->append(STRING_WITH_LEN("."));
+  }
+  str->append(var->name.str,var->name.length);
+  str->append(STRING_WITH_LEN("="));
+  if (value)
+    value->print(str, QT_ORDINARY);
+  else
+    str->append(STRING_WITH_LEN("DEFAULT"));
+}
+
 
 /*****************************************************************************
   Functions to handle SET @user_variable=const_expr
@@ -718,6 +739,12 @@ int set_var_user::update(THD *thd)
 }
 
 
+void set_var_user::print(THD *thd, String *str)
+{
+  user_var_item->print(str, QT_ORDINARY);
+}
+
+
 /*****************************************************************************
   Functions to handle SET PASSWORD
 *****************************************************************************/
@@ -764,6 +791,24 @@ int set_var_password::update(THD *thd)
 #endif
 }
 
+void set_var_password::print(THD *thd, String *str)
+{
+  if (user->user.str != NULL && user->user.length > 0)
+  {
+    str->append(STRING_WITH_LEN("PASSWORD FOR "));
+    append_identifier(thd, str, user->user.str, user->user.length);
+    if (user->host.str != NULL && user->host.length > 0)
+    {
+      str->append(STRING_WITH_LEN("@"));
+      append_identifier(thd, str, user->host.str, user->host.length);
+    }
+    str->append(STRING_WITH_LEN("="));
+  }
+  else
+    str->append(STRING_WITH_LEN("PASSWORD FOR CURRENT_USER()="));
+  str->append(STRING_WITH_LEN("<secret>"));
+}
+
 /*****************************************************************************
   Functions to handle SET NAMES and SET CHARACTER SET
 *****************************************************************************/
@@ -791,3 +836,21 @@ int set_var_collation_client::update(THD
   return 0;
 }
 
+void set_var_collation_client::print(THD *thd, String *str)
+{
+  str->append((set_cs_flags & SET_CS_NAMES) ? "NAMES " : "CHARACTER SET ");
+  if (set_cs_flags & SET_CS_DEFAULT)
+    str->append("DEFAULT");
+  else
+  {
+    str->append("'");
+    str->append(character_set_client->csname);
+    str->append("'");
+    if (set_cs_flags & SET_CS_COLLATE)
+    {
+      str->append(" COLLATE '");
+      str->append(collation_connection->name);
+      str->append("'");
+    }
+  }
+}

=== modified file 'sql/set_var.h'
--- a/sql/set_var.h	2011-07-19 15:11:15 +0000
+++ b/sql/set_var.h	2011-08-17 14:07:07 +0000
@@ -187,6 +187,7 @@ public:
   virtual int check(THD *thd)=0;           /* To check privileges etc. */
   virtual int update(THD *thd)=0;                  /* To set the value */
   virtual int light_check(THD *thd) { return check(thd); }   /* for PS */
+  virtual void print(THD *thd, String *str)=0;	/* To self-print */
   /// @returns whether this variable is @@@@optimizer_trace.
   virtual bool is_var_optimizer_trace() const { return false; }
 };
@@ -234,6 +235,7 @@ public:
   int check(THD *thd);
   int update(THD *thd);
   int light_check(THD *thd);
+  void print(THD *thd, String *str);	/* To self-print */
 #ifdef OPTIMIZER_TRACE
   virtual bool is_var_optimizer_trace() const
   {
@@ -255,6 +257,7 @@ public:
   int check(THD *thd);
   int update(THD *thd);
   int light_check(THD *thd);
+  void print(THD *thd, String *str);	/* To self-print */
 };
 
 /* For SET PASSWORD */
@@ -269,6 +272,7 @@ public:
   {}
   int check(THD *thd);
   int update(THD *thd);
+  void print(THD *thd, String *str);	/* To self-print */
 };
 
 
@@ -276,19 +280,24 @@ public:
 
 class set_var_collation_client: public set_var_base
 {
+  int   set_cs_flags;
   const CHARSET_INFO *character_set_client;
   const CHARSET_INFO *character_set_results;
   const CHARSET_INFO *collation_connection;
 public:
-  set_var_collation_client(const CHARSET_INFO *client_coll_arg,
+  enum  set_cs_flags_enum { SET_CS_NAMES=1, SET_CS_DEFAULT=2, SET_CS_COLLATE=4 };
+  set_var_collation_client(int set_cs_flags_arg,
+                           const CHARSET_INFO *client_coll_arg,
                            const CHARSET_INFO *connection_coll_arg,
                            const CHARSET_INFO *result_coll_arg)
-    :character_set_client(client_coll_arg),
+    :set_cs_flags(set_cs_flags_arg),
+     character_set_client(client_coll_arg),
      character_set_results(result_coll_arg),
      collation_connection(connection_coll_arg)
   {}
   int check(THD *thd);
   int update(THD *thd);
+  void print(THD *thd, String *str);	/* To self-print */
 };
 
 

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-07-28 10:54:44 +0000
+++ b/sql/sql_acl.cc	2011-08-18 13:53:05 +0000
@@ -3897,7 +3897,8 @@ bool mysql_routine_grant(THD *thd, TABLE
     {
       result= TRUE;
       continue;
-    }  
+    }
+
     /* Create user if needed */
     error=replace_user_table(thd, tables[0].table, *Str,
 			     0, revoke_grant, create_new_users,
@@ -3954,8 +3955,19 @@ bool mysql_routine_grant(THD *thd, TABLE
 
   if (write_to_binlog && should_write_to_binlog)
   {
-    if (write_bin_log(thd, FALSE, thd->query(), thd->query_length()))
-      result= TRUE;
+    if (revoke_grant)
+    {
+      if (write_bin_log(thd, FALSE, thd->query(), thd->query_length()))
+        result= TRUE;
+    }
+    else
+    {
+      DBUG_ASSERT(thd->rewritten_query.length());
+      if (write_bin_log(thd, FALSE,
+                        thd->rewritten_query.c_ptr_safe(),
+                        thd->rewritten_query.length()))
+        result= TRUE;
+    }
   }
 
   mysql_rwlock_unlock(&LOCK_grant);
@@ -4072,6 +4084,7 @@ bool mysql_grant(THD *thd, const char *d
       result= TRUE;
       continue;
     }
+
     /*
       No User, but a password?
       They did GRANT ... TO CURRENT_USER() IDENTIFIED BY ... !
@@ -4079,6 +4092,7 @@ bool mysql_grant(THD *thd, const char *d
     */
     if (!tmp_Str->user.str && tmp_Str->password.str)
       Str->password= tmp_Str->password;
+
     if (replace_user_table(thd, tables[0].table, *Str,
                            (!db ? rights : 0), revoke_grant, create_new_users,
                            test(thd->variables.sql_mode &
@@ -4115,8 +4129,16 @@ bool mysql_grant(THD *thd, const char *d
   mysql_mutex_unlock(&acl_cache->lock);
 
   if (should_write_to_binlog)
-    result= result |
-            write_bin_log(thd, FALSE, thd->query(), thd->query_length());
+  {
+    if (thd->rewritten_query.length())
+      result= result |
+          write_bin_log(thd, FALSE,
+                        thd->rewritten_query.c_ptr_safe(),
+                        thd->rewritten_query.length());
+    else
+      result= result |
+              write_bin_log(thd, FALSE, thd->query(), thd->query_length());
+  }
 
   mysql_rwlock_unlock(&LOCK_grant);
 
@@ -5177,7 +5199,9 @@ static void add_user_option(String *gran
   }
 }
 
-static const char *command_array[]=
+#endif /*NO_EMBEDDED_ACCESS_CHECKS */
+
+const char *command_array[]=
 {
   "SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "RELOAD",
   "SHUTDOWN", "PROCESS","FILE", "GRANT", "REFERENCES", "INDEX",
@@ -5187,13 +5211,27 @@ static const char *command_array[]=
   "CREATE USER", "EVENT", "TRIGGER", "CREATE TABLESPACE"
 };
 
-static uint command_lengths[]=
+uint command_lengths[]=
 {
   6, 6, 6, 6, 6, 4, 6, 8, 7, 4, 5, 10, 5, 5, 14, 5, 23, 11, 7, 17, 18, 11, 9,
   14, 13, 11, 5, 7, 17
 };
 
 
+void append_int(String *str, const char *txt, size_t len,
+                long val, int cond)
+{
+  if (cond)
+  {
+    String numbuf(42);
+    str->append(txt,len);
+    numbuf.set((longlong)val,&my_charset_bin);
+    str->append(numbuf);
+  }
+}
+
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+
 static int show_routine_grants(THD *thd, LEX_USER *lex_user, HASH *hash,
                                const char *type, int typelen,
                                char *buff, int buffsize);
@@ -6405,6 +6443,8 @@ static int handle_grant_data(TABLE_LIST 
   DBUG_RETURN(result);
 }
 
+#endif /*NO_EMBEDDED_ACCESS_CHECKS */
+
 /**
   Auxiliary function for constructing a  user list string.
   @param str     A String to store the user list.
@@ -6413,8 +6453,8 @@ static int handle_grant_data(TABLE_LIST 
   @param ident   If TRUE, append ' IDENTIFIED BY/WITH...' after the user,
                  if the given user has credentials set with 'IDENTIFIED BY/WITH'
  */
-static void append_user(String *str, LEX_USER *user, bool comma= TRUE,
-                        bool ident= FALSE)
+void append_user(String *str, LEX_USER *user, bool comma= TRUE,
+                 bool ident= FALSE)
 {
   String from_user(user->user.str, user->user.length, system_charset_info);
   String from_plugin(user->plugin.str, user->plugin.length, system_charset_info);
@@ -6454,6 +6494,7 @@ static void append_user(String *str, LEX
   }
 }
 
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
 
 /*
   Create a list of users.
@@ -6472,7 +6513,6 @@ bool mysql_create_user(THD *thd, List <L
 {
   int result;
   String wrong_users;
-  String log_query;
   LEX_USER *user_name, *tmp_user_name;
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
@@ -6501,7 +6541,6 @@ bool mysql_create_user(THD *thd, List <L
   mysql_rwlock_wrlock(&LOCK_grant);
   mysql_mutex_lock(&acl_cache->lock);
 
-  log_query.append(STRING_WITH_LEN("CREATE USER"));
   while ((tmp_user_name= user_list++))
   {
     if (!(user_name= get_current_user(thd, tmp_user_name)))
@@ -6510,24 +6549,20 @@ bool mysql_create_user(THD *thd, List <L
       continue;
     }
 
-    log_query.append(' ');
-    append_user(&log_query, user_name, FALSE, TRUE);
-    log_query.append(',');
-
     /*
       Search all in-memory structures and grant tables
       for a mention of the new user name.
     */
     if (handle_grant_data(tables, 0, user_name, NULL))
     {
-      append_user(&wrong_users, user_name, wrong_users.length() > 0);
+      append_user(&wrong_users, user_name, wrong_users.length() > 0, FALSE);
       result= TRUE;
       continue;
     }
 
     if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
     {
-      append_user(&wrong_users, user_name, wrong_users.length() > 0);
+      append_user(&wrong_users, user_name, wrong_users.length() > 0, FALSE);
       result= TRUE;
       continue;
     }
@@ -6542,9 +6577,9 @@ bool mysql_create_user(THD *thd, List <L
 
   if (some_users_created)
   {
-    /* Remove the last ',' */
-    log_query.length(log_query.length()-1);
-    result|= write_bin_log(thd, FALSE, log_query.c_ptr_safe(), log_query.length());
+    result|= write_bin_log(thd, FALSE,
+                           thd->rewritten_query.c_ptr_safe(),
+                           thd->rewritten_query.length());
   }
 
   mysql_rwlock_unlock(&LOCK_grant);
@@ -6613,7 +6648,7 @@ bool mysql_drop_user(THD *thd, List <LEX
     }  
     if (handle_grant_data(tables, 1, user_name, NULL) <= 0)
     {
-      append_user(&wrong_users, user_name, wrong_users.length() > 0);
+      append_user(&wrong_users, user_name, wrong_users.length() > 0, FALSE);
       result= TRUE;
       continue;
     }
@@ -6709,7 +6744,7 @@ bool mysql_rename_user(THD *thd, List <L
     if (handle_grant_data(tables, 0, user_to, NULL) ||
         handle_grant_data(tables, 0, user_from, user_to) <= 0)
     {
-      append_user(&wrong_users, user_from, wrong_users.length() > 0);
+      append_user(&wrong_users, user_from, wrong_users.length() > 0, FALSE);
       result= TRUE;
       continue;
     }

=== modified file 'sql/sql_acl.h'
--- a/sql/sql_acl.h	2011-06-30 15:50:45 +0000
+++ b/sql/sql_acl.h	2011-08-17 14:07:07 +0000
@@ -180,10 +180,16 @@ enum mysql_db_table_field
 
 extern const TABLE_FIELD_DEF mysql_db_table_def;
 extern bool mysql_user_table_is_in_short_password_format;
+extern const char *command_array[];
+extern uint        command_lengths[];
+
 
 /* prototypes */
 
 bool hostname_requires_resolving(const char *hostname);
+void append_user(String *str, LEX_USER *user, bool comma, bool passwd);
+void append_int(String *str, const char *txt, size_t len,
+                long val, int cond);
 my_bool  acl_init(bool dont_read_acl_tables);
 my_bool acl_reload(THD *thd);
 void acl_free(bool end=0);

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-08-15 09:44:00 +0000
+++ b/sql/sql_class.h	2011-08-18 18:05:45 +0000
@@ -829,6 +829,23 @@ public:
   */
   CSET_STRING query_string;
 
+  /*
+    In some cases, we may want to modify the query (i.e. replace
+    passwords with their hashes before logging the statement etc.).
+
+    In case the query was rewritten, the original query will live in
+    query_string, while the rewritten query lives in rewritten_query.
+    If rewritten_query is empty, query_string should be logged.
+    If rewritten_query is non-empty, the rewritten query it contains
+    should be used in logs (general log, slow query log, binary log).
+
+    Currently, password obfuscation is the only rewriting we do; more
+    may follow at a later date, both pre- and post parsing of the query.
+    Rewriting of binloggable statements must preserve all pertinent
+    information.
+  */
+  String      rewritten_query;
+
   inline char *query() const { return query_string.str(); }
   inline uint32 query_length() const { return query_string.length(); }
   const CHARSET_INFO *query_charset() const { return query_string.charset(); }

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-08-17 08:11:13 +0000
+++ b/sql/sql_parse.cc	2011-08-18 18:05:45 +0000
@@ -96,6 +96,7 @@
 #include "mysql/psi/mysql_statement.h"
 #include "sql_bootstrap.h"
 #include "opt_explain.h"
+#include "sql_rewrite.h"
 
 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
 
@@ -1165,7 +1166,9 @@ bool dispatch_command(enum enum_server_c
                       (char *) thd->security_ctx->host_or_ip);
     char *packet_end= thd->query() + thd->query_length();
 
-    general_log_write(thd, command, thd->query(), thd->query_length());
+    if (opt_log_raw)
+      general_log_write(thd, command, thd->query(), thd->query_length());
+
     DBUG_PRINT("query",("%-.4096s",thd->query()));
 
 #if defined(ENABLED_PROFILING)
@@ -1629,13 +1632,19 @@ void log_slow_statement(THD *thd)
          ((thd->server_status &
            (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
           opt_log_queries_not_using_indexes &&
-           !(sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND))) &&
+          !(sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND))) &&
         thd->get_examined_row_count() >= thd->variables.min_examined_row_limit)
     {
       THD_STAGE_INFO(thd, stage_logging_slow_query);
       thd->status_var.long_query_count++;
-      slow_log_print(thd, thd->query(), thd->query_length(), 
-                     end_utime_of_query);
+      if (thd->rewritten_query.length())
+        slow_log_print(thd,
+                       thd->rewritten_query.c_ptr_safe(),
+                       thd->rewritten_query.length(), 
+                       end_utime_of_query);
+      else
+        slow_log_print(thd, thd->query(), thd->query_length(), 
+                       end_utime_of_query);
     }
   }
   DBUG_VOID_RETURN;
@@ -1814,6 +1823,7 @@ bool alloc_query(THD *thd, const char *p
       return TRUE;
   query[packet_length]= '\0';
   thd->set_query(query, packet_length);
+  thd->rewritten_query.free();                 // free here lest PS break
 
   /* Reclaim some memory */
   thd->packet.shrink(thd->variables.net_buffer_length);
@@ -5699,6 +5709,33 @@ void mysql_parse(THD *thd, char *rawbuf,
 
     bool err= parse_sql(thd, parser_state, NULL);
 
+    const char *found_semicolon= parser_state->m_lip.found_semicolon;
+    size_t      qlen= found_semicolon
+                      ? (found_semicolon - thd->query())
+                      : thd->query_length();
+
+
+    /*
+      See whether we can do any query rewriting. opt_log_raw only controls
+      writing to the general log, so rewriting still needs to happen because
+      the other logs (binlog, slow query log, ...) can not be set to raw mode
+      for security reasons.
+    */
+    mysql_rewrite_query(thd);
+
+    if (thd->rewritten_query.length())
+    {
+      lex->safe_to_cache_query= FALSE; // see comments below
+      if (!opt_log_raw)
+        general_log_write(thd, COM_QUERY, thd->rewritten_query.c_ptr_safe(),
+                                          thd->rewritten_query.length());
+    }
+    else
+    {
+      if (!opt_log_raw)
+        general_log_write(thd, COM_QUERY, thd->query(), qlen);
+    }
+
     if (!err)
     {
       thd->m_statement_psi= MYSQL_REFINE_STATEMENT(thd->m_statement_psi,
@@ -5715,7 +5752,6 @@ void mysql_parse(THD *thd, char *rawbuf,
       {
 	if (! thd->is_error())
 	{
-          const char *found_semicolon= parser_state->m_lip.found_semicolon;
           /*
             Binlog logs a string starting from thd->query and having length
             thd->query_length; so we set thd->query_length correctly (to not
@@ -5769,9 +5805,20 @@ void mysql_parse(THD *thd, char *rawbuf,
   }
   else
   {
-    /* Only SELECT are cached in the query cache. */
+    /*
+      Query cache hit. We need to write the general log here.
+      Right now, we only cache SELECT results; if the cache ever
+      becomes more generic, we should also cache the rewritten
+      query-string together with the original query-string (which
+      we'd still use for the matching) when we first execute the
+      query, and then use the obfuscated query-string for logging
+      here when the query is given again.
+    */
     thd->m_statement_psi= MYSQL_REFINE_STATEMENT(thd->m_statement_psi,
                                                  sql_statement_info[SQLCOM_SELECT].m_key);
+    if (!opt_log_raw)
+      general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
+    parser_state->m_lip.found_semicolon= NULL;
   }
 
   DBUG_VOID_RETURN;

=== added file 'sql/sql_rewrite.cc'
--- a/sql/sql_rewrite.cc	1970-01-01 00:00:00 +0000
+++ b/sql/sql_rewrite.cc	2011-08-18 15:27:05 +0000
@@ -0,0 +1,375 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; version 2 of
+   the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   02110-1301  USA */
+
+
+#include "sql_acl.h"    // append_user
+#include "sql_parse.h"  // get_current_user
+#include "sql_show.h"   // append_identifier
+#include "sp_head.h"    // TYPE_ENUM_(FUNCTION|PROCEDURE)
+
+
+
+static void mysql_rewrite_grant(THD *thd, String *rlb)
+{
+  LEX        *lex= thd->lex;
+  TABLE_LIST *first_table= (TABLE_LIST*) lex->select_lex.table_list.first;
+  bool        comma= FALSE, comma_inner;
+  String      cols(1024);
+  int         c;
+
+  rlb->append(STRING_WITH_LEN("GRANT "));
+
+  if (lex->all_privileges)
+    rlb->append(STRING_WITH_LEN("ALL PRIVILEGES"));
+  else
+  {
+    ulong priv;
+
+    for (c= 0, priv = SELECT_ACL; priv <= GLOBAL_ACLS; c++, priv <<= 1)
+    {
+      if (priv == GRANT_ACL)
+        continue;
+
+      comma_inner= FALSE;
+
+      if (lex->columns.elements)               // show columns, if any
+      {
+        class LEX_COLUMN *column;
+        List_iterator <LEX_COLUMN> column_iter(lex->columns);
+
+        cols.length(0);
+        cols.append(STRING_WITH_LEN(" ("));
+
+        while ((column = column_iter++))
+        {
+          if (column->rights & priv)
+          {
+            if (comma_inner)
+              cols.append(STRING_WITH_LEN(", "));
+            else
+              comma_inner= TRUE;
+            cols.append(column->column.ptr(),column->column.length());
+          }
+        }
+        cols.append(STRING_WITH_LEN(")"));
+      }
+
+      if (comma_inner || (lex->grant & priv))  // show privilege name
+      {
+        if (comma)
+          rlb->append(STRING_WITH_LEN(", "));
+        else
+          comma= TRUE;
+        rlb->append(command_array[c],command_lengths[c]);
+        if (!(lex->grant & priv))              // general outranks specific
+          rlb->append(cols);
+      }
+    }
+    if (!comma)                                // no privs, default to USAGE
+      rlb->append(STRING_WITH_LEN("USAGE"));
+  }
+
+  rlb->append(STRING_WITH_LEN(" ON "));
+  switch(lex->type)
+  {
+  case TYPE_ENUM_PROCEDURE: rlb->append(STRING_WITH_LEN("PROCEDURE ")); break;
+  case TYPE_ENUM_FUNCTION:  rlb->append(STRING_WITH_LEN("FUNCTION "));  break;
+  default:                                                              break;
+  }
+
+  if (first_table)
+  {
+    append_identifier(thd, rlb, first_table->db, strlen(first_table->db));
+    rlb->append(STRING_WITH_LEN("."));
+    append_identifier(thd, rlb, first_table->table_name, strlen(first_table->table_name));
+  }
+  else
+  {
+    if (lex->current_select->db)
+      append_identifier(thd, rlb, lex->current_select->db, strlen(lex->current_select->db));
+    else
+      rlb->append("*");
+    rlb->append(STRING_WITH_LEN(".*"));
+  }
+
+  rlb->append(STRING_WITH_LEN(" TO "));
+  {
+    LEX_USER *user_name, *tmp_user_name;
+    List_iterator <LEX_USER> user_list(lex->users_list);
+    bool comma= FALSE;
+
+    while ((tmp_user_name= user_list++))
+    {
+      if ((user_name= get_current_user(thd, tmp_user_name)))
+      {
+        append_user(rlb, user_name, comma, TRUE);
+        comma= TRUE;
+      }
+    }
+  }
+
+  if (lex->ssl_type != SSL_TYPE_NOT_SPECIFIED)
+  {
+    rlb->append(STRING_WITH_LEN(" REQUIRE"));
+    switch (lex->ssl_type)
+    {
+    case SSL_TYPE_SPECIFIED:
+      if (lex->x509_subject)
+      {
+        rlb->append(STRING_WITH_LEN(" SUBJECT '"));
+        rlb->append(lex->x509_subject);
+        rlb->append(STRING_WITH_LEN("'"));
+      }
+      if (lex->x509_issuer)
+      {
+        rlb->append(STRING_WITH_LEN(" ISSUER '"));
+        rlb->append(lex->x509_subject);
+        rlb->append(STRING_WITH_LEN("'"));
+      }
+      if (lex->ssl_cipher)
+      {
+        rlb->append(STRING_WITH_LEN(" CIPHER '"));
+        rlb->append(lex->ssl_cipher);
+        rlb->append(STRING_WITH_LEN("'"));
+      }
+      break;
+    case SSL_TYPE_X509:
+      rlb->append(STRING_WITH_LEN(" X509"));
+      break;
+    case SSL_TYPE_ANY:
+      rlb->append(STRING_WITH_LEN(" SSL"));
+      break;
+    case SSL_TYPE_NOT_SPECIFIED:
+      /* fall-thru */
+    case SSL_TYPE_NONE:
+      rlb->append(STRING_WITH_LEN(" NONE"));
+      break;
+    }
+  }
+
+  if (lex->mqh.specified_limits || (lex->grant & GRANT_ACL))
+  {
+    rlb->append(STRING_WITH_LEN(" WITH"));
+    if (lex->grant & GRANT_ACL)
+      rlb->append(STRING_WITH_LEN(" GRANT OPTION"));
+
+    append_int(rlb, STRING_WITH_LEN(" MAX_QUERIES_PER_HOUR "),
+               lex->mqh.questions,
+               lex->mqh.specified_limits & USER_RESOURCES::QUERIES_PER_HOUR);
+
+    append_int(rlb, STRING_WITH_LEN(" MAX_UPDATES_PER_HOUR "),
+               lex->mqh.updates,
+               lex->mqh.specified_limits & USER_RESOURCES::UPDATES_PER_HOUR);
+
+    append_int(rlb, STRING_WITH_LEN(" MAX_CONNECTIONS_PER_HOUR "),
+               lex->mqh.conn_per_hour,
+               lex->mqh.specified_limits & USER_RESOURCES::CONNECTIONS_PER_HOUR);
+
+    append_int(rlb, STRING_WITH_LEN(" MAX_USER_CONNECTIONS "),
+               lex->mqh.user_conn,
+               lex->mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS);
+  }
+}
+
+
+
+static void mysql_rewrite_set(THD *thd, String *rlb)
+{
+  LEX                              *lex= thd->lex;
+  List_iterator_fast<set_var_base>  it(lex->var_list);
+  set_var_base                     *var;
+  bool                              comma= FALSE;
+
+  rlb->append(STRING_WITH_LEN("SET "));
+
+  while ((var= it++))
+  {
+    if (comma)
+      rlb->append(STRING_WITH_LEN(","));
+    else
+      comma= TRUE;
+
+    var->print(thd, rlb);
+  }
+}
+
+
+static void mysql_rewrite_create_user(THD *thd, String *rlb)
+{
+  LEX                      *lex= thd->lex;
+  LEX_USER                 *user_name, *tmp_user_name;
+  List_iterator <LEX_USER>  user_list(lex->users_list);
+  bool                      comma= FALSE;
+
+  rlb->append(STRING_WITH_LEN("CREATE USER "));
+  while ((tmp_user_name= user_list++))
+  {
+    if ((user_name= get_current_user(thd, tmp_user_name)))
+    {
+      append_user(rlb, user_name, comma, TRUE);
+      comma= TRUE;
+    }
+  }
+}
+
+
+static void mysql_rewrite_change_master(THD *thd, String *rlb)
+{
+  LEX *lex= thd->lex;
+
+  rlb->append(STRING_WITH_LEN("CHANGE MASTER TO"));
+
+  if (lex->mi.host)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_HOST = '"));
+    rlb->append(lex->mi.host);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.user)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_USER = '"));
+    rlb->append(lex->mi.user);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.password)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_PASSWORD = <secret>"));
+  }
+  if (lex->mi.port)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_PORT = "));
+    rlb->append_ulonglong(lex->mi.port);
+  }
+  if (lex->mi.connect_retry)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_CONNECT_RETRY = "));
+    rlb->append_ulonglong(lex->mi.connect_retry);
+  }
+  if (lex->mi.ssl)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL = "));
+    rlb->append(lex->mi.ssl == LEX_MASTER_INFO::LEX_MI_ENABLE ? "1" : "0");
+  }
+  if (lex->mi.ssl_ca)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL_CA = '"));
+    rlb->append(lex->mi.ssl_ca);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.ssl_capath)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL_CAPATH = '"));
+    rlb->append(lex->mi.ssl_capath);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.ssl_cert)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL_CERT = '"));
+    rlb->append(lex->mi.ssl_cert);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.ssl_cipher)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL_CIPHER = '"));
+    rlb->append(lex->mi.ssl_cipher);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.ssl_key)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL_KEY = '"));
+    rlb->append(lex->mi.ssl_key);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.log_file_name)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_LOG_FILE = '"));
+    rlb->append(lex->mi.log_file_name);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.pos)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_LOG_POS = "));
+    rlb->append_ulonglong(lex->mi.pos);
+  }
+  if (lex->mi.relay_log_name)
+  {
+    rlb->append(STRING_WITH_LEN(" RELAY_LOG_FILE = '"));
+    rlb->append(lex->mi.relay_log_name);
+    rlb->append(STRING_WITH_LEN("'"));
+  }
+  if (lex->mi.relay_log_pos)
+  {
+    rlb->append(STRING_WITH_LEN(" RELAY_LOG_POS = "));
+    rlb->append_ulonglong(lex->mi.relay_log_pos);
+  }
+
+  if (lex->mi.ssl_verify_server_cert)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_SSL_VERIFY_SERVER_CERT = "));
+    rlb->append(lex->mi.ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE ? "1" : "0");
+  }
+  if (lex->mi.repl_ignore_server_ids_opt)
+  {
+    bool first= TRUE;
+    rlb->append(STRING_WITH_LEN(" IGNORE_SERVER_IDS = ( "));
+    for (uint i= 0; i < lex->mi.repl_ignore_server_ids.elements; i++)
+    {
+      ulong s_id;
+      get_dynamic(&lex->mi.repl_ignore_server_ids, (uchar*) &s_id, i);
+      if (first)
+        first= FALSE;
+      else
+        rlb->append(STRING_WITH_LEN(", "));
+      rlb->append_ulonglong(s_id);
+    }
+    rlb->append(STRING_WITH_LEN(" )"));
+  }
+  if (lex->mi.heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
+  {
+    rlb->append(STRING_WITH_LEN(" MASTER_HEARTBEAT_PERIOD = "));
+    if (lex->mi.heartbeat_opt == LEX_MASTER_INFO::LEX_MI_DISABLE)
+      rlb->append(STRING_WITH_LEN("0"));
+    else
+    {
+      char buf[64];
+      snprintf(buf, 64, "%f", lex->mi.heartbeat_period);
+      rlb->append(buf);
+    }
+  }
+}
+
+
+/**
+Rewrite a query (to obfuscate passwords etc.)
+@param thd Current thread
+*/
+
+void mysql_rewrite_query(THD *thd)
+{
+  String *rlb= &thd->rewritten_query;
+
+  rlb->free();
+
+  switch(thd->lex->sql_command)
+  {
+  case SQLCOM_GRANT:         mysql_rewrite_grant(thd, rlb);         break;
+  case SQLCOM_SET_OPTION:    mysql_rewrite_set(thd, rlb);           break;
+  case SQLCOM_CREATE_USER:   mysql_rewrite_create_user(thd, rlb);   break;
+  case SQLCOM_CHANGE_MASTER: mysql_rewrite_change_master(thd, rlb); break;
+  default:                   /* unhandled query types are legal. */ break;
+  }
+}

=== added file 'sql/sql_rewrite.h'
--- a/sql/sql_rewrite.h	1970-01-01 00:00:00 +0000
+++ b/sql/sql_rewrite.h	2011-08-17 14:07:07 +0000
@@ -0,0 +1,18 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; version 2 of
+   the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   02110-1301  USA */
+
+void mysql_rewrite_query(THD *thd);

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-08-15 08:58:05 +0000
+++ b/sql/sql_yacc.yy	2011-08-18 18:05:45 +0000
@@ -13145,10 +13145,12 @@ option_value:
           {
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
+            int flags= $2 ? 0 : set_var_collation_client::SET_CS_DEFAULT;
             const CHARSET_INFO *cs2;
             cs2= $2 ? $2: global_system_variables.character_set_client;
             set_var_collation_client *var;
-            var= new set_var_collation_client(cs2,
+            var= new set_var_collation_client(flags,
+                                              cs2,
                                               thd->variables.collation_database,
                                               cs2);
             if (var == NULL)
@@ -13175,6 +13177,9 @@ option_value:
             LEX *lex= Lex;
             const CHARSET_INFO *cs2;
             const CHARSET_INFO *cs3;
+            int flags= set_var_collation_client::SET_CS_NAMES
+                       | ($2 ? 0 : set_var_collation_client::SET_CS_DEFAULT)
+                       | ($3 ? set_var_collation_client::SET_CS_COLLATE : 0);
             cs2= $2 ? $2 : global_system_variables.character_set_client;
             cs3= $3 ? $3 : cs2;
             if (!my_charset_same(cs2, cs3))
@@ -13184,7 +13189,7 @@ option_value:
               MYSQL_YYABORT;
             }
             set_var_collation_client *var;
-            var= new set_var_collation_client(cs3, cs3, cs3);
+            var= new set_var_collation_client(flags, cs3, cs3, cs3);
             if (var == NULL)
               MYSQL_YYABORT;
             lex->var_list.push_back(var);
@@ -13208,6 +13213,7 @@ option_value:
               MYSQL_YYABORT;
             user->host=null_lex_str;
             user->user.str=thd->security_ctx->user;
+            user->user.length= strlen(thd->security_ctx->user);
             set_var_password *var= new set_var_password(user, $3);
             if (var == NULL)
               MYSQL_YYABORT;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tatjana.nuernberg:3271 to 3272) WL#5706Tatjana Azundris Nuernberg22 Aug