[Commits] Rev 3337: Merge 5.5 -> 5.5-mwl248. in file:///home/igor/maria/maria-5.5-mwl248-merge/

Igor Babaev igor at askmonty.org
Thu Apr 12 06:45:12 EEST 2012


At file:///home/igor/maria/maria-5.5-mwl248-merge/

------------------------------------------------------------
revno: 3337 [merge]
revision-id: igor at askmonty.org-20120412034452-wtch0zecpuv3bovq
parent: igor at askmonty.org-20120412001406-ykeclwhdw3as70mo
parent: wlad at montyprogram.com-20120411234044-o1drdcpni36ncsvg
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.5-mwl248-merge
timestamp: Wed 2012-04-11 20:44:52 -0700
message:
  Merge 5.5 -> 5.5-mwl248.
removed:
  mysql-test/suite/innodb/include/innodb-index.inc innodbindex.inc-20090610132748-q9m60aph2eqy8zr6-7
  mysql-test/t/cache_innodb-master.opt sp1f-innodb_cachemaster.o-20011213003118-4nv4jydquqfziihl2qr2nbnwvb2oaavw
added:
  extra/yassl/certs/ca-key.pem   cakey.pem-20120210130859-9p7d3sr25n6dp19m-1
  extra/yassl/certs/client-keyEnc.pem clientkeyenc.pem-20120210130859-9p7d3sr25n6dp19m-2
  extra/yassl/certs/client-keyEnc3.pem clientkeyenc3.pem-20120210130859-9p7d3sr25n6dp19m-3
  extra/yassl/certs/server-keyEnc.pem serverkeyenc.pem-20120210130859-9p7d3sr25n6dp19m-4
  extra/yassl/taocrypt/certs/    certs-20120210130859-9p7d3sr25n6dp19m-5
  extra/yassl/taocrypt/certs/client-cert.der clientcert.der-20120210130859-9p7d3sr25n6dp19m-6
  extra/yassl/taocrypt/certs/client-key.der clientkey.der-20120210130859-9p7d3sr25n6dp19m-7
  extra/yassl/taocrypt/certs/dh1024.dat dh1024.dat-20120210130859-9p7d3sr25n6dp19m-8
  extra/yassl/taocrypt/certs/dsa512.der dsa512.der-20120210130859-9p7d3sr25n6dp19m-9
  extra/yassl/taocrypt/include/hc128.hpp hc128.hpp-20120210115138-07wzplwfr3alb73v-1
  extra/yassl/taocrypt/include/rabbit.hpp rabbit.hpp-20120210115138-07wzplwfr3alb73v-2
  extra/yassl/taocrypt/src/hc128.cpp hc128.cpp-20120210115138-07wzplwfr3alb73v-3
  extra/yassl/taocrypt/src/rabbit.cpp rabbit.cpp-20120210115138-07wzplwfr3alb73v-4
  include/mysql/service_debug_sync.h service_debug_sync.h-20120328080810-qc97fjgdp1x5308v-1
  libservices/debug_sync_service.c debug_sync_service.c-20120328080810-qc97fjgdp1x5308v-2
  mysql-test/include/show_slave_hosts.inc show_slave_hosts.inc-20120227072902-7310n6su6n3nb6r5-1
  mysql-test/r/bug13633383.result bug13633383.result-20120213155348-9433ugaeny1ooyhh-1
  mysql-test/r/partition_cache.result partition_cache.resu-20120220204739-9jnka517t1x0izay-1
  mysql-test/suite/innodb/r/innodb-autoinc-61209.result innodbautoinc61209.r-20120326130608-t12n41hhp3bvn56p-1
  mysql-test/suite/innodb/r/innodb-blob.result innodbblob.result-20120216113838-r8ixyuw326rt8xm2-1
  mysql-test/suite/innodb/r/innodb_bug11754376.result innodb_bug11754376.r-20120206105906-kcr4jqc70cg32buu-1
  mysql-test/suite/innodb/r/innodb_bug11766634.result innodb_bug11766634.r-20120308103014-oxayhaexlnkgn0gj-1
  mysql-test/suite/innodb/r/innodb_bug13510739.result innodb_bug13510739.r-20111222110530-7963diq5tsx2gywf-1
  mysql-test/suite/innodb/t/innodb-autoinc-61209.test innodbautoinc61209.t-20120326130608-t12n41hhp3bvn56p-2
  mysql-test/suite/innodb/t/innodb-blob.test innodbblob.test-20120216113835-6qxxhy17bbyet785-1
  mysql-test/suite/innodb/t/innodb_bug11754376.test innodb_bug11754376.t-20120206105906-kcr4jqc70cg32buu-2
  mysql-test/suite/innodb/t/innodb_bug11766634.test innodb_bug11766634.t-20120308102809-e9lg534ggu2oh5dj-1
  mysql-test/suite/innodb/t/innodb_bug13510739.test innodb_bug13510739.t-20111222110530-7963diq5tsx2gywf-2
  mysql-test/suite/rpl/r/rpl_filter_dbs_dynamic.result rpl_filter_dbs_dynam-20120319214219-axu9qo655ligfsw5-1
  mysql-test/suite/rpl/r/rpl_filter_tables_dynamic.result rpl_filter_tables_dy-20120319214219-axu9qo655ligfsw5-2
  mysql-test/suite/rpl/r/rpl_filter_wild_tables_dynamic.result rpl_filter_wild_tabl-20120319214219-axu9qo655ligfsw5-3
  mysql-test/suite/rpl/r/rpl_report_port.result rpl_report_port.resu-20120227072549-4oe8ag18mgwzl3fo-1
  mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result rpl_stm_bug12400313.-20120306181232-or8g9sm47y8ndiwd-1
  mysql-test/suite/rpl/t/rpl_filter_dbs_dynamic.test rpl_filter_dbs_dynam-20120319214209-bszceb8caa4lxpwj-1
  mysql-test/suite/rpl/t/rpl_filter_tables_dynamic.test rpl_filter_tables_dy-20120319214209-bszceb8caa4lxpwj-2
  mysql-test/suite/rpl/t/rpl_filter_wild_tables_dynamic.test rpl_filter_wild_tabl-20120319214209-bszceb8caa4lxpwj-3
  mysql-test/suite/rpl/t/rpl_report_port-slave.opt rpl_report_portslave-20120227072543-e1ufe71c24dejw6f-1
  mysql-test/suite/rpl/t/rpl_report_port.test rpl_report_port.test-20120227072537-rx5bpobz6eox3dyc-1
  mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt rpl_stm_bug12400313s-20120306181028-thtj3ilmp6srzxz0-1
  mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test rpl_stm_bug12400313.-20120306181028-thtj3ilmp6srzxz0-2
  mysql-test/suite/sys_vars/r/replicate_do_db_basic.result replicate_do_db_basi-20120319214224-523tmwz959g3efkb-1
  mysql-test/suite/sys_vars/r/replicate_do_table_basic.result replicate_do_table_b-20120319214224-523tmwz959g3efkb-2
  mysql-test/suite/sys_vars/r/replicate_ignore_db_basic.result replicate_ignore_db_-20120319214224-523tmwz959g3efkb-3
  mysql-test/suite/sys_vars/r/replicate_ignore_table_basic.result replicate_ignore_tab-20120319214224-523tmwz959g3efkb-4
  mysql-test/suite/sys_vars/r/replicate_wild_do_table_basic.result replicate_wild_do_ta-20120319214224-523tmwz959g3efkb-5
  mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_basic.result replicate_wild_ignor-20120319214224-523tmwz959g3efkb-6
  mysql-test/suite/sys_vars/t/replicate_do_db_basic.test replicate_do_db_basi-20120319214203-1snudiau4r2wtmts-1
  mysql-test/suite/sys_vars/t/replicate_do_table_basic.test replicate_do_table_b-20120319214203-1snudiau4r2wtmts-2
  mysql-test/suite/sys_vars/t/replicate_ignore_db_basic.test replicate_ignore_db_-20120319214203-1snudiau4r2wtmts-3
  mysql-test/suite/sys_vars/t/replicate_ignore_table_basic.test replicate_ignore_tab-20120319214203-1snudiau4r2wtmts-4
  mysql-test/suite/sys_vars/t/replicate_wild_do_table_basic.test replicate_wild_do_ta-20120319214203-1snudiau4r2wtmts-5
  mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_basic.test replicate_wild_ignor-20120319214203-1snudiau4r2wtmts-6
  mysql-test/t/bug13633383.test  bug13633383.test-20120213153955-yzqk0k9n9g70h9mg-1
  mysql-test/t/partition_cache.test partition_cache.test-20120220204747-k0317brje8yrnhgp-1
  sql/mem_root_array.h           mem_root_array.h-20110207133217-h22c8nvslgvxlat2-1
renamed:
  include/mysql/service_logger.h => plugin/sql_errlog/service_logger.h service_logger.h-20120309142604-epp6z5qsp7x8i6gh-1
  libservices/logger_service.c => plugin/sql_errlog/logger_service.c logger_service.c-20120309131431-ryy14kz0yfzf0v9j-1
  sql/sql_logger.cc => plugin/sql_errlog/sql_logger.cc my_logger.c-20120309131627-m9cjf8i37dgdugga-1
modified:
  .bzrignore                     sp1f-ignore-20001018235455-q4gxfbritt5f42nwix354ufpsvrf5ebj
  BUILD/SETUP.sh                 sp1f-setup.sh-20001218212418-itvzddls4bsqffggcsjklbawdmaxdhde
  CMakeLists.txt                 sp1f-cmakelists.txt-20060831175236-433hkm7nrqfjbwios4ancgytabw354nr
  VERSION                        version-20101120144121-246n4i4siyolltwd-1
  client/CMakeLists.txt          sp1f-cmakelists.txt-20060831175236-tdyayhfqw2zme3vhwbn6l2lno4em3u3t
  client/mysql_plugin.c          mysql_plugin.c-20110719141108-yjv31xepi22r64rr-1
  client/mysql_upgrade.c         sp1f-mysql_upgrade.c-20060428040559-3xcugp4nhhb6qfwfacoqw3d4ibgbeboz
  client/mysqladmin.cc           sp1f-mysqladmin.c-19700101030959-ud6encjcx2oypzvp7ptmojbi3xdos2fs
  client/mysqlcheck.c            sp1f-mysqlcheck.c-20010419220847-mlhe2ixwl5ajjyneyciytsdsis3iujhl
  client/mysqldump.c             sp1f-mysqldump.c-19700101030959-thxq2iabzu3yo5snymsubfeclf7v5rac
  client/mysqlimport.c           sp1f-mysqlimport.c-19700101030959-m6nmuvl5kbp2qmdqtmu5mxafegtn7ipv
  client/mysqlshow.c             sp1f-mysqlshow.c-19700101030959-b6rjdpnvma7hacca2ibkkibowbi4hulk
  client/mysqlslap.c             sp1f-mysqlslap.c-20051130000206-7t375hf5mtlqof5xd4nj76yckxvxykhv
  client/sql_string.cc.dontuse   sp1f-sql_string.cc-19700101030959-72h4johdz5mgcc6z2xceguohasr3pkrx
  cmake/abi_check.cmake          abi_check.cmake-20091108233336-m9ewbh1c209yaw0h-7
  cmake/build_configurations/mysql_release.cmake mysql_release.cmake-20100109193252-ep2b0blw0n8x05ml-2
  cmake/do_abi_check.cmake       do_abi_check.cmake-20091108233336-m9ewbh1c209yaw0h-15
  cmake/install_layout.cmake     install_layout.cmake-20100123024817-ukfvifcz5uo0ipm0-1
  cmake/install_macros.cmake     install_macros.cmake-20091108233336-m9ewbh1c209yaw0h-18
  cmake/make_dist.cmake.in       make_dist.cmake.in-20091108233336-m9ewbh1c209yaw0h-19
  cmake/mysql_version.cmake      mysql_version.cmake-20091108233336-m9ewbh1c209yaw0h-22
  cmake/os/WindowsCache.cmake    windowscache.cmake-20100129014232-7vc51i2226x69hzq-1
  cmake/package_name.cmake       package_name.cmake-20100128095813-kh6ru0ekf0fsgm6s-1
  cmake/readline.cmake           readline.cmake-20091108233336-m9ewbh1c209yaw0h-24
  cmd-line-utils/libedit/chartype.h chartype.h-20111013192143-egrar43j7jwt5yf8-1
  cmd-line-utils/libedit/np/unvis.c sp1f-unvis.c-20040824165209-gouef2gpxcah7z56mebj7hp3kxbaolxz
  cmd-line-utils/libedit/np/vis.c sp1f-vis.c-20040824165209-siah3r5p6x635mvs4zioe4wnzb7v5u2a
  configure.cmake                configure.cmake-20091108233336-m9ewbh1c209yaw0h-4
  dbug/CMakeLists.txt            sp1f-cmakelists.txt-20060831175236-d5bv3fgibf4p4ql4ntcr4ypt63z5zfi6
  dbug/dbug.c                    sp1f-dbug.c-19700101030959-dmu3qmh72hbptp5opqnmfgjtfckxi5ug
  debian/dist/Debian/rules       rules-20120106141949-ss9vejrt5vxxzlhb-131
  debian/dist/Ubuntu/rules       rules-20120106141949-ss9vejrt5vxxzlhb-140
  extra/yassl/INSTALL            sp1f-install-20050428132302-7g6jtgwbobh2b6t67tb6qtqqv3oclyqm
  extra/yassl/README             sp1f-readme-20050428132302-kkt7ut4rj7wkpprizgjdkcfhs3w4fwkd
  extra/yassl/certs/ca-cert.pem  sp1f-cacert.pem-20060503110811-uyxzkh5bvwawbbt3afztwera2yzt4mes
  extra/yassl/certs/client-cert.der sp1f-clientcert.der-20060503111055-belh4pjgfofrfv4ss6krjapskeho2uk6
  extra/yassl/certs/client-cert.pem sp1f-clientcert.pem-20060503110814-jw3fius6y2egr7jvgh3d5vjfk23ubps7
  extra/yassl/certs/client-key.der sp1f-clientkey.der-20060503111055-rv3zgbm3tqvkibssk3odbgcd6tvq3kum
  extra/yassl/certs/client-key.pem sp1f-clientkey.pem-20060503110815-vbntic3x4exz2zjl6pplhg7mrxbjvsyw
  extra/yassl/certs/dsa-cert.pem sp1f-dsacert.pem-20060503110817-uqwo24zwc4i6lsrgzuwhag45vfw4hjve
  extra/yassl/certs/dsa512.der   sp1f-dsa512.der-20060503111056-zwxz3jblber7d2lulcxtyypt22xv7mdt
  extra/yassl/certs/server-cert.pem sp1f-servercert.pem-20060503110818-icdnih6n2ndkpgf5o33ijzch3wxzskkc
  extra/yassl/certs/server-key.pem sp1f-serverkey.pem-20060503110819-k2l6xl4omij762uz66jehmsvclohfths
  extra/yassl/certs/taoCert.txt  sp1f-taocert.txt-20060503110819-ehpis4khhxew4mb5bjchqrqaylrruaxx
  extra/yassl/examples/client/client.cpp sp1f-client.cpp-20060406222009-4h32d5zkqiisxkltlegypyoytop4ze3f
  extra/yassl/examples/echoclient/echoclient.cpp sp1f-echoclient.cpp-20060406222010-j6vpu7auff5yqzs52zdg4pr2vicsqlet
  extra/yassl/examples/echoserver/echoserver.cpp sp1f-echoserver.cpp-20060406222010-lu453n5mu6nf5uqgqsgimo7ysaf5d36s
  extra/yassl/examples/server/server.cpp sp1f-server.cpp-20060406222010-nlte4kduzsdd6eui5lxwiuqipe6h5sq6
  extra/yassl/include/buffer.hpp sp1f-buffer.hpp-20050428132302-6tyamx72xd4vqpeb2ydbrfw2krj3xjwc
  extra/yassl/include/openssl/ssl.h sp1f-ssl.h-20050428132306-pfslrljxqbmonu5dgwfln7oxljeyjks7
  extra/yassl/include/socket_wrapper.hpp sp1f-socket_wrapper.hpp-20050428132306-bqx7xkhc74zu5omcavohfvmey2shfajs
  extra/yassl/include/yassl_int.hpp sp1f-yassl_int.hpp-20050428132307-uqdopnog3njo2nicimdqmt7fco35gagn
  extra/yassl/include/yassl_types.hpp sp1f-yassl_types.hpp-20050428132307-ofmbhn7a6742yr265w4ffuvwvcunqbbn
  extra/yassl/src/buffer.cpp     sp1f-buffer.cpp-20050428132309-kbwq62tc7v4c2zpnz3hsua2d2r6no54s
  extra/yassl/src/cert_wrapper.cpp sp1f-cert_wrapper.cpp-20050428132309-mktvm6itdonhykplsfehgzirukkexscx
  extra/yassl/src/handshake.cpp  sp1f-handshake.cpp-20050428132310-fmtqaesmdo3txlm6dnhqmef23jgyrmih
  extra/yassl/src/make.bat*      sp1f-make.bat-20060406222010-aa43he4zo5qo5nfoo6omaj7ov7n5hjgt
  extra/yassl/src/socket_wrapper.cpp sp1f-socket_wrapper.cpp-20050428132310-xrpwjspnwh7abs6ihpqsdatritl5rpw2
  extra/yassl/src/ssl.cpp        sp1f-ssl.cpp-20050428132310-dxnfnbmwz6rpnkj4agjb5nvfhhg345nq
  extra/yassl/src/yassl.cpp      sp1f-yassl.cpp-20060406222010-m45qpysrvm2myvtzq7nynprf7d5uk2lp
  extra/yassl/src/yassl_error.cpp sp1f-yassl_error.cpp-20050428132311-uwd5s2khyebi5wkzp66p3hhvr4sh44f3
  extra/yassl/src/yassl_imp.cpp  sp1f-yassl_imp.cpp-20050428132311-kbtb6sfna2iec57rsngc5wa76djjl76p
  extra/yassl/src/yassl_int.cpp  sp1f-yassl_int.cpp-20050428132311-hjgnphdasudo2ncxocoetyb7twor5fpq
  extra/yassl/taocrypt/CMakeLists.txt sp1f-cmakelists.txt-20060831175237-ewydqdjmnnisumb2tchnxjj6yzqrzyga
  extra/yassl/taocrypt/README    sp1f-readme-20060925125017-s6ixwddqxmjeguvv2yv4krlterx7nses
  extra/yassl/taocrypt/benchmark/benchmark.cpp sp1f-benchmark.cpp-20060406222010-ugjigytqyxdlzvlcnllsoygavyp54cv2
  extra/yassl/taocrypt/benchmark/benchmark.dsp sp1f-benchmark.dsp-20060406222010-o5uh3yro624s5hg6l3n5ibvi52b6dmxf
  extra/yassl/taocrypt/benchmark/dh1024.der sp1f-dh1024.der-20060419094248-eqpobnhkj55sidr7rjazvhoj6gtvxh3u
  extra/yassl/taocrypt/benchmark/dsa1024.der sp1f-dsa1024.der-20060419094249-6ddqgge2aaonq46ymzvkzktzuadmt7yt
  extra/yassl/taocrypt/benchmark/make.bat* sp1f-make.bat-20060406222010-rptfjzsdiccrqgteth5hfotxm6crjet6
  extra/yassl/taocrypt/benchmark/rsa1024.der sp1f-rsa1024.der-20060419094249-zajqxvi3y7pikmxizmbxsg7iv3kdsnxp
  extra/yassl/taocrypt/include/asn.hpp sp1f-asn.hpp-20050428132312-5ijcjgxj7cy3t67jcpi4rg3rbr4nnfmn
  extra/yassl/taocrypt/include/block.hpp sp1f-block.hpp-20050428132313-36s5yrjvbk36ud3nkobt5zsv2ctac72e
  extra/yassl/taocrypt/include/blowfish.hpp sp1f-blowfish.hpp-20060406222010-zucedrbnxxctfgffid5miijrhbr2jugj
  extra/yassl/taocrypt/include/des.hpp sp1f-des.hpp-20050428132313-hf7dbu77afvr7w4dvvoa5crxxx2b6ydb
  extra/yassl/taocrypt/include/file.hpp sp1f-file.hpp-20050428132314-suetfymp6etwtlywbaedxmkotd4p3opg
  extra/yassl/taocrypt/include/hash.hpp sp1f-hash.hpp-20050428132314-borjlquk3q2ddfbxkm27jhvnxp4lk7fs
  extra/yassl/taocrypt/include/integer.hpp sp1f-integer.hpp-20050428132315-3kekwcpo4kdfgckxq2lvgdrh2dp25ptb
  extra/yassl/taocrypt/include/kernelc.hpp sp1f-kernelc.hpp-20060406222010-k3qhurryayrni7gtpig65x55z6q4jinn
  extra/yassl/taocrypt/include/misc.hpp sp1f-misc.hpp-20050428132315-sndoqvfoyyrm36qprr7dloper7bgdref
  extra/yassl/taocrypt/include/modes.hpp sp1f-modes.hpp-20050428132316-td6cnzuargeuvsxs2vqse74d62tzbxtj
  extra/yassl/taocrypt/include/pwdbased.hpp sp1f-pwdbased.hpp-20060406222010-bpokcpy436xv66v2mkcnqzunk2scpgia
  extra/yassl/taocrypt/include/rsa.hpp sp1f-rsa.hpp-20050428132316-5ssb3th6gzgwdqvr73tfofl7b7szqpby
  extra/yassl/taocrypt/include/runtime.hpp sp1f-runtime.hpp-20050428132317-dlygl4ymyhutyqx6o6lyswa7ff2t6x6m
  extra/yassl/taocrypt/include/types.hpp sp1f-types.hpp-20050531155627-tlqjwae5ppoz4eujnxlkn5mdxpj3g54w
  extra/yassl/taocrypt/mySTL/stdexcept.hpp sp1f-stdexcept.hpp-20060925125017-msegxvrrtrjubps2xmfyojqdpfslwqdm
  extra/yassl/taocrypt/mySTL/vector.hpp sp1f-vector.hpp-20060925125017-6i52tljke4whmnl6qapht3fvtqmrdxpf
  extra/yassl/taocrypt/src/aes.cpp sp1f-aes.cpp-20050428132317-uxgjfy6orpo43a7y4rl43twubxicfuwx
  extra/yassl/taocrypt/src/aestables.cpp sp1f-aestables.cpp-20050428132317-vuxoljwls2btdkjhxsvfytijxuqgy655
  extra/yassl/taocrypt/src/algebra.cpp sp1f-algebra.cpp-20050428132318-l4wul3z6jyhw35f2lt3dcjumpfo4a6k5
  extra/yassl/taocrypt/src/arc4.cpp sp1f-arc4.cpp-20050428132318-4nrzqynftxwhjzk666pvimmvkohpnuls
  extra/yassl/taocrypt/src/asn.cpp sp1f-asn.cpp-20050428132318-okq6hllvtur6rcfg4gc5pbxebunf764v
  extra/yassl/taocrypt/src/blowfish.cpp sp1f-blowfish.cpp-20060406222010-beh7j2xgtab3towbsx2ab67o4dwfvbbr
  extra/yassl/taocrypt/src/coding.cpp sp1f-coding.cpp-20050428132318-jpfvjcvdr4i7r5x3qh35znxvpjq3dwe4
  extra/yassl/taocrypt/src/dsa.cpp sp1f-dsa.cpp-20050428132319-udtogpzkbjojv2bw6ysl7bohbdpnybiy
  extra/yassl/taocrypt/src/hash.cpp sp1f-hash.cpp-20050428132319-2cjtjj2apr5edrtczy7rbpz7b5enc3sl
  extra/yassl/taocrypt/src/integer.cpp sp1f-integer.cpp-20050428132320-2vatfv53z63b7dsohuirjujaevyb6dfs
  extra/yassl/taocrypt/src/make.bat* sp1f-make.bat-20060406222010-kinmq7ukjfi5gwebeyrjdjfwiinbbvyl
  extra/yassl/taocrypt/src/md4.cpp sp1f-md4.cpp-20060522131323-ihkxm7drq5hdhs3wuu2mffge5hrk3uz2
  extra/yassl/taocrypt/src/md5.cpp sp1f-md5.cpp-20050428132320-mqex3w7plzwhreh6nhb3ythr22sbw4q4
  extra/yassl/taocrypt/src/misc.cpp sp1f-misc.cpp-20050428132320-f5txb7caw354yqxg3gy6hdi6o3y7i57y
  extra/yassl/taocrypt/src/random.cpp sp1f-random.cpp-20050428132321-q6wudeoop6upz7agf4pmigiyw6d6d3mt
  extra/yassl/taocrypt/src/ripemd.cpp sp1f-ripemd.cpp-20050428132321-3cumwiky4hdu2qhtw26rzzkdyezyhacw
  extra/yassl/taocrypt/src/rsa.cpp sp1f-rsa.cpp-20050428132321-xkjlny4o37c63eayccfmliqssnj7kvnw
  extra/yassl/taocrypt/src/sha.cpp sp1f-sha.cpp-20050428132321-t4opn5f5tcgn4hqwduscydnyviba227i
  extra/yassl/taocrypt/src/template_instnt.cpp sp1f-template_instnt.cpp-20050531155627-b5iolfnczt7vosdpxnmmdgaa7affoaza
  extra/yassl/taocrypt/src/twofish.cpp sp1f-twofish.cpp-20060406222010-2kl46zuqro6t3ys6enrgmpbqg6xyyj4g
  extra/yassl/taocrypt/taocrypt.dsp sp1f-taocrypt.dsp-20050428132321-tm7vxgeut6vbrfmrzzgy5cdo63yxjrgs
  extra/yassl/taocrypt/test/make.bat* sp1f-make.bat-20060406222010-ycghya63j4t2hse4hu67l36vt3jr6wfe
  extra/yassl/taocrypt/test/memory.cpp sp1f-memory.cpp-20060406222010-kdxuxuuevhwxm5ljsq223nc6272ypm73
  extra/yassl/taocrypt/test/test.cpp sp1f-test.cpp-20060406222010-koh7ezcemwasfrlrbreb4fmnbvkitlep
  extra/yassl/testsuite/make.bat* sp1f-make.bat-20060406222011-hiqwmp3wdrny2l7xqbe3ge43sgophn72
  extra/yassl/testsuite/test.hpp sp1f-test.hpp-20060406222011-q4fidwoqe42be3efl4rhd5oxr2ozqllo
  extra/yassl/testsuite/testsuite.cpp sp1f-testsuite.cpp-20060406222011-f73taryyq4gahzieyoneoi6x6rtmbs5n
  include/CMakeLists.txt         cmakelists.txt-20091108233336-m9ewbh1c209yaw0h-28
  include/m_ctype.h              sp1f-m_ctype.h-19700101030959-dsoy764fhlrdbb6tsjldsk3e5fohfai6
  include/m_string.h             sp1f-m_string.h-19700101030959-rraattbvw5ffkokv4sixxf3s7brqqaga
  include/my_global.h            sp1f-my_global.h-20010915021246-4vawdgfw4vg3tuxq6mejt7lrchcnceha
  include/my_stacktrace.h        sp1f-stacktrace.h-20010513221240-cbiiu5humlsaar4gwejtppmg4trxkj47
  include/my_sys.h               sp1f-my_sys.h-19700101030959-lyllvna5vzqfcjnmlcrutgqocylhtb54
  include/my_valgrind.h          my_valgrind.h-20110704153950-8462etwl021h2b9y-1
  include/myisam.h               sp1f-myisam.h-19700101030959-2zv2wn7kuuvbyktuyfsitra6cl37h3mm
  include/mysql.h.pp             mysql.h.pp-20080613094407-2m1760u4zdzt4dc7-1
  include/mysql/plugin.h         sp1f-plugin.h-20051105112032-xacmvx22ghtcgtqhu6v56b4bneqtx7l5
  include/mysql/plugin_audit.h.pp plugin_audit.h.pp-20100820112644-7m3swx54hu8llako-1
  include/mysql/plugin_auth.h.pp plugin_auth.h.pp-20100809083003-jg96q8vfae3s4fcp-1
  include/mysql/plugin_ftparser.h.pp plugin_ftparser.h.pp-20100820112701-e0ivb121hvysfyqp-1
  include/mysql/services.h       services.h-20091102183141-xa3a00skaz3d3sga-4
  include/mysql_com.h            sp1f-mysql_com.h-19700101030959-a255cet4ojn7jbd4gb4wadueimhj57r7
  include/service_versions.h     service_versions.h-20091102183141-xa3a00skaz3d3sga-1
  include/welcome_copyright_notice.h welcome_copyright_no-20101005135656-p7fnkc5dqg336mkn-1
  libmysql/CMakeLists.txt        sp1f-cmakelists.txt-20060831175237-3bbprkzqdl3gopcnlt3evmaikau67bcq
  libmysqld/CMakeLists.txt       sp1f-cmakelists.txt-20060403082523-x3vxka3k56u2wpzwcrlpykznlz2akpxd
  libmysqld/examples/CMakeLists.txt sp1f-cmakelists.txt-20060403082846-qs2z7khuwbdcejrq62ruchgkp4vewfxd
  libservices/CMakeLists.txt     cmakelists.txt-20091102183209-n553i83fwdop79be-2
  libservices/HOWTO              howto-20091102183209-n553i83fwdop79be-3
  mysql-test/CMakeLists.txt      cmakelists.txt-20091108233336-m9ewbh1c209yaw0h-30
  mysql-test/collections/default.experimental default.experimental-20090224104813-e52mxw708penxv44-1
  mysql-test/extra/rpl_tests/rpl_insert_id_pk.test sp1f-rpl_insert_id_pk.tes-20060208154350-flqohbn7b5u5gqhi2vjoohkzat7ove7s
  mysql-test/extra/rpl_tests/rpl_multi_update.test sp1f-rpl_multi_update.tes-20051222053450-d5uy7cni7yhk44fizbbc6brtxh3fh56z
  mysql-test/extra/rpl_tests/rpl_multi_update2.test sp1f-rpl_multi_update2.te-20051222053450-6dbq7afy4dnxmcq6o5thbphetg2dvyw3
  mysql-test/extra/rpl_tests/rpl_multi_update3.test sp1f-rpl_multi_update3.te-20051222053450-clwzzqow34wk3zdj3y32epqo44l3eshn
  mysql-test/extra/rpl_tests/rpl_start_stop_slave.test sp1f-rpl_start_stop_slave-20041125082126-dkafmip36n5zdykbnlcpgwczz4hjkaqk
  mysql-test/include/mtr_check.sql sp1f-mtr_check.sql-20080409102737-d44u354i4sbvhamdh4fgbkf2sqvsvgty
  mysql-test/include/not_crashrep.inc not_crashrep.inc-20110114123855-sqsefeosp990rbk6-1
  mysql-test/include/query_cache.inc sp1f-innodb_cache.test-20011213003118-xsp2owsrgo3bo7sdwecltsmuzl7cwgir
  mysql-test/mysql-stress-test.pl sp1f-mysqlstresstest.pl-20051018162159-2oxz4uxwtkipjw3r7znlxngpg6l5vf63
  mysql-test/mysql-test-run.pl   sp1f-mysqltestrun.pl-20041230152716-xjnn5ndv4rr4by6ijmj5a4ysubxc7qh3
  mysql-test/r/cache_innodb.result sp1f-innodb_cache.result-20011213003118-g4i5k3o2g3my7h7i6l45qwp442h355bp
  mysql-test/r/csv.result        sp1f-csv.result-20040813035429-xygspmdjj5llofwnj6e4ahynqepuqyue
  mysql-test/r/ctype_ucs.result  sp1f-ctype_ucs.result-20030916112630-sohywipskzw3eqmbhfsqxqjteoun6t2g
  mysql-test/r/derived_view.result derived_view.result-20100429210222-m2cev70na5t81kgl-1
  mysql-test/r/error_simulation.result sp1f-error_simulation.res-20070607075906-xa3kpzpeuys6pitdn4jruh5bpdcoiwqq
  mysql-test/r/filesort_debug.result filesort_debug.resul-20110106134541-fb7ogxs3atlhlwd3-2
  mysql-test/r/func_in.result    sp1f-func_in.result-20001228015633-taucsvp7ggm45m64jbcfu6nyfgdhosnc
  mysql-test/r/func_time.result  sp1f-func_time.result-20001228015633-voo54ouzgwctcbmk22zwazoev5os5o4x
  mysql-test/r/innodb_ext_key.result innodb_ext_key.resul-20111231055541-g66ihtrsfs3fu0eo-1
  mysql-test/r/join.result       sp1f-join.result-20001228015633-f4navd6fbbzksvhaaqulo5ihgevkjty2
  mysql-test/r/join_cache.result join_cache.result-20091221012827-jfu65h0x5bmixhh3-1
  mysql-test/r/join_outer.result sp1f-join_outer.result-20001228015633-vk2jshiracfus3ze2d2bim2csnnrc5us
  mysql-test/r/join_outer_jcl6.result join_outer_jcl6.resu-20091221012858-uiftww98yhc31z02-1
  mysql-test/r/multi_update.result sp1f-multi_update.result-20010611232825-7f2vetuxiyd3bu5lefd5a2ze43xed33y
  mysql-test/r/myisam.result     sp1f-myisam.result-20010411215653-pgxkk2xg4lh3nxresmfnsuszf5h3nont
  mysql-test/r/mysqld--help.result mysqldhelp.result-20091210121810-wnsq93ex4gn8t8su-1
  mysql-test/r/partition.result  sp1f-partition.result-20050718113029-xlmjyugiq5h2b5wjp236ipsmkmej7i62
  mysql-test/r/partition_error.result sp1f-partition_error.resu-20050720124221-iacosg62tkflqhizuvhtiem5oeicwjit
  mysql-test/r/partition_innodb.result sp1f-partition_innodb.res-20060518171642-5muwpwnvtxepgop4yhgzzrv2xo2wjlps
  mysql-test/r/partition_pruning.result sp1f-partition_pruning.re-20051222092851-tdvef3tnyhio2fj4ktnbr4ienfg7k5qr
  mysql-test/r/plugin.result     sp1f-plugin.result-20061214230953-dljmjo3wuacc3eox3gwroufqmk3hlne7
  mysql-test/r/ps.result         sp1f-ps.result-20040405154119-efxzt5onloys45nfjak4gt44kr4awkdi
  mysql-test/r/range_vs_index_merge.result range_vs_index_merge-20091012044448-yb3s5ffmp6m60y3r-1
  mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff range_vs_index_merge-20120208201213-h2qfp78dnktupnni-2
  mysql-test/r/range_vs_index_merge_innodb.result range_vs_index_merge-20091012044457-ng2xbpvlta5mfvs2-1
  mysql-test/r/sp-bugs.result    spbugs.result-20091008145837-dfo321akug9vxs7z-2
  mysql-test/r/sp-code.result    sp1f-spcode.result-20051118153020-wmrrkha3uxtwtowtviryge45taxxk6p7
  mysql-test/r/sp.result         sp1f-sp.result-20030117133802-duandg3yzagzyv7zhhbbt2kcomcegpc7
  mysql-test/r/sp_notembedded.result sp1f-sp_notembedded.resul-20060224163410-okgh2uh6w7jxcoszw5y4sk6pq3ngt5n6
  mysql-test/r/sql_mode.result   sp1f-sql_mode.result-20030115233402-4ngo5orswx6jecypj7emeiqzup5smd3u
  mysql-test/r/strict.result     sp1f-strict.result-20040928170753-t5ampq424to7n62krizjgbhom3w5uffk
  mysql-test/r/subselect.result  subselect_scache.res-20110713142423-t6lrgrizahbpk2co-2
  mysql-test/r/subselect3.result sp1f-subselect3.result-20061031174245-v7hvtc7uwevifiq4lziwv5gdcxpeak7t
  mysql-test/r/subselect3_jcl6.result subselect3_jcl6.resu-20100117143923-cf6j4mu5zzng00u7-1
  mysql-test/r/subselect_no_mat.result subselect_no_mat.res-20100117143924-hut18sl9k2c7qdj8-1
  mysql-test/r/subselect_no_opts.result subselect_no_opts.re-20100117143925-pabg7o8iyokjlu93-1
  mysql-test/r/subselect_no_scache.result sp1f-subselect.result-20020512204640-zgegcsgavnfd7t7eyrf7ibuqomsw7uzo
  mysql-test/r/subselect_no_semijoin.result subselect_no_semijoi-20100117143925-9yfygtcm7fwsuq2p-1
  mysql-test/r/subselect_sj.result subselect_sj.result-20100117143926-nrop4ku355g3kv8b-1
  mysql-test/r/subselect_sj2.result subselect_sj2.result-20100117143927-4k8x8d6czjviugog-1
  mysql-test/r/subselect_sj2_jcl6,innodb_plugin.rdiff subselect_sj2_jcl6in-20120207142131-c8coyq1dzhk9b3hp-4
  mysql-test/r/subselect_sj2_jcl6.result subselect_sj2_jcl6.r-20100117143927-r3uxj2zuyjtrnokh-1
  mysql-test/r/subselect_sj2_mat.result subselect_sj2_mat.re-20110203133247-60oo2ydzq1r2g7ib-1
  mysql-test/r/subselect_sj_jcl6.result subselect_sj_jcl6.re-20100117143928-7vzk51yaf29cdavp-1
  mysql-test/r/subselect_sj_mat.result subselect_sj_mat.res-20100524221009-pdj0un54npqbnpcr-1
  mysql-test/r/subselect_sj_nonmerged.result subselect_sj_nonmerg-20110509190955-qez8cl79n7kmj030-1
  mysql-test/r/view.result       sp1f-view.result-20040715221517-nqk3l34grrhprjiitidhfjyjqlgh6a5v
  mysql-test/r/xa.result         sp1f-xa.result-20050403224953-ks6zlldv2mxqgh4edidq7sdrlmj7ko4l
  mysql-test/suite/binlog/r/binlog_sql_mode.result binlog_sql_mode.resu-20090228013050-26xcia0pj5n6pb45-1
  mysql-test/suite/binlog/r/binlog_unsafe.result sp1f-binlog_unsafe.result-20070514124535-jqttmp2p2jfelgeewle4swp5rb4j7pbi
  mysql-test/suite/binlog/t/binlog_sql_mode.test binlog_sql_mode.test-20090228013040-b237oc3mtgm8a2z3-1
  mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test binlog_stm_unsafe_wa-20090627130655-dgww8l4zomxa6h9l-3
  mysql-test/suite/binlog/t/binlog_unsafe.test sp1f-binlog_unsafe.test-20070514124535-pau2ov4yta3qsk5zbdwkywce3vhd54xr
  mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result db_alter_collate_asc-20100318063957-2dmdo1x4zoz5403e-40
  mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result db_alter_collate_utf-20100318063957-2dmdo1x4zoz5403e-41
  mysql-test/suite/innodb/r/group_commit_crash.result group_commit_crash.r-20101103154517-3aygrus3jb54zm9q-5
  mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result group_commit_crash_n-20110323142621-bqdeduqzmg76n3et-2
  mysql-test/suite/innodb/r/innodb-autoinc.result 2455 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Finnodb%2B%2Fmysql-test%2Finnodb-autoinc.result
  mysql-test/suite/innodb/r/innodb-index.result 1414 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb-index.result
  mysql-test/suite/innodb/r/innodb.result 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmysql-test%2Finnodb.result
  mysql-test/suite/innodb/t/group_commit_crash.test group_commit_crash.t-20101103154517-3aygrus3jb54zm9q-1
  mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test group_commit_crash_n-20110323142621-bqdeduqzmg76n3et-7
  mysql-test/suite/innodb/t/innodb-autoinc.test 2455 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Finnodb%2B%2Fmysql-test%2Finnodb-autoinc.test
  mysql-test/suite/innodb/t/innodb-index.test 1414 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb-index.test
  mysql-test/suite/innodb/t/innodb.test 1414 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb.test
  mysql-test/suite/innodb/t/innodb_bug34300.test 2455 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Finnodb%2B%2Fmysql-test%2Finnodb_bug34300.test
  mysql-test/suite/innodb/t/innodb_bug53756.test innodb_bug53756.test-20110210065500-5q1houbj07286cxl-1
  mysql-test/suite/maria/r/maria-autozerofill.result mariaautozerofill.re-20080707195605-a7q25y7nbr4vfpjx-1
  mysql-test/suite/maria/r/maria-recovery2.result mariarecovery2.resul-20080630093411-1pwfhsjq1fv1w1gc-1
  mysql-test/suite/maria/t/maria-autozerofill.test mariaautozerofill.te-20080707195601-x71s8bvwzcns888r-1
  mysql-test/suite/oqgraph/suite.opt suite.opt-20100412232042-krigdxpl8d8u3m19-1
  mysql-test/suite/oqgraph/suite.pm suite.pm-20100824124950-a6ymvab6maub7tuq-2
  mysql-test/suite/rpl/r/rpl_auto_increment_11932.result sp1f-rpl_auto_increment_1-20060503065640-ledbbwqepm2rhq2c2t2bcxv5py3haqp3
  mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result rpl_cant_read_event_-20110922182645-nrm6de43nn96v0qw-1
  mysql-test/suite/rpl/r/rpl_checksum.result rpl_checksum.result-20110429074157-v9ud6mfnk2es874n-8
  mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result sp1f-rpl_innodb_mixed_dml-20070206122521-55gg47nv2ebmatncbhfe7ihcle7wzd6n
  mysql-test/suite/rpl/r/rpl_insert_id_pk.result sp1f-rpl_insert_id_pk.res-20060208154441-d5of2xrisfjvjn32hl36vlc7ubgxmzde
  mysql-test/suite/rpl/r/rpl_known_bugs_detection.result sp1f-rpl_known_bugs_detec-20070208145312-rkcaxiqdn2ilhg7ghznmjftmxg5xqqee
  mysql-test/suite/rpl/r/rpl_log_pos.result sp1f-rpl000014.result-20001212220135-a5ffppjzfu3hlnpovghh4w3fdmgdmk6c
  mysql-test/suite/rpl/r/rpl_manual_change_index_file.result rpl_manual_change_in-20091210082846-phn3436ez8k1e97a-1
  mysql-test/suite/rpl/r/rpl_multi_update.result sp1f-rpl_multi_update.res-20031204214155-o7b7kddws2khwccwdzsw2b62echfhx3l
  mysql-test/suite/rpl/r/rpl_multi_update2.result sp1f-rpl_multi_update2.re-20050130102354-zvz22cpnujhjqyztzyl2m2mrpzcykctr
  mysql-test/suite/rpl/r/rpl_multi_update3.result sp1f-rpl_multi_update3.re-20050616203231-5u2sh6ebkn3zzdolvppdq7ojfxpgjnup
  mysql-test/suite/rpl/r/rpl_packet.result sp1f-rpl_packet.result-20060911211902-zl764nrlzzu3kom3pf3rrm6eltxveylw
  mysql-test/suite/rpl/r/rpl_rotate_logs.result sp1f-rpl000016.result-20001215004309-cb7o2ahawq7tlqn2c5be5wemg2fe5m7x
  mysql-test/suite/rpl/r/rpl_show_slave_hosts.result rpl_show_slave_hosts-20091020030026-5965391zbpba1jt8-1
  mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result sp1f-rpl_start_stop_slave-20041125082125-c4slzukwrdeef6bomxoxf3by4rlugnhg
  mysql-test/suite/rpl/t/rpl_auto_increment_11932.test sp1f-rpl_auto_increment_1-20060503065639-d5udbkc3wpezg7iyv7mrxpyib4p2g2ex
  mysql-test/suite/rpl/t/rpl_checksum.test rpl_checksum.test-20110429074157-v9ud6mfnk2es874n-12
  mysql-test/suite/rpl/t/rpl_multi_update2.test sp1f-rpl_multi_update2.te-20050130102355-ujevgj4og3rljopnxxa7lvlcgbq5y52g
  mysql-test/suite/rpl/t/rpl_multi_update3.test sp1f-rpl_multi_update3.te-20050616203114-y2jzc5mzhs5qne2h4qfit2kdukalj2f7
  mysql-test/suite/rpl/t/rpl_optimize.test sp1f-rpl_optimize.test-20040222102242-sa235qkcz6ilnydeaz2vkcubkou7kkyr
  mysql-test/suite/rpl/t/rpl_rotate_logs.test sp1f-rpl000016.test-20001215004309-uqid5ejphbyjwielf3t6nd7523ynp353
  mysql-test/suite/rpl/t/rpl_semi_sync_event.test rpl_semi_sync_event.-20091128144701-igemv6utxf9ov366-3
  mysql-test/suite/rpl/t/rpl_show_slave_hosts.test rpl_show_slave_hosts-20091020030413-tms3d9h9t31t4gj0-2
  mysql-test/suite/rpl/t/rpl_start_stop_slave.test rpl_start_stop_slave-20120117065646-2f4dwqwzlynpwnt0-1
  mysql-test/suite/rpl/t/rpl_timezone.test sp1f-rpl_timezone.test-20040618061121-pvoxjozqh37mmxq6duvd5limkzd2hj2m
  mysql-test/suite/sys_vars/r/debug_dbug_func.result sp1f-variables_debug.resu-20080226150357-xrpcjxbbb6lhnyicksx3a7ozn3i5wh5x
  mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_basic.result innodb_adaptive_flus-20100129060222-p8juqsnqxpovki1u-1
  mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_basic.result innodb_adaptive_hash-20100129060221-lihep0auyc2wf80o-1
  mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result innodb_large_prefix_-20110817025243-92i2h5tx7rmypnn2-1
  mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result innodb_random_read_a-20110719144937-b1qncp7yiumkhjbq-1
  mysql-test/suite/sys_vars/r/innodb_stats_on_metadata_basic.result innodb_stats_on_meta-20100129060214-9we0vb3euzk66alz-1
  mysql-test/suite/sys_vars/r/innodb_strict_mode_basic.result innodb_strict_mode_b-20100129060213-qezosjob8dkynbdp-1
  mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result sp1f-innodb_support_xa_ba-20080410131332-mbbi2rvvrnpwmnhcmv7q3bihsl4ophja
  mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result sp1f-innodb_table_locks_b-20080410131332-6idmj7nzhf2ao54argwpy4gcpgx5csgc
  mysql-test/suite/sys_vars/r/rpl_semi_sync_master_enabled_basic.result rpl_semi_sync_master-20100129060100-lxq3nwvvwhvmndhu-1
  mysql-test/suite/sys_vars/r/rpl_semi_sync_slave_enabled_basic.result rpl_semi_sync_slave_-20100129060056-fvtqdzxkj3y3l6wh-1
  mysql-test/suite/sys_vars/t/debug_dbug_func.test sp1f-variables_debug.test-20080226150357-odgq22hsyfmfw7na43dwgeuppys77opf
  mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_basic.test innodb_adaptive_flus-20100129055824-bfooz2lm8qlle9sf-1
  mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_basic.test innodb_adaptive_hash-20100129055823-0xarahctp86knkvk-1
  mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test innodb_large_prefix_-20110817025251-k8jwah3ukn9b3ic3-1
  mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test innodb_random_read_a-20110719144937-b1qncp7yiumkhjbq-2
  mysql-test/suite/sys_vars/t/innodb_stats_on_metadata_basic.test innodb_stats_on_meta-20100129055817-7ulju2pw7h9mx1av-1
  mysql-test/suite/sys_vars/t/innodb_strict_mode_basic.test innodb_strict_mode_b-20100129055815-ya2m1uqaanzwn1ut-1
  mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test sp1f-innodb_support_xa_ba-20080410131357-p6rsjjuynd562wmhqgmwarh46hbthemd
  mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test sp1f-innodb_table_locks_b-20080410131357-kluuntyilbrojwfomia5pnyyvdbgbysf
  mysql-test/suite/sys_vars/t/report_port_basic.test report_port_basic.te-20091218142509-7v4mjqsbsr728g1f-52
  mysql-test/t/csv.test          sp1f-csv.test-20040813035429-r4segxdqrdhxsixrtpgiksyj6dmyiylv
  mysql-test/t/ctype_ucs.test    sp1f-ctype_ucs.test-20030916112631-7diba44oovwv3h5kqbswfqbveczwbrxv
  mysql-test/t/derived_view.test derived_view.test-20100429210209-ex88ainrb3oc2d4n-1
  mysql-test/t/error_simulation.test sp1f-error_simulation.tes-20070607075906-744s5ceatbglwd2q3if5hfmarmy24kac
  mysql-test/t/events_restart.test sp1f-events_restart_phase-20060713085945-5px6siqcty3gcwlpi6qucrczqw5msvoy
  mysql-test/t/filesort_debug.test filesort_debug.test-20110106134541-fb7ogxs3atlhlwd3-1
  mysql-test/t/func_in.test      sp1f-func_in.test-20001228015635-dykb2qebuowolk7cf6gpa4brezc4m5gk
  mysql-test/t/join.test         sp1f-join.test-20001228015636-punt3oq3irbqswtbrlkelkxape6lttnl
  mysql-test/t/join_outer.test   sp1f-join_outer.test-20001228015636-himrcptylaquy6l5d7pl7pawom3ytmtw
  mysql-test/t/multi_update.test sp1f-multi_update.test-20010611232825-wkkm3vvyawipiowjzwqmkqegx6wd6aiw
  mysql-test/t/myisam.test       sp1f-myisam.test-20010411215653-cdmhjqbeu3xtipkauwbbirystludnac3
  mysql-test/t/mysqldump-no-binlog.test sp1f-mysqldumpnobinlog.te-20080307091549-gsznkxfsvgdjqsson2ypolejhx7fgmkj
  mysql-test/t/mysqldump.test    sp1f-mysqldump.test-20030924111344-fh6llfm45dls3uxwugociq3shkpxsxn3
  mysql-test/t/openssl_1.test    sp1f-ssl.test-20010831211355-mk47pipvythsqcor32yidzoopgdewdo6
  mysql-test/t/partition.test    sp1f-partition.test-20050718113034-pbo3ht3bf4gfa3mz44on3sqafyctwo35
  mysql-test/t/partition_error.test sp1f-partition_error.test-20050720124214-od2aou4vzloggrqktgmbjzvuhajiukpm
  mysql-test/t/partition_innodb.test sp1f-partition_innodb.tes-20060518171642-twfw23mpackjkfvorfvay4dhvjxhtbfm
  mysql-test/t/ps.test           sp1f-ps.test-20040405154119-4zqf6po44yypvz5foa2osprg5kb5ok63
  mysql-test/t/range_vs_index_merge.test range_vs_index_merge-20091012044353-5lvq3s1z3z60wdt8-1
  mysql-test/t/sp-bugs.test      spbugs.test-20091008145837-dfo321akug9vxs7z-1
  mysql-test/t/sp-code.test      sp1f-spcode.test-20051118153020-dnazftrwgxffrafbknyo465hqhduppds
  mysql-test/t/sp.test           sp1f-sp.test-20030117133803-b6pcfv2yscbqkur5fszep7acmdg7nf5k
  mysql-test/t/sp_notembedded.test sp1f-sp_notembedded.test-20060224163411-4bxzhibgkpu3fm3zoyvknrqo3zudvvfa
  mysql-test/t/sql_mode.test     sp1f-sql_mode.test-20030115233357-oryan464hu3t4h4jx46okyuqnhoioujm
  mysql-test/t/subselect.test    sp1f-subselect.test-20020512204640-lyqrayx6uwsn7zih6y7kerkenuitzbvr
  mysql-test/t/subselect_sj.test subselect_sj.test-20100117143931-qp396ufpe3k0scre-1
  mysql-test/t/subselect_sj2.test subselect_sj2.test-20100117143932-vxp9ugyy3s0mdo5j-1
  mysql-test/t/view.test         sp1f-view.test-20040715221517-2kxb7l4itrpl4mw266xe5gby4vftru3z
  mysql-test/t/xa.test           sp1f-xa.test-20050403224954-lwrpyxgzlsnvmlzqdkoeuxg62yhkyecp
  mysql-test/valgrind.supp       sp1f-valgrind.supp-20050406142216-yg7xhezklqhgqlc3inx36vbghodhbovy
  mysys/charset-def.c            sp1f-charsetdef.c-20031006195631-2zdalecmihnwhbxa6t6z67yy7avh5zgj
  mysys/lf_alloc-pin.c           lf_allocpin.c-20091118013037-913qkgtk23x27rpu-2
  mysys/my_addr_resolve.c        my_addr_resolve.c-20111209100537-b1eqh8fgltqswm18-1
  mysys/my_getsystime.c          sp1f-my_getsystime.c-20040302212107-h5blakn74xewolernjfpc23tn623kllm
  mysys/my_init.c                sp1f-my_init.c-19700101030959-ghisog5texwet5e5x7gn35bf4c4d3v3h
  mysys/my_new.cc                sp1f-my_new.cc-20011209220823-p26pqwnu4mbvwbp35yzzkwq4ocvmuvvb
  mysys/my_static.c              sp1f-my_static.c-19700101030959-vmmfiyygpz2awmm7d3pguy4rsuugbhcs
  mysys/my_symlink.c             sp1f-my_symlink.c-20010531091851-nnlz7igptpjfrbgf6sspd6vtv2hv63ab
  mysys/ptr_cmp.c                sp1f-ptr_cmp.c-19700101030959-pt5bze4uvwddaccqddrvr5fpa6czttuk
  mysys/stacktrace.c             sp1f-stacktrace.c-20010513221240-wwmyzt4dneecpsyuor3g7w3zacc6u4mq
  mysys/thr_lock.c               sp1f-thr_lock.c-19700101030959-igvxgo25qd7i2moc4pgo5eoth3xp34mh
  packaging/WiX/custom_ui.wxs    custom_ui.wxs-20100724134108-q1omercn9gzu3bli-1
  plugin/auth_examples/dialog_examples.c dialog.c-20100809083114-3klj7wt36fx4ojnl-14
  plugin/auth_examples/qa_auth_interface.c qa_auth_interface.c-20101020145224-3bu554xbd53lvgfb-2
  plugin/auth_examples/qa_auth_server.c qa_auth_server.c-20101020145224-3bu554xbd53lvgfb-3
  plugin/daemon_example/CMakeLists.txt cmakelists.txt-20091108233336-m9ewbh1c209yaw0h-36
  plugin/daemon_example/daemon_example.cc sp1f-daemon_example.c-20061111012154-pap3nupaza2ssvtmjkw5lq7l2yvwcdcv
  plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp hstcpsvr_worker.cpp-20110219131638-4j25tgv3pc5mergb-45
  plugin/handler_socket/libhsclient/fatal.cpp fatal.cpp-20110219131638-4j25tgv3pc5mergb-59
  plugin/semisync/semisync_master.cc semisync_master.cc-20090926043316-1tenv210xoci1uvm-8
  plugin/sql_errlog/CMakeLists.txt cmakelists.txt-20120309131554-q60o7y5n84cgpil8-2
  plugin/sql_errlog/sql_errlog.c sql_errlog.c-20120309131608-kwfoiomwoy4784fk-1
  scripts/mysql_install_db.pl.in sp1f-mysql_install_db.pl.-20071227210414-b22bp3cyv5jo3e27gkbbv2hpu4cxsay7
  scripts/mysql_install_db.sh    sp1f-mysql_install_db.sh-19700101030959-4m5n7i4aoib6psuxshrwl3qhkibxg7bp
  scripts/mysqld_safe.sh         sp1f-safe_mysqld.sh-19700101030959-y2kdxkfqgrb5lrpd7uclbpw7ljqmzxvj
  scripts/mytop.sh               mytop.sh-20110627161159-12i6t8if6e5q5v6c-1
  sql-common/my_time.c           sp1f-my_time.c-20040624160839-c5ljhxyjpi5czybdscnldwjexwdyx3o6
  sql/CMakeLists.txt             sp1f-cmakelists.txt-20060831175237-esoeu5kpdtwjvehkghwy6fzbleniq2wy
  sql/debug_sync.cc              debug_sync.cc-20090925124518-2m0htks1bbp5jaf5-5
  sql/debug_sync.h               debug_sync.h-20090925124518-2m0htks1bbp5jaf5-6
  sql/field.cc                   sp1f-field.cc-19700101030959-f4imaofclsea3n4fj4ow5m7havmyxa2r
  sql/filesort.cc                sp1f-filesort.cc-19700101030959-mfm2vmdgqqru7emm2meeecleb2q3zdso
  sql/ha_ndbcluster.h            sp1f-ha_ndbcluster.h-20040414175838-f2xtjmtguwmk5nwfkstanc4lig3fcuvm
  sql/ha_ndbcluster_binlog.h     sp1f-ha_ndbcluster_binlog-20060112185048-rbsiqmbfc7r3rhd6pjcyy2zwtpunvwix
  sql/ha_partition.cc            sp1f-ha_partition.cc-20050718113037-eoky4qluumb5dmdyg5z6n2fvdkgutxms
  sql/ha_partition.h             sp1f-ha_partition.h-20050718113038-4xxwqkuu2xgxqtrwfbc43zgfyfcwzjsq
  sql/handler.cc                 sp1f-handler.cc-19700101030959-ta6zfrlbxzucylciyro3musjsdpocrdh
  sql/handler.h                  sp1f-handler.h-19700101030959-mumq2hpilkpgxuf22ftyv5kbilysnzvn
  sql/item.cc                    sp1f-item.cc-19700101030959-u7hxqopwpfly4kf5ctlyk2dvrq4l3dhn
  sql/item.h                     sp1f-item.h-19700101030959-rrkb43htudd62batmoteashkebcwykpa
  sql/item_cmpfunc.cc            sp1f-item_cmpfunc.cc-19700101030959-hrk7pi2n6qpwxauufnkizirsoucdcx2e
  sql/item_cmpfunc.h             sp1f-item_cmpfunc.h-19700101030959-pcvbjplo4e4ng7ibynfhcd6pjyem57gr
  sql/item_func.cc               sp1f-item_func.cc-19700101030959-3wmsx76yvc25sroqpfrx2n77kqdxxn3y
  sql/item_subselect.cc          sp1f-item_subselect.cc-20020512204640-qep43aqhsfrwkqmrobni6czc3fqj36oo
  sql/item_timefunc.cc           sp1f-item_timefunc.cc-19700101030959-rvvlgmw5b4ewpuuxuntrkiqimyrr5sw2
  sql/item_xmlfunc.cc            sp1f-item_xmlfunc.cc-20051221130500-wo5dgojvjjm6mmra7fay3ri7ud5ow3yl
  sql/lock.cc                    sp1f-lock.cc-19700101030959-lzrt5tyolna3dcihuenjh7nlicr7llt7
  sql/log.cc                     sp1f-log.cc-19700101030959-r3hdfovek4kl6nd64ovoaknmirota6bq
  sql/log_event.cc               sp1f-log_event.cc-19700101030959-msmqlflsngxosswid2hpzxly5vfqdddc
  sql/log_event.h                sp1f-log_event.h-19700101030959-clq6ett55tcqbpys2i4cpfrdccq7j4om
  sql/mysqld.cc                  sp1f-mysqld.cc-19700101030959-zpswdvekpvixxzxf7gdtofzel7nywtfj
  sql/mysqld.h                   mysqld.h-20100331135644-cgcb6oowzqyx7fi3-11
  sql/opt_range.cc               sp1f-opt_range.cc-19700101030959-afe3wtevb7zwrg4xyibt35uamov5r7ds
  sql/opt_subselect.cc           opt_subselect.cc-20100215190428-nekkl8wisp0k6nlk-1
  sql/password.c                 sp1f-password.c-19700101030959-hyqrqz6vp4g26qbqvd4fq6z2ecdiqerx
  sql/protocol.cc                sp1f-net_pkg.cc-19700101030959-7izj6xxqwgfgxuikg6t24dhcwdedbl6i
  sql/records.cc                 sp1f-records.cc-19700101030959-xg6elqzdqhvrmobazxrjajmiyqxf7lx7
  sql/rpl_filter.cc              sp1f-table_filter.cc-20050308201116-4anzb26smj76r56ihkpxzbtnzlzatr2k
  sql/rpl_filter.h               sp1f-table_filter.h-20050308201116-ynbrrxlqijcoxfwgnipwjhgfw7vhdytw
  sql/rpl_handler.h              rpl_handler.h-20090926043211-4j841blpzpmkrczb-2
  sql/rpl_injector.cc            sp1f-rpl_injector.cc-20060112185049-nmh4krszzy7lfqbhbaznaczvq36kmykc
  sql/rpl_mi.cc                  sp1f-rpl_mi.cc-20061031155149-ifponask6mps7kiynabbuk7u6tb6k6ld
  sql/rpl_mi.h                   sp1f-rpl_mi.h-20061031155149-ty2i7rlwssgopgfuvbkilxy4c5miasqn
  sql/rpl_rli.cc                 sp1f-rpl_rli.cc-20061031112305-25t7pxjrjm24qo5h65c7rml66xu3uw4p
  sql/rpl_rli.h                  sp1f-rpl_rli.h-20051222053448-bte4b72jikihtk3zbn5jyj2vbiawtwgc
  sql/set_var.h                  sp1f-set_var.h-20020723153119-2yomygq3s4xjbqvuue3cdlpbjtj3kwmk
  sql/share/errmsg-utf8.txt      errmsgutf8.txt-20091015110028-k6y6a4bi5wlaxw53-1
  sql/signal_handler.cc          signal_handler.cc-20111122141101-njqkv8k88u89kenz-1
  sql/slave.cc                   sp1f-slave.cc-19700101030959-a636aj3mjxgu7fnznrg5kt77p3u2bvhh
  sql/sp_cache.cc                sp1f-sp_cache.cc-20030703140129-ugsn54s2jpxh7hdznsgxn6ubwvbtj5hw
  sql/sp_cache.h                 sp1f-sp_cache.h-20030703140129-67y2uethxrlpp7ajwnru6x3d2snz4xur
  sql/sp_head.cc                 sp1f-sp_head.cc-20021208185920-jtgc5wvyqdnu2gvcdus3gazrfhxbofxd
  sql/sp_head.h                  sp1f-sp_head.h-20021208185920-yrolg3rzamehfoejkbiai4q7njg5w6cd
  sql/sql_admin.cc               sql_table_maintenanc-20100813113324-ljhzawblfs477jro-2
  sql/sql_base.cc                sp1f-sql_base.cc-19700101030959-w7tul2gb2n4jzayjwlslj3ybmf3uhk6a
  sql/sql_cache.cc               sp1f-sql_cache.cc-19700101030959-74bsqwcnhboovijsogcenqana5inu6wo
  sql/sql_class.cc               sp1f-sql_class.cc-19700101030959-rpotnweaff2pikkozh3butrf7mv3oero
  sql/sql_connect.cc             sp1f-sql_connect.cc-20070223111352-fhh5znxdfvzxuca7da3uu4olnwgkrm4n
  sql/sql_delete.cc              sp1f-sql_delete.cc-19700101030959-ch2a6r6ushvc2vfwxt7ehcjuplelwthr
  sql/sql_handler.cc             sp1f-sql_handler.cc-20010406221833-l4tsiortoyipmoyajcoz2tcdppvyeltl
  sql/sql_join_cache.cc          sql_join_cache.cc-20091221012625-ipp8zu28iijhjmq2-1
  sql/sql_lex.cc                 sp1f-sql_lex.cc-19700101030959-4pizwlu5rqkti27gcwsvxkawq6bc2kph
  sql/sql_lex.h                  sp1f-sql_lex.h-19700101030959-sgldb2sooc7twtw5q7pgjx7qzqiaa3sn
  sql/sql_list.h                 sp1f-sql_list.h-19700101030959-hyddr5nvvtrgbk7llgnah4i4bf6ugspn
  sql/sql_parse.cc               sp1f-sql_parse.cc-19700101030959-ehcre3rwhv5l3mlxqhaxg36ujenxnrcd
  sql/sql_partition.cc           sp1f-sql_partition.cc-20050718113038-57h5bzswps6cel2y7k7qideue3ghbg3u
  sql/sql_partition.h            sp1f-sql_partition.h-20060216163825-un6ect3xl76xucer2pubythjlegvmy43
  sql/sql_plugin.cc              sp1f-sql_plugin.cc-20051105112032-hrm64p6xfjq33ud6zy3uivpo7azm75a2
  sql/sql_plugin_services.h      sql_plugin_services.-20091102183141-xa3a00skaz3d3sga-5
  sql/sql_prepare.cc             sp1f-sql_prepare.cc-20020612210720-gtqjjiu7vpmfxb5xct2qke7urmqcabli
  sql/sql_profile.cc             sp1f-sql_profile.cc-20070222150305-yv5grcusm3k2b6rrcx3kkqggtm33i3z4
  sql/sql_repl.cc                sp1f-sql_repl.cc-20001002032713-xqbns5ofqsaebhgi2ypcfn7nhz7nh5rp
  sql/sql_select.cc              sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb
  sql/sql_select.h               sp1f-sql_select.h-19700101030959-oqegfxr76xlgmrzd6qlevonoibfnwzoz
  sql/sql_show.cc                sp1f-sql_show.cc-19700101030959-umlljfnpplg452h7reeyqr4xnbmlkvfj
  sql/sql_table.cc               sp1f-sql_table.cc-19700101030959-tzdkvgigezpuaxnldqh3fx2h7h2ggslu
  sql/sql_udf.cc                 sp1f-sql_udf.cc-19700101030959-tk7ysmv4dpwkfhtdovfbqe5i6uvq67ft
  sql/sql_update.cc              sp1f-sql_update.cc-19700101030959-edlgskfuer2ylczbw2znrr5gzfefiyw7
  sql/sql_view.cc                sp1f-sql_view.cc-20040715221517-nw4p4mja6nzzlvwwhzfgfqb4umxqobe4
  sql/sql_yacc.yy                sp1f-sql_yacc.yy-19700101030959-wvn4qyy2drpmge7kaq3dysprbhlrv27j
  sql/sys_vars.cc                set_var_new.cc-20090803110928-jyk836zs40b2z8e3-1
  sql/sys_vars.h                 set_var_new.h-20090803110931-vmsjdorbe4cavl4e-1
  sql/table.cc                   sp1f-table.cc-19700101030959-nsxtem2adyqzwe6nz4cgrpcmts3o54v7
  sql/table.h                    sp1f-table.h-19700101030959-dv72bajftxj5fbdjuajquappanuv2ija
  sql/threadpool_unix.cc         threadpool_unix.cc-20111206025604-8metqls7xtteshwe-1
  sql/threadpool_win.cc          threadpool_win.cc-20111206025600-c3x46cyz1n70dagb-1
  sql/transaction.cc             transaction.cc-20080807231139-0scowboulgaz4j08-1
  sql/unireg.h                   sp1f-unireg.h-19700101030959-6vhptb2vfyo4mcjkgdm3n5uw6u64czfo
  storage/archive/ha_archive.cc  sp1f-ha_archive.cc-20040521001938-uy57z43drkjeirpjafdzdpvfxruqho4q
  storage/archive/ha_archive.h   sp1f-ha_archive.h-20040521001938-2znbujthgg7fimriindwgekrepwpb2x4
  storage/blackhole/ha_blackhole.cc sp1f-ha_blackhole.cc-20050323001036-ikllt6ts2equ6w4aru2q3rhdbrn64twz
  storage/csv/ha_tina.cc         sp1f-ha_tina.cc-20040813035429-5pwcme2ehkkuei6gu6ueo4tfldeeyw7l
  storage/csv/ha_tina.h          sp1f-ha_tina.h-20040813035430-sy73tmu2k4ln7oqqdk4ggkjrc75d2x3u
  storage/example/ha_example.cc  sp1f-ha_example.cc-20040331231732-d55r4dr2e7cf5dutte3f74z6h6yxdywb
  storage/federated/ha_federated.cc sp1f-ha_federated.cc-20041211200120-gu52ex5sicbua5vtoocuki3ltllsvm2c
  storage/heap/_check.c          sp1f-_check.c-19700101030959-sgi2guhiisou7o2v3rxbs6jqfikzvdsn
  storage/heap/heapdef.h         sp1f-heapdef.h-19700101030959-w5uzimyb2766kzenf2cdgppwq4dnlm2b
  storage/heap/hp_create.c       sp1f-hp_create.c-19700101030959-r3lpfh6ord53o3mlewvy4ig2gikmerwl
  storage/heap/hp_delete.c       sp1f-hp_delete.c-19700101030959-q7d6q5ne5m2n4f7u4yelrklhkm2ksgun
  storage/heap/hp_hash.c         sp1f-hp_hash.c-19700101030959-ethhaln7aj6b34av75b5wo7wna337f6e
  storage/heap/hp_info.c         sp1f-hp_info.c-19700101030959-xtkru2hsi4pyudf72hcgd77zq6pvud3a
  storage/heap/hp_test2.c        sp1f-hp_test2.c-19700101030959-istrlh2h6lqlrwuuixqarqmz2hgtwrlc
  storage/heap/hp_write.c        sp1f-hp_write.c-19700101030959-fyft5higet4kliqpr6vywernwiypjfzr
  storage/innobase/btr/btr0btr.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0btr.c
  storage/innobase/btr/btr0cur.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0cur.c
  storage/innobase/btr/btr0pcur.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0pcur.c
  storage/innobase/btr/btr0sea.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0sea.c
  storage/innobase/buf/buf0buf.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0buf.c
  storage/innobase/buf/buf0flu.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0flu.c
  storage/innobase/buf/buf0lru.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0lru.c
  storage/innobase/dict/dict0dict.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0dict.c
  storage/innobase/fil/fil0fil.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ffil%2Ffil0fil.c
  storage/innobase/fsp/fsp0fsp.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ffsp%2Ffsp0fsp.c
  storage/innobase/handler/ha_innodb.cc 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fhandler%2Fha_innodb.cc
  storage/innobase/handler/handler0alter.cc 1845 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fhandler%2Fhandler0alter.cc
  storage/innobase/ibuf/ibuf0ibuf.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fibuf%2Fibuf0ibuf.c
  storage/innobase/include/btr0btr.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0btr.h
  storage/innobase/include/btr0btr.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0btr.ic
  storage/innobase/include/btr0cur.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0cur.h
  storage/innobase/include/btr0cur.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0cur.ic
  storage/innobase/include/buf0buf.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbuf0buf.h
  storage/innobase/include/buf0buf.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbuf0buf.ic
  storage/innobase/include/buf0lru.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbuf0lru.h
  storage/innobase/include/buf0types.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbuf0types.h
  storage/innobase/include/dict0dict.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.h
  storage/innobase/include/dict0dict.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.ic
  storage/innobase/include/dict0mem.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0mem.h
  storage/innobase/include/fil0fil.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ffil0fil.h
  storage/innobase/include/fsp0fsp.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ffsp0fsp.h
  storage/innobase/include/log0log.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0log.h
  storage/innobase/include/mtr0mtr.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmtr0mtr.h
  storage/innobase/include/mtr0mtr.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmtr0mtr.ic
  storage/innobase/include/page0page.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fpage0page.h
  storage/innobase/include/page0page.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fpage0page.ic
  storage/innobase/include/srv0srv.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsrv0srv.h
  storage/innobase/include/sync0rw.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsync0rw.h
  storage/innobase/include/sync0rw.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsync0rw.ic
  storage/innobase/include/sync0sync.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsync0sync.h
  storage/innobase/include/trx0purge.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0purge.h
  storage/innobase/include/trx0rec.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0rec.ic
  storage/innobase/include/trx0undo.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0undo.h
  storage/innobase/include/ut0ut.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fut0ut.h
  storage/innobase/lock/lock0lock.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flock%2Flock0lock.c
  storage/innobase/log/log0log.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0log.c
  storage/innobase/mtr/mtr0mtr.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmtr%2Fmtr0mtr.c
  storage/innobase/os/os0file.c  2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0file.c
  storage/innobase/page/page0cur.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpage%2Fpage0cur.c
  storage/innobase/page/page0page.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpage%2Fpage0page.c
  storage/innobase/row/row0ins.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0ins.c
  storage/innobase/row/row0merge.c 1414 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Frow%2Frow0merge.c
  storage/innobase/row/row0mysql.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0mysql.c
  storage/innobase/row/row0row.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0row.c
  storage/innobase/row/row0sel.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0sel.c
  storage/innobase/row/row0upd.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0upd.c
  storage/innobase/srv/srv0srv.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0srv.c
  storage/innobase/srv/srv0start.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0start.c
  storage/innobase/sync/sync0rw.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0rw.c
  storage/innobase/sync/sync0sync.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0sync.c
  storage/innobase/trx/trx0purge.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0purge.c
  storage/innobase/trx/trx0rec.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0rec.c
  storage/innobase/trx/trx0sys.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0sys.c
  storage/innobase/trx/trx0trx.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0trx.c
  storage/innobase/trx/trx0undo.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0undo.c
  storage/maria/CMakeLists.txt   sp1f-cmakelists.txt-20060904145307-qtvi5bxnxyt7nzs4gtpsyte5vv3fwm2i
  storage/maria/ha_maria.cc      sp1f-ha_maria.cc-20060411134405-dmngb4v5x5fxlxhff527ud3etiutxuxk
  storage/maria/ha_maria.h       sp1f-ha_maria.h-20060411134405-vvsjodaugfqw4mekr3sxxnj26gukxxuo
  storage/maria/ma_close.c       sp1f-ma_close.c-20060411134409-5c3eq7j6oloex4c4hrvcqrsuvz7xohev
  storage/maria/ma_create.c      sp1f-ma_create.c-20060411134410-ozzigempkjj2kdgxfbasiwfjzwjejevd
  storage/maria/ma_extra.c       sp1f-ma_extra.c-20060411134414-odsjlm2dvwmrpwdcyu3eqmkilaatl3gb
  storage/maria/ma_open.c        sp1f-ma_open.c-20060411134425-47m3424sotlyyl5b3k5brotxm23ryffh
  storage/maria/ma_rename.c      sp1f-ma_rename.c-20060411134429-222uqg7girn62f3wbw47mc7pswjrhtqa
  storage/maria/ma_state.c       sp1f-ma_state.c-20080529153331-ttwxiq5ksyib6sdrdsdl2lnbbm362lwh
  storage/maria/maria_def.h      sp1f-maria_def.h-20060411134454-urdx4joxwcwzxbmltpzejn53y2rgjs44
  storage/maria/trnman.c         sp1f-trxman.c-20060816182810-j2a3jdxiefkpc62ad3xtioi44dbmr3dv
  storage/myisam/ft_boolean_search.c sp1f-ft_boolean_search.c-20010411110351-pu6lfsyiumvnnewko2oqbyjz6g3q4xm3
  storage/myisam/ft_nlq_search.c sp1f-ft_nlq_search.c-20010411110351-a7dhoojgfpsydi5k4qawswaatmakqe7b
  storage/myisam/ha_myisam.cc    sp1f-ha_myisam.cc-19700101030959-7xzssylbn7zfz3nupnsw43wws6xlltsu
  storage/myisam/ha_myisam.h     sp1f-ha_myisam.h-19700101030959-6vqsvuthz3pkfqplhfwzqrdryoixszpn
  storage/myisam/mi_check.c      sp1f-mi_check.c-19700101030959-yzbhnjgzcmqdyj4zz5codhkkw5eedp6f
  storage/myisam/mi_packrec.c    sp1f-mi_packrec.c-19700101030959-q5c7eimwd4jctgok3jwycbwjfq3qs6lj
  storage/myisam/mi_preload.c    sp1f-mi_preload.c-20030611165600-rxps6kg3kstoy3ctzurhnvi6czu6yqnx
  storage/myisam/myisamchk.c     sp1f-myisamchk.c-19700101030959-hdnrqowbdb3ujo3qgjtzs6lgogwckvgc
  storage/myisam/myisamdef.h     sp1f-myisamdef.h-19700101030959-fzrxvpmzhzqfn5w2clasmcw7af4kanoa
  storage/myisam/sort.c          sp1f-sort.c-19700101030959-n36775hcenftishba6lu6m7qtninzzgb
  storage/perfschema/ha_perfschema.cc ha_perfschema.cc-20100112014624-d08sjwithhzt6x1c-4
  storage/perfschema/pfs.cc      pfs.cc-20100112014624-d08sjwithhzt6x1c-6
  storage/perfschema/pfs_instr.cc pfs_instr.cc-20100112014624-d08sjwithhzt6x1c-20
  storage/perfschema/table_ews_global_by_event_name.cc table_ews_global_by_-20100812134112-n926y2hx4pkfq0y6-1
  storage/perfschema/table_ews_global_by_event_name.h table_ews_global_by_-20100812134112-n926y2hx4pkfq0y6-2
  storage/xtradb/fsp/fsp0fsp.c   fsp0fsp.c-20081201061010-zymrrwrczns2vrex-64
  storage/xtradb/handler/ha_innodb.cc ha_innodb.cc-20081201061010-zymrrwrczns2vrex-70
  storage/xtradb/include/ut0ut.h ut0ut.h-20081201061010-zymrrwrczns2vrex-263
  storage/xtradb/os/os0file.c    os0file.c-20081201061010-zymrrwrczns2vrex-313
  storage/xtradb/row/row0merge.c row0merge.c-20081201061010-zymrrwrczns2vrex-335
  storage/xtradb/row/row0sel.c   row0sel.c-20081201061010-zymrrwrczns2vrex-339
  strings/ctype-simple.c         sp1f-ctypesimple.c-20020312173754-2nnl6235owml5myqwzsl3uzlhz72bwho
  strings/ctype-uca.c            sp1f-ctypeuca.c-20040324121604-kwaskdasqzdrufymlf27j4gl3gwdy5fq
  strings/ctype-ucs2.c           sp1f-ctypeucs2.c-20030521102942-3fr4x6ti6jw6vqwdh7byhlxpu6oivdnn
  strings/ctype-utf8.c           sp1f-ctypeutf8.c-20020328133143-7ldgrkcon3ejrongwc7hy4m63qddjsal
  strings/decimal.c              sp1f-decimal.c-20041018120639-qqm4oeadwhbdhuxgwlc657il4tu44n6m
  strings/dtoa.c                 sp1f-dtoa.c-20071207165611-krn6cwngnnt5ewmrlc3vgnmddrnlkrzk
  support-files/CMakeLists.txt   cmakelists.txt-20091108233336-m9ewbh1c209yaw0h-33
  unittest/mysys/bitmap-t.c      sp1f-bitmap.t.c-20060404161610-egnwrukmbsmsvffsbdpoqap5rwmjqmfy
  unittest/mysys/my_atomic-t.c   sp1f-test_atomic.c-20060531164346-c6py6vo7ewoosyc3rm6z4hc3qtlzdogs
  unittest/mysys/thr_template.c  thr_template.c-20091117231939-lwiwbjiwz8fz8emn-1
  plugin/sql_errlog/service_logger.h service_logger.h-20120309142604-epp6z5qsp7x8i6gh-1
  plugin/sql_errlog/logger_service.c logger_service.c-20120309131431-ryy14kz0yfzf0v9j-1
  plugin/sql_errlog/sql_logger.cc my_logger.c-20120309131627-m9cjf8i37dgdugga-1
-------------- next part --------------
=== modified file '.bzrignore'
--- a/.bzrignore	2012-02-22 11:14:34 +0000
+++ b/.bzrignore	2012-04-02 09:30:14 +0000
@@ -1139,3 +1139,4 @@
 libmysqld/gcalc_tools.cc
 sql/share/errmsg.sys
 sql/share/mysql
+install_manifest.txt

=== modified file 'BUILD/SETUP.sh'
--- a/BUILD/SETUP.sh	2012-02-24 13:37:00 +0000
+++ b/BUILD/SETUP.sh	2012-03-20 13:23:56 +0000
@@ -148,6 +148,7 @@
 # Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro
 # LINT_INIT(), which is only useful for silencing spurious warnings
 # of static analysis tools. We want LINT_INIT() to be a no-op in Valgrind.
+valgrind_flags="-DHAVE_valgrind -USAFEMALLOC"
 valgrind_flags="$valgrind_flags -UFORCE_INIT_OF_VARS -Wno-uninitialized"
 valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
 valgrind_configs="--with-valgrind"

=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	2012-03-09 07:06:59 +0000
+++ b/CMakeLists.txt	2012-03-27 23:04:46 +0000
@@ -1,5 +1,5 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates.
-# Copyright (c) 2008-2011 Monty Program Ab
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates.
+# Copyright (c) 2008, 2012 Monty Program Ab
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

=== modified file 'VERSION'
--- a/VERSION	2012-03-09 07:06:59 +0000
+++ b/VERSION	2012-04-10 06:28:13 +0000
@@ -1,4 +1,4 @@
 MYSQL_VERSION_MAJOR=5
 MYSQL_VERSION_MINOR=5
-MYSQL_VERSION_PATCH=21
+MYSQL_VERSION_PATCH=23
 MYSQL_VERSION_EXTRA=

=== modified file 'client/CMakeLists.txt'
--- a/client/CMakeLists.txt	2012-02-22 11:14:34 +0000
+++ b/client/CMakeLists.txt	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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

=== modified file 'client/mysql_plugin.c'
--- a/client/mysql_plugin.c	2012-01-24 16:08:57 +0000
+++ b/client/mysql_plugin.c	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+   Copyright (c) 2011, 2012, 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
@@ -100,6 +100,7 @@
   char operation[16];
 
   MY_INIT(argv[0]);
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
   plugin_data.name= 0; // initialize name
   
   /*

=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2012-01-16 19:16:35 +0000
+++ b/client/mysql_upgrade.c	2012-03-23 09:53:25 +0000
@@ -255,7 +255,7 @@
     puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
     puts("MariaDB utility for upgrading databases to new MariaDB versions.\n");
     my_print_help(my_long_options);
-    exit(0);
+    die(0);
     break;
 
   case '#':

=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2012-01-13 14:50:02 +0000
+++ b/client/mysqladmin.cc	2012-03-23 09:53:25 +0000
@@ -307,6 +307,7 @@
 
   MY_INIT(argv[0]);
   mysql_init(&mysql);
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
   if ((error= load_defaults("my",load_default_groups,&argc,&argv)))
     goto err1;
   save_argv = argv;				/* Save for free_defaults */
@@ -329,6 +330,8 @@
   (void) signal(SIGINT,endprog);			/* Here if abort */
   (void) signal(SIGTERM,endprog);		/* Here if abort */
 
+  sf_leaking_memory=0; /* from now on we cleanup properly */
+
   if (opt_compress)
     mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
   if (opt_connect_timeout)

=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c	2012-01-13 14:50:02 +0000
+++ b/client/mysqlcheck.c	2012-03-23 09:53:25 +0000
@@ -975,6 +975,7 @@
   char **defaults_argv;
 
   MY_INIT(argv[0]);
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
   /*
   ** Check out the args
   */
@@ -984,6 +985,7 @@
   defaults_argv= argv;
   if (get_options(&argc, &argv))
     goto end1;
+  sf_leaking_memory=0; /* from now on we cleanup properly */
 
   ret= EX_MYSQLERR;
   if (dbConnect(current_host, current_user, opt_password))

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2012-03-09 07:06:59 +0000
+++ b/client/mysqldump.c	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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
@@ -590,17 +590,17 @@
 
 static void print_version(void)
 {
-  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION,
+  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname_short,DUMP_VERSION,
          MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
 } /* print_version */
 
 
 static void short_usage_sub(void)
 {
-  printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
+  printf("Usage: %s [OPTIONS] database [tables]\n", my_progname_short);
   printf("OR     %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
-         my_progname);
-  printf("OR     %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname);
+         my_progname_short);
+  printf("OR     %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname_short);
 }
 
 
@@ -620,7 +620,7 @@
 static void short_usage(void)
 {
   short_usage_sub();
-  printf("For more options, use %s --help\n", my_progname);
+  printf("For more options, use %s --help\n", my_progname_short);
 }
 
 
@@ -947,7 +947,7 @@
                 fields_terminated))
   {
     fprintf(stderr,
-            "%s: You must use option --tab with --fields-...\n", my_progname);
+            "%s: You must use option --tab with --fields-...\n", my_progname_short);
     return(EX_USAGE);
   }
 
@@ -965,7 +965,7 @@
   if (opt_single_transaction && opt_lock_all_tables)
   {
     fprintf(stderr, "%s: You can't use --single-transaction and "
-            "--lock-all-tables at the same time.\n", my_progname);
+            "--lock-all-tables at the same time.\n", my_progname_short);
     return(EX_USAGE);
   }
   if (opt_master_data)
@@ -977,14 +977,14 @@
     lock_tables= 0;
   if (enclosed && opt_enclosed)
   {
-    fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname);
+    fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname_short);
     return(EX_USAGE);
   }
   if ((opt_databases || opt_alldbs) && path)
   {
     fprintf(stderr,
             "%s: --databases or --all-databases can't be used with --tab.\n",
-            my_progname);
+            my_progname_short);
     return(EX_USAGE);
   }
   if (strcmp(default_charset, charset_info->csname) &&
@@ -1036,7 +1036,7 @@
   my_vsnprintf(buffer, sizeof(buffer), fmt_reason, args);
   va_end(args);
 
-  fprintf(stderr, "%s: %s\n", my_progname, buffer);
+  fprintf(stderr, "%s: %s\n", my_progname_short, buffer);
   fflush(stderr);
 
   ignore_errors= 0; /* force the exit */
@@ -1070,7 +1070,7 @@
   my_vsnprintf(buffer, sizeof(buffer), fmt_reason, args);
   va_end(args);
 
-  fprintf(stderr, "%s: %s\n", my_progname, buffer);
+  fprintf(stderr, "%s: %s\n", my_progname_short, buffer);
   fflush(stderr);
 
   maybe_exit(error_num);
@@ -2152,7 +2152,7 @@
           if (create_delimiter(row[3], delimiter, sizeof(delimiter)) == NULL)
           {
             fprintf(stderr, "%s: Warning: Can't create delimiter for event '%s'\n",
-                    my_progname, event_name);
+                    my_progname_short, event_name);
             DBUG_RETURN(1);
           }
 
@@ -2367,10 +2367,10 @@
           {
             if (opt_xml)
             {
-              if (i)                            // Procedures.
+              if (i)                            /* Procedures. */
                 print_xml_row(sql_file, "routine", routine_res, &row,
                               "Create Procedure");
-              else                              // Functions.
+              else                              /* Functions. */
                 print_xml_row(sql_file, "routine", routine_res, &row,
                               "Create Function");
               continue;
@@ -2766,7 +2766,7 @@
   else
   {
     verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
-                my_progname, mysql_error(mysql));
+                my_progname_short, mysql_error(mysql));
 
     my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
 
@@ -2877,7 +2877,7 @@
           goto continue_xml;
         }
         fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
-                my_progname, result_table, mysql_error(mysql));
+                my_progname_short, result_table, mysql_error(mysql));
         if (path)
           my_fclose(sql_file, MYF(MY_WME));
         DBUG_RETURN(0);
@@ -3533,7 +3533,7 @@
     if (mysql_num_fields(res) != num_fields)
     {
       fprintf(stderr,"%s: Error in field count for table: %s !  Aborting.\n",
-              my_progname, result_table);
+              my_progname_short, result_table);
       error= EX_CONSCHECK;
       goto err;
     }
@@ -3798,7 +3798,7 @@
     {
       my_snprintf(buf, sizeof(buf),
                   "%s: Error %d: %s when dumping table %s at row: %ld\n",
-                  my_progname,
+                  my_progname_short,
                   mysql_errno(mysql),
                   mysql_error(mysql),
                   result_table,
@@ -3992,8 +3992,8 @@
       DBUG_RETURN(0);
     }
 
-    my_printf_error(0, "Error: '%s' when trying to dump tablespaces",
-                    MYF(0), mysql_error(mysql));
+    fprintf(stderr, "%s: Error: '%s' when trying to dump tablespaces\n",
+                    my_progname_short, mysql_error(mysql));
     DBUG_RETURN(1);
   }
 
@@ -4138,8 +4138,8 @@
     if (mysql_query(mysql, "SHOW DATABASES") ||
         !(tableres= mysql_store_result(mysql)))
     {
-      my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s",
-                      MYF(0), mysql_error(mysql));
+      fprintf(stderr, "%s: Error: Couldn't execute 'SHOW DATABASES': %s\n",
+                      my_progname_short, mysql_error(mysql));
       return 1;
     }
     while ((row= mysql_fetch_row(tableres)))
@@ -4666,8 +4666,8 @@
       if (!ignore_errors)
       {
         /* SHOW MASTER STATUS reports nothing and --force is not enabled */
-        my_printf_error(0, "Error: Binlogging on server not active",
-                        MYF(0));
+        fprintf(stderr, "%s: Error: Binlogging on server not active\n",
+                my_progname_short);
         maybe_exit(EX_MYSQLERR);
         return 1;
       }
@@ -4750,7 +4750,7 @@
     if (!ignore_errors)
     {
       /* SHOW SLAVE STATUS reports nothing and --force is not enabled */
-      my_printf_error(0, "Error: Slave not set up", MYF(0));
+      fprintf(stderr, "%s: Error: Slave not set up\n", my_progname_short);
     }
     mysql_free_result(slave);
     return 1;
@@ -4810,7 +4810,7 @@
   /* now, start slave if stopped */
   if (mysql_query_with_error_report(mysql_con, 0, "START SLAVE"))
   {
-    my_printf_error(0, "Error: Unable to start slave", MYF(0));
+    fprintf(stderr, "%s: Error: Unable to start slave\n", my_progname_short);
     return 1;
   }
   return(0);
@@ -5452,8 +5452,9 @@
   char bin_log_name[FN_REFLEN];
   int exit_code;
   int consistent_binlog_pos= 0;
-  MY_INIT("mysqldump");
+  MY_INIT(argv[0]);
 
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
   compatible_mode_normal_str[0]= 0;
   default_charset= (char *)mysql_universal_client_charset;
   bzero((char*) &ignore_table, sizeof(ignore_table));
@@ -5464,6 +5465,7 @@
     free_resources();
     exit(exit_code);
   }
+  sf_leaking_memory=0; /* from now on we cleanup properly */
 
   /*
     Disable comments in xml mode if 'comments' option is not explicitly used.

=== modified file 'client/mysqlimport.c'
--- a/client/mysqlimport.c	2012-01-13 14:50:02 +0000
+++ b/client/mysqlimport.c	2012-03-23 09:53:25 +0000
@@ -613,6 +613,7 @@
 {
   int error=0;
   MY_INIT(argv[0]);
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
 
   if (load_defaults("my",load_default_groups,&argc,&argv))
     return 1;
@@ -623,6 +624,7 @@
     free_defaults(argv_to_free);
     return(1);
   }
+  sf_leaking_memory=0; /* from now on we cleanup properly */
 
 #ifdef HAVE_LIBPTHREAD
   if (opt_use_threads && !lock_tables)

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2012-01-13 14:50:02 +0000
+++ b/client/mysqlshow.c	2012-03-23 09:53:25 +0000
@@ -67,11 +67,13 @@
   char *wild;
   MYSQL mysql;
   MY_INIT(argv[0]);
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
   if (load_defaults("my",load_default_groups,&argc,&argv))
     exit(1);
 
   get_options(&argc,&argv);
 
+  sf_leaking_memory=0; /* from now on we cleanup properly */
   wild=0;
   if (argc)
   {

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2012-01-13 14:50:02 +0000
+++ b/client/mysqlslap.c	2012-03-23 09:53:25 +0000
@@ -317,6 +317,7 @@
   option_string *eptr;
 
   MY_INIT(argv[0]);
+  sf_leaking_memory=1; /* don't report memory leaks on early exits */
 
   if (load_defaults("my",load_default_groups,&argc,&argv))
   {
@@ -330,6 +331,7 @@
     my_end(0);
     exit(1);
   }
+  sf_leaking_memory=0; /* from now on we cleanup properly */
 
   /* Seed the random number generator if we will be using it. */
   if (auto_generate_sql)

=== modified file 'client/sql_string.cc.dontuse'
--- a/client/sql_string.cc.dontuse	2012-01-16 19:16:35 +0000
+++ b/client/sql_string.cc.dontuse	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'cmake/abi_check.cmake'
--- a/cmake/abi_check.cmake	2011-06-30 15:46:53 +0000
+++ b/cmake/abi_check.cmake	2012-03-28 17:26:00 +0000
@@ -55,6 +55,17 @@
     VERBATIM
   )
 
+  ADD_CUSTOM_TARGET(abi_update
+  COMMAND ${CMAKE_COMMAND} 
+    -DCOMPILER=${COMPILER}
+    -DABI_UPDATE=1
+    -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
+    -DBINARY_DIR=${CMAKE_BINARY_DIR}
+    "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
+    -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
+    VERBATIM
+  )
+
   ADD_CUSTOM_TARGET(abi_check_all
   COMMAND ${CMAKE_COMMAND} 
     -DCOMPILER=${COMPILER} 

=== modified file 'cmake/build_configurations/mysql_release.cmake'
--- a/cmake/build_configurations/mysql_release.cmake	2012-03-13 13:43:34 +0000
+++ b/cmake/build_configurations/mysql_release.cmake	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 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

=== modified file 'cmake/do_abi_check.cmake'
--- a/cmake/do_abi_check.cmake	2011-06-30 15:46:53 +0000
+++ b/cmake/do_abi_check.cmake	2012-03-28 17:26:00 +0000
@@ -75,8 +75,12 @@
   EXECUTE_PROCESS(
     COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result)
   IF(NOT ${result} EQUAL 0)
-    MESSAGE(FATAL_ERROR 
-      "ABI check found difference between ${file}.pp and ${abi_check_out}")
+    IF(ABI_UPDATE)
+      EXECUTE_PROCESS(COMMAND mv -v ${abi_check_out} ${file}.pp)
+    ELSE(ABI_UPDATE)
+      MESSAGE(FATAL_ERROR 
+        "ABI check found difference between ${file}.pp and ${abi_check_out}")
+    ENDIF(ABI_UPDATE)
   ENDIF()
   FILE(REMOVE ${abi_check_out})
 ENDFOREACH()

=== modified file 'cmake/install_layout.cmake'
--- a/cmake/install_layout.cmake	2012-01-23 11:20:16 +0000
+++ b/cmake/install_layout.cmake	2012-04-03 06:00:57 +0000
@@ -115,7 +115,7 @@
 SET(INSTALL_LIBDIR_STANDALONE           "lib")
 SET(INSTALL_PLUGINDIR_STANDALONE        "lib/plugin")
 #
-SET(INSTALL_INCLUDEDIR_STANDALONE       "include")
+SET(INSTALL_INCLUDEDIR_STANDALONE       "include/mysql")
 #
 SET(INSTALL_DOCDIR_STANDALONE           "docs")
 SET(INSTALL_DOCREADMEDIR_STANDALONE     ".")
@@ -198,7 +198,7 @@
 SET(INSTALL_LIBDIR_SVR4                 "lib")
 SET(INSTALL_PLUGINDIR_SVR4              "lib/plugin")
 #
-SET(INSTALL_INCLUDEDIR_SVR4             "include")
+SET(INSTALL_INCLUDEDIR_SVR4             "include/mysql")
 #
 SET(INSTALL_DOCDIR_SVR4                 "docs")
 SET(INSTALL_DOCREADMEDIR_SVR4           ".")

=== modified file 'cmake/install_macros.cmake'
--- a/cmake/install_macros.cmake	2012-03-16 19:52:17 +0000
+++ b/cmake/install_macros.cmake	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 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
@@ -40,17 +40,26 @@
     IF(CMAKE_GENERATOR MATCHES "Visual Studio")
       STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" pdb_location ${pdb_location})
     ENDIF()
-    IF(ARG_COMPONENT STREQUAL "Server" AND (target MATCHES "mysqld" OR type MATCHES "MODULE"))
-      #MESSAGE("PDB: ${targets}")
-      SET(comp Server)
-    ELSEIF(ARG_COMPONENT MATCHES Development 
-      OR ARG_COMPONENT MATCHES SharedLibraries 
-      OR ARG_COMPONENT MATCHES Embedded)
+	
+    set(comp "")
+    IF(ARG_COMPONENT STREQUAL "Server")
+      IF(target MATCHES "mysqld" OR type MATCHES "MODULE")
+        #MESSAGE("PDB: ${targets}")
+        SET(comp Server)
+      ENDIF()
+    ENDIF()
+ 
+    IF(NOT comp MATCHES Server)
+      IF(ARG_COMPONENT MATCHES Development
+        OR ARG_COMPONENT MATCHES SharedLibraries
+        OR ARG_COMPONENT MATCHES Embedded)
+        SET(comp Debuginfo)
+      ENDIF()
+    ENDIF()
 
-      SET(comp Debuginfo)
-    ELSE()
+    IF(NOT comp)
       SET(comp Debuginfo_archive_only) # not in MSI
-    ENDIF()	  
+    ENDIF()
     INSTALL(FILES ${pdb_location} DESTINATION ${ARG_INSTALL_LOCATION} COMPONENT ${comp})
   ENDFOREACH()
   ENDIF()

=== modified file 'cmake/make_dist.cmake.in'
--- a/cmake/make_dist.cmake.in	2011-06-10 07:12:10 +0000
+++ b/cmake/make_dist.cmake.in	2012-03-22 15:16:11 +0000
@@ -120,8 +120,13 @@
    ${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY)
 
 # Copy spec files
-CONFIGURE_FILE(${CMAKE_BINARY_DIR}/support-files/mysql.${VERSION}.spec
-   ${PACKAGE_DIR}/support-files/mysql.${VERSION}.spec COPYONLY)
+SET(SPECFILENAME "mysql.${VERSION}.spec")
+IF("${VERSION}" MATCHES "-ndb-")
+  STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+  SET(SPECFILENAME "mysql-cluster-${NDBVERSION}.spec")
+ENDIF()
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/support-files/${SPECFILENAME}
+   ${PACKAGE_DIR}/support-files/${SPECFILENAME} COPYONLY)
 
 # Add documentation, if user has specified where to find them
 IF(MYSQL_DOCS_LOCATION)

=== modified file 'cmake/mysql_version.cmake'
--- a/cmake/mysql_version.cmake	2011-11-03 18:17:05 +0000
+++ b/cmake/mysql_version.cmake	2012-04-10 06:28:13 +0000
@@ -57,7 +57,10 @@
   MESSAGE("-- MariaDB ${VERSION}")
   SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
   SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
-  STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${VERSION}")
+  # Use NDBVERSION irregardless of whether this is Cluster or not, if not
+  # then the regex will be ignored anyway.
+  STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+  STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${NDBVERSION}")
   MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}")
   MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
   SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
@@ -93,6 +96,10 @@
 
 IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
   SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION}")
+  IF("${VERSION}" MATCHES "-ndb-")
+    STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+    SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-cluster-gpl-${NDBVERSION}")
+  ENDIF()
 ENDIF()
 SET(CPACK_PACKAGE_CONTACT "MariaDB team <info at montyprogram.com>")
 SET(CPACK_PACKAGE_VENDOR "Monty Program AB")

=== modified file 'cmake/os/WindowsCache.cmake'
--- a/cmake/os/WindowsCache.cmake	2012-02-27 18:54:30 +0000
+++ b/cmake/os/WindowsCache.cmake	2012-03-22 14:44:06 +0000
@@ -137,6 +137,7 @@
 SET(HAVE_PCLOSE CACHE  INTERNAL "")
 SET(HAVE_PERROR 1 CACHE  INTERNAL "")
 SET(HAVE_PEERCRED CACHE INTERNAL "")
+SET(HAVE_PAM_APPL_H CACHE INTERNAL "")
 SET(HAVE_POLL_H CACHE  INTERNAL "")
 SET(HAVE_POPEN CACHE  INTERNAL "")
 SET(HAVE_POLL CACHE INTERNAL "")
@@ -248,6 +249,7 @@
 SET(HAVE_STRLCAT CACHE  INTERNAL "")
 SET(HAVE_STRLCPY CACHE  INTERNAL "")
 SET(HAVE_STRNCASECMP CACHE  INTERNAL "")
+SET(HAVE_STRNDUP CACHE  INTERNAL "")
 IF(MSVC_VERSION GREATER 1310)
 SET(HAVE_STRNLEN 1 CACHE  INTERNAL "")
 ENDIF()

=== modified file 'cmake/package_name.cmake'
--- a/cmake/package_name.cmake	2011-11-03 18:17:05 +0000
+++ b/cmake/package_name.cmake	2012-04-10 06:28:13 +0000
@@ -123,8 +123,15 @@
     SET(PRODUCT_TAG)
   ENDIF()
 
-  SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
-  
+  IF("${VERSION}" MATCHES "-ndb-")
+    STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+    SET(package_name "mysql-cluster${PRODUCT_TAG}-${NDBVERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
+  ELSE()
+    SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
+  ENDIF()
+
+  MESSAGE("-- Packaging as: ${package_name}")
+
   # Sometimes package suffix is added (something like "-icc-glibc23")
   IF(PACKAGE_SUFFIX)
     SET(package_name "${package_name}${PACKAGE_SUFFIX}")

=== modified file 'cmake/readline.cmake'
--- a/cmake/readline.cmake	2012-02-02 20:48:22 +0000
+++ b/cmake/readline.cmake	2012-04-11 23:33:43 +0000
@@ -210,7 +210,10 @@
     IF(WITH_READLINE)
       MYSQL_USE_BUNDLED_READLINE()
     ELSE()
-      MYSQL_FIND_SYSTEM_READLINE()
+      # OSX includes incompatible readline lib
+      IF (NOT APPLE)
+        MYSQL_FIND_SYSTEM_READLINE()
+      ENDIF()
       IF(NOT USE_NEW_READLINE_INTERFACE)
         MYSQL_FIND_SYSTEM_LIBEDIT()
         IF(NOT USE_LIBEDIT_INTERFACE)

=== modified file 'cmd-line-utils/libedit/chartype.h'
--- a/cmd-line-utils/libedit/chartype.h	2012-01-11 17:40:29 +0000
+++ b/cmd-line-utils/libedit/chartype.h	2012-03-30 13:00:10 +0000
@@ -49,7 +49,7 @@
   TODO : Verify if FreeBSD & AIX stores ISO 10646 in wchar_t. */
 #if !defined(__NetBSD__) && !defined(__sun) \
   && !(defined(__APPLE__) && defined(__MACH__)) \
-  && !defined(__FreeBSD__) && !defined(_AIX)
+  && !defined(__FreeBSD__) && !defined(_AIX) && !defined(__OpenBSD__)
 #ifndef __STDC_ISO_10646__
 /* In many places it is assumed that the first 127 code points are ASCII
  * compatible, so ensure wchar_t indeed does ISO 10646 and not some other

=== modified file 'cmd-line-utils/libedit/np/unvis.c'
--- a/cmd-line-utils/libedit/np/unvis.c	2011-10-29 18:08:40 +0000
+++ b/cmd-line-utils/libedit/np/unvis.c	2012-03-30 13:00:10 +0000
@@ -64,7 +64,7 @@
 #include "np/vis.h"
 
 #ifdef __weak_alias
-__weak_alias(strnunvisx,_strnunvisx)
+__weak_alias(strnunvisx,_strnunvisx);
 #endif
 
 #if !HAVE_VIS

=== modified file 'cmd-line-utils/libedit/np/vis.c'
--- a/cmd-line-utils/libedit/np/vis.c	2011-10-28 14:40:46 +0000
+++ b/cmd-line-utils/libedit/np/vis.c	2012-03-30 13:00:10 +0000
@@ -77,7 +77,7 @@
 #include <stdlib.h>
 
 #ifdef __weak_alias
-__weak_alias(strvisx,_strvisx)
+__weak_alias(strvisx,_strvisx);
 #endif
 
 #if !HAVE_VIS || !HAVE_SVIS

=== modified file 'configure.cmake'
--- a/configure.cmake	2012-02-23 14:31:24 +0000
+++ b/configure.cmake	2012-04-11 23:33:43 +0000
@@ -149,7 +149,9 @@
   SET(CMAKE_REQUIRED_LIBRARIES 
     ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT})
 
-  LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
+  IF(CMAKE_REQUIRED_LIBRARIES)
+    LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
+  ENDIF()
   LINK_LIBRARIES(${CMAKE_THREAD_LIBS_INIT})
   
   OPTION(WITH_LIBWRAP "Compile with tcp wrappers support" OFF)
@@ -397,6 +399,7 @@
 CHECK_FUNCTION_EXISTS (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE)
 CHECK_FUNCTION_EXISTS (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE)
 CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE)
+CHECK_FUNCTION_EXISTS (pthread_attr_getguardsize HAVE_PTHREAD_ATTR_GETGUARDSIZE)
 CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
 CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
 CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK)
@@ -435,7 +438,6 @@
 CHECK_FUNCTION_EXISTS (strsignal HAVE_STRSIGNAL)
 CHECK_FUNCTION_EXISTS (fgetln HAVE_FGETLN)
 CHECK_FUNCTION_EXISTS (strpbrk HAVE_STRPBRK)
-CHECK_FUNCTION_EXISTS (strsep HAVE_STRSEP)
 CHECK_FUNCTION_EXISTS (strstr HAVE_STRSTR)
 CHECK_FUNCTION_EXISTS (strtok_r HAVE_STRTOK_R)
 CHECK_FUNCTION_EXISTS (strtol HAVE_STRTOL)

=== modified file 'dbug/CMakeLists.txt'
--- a/dbug/CMakeLists.txt	2011-12-12 21:58:24 +0000
+++ b/dbug/CMakeLists.txt	2012-04-11 23:33:43 +0000
@@ -27,7 +27,7 @@
 ADD_EXECUTABLE(factorial my_main.c factorial.c)
 TARGET_LINK_LIBRARIES(factorial dbug)
 
-IF(NOT WIN32)
+IF(NOT WIN32 AND NOT CMAKE_GENERATOR MATCHES Xcode)
   FIND_PROGRAM(GROFF groff)
   FIND_PROGRAM(NROFF nroff)
   SET(OUTPUT_INC output1.r output2.r output3.r output4.r output5.r)
@@ -63,5 +63,5 @@
     ADD_CUSTOM_TARGET(t ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.t)
   ENDIF(NROFF)
 
-ENDIF(NOT WIN32)
+ENDIF()
 

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2012-02-22 11:14:34 +0000
+++ b/dbug/dbug.c	2012-03-24 20:51:10 +0000
@@ -172,6 +172,20 @@
 #define NOT_MATCHED     0
 
 /*
+ * Debugging settings can be shared between threads.
+ * But FILE* streams cannot normally be shared - what if
+ * one thread closes a stream, while another thread still uses it?
+ * As a workaround, we have shared FILE pointers with reference counters
+ */
+typedef struct {
+  FILE *file;
+  uint used;
+} sFILE;
+
+sFILE shared_stdout = { 0, 1 << 30 }, *sstdout = &shared_stdout;
+sFILE shared_stderr = { 0, 1 << 30 }, *sstderr = &shared_stderr;
+
+/*
  *      Debugging settings can be pushed or popped off of a
  *      stack which is implemented as a linked list.  Note
  *      that the head of the list is the current settings and the
@@ -186,7 +200,7 @@
   uint maxdepth;                /* Current maximum trace depth          */
   uint delay;                   /* Delay after each output line         */
   uint sub_level;               /* Sub this from code_state->level      */
-  FILE *out_file;               /* Current output stream                */
+  sFILE *out_file;              /* Current output stream                */
   char name[FN_REFLEN];         /* Name of output file                  */
   struct link *functions;       /* List of functions                    */
   struct link *keywords;        /* List of debug keywords               */
@@ -251,11 +265,11 @@
 
         /* OpenClose debug output stream */
 static void DBUGOpenFile(CODE_STATE *,const char *, const char *, int);
-static void DBUGCloseFile(CODE_STATE *cs, FILE *fp);
+static void DBUGCloseFile(CODE_STATE *cs, sFILE *new_value);
         /* Push current debug settings */
 static void PushState(CODE_STATE *cs);
 	/* Free memory associated with debug state. */
-static void FreeState (CODE_STATE *cs, struct settings *state, int free_state);
+static void FreeState (CODE_STATE *cs, int free_state);
         /* Test for tracing enabled */
 static int DoTrace(CODE_STATE *cs);
 /*
@@ -328,9 +342,11 @@
   if (!init_done)
   {
     init_done=TRUE;
+    sstdout->file= stdout;
+    sstderr->file= stderr;
     pthread_mutex_init(&THR_LOCK_dbug, NULL);
     bzero(&init_settings, sizeof(init_settings));
-    init_settings.out_file=stderr;
+    init_settings.out_file= sstderr;
     init_settings.flags=OPEN_APPEND;
   }
 
@@ -455,12 +471,12 @@
   rel= control[0] == '+' || control[0] == '-';
   if ((!rel || (!stack->out_file && !stack->next)))
   {
-    FreeState(cs, stack, 0);
+    FreeState(cs, 0);
     stack->flags= 0;
     stack->delay= 0;
     stack->maxdepth= 0;
     stack->sub_level= 0;
-    stack->out_file= stderr;
+    stack->out_file= sstderr;
     stack->functions= NULL;
     stack->keywords= NULL;
     stack->processes= NULL;
@@ -472,22 +488,17 @@
     stack->maxdepth= stack->next->maxdepth;
     stack->sub_level= stack->next->sub_level;
     strcpy(stack->name, stack->next->name);
+    stack->out_file= stack->next->out_file;
+    stack->out_file->used++;
     if (stack->next == &init_settings)
     {
-      /*
-        Never share with the global parent - it can change under your feet.
-
-        Reset out_file to stderr to prevent sharing of trace files between
-        global and session settings.
-      */
-      stack->out_file= stderr;
+      /* never share with the global parent - it can change under your feet */
       stack->functions= ListCopy(init_settings.functions);
       stack->keywords= ListCopy(init_settings.keywords);
       stack->processes= ListCopy(init_settings.processes);
     }
     else
     {
-      stack->out_file= stack->next->out_file;
       stack->functions= stack->next->functions;
       stack->keywords= stack->next->keywords;
       stack->processes= stack->next->processes;
@@ -581,10 +592,8 @@
     case 'o':
       if (sign < 0)
       {
-        if (!is_shared(stack, out_file))
-          DBUGCloseFile(cs, stack->out_file);
+        DBUGCloseFile(cs, sstderr);
         stack->flags &= ~FLUSH_ON_WRITE;
-        stack->out_file= stderr;
         break;
       }
       if (c == 'a' || c == 'A')
@@ -884,18 +893,15 @@
 
 void _db_pop_()
 {
-  struct settings *discard;
   uint old_fflags;
   CODE_STATE *cs;
 
   get_code_state_or_return;
 
-  discard= cs->stack;
-  if (discard != &init_settings)
+  if (cs->stack != &init_settings)
   {
     old_fflags=fflags(cs);
-    cs->stack= discard->next;
-    FreeState(cs, discard, 1);
+    FreeState(cs, 1);
     FixTraceFlags(old_fflags, cs);
   }
 }
@@ -1009,7 +1015,7 @@
   op_str_to_buf(
     ((cs->stack->flags & FLUSH_ON_WRITE ? 0 : 32) |
      (cs->stack->flags & OPEN_APPEND ? 'A' : 'O')),
-    cs->stack->name, cs->stack->out_file != stderr);
+    cs->stack->name, cs->stack->out_file != sstderr);
   op_list_to_buf('p', cs->stack->processes, cs->stack->processes);
   op_bool_to_buf('P', cs->stack->flags & PROCESS_ON);
   op_bool_to_buf('r', cs->stack->sub_level != 0);
@@ -1125,7 +1131,7 @@
         pthread_mutex_lock(&THR_LOCK_dbug);
       DoPrefix(cs, _line_);
       Indent(cs, cs->level);
-      (void) fprintf(cs->stack->out_file, ">%s\n", cs->func);
+      (void) fprintf(cs->stack->out_file->file, ">%s\n", cs->func);
       DbugFlush(cs);                       /* This does a unlock */
     }
     break;
@@ -1182,7 +1188,7 @@
         pthread_mutex_lock(&THR_LOCK_dbug);
       DoPrefix(cs, _line_);
       Indent(cs, cs->level);
-      (void) fprintf(cs->stack->out_file, "<%s\n", cs->func);
+      (void) fprintf(cs->stack->out_file->file, "<%s\n", cs->func);
       DbugFlush(cs);
     }
   }
@@ -1271,9 +1277,9 @@
     if (TRACING)
       Indent(cs, cs->level + 1);
     else
-      (void) fprintf(cs->stack->out_file, "%s: ", cs->func);
-    (void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword);
-    DbugVfprintf(cs->stack->out_file, format, args);
+      (void) fprintf(cs->stack->out_file->file, "%s: ", cs->func);
+    (void) fprintf(cs->stack->out_file->file, "%s: ", cs->u_keyword);
+    DbugVfprintf(cs->stack->out_file->file, format, args);
     DbugFlush(cs);
     errno=save_errno;
   }
@@ -1333,9 +1339,9 @@
     }
     else
     {
-      fprintf(cs->stack->out_file, "%s: ", cs->func);
+      fprintf(cs->stack->out_file->file, "%s: ", cs->func);
     }
-    (void) fprintf(cs->stack->out_file, "%s: Memory: 0x%lx  Bytes: (%ld)\n",
+    (void) fprintf(cs->stack->out_file->file, "%s: Memory: 0x%lx  Bytes: (%ld)\n",
             keyword, (ulong) memory, (long) length);
 
     pos=0;
@@ -1344,14 +1350,14 @@
       uint tmp= *((unsigned char*) memory++);
       if ((pos+=3) >= 80)
       {
-        fputc('\n',cs->stack->out_file);
+        fputc('\n',cs->stack->out_file->file);
         pos=3;
       }
-      fputc(_dig_vec_upper[((tmp >> 4) & 15)], cs->stack->out_file);
-      fputc(_dig_vec_upper[tmp & 15], cs->stack->out_file);
-      fputc(' ',cs->stack->out_file);
+      fputc(_dig_vec_upper[((tmp >> 4) & 15)], cs->stack->out_file->file);
+      fputc(_dig_vec_upper[tmp & 15], cs->stack->out_file->file);
+      fputc(' ',cs->stack->out_file->file);
     }
-    (void) fputc('\n',cs->stack->out_file);
+    (void) fputc('\n',cs->stack->out_file->file);
     DbugFlush(cs);
   }
   else if (!cs->locked)
@@ -1578,8 +1584,9 @@
  *	state. If free_state is set, also free 'state'
  *
  */
-static void FreeState(CODE_STATE *cs, struct settings *state, int free_state)
+static void FreeState(CODE_STATE *cs, int free_state)
 {
+  struct settings *state= cs->stack;
   if (!is_shared(state, keywords))
     FreeList(state->keywords);
   if (!is_shared(state, functions))
@@ -1587,13 +1594,14 @@
   if (!is_shared(state, processes))
     FreeList(state->processes);
 
-  if (!is_shared(state, out_file))
-    DBUGCloseFile(cs, state->out_file);
-  else
-    (void) fflush(state->out_file);
+  DBUGCloseFile(cs, NULL);
 
   if (free_state)
-    free((void*) state);
+  {
+    struct settings *next= state->next;
+    free(state);
+    cs->stack= next;
+  }
 }
 
 
@@ -1616,9 +1624,7 @@
  */
 void _db_end_()
 {
-  struct settings *discard;
-  static struct settings tmp;
-  CODE_STATE *cs;
+  CODE_STATE *cs, dummy_cs;
   /*
     Set _dbug_on_ to be able to do full reset even when DEBUGGER_OFF was
     called after dbug was initialized
@@ -1627,24 +1633,18 @@
   cs= code_state();
 
   if (cs)
-    while ((discard= cs->stack))
-    {
-      if (discard == &init_settings)
-        break;
-      cs->stack= discard->next;
-      FreeState(cs, discard, 1);
-    }
-  tmp= init_settings;
+  {
+    while (cs->stack && cs->stack != &init_settings)
+      FreeState(cs, 1);
+  }
+  else
+  {
+    cs= &dummy_cs;
+    bzero(cs, sizeof(*cs));
+  }
 
-  init_settings.flags=    OPEN_APPEND;
-  init_settings.out_file= stderr;
-  init_settings.maxdepth= 0;
-  init_settings.delay= 0;
-  init_settings.sub_level= 0;
-  init_settings.functions= 0;
-  init_settings.keywords= 0;
-  init_settings.processes= 0;
-  FreeState(cs, &tmp, 0);
+  cs->stack= &init_settings;
+  FreeState(cs, 0);
 }
 
 
@@ -1683,7 +1683,7 @@
 {
   CODE_STATE *cs;
   get_code_state_or_return NULL;
-  return cs->stack->out_file;
+  return cs->stack->out_file->file;
 }
 
 /*
@@ -1744,9 +1744,9 @@
   for (count= 0; count < indent ; count++)
   {
     if ((count % INDENT) == 0)
-      fputc('|',cs->stack->out_file);
+      fputc('|',cs->stack->out_file->file);
     else
-      fputc(' ',cs->stack->out_file);
+      fputc(' ',cs->stack->out_file->file);
   }
 }
 
@@ -1805,10 +1805,10 @@
   cs->lineno++;
   if (cs->stack->flags & PID_ON)
   {
-    (void) fprintf(cs->stack->out_file, "%-7s: ", my_thread_name());
+    (void) fprintf(cs->stack->out_file->file, "%-7s: ", my_thread_name());
   }
   if (cs->stack->flags & NUMBER_ON)
-    (void) fprintf(cs->stack->out_file, "%5d: ", cs->lineno);
+    (void) fprintf(cs->stack->out_file->file, "%5d: ", cs->lineno);
   if (cs->stack->flags & TIMESTAMP_ON)
   {
 #ifdef __WIN__
@@ -1816,7 +1816,7 @@
        in system ticks, 10 ms intervals. See my_getsystime.c for high res */
     SYSTEMTIME loc_t;
     GetLocalTime(&loc_t);
-    (void) fprintf (cs->stack->out_file,
+    (void) fprintf (cs->stack->out_file->file,
                     /* "%04d-%02d-%02d " */
                     "%02d:%02d:%02d.%06d ",
                     /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/
@@ -1828,7 +1828,7 @@
     {
       if ((tm_p= localtime((const time_t *)&tv.tv_sec)))
       {
-        (void) fprintf (cs->stack->out_file,
+        (void) fprintf (cs->stack->out_file->file,
                         /* "%04d-%02d-%02d " */
                         "%02d:%02d:%02d.%06d ",
                         /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/
@@ -1839,13 +1839,13 @@
 #endif
   }
   if (cs->stack->flags & PROCESS_ON)
-    (void) fprintf(cs->stack->out_file, "%s: ", cs->process);
+    (void) fprintf(cs->stack->out_file->file, "%s: ", cs->process);
   if (cs->stack->flags & FILE_ON)
-    (void) fprintf(cs->stack->out_file, "%14s: ", BaseName(cs->file));
+    (void) fprintf(cs->stack->out_file->file, "%14s: ", BaseName(cs->file));
   if (cs->stack->flags & LINE_ON)
-    (void) fprintf(cs->stack->out_file, "%5d: ", _line_);
+    (void) fprintf(cs->stack->out_file->file, "%5d: ", _line_);
   if (cs->stack->flags & DEPTH_ON)
-    (void) fprintf(cs->stack->out_file, "%4d: ", cs->level);
+    (void) fprintf(cs->stack->out_file->file, "%4d: ", cs->level);
 }
 
 
@@ -1884,9 +1884,7 @@
     name=cs->stack->name;
     if (strcmp(name, "-") == 0)
     {
-      if (!is_shared(cs->stack, out_file))
-        DBUGCloseFile(cs, cs->stack->out_file);
-      cs->stack->out_file= stdout;
+      DBUGCloseFile(cs, sstdout);
       cs->stack->flags |= FLUSH_ON_WRITE;
       cs->stack->name[0]=0;
     }
@@ -1908,9 +1906,10 @@
         }
         else
         {
-          if (!is_shared(cs->stack, out_file))
-            DBUGCloseFile(cs, cs->stack->out_file);
-          cs->stack->out_file= fp;
+          sFILE *sfp= (sFILE *)DbugMalloc(sizeof(sFILE));
+          sfp->file= fp;
+          sfp->used= 1;
+          DBUGCloseFile(cs, sfp);
         }
       }
     }
@@ -1934,16 +1933,30 @@
  *
  */
 
-static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
+static void DBUGCloseFile(CODE_STATE *cs, sFILE *new_value)
 {
-  if (cs && fp && fp != stderr && fp != stdout && fclose(fp) == EOF)
+  sFILE *fp;
+  if (!cs || !cs->stack || !cs->stack->out_file)
+    return;
+  if (!cs->locked)
+    pthread_mutex_lock(&THR_LOCK_dbug);
+
+  fp= cs->stack->out_file;
+  if (--fp->used == 0)
   {
-    if (!cs->locked)
-      pthread_mutex_lock(&THR_LOCK_dbug);
-    (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);
-    perror("");
-    DbugFlush(cs);
+    if (fclose(fp->file) == EOF)
+    {
+      (void) fprintf(stderr, ERR_CLOSE, cs->process);
+      perror("");
+    }
+    else
+    {
+      free(fp);
+    }
   }
+  cs->stack->out_file= new_value;
+  if (!cs->locked)
+    pthread_mutex_unlock(&THR_LOCK_dbug);
 }
 
 
@@ -2111,7 +2124,7 @@
 {
   if (cs->stack->flags & FLUSH_ON_WRITE)
   {
-    (void) fflush(cs->stack->out_file);
+    (void) fflush(cs->stack->out_file->file);
     if (cs->stack->delay)
       (void) Delay(cs->stack->delay);
   }
@@ -2126,7 +2139,7 @@
 {
   CODE_STATE *cs;
   get_code_state_or_return;
-  (void) fflush(cs->stack->out_file);
+  (void) fflush(cs->stack->out_file->file);
 }
 
 

=== modified file 'debian/dist/Debian/rules'
--- a/debian/dist/Debian/rules	2012-02-06 12:30:39 +0000
+++ b/debian/dist/Debian/rules	2012-04-03 06:00:57 +0000
@@ -169,8 +169,6 @@
 	# libmysqlclient-dev: forgotten header file since 3.23.25?
 	cp $(BUILDDIR)/include/my_config.h $(TMP)/usr/include/mysql/
 	cp include/my_dir.h $(TMP)/usr/include/mysql/
-	mv $(TMP)/usr/include/mysql/mysql/*.h $(TMP)/usr/include/mysql/
-	mv $(TMP)/usr/include/mysql/mysql/psi $(TMP)/usr/include/mysql/
 
 	# mysql-common: We provide our own version of this package for
 	# completeness, but we can use an existing version; mariadb-specic

=== modified file 'debian/dist/Ubuntu/rules'
--- a/debian/dist/Ubuntu/rules	2012-01-28 20:22:14 +0000
+++ b/debian/dist/Ubuntu/rules	2012-04-03 06:00:57 +0000
@@ -169,8 +169,6 @@
 	# libmysqlclient-dev: forgotten header file since 3.23.25?
 	cp $(BUILDDIR)/include/my_config.h $(TMP)/usr/include/mysql/
 	cp include/my_dir.h $(TMP)/usr/include/mysql/
-	mv $(TMP)/usr/include/mysql/mysql/*.h $(TMP)/usr/include/mysql/
-	mv $(TMP)/usr/include/mysql/mysql/psi $(TMP)/usr/include/mysql/
 
 	# mysql-common: We provide our own version of this package for
 	# completeness, but we can use an existing version; mariadb-specic

=== modified file 'extra/yassl/INSTALL'
--- a/extra/yassl/INSTALL	2005-04-28 13:23:27 +0000
+++ b/extra/yassl/INSTALL	2012-02-10 14:33:27 +0000
@@ -1,13 +1,19 @@
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
-
-   This file is free documentation; the Free Software Foundation gives
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
 unlimited permission to copy, distribute and modify it.
 
 Basic Installation
 ==================
 
-   These are generic installation instructions.
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
 
    The `configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
@@ -20,9 +26,9 @@
 
    It can also use an optional file (typically called `config.cache'
 and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  (Caching is
+the results of its tests to speed up reconfiguring.  Caching is
 disabled by default to prevent problems with accidental use of stale
-cache files.)
+cache files.
 
    If you need to do unusual things to compile the package, please try
 to figure out how `configure' could check whether to do them, and mail
@@ -32,20 +38,17 @@
 may remove or edit it.
 
    The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
 
 The simplest way to compile this package is:
 
   1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.  If you're
-     using `csh' on an old version of System V, you might need to type
-     `sh ./configure' instead to prevent `csh' from trying to execute
-     `configure' itself.
+     `./configure' to configure the package for your system.
 
-     Running `configure' takes awhile.  While running, it prints some
-     messages telling which features it is checking for.
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
 
   2. Type `make' to compile the package.
 
@@ -67,51 +70,49 @@
 Compilers and Options
 =====================
 
-   Some systems require unusual options for compilation or linking that
-the `configure' script does not know about.  Run `./configure --help'
-for details on some of the pertinent environment variables.
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
 
    You can give `configure' initial values for configuration parameters
 by setting variables in the command line or in the environment.  Here
 is an example:
 
-     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
 
    *Note Defining Variables::, for more details.
 
 Compiling For Multiple Architectures
 ====================================
 
-   You can compile the package for more than one kind of computer at the
+You can compile the package for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
-own directory.  To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+own directory.  To do this, you can use GNU `make'.  `cd' to the
 directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
 source code in the directory that `configure' is in and in `..'.
 
-   If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory.  After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
 
 Installation Names
 ==================
 
-   By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc.  You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
 
    In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
+options like `--bindir=DIR' to specify different values for particular
 kinds of files.  Run `configure --help' for a list of the directories
 you can set and what kinds of files go in them.
 
@@ -122,7 +123,7 @@
 Optional Features
 =================
 
-   Some packages pay attention to `--enable-FEATURE' options to
+Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
 is something like `gnu-as' or `x' (for the X Window System).  The
@@ -137,11 +138,11 @@
 Specifying the System Type
 ==========================
 
-   There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on.  Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
 `--build=TYPE' option.  TYPE can either be a short name for the system
 type, such as `sun4', or a canonical name which has the form:
 
@@ -156,7 +157,7 @@
 need to know the machine type.
 
    If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
+use the option `--target=TYPE' to select the type of system they will
 produce code for.
 
    If you want to _use_ a cross compiler, that generates code for a
@@ -167,9 +168,9 @@
 Sharing Defaults
 ================
 
-   If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
 `configure' looks for `PREFIX/share/config.site' if it exists, then
 `PREFIX/etc/config.site' if it exists.  Or, you can set the
 `CONFIG_SITE' environment variable to the location of the site script.
@@ -178,7 +179,7 @@
 Defining Variables
 ==================
 
-   Variables not defined in a site shell script can be set in the
+Variables not defined in a site shell script can be set in the
 environment passed to `configure'.  However, some packages may run
 configure again during the build, and the customized values of these
 variables may be lost.  In order to avoid this problem, you should set
@@ -186,14 +187,18 @@
 
      ./configure CC=/usr/local2/bin/gcc
 
-will cause the specified gcc to be used as the C compiler (unless it is
+causes the specified `gcc' to be used as the C compiler (unless it is
 overridden in the site shell script).
 
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
 `configure' Invocation
 ======================
 
-   `configure' recognizes the following options to control how it
-operates.
+`configure' recognizes the following options to control how it operates.
 
 `--help'
 `-h'

=== modified file 'extra/yassl/README'
--- a/extra/yassl/README	2007-03-23 10:52:25 +0000
+++ b/extra/yassl/README	2012-03-02 12:12:07 +0000
@@ -1,3 +1,120 @@
+*** Note, Please read ***
+
+yaSSL takes a different approach to certificate verification than OpenSSL does.
+The default policy for the client is to verify the server, this means that if
+you don't load CAs to verify the server you'll get a connect error, unable to 
+verify.  It you want to mimic OpenSSL behavior of not verifying the server and
+reducing security you can do this by calling:
+
+SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
+
+before calling SSL_new();
+
+*** end Note ***
+
+yaSSL Release notes, version 2.1.2 (9/2/2011)
+
+    This release of yaSSL contains bug fixes, better non-blocking support with
+    SSL_write, and OpenSSL RSA public key format support.
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 2.0.0 (7/6/2010)
+
+    This release of yaSSL contains bug fixes, new testing certs,
+    and a security patch for a potential heap overflow on forged application
+    data processing.  Vulnerability discovered by Matthieu Bonetti from VUPEN
+    Security http://www.vupen.com.
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.9.9 (1/26/2010)
+
+    This release of yaSSL contains bug fixes, the removal of assert() s and
+    a security patch for a buffer overflow possibility in certificate name
+    processing. 
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.9.8 (10/14/09)
+
+    This release of yaSSL contains bug fixes and adds new stream ciphers
+    Rabbit and HC-128
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.9.6 (11/13/08)
+
+    This release of yaSSL contains bug fixes, adds autconf shared library
+    support and has better server suite detection based on certficate and
+    private key.
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.9.2 (9/24/08)
+
+    This release of yaSSL contains bug fixes and improved certificate verify
+    callback support. 
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.8.8 (5/7/08)
+
+    This release of yaSSL contains bug fixes, and better socket handling. 
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.8.6 (1/31/08)
+
+    This release of yaSSL contains bug fixes, and fixes security problems
+    associated with using SSL 2.0 client hellos and improper input handling.
+    Please upgrade to this version if you are using a previous one. 
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.7.5 (10/15/07)
+
+    This release of yaSSL contains bug fixes, adds MSVC 2005 project support,
+    GCC 4.2 support, IPV6 support and test, and new test certificates. 
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.7.2 (8/20/07)
+
+    This release of yaSSL contains bug fixes and adds initial OpenVPN support.
+    Just configure at this point and beginning of build. 
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
+*****************yaSSL Release notes, version 1.6.8 (4/16/07)
+
+    This release of yaSSL contains bug fixes and adds SHA-256, SHA-512, SHA-224,
+    and SHA-384.
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
 *****************yaSSL Release notes, version 1.6.0 (2/22/07)
 
     This release of yaSSL contains bug fixes, portability enhancements, and
@@ -13,7 +130,7 @@
 
 
 
-    Since yaSSL now supports zlib, as does libcur, the libcurl build test can
+    Since yaSSL now supports zlib, as does libcurl, the libcurl build test can
     fail if yaSSL is built with zlib support since the zlib library isn't 
     passed.  You can do two things to fix this: 
 
@@ -518,7 +635,7 @@
 *********************
 
 Contact: please send comments or questions to Todd A Ouska at todd at yassl.com
-and/or Larry Stefonic at larry at yassl.com or 425-741-6858.
+and/or Larry Stefonic at larry at yassl.com.
 
 
 

=== modified file 'extra/yassl/certs/ca-cert.pem'
--- a/extra/yassl/certs/ca-cert.pem	2010-06-08 13:36:47 +0000
+++ b/extra/yassl/certs/ca-cert.pem	2012-02-10 14:33:27 +0000
@@ -1,53 +1,56 @@
 Certificate:
     Data:
         Version: 3 (0x2)
-        Serial Number: 0 (0x0)
+        Serial Number:
+            8a:37:22:65:73:f5:aa:e8
         Signature Algorithm: md5WithRSAEncryption
-        Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
+        Issuer: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
         Validity
-            Not Before: Mar  7 03:10:11 2005 GMT
-            Not After : Apr  1 03:10:11 2046 GMT
-        Subject: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
+            Not Before: Jun 30 18:47:10 2010 GMT
+            Not After : Mar 26 18:47:10 2013 GMT
+        Subject: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
         Subject Public Key Info:
             Public Key Algorithm: rsaEncryption
             RSA Public Key: (512 bit)
                 Modulus (512 bit):
-                    00:ef:c1:e3:9a:3c:6e:6e:cb:26:6f:05:be:e0:cb:
-                    57:a0:4b:68:e6:1b:f9:95:db:01:92:aa:6e:a6:b5:
-                    2d:b1:2b:50:fd:db:13:f2:c5:d8:b8:4f:75:28:53:
-                    72:e8:e5:11:9d:bb:c3:4f:4f:09:fd:4c:e7:46:d5:
-                    1d:bb:35:02:af
+                    00:97:30:b9:1a:92:ef:25:4f:ca:4c:11:31:95:1a:
+                    e1:c0:10:19:0a:20:b9:37:80:1a:57:38:02:4e:1b:
+                    c5:0f:28:4f:da:e3:c9:16:aa:50:bd:4a:fb:b7:71:
+                    c7:35:cc:63:81:c1:dd:9d:33:f9:38:16:88:32:a0:
+                    aa:56:23:03:a3
                 Exponent: 65537 (0x10001)
         X509v3 extensions:
             X509v3 Subject Key Identifier: 
-                1D:EF:A1:B8:81:78:12:47:E8:57:06:08:74:18:F7:D3:AA:D8:F7:BD
+                3B:66:FD:A0:40:C6:F4:E2:70:CF:21:1A:0C:4F:67:FE:B7:4B:42:09
             X509v3 Authority Key Identifier: 
-                keyid:1D:EF:A1:B8:81:78:12:47:E8:57:06:08:74:18:F7:D3:AA:D8:F7:BD
-                DirName:/C=US/ST=Oregon/L=Portland/O=sawtooth/CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
-                serial:00
+                keyid:3B:66:FD:A0:40:C6:F4:E2:70:CF:21:1A:0C:4F:67:FE:B7:4B:42:09
+                DirName:/C=US/ST=Montana/L=Bozeman/O=sawtooth/OU=consulting/CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
+                serial:8A:37:22:65:73:F5:AA:E8
 
             X509v3 Basic Constraints: 
                 CA:TRUE
     Signature Algorithm: md5WithRSAEncryption
-        d9:77:e3:07:d9:2e:ec:2f:9b:8e:9e:ca:b4:00:0b:ef:c7:74:
-        cb:f4:f6:44:2f:02:75:17:a5:74:3e:26:b2:26:fd:1f:ab:3a:
-        df:d5:e3:05:14:08:d0:8c:1d:c9:3e:e1:59:6f:b3:38:5d:af:
-        78:60:e3:c5:6a:69:96:80:7d:00
+        32:65:a2:b1:dc:6d:e0:8d:8b:c8:58:29:8e:b8:18:4b:62:88:
+        13:67:f8:6c:75:46:75:8f:8a:19:a6:a3:d5:3c:fc:57:4e:7a:
+        68:a9:fc:93:dc:ae:29:7d:bb:4e:ec:ea:55:fa:a4:e3:00:61:
+        f4:b0:34:6d:d1:d5:a4:64:24:f8
 -----BEGIN CERTIFICATE-----
-MIIC7zCCApmgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBiTELMAkGA1UEBhMCVVMx
-DzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxETAPBgNVBAoTCHNh
-d3Rvb3RoMSQwIgYDVQQDExt3d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAb
-BgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMB4XDTA1MDMwNzAzMTAxMVoXDTQ2
-MDQwMTAzMTAxMVowgYkxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZPcmVnb24xETAP
-BgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290aDEkMCIGA1UEAxMbd3d3
-LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlh
-c3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDvweOaPG5uyyZvBb7gy1eg
-S2jmG/mV2wGSqm6mtS2xK1D92xPyxdi4T3UoU3Lo5RGdu8NPTwn9TOdG1R27NQKv
-AgMBAAGjgekwgeYwHQYDVR0OBBYEFB3vobiBeBJH6FcGCHQY99Oq2Pe9MIG2BgNV
-HSMEga4wgauAFB3vobiBeBJH6FcGCHQY99Oq2Pe9oYGPpIGMMIGJMQswCQYDVQQG
-EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDERMA8GA1UE
-ChMIc2F3dG9vdGgxJDAiBgNVBAMTG3d3dy5zYXd0b290aC1jb25zdWx0aW5nLmNv
-bTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb22CAQAwDAYDVR0TBAUwAwEB
-/zANBgkqhkiG9w0BAQQFAANBANl34wfZLuwvm46eyrQAC+/HdMv09kQvAnUXpXQ+
-JrIm/R+rOt/V4wUUCNCMHck+4Vlvszhdr3hg48VqaZaAfQA=
+MIIDQDCCAuqgAwIBAgIJAIo3ImVz9aroMA0GCSqGSIb3DQEBBAUAMIGeMQswCQYD
+VQQGEwJVUzEQMA4GA1UECBMHTW9udGFuYTEQMA4GA1UEBxMHQm96ZW1hbjERMA8G
+A1UEChMIc2F3dG9vdGgxEzARBgNVBAsTCmNvbnN1bHRpbmcxJDAiBgNVBAMTG3d3
+dy5zYXd0b290aC1jb25zdWx0aW5nLmNvbTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5
+YXNzbC5jb20wHhcNMTAwNjMwMTg0NzEwWhcNMTMwMzI2MTg0NzEwWjCBnjELMAkG
+A1UEBhMCVVMxEDAOBgNVBAgTB01vbnRhbmExEDAOBgNVBAcTB0JvemVtYW4xETAP
+BgNVBAoTCHNhd3Rvb3RoMRMwEQYDVQQLEwpjb25zdWx0aW5nMSQwIgYDVQQDExt3
+d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A
+eWFzc2wuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJcwuRqS7yVPykwRMZUa
+4cAQGQoguTeAGlc4Ak4bxQ8oT9rjyRaqUL1K+7dxxzXMY4HB3Z0z+TgWiDKgqlYj
+A6MCAwEAAaOCAQcwggEDMB0GA1UdDgQWBBQ7Zv2gQMb04nDPIRoMT2f+t0tCCTCB
+0wYDVR0jBIHLMIHIgBQ7Zv2gQMb04nDPIRoMT2f+t0tCCaGBpKSBoTCBnjELMAkG
+A1UEBhMCVVMxEDAOBgNVBAgTB01vbnRhbmExEDAOBgNVBAcTB0JvemVtYW4xETAP
+BgNVBAoTCHNhd3Rvb3RoMRMwEQYDVQQLEwpjb25zdWx0aW5nMSQwIgYDVQQDExt3
+d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A
+eWFzc2wuY29tggkAijciZXP1qugwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQF
+AANBADJlorHcbeCNi8hYKY64GEtiiBNn+Gx1RnWPihmmo9U8/FdOemip/JPcril9
+u07s6lX6pOMAYfSwNG3R1aRkJPg=
 -----END CERTIFICATE-----

=== added file 'extra/yassl/certs/ca-key.pem'
--- a/extra/yassl/certs/ca-key.pem	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/certs/ca-key.pem	2012-02-10 14:33:27 +0000
@@ -0,0 +1,9 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIBOQIBAAJBAJcwuRqS7yVPykwRMZUa4cAQGQoguTeAGlc4Ak4bxQ8oT9rjyRaq
+UL1K+7dxxzXMY4HB3Z0z+TgWiDKgqlYjA6MCAwEAAQJAEQ9TY7c+uuQU/J5YDO4a
+mRR37tegbq3Kyxqrz+p8QuhqLDtVh13GaF7rVU70vyNHm+cgihUyzho/PViAkPBo
+qQIhAMU8/RDhDLgL5BxID4sxKIVBtg+imFSbyKVyg7oQLUcXAiEAxDu94O45Cf4a
+np9R0thumY/QqWpCkycWAB7fFEuaf1UCIEH+bg4/vqm2ENUFp23DPPOZUPlaRe3J
+UhFJh5mx3/RxAiBq++8vfHFYg1Lb/BxOCXVy/zdRxf753ytdcXdJx1Y56QIgVgpN
+FNfYJofQfWaP96sjlc0usrT28uceHx0QmHqolVc=
+-----END RSA PRIVATE KEY-----

=== modified file 'extra/yassl/certs/client-cert.der'
Binary files a/extra/yassl/certs/client-cert.der	2010-06-08 13:36:47 +0000 and b/extra/yassl/certs/client-cert.der	2012-02-10 14:33:27 +0000 differ
=== modified file 'extra/yassl/certs/client-cert.pem'
--- a/extra/yassl/certs/client-cert.pem	2010-06-08 13:36:47 +0000
+++ b/extra/yassl/certs/client-cert.pem	2012-02-10 14:33:27 +0000
@@ -1,52 +1,55 @@
 Certificate:
     Data:
         Version: 3 (0x2)
-        Serial Number: 0 (0x0)
+        Serial Number:
+            c5:d7:6c:11:36:f0:35:e1
         Signature Algorithm: md5WithRSAEncryption
-        Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, CN=www.yassl.com/emailAddress=info at yassl.com
+        Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=programming, CN=www.yassl.com/emailAddress=info at yassl.com
         Validity
-            Not Before: Mar  7 03:00:31 2005 GMT
-            Not After : Apr  1 03:00:31 2046 GMT
-        Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, CN=www.yassl.com/emailAddress=info at yassl.com
+            Not Before: Jun 30 18:39:39 2010 GMT
+            Not After : Mar 26 18:39:40 2013 GMT
+        Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=programming, CN=www.yassl.com/emailAddress=info at yassl.com
         Subject Public Key Info:
             Public Key Algorithm: rsaEncryption
             RSA Public Key: (512 bit)
                 Modulus (512 bit):
-                    00:cd:1f:78:47:f8:b8:d6:08:bf:bd:7c:23:61:86:
-                    36:28:ac:ee:3c:a8:9a:94:e6:d5:26:e8:71:50:b2:
-                    26:8b:1c:1e:3f:75:b2:d3:b3:67:95:0c:fd:76:28:
-                    65:d5:ce:12:82:9e:06:00:a2:09:dd:ce:3a:26:dd:
-                    46:2a:a0:45:71
+                    00:bd:51:4a:14:fd:6a:19:84:0c:33:38:fc:27:32:
+                    9c:97:0b:fc:a4:18:60:69:4e:d9:d8:78:50:0b:e9:
+                    20:5d:d6:1d:70:1c:0c:24:9f:23:82:cc:3a:01:d5:
+                    97:17:b2:73:6c:86:cf:b5:f1:e5:ce:68:0c:d9:a2:
+                    12:39:7c:f2:53
                 Exponent: 65537 (0x10001)
         X509v3 extensions:
             X509v3 Subject Key Identifier: 
-                AE:25:5E:FA:4D:A3:5B:2B:87:DE:F1:2A:F5:42:C0:FF:CE:B5:B4:AD
+                5C:F7:29:21:69:7A:09:78:9E:7B:CD:53:42:02:EC:CE:29:0D:11:DF
             X509v3 Authority Key Identifier: 
-                keyid:AE:25:5E:FA:4D:A3:5B:2B:87:DE:F1:2A:F5:42:C0:FF:CE:B5:B4:AD
-                DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/CN=www.yassl.com/emailAddress=info at yassl.com
-                serial:00
+                keyid:5C:F7:29:21:69:7A:09:78:9E:7B:CD:53:42:02:EC:CE:29:0D:11:DF
+                DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/OU=programming/CN=www.yassl.com/emailAddress=info at yassl.com
+                serial:C5:D7:6C:11:36:F0:35:E1
 
             X509v3 Basic Constraints: 
                 CA:TRUE
     Signature Algorithm: md5WithRSAEncryption
-        59:19:ae:1b:4e:65:9e:ca:f1:b8:3d:ff:c7:5e:15:86:10:97:
-        8c:3e:22:32:ab:4e:75:a7:70:83:f2:fb:2f:af:fe:26:28:e9:
-        4f:d4:c9:49:7c:6f:51:7e:2a:ff:a0:5b:25:45:2e:66:d9:0d:
-        92:94:e5:b8:60:c6:67:1a:f3:03
+        b4:a5:f1:71:26:4d:b9:ff:54:f3:09:1f:ac:e1:19:59:e5:ec:
+        57:e3:f1:0b:b2:8f:f3:29:eb:6b:c6:fa:27:33:3e:91:d0:77:
+        43:c9:ce:1e:0f:71:07:a9:f7:26:e0:7e:ff:30:7d:52:0a:e1:
+        80:48:46:bb:99:e9:d9:77:ce:75
 -----BEGIN CERTIFICATE-----
-MIICtzCCAmGgAwIBAgIBADANBgkqhkiG9w0BAQQFADB4MQswCQYDVQQGEwJVUzEP
-MA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwGA1UEChMFeWFT
-U0wxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A
-eWFzc2wuY29tMB4XDTA1MDMwNzAzMDAzMVoXDTQ2MDQwMTAzMDAzMVoweDELMAkG
-A1UEBhMCVVMxDzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxDjAM
-BgNVBAoTBXlhU1NMMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcN
-AQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDNH3hH
-+LjWCL+9fCNhhjYorO48qJqU5tUm6HFQsiaLHB4/dbLTs2eVDP12KGXVzhKCngYA
-ogndzjom3UYqoEVxAgMBAAGjgdUwgdIwHQYDVR0OBBYEFK4lXvpNo1srh97xKvVC
-wP/OtbStMIGiBgNVHSMEgZowgZeAFK4lXvpNo1srh97xKvVCwP/OtbStoXykejB4
-MQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFu
-ZDEOMAwGA1UEChMFeWFTU0wxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkq
-hkiG9w0BCQEWDmluZm9AeWFzc2wuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZI
-hvcNAQEEBQADQQBZGa4bTmWeyvG4Pf/HXhWGEJeMPiIyq051p3CD8vsvr/4mKOlP
-1MlJfG9Rfir/oFslRS5m2Q2SlOW4YMZnGvMD
+MIIDDjCCArigAwIBAgIJAMXXbBE28DXhMA0GCSqGSIb3DQEBBAUAMIGOMQswCQYD
+VQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwG
+A1UEChMFeWFTU0wxFDASBgNVBAsTC3Byb2dyYW1taW5nMRYwFAYDVQQDEw13d3cu
+eWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0xMDA2
+MzAxODM5MzlaFw0xMzAzMjYxODM5NDBaMIGOMQswCQYDVQQGEwJVUzEPMA0GA1UE
+CBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwGA1UEChMFeWFTU0wxFDAS
+BgNVBAsTC3Byb2dyYW1taW5nMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJ
+KoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgC
+QQC9UUoU/WoZhAwzOPwnMpyXC/ykGGBpTtnYeFAL6SBd1h1wHAwknyOCzDoB1ZcX
+snNshs+18eXOaAzZohI5fPJTAgMBAAGjgfYwgfMwHQYDVR0OBBYEFFz3KSFpegl4
+nnvNU0IC7M4pDRHfMIHDBgNVHSMEgbswgbiAFFz3KSFpegl4nnvNU0IC7M4pDRHf
+oYGUpIGRMIGOMQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQH
+EwhQb3J0bGFuZDEOMAwGA1UEChMFeWFTU0wxFDASBgNVBAsTC3Byb2dyYW1taW5n
+MRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlh
+c3NsLmNvbYIJAMXXbBE28DXhMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQAD
+QQC0pfFxJk25/1TzCR+s4RlZ5exX4/ELso/zKetrxvonMz6R0HdDyc4eD3EHqfcm
+4H7/MH1SCuGASEa7menZd851
 -----END CERTIFICATE-----

=== modified file 'extra/yassl/certs/client-key.der'
Binary files a/extra/yassl/certs/client-key.der	2006-05-03 11:20:51 +0000 and b/extra/yassl/certs/client-key.der	2012-02-10 14:33:27 +0000 differ
=== modified file 'extra/yassl/certs/client-key.pem'
--- a/extra/yassl/certs/client-key.pem	2006-05-03 11:08:24 +0000
+++ b/extra/yassl/certs/client-key.pem	2012-02-10 14:33:27 +0000
@@ -1,9 +1,9 @@
 -----BEGIN RSA PRIVATE KEY-----
-MIIBOgIBAAJBAM0feEf4uNYIv718I2GGNiis7jyompTm1SbocVCyJoscHj91stOz
-Z5UM/XYoZdXOEoKeBgCiCd3OOibdRiqgRXECAwEAAQJAXwa6OVVvg7Bv63+MAI0l
-n/hlMfLGEj9R9gFvJXwywPSEQhijOZmedpHALufFPNHtwba9dmbqMkBAw9JDaAgg
-QQIhAO+mBaSmoG5AYVKYQZiASe/2wMZjaQSN+zFLyF97OX8ZAiEA2x5iRmXUkbOT
-8Td/vx8R9mq9W5CJu+cN+SWGwTYhPBkCIGZFM6NQeKaUUvQshdHO7b66Twpa4jZP
-YSNoc9pLe/4BAiB+jIvBkKo2A/rbg2waG32qTXdTXKTPiuA9Fnk/OV30cQIhANuA
-uMdo+T+rYcNGJ1hCYKDe9JWBpNfSQ+H/A7sWuW8L
+MIIBPAIBAAJBAL1RShT9ahmEDDM4/CcynJcL/KQYYGlO2dh4UAvpIF3WHXAcDCSf
+I4LMOgHVlxeyc2yGz7Xx5c5oDNmiEjl88lMCAwEAAQJAVGHWLlLhpqvXsEEXCvWh
+HCYono+K8YVGzhiaPSTU212fCoQryIxsXQKGBjhFdZm96DZWp+Vd/t/u+B4ZeaqY
++QIhAOBEfbFtdZqk5OmbbRsRVPI7+YYmubgY1TVIPqmxHQ4NAiEA2BrTQkjOb3ul
+A/SZO04fJUZsm7Ng92FWHDJsRancSd8CIQCmGbQqZBK1TamJZ6dAY+7RViAx/p6Q
+vjuzMeXPUrFdRQIhAMkfBhg9bCqjFyt8PBPOm/vz8+ZgZlE0/JAXeV7IPCVfAiEA
+gZwCFm1ghGxmaoB424YC4DHeDeN/g9xwJHT7EuM9Mvc=
 -----END RSA PRIVATE KEY-----

=== added file 'extra/yassl/certs/client-keyEnc.pem'
--- a/extra/yassl/certs/client-keyEnc.pem	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/certs/client-keyEnc.pem	2012-02-10 14:33:27 +0000
@@ -0,0 +1,12 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-CBC,B9D8FB94E38635AB
+
+e7bVyzL1RF6p7hl8GDaOrRTcgB4ip+pWWUcnNf6y2tsuAQx/c/Bd5c9ZDc3L5AXC
+oOAzWYB+ay1vWkmAQB4ivFS5QzGDf8870d4FbOejwmgPhiHdZNw5xNwscAN6ps0v
+dFaUrR9nzWmbycsQCjXZGIZtGFCtXkA8Gdl5OMO4o+rzM0muNPS5fb++x7oNl1YG
+gjReu2sQ85dPfMlnoHhr8Pz9LBcxVyOmcqtmT0SOSuPcoj6aDtcZ+EY9MQf6SR9E
+ysmrJKMtp+ABgXglAj5hbT0dMpoJ2KpJYk62JAh/A6DDyv5YYUI0W57xY5+QzaV+
+YXnIvqwLjJ3cXEV4YH7ozLHAESgnAAUoQsin42rrRKt7GxjSdBoFhWjH69V2nl65
+LYRNjE1O5BBEX+rz0S+fe2ZZgT17kUr7eLZCq15J+L5xWQ7R4ERc0w==
+-----END RSA PRIVATE KEY-----

=== added file 'extra/yassl/certs/client-keyEnc3.pem'
--- a/extra/yassl/certs/client-keyEnc3.pem	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/certs/client-keyEnc3.pem	2012-02-10 14:33:27 +0000
@@ -0,0 +1,12 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,BDE979D13CCC0ABD
+
+N7yz2JV13EmQ7MZPL5wamid5+G1V1gp8FKqMemAC5JDxonS/W9oViMLUcxbfPTDx
+FznKdYSVTIQ7vv3ofmDG4MEyV/2C568N2kdtAw+jTfrZFN+IU9CI+W+In/nacirF
+02sAcvDMofustnooKNOO7/iyb5+3vRvEt5vSSRQn5WuSQ9sUKjuzoLs/lbf7fyAt
+4NeqfI3rYBZXxiUOLITOGXzGNRuFoY+o2uDCfelLAJ8uhiVG6ME3LeJEo1dT5lZ8
+CSJOLPasKg0iG4V7olM4j9FvAfZr48RRsSfUen756Jo2HpI4bad8LKhFYIdNs2Au
+WwKLmjpo6QB9hBmRshR04rEXPdrgTqLBExCE08PyaGYnWU8ggWritCeBzDQFj/n4
+sI+NO0Mymuvg98e5RpO52lg3Xnqv9RIK3guLFOmI6aEHC0PS4WwOEQ==
+-----END RSA PRIVATE KEY-----

=== modified file 'extra/yassl/certs/dsa-cert.pem'
--- a/extra/yassl/certs/dsa-cert.pem	2010-06-08 13:36:47 +0000
+++ b/extra/yassl/certs/dsa-cert.pem	2012-02-10 14:33:27 +0000
@@ -1,13 +1,14 @@
 Certificate:
     Data:
         Version: 3 (0x2)
-        Serial Number: 0 (0x0)
+        Serial Number:
+            ce:df:23:31:64:b4:13:da
         Signature Algorithm: dsaWithSHA1
-        Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL DSA, CN=yaSSL DSA/emailAddress=info at yassl.com
+        Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=testing, CN=www.yassl.com/emailAddress=info at yassl.com
         Validity
-            Not Before: Mar  7 03:22:00 2005 GMT
-            Not After : Apr  1 03:22:00 2046 GMT
-        Subject: C=US, ST=Oregon, L=Portland, O=yaSSL DSA, CN=yaSSL DSA/emailAddress=info at yassl.com
+            Not Before: Jun 30 18:56:38 2010 GMT
+            Not After : Mar 26 18:56:39 2013 GMT
+        Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=testing, CN=www.yassl.com/emailAddress=info at yassl.com
         Subject Public Key Info:
             Public Key Algorithm: dsaEncryption
             DSA Public Key:
@@ -37,32 +38,33 @@
                 BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2
             X509v3 Authority Key Identifier: 
                 keyid:BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2
-                DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL DSA/CN=yaSSL DSA/emailAddress=info at yassl.com
-                serial:00
+                DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/OU=testing/CN=www.yassl.com/emailAddress=info at yassl.com
+                serial:CE:DF:23:31:64:B4:13:DA
 
             X509v3 Basic Constraints: 
                 CA:TRUE
     Signature Algorithm: dsaWithSHA1
-        30:2c:02:14:7e:5e:94:fc:7f:ca:81:ab:b3:32:f7:21:83:48:
-        48:5f:0a:f1:13:ca:02:14:73:54:32:14:51:22:bf:0b:ec:d7:
-        6a:6a:fa:a7:1d:46:b4:c2:a3:b5
+        30:2d:02:14:00:a3:21:20:34:6a:2c:f9:fb:76:d7:20:c9:c0:
+        35:1b:64:9a:c2:83:02:15:00:a4:59:ac:6d:da:85:48:ff:f5:
+        0d:49:72:c8:cd:91:fc:ec:2f:5c:63
 -----BEGIN CERTIFICATE-----
-MIIDMjCCAvKgAwIBAgIBADAJBgcqhkjOOAQDMHgxCzAJBgNVBAYTAlVTMQ8wDQYD
-VQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMRIwEAYDVQQKEwl5YVNTTCBE
-U0ExEjAQBgNVBAMTCXlhU1NMIERTQTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNz
-bC5jb20wHhcNMDUwMzA3MDMyMjAwWhcNNDYwNDAxMDMyMjAwWjB4MQswCQYDVQQG
-EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDESMBAGA1UE
-ChMJeWFTU0wgRFNBMRIwEAYDVQQDEwl5YVNTTCBEU0ExHTAbBgkqhkiG9w0BCQEW
-DmluZm9AeWFzc2wuY29tMIHwMIGoBgcqhkjOOAQBMIGcAkEAmSlpgMk8mGhFqYL+
-Z+uViMW0DNYmRZUZLKAgW37faencww/zYQolm/IhAWrNqow358pm21b0D3160Ri5
-Qv0bEQIVAK0lKasKnwkcwa0DIHZ/prfdTQMJAkASiJna59ALk5vm7jwhf5yztI2l
-jOI3gD8X0YFPvfBxtjIIVN2/AeKzdwZkdYoE1nk5sQIDA8YGdOWQBQoQRhkxA0MA
-AkAEhKAmMXIM6E9dUxdisYDKwBZfwx7qxdmYOPm+VlNHaM4IIlccuw13kc9bNu3z
-JIKQis2QfNt3+Rctc3Pvu7mCo4HVMIHSMB0GA1UdDgQWBBS++Yxd1hy07oHdNlYK
-IeRhRHPp4jCBogYDVR0jBIGaMIGXgBS++Yxd1hy07oHdNlYKIeRhRHPp4qF8pHow
-eDELMAkGA1UEBhMCVVMxDzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxh
-bmQxEjAQBgNVBAoTCXlhU1NMIERTQTESMBAGA1UEAxMJeWFTU0wgRFNBMR0wGwYJ
-KoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbYIBADAMBgNVHRMEBTADAQH/MAkGByqG
-SM44BAMDLwAwLAIUfl6U/H/KgauzMvchg0hIXwrxE8oCFHNUMhRRIr8L7Ndqavqn
-HUa0wqO1
+MIIDfjCCAz2gAwIBAgIJAM7fIzFktBPaMAkGByqGSM44BAMwgYoxCzAJBgNVBAYT
+AlVTMQ8wDQYDVQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMQ4wDAYDVQQK
+EwV5YVNTTDEQMA4GA1UECxMHdGVzdGluZzEWMBQGA1UEAxMNd3d3Lnlhc3NsLmNv
+bTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb20wHhcNMTAwNjMwMTg1NjM4
+WhcNMTMwMzI2MTg1NjM5WjCBijELMAkGA1UEBhMCVVMxDzANBgNVBAgTBk9yZWdv
+bjERMA8GA1UEBxMIUG9ydGxhbmQxDjAMBgNVBAoTBXlhU1NMMRAwDgYDVQQLEwd0
+ZXN0aW5nMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5p
+bmZvQHlhc3NsLmNvbTCB8DCBqAYHKoZIzjgEATCBnAJBAJkpaYDJPJhoRamC/mfr
+lYjFtAzWJkWVGSygIFt+32np3MMP82EKJZvyIQFqzaqMN+fKZttW9A99etEYuUL9
+GxECFQCtJSmrCp8JHMGtAyB2f6a33U0DCQJAEoiZ2ufQC5Ob5u48IX+cs7SNpYzi
+N4A/F9GBT73wcbYyCFTdvwHis3cGZHWKBNZ5ObECAwPGBnTlkAUKEEYZMQNDAAJA
+BISgJjFyDOhPXVMXYrGAysAWX8Me6sXZmDj5vlZTR2jOCCJXHLsNd5HPWzbt8ySC
+kIrNkHzbd/kXLXNz77u5gqOB8jCB7zAdBgNVHQ4EFgQUvvmMXdYctO6B3TZWCiHk
+YURz6eIwgb8GA1UdIwSBtzCBtIAUvvmMXdYctO6B3TZWCiHkYURz6eKhgZCkgY0w
+gYoxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRs
+YW5kMQ4wDAYDVQQKEwV5YVNTTDEQMA4GA1UECxMHdGVzdGluZzEWMBQGA1UEAxMN
+d3d3Lnlhc3NsLmNvbTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb22CCQDO
+3yMxZLQT2jAMBgNVHRMEBTADAQH/MAkGByqGSM44BAMDMAAwLQIUAKMhIDRqLPn7
+dtcgycA1G2SawoMCFQCkWaxt2oVI//UNSXLIzZH87C9cYw==
 -----END CERTIFICATE-----

=== modified file 'extra/yassl/certs/dsa512.der'
Binary files a/extra/yassl/certs/dsa512.der	2006-05-03 11:20:51 +0000 and b/extra/yassl/certs/dsa512.der	2012-02-10 14:33:27 +0000 differ
=== modified file 'extra/yassl/certs/server-cert.pem'
--- a/extra/yassl/certs/server-cert.pem	2010-06-08 13:36:47 +0000
+++ b/extra/yassl/certs/server-cert.pem	2012-02-10 14:33:27 +0000
@@ -3,36 +3,37 @@
         Version: 1 (0x0)
         Serial Number: 1 (0x1)
         Signature Algorithm: md5WithRSAEncryption
-        Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
+        Issuer: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info at yassl.com
         Validity
-            Not Before: Mar  8 03:00:47 2005 GMT
-            Not After : Apr  2 03:00:47 2046 GMT
-        Subject: C=US, ST=Oregon, L=Portland, O=taoSoftDev, CN=www.taosoftdev.com/emailAddress=info at yassl.com
+            Not Before: Jun 30 18:52:17 2010 GMT
+            Not After : Mar 26 18:52:17 2013 GMT
+        Subject: C=US, ST=Montana, L=Bozeman, O=yaSSL, OU=support, CN=www.yassl.com/emailAddress=info at yassl.com
         Subject Public Key Info:
             Public Key Algorithm: rsaEncryption
             RSA Public Key: (512 bit)
                 Modulus (512 bit):
-                    00:a4:68:bb:bc:b7:27:5f:3c:f5:78:c6:1a:af:b9:
-                    95:fc:7e:61:1f:a8:81:0a:ca:43:88:9a:03:e0:d0:
-                    a6:79:70:16:34:b9:7c:75:54:ca:70:19:66:38:be:
-                    6e:28:7e:a5:ff:6b:3c:83:2f:39:42:c3:15:f3:bd:
-                    f2:25:93:22:e7
+                    00:c6:7b:c0:68:81:2f:de:82:3f:f9:ac:c3:86:4a:
+                    66:b7:ec:d4:f1:f6:64:21:ff:f5:a2:34:42:d0:38:
+                    9f:c6:dd:3b:6e:26:65:6a:54:96:dd:d2:7b:eb:36:
+                    a2:ae:7e:2a:9e:7e:56:a5:b6:87:9f:15:c7:18:66:
+                    7e:16:77:e2:a7
                 Exponent: 65537 (0x10001)
     Signature Algorithm: md5WithRSAEncryption
-        36:72:12:3b:ac:e4:58:83:09:86:4f:71:2a:3a:0d:8a:05:27:
-        75:f3:3e:62:4f:ab:b8:70:20:cd:ad:70:ab:91:11:68:f8:82:
-        33:e2:78:85:a8:16:f5:66:bd:68:2c:5a:26:15:12:1e:6e:83:
-        c7:6d:62:b9:c3:ff:e1:86:e4:e6
+        58:a9:98:e7:16:52:4c:40:e7:e1:47:92:19:1b:3a:8f:97:6c:
+        7b:b7:b0:cb:20:6d:ad:b5:d3:47:58:d8:e4:f2:3e:32:e9:ef:
+        87:77:e5:54:36:f4:8d:50:8d:07:b4:77:45:ea:9d:a4:33:36:
+        9b:0b:e0:74:58:11:c5:01:7b:4d
 -----BEGIN CERTIFICATE-----
-MIIB9zCCAaECAQEwDQYJKoZIhvcNAQEEBQAwgYkxCzAJBgNVBAYTAlVTMQ8wDQYD
-VQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290
-aDEkMCIGA1UEAxMbd3d3LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZI
-hvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0wNTAzMDgwMzAwNDdaFw00NjA0MDIw
-MzAwNDdaMIGCMQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQH
-EwhQb3J0bGFuZDETMBEGA1UEChMKdGFvU29mdERldjEbMBkGA1UEAxMSd3d3LnRh
-b3NvZnRkZXYuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0G
-CSqGSIb3DQEBAQUAA0sAMEgCQQCkaLu8tydfPPV4xhqvuZX8fmEfqIEKykOImgPg
-0KZ5cBY0uXx1VMpwGWY4vm4ofqX/azyDLzlCwxXzvfIlkyLnAgMBAAEwDQYJKoZI
-hvcNAQEEBQADQQA2chI7rORYgwmGT3EqOg2KBSd18z5iT6u4cCDNrXCrkRFo+IIz
-4niFqBb1Zr1oLFomFRIeboPHbWK5w//hhuTm
+MIICFDCCAb4CAQEwDQYJKoZIhvcNAQEEBQAwgZ4xCzAJBgNVBAYTAlVTMRAwDgYD
+VQQIEwdNb250YW5hMRAwDgYDVQQHEwdCb3plbWFuMREwDwYDVQQKEwhzYXd0b290
+aDETMBEGA1UECxMKY29uc3VsdGluZzEkMCIGA1UEAxMbd3d3LnNhd3Rvb3RoLWNv
+bnN1bHRpbmcuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0x
+MDA2MzAxODUyMTdaFw0xMzAzMjYxODUyMTdaMIGKMQswCQYDVQQGEwJVUzEQMA4G
+A1UECBMHTW9udGFuYTEQMA4GA1UEBxMHQm96ZW1hbjEOMAwGA1UEChMFeWFTU0wx
+EDAOBgNVBAsTB3N1cHBvcnQxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkq
+hkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJB
+AMZ7wGiBL96CP/msw4ZKZrfs1PH2ZCH/9aI0QtA4n8bdO24mZWpUlt3Se+s2oq5+
+Kp5+VqW2h58VxxhmfhZ34qcCAwEAATANBgkqhkiG9w0BAQQFAANBAFipmOcWUkxA
+5+FHkhkbOo+XbHu3sMsgba2100dY2OTyPjLp74d35VQ29I1QjQe0d0XqnaQzNpsL
+4HRYEcUBe00=
 -----END CERTIFICATE-----

=== modified file 'extra/yassl/certs/server-key.pem'
--- a/extra/yassl/certs/server-key.pem	2006-05-03 11:08:24 +0000
+++ b/extra/yassl/certs/server-key.pem	2012-02-10 14:33:27 +0000
@@ -1,9 +1,9 @@
 -----BEGIN RSA PRIVATE KEY-----
-MIIBOQIBAAJBAKRou7y3J1889XjGGq+5lfx+YR+ogQrKQ4iaA+DQpnlwFjS5fHVU
-ynAZZji+bih+pf9rPIMvOULDFfO98iWTIucCAwEAAQJABLVvMw931DV1vljGKORC
-1HF2LKbx0zJJzt7CX6z6J54vcE79K3NYXdU6o7/j1WTtfD47tFG+4ljGvSYPmrCI
-2QIhANfiY6is6JUJGGgeMxyWeQRPXfaE9Yrk6OhxHhpYf5CTAiEAwvWraeLPy/NE
-B+0w80mh8tCv2tpuKaYMOG53XpYX3N0CIDy/Bj3rUZLGOWjqvoUXzjupPY5lgVYw
-7Vyin87YAiUjAiAgM8X5em5KSMc+6+2+8bWfTtsNMjEqDfRMyepLpE0SvQIgTSYL
-WWfcZoRUPDM9GEuQ40nifVNjobzvjTW4aYyHCEI=
+MIIBOwIBAAJBAMZ7wGiBL96CP/msw4ZKZrfs1PH2ZCH/9aI0QtA4n8bdO24mZWpU
+lt3Se+s2oq5+Kp5+VqW2h58VxxhmfhZ34qcCAwEAAQJBAJSbGxgjgV+rTZL2Ev58
+viN/IoB25cm/Bn4Heu7DNn2A2kpdGX2cCaf7rEQoIKCiHxvopvxOcd/7nLS/gNli
+dCECIQD/cX/9fvB1Uajw0fmvwNON9+3P9uJSqpig90zL32pwjQIhAMbqee9TBMN4
+TxXbgWqA92PrCXe8WDZ3PwoJqdR6MRUDAiEAny+TDF1z6hiWiGTCDgXDkKBlwgjf
+p5aKgR077XzwLu0CICVpWEGg1ZaF/CnaPP7w/pZ2UDOK4vRrfRnAM4bY7H5NAiBS
+1eXJ/MCZ2uPfpl7XK2BU9P69KdKUk5WHxdRchVvcDg==
 -----END RSA PRIVATE KEY-----

=== added file 'extra/yassl/certs/server-keyEnc.pem'
--- a/extra/yassl/certs/server-keyEnc.pem	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/certs/server-keyEnc.pem	2012-02-10 14:33:27 +0000
@@ -0,0 +1,12 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-CBC,08132C1FFF5BC8CC
+
+gsvuAsGmB8AkR23M25w4E6wuywfBey1Jqh3g71gJcnsUYwynex9dvfAU0lTowOXh
+sb7ld1KNjEMzrht9AC1IC0iE1rLqvRQZOdJ7h3n7aHZQ4a/HjcwAhqJq0ZW45m6Q
+mpoO5fRISjx2VbKFRUz6Xj2x0/do3IjQhpuUDVrTFFe1sEySM6APZ6CVpcnTOyPR
+ADyLDKzOi2E+sj1UXs58pct56FaqTIZPUEflICU3k6q9FPU6gsYANRLfzegclkv4
+JAx6mKVSJuYnjCCppx8WBwGJa1J1GcYRJ3qFfdbUzL4bcXTvoFkJEnDkHsXgDUS6
+xmT0XGT3IMaW8cwQ8KD8m5YYI/L26Mas/w3eA2ekyMR8pYICjXp/YZtcKxxkQSVE
+Uv/+D+20KbNAHIW5Mrxf61cX/CggGEbVP8ZhDY1flh8=
+-----END RSA PRIVATE KEY-----

=== modified file 'extra/yassl/certs/taoCert.txt'
--- a/extra/yassl/certs/taoCert.txt	2006-05-03 11:08:24 +0000
+++ b/extra/yassl/certs/taoCert.txt	2012-02-10 14:33:27 +0000
@@ -47,4 +47,16 @@
 b) openssl rsa -in key.pem -outform DER -out key.der
 
 
+**** To encrypt rsa key already in pem **********
+
+a) openssl rsa <server-key.pem.bak -des >server-keyEnc.pem
+
+note location of des, pass = yassl123
+
+
+*** To make a public key from a private key ******
+
+
+openssl rsa -in 1024rsa.priv -pubout -out 1024rsa.pub
+
 

=== modified file 'extra/yassl/examples/client/client.cpp'
--- a/extra/yassl/examples/client/client.cpp	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/examples/client/client.cpp	2012-04-07 13:58:46 +0000
@@ -36,15 +36,20 @@
     void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd)
     {
         int ret = SSL_connect(ssl);
-        while (ret =! SSL_SUCCESS && SSL_get_error(ssl, 0) ==
-                                     SSL_ERROR_WANT_READ) {
-            printf("... client would block\n");
+        int err = SSL_get_error(ssl, 0);
+        while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ ||
+                                      err == SSL_ERROR_WANT_WRITE)) {
+            if (err == SSL_ERROR_WANT_READ)
+                printf("... client would read block\n");
+            else
+                printf("... client would write block\n");
             #ifdef _WIN32
                 Sleep(1000);
             #else
                 sleep(1);
             #endif
             ret = SSL_connect(ssl);
+            err = SSL_get_error(ssl, 0);
         }
         if (ret != SSL_SUCCESS)
             ClientError(ctx, ssl, sockfd, "SSL_connect failed");
@@ -81,7 +86,8 @@
 #ifdef NON_BLOCKING
     NonBlockingSSL_Connect(ssl, ctx, sockfd);
 #else
-    if (SSL_connect(ssl) != SSL_SUCCESS)
+    // if you get an error here see note at top of README
+    if (SSL_connect(ssl) != SSL_SUCCESS)   
         ClientError(ctx, ssl, sockfd, "SSL_connect failed");
 #endif
     showPeer(ssl);
@@ -105,7 +111,7 @@
     int input = SSL_read(ssl, reply, sizeof(reply));
     if (input > 0) {
         reply[input] = 0;
-    printf("Server response: %s\n", reply);
+        printf("Server response: %s\n", reply);
     }
 
 #ifdef TEST_RESUME
@@ -121,18 +127,18 @@
     tcp_connect(sockfd);
     SSL_set_fd(sslResume, sockfd);
     SSL_set_session(sslResume, session);
-    
+
     if (SSL_connect(sslResume) != SSL_SUCCESS)
         ClientError(ctx, sslResume, sockfd, "SSL_resume failed");
     showPeer(sslResume);
-  
+
     if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg))
         ClientError(ctx, sslResume, sockfd, "SSL_write failed");
 
     input = SSL_read(sslResume, reply, sizeof(reply));
     if (input > 0) {
         reply[input] = 0;
-    printf("Server response: %s\n", reply);
+        printf("Server response: %s\n", reply);
     }
 
     SSL_shutdown(sslResume);

=== modified file 'extra/yassl/examples/echoclient/echoclient.cpp'
--- a/extra/yassl/examples/echoclient/echoclient.cpp	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/examples/echoclient/echoclient.cpp	2012-04-07 13:58:46 +0000
@@ -74,10 +74,10 @@
 
     char send[1024];
     char reply[1024];
- 
+
     while (fgets(send, sizeof(send), fin)) {
 
-        int sendSz = strlen(send) + 1;
+        int sendSz = (int)strlen(send) + 1;
         if (SSL_write(ssl, send, sendSz) != sendSz)
             EchoClientError(ctx, ssl, sockfd, "SSL_write failed");
 
@@ -86,7 +86,7 @@
             break;
         }
 
-        if (SSL_read(ssl, reply, sizeof(reply)) > 0) 
+        if (SSL_read(ssl, reply, sizeof(reply)) > 0)
             fputs(reply, fout);
     }
 

=== modified file 'extra/yassl/examples/echoserver/echoserver.cpp'
--- a/extra/yassl/examples/echoserver/echoserver.cpp	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/examples/echoserver/echoserver.cpp	2012-04-07 13:58:46 +0000
@@ -93,11 +93,11 @@
 #endif
 
     while (!shutdown) {
-        sockaddr_in client;
+        SOCKADDR_IN_T client;
         socklen_t   client_len = sizeof(client);
         SOCKET_T    clientfd   = accept(sockfd, (sockaddr*)&client,
                                       (ACCEPT_THIRD_T)&client_len);
-        if (clientfd == -1) {
+        if (clientfd == (SOCKET_T) -1) {
             SSL_CTX_free(ctx);
             tcp_close(sockfd);
             err_sys("tcp accept failed");
@@ -111,11 +111,11 @@
             tcp_close(clientfd);
             continue; 
         }
-
+       
         char command[1024];
         int echoSz(0);
         while ( (echoSz = SSL_read(ssl, command, sizeof(command))) > 0) {
-           
+
             if ( strncmp(command, "quit", 4) == 0) {
                 printf("client sent quit command: shutting down!\n");
                 shutdown = true;
@@ -127,7 +127,7 @@
                 char header[] = "<html><body BGCOLOR=\"#ffffff\">\n<pre>\n";
                 char body[]   = "greetings from yaSSL\n";
                 char footer[] = "</body></html>\r\n\r\n";
-            
+
                 strncpy(command, type, sizeof(type));
                 echoSz = sizeof(type) - 1;
 
@@ -140,7 +140,7 @@
 
                 if (SSL_write(ssl, command, echoSz) != echoSz)
                     EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed");
-
+               
                 break;
             }
             command[echoSz] = 0;

=== modified file 'extra/yassl/examples/server/server.cpp'
--- a/extra/yassl/examples/server/server.cpp	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/examples/server/server.cpp	2012-04-07 13:58:46 +0000
@@ -35,15 +35,20 @@
     void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd)
     {
         int ret = SSL_accept(ssl);
-        while (ret != SSL_SUCCESS && SSL_get_error(ssl, 0) ==
-                                     SSL_ERROR_WANT_READ) {
-            printf("... server would block\n");
+        int err = SSL_get_error(ssl, 0);
+        while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ ||
+                                      err == SSL_ERROR_WANT_WRITE)) {
+            if (err == SSL_ERROR_WANT_READ)
+                printf("... server would read block\n");
+            else
+                printf("... server would write block\n");
             #ifdef _WIN32
                 Sleep(1000);
             #else
                 sleep(1);
             #endif
             ret = SSL_accept(ssl);
+            err = SSL_get_error(ssl, 0);
         }
         if (ret != SSL_SUCCESS)
             ServerError(ctx, ssl, clientfd, "SSL_accept failed");
@@ -78,14 +83,14 @@
 
     SSL* ssl = SSL_new(ctx);
     SSL_set_fd(ssl, clientfd);
-   
+
 #ifdef NON_BLOCKING
     NonBlockingSSL_Accept(ssl, ctx, clientfd);
 #else
     if (SSL_accept(ssl) != SSL_SUCCESS)
         ServerError(ctx, ssl, clientfd, "SSL_accept failed");
 #endif
-
+     
     showPeer(ssl);
     printf("Using Cipher Suite: %s\n", SSL_get_cipher(ssl));
 
@@ -93,7 +98,7 @@
     int input = SSL_read(ssl, command, sizeof(command));
     if (input > 0) {
         command[input] = 0;
-    printf("First client command: %s\n", command);
+        printf("First client command: %s\n", command);
     }
 
     char msg[] = "I hear you, fa shizzle!";

=== modified file 'extra/yassl/include/buffer.hpp'
--- a/extra/yassl/include/buffer.hpp	2007-03-23 12:43:09 +0000
+++ b/extra/yassl/include/buffer.hpp	2012-02-13 11:40:12 +0000
@@ -46,12 +46,6 @@
 const uint AUTO = 0xFEEDBEEF;
 
 
-// Checking Policy should implement a check function that tests whether the
-// index is within the size limit of the array
-struct Check {
-    void check(uint i, uint limit);
-};
-
 
 struct NoCheck {
     void check(uint, uint);
@@ -66,7 +60,7 @@
  * write to the buffer bulk wise and have the correct size
  */
 
-class input_buffer : public Check {
+class input_buffer : public NoCheck {
     uint   size_;                // number of elements in buffer
     uint   current_;             // current offset position in buffer
     byte*  buffer_;              // storage for buffer
@@ -132,7 +126,7 @@
  * Not using vector because need checked []access and the ability to
  * write to the buffer bulk wise and retain correct size
  */
-class output_buffer : public Check {
+class output_buffer : public NoCheck {
     uint    current_;                // current offset and elements in buffer
     byte*   buffer_;                 // storage for buffer
     byte*   end_;                    // end of storage marker

=== modified file 'extra/yassl/include/openssl/ssl.h'
--- a/extra/yassl/include/openssl/ssl.h	2011-06-30 15:46:53 +0000
+++ b/extra/yassl/include/openssl/ssl.h	2012-03-02 12:23:52 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc.
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    Use is subject to license terms.
 
    This program is free software; you can redistribute it and/or modify
@@ -30,12 +30,12 @@
 #include "prefix_ssl.h"
 #endif
 
-#include <stdio.h>   /* ERR_print fp */
+#include <stdio.h>    /* ERR_print fp */
 #include "opensslv.h" /* for version number */
 #include "rsa.h"
 
 
-#define YASSL_VERSION "1.7.2"
+#define YASSL_VERSION "2.2.0"
 
 
 #if defined(__cplusplus)
@@ -43,9 +43,9 @@
 #endif
 
  void yaSSL_CleanUp();   /* call once at end of application use to
-                                      free static singleton memory holders,
-                                      not a leak per se, but helpful when 
-                                      looking for them                      */
+                            free static singleton memory holders,
+                            not a leak per se, but helpful when
+                            looking for them                      */
 
 #if defined(__cplusplus)
 } // extern
@@ -70,11 +70,11 @@
     class X509;
     class X509_NAME;
 #else
-    typedef struct SSL         SSL;          
+    typedef struct SSL          SSL;          
     typedef struct SSL_SESSION  SSL_SESSION;
-    typedef struct SSL_METHOD  SSL_METHOD;
-    typedef struct SSL_CTX     SSL_CTX;
-    typedef struct SSL_CIPHER  SSL_CIPHER;
+    typedef struct SSL_METHOD   SSL_METHOD;
+    typedef struct SSL_CTX      SSL_CTX;
+    typedef struct SSL_CIPHER   SSL_CIPHER;
 
     typedef struct RSA RSA;
 
@@ -107,6 +107,15 @@
 
 /* X509 stuff, different file? */
 
+/* because mySQL dereferences to use error and current_cert, even after calling
+ * get functions for local references */
+typedef struct X509_STORE_CTX {
+    int   error;
+    int   error_depth;
+    X509* current_cert;
+} X509_STORE_CTX;
+
+
 typedef struct X509_STORE         X509_STORE;
 typedef struct X509_LOOKUP        X509_LOOKUP;
 typedef struct X509_OBJECT { char c; } X509_OBJECT;
@@ -125,16 +134,6 @@
 
 
 
-/* because mySQL dereferences to use error and current_cert, even after calling
- * get functions for local references */
-typedef struct X509_STORE_CTX {
-    int   error;
-    int   error_depth;
-    X509* current_cert;
-} X509_STORE_CTX;
-
-
-
 X509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*);
 int   X509_STORE_CTX_get_error(X509_STORE_CTX*);
 int   X509_STORE_CTX_get_error_depth(X509_STORE_CTX*);
@@ -205,7 +204,7 @@
 int  SSL_set_fd (SSL*, YASSL_SOCKET_T);
 YASSL_SOCKET_T SSL_get_fd(const SSL*);
 int  SSL_connect(SSL*);                    /* if you get an error from connect
-                                              see note at top of REAMDE */
+                                              see note at top of README       */
 int  SSL_write(SSL*, const void*, int);
 int  SSL_read(SSL*, void*, int);
 int  SSL_accept(SSL*);
@@ -351,11 +350,11 @@
     SSL_ERROR_ZERO_RETURN      = 84,
     SSL_ERROR_SSL              = 85,
 
-    SSL_SENT_SHUTDOWN     = 90,
-    SSL_RECEIVED_SHUTDOWN = 91,
+    SSL_ST_CONNECT        = 90,
+    SSL_ST_ACCEPT         = 91,
     SSL_CB_LOOP           = 92,
-    SSL_ST_CONNECT        = 93,
-    SSL_ST_ACCEPT         = 94,
+    SSL_SENT_SHUTDOWN     = 93,
+    SSL_RECEIVED_SHUTDOWN = 94,
     SSL_CB_ALERT          = 95,
     SSL_CB_READ           = 96,
     SSL_CB_HANDSHAKE_DONE = 97
@@ -366,7 +365,7 @@
 SSL_METHOD *SSLv3_method(void);
 SSL_METHOD *SSLv3_server_method(void);
 SSL_METHOD *SSLv3_client_method(void);
-SSL_METHOD *TLSv1_server_method(void);  
+SSL_METHOD *TLSv1_server_method(void);
 SSL_METHOD *TLSv1_client_method(void);
 SSL_METHOD *TLSv1_1_server_method(void);
 SSL_METHOD *TLSv1_1_client_method(void);

=== modified file 'extra/yassl/include/socket_wrapper.hpp'
--- a/extra/yassl/include/socket_wrapper.hpp	2007-03-28 16:47:51 +0000
+++ b/extra/yassl/include/socket_wrapper.hpp	2012-02-13 11:40:12 +0000
@@ -26,7 +26,6 @@
 #ifndef yaSSL_SOCKET_WRAPPER_HPP
 #define yaSSL_SOCKET_WRAPPER_HPP
 
-#include <assert.h>
 
 #ifdef _WIN32
     #include <winsock2.h>
@@ -73,7 +72,8 @@
     uint     get_ready() const;
     socket_t get_fd()    const;
 
-    uint send(const byte* buf, unsigned int len, int flags = 0) const;
+    uint send(const byte* buf, unsigned int len, unsigned int& sent,
+              int flags = 0);
     uint receive(byte* buf, unsigned int len, int flags = 0);
 
     bool wait();

=== modified file 'extra/yassl/include/yassl_int.hpp'
--- a/extra/yassl/include/yassl_int.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/include/yassl_int.hpp	2012-04-07 13:58:46 +0000
@@ -168,7 +168,7 @@
 
 // openSSL X509 names
 class X509_NAME {
-    char* name_;
+    char*       name_;
     size_t      sz_;
     ASN1_STRING entry_;
 public:
@@ -246,11 +246,11 @@
     SSL_SESSION(const SSL&, RandomPool&);
     ~SSL_SESSION();
 
-    const opaque* GetID()      const;
-    const opaque* GetSecret()  const;
-    const Cipher* GetSuite()   const;
-          uint    GetBornOn()  const;
-          uint    GetTimeOut() const;
+    const opaque* GetID()       const;
+    const opaque* GetSecret()   const;
+    const Cipher* GetSuite()    const;
+          uint    GetBornOn()   const;
+          uint    GetTimeOut()  const;
           X509*   GetPeerX509() const;
           void    SetTimeOut(uint);
 
@@ -417,33 +417,33 @@
 public:
     typedef STL::list<x509*> CertList;
 private:
-    SSL_METHOD* method_;
-    x509*       certificate_;
-    x509*       privateKey_;
-    CertList    caList_;
-    Ciphers     ciphers_;
-    DH_Parms    dhParms_;
+    SSL_METHOD*     method_;
+    x509*           certificate_;
+    x509*           privateKey_;
+    CertList        caList_;
+    Ciphers         ciphers_;
+    DH_Parms        dhParms_;
     pem_password_cb passwordCb_;
     void*           userData_;
     bool            sessionCacheOff_;
     bool            sessionCacheFlushOff_;
-    Stats       stats_;
-    Mutex       mutex_;         // for Stats
+    Stats           stats_;
+    Mutex           mutex_;         // for Stats
     VerifyCallback  verifyCallback_;
 public:
     explicit SSL_CTX(SSL_METHOD* meth);
     ~SSL_CTX();
 
-    const x509*       getCert()     const;
-    const x509*       getKey()      const;
-    const SSL_METHOD* getMethod()   const;
-    const Ciphers&    GetCiphers()  const;
-    const DH_Parms&   GetDH_Parms() const;
-    const Stats&      GetStats()    const;
-    VerifyCallback    getVerifyCallback() const;
+    const x509*       getCert()       const;
+    const x509*       getKey()        const;
+    const SSL_METHOD* getMethod()     const;
+    const Ciphers&    GetCiphers()    const;
+    const DH_Parms&   GetDH_Parms()   const;
+    const Stats&      GetStats()      const;
+    VerifyCallback getVerifyCallback() const;
     pem_password_cb   GetPasswordCb() const;
           void*       GetUserData()   const;
-          bool        GetSessionCacheOff() const;
+          bool        GetSessionCacheOff()      const;
           bool        GetSessionCacheFlushOff() const;
 
     void setVerifyPeer();
@@ -532,10 +532,13 @@
 public: 
     typedef STL::list<input_buffer*>  inputList;
     typedef STL::list<output_buffer*> outputList;
+    int prevSent;     // previous plain text bytes sent when got WANT_WRITE
+    int plainSz;      // plain text bytes in buffer to send when got WANT_WRITE 
 private:
-    inputList  dataList_;                // list of users app data / handshake
-    outputList handShakeList_;           // buffered handshake msgs
-    input_buffer* rawInput_;             // buffered raw input yet to process
+    inputList      dataList_;             // list of users app data / handshake
+    outputList     handShakeList_;        // buffered handshake msgs
+    input_buffer*  rawInput_;             // buffered raw input yet to process
+    output_buffer* output_;               // WANT_WRITE buffered output 
 public:
     Buffers();
     ~Buffers();
@@ -546,11 +549,13 @@
     inputList&  useData();
     outputList& useHandShake();
 
-    void          SetRawInput(input_buffer*);  // takes ownership
-    input_buffer* TakeRawInput();              // takes ownership 
+    void           SetRawInput(input_buffer*);  // takes ownership
+    input_buffer*  TakeRawInput();              // takes ownership 
+    void           SetOutput(output_buffer*);   // takes ownership
+    output_buffer* TakeOutput();                // takes ownership 
 private:
     Buffers(const Buffers&);             // hide copy
-    Buffers& operator=(const Buffers&); // and assign   
+    Buffers& operator=(const Buffers&);  // and assign   
 };
 
 
@@ -652,6 +657,7 @@
     void deriveKeys();
     void deriveTLSKeys();
     void Send(const byte*, uint);
+    void SendWriteBuffered();
 
     uint bufferedData();
     uint get_SEQIncrement(bool);

=== modified file 'extra/yassl/include/yassl_types.hpp'
--- a/extra/yassl/include/yassl_types.hpp	2011-06-30 15:46:53 +0000
+++ b/extra/yassl/include/yassl_types.hpp	2012-02-13 12:44:54 +0000
@@ -26,7 +26,6 @@
 #define yaSSL_TYPES_HPP
 
 #include <stddef.h>
-#include <assert.h>
 #include "type_traits.hpp"
 
 
@@ -37,6 +36,13 @@
 #endif
 
 
+#ifdef _MSC_VER
+    // disable conversion warning
+    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
+    #pragma warning(disable:4244 4996)
+#endif
+
+
 namespace yaSSL {
 
 #define YASSL_LIB
@@ -63,29 +69,29 @@
     template<typename T>
     void ysDelete(T* ptr)
     {
-    if (ptr) ptr->~T();
-    ::operator delete(ptr, yaSSL::ys);
+        if (ptr) ptr->~T();
+        ::operator delete(ptr, yaSSL::ys);
     }
 
     template<typename T>
     void ysArrayDelete(T* ptr)
     {
-    // can't do array placement destruction since not tracking size in
-    // allocation, only allow builtins to use array placement since they
-    // don't need destructors called
-    typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1];
-    (void)sizeof(builtin);
+        // can't do array placement destruction since not tracking size in
+        // allocation, only allow builtins to use array placement since they
+        // don't need destructors called
+        typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1];
+        (void)sizeof(builtin);
 
-    ::operator delete[](ptr, yaSSL::ys);
+        ::operator delete[](ptr, yaSSL::ys);
     }
 
     #define NEW_YS new (yaSSL::ys)
 
     // to resolve compiler generated operator delete on base classes with
-    // virtual destructors (when on stack), make sure doesn't get called
+    // virtual destructors (when on stack)
     class virtual_base {
     public:
-    static void operator delete(void*) { assert(0); }
+        static void operator delete(void*) { }
     };
 
 
@@ -124,7 +130,7 @@
 
 typedef unsigned int uint;
 
- 
+
 #ifdef USE_SYS_STL
     // use system STL
     #define STL_VECTOR_FILE    <vector>

=== modified file 'extra/yassl/src/buffer.cpp'
--- a/extra/yassl/src/buffer.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/src/buffer.cpp	2012-04-07 13:58:46 +0000
@@ -35,14 +35,6 @@
 
 
 
-// Checking Policy should implement a check function that tests whether the
-// index is within the size limit of the array
-
-void Check::check(uint i, uint limit) 
-{ 
-    assert(i < limit);
-}
-
 
 void NoCheck::check(uint, uint) 
 {
@@ -86,7 +78,6 @@
 // users can pass defualt zero length buffer and then allocate
 void input_buffer::allocate(uint s) 
 { 
-    assert(!buffer_);       // find realloc error
     buffer_ = NEW_YS byte[s];
     end_ = buffer_ + s; 
 }
@@ -144,7 +135,6 @@
 // user passes in AUTO index for ease of use
 const byte& input_buffer::operator[](uint i) 
 {
-    assert (i == AUTO);
     check(current_, size_);
     return buffer_[current_++];
 }
@@ -241,7 +231,6 @@
 // users can pass defualt zero length buffer and then allocate
 void output_buffer::allocate(uint s) 
 { 
-    assert(!buffer_);   // find realloc error
     buffer_ = NEW_YS byte[s]; end_ = buffer_ + s; 
 }
 
@@ -257,7 +246,6 @@
 // user passes in AUTO as index for ease of use
 byte& output_buffer::operator[](uint i) 
 {
-    assert(i == AUTO);
     check(current_, get_capacity());
     return buffer_[current_++];
 }

=== modified file 'extra/yassl/src/cert_wrapper.cpp'
--- a/extra/yassl/src/cert_wrapper.cpp	2011-06-30 15:46:53 +0000
+++ b/extra/yassl/src/cert_wrapper.cpp	2012-02-13 12:44:54 +0000
@@ -250,7 +250,8 @@
         TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
         TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
 
-        if (int err = cert.GetError().What())
+        int err = cert.GetError().What();
+        if ( err )
             return err;
 
         const TaoCrypt::PublicKey& key = cert.GetPublicKey();
@@ -266,7 +267,7 @@
         TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
 
         int err = cert.GetError().What();
-        if ( err )
+        if ( err && err != TaoCrypt::SIG_OTHER_E)
             return err;
 
         uint sz = cert.GetPublicKey().size();
@@ -327,7 +328,6 @@
 // Store OpenSSL type peer's cert
 void CertManager::setPeerX509(X509* x)
 {
-    assert(peerX509_ == 0);
     if (x == 0) return;
 
     X509_NAME* issuer   = x->GetIssuer();

=== modified file 'extra/yassl/src/handshake.cpp'
--- a/extra/yassl/src/handshake.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/src/handshake.cpp	2012-04-07 13:58:46 +0000
@@ -50,7 +50,7 @@
     hello.suite_len_ = ssl.getSecurity().get_parms().suites_size_;
     memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_,
            hello.suite_len_);
-    hello.comp_len_ = 1;                   
+    hello.comp_len_ = 1;
 
     hello.set_length(sizeof(ProtocolVersion) +
                      RAN_LEN +
@@ -528,8 +528,9 @@
     input.read(len, sizeof(len));
     uint16 randomLen;
     ato16(len, randomLen);
+
     if (ch.suite_len_ > MAX_SUITE_SZ || sessionLen > ID_LEN ||
-        randomLen > RAN_LEN) {
+                                        randomLen > RAN_LEN) {
         ssl.SetError(bad_input);
         return;
     }
@@ -707,7 +708,7 @@
 {
     // wait for input if blocking
     if (!ssl.useSocket().wait()) {
-      ssl.SetError(receive_error);
+        ssl.SetError(receive_error);
         return 0;
     }
     uint ready = ssl.getSocket().get_ready();
@@ -750,8 +751,8 @@
         if (static_cast<uint>(RECORD_HEADER) > buffer.get_remaining())
             needHdr = true;
         else {
-        buffer >> hdr;
-        ssl.verifyState(hdr);
+            buffer >> hdr;
+            ssl.verifyState(hdr);
         }
 
         // make sure we have enough input in buffer to process this record
@@ -789,9 +790,8 @@
 void processReply(SSL& ssl)
 {
     if (ssl.GetError()) return;
-
-    if (DoProcessReply(ssl))
-    {
+  
+    if (DoProcessReply(ssl)) {
         // didn't complete process
         if (!ssl.getSocket().IsNonBlocking()) {
             // keep trying now, blocking ok
@@ -857,6 +857,7 @@
     if (ssl.GetError()) return;
     ServerKeyExchange sk(ssl);
     sk.build(ssl);
+    if (ssl.GetError()) return;
 
     RecordLayerHeader rlHeader;
     HandShakeHeader   hsHeader;
@@ -875,8 +876,7 @@
 // send change cipher
 void sendChangeCipher(SSL& ssl, BufferOutput buffer)
 {
-    if (ssl.getSecurity().get_parms().entity_ == server_end)
-    {
+    if (ssl.getSecurity().get_parms().entity_ == server_end) {
         if (ssl.getSecurity().get_resuming())
             ssl.verifyState(clientKeyExchangeComplete);
         else
@@ -913,7 +913,7 @@
     }
     else {
         if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())
-        GetSessions().add(ssl);  // store session
+            GetSessions().add(ssl);  // store session
         if (side == client_end)
             buildFinished(ssl, ssl.useHashes().use_verify(), server); // server
     }   
@@ -929,13 +929,23 @@
 // send data
 int sendData(SSL& ssl, const void* buffer, int sz)
 {
-    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
-        ssl.SetError(no_error);
-
-    ssl.verfiyHandShakeComplete();
-    if (ssl.GetError()) return -1;
     int sent = 0;
 
+    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
+        ssl.SetError(no_error);
+
+    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
+        ssl.SetError(no_error);
+        ssl.SendWriteBuffered();
+        if (!ssl.GetError()) {
+            // advance sent to prvevious sent + plain size just sent
+            sent = ssl.useBuffers().prevSent + ssl.useBuffers().plainSz;
+        }
+    }
+
+    ssl.verfiyHandShakeComplete();
+    if (ssl.GetError()) return -1;
+
     for (;;) {
         int len = min(sz - sent, MAX_RECORD_SIZE);
         output_buffer out;
@@ -943,6 +953,8 @@
 
         Data data;
 
+        if (sent == sz) break;
+
         if (ssl.CompressionOn()) {
             if (Compress(static_cast<const opaque*>(buffer) + sent, len,
                          tmp) == -1) {
@@ -957,9 +969,14 @@
         buildMessage(ssl, out, data);
         ssl.Send(out.get_buffer(), out.get_size());
 
-        if (ssl.GetError()) return -1;
+        if (ssl.GetError()) {
+            if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
+                ssl.useBuffers().plainSz  = len;
+                ssl.useBuffers().prevSent = sent;
+            }
+            return -1;
+        }
         sent += len;
-        if (sent == sz) break;
     }
     ssl.useLog().ShowData(sent, true);
     return sent;
@@ -992,7 +1009,7 @@
     if (peek)
         ssl.PeekData(data);
     else
-    ssl.fillData(data);
+        ssl.fillData(data);
 
     ssl.useLog().ShowData(data.get_length());
     if (ssl.GetError()) return -1;

=== modified file 'extra/yassl/src/make.bat' (properties changed: -x to +x)
=== modified file 'extra/yassl/src/socket_wrapper.cpp'
--- a/extra/yassl/src/socket_wrapper.cpp	2011-06-30 15:46:53 +0000
+++ b/extra/yassl/src/socket_wrapper.cpp	2012-02-13 12:44:54 +0000
@@ -109,19 +109,28 @@
 }
 
 
-uint Socket::send(const byte* buf, unsigned int sz, int flags) const
+uint Socket::send(const byte* buf, unsigned int sz, unsigned int& written,
+                  int flags)
 {
     const byte* pos = buf;
     const byte* end = pos + sz;
 
+    wouldBlock_ = false;
+
     while (pos != end) {
         int sent = ::send(socket_, reinterpret_cast<const char *>(pos),
                           static_cast<int>(end - pos), flags);
-
-    if (sent == -1)
-        return 0;
-
+        if (sent == -1) {
+            if (get_lastError() == SOCKET_EWOULDBLOCK || 
+                get_lastError() == SOCKET_EAGAIN) {
+                wouldBlock_  = true; // would have blocked this time only
+                nonBlocking_ = true; // nonblocking, win32 only way to tell 
+                return 0;
+            }
+            return static_cast<uint>(-1);
+        }
         pos += sent;
+        written += sent;
     }
 
     return sz;
@@ -140,8 +149,8 @@
             get_lastError() == SOCKET_EAGAIN) {
             wouldBlock_  = true; // would have blocked this time only
             nonBlocking_ = true; // socket nonblocking, win32 only way to tell
-        return 0;
-    }
+            return 0;
+        }
     }
     else if (recvd == 0)
         return static_cast<uint>(-1);

=== modified file 'extra/yassl/src/ssl.cpp'
--- a/extra/yassl/src/ssl.cpp	2011-12-27 00:14:54 +0000
+++ b/extra/yassl/src/ssl.cpp	2012-03-27 23:04:46 +0000
@@ -252,60 +252,73 @@
     if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
         ssl->SetError(no_error);
 
+    if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
+    
+        ssl->SetError(no_error);
+        ssl->SendWriteBuffered();
+        if (!ssl->GetError())
+            ssl->useStates().UseConnect() =
+                             ConnectState(ssl->getStates().GetConnect() + 1);
+    }
+
     ClientState neededState;
 
     switch (ssl->getStates().GetConnect()) {
 
     case CONNECT_BEGIN :
-    sendClientHello(*ssl);
+        sendClientHello(*ssl);
         if (!ssl->GetError())
             ssl->useStates().UseConnect() = CLIENT_HELLO_SENT;
 
     case CLIENT_HELLO_SENT :
         neededState = ssl->getSecurity().get_resuming() ?
-        serverFinishedComplete : serverHelloDoneComplete;
-    while (ssl->getStates().getClient() < neededState) {
-        if (ssl->GetError()) break;
-    processReply(*ssl);
-    }
+                      serverFinishedComplete : serverHelloDoneComplete;
+        while (ssl->getStates().getClient() < neededState) {
+            if (ssl->GetError()) break;
+            processReply(*ssl);
+            // if resumption failed, reset needed state 
+            if (neededState == serverFinishedComplete)
+                if (!ssl->getSecurity().get_resuming())
+                    neededState = serverHelloDoneComplete;
+        }
         if (!ssl->GetError())
             ssl->useStates().UseConnect() = FIRST_REPLY_DONE;
 
     case FIRST_REPLY_DONE :
-    if(ssl->getCrypto().get_certManager().sendVerify())
-        sendCertificate(*ssl);
-
-    if (!ssl->getSecurity().get_resuming())
-        sendClientKeyExchange(*ssl);
-
-    if(ssl->getCrypto().get_certManager().sendVerify())
-        sendCertificateVerify(*ssl);
-
-    sendChangeCipher(*ssl);
-    sendFinished(*ssl, client_end);
-    ssl->flushBuffer();
+        if(ssl->getCrypto().get_certManager().sendVerify())
+            sendCertificate(*ssl);
+
+        if (!ssl->getSecurity().get_resuming())
+            sendClientKeyExchange(*ssl);
+
+        if(ssl->getCrypto().get_certManager().sendVerify())
+            sendCertificateVerify(*ssl);
+
+        sendChangeCipher(*ssl);
+        sendFinished(*ssl, client_end);
+        ssl->flushBuffer();
 
         if (!ssl->GetError())
             ssl->useStates().UseConnect() = FINISHED_DONE;
 
     case FINISHED_DONE :
-    if (!ssl->getSecurity().get_resuming())
-        while (ssl->getStates().getClient() < serverFinishedComplete) {
-            if (ssl->GetError()) break;
-        processReply(*ssl);
-        }
+        if (!ssl->getSecurity().get_resuming())
+            while (ssl->getStates().getClient() < serverFinishedComplete) {
+                if (ssl->GetError()) break;
+                processReply(*ssl);
+            }
         if (!ssl->GetError())
             ssl->useStates().UseConnect() = SECOND_REPLY_DONE;
 
     case SECOND_REPLY_DONE :
-    ssl->verifyState(serverFinishedComplete);
-    ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
+        ssl->verifyState(serverFinishedComplete);
+        ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
 
         if (ssl->GetError()) {
             GetErrors().Add(ssl->GetError());
-        return SSL_FATAL_ERROR;
+            return SSL_FATAL_ERROR;
         }   
-    return SSL_SUCCESS;
+        return SSL_SUCCESS;
 
     default :
         return SSL_FATAL_ERROR; // unkown state
@@ -331,27 +344,36 @@
     if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
         ssl->SetError(no_error);
 
+    if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
+    
+        ssl->SetError(no_error);
+        ssl->SendWriteBuffered();
+        if (!ssl->GetError())
+            ssl->useStates().UseAccept() =
+                             AcceptState(ssl->getStates().GetAccept() + 1);
+    }
+
     switch (ssl->getStates().GetAccept()) {
 
     case ACCEPT_BEGIN :
-    processReply(*ssl);
+        processReply(*ssl);
         if (!ssl->GetError())
             ssl->useStates().UseAccept() = ACCEPT_FIRST_REPLY_DONE;
 
     case ACCEPT_FIRST_REPLY_DONE :
-    sendServerHello(*ssl);
-
-    if (!ssl->getSecurity().get_resuming()) {
-        sendCertificate(*ssl);
-
-        if (ssl->getSecurity().get_connection().send_server_key_)
-            sendServerKeyExchange(*ssl);
-
-        if(ssl->getCrypto().get_certManager().verifyPeer())
-            sendCertificateRequest(*ssl);
-
-        sendServerHelloDone(*ssl);
-        ssl->flushBuffer();
+        sendServerHello(*ssl);
+
+        if (!ssl->getSecurity().get_resuming()) {
+            sendCertificate(*ssl);
+
+            if (ssl->getSecurity().get_connection().send_server_key_)
+                sendServerKeyExchange(*ssl);
+
+            if(ssl->getCrypto().get_certManager().verifyPeer())
+                sendCertificateRequest(*ssl);
+
+            sendServerHelloDone(*ssl);
+            ssl->flushBuffer();
         }
       
         if (!ssl->GetError())
@@ -359,40 +381,40 @@
 
     case SERVER_HELLO_DONE :
         if (!ssl->getSecurity().get_resuming()) {
-        while (ssl->getStates().getServer() < clientFinishedComplete) {
-            if (ssl->GetError()) break;
-            processReply(*ssl);
+            while (ssl->getStates().getServer() < clientFinishedComplete) {
+                if (ssl->GetError()) break;
+                processReply(*ssl);
+            }
         }
-    }
         if (!ssl->GetError())
             ssl->useStates().UseAccept() = ACCEPT_SECOND_REPLY_DONE;
 
     case ACCEPT_SECOND_REPLY_DONE :
-    sendChangeCipher(*ssl);
-    sendFinished(*ssl, server_end);
-    ssl->flushBuffer();
+        sendChangeCipher(*ssl);
+        sendFinished(*ssl, server_end);
+        ssl->flushBuffer();
 
         if (!ssl->GetError())
             ssl->useStates().UseAccept() = ACCEPT_FINISHED_DONE;
 
     case ACCEPT_FINISHED_DONE :
-    if (ssl->getSecurity().get_resuming()) {
-        while (ssl->getStates().getServer() < clientFinishedComplete) {
-          if (ssl->GetError()) break;
-          processReply(*ssl);
-      }
-    }
+        if (ssl->getSecurity().get_resuming()) {
+            while (ssl->getStates().getServer() < clientFinishedComplete) {
+                if (ssl->GetError()) break;
+                processReply(*ssl);
+            }
+        }
         if (!ssl->GetError())
             ssl->useStates().UseAccept() = ACCEPT_THIRD_REPLY_DONE;
 
     case ACCEPT_THIRD_REPLY_DONE :
-    ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
+        ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
 
         if (ssl->GetError()) {
             GetErrors().Add(ssl->GetError());
-        return SSL_FATAL_ERROR;
+            return SSL_FATAL_ERROR;
         }
-    return SSL_SUCCESS;
+        return SSL_SUCCESS;
 
     default:
         return SSL_FATAL_ERROR; // unknown state
@@ -1097,7 +1119,6 @@
             ivLeft    -= store;
         }
     }
-    assert(keyOutput == (keyLen + ivLen));
     return keyOutput;
 }
 

=== modified file 'extra/yassl/src/yassl.cpp'
--- a/extra/yassl/src/yassl.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/src/yassl.cpp	2012-02-10 14:33:27 +0000
@@ -69,13 +69,13 @@
 
     if (base.ca_)
         if (SSL_CTX_load_verify_locations(base.ctx_,
-            base.ca_, 0) != SSL_SUCCESS) assert(0);
+            base.ca_, 0) != SSL_SUCCESS) throw(0);
     if (base.cert_)
         if (SSL_CTX_use_certificate_file(base.ctx_,
-            base.cert_, SSL_FILETYPE_PEM) != SSL_SUCCESS) assert(0);
+            base.cert_, SSL_FILETYPE_PEM) != SSL_SUCCESS) throw(0);
     if (base.key_)
         if (SSL_CTX_use_PrivateKey_file(base.ctx_, base.key_,
-            SSL_FILETYPE_PEM) != SSL_SUCCESS) assert(0);
+            SSL_FILETYPE_PEM) != SSL_SUCCESS) throw(0);
 
     if (end == server_end) SetDH(base);
 

=== modified file 'extra/yassl/src/yassl_error.cpp'
--- a/extra/yassl/src/yassl_error.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/src/yassl_error.cpp	2012-04-07 13:58:46 +0000
@@ -31,6 +31,11 @@
     #pragma warning(disable: 4996)
 #endif
 
+#ifdef _MSC_VER
+    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
+    #pragma warning(disable: 4996)
+#endif
+
 namespace yaSSL {
 
 
@@ -59,8 +64,9 @@
 {
     using namespace TaoCrypt;
     const int max = MAX_ERROR_SZ;  // shorthand
+    int localError = error;        // errors from a few enums 
 
-    switch ((int) error) {
+    switch (localError) {
 
         // yaSSL proper errors
     case range_error :
@@ -121,7 +127,7 @@
 
     case certificate_error :
         strncpy(buffer, "unable to proccess cerificate", max);
-        break; 
+        break;
 
     case privateKey_error :
         strncpy(buffer, "unable to proccess private key, bad format", max);
@@ -130,7 +136,7 @@
     case badVersion_error :
         strncpy(buffer, "protocol version mismatch", max);
         break;
-        
+
     case compress_error :
         strncpy(buffer, "compression error", max);
         break;
@@ -148,6 +154,10 @@
         strncpy(buffer, "the read operation would block", max);
         break;
 
+    case SSL_ERROR_WANT_WRITE :
+        strncpy(buffer, "the write operation would block", max);
+        break;
+
     case CERTFICATE_ERROR :
         strncpy(buffer, "Unable to verify certificate", max);
         break;

=== modified file 'extra/yassl/src/yassl_imp.cpp'
--- a/extra/yassl/src/yassl_imp.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/src/yassl_imp.cpp	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005, 2010, Oracle and/or its affiliates
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates
 
    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
@@ -117,7 +117,7 @@
     if (*dhClient.get_agreedKey() == 0) 
         ssl.set_preMaster(dhClient.get_agreedKey() + 1, keyLength - 1);
     else
-    ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);
+        ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);
 }
 
 
@@ -135,8 +135,7 @@
     mySTL::auto_ptr<Auth> auth;
     const CertManager& cert = ssl.getCrypto().get_certManager();
     
-    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo)
-    {
+    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) {
         if (cert.get_keyType() != rsa_sa_algo) {
             ssl.SetError(privateKey_error);
             return;
@@ -925,8 +924,6 @@
 
 void Data::SetData(uint16 len, const opaque* buffer)
 {
-    assert(write_buffer_ == 0);
-
     length_ = len;
     write_buffer_ = buffer;
 }
@@ -992,6 +989,11 @@
     int dataSz = msgSz - ivExtra - digestSz - pad - padSz;
     opaque verify[SHA_LEN];
 
+    if (dataSz < 0) {
+        ssl.SetError(bad_input);
+        return;
+    }
+
     const byte* rawData = input.get_buffer() + input.get_current();
 
     // read data
@@ -1006,10 +1008,10 @@
                                             tmp.get_buffer(), tmp.get_size()));
         }
         else {
-        input_buffer* data;
-        ssl.addData(data = NEW_YS input_buffer(dataSz));
-        input.read(data->get_buffer(), dataSz);
-        data->add_size(dataSz);
+            input_buffer* data;
+            ssl.addData(data = NEW_YS input_buffer(dataSz));
+            input.read(data->get_buffer(), dataSz);
+            data->add_size(dataSz);
         }
 
         if (ssl.isTLS())
@@ -1085,19 +1087,37 @@
     uint32 list_sz;
     byte   tmp[3];
 
+    if (input.get_remaining() < sizeof(tmp)) {
+        ssl.SetError(YasslError(bad_input));
+        return;
+    }
     tmp[0] = input[AUTO];
     tmp[1] = input[AUTO];
     tmp[2] = input[AUTO];
     c24to32(tmp, list_sz);
+
+    if (list_sz > (uint)MAX_RECORD_SIZE) { // sanity check
+        ssl.SetError(YasslError(bad_input));
+        return;
+    }
     
     while (list_sz) {
         // cert size
         uint32 cert_sz;
+
+        if (input.get_remaining() < sizeof(tmp)) {
+            ssl.SetError(YasslError(bad_input));
+            return;
+        }
         tmp[0] = input[AUTO];
         tmp[1] = input[AUTO];
         tmp[2] = input[AUTO];
         c24to32(tmp, cert_sz);
         
+        if (cert_sz > (uint)MAX_RECORD_SIZE || input.get_remaining() < cert_sz){
+            ssl.SetError(YasslError(bad_input));
+            return;
+        }
         x509* myCert;
         cm.AddPeerCert(myCert = NEW_YS x509(cert_sz));
         input.read(myCert->use_buffer(), myCert->get_length());
@@ -1294,7 +1314,7 @@
     ssl.set_pending(cipher_suite_[1]);
     ssl.set_random(random_, server_end);
     if (id_len_)
-    ssl.set_sessionID(session_id_);
+        ssl.set_sessionID(session_id_);
     else
         ssl.useSecurity().use_connection().sessionID_Set_ = false;
 
@@ -1422,7 +1442,7 @@
     if (hello.id_len_) input.read(hello.session_id_, ID_LEN);
     
     // Suites
-    byte tmp[2];
+    byte   tmp[2];
     uint16 len;
     tmp[0] = input[AUTO];
     tmp[1] = input[AUTO];
@@ -1430,8 +1450,8 @@
 
     hello.suite_len_ = min(len, static_cast<uint16>(MAX_SUITE_SZ));
     input.read(hello.cipher_suites_, hello.suite_len_);
-    if (len > hello.suite_len_) // ignore extra suites
-        input.set_current(input.get_current() + len -  hello.suite_len_);
+    if (len > hello.suite_len_)  // ignore extra suites
+        input.set_current(input.get_current() + len - hello.suite_len_);
 
     // Compression
     hello.comp_len_ = input[AUTO];
@@ -1495,8 +1515,9 @@
     if (ssl.GetMultiProtocol()) {   // SSLv23 support
         if (ssl.isTLS() && client_version_.minor_ < 1) {
             // downgrade to SSLv3
-        ssl.useSecurity().use_connection().TurnOffTLS();
-        ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
+            ssl.useSecurity().use_connection().TurnOffTLS();
+            
+            ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
             bool removeDH  = ssl.getSecurity().get_parms().removeDH_;
             bool removeRSA = false;
             bool removeDSA = false;
@@ -1510,7 +1531,7 @@
             // reset w/ SSL suites
             ssl.useSecurity().use_parms().SetSuites(pv, removeDH, removeRSA,
                                                     removeDSA);
-    }
+        }
         else if (ssl.isTLSv1_1() && client_version_.minor_ == 1)
             // downgrade to TLSv1, but use same suites
             ssl.useSecurity().use_connection().TurnOffTLS1_1();
@@ -1541,6 +1562,7 @@
         ssl.set_session(session);
         ssl.useSecurity().set_resuming(true);
         ssl.matchSuite(session->GetSuite(), SUITE_LEN);
+        if (ssl.GetError()) return;
         ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]);
         ssl.set_masterSecret(session->GetSecret());
 
@@ -2037,7 +2059,7 @@
     // verify hashes
     const  Finished& verify = ssl.getHashes().get_verify();
     uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ;
-
+    
     input.read(hashes_.md5_, finishedSz);
 
     if (memcmp(&hashes_, &verify.hashes_, finishedSz)) {

=== modified file 'extra/yassl/src/yassl_int.cpp'
--- a/extra/yassl/src/yassl_int.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/src/yassl_int.cpp	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005, 2011, Oracle and/or its affiliates
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates
 
    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
@@ -308,8 +308,9 @@
             SetError(YasslError(err));
             return;
         }
-        else if (serverSide && !(ctx->GetCiphers().setSuites_)) {
+        else if (serverSide && ctx->GetCiphers().setSuites_ == 0) {
             // remove RSA or DSA suites depending on cert key type
+            // but don't override user sets
             ProtocolVersion pv = secure_.get_connection().version_;
             
             bool removeDH  = secure_.use_parms().removeDH_;
@@ -1128,8 +1129,28 @@
 
 void SSL::Send(const byte* buffer, uint sz)
 {
-    if (socket_.send(buffer, sz) != sz)
-        SetError(send_error);
+    unsigned int sent = 0;
+
+    if (socket_.send(buffer, sz, sent) != sz) {
+        if (socket_.WouldBlock()) {
+            buffers_.SetOutput(NEW_YS output_buffer(sz - sent, buffer + sent,
+                                                    sz - sent));
+            SetError(YasslError(SSL_ERROR_WANT_WRITE));
+        }
+        else
+            SetError(send_error);
+    }
+}
+
+
+void SSL::SendWriteBuffered()
+{
+    output_buffer* out = buffers_.TakeOutput();
+
+    if (out) {
+        mySTL::auto_ptr<output_buffer> tmp(out);
+        Send(out->get_buffer(), out->get_size());
+    }
 }
 
 
@@ -1291,7 +1312,6 @@
             if (secure_.use_parms().suites_[i] == peer[j]) {
                 secure_.use_parms().suite_[0] = 0x00;
                 secure_.use_parms().suite_[1] = peer[j];
-
                 return;
             }
 
@@ -1435,7 +1455,6 @@
 
 void SSL_SESSION::CopyX509(X509* x)
 {
-    assert(peerX509_ == 0);
     if (x == 0) return;
 
     X509_NAME* issuer   = x->GetIssuer();
@@ -2232,7 +2251,7 @@
 }
 
 
-Buffers::Buffers() : rawInput_(0)
+Buffers::Buffers() : prevSent(0), plainSz(0), rawInput_(0), output_(0)
 {}
 
 
@@ -2243,12 +2262,18 @@
     STL::for_each(dataList_.begin(), dataList_.end(),
                   del_ptr_zero()) ;
     ysDelete(rawInput_);
+    ysDelete(output_);
+}
+
+
+void Buffers::SetOutput(output_buffer* ob)
+{
+    output_ = ob;
 }
 
 
 void Buffers::SetRawInput(input_buffer* ib)
 {
-    assert(rawInput_ == 0);
     rawInput_ = ib;
 }
 
@@ -2262,6 +2287,15 @@
 }
 
 
+output_buffer* Buffers::TakeOutput()
+{
+    output_buffer* ret = output_;
+    output_ = 0;
+
+    return ret;
+}
+
+
 const Buffers::inputList& Buffers::getData() const
 {
     return dataList_;
@@ -2536,14 +2570,12 @@
     // these versions should never get called
     int Compress(const byte* in, int sz, input_buffer& buffer)
     {
-        assert(0);  
         return -1;
     } 
 
 
     int DeCompress(input_buffer& in, int sz, input_buffer& out)
     {
-        assert(0);  
         return -1;
     } 
 

=== modified file 'extra/yassl/taocrypt/CMakeLists.txt'
--- a/extra/yassl/taocrypt/CMakeLists.txt	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/taocrypt/CMakeLists.txt	2012-03-27 23:04:46 +0000
@@ -20,12 +20,14 @@
 ADD_DEFINITIONS(${SSL_DEFINES})
 SET(TAOCRYPT_SOURCES		src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp 
 				src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp 
-				src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp
+				src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp 
+                                src/rabbit.cpp src/hc128.cpp
 				include/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp 
 				include/coding.hpp include/des.hpp include/dh.hpp include/dsa.hpp include/dsa.hpp
 				include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp 
 				include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
-				include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
+				include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp
+                                include/rabbit.hpp include/hc128.hpp)
 
 IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
   SET(TAOCRYPT_SOURCES ${TAOCRYPT_SOURCES} src/template_instnt.cpp)

=== modified file 'extra/yassl/taocrypt/README'
--- a/extra/yassl/taocrypt/README	2007-03-23 10:52:25 +0000
+++ b/extra/yassl/taocrypt/README	2012-02-10 14:33:27 +0000
@@ -21,7 +21,7 @@
 Public Key Crypto: RSA, DSA, Diffie-Hellman
 Password based key derivation: PBKDF2 from PKCS #5
 Pseudo Random Number Generators
-Lare Integer Support
+Large Integer Support
 Base 16/64 encoding/decoding
 DER encoding/decoding
 X.509 processing

=== modified file 'extra/yassl/taocrypt/benchmark/benchmark.cpp'
--- a/extra/yassl/taocrypt/benchmark/benchmark.cpp	2011-02-20 16:51:43 +0000
+++ b/extra/yassl/taocrypt/benchmark/benchmark.cpp	2012-04-07 13:58:46 +0000
@@ -103,7 +103,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("3DES     %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("3DES     %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                              persec);
 }
 
@@ -123,7 +123,7 @@
     double persec = 1 / total * megs;
 
     if (show)
-        printf("AES      %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+        printf("AES      %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                                  persec);
 }
 
@@ -142,7 +142,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("Twofish  %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("Twofish  %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                             persec);
 
 }
@@ -162,7 +162,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("Blowfish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("Blowfish %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                              persec);
 }
 
@@ -181,7 +181,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("ARC4     %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("ARC4     %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                              persec);
 }
 
@@ -203,7 +203,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("MD5      %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("MD5      %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                              persec);
 }
 
@@ -231,7 +231,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("SHA      %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("SHA      %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                              persec);
 }
 
@@ -253,7 +253,7 @@
 
     double persec = 1 / total * megs;
 
-    printf("RIPEMD   %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
+    printf("RIPEMD   %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
                                                              persec);
 }
 
@@ -276,7 +276,7 @@
     byte      message[] = "Everyone gets Friday off.";
     byte      cipher[128];  // for 1024 bit
     byte      plain[128];   // for 1024 bit
-    const int len = strlen((char*)message);
+    const int len = (word32)strlen((char*)message);
     
     int i;    
     double start = current_time();

=== modified file 'extra/yassl/taocrypt/benchmark/benchmark.dsp'
--- a/extra/yassl/taocrypt/benchmark/benchmark.dsp	2006-11-29 13:35:59 +0000
+++ b/extra/yassl/taocrypt/benchmark/benchmark.dsp	2012-02-13 11:40:12 +0000
@@ -49,8 +49,8 @@
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
 
 !ELSEIF  "$(CFG)" == "benchmark - Win32 Debug"
 
@@ -64,7 +64,7 @@
 # PROP Output_Dir "Debug"
 # PROP Intermediate_Dir "Debug"
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ  /c
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
 # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ  /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
@@ -72,8 +72,8 @@
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 
 !ENDIF 
 

=== modified file 'extra/yassl/taocrypt/benchmark/dh1024.der'
Binary files a/extra/yassl/taocrypt/benchmark/dh1024.der	2006-04-19 09:42:55 +0000 and b/extra/yassl/taocrypt/benchmark/dh1024.der	2012-02-10 14:33:27 +0000 differ
=== modified file 'extra/yassl/taocrypt/benchmark/dsa1024.der'
Binary files a/extra/yassl/taocrypt/benchmark/dsa1024.der	2006-04-19 09:42:55 +0000 and b/extra/yassl/taocrypt/benchmark/dsa1024.der	2012-02-10 14:33:27 +0000 differ
=== modified file 'extra/yassl/taocrypt/benchmark/make.bat' (properties changed: -x to +x)
=== modified file 'extra/yassl/taocrypt/benchmark/rsa1024.der'
Binary files a/extra/yassl/taocrypt/benchmark/rsa1024.der	2006-04-19 09:42:55 +0000 and b/extra/yassl/taocrypt/benchmark/rsa1024.der	2012-02-10 14:33:27 +0000 differ
=== added directory 'extra/yassl/taocrypt/certs'
=== added file 'extra/yassl/taocrypt/certs/client-cert.der'
Binary files a/extra/yassl/taocrypt/certs/client-cert.der	1970-01-01 00:00:00 +0000 and b/extra/yassl/taocrypt/certs/client-cert.der	2012-02-10 14:33:27 +0000 differ
=== added file 'extra/yassl/taocrypt/certs/client-key.der'
Binary files a/extra/yassl/taocrypt/certs/client-key.der	1970-01-01 00:00:00 +0000 and b/extra/yassl/taocrypt/certs/client-key.der	2012-02-10 14:33:27 +0000 differ
=== added file 'extra/yassl/taocrypt/certs/dh1024.dat'
--- a/extra/yassl/taocrypt/certs/dh1024.dat	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/taocrypt/certs/dh1024.dat	2012-02-10 14:33:27 +0000
@@ -0,0 +1,1 @@
+30818702818100DA9A18547FF03B385CC16508C173A7EF4EB61CB40EF8FEF3B31F145051676166BCDC3FE6B799FC394D08C26385F9413F896E09117E46209D6923602683CEA100924A6EE695281775C619DAA94EA8CB3691B4275B0183F1D39639EBC92995FE645D6C1BC28D409E585549BBD2C5DCDD6C208B04EADD8B7A6D997F72CBAD88390F020102
\ No newline at end of file

=== added file 'extra/yassl/taocrypt/certs/dsa512.der'
Binary files a/extra/yassl/taocrypt/certs/dsa512.der	1970-01-01 00:00:00 +0000 and b/extra/yassl/taocrypt/certs/dsa512.der	2012-02-10 14:33:27 +0000 differ
=== modified file 'extra/yassl/taocrypt/include/asn.hpp'
--- a/extra/yassl/taocrypt/include/asn.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/include/asn.hpp	2012-04-07 13:58:46 +0000
@@ -167,6 +167,7 @@
     void Decode(RSA_PublicKey&);
 private:
     void ReadHeader();
+    void ReadHeaderOpenSSL();
 };
 
 

=== modified file 'extra/yassl/taocrypt/include/block.hpp'
--- a/extra/yassl/taocrypt/include/block.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/include/block.hpp	2012-04-07 13:58:46 +0000
@@ -61,10 +61,6 @@
     void          destroy(pointer p) {p->~T();}
     size_type     max_size() const {return ~size_type(0)/sizeof(T);}
 protected:
-    static void CheckSize(size_t n)
-    {
-        assert(n <= ~size_t(0) / sizeof(T));
-    }
 };
 
 
@@ -101,7 +97,8 @@
 
     pointer allocate(size_type n, const void* = 0)
     {
-        this->CheckSize(n);
+        if (n > this->max_size())
+            return 0;
         if (n == 0)
             return 0;
         return NEW_TC T[n];
@@ -144,9 +141,8 @@
         return *this;
     }
 
-    T& operator[] (word32 i) { assert(i < sz_); return buffer_[i]; }
-    const T& operator[] (word32 i) const 
-        { assert(i < sz_); return buffer_[i]; }
+    T& operator[] (word32 i) { return buffer_[i]; }
+    const T& operator[] (word32 i) const { return buffer_[i]; }
 
     T* operator+ (word32 i) { return buffer_ + i; }
     const T* operator+ (word32 i) const { return buffer_ + i; }

=== modified file 'extra/yassl/taocrypt/include/blowfish.hpp'
--- a/extra/yassl/taocrypt/include/blowfish.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/include/blowfish.hpp	2012-04-07 13:58:46 +0000
@@ -59,11 +59,11 @@
     void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
     void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
 private:
-	static const word32 p_init_[ROUNDS + 2];
-	static const word32 s_init_[4 * 256];
+    static const word32 p_init_[ROUNDS + 2];
+    static const word32 s_init_[4 * 256];
 
-	word32 pbox_[ROUNDS + 2 + 4 * 256];
-	word32* sbox_;
+    word32 pbox_[ROUNDS + 2 + 4 * 256];
+    word32* sbox_;
 
     void crypt_block(const word32 in[2], word32 out[2]) const;
     void AsmProcess(const byte* in, byte* out) const;

=== modified file 'extra/yassl/taocrypt/include/des.hpp'
--- a/extra/yassl/taocrypt/include/des.hpp	2007-03-23 12:43:09 +0000
+++ b/extra/yassl/taocrypt/include/des.hpp	2012-02-13 11:40:12 +0000
@@ -84,7 +84,7 @@
 // DES_EDE3
 class DES_EDE3 : public Mode_BASE {
 public:
-    DES_EDE3(CipherDir DIR, Mode MODE) 
+    DES_EDE3(CipherDir DIR, Mode MODE)
         : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
 
     void SetKey(const byte*, word32, CipherDir dir);

=== modified file 'extra/yassl/taocrypt/include/file.hpp'
--- a/extra/yassl/taocrypt/include/file.hpp	2011-02-25 18:35:25 +0000
+++ b/extra/yassl/taocrypt/include/file.hpp	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2000-2007 MySQL AB
+   Copyright (C) 2000, 2012, 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
@@ -39,25 +39,32 @@
     explicit Source(word32 sz = 0) : buffer_(sz), current_(0) {}
     Source(const byte* b, word32 sz) : buffer_(b, sz), current_(0) {}
 
+    word32 remaining()         { if (GetError().What()) return 0;
+                                 else return buffer_.size() - current_; } 
     word32 size() const        { return buffer_.size(); }
     void   grow(word32 sz)     { buffer_.CleanGrow(sz); }
+
+    bool IsLeft(word32 sz) { if (remaining() >= sz) return true;
+                             else { SetError(CONTENT_E); return false; } }
    
     const byte*  get_buffer()  const { return buffer_.get_buffer(); }
     const byte*  get_current() const { return &buffer_[current_]; }
     word32       get_index()   const { return current_; }
-    void         set_index(word32 i) { current_ = i; }
+    void         set_index(word32 i) { if (i < size()) current_ = i; }
 
     byte operator[] (word32 i) { current_ = i; return next(); }
-    byte next() { return buffer_[current_++]; }
-    byte prev() { return buffer_[--current_]; }
+    byte next() { if (IsLeft(1)) return buffer_[current_++]; else return 0; }
+    byte prev() { if (current_)  return buffer_[--current_]; else return 0; }
 
     void add(const byte* data, word32 len)
     {
-        memcpy(buffer_.get_buffer() + current_, data, len);
-        current_ += len;
+        if (IsLeft(len)) {
+            memcpy(buffer_.get_buffer() + current_, data, len);
+            current_ += len;
+        }
     }
 
-    void advance(word32 i) { current_ += i; }
+    void advance(word32 i) { if (IsLeft(i)) current_ += i; }
     void reset(ByteBlock&);
 
     Error  GetError()              { return error_; }

=== modified file 'extra/yassl/taocrypt/include/hash.hpp'
--- a/extra/yassl/taocrypt/include/hash.hpp	2007-03-23 12:43:09 +0000
+++ b/extra/yassl/taocrypt/include/hash.hpp	2012-02-13 11:40:12 +0000
@@ -63,8 +63,8 @@
     word32          buffLen_;   // in bytes
     HashLengthType  loLen_;     // length in bytes
     HashLengthType  hiLen_;     // length in bytes
-    word32  digest_[MaxDigestSz];
-    word32  buffer_[MaxBufferSz / sizeof(word32)];
+    word32          digest_[MaxDigestSz];
+    word32          buffer_[MaxBufferSz / sizeof(word32)];
 
     virtual void Transform() = 0;
 

=== added file 'extra/yassl/taocrypt/include/hc128.hpp'
--- a/extra/yassl/taocrypt/include/hc128.hpp	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/taocrypt/include/hc128.hpp	2012-02-10 14:33:27 +0000
@@ -0,0 +1,63 @@
+/*
+   Copyright (c) 2005, 2010, 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; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+   MA  02110-1301  USA.
+*/
+
+/* hc128.hpp defines HC128
+*/
+
+
+#ifndef TAO_CRYPT_HC128_HPP
+#define TAO_CRYPT_HC128_HPP
+
+#include "misc.hpp"
+
+namespace TaoCrypt {
+
+
+// HC128 encryption and decryption
+class HC128 {
+public:
+
+    typedef HC128 Encryption;
+    typedef HC128 Decryption;
+
+
+    HC128() {}
+
+    void Process(byte*, const byte*, word32);
+    void SetKey(const byte*, const byte*);
+private:
+    word32 T_[1024];             /* P[i] = T[i];  Q[i] = T[1024 + i ]; */
+    word32 X_[16];
+    word32 Y_[16];
+    word32 counter1024_;         /* counter1024 = i mod 1024 at the ith step */
+    word32 key_[8];
+    word32 iv_[8];
+
+    void SetIV(const byte*);
+    void GenerateKeystream(word32*);
+    void SetupUpdate();
+
+    HC128(const HC128&);                  // hide copy
+    const HC128 operator=(const HC128&);  // and assign
+};
+
+} // namespace
+
+
+#endif // TAO_CRYPT_HC128_HPP
+

=== modified file 'extra/yassl/taocrypt/include/integer.hpp'
--- a/extra/yassl/taocrypt/include/integer.hpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/include/integer.hpp	2012-02-10 14:33:27 +0000
@@ -110,13 +110,6 @@
 #endif
 
 
-// general MIN
-template<typename T> inline
-const T& min(const T& a, const T& b)
-{
-    return a < b ? a : b;
-}
-
 
 // general MAX
 template<typename T> inline

=== modified file 'extra/yassl/taocrypt/include/kernelc.hpp'
--- a/extra/yassl/taocrypt/include/kernelc.hpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/include/kernelc.hpp	2012-02-10 14:33:27 +0000
@@ -30,17 +30,5 @@
 extern "C" void* memset(void*, int, size_t);
 extern "C" void  printk(char *fmt, ...);
 
-#define KERN_ERR "<3>"   /* error conditions */
-
-#if defined(NDEBUG)
-    #define assert(p)  	((void)0)
-#else
-    #define assert(expr)   \
-    if (!(expr))         { \
-         printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
-         #expr,__FILE__,__FUNCTION__,__LINE__); }
-#endif
-
-
 
 #endif // TAOCRYPT_KERNELC_HPP

=== modified file 'extra/yassl/taocrypt/include/misc.hpp'
--- a/extra/yassl/taocrypt/include/misc.hpp	2011-06-30 15:46:53 +0000
+++ b/extra/yassl/taocrypt/include/misc.hpp	2012-02-13 12:44:54 +0000
@@ -24,7 +24,6 @@
 
 #if !defined(DO_TAOCRYPT_KERNEL_MODE)
     #include <stdlib.h>
-    #include <assert.h>
     #include <string.h>
 #else
     #include "kernelc.hpp"
@@ -62,30 +61,30 @@
     template<typename T>
     void tcDelete(T* ptr)
     {
-    if (ptr) ptr->~T();
-    ::operator delete(ptr, TaoCrypt::tc);
+        if (ptr) ptr->~T();
+        ::operator delete(ptr, TaoCrypt::tc);
     }
 
     template<typename T>
     void tcArrayDelete(T* ptr)
     {
-    // can't do array placement destruction since not tracking size in
-    // allocation, only allow builtins to use array placement since they
-    // don't need destructors called
-    typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1];
-    (void)sizeof(builtin);
+        // can't do array placement destruction since not tracking size in
+        // allocation, only allow builtins to use array placement since they
+        // don't need destructors called
+        typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1];
+        (void)sizeof(builtin);
 
-    ::operator delete[](ptr, TaoCrypt::tc);
+        ::operator delete[](ptr, TaoCrypt::tc);
     }
 
     #define NEW_TC new (TaoCrypt::tc)
 
 
     // to resolve compiler generated operator delete on base classes with
-    // virtual destructors (when on stack), make sure doesn't get called
+    // virtual destructors (when on stack)
     class virtual_base {
     public:
-    static void operator delete(void*) { assert(0); }
+        static void operator delete(void*) { }
     };
 
 #else // YASSL_PURE_C
@@ -366,7 +365,6 @@
 template <class T1, class T2>
 inline T2 ModPowerOf2(T1 a, T2 b)
 {
-    assert(IsPowerOf2(b));
     return T2(a) & (b-1);
 }
 
@@ -409,14 +407,12 @@
 
 template <class T> inline T rotlFixed(T x, unsigned int y)
 {
-    assert(y < sizeof(T)*8);
-        return (x<<y) | (x>>(sizeof(T)*8-y));
+    return (x<<y) | (x>>(sizeof(T)*8-y));
 }
 
 template <class T> inline T rotrFixed(T x, unsigned int y)
 {
-    assert(y < sizeof(T)*8);
-        return (x>>y) | (x<<(sizeof(T)*8-y));
+    return (x>>y) | (x<<(sizeof(T)*8-y));
 }
 
 #ifdef INTEL_INTRINSICS
@@ -425,13 +421,11 @@
 
 template<> inline word32 rotlFixed(word32 x, word32 y)
 {
-    assert(y < 32);
     return y ? _lrotl(x, y) : x;
 }
 
 template<> inline word32 rotrFixed(word32 x, word32 y)
 {
-    assert(y < 32);
     return y ? _lrotr(x, y) : x;
 }
 
@@ -441,7 +435,9 @@
 #undef min
 #endif 
 
-inline word32 min(word32 a, word32 b)
+
+template <class T>
+inline const T& min(const T& a, const T& b)
 {
     return a < b ? a : b;
 }
@@ -486,7 +482,6 @@
 template <typename T>
 inline void ByteReverse(T* out, const T* in, word32 byteCount)
 {
-    assert(byteCount % sizeof(T) == 0);
     word32 count = byteCount/sizeof(T);
     for (word32 i=0; i<count; i++)
         out[i] = ByteReverse(in[i]);
@@ -574,7 +569,6 @@
                        word32 inlen)
 {
     const unsigned int U = sizeof(T);
-    assert(inlen <= outlen*U);
     memcpy(out, in, inlen);
     memset((byte *)out+inlen, 0, outlen*U-inlen);
     ByteReverseIf(out, out, RoundUpToMultipleOf(inlen, U), order);
@@ -583,7 +577,8 @@
 
 #ifdef _MSC_VER
     // disable conversion warning
-    #pragma warning(disable:4244)
+    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
+    #pragma warning(disable:4244 4996)
 #endif
 
 
@@ -678,10 +673,7 @@
 inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block)
 {
     if (assumeAligned)
-    {
-        assert(IsAligned<T>(block));
         return ByteReverseIf(*reinterpret_cast<const T *>(block), order);
-    }
     else
         return UnalignedGetWord<T>(order, block);
 }
@@ -699,7 +691,6 @@
 {
     if (assumeAligned)
     {
-        assert(IsAligned<T>(block));
         if (xorBlock)
             *reinterpret_cast<T *>(block) = ByteReverseIf(value, order) 
                 ^ *reinterpret_cast<const T *>(xorBlock);
@@ -812,7 +803,6 @@
 inline
 word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits)
 {
-    assert (shiftBits<WORD_BITS);
     word u, carry=0;
     if (shiftBits)
         for (unsigned int i=0; i<n; i++)
@@ -828,7 +818,6 @@
 inline
 word ShiftWordsRightByBits(word* r, unsigned int n, unsigned int shiftBits)
 {
-    assert (shiftBits<WORD_BITS);
     word u, carry=0;
     if (shiftBits)
         for (int i=n-1; i>=0; i--)

=== modified file 'extra/yassl/taocrypt/include/modes.hpp'
--- a/extra/yassl/taocrypt/include/modes.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/include/modes.hpp	2012-04-07 13:58:46 +0000
@@ -61,9 +61,7 @@
     explicit Mode_BASE(int sz, CipherDir dir, Mode mode) 
         : blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)),
           tmp_(reinterpret_cast<byte*>(t_)), dir_(dir), mode_(mode)
-    { 
-        assert(sz <= MaxBlockSz);
-    }
+    {}
     virtual ~Mode_BASE() {}
 
     virtual void Process(byte*, const byte*, word32);
@@ -96,8 +94,7 @@
 {
     if (mode_ == ECB)
         ECB_Process(out, in, sz);
-    else if (mode_ == CBC)
-    {
+    else if (mode_ == CBC) {
         if (dir_ == ENCRYPTION)
             CBC_Encrypt(out, in, sz);
         else

=== modified file 'extra/yassl/taocrypt/include/pwdbased.hpp'
--- a/extra/yassl/taocrypt/include/pwdbased.hpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/include/pwdbased.hpp	2012-02-10 14:33:27 +0000
@@ -48,8 +48,9 @@
                                  word32 pLen, const byte* salt, word32 sLen,
                                  word32 iterations) const
 {
-	assert(dLen <= MaxDerivedKeyLength());
-	assert(iterations > 0);
+	if (dLen > MaxDerivedKeyLength())
+        return 0;
+
 
     ByteBlock buffer(T::DIGEST_SIZE);
 	HMAC<T>   hmac;

=== added file 'extra/yassl/taocrypt/include/rabbit.hpp'
--- a/extra/yassl/taocrypt/include/rabbit.hpp	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/taocrypt/include/rabbit.hpp	2012-02-10 14:33:27 +0000
@@ -0,0 +1,65 @@
+/*
+   Copyright (c) 2005, 2010, 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; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+   MA  02110-1301  USA.
+*/
+
+/* rabbit.hpp defines Rabbit
+*/
+
+
+#ifndef TAO_CRYPT_RABBIT_HPP
+#define TAO_CRYPT_RABBIT_HPP
+
+#include "misc.hpp"
+
+namespace TaoCrypt {
+
+
+// Rabbit encryption and decryption
+class Rabbit {
+public:
+
+    typedef Rabbit Encryption;
+    typedef Rabbit Decryption;
+
+    enum RabbitCtx { Master = 0, Work = 1 };
+
+    Rabbit() {}
+
+    void Process(byte*, const byte*, word32);
+    void SetKey(const byte*, const byte*);
+private:
+    struct Ctx {
+        word32 x[8];
+        word32 c[8];
+        word32 carry;
+    };
+
+    Ctx masterCtx_;
+    Ctx workCtx_;
+
+    void NextState(RabbitCtx);
+    void SetIV(const byte*);
+
+    Rabbit(const Rabbit&);                  // hide copy
+    const Rabbit operator=(const Rabbit&);  // and assign
+};
+
+} // namespace
+
+
+#endif // TAO_CRYPT_RABBIT_HPP
+

=== modified file 'extra/yassl/taocrypt/include/rsa.hpp'
--- a/extra/yassl/taocrypt/include/rsa.hpp	2007-03-23 12:43:09 +0000
+++ b/extra/yassl/taocrypt/include/rsa.hpp	2012-02-13 11:40:12 +0000
@@ -178,7 +178,8 @@
                                  RandomNumberGenerator& rng)
 {
     PK_Lengths lengths(key_.GetModulus());
-    assert(sz <= lengths.FixedMaxPlaintextLength());
+    if (sz > lengths.FixedMaxPlaintextLength())
+        return;
 
     ByteBlock paddedBlock(lengths.PaddedBlockByteLength());
     padding_.Pad(plain, sz, paddedBlock.get_buffer(),
@@ -195,7 +196,6 @@
                                    RandomNumberGenerator& rng)
 {
     PK_Lengths lengths(key_.GetModulus());
-    assert(sz == lengths.FixedCiphertextLength());
 
     if (sz != lengths.FixedCiphertextLength())
         return 0;

=== modified file 'extra/yassl/taocrypt/include/runtime.hpp'
--- a/extra/yassl/taocrypt/include/runtime.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/include/runtime.hpp	2012-04-07 13:58:46 +0000
@@ -31,7 +31,6 @@
 
 #ifdef __sun
  
-#include <assert.h>
 
 // Handler for pure virtual functions
 namespace __Crun {
@@ -46,9 +45,7 @@
 #if __GNUC__ > 2
 
 extern "C" {
-#if !defined(DO_TAOCRYPT_KERNEL_MODE)
-    #include <assert.h>
-#else
+#if defined(DO_TAOCRYPT_KERNEL_MODE)
     #include "kernelc.hpp"
 #endif
     int __cxa_pure_virtual () __attribute__ ((weak));

=== modified file 'extra/yassl/taocrypt/include/types.hpp'
--- a/extra/yassl/taocrypt/include/types.hpp	2007-03-23 10:52:25 +0000
+++ b/extra/yassl/taocrypt/include/types.hpp	2012-02-10 14:33:27 +0000
@@ -62,7 +62,7 @@
 // compilers we've found 64-bit multiply insructions for
 #if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX)
     #if !(defined(__ICC) || defined(__INTEL_COMPILER))
-    #define HAVE_64_MULTIPLY
+        #define HAVE_64_MULTIPLY
     #endif
 #endif
 

=== modified file 'extra/yassl/taocrypt/mySTL/stdexcept.hpp'
--- a/extra/yassl/taocrypt/mySTL/stdexcept.hpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/mySTL/stdexcept.hpp	2012-02-10 14:33:27 +0000
@@ -26,7 +26,6 @@
 
 
 #include <string.h>  // strncpy
-#include <assert.h>  // assert
 #include <stdlib.h>  // size_t
 
 
@@ -41,7 +40,7 @@
     virtual const char* what() const { return ""; }
 
     // for compiler generated call, never used
-    static void operator delete(void*) { assert(0); }
+    static void operator delete(void*) { }
 private:
     // don't allow dynamic creation of exceptions
     static void* operator new(size_t);

=== modified file 'extra/yassl/taocrypt/mySTL/vector.hpp'
--- a/extra/yassl/taocrypt/mySTL/vector.hpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/mySTL/vector.hpp	2012-02-10 14:33:27 +0000
@@ -26,7 +26,6 @@
 
 #include "helpers.hpp"    // construct, destory, fill, etc.
 #include "algorithm.hpp"  // swap
-#include <assert.h>       // assert
 
 
 namespace mySTL {
@@ -141,9 +140,9 @@
     // for growing, n must be bigger than other size
     vector(size_t n, const vector& other) : vec_(n)
     {
-        assert(n > other.size());
-        vec_.finish_ = uninit_copy(other.vec_.start_, other.vec_.finish_,
-                                   vec_.start_);   
+        if (n > other.size())
+            vec_.finish_ = uninit_copy(other.vec_.start_, other.vec_.finish_,
+                                       vec_.start_);
     }
 };
 

=== modified file 'extra/yassl/taocrypt/src/aes.cpp'
--- a/extra/yassl/taocrypt/src/aes.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/aes.cpp	2012-04-07 13:58:46 +0000
@@ -79,7 +79,7 @@
                 out += BLOCK_SIZE;
                 in  += BLOCK_SIZE;
             }
-    }
+   }
 }
 
 #endif // DO_AES_ASM
@@ -87,8 +87,13 @@
 
 void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
 {
-    assert( (keylen == 16) || (keylen == 24) || (keylen == 32) );
-
+    if (keylen <= 16)
+        keylen = 16;
+    else if (keylen >= 32)
+        keylen = 32;
+    else if (keylen != 24)
+        keylen = 24;
+    
     rounds_ = keylen/4 + 6;
 
     word32 temp, *rk = key_;
@@ -246,34 +251,34 @@
     for (;;) {
         t0 =
             Te0[GETBYTE(s0, 3)] ^
-            Te1[GETBYTE(s1, 2)] ^
-            Te2[GETBYTE(s2, 1)] ^
-            Te3[GETBYTE(s3, 0)] ^
+            Te1[GETBYTE(s1, 2)]  ^
+            Te2[GETBYTE(s2, 1)]  ^
+            Te3[GETBYTE(s3, 0)]  ^
             rk[4];
         t1 =
             Te0[GETBYTE(s1, 3)] ^
-            Te1[GETBYTE(s2, 2)] ^
-            Te2[GETBYTE(s3, 1)] ^
-            Te3[GETBYTE(s0, 0)] ^
+            Te1[GETBYTE(s2, 2)]  ^
+            Te2[GETBYTE(s3, 1)]  ^
+            Te3[GETBYTE(s0, 0)]  ^
             rk[5];
         t2 =
             Te0[GETBYTE(s2, 3)] ^
-            Te1[GETBYTE(s3, 2)] ^
-            Te2[GETBYTE(s0, 1)] ^
-            Te3[GETBYTE(s1, 0)] ^
+            Te1[GETBYTE(s3, 2)]  ^
+            Te2[GETBYTE(s0, 1)]  ^
+            Te3[GETBYTE(s1, 0)]  ^
             rk[6];
         t3 =
             Te0[GETBYTE(s3, 3)] ^
-            Te1[GETBYTE(s0, 2)] ^
-            Te2[GETBYTE(s1, 1)] ^
-            Te3[GETBYTE(s2, 0)] ^
+            Te1[GETBYTE(s0, 2)]  ^
+            Te2[GETBYTE(s1, 1)]  ^
+            Te3[GETBYTE(s2, 0)]  ^
             rk[7];
 
         rk += 8;
         if (--r == 0) {
             break;
         }
-
+        
         s0 =
             Te0[GETBYTE(t0, 3)] ^
             Te1[GETBYTE(t1, 2)] ^
@@ -422,7 +427,7 @@
         (Td4[GETBYTE(t3, 2)] & 0x00ff0000) ^
         (Td4[GETBYTE(t2, 1)] & 0x0000ff00) ^
         (Td4[GETBYTE(t1, 0)] & 0x000000ff) ^
-    rk[0];
+        rk[0];
     s1 =
         (Td4[GETBYTE(t1, 3)] & 0xff000000) ^
         (Td4[GETBYTE(t0, 2)] & 0x00ff0000) ^

=== modified file 'extra/yassl/taocrypt/src/aestables.cpp'
--- a/extra/yassl/taocrypt/src/aestables.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/aestables.cpp	2012-02-10 14:33:27 +0000
@@ -33,6 +33,4 @@
 };
 
 
-
-
 } // namespace

=== modified file 'extra/yassl/taocrypt/src/algebra.cpp'
--- a/extra/yassl/taocrypt/src/algebra.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/algebra.cpp	2012-04-07 13:58:46 +0000
@@ -246,7 +246,6 @@
 
     for (i=0; i<expCount; i++)
     {
-        assert(expBegin->NotNegative());
         exponents.push_back(WindowSlider(*expBegin++, InversionIsFast(), 0));
         exponents[i].FindNextWindow();
         buckets[i].resize(1<<(exponents[i].windowSize-1), Identity());
@@ -287,7 +286,7 @@
         r = buckets[i][buckets[i].size()-1];
         if (buckets[i].size() > 1)
         {
-            for (int j= (unsigned int) (buckets[i].size()) - 2; j >= 1; j--)
+            for (size_t j = buckets[i].size()-2; j >= 1; j--)
             {
                 Accumulate(buckets[i][j], buckets[i][j+1]);
                 Accumulate(r, buckets[i][j]);

=== modified file 'extra/yassl/taocrypt/src/arc4.cpp'
--- a/extra/yassl/taocrypt/src/arc4.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/arc4.cpp	2012-02-10 14:33:27 +0000
@@ -104,7 +104,7 @@
 #ifdef DO_ARC4_ASM
 
 #ifdef _MSC_VER
-    __declspec(naked) 
+    __declspec(naked)
 #else
     __attribute__ ((noinline))
 #endif

=== modified file 'extra/yassl/taocrypt/src/asn.cpp'
--- a/extra/yassl/taocrypt/src/asn.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/asn.cpp	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005-2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc.
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    Use is subject to license terms.
 
    This program is free software; you can redistribute it and/or modify
@@ -111,7 +111,8 @@
     GetTime(certTime.tm_min,  date, i); 
     GetTime(certTime.tm_sec,  date, i); 
 
-    assert(date[i] == 'Z');     // only Zulu supported for this profile
+    if (date[i] != 'Z')     // only Zulu supported for this profile
+        return false;
 
     time_t ltime = time(0);
     tm* localTime = gmtime(&ltime);
@@ -143,6 +144,8 @@
     if (b >= LONG_LENGTH) {        
         word32 bytes = b & 0x7F;
 
+        if (source.IsLeft(bytes) == false) return 0;
+
         while (bytes--) {
             b = source.next();
             length = (length << 8) | b;
@@ -214,9 +217,9 @@
 Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h)
     : key_(k, kSz)
 {
-        size_t sz = strlen(n);
-        memcpy(name_, n, sz);
-        name_[sz] = 0;
+    size_t sz = strlen(n);
+    memcpy(name_, n, sz);
+    name_[sz] = 0;
 
     memcpy(hash_, h, SHA::DIGEST_SIZE);
 }
@@ -364,12 +367,59 @@
     ReadHeader();
     if (source_.GetError().What()) return;
 
+    ReadHeaderOpenSSL();   // may or may not be
+    if (source_.GetError().What()) return;
+
     // public key
     key.SetModulus(GetInteger(Integer().Ref()));
     key.SetPublicExponent(GetInteger(Integer().Ref()));
 }
 
 
+// Read OpenSSL format public header
+void RSA_Public_Decoder::ReadHeaderOpenSSL()
+{
+    byte b = source_.next();  // peek
+    source_.prev();
+
+    if (b != INTEGER) { // have OpenSSL public format
+        GetSequence();
+        b = source_.next();
+        if (b != OBJECT_IDENTIFIER) {
+            source_.SetError(OBJECT_ID_E);
+            return;
+        }
+
+        word32 len = GetLength(source_);
+        source_.advance(len);
+
+        b = source_.next();
+        if (b == TAG_NULL) {   // could have NULL tag and 0 terminator, may not 
+            b = source_.next();
+            if (b != 0) {
+                source_.SetError(EXPECT_0_E);
+                return; 
+            }
+        }
+        else
+            source_.prev();   // put back
+
+        b = source_.next();
+        if (b != BIT_STRING) {   
+            source_.SetError(BIT_STR_E);
+            return; 
+        }
+
+        len = GetLength(source_); 
+        b = source_.next();
+        if (b != 0)           // could have 0
+            source_.prev();   // put back
+        
+        GetSequence();
+    }
+}
+
+
 void RSA_Public_Decoder::ReadHeader()
 {
     GetSequence();
@@ -420,12 +470,12 @@
                          bool noVerify, CertType ct)
     : BER_Decoder(s), certBegin_(0), sigIndex_(0), sigLength_(0),
       signature_(0), verify_(!noVerify)
-{ 
+{
     issuer_[0] = 0;
     subject_[0] = 0;
 
     if (decode)
-        Decode(signers, ct); 
+        Decode(signers, ct);
 
 }
 
@@ -470,9 +520,9 @@
         source_.SetError(SIG_OID_E);
         return;
     }
-
+    
     if (ct != CA && verify_ && !ValidateSignature(signers))
-            source_.SetError(SIG_OTHER_E);
+        source_.SetError(SIG_OTHER_E);
 }
 
 
@@ -530,8 +580,10 @@
     read = source_.get_index() - read;
     length += read;
 
+    if (source_.GetError().What()) return;
     while (read--) source_.prev();
 
+    if (source_.IsLeft(length) == false) return;
     key_.SetSize(length);
     key_.SetKey(source_.get_current());
     source_.advance(length);
@@ -563,6 +615,8 @@
     word32 length = GetLength(source_);
     length += source_.get_index() - idx;
 
+    if (source_.IsLeft(length) == false) return;
+
     key_.AddToEnd(source_.get_buffer() + idx, length);    
 }
 
@@ -572,6 +626,8 @@
 {
     if (source_.GetError().What()) return 0;
     word32 length = GetSequence();
+
+    if (source_.GetError().What()) return 0;
     
     byte b = source_.next();
     if (b != OBJECT_IDENTIFIER) {
@@ -580,26 +636,25 @@
     }
 
     length = GetLength(source_);
+    if (source_.IsLeft(length) == false) return 0;
+
     word32 oid = 0;
-    
     while(length--)
         oid += source_.next();        // just sum it up for now
 
-    if (oid != SHAwDSA && oid != DSAk) {
-        b = source_.next();               // should have NULL tag and 0
-
-        if (b != TAG_NULL) {
-            source_.SetError(TAG_NULL_E);
-            return 0;
-        }
-
+    // could have NULL tag and 0 terminator, but may not
+    b = source_.next();
+    if (b == TAG_NULL) {
         b = source_.next();
         if (b != 0) {
             source_.SetError(EXPECT_0_E);
             return 0;
         }
     }
- 
+    else
+        // go back, didn't have it
+        b = source_.prev();
+
     return oid;
 }
 
@@ -616,6 +671,10 @@
     }
 
     sigLength_ = GetLength(source_);
+    if (sigLength_ == 0 || source_.IsLeft(sigLength_) == false) {
+        source_.SetError(CONTENT_E);
+        return 0;
+    }
   
     b = source_.next();
     if (b != 0) {
@@ -653,20 +712,22 @@
 }
 
 
-char *CertDecoder::AddTag(char *ptr, const char *buf_end, 
-                          const char *tag_name, word32 tag_name_length,
-                          word32 tag_value_length)
+// memory length checked add tag to buffer
+char* CertDecoder::AddTag(char* ptr, const char* buf_end, const char* tag_name,
+                          word32 tag_name_length, word32 tag_value_length)
 {
-  if (ptr + tag_name_length + tag_value_length > buf_end)
-      return 0;
-    
-  memcpy(ptr, tag_name, tag_name_length);
-  ptr+= tag_name_length;
-  
-  memcpy(ptr, source_.get_current(), tag_value_length);
-  ptr+= tag_value_length;
-  
-  return ptr;
+    if (ptr + tag_name_length + tag_value_length > buf_end) {
+        source_.SetError(CONTENT_E);
+        return 0;
+    }
+
+    memcpy(ptr, tag_name, tag_name_length);
+    ptr += tag_name_length;
+
+    memcpy(ptr, source_.get_current(), tag_value_length);
+    ptr += tag_value_length;
+
+    return ptr;
 }
 
 
@@ -679,18 +740,20 @@
     word32 length = GetSequence();  // length of all distinguished names
 
     if (length >= ASN_NAME_MAX)
-        goto err;
+        return;
+    if (source_.IsLeft(length) == false) return;
     length += source_.get_index();
-
-    char *ptr, *buf_end;
+    
+    char* ptr;
+    char* buf_end;
 
     if (nt == ISSUER) {
-        ptr= issuer_;
-        buf_end= ptr + sizeof(issuer_) - 1;  // 1 byte for trailing 0
+        ptr = issuer_;
+        buf_end = ptr + sizeof(issuer_) - 1;   // 1 byte for trailing 0
     }
     else {
-        ptr= subject_;
-        buf_end= ptr + sizeof(subject_) - 1;  // 1 byte for trailing 0
+        ptr = subject_;
+        buf_end = ptr + sizeof(subject_) - 1;  // 1 byte for trailing 0
     }
 
     while (source_.get_index() < length) {
@@ -704,7 +767,10 @@
         }
 
         word32 oidSz = GetLength(source_);
+        if (source_.IsLeft(oidSz) == false) return;
+
         byte joint[2];
+        if (source_.IsLeft(sizeof(joint)) == false) return;
         memcpy(joint, source_.get_current(), sizeof(joint));
 
         // v1 name types
@@ -714,62 +780,68 @@
             b              = source_.next();    // strType
             word32 strLen  = GetLength(source_);
 
+            if (source_.IsLeft(strLen) == false) return;
+
             switch (id) {
             case COMMON_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/CN=", 4, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/CN=", 4, strLen)))
+                    return;
                 break;
             case SUR_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/SN=", 4, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/SN=", 4, strLen)))
+                    return;
                 break;
             case COUNTRY_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/C=", 3, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/C=", 3, strLen)))
+                    return;
                 break;
             case LOCALITY_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/L=", 3, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/L=", 3, strLen)))
+                    return;
                 break;
             case STATE_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/ST=", 4, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/ST=", 4, strLen)))
+                    return;
                 break;
             case ORG_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/O=", 3, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/O=", 3, strLen)))
+                    return;
                 break;
             case ORGUNIT_NAME:
-                if (!(ptr= AddTag(ptr, buf_end, "/OU=", 4, strLen)))
-                  goto err;
+                if (!(ptr = AddTag(ptr, buf_end, "/OU=", 4, strLen)))
+                    return;
                 break;
             }
 
             sha.Update(source_.get_current(), strLen);
             source_.advance(strLen);
         }
-        else {
+        else { 
             bool email = false;
             if (joint[0] == 0x2a && joint[1] == 0x86)  // email id hdr
                 email = true;
 
             source_.advance(oidSz + 1);
             word32 length = GetLength(source_);
+            if (source_.IsLeft(length) == false) return;
 
-            if (email && !(ptr= AddTag(ptr, buf_end, "/emailAddress=", 14, length)))
-                goto err;
+            if (email) {
+                if (!(ptr = AddTag(ptr, buf_end, "/emailAddress=", 14, length))) {
+                    source_.SetError(CONTENT_E);
+                    return; 
+                }
+            }
 
             source_.advance(length);
         }
     }
-    *ptr= 0;
-
-    sha.Final(nt == ISSUER ? issuerHash_ : subjectHash_);
-        
-    return;
-    
-err:
-    source_.SetError(CONTENT_E);
+
+    *ptr = 0;
+
+    if (nt == ISSUER)
+        sha.Final(issuerHash_);
+    else
+        sha.Final(subjectHash_);
 }
 
 
@@ -785,6 +857,8 @@
     }
 
     word32 length = GetLength(source_);
+    if (source_.IsLeft(length) == false) return;
+
     byte date[MAX_DATE_SZ];
     if (length > MAX_DATE_SZ || length < MIN_DATE_SZ) {
         source_.SetError(DATE_SZ_E);
@@ -794,8 +868,7 @@
     memcpy(date, source_.get_current(), length);
     source_.advance(length);
 
-    if (!ValidateDate(date, b, dt) && verify_)
-    {
+    if (!ValidateDate(date, b, dt) && verify_) {
         if (dt == BEFORE)
             source_.SetError(BEFORE_DATE_E);
         else
@@ -856,7 +929,8 @@
 // validate signature signed by someone else
 bool CertDecoder::ValidateSignature(SignerList* signers)
 {
-    assert(signers);
+    if (!signers)
+        return false;
 
     SignerList::iterator first = signers->begin();
     SignerList::iterator last  = signers->end();
@@ -1077,8 +1151,7 @@
         return 0;
     }
     word32 rLen = GetLength(source);
-    if (rLen != 20)
-    {
+    if (rLen != 20) {
         if (rLen == 21) {       // zero at front, eat
             source.next();
             --rLen;
@@ -1101,8 +1174,7 @@
         return 0;
     }
     word32 sLen = GetLength(source);
-    if (sLen != 20)
-    {
+    if (sLen != 20) {
         if (sLen == 21) {
             source.next();          // zero at front, eat
             --sLen;
@@ -1123,6 +1195,7 @@
 }
 
 
+/*
 // Get Cert in PEM format from BEGIN to END
 int GetCert(Source& source)
 {
@@ -1174,12 +1247,10 @@
 
 
     // Get MacData optional
-    /*
-    mac     digestInfo  like certdecoder::getdigest?
-    macsalt octet string
-    iter    integer
+    // mac     digestInfo  like certdecoder::getdigest?
+    // macsalt octet string
+    // iter    integer
     
-    */
 }
 
 
@@ -1199,6 +1270,7 @@
 
     return 0;
 }
+*/
 
 
 

=== modified file 'extra/yassl/taocrypt/src/blowfish.cpp'
--- a/extra/yassl/taocrypt/src/blowfish.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/blowfish.cpp	2012-04-07 13:58:46 +0000
@@ -87,7 +87,10 @@
 
 void Blowfish::SetKey(const byte* key_string, word32 keylength, CipherDir dir)
 {
-	assert(keylength >= 4 && keylength <= 56);
+    if (keylength < 4)
+        keylength = 4;
+    else if (keylength > 56)
+        keylength = 56;
 
 	unsigned i, j=0, k;
 	word32 data, dspace[2] = {0, 0};
@@ -166,16 +169,21 @@
 	word32 left  = in[0];
 	word32 right = in[1];
 
+	const word32  *const s = sbox_;
 	const word32* p = pbox_;
-    word32 tmp;
 
 	left ^= p[0];
 
-    BF_ROUNDS
+    // roll back up and use s and p index instead of just p
+    for (unsigned i = 0; i < ROUNDS / 2; i++) {
+        right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
+            ^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
+            ^ p[2*i+1];
 
-#if ROUNDS == 20
-    BF_EXTRA_ROUNDS
-#endif
+        left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
+            ^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
+            ^ p[2*i+2];
+    }
 
 	right ^= p[ROUNDS + 1];
 
@@ -189,17 +197,23 @@
 void Blowfish::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out)
     const
 {
-    word32 tmp, left, right;
+    word32 left, right;
+	const word32  *const s = sbox_;
     const word32* p = pbox_;
     
     gpBlock::Get(in)(left)(right);
 	left ^= p[0];
 
-    BF_ROUNDS
+    // roll back up and use s and p index instead of just p
+    for (unsigned i = 0; i < ROUNDS / 2; i++) {
+        right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
+            ^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
+            ^ p[2*i+1];
 
-#if ROUNDS == 20
-    BF_EXTRA_ROUNDS
-#endif
+        left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
+            ^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
+            ^ p[2*i+2];
+    }
 
 	right ^= p[ROUNDS + 1];
 

=== modified file 'extra/yassl/taocrypt/src/coding.cpp'
--- a/extra/yassl/taocrypt/src/coding.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/coding.cpp	2012-04-07 13:58:46 +0000
@@ -95,7 +95,6 @@
 void HexDecoder::Decode()
 {
     word32 bytes = coded_.size();
-    assert((bytes % 2) == 0);
     decoded_.New(bytes / 2);
 
     word32 i(0);
@@ -104,15 +103,9 @@
         byte b  = coded_.next() - 0x30;  // 0 starts at 0x30
         byte b2 = coded_.next() - 0x30;
 
-        // sanity checks
-        assert( b  < sizeof(hexDecode)/sizeof(hexDecode[0]) );
-        assert( b2 < sizeof(hexDecode)/sizeof(hexDecode[0]) );
-
         b  = hexDecode[b];
         b2 = hexDecode[b2];
-        
-        assert( b != bad && b2 != bad );
-        
+
         decoded_[i++] = (b << 4) | b2;
         bytes -= 2;
     }
@@ -174,9 +167,9 @@
     } 
 
     encoded_[i++] = '\n';
-    assert(i == outSz);
-
-    plain_.reset(encoded_);
+    
+    if (i == outSz)
+        plain_.reset(encoded_);
 }
 
 
@@ -197,7 +190,6 @@
         byte e3 = coded_.next();
         byte e4 = coded_.next();
 
-        // do asserts first
         if (e1 == 0)            // end file 0's
             break;
 

=== modified file 'extra/yassl/taocrypt/src/dsa.cpp'
--- a/extra/yassl/taocrypt/src/dsa.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/dsa.cpp	2012-02-10 14:33:27 +0000
@@ -183,7 +183,8 @@
     Integer kInv = k.InverseMod(q);
     s_ = (kInv * (H + x*r_)) % q;
 
-    assert(!!r_ && !!s_);
+    if (!(!!r_ && !!s_))
+        return -1;
 
     int rSz = r_.ByteCount();
 

=== modified file 'extra/yassl/taocrypt/src/hash.cpp'
--- a/extra/yassl/taocrypt/src/hash.cpp	2007-03-23 10:52:25 +0000
+++ b/extra/yassl/taocrypt/src/hash.cpp	2012-02-10 14:33:27 +0000
@@ -21,7 +21,6 @@
 
 #include "runtime.hpp"
 #include <string.h>
-#include <assert.h>
 
 #include "hash.hpp"
 
@@ -31,8 +30,6 @@
 
 HASHwithTransform::HASHwithTransform(word32 digSz, word32 buffSz)
 {
-    assert(digSz  <= MaxDigestSz);
-    assert(buffSz <= MaxBufferSz);
 }
 
 
@@ -73,15 +70,15 @@
 // Final process, place digest in hash
 void HASHwithTransform::Final(byte* hash)
 {
-    word32    blockSz   = getBlockSize();
-    word32    digestSz  = getDigestSize();
-    word32    padSz     = getPadSize();
-    ByteOrder order     = getByteOrder();
+    word32    blockSz  = getBlockSize();
+    word32    digestSz = getDigestSize();
+    word32    padSz    = getPadSize();
+    ByteOrder order    = getByteOrder();
 
     AddLength(buffLen_);                        // before adding pads
     HashLengthType preLoLen = GetBitCountLo();
     HashLengthType preHiLen = GetBitCountHi();
-    byte*     local     = reinterpret_cast<byte*>(buffer_);
+    byte*     local         = reinterpret_cast<byte*>(buffer_);
 
     local[buffLen_++] = 0x80;  // add 1
 
@@ -95,7 +92,7 @@
         buffLen_ = 0;
     }
     memset(&local[buffLen_], 0, padSz - buffLen_);
-
+   
     ByteReverseIf(local, local, blockSz, order);
     
     memcpy(&local[padSz],   order ? &preHiLen : &preLoLen, sizeof(preLoLen));
@@ -113,8 +110,6 @@
 
 HASH64withTransform::HASH64withTransform(word32 digSz, word32 buffSz)
 {
-    assert(digSz  <= MaxDigestSz);
-    assert(buffSz <= MaxBufferSz);
 }
 
 

=== added file 'extra/yassl/taocrypt/src/hc128.cpp'
--- a/extra/yassl/taocrypt/src/hc128.cpp	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/taocrypt/src/hc128.cpp	2012-02-10 14:33:27 +0000
@@ -0,0 +1,317 @@
+/*
+   Copyright (c) 2005, 2010, 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; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+   MA  02110-1301  USA.
+*/
+
+
+#include "runtime.hpp"
+#include "hc128.hpp"
+
+
+
+namespace TaoCrypt {
+
+
+
+
+#ifdef BIG_ENDIAN_ORDER
+    #define LITTLE32(x) ByteReverse((word32)x)
+#else
+    #define LITTLE32(x) (x)
+#endif
+
+
+/*h1 function*/
+#define h1(x, y) {                              \
+     byte a,c;                                  \
+     a = (byte) (x);                            \
+     c = (byte) ((x) >> 16);                    \
+     y = (T_[512+a])+(T_[512+256+c]);           \
+}
+
+/*h2 function*/
+#define h2(x, y) {                              \
+     byte a,c;                                  \
+     a = (byte) (x);                            \
+     c = (byte) ((x) >> 16);                    \
+     y = (T_[a])+(T_[256+c]);                   \
+}
+
+/*one step of HC-128, update P and generate 32 bits keystream*/
+#define step_P(u,v,a,b,c,d,n){                  \
+     word32 tem0,tem1,tem2,tem3;                \
+     h1((X_[(d)]),tem3);                        \
+     tem0 = rotrFixed((T_[(v)]),23);            \
+     tem1 = rotrFixed((X_[(c)]),10);            \
+     tem2 = rotrFixed((X_[(b)]),8);             \
+     (T_[(u)]) += tem2+(tem0 ^ tem1);           \
+     (X_[(a)]) = (T_[(u)]);                     \
+     (n) = tem3 ^ (T_[(u)]) ;                   \
+}       
+
+/*one step of HC-128, update Q and generate 32 bits keystream*/
+#define step_Q(u,v,a,b,c,d,n){                  \
+     word32 tem0,tem1,tem2,tem3;                \
+     h2((Y_[(d)]),tem3);                        \
+     tem0 = rotrFixed((T_[(v)]),(32-23));       \
+     tem1 = rotrFixed((Y_[(c)]),(32-10));       \
+     tem2 = rotrFixed((Y_[(b)]),(32-8));        \
+     (T_[(u)]) += tem2 + (tem0 ^ tem1);         \
+     (Y_[(a)]) = (T_[(u)]);                     \
+     (n) = tem3 ^ (T_[(u)]) ;                   \
+}   
+
+
+/*16 steps of HC-128, generate 512 bits keystream*/
+void HC128::GenerateKeystream(word32* keystream)  
+{
+   word32 cc,dd;
+   cc = counter1024_ & 0x1ff;
+   dd = (cc+16)&0x1ff;
+
+   if (counter1024_ < 512)	
+   {   		
+      counter1024_ = (counter1024_ + 16) & 0x3ff;
+      step_P(cc+0, cc+1, 0, 6, 13,4, keystream[0]);
+      step_P(cc+1, cc+2, 1, 7, 14,5, keystream[1]);
+      step_P(cc+2, cc+3, 2, 8, 15,6, keystream[2]);
+      step_P(cc+3, cc+4, 3, 9, 0, 7, keystream[3]);
+      step_P(cc+4, cc+5, 4, 10,1, 8, keystream[4]);
+      step_P(cc+5, cc+6, 5, 11,2, 9, keystream[5]);
+      step_P(cc+6, cc+7, 6, 12,3, 10,keystream[6]);
+      step_P(cc+7, cc+8, 7, 13,4, 11,keystream[7]);
+      step_P(cc+8, cc+9, 8, 14,5, 12,keystream[8]);
+      step_P(cc+9, cc+10,9, 15,6, 13,keystream[9]);
+      step_P(cc+10,cc+11,10,0, 7, 14,keystream[10]);
+      step_P(cc+11,cc+12,11,1, 8, 15,keystream[11]);
+      step_P(cc+12,cc+13,12,2, 9, 0, keystream[12]);
+      step_P(cc+13,cc+14,13,3, 10,1, keystream[13]);
+      step_P(cc+14,cc+15,14,4, 11,2, keystream[14]);
+      step_P(cc+15,dd+0, 15,5, 12,3, keystream[15]);
+   }
+   else				    
+   {
+	  counter1024_ = (counter1024_ + 16) & 0x3ff;
+      step_Q(512+cc+0, 512+cc+1, 0, 6, 13,4, keystream[0]);
+      step_Q(512+cc+1, 512+cc+2, 1, 7, 14,5, keystream[1]);
+      step_Q(512+cc+2, 512+cc+3, 2, 8, 15,6, keystream[2]);
+      step_Q(512+cc+3, 512+cc+4, 3, 9, 0, 7, keystream[3]);
+      step_Q(512+cc+4, 512+cc+5, 4, 10,1, 8, keystream[4]);
+      step_Q(512+cc+5, 512+cc+6, 5, 11,2, 9, keystream[5]);
+      step_Q(512+cc+6, 512+cc+7, 6, 12,3, 10,keystream[6]);
+      step_Q(512+cc+7, 512+cc+8, 7, 13,4, 11,keystream[7]);
+      step_Q(512+cc+8, 512+cc+9, 8, 14,5, 12,keystream[8]);
+      step_Q(512+cc+9, 512+cc+10,9, 15,6, 13,keystream[9]);
+      step_Q(512+cc+10,512+cc+11,10,0, 7, 14,keystream[10]);
+      step_Q(512+cc+11,512+cc+12,11,1, 8, 15,keystream[11]);
+      step_Q(512+cc+12,512+cc+13,12,2, 9, 0, keystream[12]);
+      step_Q(512+cc+13,512+cc+14,13,3, 10,1, keystream[13]);
+      step_Q(512+cc+14,512+cc+15,14,4, 11,2, keystream[14]);
+      step_Q(512+cc+15,512+dd+0, 15,5, 12,3, keystream[15]);
+   }
+}
+
+
+/* The following defines the initialization functions */
+#define f1(x)  (rotrFixed((x),7)  ^ rotrFixed((x),18) ^ ((x) >> 3))
+#define f2(x)  (rotrFixed((x),17) ^ rotrFixed((x),19) ^ ((x) >> 10))
+
+/*update table P*/
+#define update_P(u,v,a,b,c,d){                      \
+     word32 tem0,tem1,tem2,tem3;                    \
+     tem0 = rotrFixed((T_[(v)]),23);                \
+     tem1 = rotrFixed((X_[(c)]),10);                \
+     tem2 = rotrFixed((X_[(b)]),8);                 \
+     h1((X_[(d)]),tem3);                            \
+     (T_[(u)]) = ((T_[(u)]) + tem2+(tem0^tem1)) ^ tem3;     \
+     (X_[(a)]) = (T_[(u)]);                         \
+}  
+
+/*update table Q*/
+#define update_Q(u,v,a,b,c,d){                      \
+     word32 tem0,tem1,tem2,tem3;                    \
+     tem0 = rotrFixed((T_[(v)]),(32-23));           \
+     tem1 = rotrFixed((Y_[(c)]),(32-10));           \
+     tem2 = rotrFixed((Y_[(b)]),(32-8));            \
+     h2((Y_[(d)]),tem3);                            \
+     (T_[(u)]) = ((T_[(u)]) + tem2+(tem0^tem1)) ^ tem3;     \
+     (Y_[(a)]) = (T_[(u)]);                         \
+}     
+
+/*16 steps of HC-128, without generating keystream, */
+/*but use the outputs to update P and Q*/
+void HC128::SetupUpdate()  /*each time 16 steps*/
+{
+   word32 cc,dd;
+   cc = counter1024_ & 0x1ff;
+   dd = (cc+16)&0x1ff;
+
+   if (counter1024_ < 512)	
+   {   		
+      counter1024_ = (counter1024_ + 16) & 0x3ff;
+      update_P(cc+0, cc+1, 0, 6, 13, 4);
+      update_P(cc+1, cc+2, 1, 7, 14, 5);
+      update_P(cc+2, cc+3, 2, 8, 15, 6);
+      update_P(cc+3, cc+4, 3, 9, 0,  7);
+      update_P(cc+4, cc+5, 4, 10,1,  8);
+      update_P(cc+5, cc+6, 5, 11,2,  9);
+      update_P(cc+6, cc+7, 6, 12,3,  10);
+      update_P(cc+7, cc+8, 7, 13,4,  11);
+      update_P(cc+8, cc+9, 8, 14,5,  12);
+      update_P(cc+9, cc+10,9, 15,6,  13);
+      update_P(cc+10,cc+11,10,0, 7,  14);
+      update_P(cc+11,cc+12,11,1, 8,  15);
+      update_P(cc+12,cc+13,12,2, 9,  0);
+      update_P(cc+13,cc+14,13,3, 10, 1);
+      update_P(cc+14,cc+15,14,4, 11, 2);
+      update_P(cc+15,dd+0, 15,5, 12, 3);   
+   }
+   else				    
+   {
+      counter1024_ = (counter1024_ + 16) & 0x3ff;
+      update_Q(512+cc+0, 512+cc+1, 0, 6, 13, 4);
+      update_Q(512+cc+1, 512+cc+2, 1, 7, 14, 5);
+      update_Q(512+cc+2, 512+cc+3, 2, 8, 15, 6);
+      update_Q(512+cc+3, 512+cc+4, 3, 9, 0,  7);
+      update_Q(512+cc+4, 512+cc+5, 4, 10,1,  8);
+      update_Q(512+cc+5, 512+cc+6, 5, 11,2,  9);
+      update_Q(512+cc+6, 512+cc+7, 6, 12,3,  10);
+      update_Q(512+cc+7, 512+cc+8, 7, 13,4,  11);
+      update_Q(512+cc+8, 512+cc+9, 8, 14,5,  12);
+      update_Q(512+cc+9, 512+cc+10,9, 15,6,  13);
+      update_Q(512+cc+10,512+cc+11,10,0, 7,  14);
+      update_Q(512+cc+11,512+cc+12,11,1, 8,  15);
+      update_Q(512+cc+12,512+cc+13,12,2, 9,  0);
+      update_Q(512+cc+13,512+cc+14,13,3, 10, 1);
+      update_Q(512+cc+14,512+cc+15,14,4, 11, 2);
+      update_Q(512+cc+15,512+dd+0, 15,5, 12, 3); 
+   }       
+}
+
+
+/* for the 128-bit key:  key[0]...key[15]
+*  key[0] is the least significant byte of ctx->key[0] (K_0);
+*  key[3] is the most significant byte of ctx->key[0]  (K_0);
+*  ...
+*  key[12] is the least significant byte of ctx->key[3] (K_3)
+*  key[15] is the most significant byte of ctx->key[3]  (K_3)
+*
+*  for the 128-bit iv:  iv[0]...iv[15]
+*  iv[0] is the least significant byte of ctx->iv[0] (IV_0);
+*  iv[3] is the most significant byte of ctx->iv[0]  (IV_0);
+*  ...
+*  iv[12] is the least significant byte of ctx->iv[3] (IV_3)
+*  iv[15] is the most significant byte of ctx->iv[3]  (IV_3)
+*/
+
+
+
+void HC128::SetIV(const byte* iv)
+{ 
+    word32 i;
+	
+	for (i = 0; i < (128 >> 5); i++)
+        iv_[i] = LITTLE32(((word32*)iv)[i]);
+	
+    for (; i < 8; i++) iv_[i] = iv_[i-4];
+  
+    /* expand the key and IV into the table T */ 
+    /* (expand the key and IV into the table P and Q) */ 
+	
+	for (i = 0; i < 8;  i++)   T_[i] = key_[i];
+	for (i = 8; i < 16; i++)   T_[i] = iv_[i-8];
+
+    for (i = 16; i < (256+16); i++) 
+		T_[i] = f2(T_[i-2]) + T_[i-7] + f1(T_[i-15]) + T_[i-16]+i;
+    
+	for (i = 0; i < 16;  i++)  T_[i] = T_[256+i];
+
+	for (i = 16; i < 1024; i++) 
+		T_[i] = f2(T_[i-2]) + T_[i-7] + f1(T_[i-15]) + T_[i-16]+256+i;
+    
+    /* initialize counter1024, X and Y */
+	counter1024_ = 0;
+	for (i = 0; i < 16; i++) X_[i] = T_[512-16+i];
+    for (i = 0; i < 16; i++) Y_[i] = T_[512+512-16+i];
+    
+    /* run the cipher 1024 steps before generating the output */
+	for (i = 0; i < 64; i++)  SetupUpdate();  
+}
+
+
+void HC128::SetKey(const byte* key, const byte* iv)
+{ 
+  word32 i;  
+
+  /* Key size in bits 128 */ 
+  for (i = 0; i < (128 >> 5); i++)
+      key_[i] = LITTLE32(((word32*)key)[i]);
+ 
+  for ( ; i < 8 ; i++) key_[i] = key_[i-4];
+
+  SetIV(iv);
+}
+
+
+/* The following defines the encryption of data stream */
+void HC128::Process(byte* output, const byte* input, word32 msglen)
+{
+  word32 i, keystream[16];
+
+  for ( ; msglen >= 64; msglen -= 64, input += 64, output += 64)
+  {
+	  GenerateKeystream(keystream);
+
+      /* unroll loop */
+	  ((word32*)output)[0]  = ((word32*)input)[0]  ^ LITTLE32(keystream[0]);
+	  ((word32*)output)[1]  = ((word32*)input)[1]  ^ LITTLE32(keystream[1]);
+	  ((word32*)output)[2]  = ((word32*)input)[2]  ^ LITTLE32(keystream[2]);
+	  ((word32*)output)[3]  = ((word32*)input)[3]  ^ LITTLE32(keystream[3]);
+	  ((word32*)output)[4]  = ((word32*)input)[4]  ^ LITTLE32(keystream[4]);
+	  ((word32*)output)[5]  = ((word32*)input)[5]  ^ LITTLE32(keystream[5]);
+	  ((word32*)output)[6]  = ((word32*)input)[6]  ^ LITTLE32(keystream[6]);
+	  ((word32*)output)[7]  = ((word32*)input)[7]  ^ LITTLE32(keystream[7]);
+	  ((word32*)output)[8]  = ((word32*)input)[8]  ^ LITTLE32(keystream[8]);
+	  ((word32*)output)[9]  = ((word32*)input)[9]  ^ LITTLE32(keystream[9]);
+	  ((word32*)output)[10] = ((word32*)input)[10] ^ LITTLE32(keystream[10]);
+	  ((word32*)output)[11] = ((word32*)input)[11] ^ LITTLE32(keystream[11]);
+	  ((word32*)output)[12] = ((word32*)input)[12] ^ LITTLE32(keystream[12]);
+	  ((word32*)output)[13] = ((word32*)input)[13] ^ LITTLE32(keystream[13]);
+	  ((word32*)output)[14] = ((word32*)input)[14] ^ LITTLE32(keystream[14]);
+	  ((word32*)output)[15] = ((word32*)input)[15] ^ LITTLE32(keystream[15]);
+  }
+
+  if (msglen > 0)
+  {
+      GenerateKeystream(keystream);
+
+#ifdef BIG_ENDIAN_ORDER
+      {
+          word32 wordsLeft = msglen / sizeof(word32);
+          if (msglen % sizeof(word32)) wordsLeft++;
+          
+          ByteReverse(keystream, keystream, wordsLeft * sizeof(word32));
+      }
+#endif
+
+      for (i = 0; i < msglen; i++)
+	      output[i] = input[i] ^ ((byte*)keystream)[i];
+  }
+
+}
+
+
+}  // namespace

=== modified file 'extra/yassl/taocrypt/src/integer.cpp'
--- a/extra/yassl/taocrypt/src/integer.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/integer.cpp	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005, 2010, Oracle and/or its affiliates
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates
 
    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
@@ -73,7 +73,8 @@
 CPP_TYPENAME AlignedAllocator<T>::pointer AlignedAllocator<T>::allocate(
                                            size_type n, const void *)
 {
-    CheckSize(n);
+    if (n > max_size())
+        return 0;
     if (n == 0)
         return 0;
     if (n >= 4)
@@ -91,16 +92,13 @@
     #endif
 
     #ifdef TAOCRYPT_NO_ALIGNED_ALLOC
-        assert(m_pBlock == 0);
         m_pBlock = p;
         if (!IsAlignedOn(p, 16))
         {
-            assert(IsAlignedOn(p, 8));
             p = (byte *)p + 8;
         }
     #endif
 
-        assert(IsAlignedOn(p, 16));
         return (T*)p;
     }
     return NEW_TC T[n];
@@ -116,7 +114,6 @@
         #ifdef TAOCRYPT_MM_MALLOC_AVAILABLE
             _mm_free(p);
         #elif defined(TAOCRYPT_NO_ALIGNED_ALLOC)
-            assert(m_pBlock == p || (byte*)m_pBlock+8 == p);
             free(m_pBlock);
             m_pBlock = 0;
         #else
@@ -284,14 +281,14 @@
 
 private:
     struct dword_struct
-    {
-    #ifdef LITTLE_ENDIAN_ORDER
-        word low;
-        word high;
-    #else
-        word high;
-        word low;
-    #endif
+        {
+        #ifdef LITTLE_ENDIAN_ORDER
+            word low;
+            word high;
+        #else
+            word high;
+            word low;
+        #endif
     };
 
     union
@@ -365,9 +362,6 @@
 template <class S, class D>
 S DivideThreeWordsByTwo(S* A, S B0, S B1, D* dummy_VC6_WorkAround = 0)
 {
-    // assert {A[2],A[1]} < {B1,B0}, so quotient can fit in a S
-    assert(A[2] < B1 || (A[2]==B1 && A[1] < B0));
-
     // estimate the quotient: do a 2 S by 1 S divide
     S Q;
     if (S(B1+1) == 0)
@@ -393,7 +387,6 @@
         A[1] = u.GetLowHalf();
         A[2] += u.GetHighHalf();
         Q++;
-        assert(Q);	// shouldn't overflow
     }
 
     return Q;
@@ -491,7 +484,6 @@
 
 static word Increment(word *A, unsigned int N, word B=1)
 {
-    assert(N);
     word t = A[0];
     A[0] = t+B;
     if (A[0] >= t)
@@ -504,7 +496,6 @@
 
 static word Decrement(word *A, unsigned int N, word B=1)
 {
-    assert(N);
     word t = A[0];
     A[0] = t-B;
     if (A[0] <= t)
@@ -538,14 +529,11 @@
 
 static word AtomicInverseModPower2(word A)
 {
-    assert(A%2==1);
-
     word R=A%8;
 
     for (unsigned i=3; i<WORD_BITS; i*=2)
         R = R*(2-R*A);
 
-    assert(word(R*A)==1);
     return R;
 }
 
@@ -576,14 +564,11 @@
 
     static void TAOCRYPT_CDECL Square2(word *R, const word *A);
     static void TAOCRYPT_CDECL Square4(word *R, const word *A);
-    static void TAOCRYPT_CDECL Square8(word *R, const word *A) {assert(false);}
     static unsigned int TAOCRYPT_CDECL SquareRecursionLimit() {return 4;}
 };
 
 word Portable::Add(word *C, const word *A, const word *B, unsigned int N)
 {
-    assert (N%2 == 0);
-
     DWord u(0, 0);
     for (unsigned int i = 0; i < N; i+=2)
     {
@@ -597,8 +582,6 @@
 
 word Portable::Subtract(word *C, const word *A, const word *B, unsigned int N)
 {
-    assert (N%2 == 0);
-
     DWord u(0, 0);
     for (unsigned int i = 0; i < N; i+=2)
     {
@@ -1013,7 +996,7 @@
     static jmp_buf s_env;
     static void SigIllHandler(int)
     {
-    longjmp(s_env, 1);
+        longjmp(s_env, 1);
     }
 #endif
 
@@ -2130,8 +2113,6 @@
 void RecursiveMultiply(word *R, word *T, const word *A, const word *B,
                        unsigned int N)
 {
-    assert(N>=2 && N%2==0);
-
     if (LowLevel::MultiplyRecursionLimit() >= 8 && N==8)
         LowLevel::Multiply8(R, A, B);
     else if (LowLevel::MultiplyRecursionLimit() >= 4 && N==4)
@@ -2188,7 +2169,6 @@
         carry += LowLevel::Add(T0, T0, R2, N);
         carry += LowLevel::Add(R1, R1, T0, N);
 
-        assert (carry >= 0 && carry <= 2);
         Increment(R3, N2, carry);
     }
 }
@@ -2196,9 +2176,6 @@
 
 void RecursiveSquare(word *R, word *T, const word *A, unsigned int N)                     
 {
-    assert(N && N%2==0);
-    if (LowLevel::SquareRecursionLimit() >= 8 && N==8)
-        LowLevel::Square8(R, A);
     if (LowLevel::SquareRecursionLimit() >= 4 && N==4)
         LowLevel::Square4(R, A);
     else if (N==2)
@@ -2227,7 +2204,6 @@
 void RecursiveMultiplyBottom(word *R, word *T, const word *A, const word *B,
                              unsigned int N)
 {
-    assert(N>=2 && N%2==0);
     if (LowLevel::MultiplyBottomRecursionLimit() >= 8 && N==8)
         LowLevel::Multiply8Bottom(R, A, B);
     else if (LowLevel::MultiplyBottomRecursionLimit() >= 4 && N==4)
@@ -2250,8 +2226,6 @@
 void RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A,
                           const word *B, unsigned int N)
 {
-    assert(N>=2 && N%2==0);
-
     if (N==4)
     {
         LowLevel::Multiply4(T, A, B);
@@ -2315,7 +2289,6 @@
         carry += Increment(R0, N2, c2+t);
         carry += LowLevel::Add(R0, R0, T1, N2);
         carry += LowLevel::Add(R0, R0, T3, N2);
-        assert (carry >= 0 && carry <= 2);
 
         CopyWords(R1, T3, N2);
         Increment(R1, N2, carry);
@@ -2364,9 +2337,6 @@
         STL::swap(NA, NB);
     }
 
-    assert(NB % NA == 0);
-    assert((NB/NA)%2 == 0); 	// NB is an even multiple of NA
-
     if (NA==2 && !A[1])
     {
         switch (A[0])
@@ -2433,8 +2403,6 @@
 unsigned int AlmostInverse(word *R, word *T, const word *A, unsigned int NA,
                            const word *M, unsigned int N)
 {
-    assert(NA<=N && N && N%2==0);
-
     word *b = T;
     word *c = T+N;
     word *f = T+2*N;
@@ -2460,7 +2428,6 @@
 
             ShiftWordsRightByWords(f, fgLen, 1);
             if (c[bcLen-1]) bcLen+=2;
-            assert(bcLen <= N);
             ShiftWordsLeftByWords(c, bcLen, 1);
             k+=WORD_BITS;
             t=f[0];
@@ -2489,7 +2456,6 @@
         {
             c[bcLen] = t;
             bcLen+=2;
-            assert(bcLen <= N);
         }
 
         if (f[fgLen-2]==0 && g[fgLen-2]==0 && f[fgLen-1]==0 && g[fgLen-1]==0)
@@ -2508,7 +2474,6 @@
         {
             b[bcLen] = 1;
             bcLen+=2;
-            assert(bcLen <= N);
         }
     }
 }
@@ -2622,11 +2587,14 @@
     }
 
     word32 length = GetLength(source);
+    if (length == 0 || source.GetError().What()) return;
 
     if ( (b = source.next()) == 0x00)
         length--;
     else
         source.prev();
+
+    if (source.IsLeft(length) == false) return;
  
     unsigned int words = (length + WORD_SIZE - 1) / WORD_SIZE;
     words = RoundupSize(words);
@@ -2741,8 +2709,6 @@
 void Integer::Randomize(RandomNumberGenerator& rng, const Integer& min,
                         const Integer& max)
 {
-    assert(min <= max);
-
     Integer range = max - min;
     const unsigned int nbits = range.BitCount();
 
@@ -2881,7 +2847,7 @@
     else
     {
         word borrow = Decrement(reg_.get_buffer(), reg_.size());
-        assert(!borrow);
+        (void)borrow;           // shut up compiler
         if (WordCount()==0)
             *this = Zero();
     }
@@ -2998,7 +2964,6 @@
                                b.reg_.get_buffer(), bSize);
         CopyWords(diff.reg_+bSize, a.reg_+bSize, aSize-bSize);
         borrow = Decrement(diff.reg_+bSize, aSize-bSize, borrow);
-        assert(!borrow);
         diff.sign_ = Integer::POSITIVE;
     }
     else
@@ -3007,7 +2972,6 @@
                                a.reg_.get_buffer(), aSize);
         CopyWords(diff.reg_+aSize, b.reg_+aSize, bSize-aSize);
         borrow = Decrement(diff.reg_+aSize, bSize-aSize, borrow);
-        assert(!borrow);
         diff.sign_ = Integer::NEGATIVE;
     }
 }
@@ -3067,7 +3031,6 @@
 
 unsigned long Integer::GetBits(unsigned int i, unsigned int n) const
 {
-    assert(n <= sizeof(unsigned long)*8);
     unsigned long v = 0;
     for (unsigned int j=0; j<n; j++)
         v |= GetBit(i+j) << j;
@@ -3127,8 +3090,6 @@
 
 signed long Integer::ConvertToLong() const
 {
-    assert(IsConvertableToLong());
-
     unsigned long value = reg_[0];
     value += SafeLeftShift<WORD_BITS, unsigned long>(reg_[1]);
     return sign_ == POSITIVE ? value : -(signed long)value;
@@ -3227,11 +3188,9 @@
     {
         // multiply quotient and divisor and add remainder, make sure it 
         // equals dividend
-        assert(!T[2] && !T[3] && (T[1] < B[1] || (T[1]==B[1] && T[0]<B[0])));
         word P[4];
         Portable::Multiply2(P, Q, B);
         Add(P, P, T, 4);
-        assert(memcmp(P, A, 4*WORD_SIZE)==0);
     }
 #endif
 }
@@ -3241,8 +3200,6 @@
 static void CorrectQuotientEstimate(word *R, word *T, word *Q, const word *B,
                                     unsigned int N)
 {
-    assert(N && N%2==0);
-
     if (Q[1])
     {
         T[N] = T[N+1] = 0;
@@ -3260,13 +3217,12 @@
     }
 
     word borrow = Subtract(R, R, T, N+2);
-    assert(!borrow && !R[N+1]);
+    (void)borrow;       // shut up compiler
 
     while (R[N] || Compare(R, B, N) >= 0)
     {
         R[N] -= Subtract(R, R, B, N);
         Q[1] += (++Q[0]==0);
-        assert(Q[0] || Q[1]); // no overflow
     }
 }
 
@@ -3280,10 +3236,6 @@
 void Divide(word* R, word* Q, word* T, const word* A, unsigned int NA,
             const word* B, unsigned int NB)
 {
-    assert(NA && NB && NA%2==0 && NB%2==0);
-    assert(B[NB-1] || B[NB-2]);
-    assert(NB <= NA);
-
     // set up temporary work space
     word *const TA=T;
     word *const TB=T+NA+2;
@@ -3294,7 +3246,6 @@
     TB[0] = TB[NB-1] = 0;
     CopyWords(TB+shiftWords, B, NB-shiftWords);
     unsigned shiftBits = WORD_BITS - BitPrecision(TB[NB-1]);
-    assert(shiftBits < WORD_BITS);
     ShiftWordsLeftByBits(TB, NB, shiftBits);
 
     // copy A into TA and normalize it
@@ -3314,7 +3265,6 @@
     else
     {
         NA+=2;
-        assert(Compare(TA+NA-NB, TB, NB) < 0);
     }
 
     word BT[2];
@@ -3340,8 +3290,6 @@
     unsigned aSize = a.WordCount();
     unsigned bSize = b.WordCount();
 
-    assert(bSize);
-
     if (a.PositiveCompare(b) == -1)
     {
         remainder = a;
@@ -3429,8 +3377,6 @@
 void Integer::Divide(word &remainder, Integer &quotient,
                      const Integer &dividend, word divisor)
 {
-    assert(divisor);
-
     if ((divisor & (divisor-1)) == 0)	// divisor is a power of 2
     {
         quotient = dividend >> (BitPrecision(divisor)-1);
@@ -3470,8 +3416,6 @@
 
 word Integer::Modulo(word divisor) const
 {
-    assert(divisor);
-
     word remainder;
 
     if ((divisor & (divisor-1)) == 0)	// divisor is a power of 2
@@ -3517,7 +3461,6 @@
 
     // overestimate square root
     Integer x, y = Power2((BitCount()+1)/2);
-    assert(y*y >= *this);
 
     do
     {
@@ -3562,8 +3505,6 @@
 
 Integer Integer::InverseMod(const Integer &m) const
 {
-    assert(m.NotNegative());
-
     if (IsNegative() || *this>=m)
         return (*this%m).InverseMod(m);
 
@@ -3806,7 +3747,7 @@
     word borrow = Subtract(T, X+N, T, N);
     // defend against timing attack by doing this Add even when not needed
     word carry = Add(T+N, T, M, N);
-    assert(carry || !borrow);
+    (void)carry;            // shut up compiler
     CopyWords(R, T + (borrow ? N : 0), N);
 }
 
@@ -3862,7 +3803,6 @@
       u((word)0, modulus.reg_.size()),
       workspace(5*modulus.reg_.size())
 {
-    assert(modulus.IsOdd());
     RecursiveInverseModPower2(u.reg_.get_buffer(), workspace.get_buffer(),
                               modulus.reg_.get_buffer(), modulus.reg_.size());
 }
@@ -3873,7 +3813,6 @@
     word *const T = workspace.begin();
     word *const R = result.reg_.begin();
     const unsigned int N = modulus.reg_.size();
-    assert(a.reg_.size()<=N && b.reg_.size()<=N);
 
     AsymmetricMultiply(T, T+2*N, a.reg_.get_buffer(), a.reg_.size(),
                        b.reg_.get_buffer(), b.reg_.size());
@@ -3888,7 +3827,6 @@
     word *const T = workspace.begin();
     word *const R = result.reg_.begin();
     const unsigned int N = modulus.reg_.size();
-    assert(a.reg_.size()<=N);
 
     TaoCrypt::Square(T, T+2*N, a.reg_.get_buffer(), a.reg_.size());
     SetWords(T+2*a.reg_.size(), 0, 2*N-2*a.reg_.size());
@@ -3902,7 +3840,6 @@
     word *const T = workspace.begin();
     word *const R = result.reg_.begin();
     const unsigned int N = modulus.reg_.size();
-    assert(a.reg_.size()<=N);
 
     CopyWords(T, a.reg_.get_buffer(), a.reg_.size());
     SetWords(T+a.reg_.size(), 0, 2*N-a.reg_.size());
@@ -3919,7 +3856,6 @@
     word *const T = workspace.begin();
     word *const R = result.reg_.begin();
     const unsigned int N = modulus.reg_.size();
-    assert(a.reg_.size()<=N);
 
     CopyWords(T, a.reg_.get_buffer(), a.reg_.size());
     SetWords(T+a.reg_.size(), 0, 2*N-a.reg_.size());

=== modified file 'extra/yassl/taocrypt/src/make.bat' (properties changed: -x to +x)
=== modified file 'extra/yassl/taocrypt/src/md4.cpp'
--- a/extra/yassl/taocrypt/src/md4.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/md4.cpp	2012-02-10 14:33:27 +0000
@@ -27,7 +27,7 @@
     #include "algorithm.hpp"
 #endif
 
-   
+
 namespace STL = STL_NAMESPACE;
    
 

=== modified file 'extra/yassl/taocrypt/src/md5.cpp'
--- a/extra/yassl/taocrypt/src/md5.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/md5.cpp	2012-02-10 14:33:27 +0000
@@ -30,7 +30,7 @@
 
 namespace STL = STL_NAMESPACE;
 
-   
+
 
 namespace TaoCrypt {
 
@@ -108,14 +108,14 @@
 
     // at once for asm
     if (buffLen_ == 0) {
-            word32 times = len / BLOCK_SIZE;
-            if (times) {
-                AsmTransform(data, times);
-                const word32 add = BLOCK_SIZE * times;
-                AddLength(add);
-                len  -= add;
-                data += add;
-            }
+        word32 times = len / BLOCK_SIZE;
+        if (times) {
+            AsmTransform(data, times);
+            const word32 add = BLOCK_SIZE * times;
+            AddLength(add);
+            len  -= add;
+            data += add;
+        }
     }
 
     // cache any data left

=== modified file 'extra/yassl/taocrypt/src/misc.cpp'
--- a/extra/yassl/taocrypt/src/misc.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/misc.cpp	2012-04-07 13:58:46 +0000
@@ -41,28 +41,28 @@
 
     void* operator new(size_t sz, TaoCrypt::new_t)
     {
-    void* ptr = malloc(sz ? sz : 1);
-    if (!ptr) abort();
+        void* ptr = malloc(sz ? sz : 1);
+        if (!ptr) abort();
 
-    return ptr;
+        return ptr;
     }
 
 
     void operator delete(void* ptr, TaoCrypt::new_t)
     {
-    if (ptr) free(ptr);
+        if (ptr) free(ptr);
     }
 
 
     void* operator new[](size_t sz, TaoCrypt::new_t nt)
     {
-    return ::operator new(sz, nt);
+        return ::operator new(sz, nt);
     }
 
 
     void operator delete[](void* ptr, TaoCrypt::new_t nt)
     {
-    ::operator delete(ptr, nt);
+        ::operator delete(ptr, nt);
     }
 
 
@@ -89,7 +89,6 @@
 // Handler for pure virtual functions
 namespace __Crun {
     void pure_error() {
-      assert(!"Aborted: pure virtual method called.");
     }
 }
 
@@ -100,7 +99,6 @@
 extern "C" {
 
     int __cxa_pure_virtual() {
-      assert(!"Aborted: pure virtual method called.");
       return 0;
     }
 
@@ -205,8 +203,8 @@
     return true;
 #else
     word32 eax, ebx;
-        __asm__ __volatile
-        (
+    __asm__ __volatile
+    (
         /* Put EFLAGS in eax and ebx */
         "pushf;"
         "pushf;"
@@ -223,9 +221,9 @@
         "pop %0;"
         "popf"
         : "=r" (eax), "=r" (ebx)
-            :
+        :
         : "cc"
-        );
+    );
 
     if (eax == ebx)
         return false;

=== added file 'extra/yassl/taocrypt/src/rabbit.cpp'
--- a/extra/yassl/taocrypt/src/rabbit.cpp	1970-01-01 00:00:00 +0000
+++ b/extra/yassl/taocrypt/src/rabbit.cpp	2012-02-10 14:33:27 +0000
@@ -0,0 +1,250 @@
+/*
+   Copyright (c) 2005, 2010, 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; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+   MA  02110-1301  USA.
+*/
+
+
+#include "runtime.hpp"
+#include "rabbit.hpp"
+
+
+
+namespace TaoCrypt {
+
+
+#define U32V(x)  (word32)(x)
+
+
+#ifdef BIG_ENDIAN_ORDER
+    #define LITTLE32(x) ByteReverse((word32)x)
+#else
+    #define LITTLE32(x) (x)
+#endif
+
+
+// local
+namespace {
+
+
+/* Square a 32-bit unsigned integer to obtain the 64-bit result and return */
+/* the upper 32 bits XOR the lower 32 bits */
+word32 RABBIT_g_func(word32 x)
+{
+    /* Temporary variables */
+    word32 a, b, h, l;
+
+    /* Construct high and low argument for squaring */
+    a = x&0xFFFF;
+    b = x>>16;
+
+    /* Calculate high and low result of squaring */
+    h = (((U32V(a*a)>>17) + U32V(a*b))>>15) + b*b;
+    l = x*x;
+
+    /* Return high XOR low */
+    return U32V(h^l);
+}
+
+
+} // namespace local
+
+
+/* Calculate the next internal state */
+void Rabbit::NextState(RabbitCtx which)
+{
+    /* Temporary variables */
+    word32 g[8], c_old[8], i;
+
+    Ctx* ctx;
+
+    if (which == Master)
+        ctx = &masterCtx_;
+    else
+        ctx = &workCtx_;
+
+    /* Save old counter values */
+    for (i=0; i<8; i++)
+        c_old[i] = ctx->c[i];
+
+    /* Calculate new counter values */
+    ctx->c[0] = U32V(ctx->c[0] + 0x4D34D34D + ctx->carry);
+    ctx->c[1] = U32V(ctx->c[1] + 0xD34D34D3 + (ctx->c[0] < c_old[0]));
+    ctx->c[2] = U32V(ctx->c[2] + 0x34D34D34 + (ctx->c[1] < c_old[1]));
+    ctx->c[3] = U32V(ctx->c[3] + 0x4D34D34D + (ctx->c[2] < c_old[2]));
+    ctx->c[4] = U32V(ctx->c[4] + 0xD34D34D3 + (ctx->c[3] < c_old[3]));
+    ctx->c[5] = U32V(ctx->c[5] + 0x34D34D34 + (ctx->c[4] < c_old[4]));
+    ctx->c[6] = U32V(ctx->c[6] + 0x4D34D34D + (ctx->c[5] < c_old[5]));
+    ctx->c[7] = U32V(ctx->c[7] + 0xD34D34D3 + (ctx->c[6] < c_old[6]));
+    ctx->carry = (ctx->c[7] < c_old[7]);
+   
+    /* Calculate the g-values */
+    for (i=0;i<8;i++)
+        g[i] = RABBIT_g_func(U32V(ctx->x[i] + ctx->c[i]));
+
+    /* Calculate new state values */
+    ctx->x[0] = U32V(g[0] + rotlFixed(g[7],16) + rotlFixed(g[6], 16));
+    ctx->x[1] = U32V(g[1] + rotlFixed(g[0], 8) + g[7]);
+    ctx->x[2] = U32V(g[2] + rotlFixed(g[1],16) + rotlFixed(g[0], 16));
+    ctx->x[3] = U32V(g[3] + rotlFixed(g[2], 8) + g[1]);
+    ctx->x[4] = U32V(g[4] + rotlFixed(g[3],16) + rotlFixed(g[2], 16));
+    ctx->x[5] = U32V(g[5] + rotlFixed(g[4], 8) + g[3]);
+    ctx->x[6] = U32V(g[6] + rotlFixed(g[5],16) + rotlFixed(g[4], 16));
+    ctx->x[7] = U32V(g[7] + rotlFixed(g[6], 8) + g[5]);
+}
+
+
+/* IV setup */
+void Rabbit::SetIV(const byte* iv)
+{
+    /* Temporary variables */
+    word32 i0, i1, i2, i3, i;
+      
+    /* Generate four subvectors */
+    i0 = LITTLE32(*(word32*)(iv+0));
+    i2 = LITTLE32(*(word32*)(iv+4));
+    i1 = (i0>>16) | (i2&0xFFFF0000);
+    i3 = (i2<<16) | (i0&0x0000FFFF);
+
+    /* Modify counter values */
+    workCtx_.c[0] = masterCtx_.c[0] ^ i0;
+    workCtx_.c[1] = masterCtx_.c[1] ^ i1;
+    workCtx_.c[2] = masterCtx_.c[2] ^ i2;
+    workCtx_.c[3] = masterCtx_.c[3] ^ i3;
+    workCtx_.c[4] = masterCtx_.c[4] ^ i0;
+    workCtx_.c[5] = masterCtx_.c[5] ^ i1;
+    workCtx_.c[6] = masterCtx_.c[6] ^ i2;
+    workCtx_.c[7] = masterCtx_.c[7] ^ i3;
+
+    /* Copy state variables */
+    for (i=0; i<8; i++)
+        workCtx_.x[i] = masterCtx_.x[i];
+    workCtx_.carry = masterCtx_.carry;
+
+    /* Iterate the system four times */
+    for (i=0; i<4; i++)
+        NextState(Work);
+}
+
+
+/* Key setup */
+void Rabbit::SetKey(const byte* key, const byte* iv)
+{
+    /* Temporary variables */
+    word32 k0, k1, k2, k3, i;
+
+    /* Generate four subkeys */
+    k0 = LITTLE32(*(word32*)(key+ 0));
+    k1 = LITTLE32(*(word32*)(key+ 4));
+    k2 = LITTLE32(*(word32*)(key+ 8));
+    k3 = LITTLE32(*(word32*)(key+12));
+
+    /* Generate initial state variables */
+    masterCtx_.x[0] = k0;
+    masterCtx_.x[2] = k1;
+    masterCtx_.x[4] = k2;
+    masterCtx_.x[6] = k3;
+    masterCtx_.x[1] = U32V(k3<<16) | (k2>>16);
+    masterCtx_.x[3] = U32V(k0<<16) | (k3>>16);
+    masterCtx_.x[5] = U32V(k1<<16) | (k0>>16);
+    masterCtx_.x[7] = U32V(k2<<16) | (k1>>16);
+
+    /* Generate initial counter values */
+    masterCtx_.c[0] = rotlFixed(k2, 16);
+    masterCtx_.c[2] = rotlFixed(k3, 16);
+    masterCtx_.c[4] = rotlFixed(k0, 16);
+    masterCtx_.c[6] = rotlFixed(k1, 16);
+    masterCtx_.c[1] = (k0&0xFFFF0000) | (k1&0xFFFF);
+    masterCtx_.c[3] = (k1&0xFFFF0000) | (k2&0xFFFF);
+    masterCtx_.c[5] = (k2&0xFFFF0000) | (k3&0xFFFF);
+    masterCtx_.c[7] = (k3&0xFFFF0000) | (k0&0xFFFF);
+
+    /* Clear carry bit */
+    masterCtx_.carry = 0;
+
+    /* Iterate the system four times */
+    for (i=0; i<4; i++)
+        NextState(Master);
+
+    /* Modify the counters */
+    for (i=0; i<8; i++)
+        masterCtx_.c[i] ^= masterCtx_.x[(i+4)&0x7];
+
+    /* Copy master instance to work instance */
+    for (i=0; i<8; i++) {
+        workCtx_.x[i] = masterCtx_.x[i];
+        workCtx_.c[i] = masterCtx_.c[i];
+    }
+    workCtx_.carry = masterCtx_.carry;
+
+    if (iv) SetIV(iv);    
+}
+
+
+/* Encrypt/decrypt a message of any size */
+void Rabbit::Process(byte* output, const byte* input, word32 msglen)
+{
+    /* Temporary variables */
+    word32 i;
+    byte buffer[16];
+
+    /* Encrypt/decrypt all full blocks */
+    while (msglen >= 16) {
+        /* Iterate the system */
+        NextState(Work);
+
+        /* Encrypt/decrypt 16 bytes of data */
+        *(word32*)(output+ 0) = *(word32*)(input+ 0) ^
+                   LITTLE32(workCtx_.x[0] ^ (workCtx_.x[5]>>16) ^
+                   U32V(workCtx_.x[3]<<16));
+        *(word32*)(output+ 4) = *(word32*)(input+ 4) ^
+                   LITTLE32(workCtx_.x[2] ^ (workCtx_.x[7]>>16) ^
+                   U32V(workCtx_.x[5]<<16));
+        *(word32*)(output+ 8) = *(word32*)(input+ 8) ^
+                   LITTLE32(workCtx_.x[4] ^ (workCtx_.x[1]>>16) ^
+                   U32V(workCtx_.x[7]<<16));
+        *(word32*)(output+12) = *(word32*)(input+12) ^
+                   LITTLE32(workCtx_.x[6] ^ (workCtx_.x[3]>>16) ^
+                   U32V(workCtx_.x[1]<<16));
+
+        /* Increment pointers and decrement length */
+        input  += 16;
+        output += 16;
+        msglen -= 16;
+    }
+
+    /* Encrypt/decrypt remaining data */
+    if (msglen) {
+        /* Iterate the system */
+        NextState(Work);
+
+        /* Generate 16 bytes of pseudo-random data */
+        *(word32*)(buffer+ 0) = LITTLE32(workCtx_.x[0] ^
+                  (workCtx_.x[5]>>16) ^ U32V(workCtx_.x[3]<<16));
+        *(word32*)(buffer+ 4) = LITTLE32(workCtx_.x[2] ^ 
+                  (workCtx_.x[7]>>16) ^ U32V(workCtx_.x[5]<<16));
+        *(word32*)(buffer+ 8) = LITTLE32(workCtx_.x[4] ^ 
+                  (workCtx_.x[1]>>16) ^ U32V(workCtx_.x[7]<<16));
+        *(word32*)(buffer+12) = LITTLE32(workCtx_.x[6] ^ 
+                  (workCtx_.x[3]>>16) ^ U32V(workCtx_.x[1]<<16));
+
+        /* Encrypt/decrypt the data */
+        for (i=0; i<msglen; i++)
+            output[i] = input[i] ^ buffer[i];
+    }
+}
+
+
+}  // namespace

=== modified file 'extra/yassl/taocrypt/src/random.cpp'
--- a/extra/yassl/taocrypt/src/random.cpp	2011-06-30 15:46:53 +0000
+++ b/extra/yassl/taocrypt/src/random.cpp	2012-02-13 12:44:54 +0000
@@ -96,13 +96,13 @@
 
 /* The default OS_Seed implementation */
 
-OS_Seed::OS_Seed() 
+OS_Seed::OS_Seed()
 {
     fd_ = open("/dev/urandom",O_RDONLY);
     if (fd_ == -1) {
         fd_ = open("/dev/random",O_RDONLY);
-    if (fd_ == -1)
-        error_.SetError(OPEN_RAN_E);
+        if (fd_ == -1)
+            error_.SetError(OPEN_RAN_E);
     }
 }
 

=== modified file 'extra/yassl/taocrypt/src/ripemd.cpp'
--- a/extra/yassl/taocrypt/src/ripemd.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/ripemd.cpp	2012-02-10 14:33:27 +0000
@@ -110,14 +110,14 @@
 
     // all at once for asm
     if (buffLen_ == 0) {
-            word32 times = len / BLOCK_SIZE;
-            if (times) {
-                AsmTransform(data, times);
-                const word32 add = BLOCK_SIZE * times;
-                AddLength(add);
-                len  -= add;
-                data += add;
-            }
+        word32 times = len / BLOCK_SIZE;
+        if (times) {
+            AsmTransform(data, times);
+            const word32 add = BLOCK_SIZE * times;
+            AddLength(add);
+            len  -= add;
+            data += add;
+        }
     }
 
     // cache any data left

=== modified file 'extra/yassl/taocrypt/src/rsa.cpp'
--- a/extra/yassl/taocrypt/src/rsa.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/rsa.cpp	2012-02-10 14:33:27 +0000
@@ -61,7 +61,6 @@
 
     Integer y = ModularRoot(re, dq_, dp_, q_, p_, u_);
     y = modn.Divide(y, r);				    // unblind
-    assert(modn.Exponentiate(y, e_) == x);  // check
        
     return y;
 }
@@ -124,7 +123,8 @@
     unsigned i=1;
     while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body
         }
-    assert(i==pkcsBlockLen || pkcsBlock[i-1]==0);
+    if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))
+        return 0;
 
     unsigned int outputLen = pkcsBlockLen - i;
     invalid = (outputLen > maxOutputLen) || invalid;
@@ -179,7 +179,8 @@
     unsigned i=1;
     while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body
         }
-    assert(i==pkcsBlockLen || pkcsBlock[i-1]==0);
+    if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))
+        return 0;
 
     unsigned int outputLen = pkcsBlockLen - i;
     invalid = (outputLen > maxOutputLen) || invalid;

=== modified file 'extra/yassl/taocrypt/src/sha.cpp'
--- a/extra/yassl/taocrypt/src/sha.cpp	2007-03-23 10:52:25 +0000
+++ b/extra/yassl/taocrypt/src/sha.cpp	2012-02-10 14:33:27 +0000
@@ -344,14 +344,14 @@
 
     // all at once for asm
     if (buffLen_ == 0) {
-            word32 times = len / BLOCK_SIZE;
-            if (times) {
-                AsmTransform(data, times);
-                const word32 add = BLOCK_SIZE * times;
-                AddLength(add);
-                 len  -= add;
-                data += add;
-            }
+        word32 times = len / BLOCK_SIZE;
+        if (times) {
+            AsmTransform(data, times);
+            const word32 add = BLOCK_SIZE * times;
+            AddLength(add);
+            len  -= add;
+            data += add;
+        }
     }
 
     // cache any data left

=== modified file 'extra/yassl/taocrypt/src/template_instnt.cpp'
--- a/extra/yassl/taocrypt/src/template_instnt.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/template_instnt.cpp	2012-02-10 14:33:27 +0000
@@ -61,7 +61,6 @@
 template class HMAC<MD5>;
 template class HMAC<SHA>;
 template class HMAC<RIPEMD160>;
-
 }
 
 namespace mySTL {

=== modified file 'extra/yassl/taocrypt/src/twofish.cpp'
--- a/extra/yassl/taocrypt/src/twofish.cpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/taocrypt/src/twofish.cpp	2012-04-07 13:58:46 +0000
@@ -141,8 +141,6 @@
 
 void Twofish::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
 {
-	assert(keylen >= 16 && keylen <= 32);
-
 	unsigned int len = (keylen <= 16 ? 2 : (keylen <= 24 ? 3 : 4));
     word32 key[8];
 	GetUserKey(LittleEndianOrder, key, len*2, userKey, keylen);

=== modified file 'extra/yassl/taocrypt/taocrypt.dsp'
--- a/extra/yassl/taocrypt/taocrypt.dsp	2006-11-29 13:35:59 +0000
+++ b/extra/yassl/taocrypt/taocrypt.dsp	2012-02-13 11:40:12 +0000
@@ -138,6 +138,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\hc128.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\integer.cpp
 # End Source File
 # Begin Source File
@@ -158,6 +162,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\rabbit.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\random.cpp
 # End Source File
 # Begin Source File
@@ -238,6 +246,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\include\hc128.hpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\include\hmac.hpp
 # End Source File
 # Begin Source File
@@ -274,6 +286,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\include\rabbit.hpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\include\random.hpp
 # End Source File
 # Begin Source File

=== modified file 'extra/yassl/taocrypt/test/make.bat' (properties changed: -x to +x)
=== modified file 'extra/yassl/taocrypt/test/memory.cpp'
--- a/extra/yassl/taocrypt/test/memory.cpp	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/taocrypt/test/memory.cpp	2012-04-07 13:58:46 +0000
@@ -328,3 +328,32 @@
 {
     ::operator delete(ptr);
 }
+
+
+extern "C" {
+
+void* XMALLOC(size_t sz, void* head)
+{
+    return ::operator new(sz);
+}
+
+void* XREALLOC(void* ptr, size_t sz, void* heap)
+{
+    void* ret = ::operator new(sz);
+
+    if (ret && ptr)
+        memcpy(ret, ptr, sz);
+
+    if (ret)
+        ::operator delete(ptr);
+    return ret;
+}
+
+
+void XFREE(void* ptr, void* heap)
+{
+    ::operator delete(ptr);
+}
+
+}  // extern "C"
+

=== modified file 'extra/yassl/taocrypt/test/test.cpp'
--- a/extra/yassl/taocrypt/test/test.cpp	2011-02-20 16:51:43 +0000
+++ b/extra/yassl/taocrypt/test/test.cpp	2012-04-07 13:58:46 +0000
@@ -27,6 +27,8 @@
 #include "coding.hpp"
 #include "random.hpp"
 #include "pwdbased.hpp"
+#include "rabbit.hpp"
+#include "hc128.hpp"
 
 
 
@@ -86,16 +88,18 @@
 using TaoCrypt::tcArrayDelete;
 using TaoCrypt::GetCert;
 using TaoCrypt::GetPKCS_Cert;
-
+using TaoCrypt::Rabbit;
+using TaoCrypt::HC128;
 
 struct testVector {
     byte*  input_;
     byte*  output_; 
-    size_t inLen_;
-    size_t outLen_;
+    word32 inLen_;
+    word32 outLen_;
 
     testVector(const char* in, const char* out) : input_((byte*)in),
-               output_((byte*)out), inLen_(strlen(in)), outLen_(strlen(out)) {}
+               output_((byte*)out), inLen_((word32)strlen(in)),
+               outLen_((word32)strlen(out)) {}
 };
 
 int  sha_test();
@@ -120,13 +124,15 @@
 int  dh_test();
 int  pwdbased_test();
 int  pkcs12_test();
+int  rabbit_test();
+int  hc128_test();
 
 TaoCrypt::RandomNumberGenerator rng;
 
 
 void err_sys(const char* msg, int es)
 {
-    printf("%s", msg);
+    printf("%s\n", msg);
     exit(es);    
 }
 
@@ -162,7 +168,7 @@
 void taocrypt_test(void* args)
 {
     ((func_args*)args)->return_code = -1; // error state
-    
+
     msg    = NEW_TC byte[24];
     plain  = NEW_TC byte[24];
     cipher = NEW_TC byte[24];
@@ -229,6 +235,16 @@
     else
         printf( "ARC4     test passed!\n");
 
+    if ( (ret = rabbit_test()) )
+        err_sys("Rabbit   test failed!\n", ret);
+    else
+        printf( "Rabbit   test passed!\n");
+
+    if ( (ret = hc128_test()) )
+        err_sys("HC128    test failed!\n", ret);
+    else
+        printf( "HC128    test passed!\n");
+
     if ( (ret = des_test()) )
         err_sys("DES      test failed!\n", ret);
     else
@@ -306,16 +322,16 @@
 void file_test(const char* file, byte* check)
 {
     FILE* f;
-    int   i(0);
-    MD5   md5;
-    byte  buf[1024];
-    byte  md5sum[MD5::DIGEST_SIZE];
+    int i = 0;
+    MD5    md5;
+    byte   buf[1024];
+    byte   md5sum[MD5::DIGEST_SIZE];
     
     if( !( f = fopen( file, "rb" ) )) {
         printf("Can't open %s\n", file);
         return;
     }
-    while( ( i = fread(buf, 1, sizeof(buf), f )) > 0 )
+    while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 )
         md5.Update(buf, i);
     
     md5.Final(md5sum);
@@ -704,7 +720,7 @@
 
     int times( sizeof(test_hmacMD5) / sizeof(testVector) );
     for (int i = 0; i < times; ++i) {
-        hmacMD5.SetKey((byte*)keys[i], strlen(keys[i]));
+        hmacMD5.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
         hmacMD5.Update(test_hmacMD5[i].input_, test_hmacMD5[i].inLen_);
         hmacMD5.Final(hash);
 
@@ -747,8 +763,8 @@
         ARC4::Encryption enc;
         ARC4::Decryption dec;
 
-        enc.SetKey((byte*)keys[i], strlen(keys[i]));
-        dec.SetKey((byte*)keys[i], strlen(keys[i]));
+        enc.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
+        dec.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
 
         enc.Process(cipher, test_arc4[i].input_, test_arc4[i].outLen_);
         dec.Process(plain,  cipher, test_arc4[i].outLen_);
@@ -764,6 +780,114 @@
 }
 
 
+int rabbit_test()
+{
+    byte cipher[16];
+    byte plain[16];
+
+    const char* keys[] = 
+    {           
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\xAC\xC3\x51\xDC\xF1\x62\xFC\x3B\xFE\x36\x3D\x2E\x29\x13\x28\x91"
+    };
+
+    const char* ivs[] =
+    {
+        "\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\x59\x7E\x26\xC1\x75\xF5\x73\xC3",
+        0
+    };
+
+
+    testVector test_rabbit[] =
+    {
+        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
+                   "\xED\xB7\x05\x67\x37\x5D\xCD\x7C"),
+        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
+                   "\x6D\x7D\x01\x22\x92\xCC\xDC\xE0"),
+        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
+                   "\x9C\x51\xE2\x87\x84\xC3\x7F\xE9")
+    };
+
+
+    int times( sizeof(test_rabbit) / sizeof(testVector) );
+    for (int i = 0; i < times; ++i) {
+        Rabbit::Encryption enc;
+        Rabbit::Decryption dec;
+
+        enc.SetKey((byte*)keys[i], (byte*)ivs[i]);
+        dec.SetKey((byte*)keys[i], (byte*)ivs[i]);
+
+        enc.Process(cipher, test_rabbit[i].input_, test_rabbit[i].outLen_);
+        dec.Process(plain,  cipher, test_rabbit[i].outLen_);
+
+        if (memcmp(plain, test_rabbit[i].input_, test_rabbit[i].outLen_))
+            return -230 - i;
+
+        if (memcmp(cipher, test_rabbit[i].output_, test_rabbit[i].outLen_))
+            return -240 - i;
+    }
+
+    return 0;
+}
+
+
+int hc128_test()
+{
+    byte cipher[16];
+    byte plain[16];
+
+    const char* keys[] = 
+    {           
+        "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\x00\x53\xA6\xF9\x4C\x9F\xF2\x45\x98\xEB\x3E\x91\xE4\x37\x8A\xDD",
+        "\x0F\x62\xB5\x08\x5B\xAE\x01\x54\xA7\xFA\x4D\xA0\xF3\x46\x99\xEC"
+    };
+
+    const char* ivs[] =
+    {
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+        "\x0D\x74\xDB\x42\xA9\x10\x77\xDE\x45\xAC\x13\x7A\xE1\x48\xAF\x16",
+        "\x28\x8F\xF6\x5D\xC4\x2B\x92\xF9\x60\xC7\x2E\x95\xFC\x63\xCA\x31"
+    };
+
+    testVector test_hc128[] =
+    {
+        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
+                   "\x37\x86\x02\xB9\x8F\x32\xA7\x48"),
+        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
+                   "\x33\x7F\x86\x11\xC6\xED\x61\x5F"),
+        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
+                   "\x2E\x1E\xD1\x2A\x85\x51\xC0\x5A"),
+      testVector("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+                 "\x1C\xD8\xAE\xDD\xFE\x52\xE2\x17\xE8\x35\xD0\xB7\xE8\x4E\x29")
+    };
+
+    int times( sizeof(test_hc128) / sizeof(testVector) );
+    for (int i = 0; i < times; ++i) {
+        HC128::Encryption enc;
+        HC128::Decryption dec;
+
+        enc.SetKey((byte*)keys[i], (byte*)ivs[i]);
+        dec.SetKey((byte*)keys[i], (byte*)ivs[i]);
+
+        enc.Process(cipher, test_hc128[i].input_, test_hc128[i].outLen_);
+        dec.Process(plain,  cipher, test_hc128[i].outLen_);
+
+        if (memcmp(plain, test_hc128[i].input_, test_hc128[i].outLen_))
+            return -330 - i;
+
+        if (memcmp(cipher, test_hc128[i].output_, test_hc128[i].outLen_))
+            return -340 - i;
+    }
+
+    return 0;
+}
+
+
 int des_test()
 {
     //ECB mode
@@ -1026,7 +1150,7 @@
 
     RSAES_Encryptor enc(priv);
     byte message[] = "Everyone gets Friday off.";
-    const int len(strlen((char*)message));
+    const word32 len = (word32)strlen((char*)message);
     byte cipher[64];
     enc.Encrypt(message, len, cipher, rng);
 
@@ -1054,6 +1178,8 @@
         }
     }
     CertDecoder cd(source2, true, 0, false, CertDecoder::CA);
+    if (cd.GetError().What())
+        err_sys("cert error", -80);
     Source source3(cd.GetPublicKey().GetKey(), cd.GetPublicKey().size());
     RSA_PublicKey pub(source3);
  
@@ -1174,6 +1300,7 @@
 }
 
 
+/*
 int pkcs12_test()
 {
     Source cert;
@@ -1206,4 +1333,5 @@
 
     return 0;
 }
+*/
 

=== modified file 'extra/yassl/testsuite/make.bat' (properties changed: -x to +x)
=== modified file 'extra/yassl/testsuite/test.hpp'
--- a/extra/yassl/testsuite/test.hpp	2012-01-13 14:50:02 +0000
+++ b/extra/yassl/testsuite/test.hpp	2012-04-07 13:58:46 +0000
@@ -23,6 +23,7 @@
 
 #include "runtime.hpp"
 #include "openssl/ssl.h"   /* openssl compatibility test */
+#include "error.hpp"
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -32,6 +33,10 @@
 #ifdef _WIN32
     #include <winsock2.h>
     #include <process.h>
+    #ifdef TEST_IPV6            // don't require newer SDK for IPV4
+	    #include <ws2tcpip.h>
+        #include <wspiapi.h>
+    #endif
     #define SOCKET_T unsigned int
 #else
     #include <string.h>
@@ -42,6 +47,9 @@
     #include <sys/time.h>
     #include <sys/types.h>
     #include <sys/socket.h>
+    #ifdef TEST_IPV6
+        #include <netdb.h>
+    #endif
     #include <pthread.h>
 #ifdef NON_BLOCKING
     #include <fcntl.h>
@@ -50,6 +58,13 @@
 #endif /* _WIN32 */
 
 
+#ifdef _MSC_VER
+    // disable conversion warning
+    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
+    #pragma warning(disable:4244 4996)
+#endif
+
+
 #if !defined(_SOCKLEN_T) && (defined(_WIN32) || defined(__APPLE__))
     typedef int socklen_t;
 #endif
@@ -64,6 +79,15 @@
 #endif
 
 
+#ifdef TEST_IPV6
+    typedef sockaddr_in6 SOCKADDR_IN_T;
+    #define AF_INET_V    AF_INET6
+#else
+    typedef sockaddr_in  SOCKADDR_IN_T;
+    #define AF_INET_V    AF_INET
+#endif
+   
+
 // Check if _POSIX_THREADS should be forced
 #if !defined(_POSIX_THREADS) && defined(__hpux)
 // HPUX does not define _POSIX_THREADS as it's not _fully_ implemented
@@ -73,7 +97,7 @@
 
 #ifndef _POSIX_THREADS
     typedef unsigned int  THREAD_RETURN;
-    typedef unsigned long THREAD_TYPE;
+    typedef HANDLE        THREAD_TYPE;
     #define YASSL_API __stdcall
 #else
     typedef void*         THREAD_RETURN;
@@ -120,8 +144,8 @@
 void join_thread(THREAD_TYPE);
 
 // yaSSL
-const char* const    yasslIP   = "127.0.0.1";
-const unsigned short yasslPort = 11111;
+const char* const    yasslIP      = "127.0.0.1";
+const unsigned short yasslPort    =  11111;
 
 
 // client
@@ -180,7 +204,7 @@
 
 static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
 {
-    strncpy(passwd, "12345678", sz);
+    strncpy(passwd, "yassl123", sz);
     return 8;
 }
 
@@ -300,14 +324,35 @@
 }
 
 
-inline void tcp_socket(SOCKET_T& sockfd, sockaddr_in& addr)
+inline void tcp_socket(SOCKET_T& sockfd, SOCKADDR_IN_T& addr)
 {
-    sockfd = socket(AF_INET, SOCK_STREAM, 0);
+    sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
     memset(&addr, 0, sizeof(addr));
-    addr.sin_family = AF_INET;
-
+
+#ifdef TEST_IPV6
+    addr.sin6_family = AF_INET_V;
+    addr.sin6_port = htons(yasslPort);
+    addr.sin6_addr = in6addr_loopback;
+
+    /* // for external testing later 
+    addrinfo hints;
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family   = AF_INET_V;
+    hints.ai_socktype = SOCK_STREAM;
+    hints.ai_flags    = AI_PASSIVE;
+
+    getaddrinfo(yasslIP6, yasslPortStr, &hints, info);
+    // then use info connect(sockfd, info->ai_addr, info->ai_addrlen)
+
+    if (*info == 0)
+        err_sys("getaddrinfo failed");
+        */   // end external testing later
+#else
+    addr.sin_family = AF_INET_V;
     addr.sin_port = htons(yasslPort);
     addr.sin_addr.s_addr = inet_addr(yasslIP);
+#endif
+
 }
 
 
@@ -318,13 +363,13 @@
 #else
     close(sockfd);
 #endif
-    sockfd = -1;
+    sockfd = (SOCKET_T) -1;
 }
 
 
 inline void tcp_connect(SOCKET_T& sockfd)
 {
-    sockaddr_in addr;
+    SOCKADDR_IN_T addr;
     tcp_socket(sockfd, addr);
 
     if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {
@@ -336,9 +381,15 @@
 
 inline void tcp_listen(SOCKET_T& sockfd)
 {
-    sockaddr_in addr;
+    SOCKADDR_IN_T addr;
     tcp_socket(sockfd, addr);
 
+#ifndef _WIN32
+    int       on  = 1;
+    socklen_t len = sizeof(on);
+    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
+#endif
+
     if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {
         tcp_close(sockfd);
         err_sys("tcp bind failed");
@@ -355,7 +406,7 @@
 {
     tcp_listen(sockfd);
 
-    sockaddr_in client;
+    SOCKADDR_IN_T client;
     socklen_t client_len = sizeof(client);
 
 #if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
@@ -369,7 +420,7 @@
 
     clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len);
 
-    if (clientfd == -1) {
+    if (clientfd == (SOCKET_T) -1) {
         tcp_close(sockfd);
         err_sys("tcp accept failed");
     }
@@ -387,10 +438,8 @@
         char* issuer  = X509_NAME_oneline(X509_get_issuer_name(peer), 0, 0);
         char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0);
 
-        printf("peer's cert info:\n");
-        printf("issuer : %s\n", issuer);
-        printf("subject: %s\n", subject);
-
+        printf("peer's cert info:\n issuer : %s\n subject: %s\n", issuer,
+                                                                  subject);
         free(subject);
         free(issuer);
     }
@@ -436,5 +485,19 @@
 }
 
 
+inline int verify_callback(int preverify_ok, X509_STORE_CTX* ctx)
+{
+    X509* err_cert = X509_STORE_CTX_get_current_cert(ctx);
+    int   err      = X509_STORE_CTX_get_error(ctx);
+    int   depth    = X509_STORE_CTX_get_error_depth(ctx);
+
+    // test allow self signed
+    if (err_cert && depth == 0 && err == TaoCrypt::SIG_OTHER_E)
+        return 1;
+
+    return 0;
+}
+
+
 #endif // yaSSL_TEST_HPP
 

=== modified file 'extra/yassl/testsuite/testsuite.cpp'
--- a/extra/yassl/testsuite/testsuite.cpp	2011-10-19 19:45:18 +0000
+++ b/extra/yassl/testsuite/testsuite.cpp	2012-04-07 13:58:46 +0000
@@ -119,7 +119,7 @@
 void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
 {
 #ifndef _POSIX_THREADS
-    *thread = _beginthreadex(0, 0, fun, args, 0, 0);
+    *thread = (HANDLE)_beginthreadex(0, 0, fun, args, 0, 0);
 #else
     pthread_create(thread, 0, fun, args);
 #endif
@@ -129,9 +129,9 @@
 void join_thread(THREAD_TYPE thread)
 {
 #ifndef _POSIX_THREADS
-    int res = WaitForSingleObject(reinterpret_cast<HANDLE>(thread), INFINITE);
+    int res = WaitForSingleObject(thread, INFINITE);
     assert(res == WAIT_OBJECT_0);
-    res = CloseHandle(reinterpret_cast<HANDLE>(thread));
+    res = CloseHandle(thread);
     assert(res);
 #else
     pthread_join(thread, 0);
@@ -158,7 +158,7 @@
 {
     /* test des encrypt/decrypt */
     char data[] = "this is my data ";
-    int  dataSz = strlen(data);
+    int  dataSz = (int)strlen(data);
     DES_key_schedule key[3];
     byte iv[8];
     EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1,

=== modified file 'include/CMakeLists.txt'
--- a/include/CMakeLists.txt	2011-12-02 15:29:02 +0000
+++ b/include/CMakeLists.txt	2012-04-03 06:00:57 +0000
@@ -20,22 +20,14 @@
 ${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h
 ${CMAKE_CURRENT_BINARY_DIR}/sql_state.h
 )
-SET(HEADERS_ABI 
+
+SET(HEADERS 
   mysql.h 
   mysql_com.h
   mysql_time.h 
   my_list.h
   my_alloc.h
   typelib.h 
-  mysql/plugin.h
-  mysql/plugin_audit.h
-  mysql/plugin_ftparser.h
-  mysql/plugin_auth.h
-  mysql/client_plugin.h
-)
-
-SET(HEADERS 
-  ${HEADERS_ABI} 
   my_dbug.h 
   m_string.h
   my_sys.h 
@@ -61,4 +53,4 @@
 )
 
 INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
-INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR}/mysql COMPONENT Development FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development FILES_MATCHING PATTERN "*.h")

=== modified file 'include/m_ctype.h'
--- a/include/m_ctype.h	2012-03-09 07:06:59 +0000
+++ b/include/m_ctype.h	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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
@@ -71,7 +71,7 @@
 
 extern MY_UNICASE_INFO *const my_unicase_default[256];
 extern MY_UNICASE_INFO *const my_unicase_turkish[256];
-extern MY_UNICASE_INFO *my_unicase_mysql500[256];
+extern MY_UNICASE_INFO *const my_unicase_mysql500[256];
 
 #define MY_UCA_MAX_CONTRACTION 4
 #define MY_UCA_MAX_WEIGHT_SIZE 8
@@ -356,6 +356,7 @@
 extern struct charset_info_st my_charset_ucs2_general_ci;
 extern struct charset_info_st my_charset_ucs2_general_mysql500_ci;
 extern struct charset_info_st my_charset_ucs2_unicode_ci;
+extern struct charset_info_st my_charset_ucs2_general_mysql500_ci;
 extern struct charset_info_st my_charset_ujis_bin;
 extern struct charset_info_st my_charset_ujis_japanese_ci;
 extern struct charset_info_st my_charset_utf16_bin;

=== modified file 'include/m_string.h'
--- a/include/m_string.h	2012-01-13 14:50:02 +0000
+++ b/include/m_string.h	2012-04-07 13:58:46 +0000
@@ -66,7 +66,9 @@
 # define bcmp(A,B,C)		memcmp((A),(B),(C))
 #endif
 
-#if !defined(bzero) && (!defined(HAVE_BZERO) || !defined(HAVE_DECL_BZERO))
+#if !defined(bzero) && (!defined(HAVE_BZERO) || !HAVE_DECL_BZERO || defined(_AIX))
+/* See autoconf doku: "HAVE_DECL_symbol" will be defined after configure, to 0 or 1 */
+/* AIX has bzero() as a function, but the declaration prototype is strangely hidden */
 # define bzero(A,B)             memset((A),0,(B))
 #endif
 

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2012-03-13 12:27:14 +0000
+++ b/include/my_global.h	2012-03-27 23:04:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2001, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2001, 2012, Oracle and/or its affiliates.
 
    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
@@ -446,6 +446,10 @@
 #define SIGNAL_HANDLER_RESET_ON_DELIVERY
 #endif
 
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
 /*
   Deprecated workaround for false-positive uninitialized variables
   warnings. Those should be silenced using tool-specific heuristics.

=== modified file 'include/my_stacktrace.h'
--- a/include/my_stacktrace.h	2012-03-13 12:34:24 +0000
+++ b/include/my_stacktrace.h	2012-04-03 12:48:56 +0000
@@ -50,11 +50,13 @@
 void my_write_core(int sig);
 #if BACKTRACE_DEMANGLE
 char *my_demangle(const char *mangled_name, int *status);
-#endif
+#endif /* BACKTRACE_DEMANGLE */
 #ifdef __WIN__
 void my_set_exception_pointers(EXCEPTION_POINTERS *ep);
-#endif
-#endif
+#endif /* __WIN__ */
+#else
+#define my_init_stacktrace() do { } while(0)
+#endif /* ! (defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)) */
 
 #ifndef _WIN32
 #define MY_ADDR_RESOLVE_FORK
@@ -82,50 +84,6 @@
 void my_write_core(int sig);
 #endif
 
-
-
-/**
-  Async-signal-safe utility functions used by signal handler routines.
-  Declared here in order to unit-test them.
-  These are not general-purpose, but tailored to the signal handling routines.
-*/
-/**
-  Converts a longlong value to string.
-  @param   base 10 for decimal, 16 for hex values (0..9a..f)
-  @param   val  The value to convert
-  @param   buf  Assumed to point to the *end* of the buffer.
-  @returns Pointer to the first character of the converted string.
-           Negative values:
-           for base-10 the return string will be prepended with '-'
-           for base-16 the return string will contain 16 characters
-  Implemented with simplicity, and async-signal-safety in mind.
-*/
-char *my_safe_itoa(int base, longlong val, char *buf);
-
-/**
-  Converts a ulonglong value to string.
-  @param   base 10 for decimal, 16 for hex values (0..9a..f)
-  @param   val  The value to convert
-  @param   buf  Assumed to point to the *end* of the buffer.
-  @returns Pointer to the first character of the converted string.
-  Implemented with simplicity, and async-signal-safety in mind.
-*/
-char *my_safe_utoa(int base, ulonglong val, char *buf);
-
-/**
-  A (very) limited version of snprintf.
-  @param   to   Destination buffer.
-  @param   n    Size of destination buffer.
-  @param   fmt  printf() style format string.
-  @returns Number of bytes written, including terminating '\0'
-  Supports 'd' 'i' 'u' 'x' 'p' 's' conversion.
-  Supports 'l' and 'll' modifiers for integral types.
-  Does not support any width/precision.
-  Implemented with simplicity, and async-signal-safety in mind.
-*/
-size_t my_safe_snprintf(char* to, size_t n, const char* fmt, ...)
-  ATTRIBUTE_FORMAT(printf, 3, 4);
-
 /**
   A (very) limited version of snprintf, which writes the result to STDERR.
   @sa my_safe_snprintf

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2012-03-13 20:55:56 +0000
+++ b/include/my_sys.h	2012-03-28 17:26:00 +0000
@@ -157,16 +157,6 @@
 
 extern int sf_leaking_memory; /* set to 1 to disable memleak detection */
 
-#if defined(ENABLED_DEBUG_SYNC)
-extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
-#define DEBUG_SYNC_C(_sync_point_name_) do {                            \
-    if (debug_sync_C_callback_ptr != NULL)                              \
-      (*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
-  while(0)
-#else
-#define DEBUG_SYNC_C(_sync_point_name_)
-#endif /* defined(ENABLED_DEBUG_SYNC) */
-
 #ifdef HAVE_LARGE_PAGES
 extern uint my_get_large_page_size(void);
 extern uchar * my_large_malloc(size_t size, myf my_flags);

=== modified file 'include/my_valgrind.h'
--- a/include/my_valgrind.h	2012-02-23 14:31:24 +0000
+++ b/include/my_valgrind.h	2012-03-22 11:31:09 +0000
@@ -23,7 +23,7 @@
 #define IF_VALGRIND(A,B) B
 #endif
 
-#if defined(HAVE_VALGRIND)
+#if defined(HAVE_VALGRIND) && defined(HAVE_valgrind)
 # include <valgrind/memcheck.h>
 # define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
 # define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)

=== modified file 'include/myisam.h'
--- a/include/myisam.h	2012-01-13 14:50:02 +0000
+++ b/include/myisam.h	2012-03-27 23:04:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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
@@ -421,7 +421,7 @@
 int sort_ft_buf_flush(MI_SORT_PARAM *sort_param);
 int thr_write_keys(MI_SORT_PARAM *sort_param);
 int sort_write_record(MI_SORT_PARAM *sort_param);
-int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
+int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulonglong);
 
 #ifdef	__cplusplus
 }

=== modified file 'include/mysql.h.pp'
--- a/include/mysql.h.pp	2012-02-21 21:15:44 +0000
+++ b/include/mysql.h.pp	2012-03-26 10:33:49 +0000
@@ -66,9 +66,7 @@
   SHUTDOWN_WAIT_TRANSACTIONS= (unsigned char)(1 << 1),
   SHUTDOWN_WAIT_UPDATES= (unsigned char)(1 << 3),
   SHUTDOWN_WAIT_ALL_BUFFERS= ((unsigned char)(1 << 3) << 1),
-  SHUTDOWN_WAIT_CRITICAL_BUFFERS= ((unsigned char)(1 << 3) << 1) + 1,
-  SHUTDOWN_KILL_QUERY= 254,
-  SHUTDOWN_KILL_CONNECTION= 255
+  SHUTDOWN_WAIT_CRITICAL_BUFFERS= ((unsigned char)(1 << 3) << 1) + 1
 };
 enum enum_cursor_type
 {

=== modified file 'include/mysql/plugin.h'
--- a/include/mysql/plugin.h	2012-03-13 20:55:56 +0000
+++ b/include/mysql/plugin.h	2012-03-28 17:26:00 +0000
@@ -1,5 +1,5 @@
-/* Copyright (c) 2005, 2010, Oracle and/or its affiliates
-   Copyright (C) 2009-2011 Monty Program Ab
+/* Copyright (c) 2005, 2011, Oracle and/or its affiliates
+   Copyright (C) 2009, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -72,7 +72,7 @@
 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103
 
 /* MariaDB plugin interface version */
-#define MARIA_PLUGIN_INTERFACE_VERSION 0x0102
+#define MARIA_PLUGIN_INTERFACE_VERSION 0x0103
 
 /*
   The allowable types of plugins

=== modified file 'include/mysql/plugin_audit.h.pp'
--- a/include/mysql/plugin_audit.h.pp	2012-03-14 12:37:49 +0000
+++ b/include/mysql/plugin_audit.h.pp	2012-03-28 17:26:00 +0000
@@ -80,24 +80,8 @@
 void thd_progress_end(void* thd);
 const char *set_thd_proc_info(void*, const char * info, const char *func,
                               const char *file, unsigned int line);
-#include <mysql/service_logger.h>
-typedef struct logger_handle_st LOGGER_HANDLE;
-extern struct logger_service_st {
-  LOGGER_HANDLE* (*open)(const char *path,
-                         unsigned long long size_limit,
-                         unsigned int rotations);
-  int (*close)(LOGGER_HANDLE *log);
-  int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
-  int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
-  int (*rotate)(LOGGER_HANDLE *log);
-} *logger_service;
-  LOGGER_HANDLE *logger_open(const char *path,
-                             unsigned long long size_limit,
-                             unsigned int rotations);
-  int logger_close(LOGGER_HANDLE *log);
-  int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
-  int logger_rotate(LOGGER_HANDLE *log);
-  int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
+#include <mysql/service_debug_sync.h>
+extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;

=== modified file 'include/mysql/plugin_auth.h.pp'
--- a/include/mysql/plugin_auth.h.pp	2012-03-14 12:37:49 +0000
+++ b/include/mysql/plugin_auth.h.pp	2012-03-28 17:26:00 +0000
@@ -80,24 +80,8 @@
 void thd_progress_end(void* thd);
 const char *set_thd_proc_info(void*, const char * info, const char *func,
                               const char *file, unsigned int line);
-#include <mysql/service_logger.h>
-typedef struct logger_handle_st LOGGER_HANDLE;
-extern struct logger_service_st {
-  LOGGER_HANDLE* (*open)(const char *path,
-                         unsigned long long size_limit,
-                         unsigned int rotations);
-  int (*close)(LOGGER_HANDLE *log);
-  int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
-  int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
-  int (*rotate)(LOGGER_HANDLE *log);
-} *logger_service;
-  LOGGER_HANDLE *logger_open(const char *path,
-                             unsigned long long size_limit,
-                             unsigned int rotations);
-  int logger_close(LOGGER_HANDLE *log);
-  int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
-  int logger_rotate(LOGGER_HANDLE *log);
-  int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
+#include <mysql/service_debug_sync.h>
+extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;

=== modified file 'include/mysql/plugin_ftparser.h.pp'
--- a/include/mysql/plugin_ftparser.h.pp	2012-03-14 12:37:49 +0000
+++ b/include/mysql/plugin_ftparser.h.pp	2012-03-28 17:26:00 +0000
@@ -80,24 +80,8 @@
 void thd_progress_end(void* thd);
 const char *set_thd_proc_info(void*, const char * info, const char *func,
                               const char *file, unsigned int line);
-#include <mysql/service_logger.h>
-typedef struct logger_handle_st LOGGER_HANDLE;
-extern struct logger_service_st {
-  LOGGER_HANDLE* (*open)(const char *path,
-                         unsigned long long size_limit,
-                         unsigned int rotations);
-  int (*close)(LOGGER_HANDLE *log);
-  int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
-  int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
-  int (*rotate)(LOGGER_HANDLE *log);
-} *logger_service;
-  LOGGER_HANDLE *logger_open(const char *path,
-                             unsigned long long size_limit,
-                             unsigned int rotations);
-  int logger_close(LOGGER_HANDLE *log);
-  int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
-  int logger_rotate(LOGGER_HANDLE *log);
-  int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
+#include <mysql/service_debug_sync.h>
+extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;

=== added file 'include/mysql/service_debug_sync.h'
--- a/include/mysql/service_debug_sync.h	1970-01-01 00:00:00 +0000
+++ b/include/mysql/service_debug_sync.h	2012-03-28 17:26:00 +0000
@@ -0,0 +1,354 @@
+#ifndef MYSQL_SERVICE_DEBUG_SYNC_INCLUDED
+/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
+   Copyright (c) 2012, Monty Program Ab
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
+
+/**
+  @file
+  == Debug Sync Facility ==
+
+  The Debug Sync Facility allows placement of synchronization points in
+  the server code by using the DEBUG_SYNC macro:
+
+      open_tables(...)
+
+      DEBUG_SYNC(thd, "after_open_tables");
+
+      lock_tables(...)
+
+  When activated, a sync point can
+
+    - Emit a signal and/or
+    - Wait for a signal
+
+  Nomenclature:
+
+    - signal:             A value of a global variable that persists
+                          until overwritten by a new signal. The global
+                          variable can also be seen as a "signal post"
+                          or "flag mast". Then the signal is what is
+                          attached to the "signal post" or "flag mast".
+
+    - emit a signal:      Assign the value (the signal) to the global
+                          variable ("set a flag") and broadcast a
+                          global condition to wake those waiting for
+                          a signal.
+
+    - wait for a signal:  Loop over waiting for the global condition until
+                          the global value matches the wait-for signal.
+
+  By default, all sync points are inactive. They do nothing (except to
+  burn a couple of CPU cycles for checking if they are active).
+
+  A sync point becomes active when an action is requested for it.
+  To do so, put a line like this in the test case file:
+
+      SET DEBUG_SYNC= 'after_open_tables SIGNAL opened WAIT_FOR flushed';
+
+  This activates the sync point 'after_open_tables'. It requests it to
+  emit the signal 'opened' and wait for another thread to emit the signal
+  'flushed' when the thread's execution runs through the sync point.
+
+  For every sync point there can be one action per thread only. Every
+  thread can request multiple actions, but only one per sync point. In
+  other words, a thread can activate multiple sync points.
+
+  Here is an example how to activate and use the sync points:
+
+      --connection conn1
+      SET DEBUG_SYNC= 'after_open_tables SIGNAL opened WAIT_FOR flushed';
+      send INSERT INTO t1 VALUES(1);
+          --connection conn2
+          SET DEBUG_SYNC= 'now WAIT_FOR opened';
+          SET DEBUG_SYNC= 'after_abort_locks SIGNAL flushed';
+          FLUSH TABLE t1;
+
+  When conn1 runs through the INSERT statement, it hits the sync point
+  'after_open_tables'. It notices that it is active and executes its
+  action. It emits the signal 'opened' and waits for another thread to
+  emit the signal 'flushed'.
+
+  conn2 waits immediately at the special sync point 'now' for another
+  thread to emit the 'opened' signal.
+
+  A signal remains in effect until it is overwritten. If conn1 signals
+  'opened' before conn2 reaches 'now', conn2 will still find the 'opened'
+  signal. It does not wait in this case.
+
+  When conn2 reaches 'after_abort_locks', it signals 'flushed', which lets
+  conn1 awake.
+
+  Normally the activation of a sync point is cleared when it has been
+  executed. Sometimes it is necessary to keep the sync point active for
+  another execution. You can add an execute count to the action:
+
+      SET DEBUG_SYNC= 'name SIGNAL sig EXECUTE 3';
+
+  This sets the signal point's activation counter to 3. Each execution
+  decrements the counter. After the third execution the sync point
+  becomes inactive.
+
+  One of the primary goals of this facility is to eliminate sleeps from
+  the test suite. In most cases it should be possible to rewrite test
+  cases so that they do not need to sleep. (But this facility cannot
+  synchronize multiple processes.) However, to support test development,
+  and as a last resort, sync point waiting times out. There is a default
+  timeout, but it can be overridden:
+
+      SET DEBUG_SYNC= 'name WAIT_FOR sig TIMEOUT 10 EXECUTE 2';
+
+  TIMEOUT 0 is special: If the signal is not present, the wait times out
+  immediately.
+
+  When a wait timed out (even on TIMEOUT 0), a warning is generated so
+  that it shows up in the test result.
+
+  You can throw an error message and kill the query when a synchronization
+  point is hit a certain number of times:
+
+      SET DEBUG_SYNC= 'name HIT_LIMIT 3';
+
+  Or combine it with signal and/or wait:
+
+      SET DEBUG_SYNC= 'name SIGNAL sig EXECUTE 2 HIT_LIMIT 3';
+
+  Here the first two hits emit the signal, the third hit returns the error
+  message and kills the query.
+
+  For cases where you are not sure that an action is taken and thus
+  cleared in any case, you can force to clear (deactivate) a sync point:
+
+      SET DEBUG_SYNC= 'name CLEAR';
+
+  If you want to clear all actions and clear the global signal, use:
+
+      SET DEBUG_SYNC= 'RESET';
+
+  This is the only way to reset the global signal to an empty string.
+
+  For testing of the facility itself you can execute a sync point just
+  as if it had been hit:
+
+      SET DEBUG_SYNC= 'name TEST';
+
+
+  === Formal Syntax ===
+
+  The string to "assign" to the DEBUG_SYNC variable can contain:
+
+      {RESET |
+       <sync point name> TEST |
+       <sync point name> CLEAR |
+       <sync point name> {{SIGNAL <signal name> |
+                           WAIT_FOR <signal name> [TIMEOUT <seconds>]}
+                          [EXECUTE <count>] &| HIT_LIMIT <count>}
+
+  Here '&|' means 'and/or'. This means that one of the sections
+  separated by '&|' must be present or both of them.
+
+
+  === Activation/Deactivation ===
+
+  The facility is an optional part of the MySQL server.
+  It is enabled in a debug server by default.
+
+      ./configure --enable-debug-sync
+
+  The Debug Sync Facility, when compiled in, is disabled by default. It
+  can be enabled by a mysqld command line option:
+
+      --debug-sync-timeout[=default_wait_timeout_value_in_seconds]
+
+  'default_wait_timeout_value_in_seconds' is the default timeout for the
+  WAIT_FOR action. If set to zero, the facility stays disabled.
+
+  The facility is enabled by default in the test suite, but can be
+  disabled with:
+
+      mysql-test-run.pl ... --debug-sync-timeout=0 ...
+
+  Likewise the default wait timeout can be set:
+
+      mysql-test-run.pl ... --debug-sync-timeout=10 ...
+
+  The command line option influences the readable value of the system
+  variable 'debug_sync'.
+
+  * If the facility is not compiled in, the system variable does not exist.
+
+  * If --debug-sync-timeout=0 the value of the variable reads as "OFF".
+
+  * Otherwise the value reads as "ON - current signal: " followed by the
+    current signal string, which can be empty.
+
+  The readable variable value is the same, regardless if read as global
+  or session value.
+
+  Setting the 'debug-sync' system variable requires 'SUPER' privilege.
+  You can never read back the string that you assigned to the variable,
+  unless you assign the value that the variable does already have. But
+  that would give a parse error. A syntactically correct string is
+  parsed into a debug sync action and stored apart from the variable value.
+
+
+  === Implementation ===
+
+  Pseudo code for a sync point:
+
+      #define DEBUG_SYNC(thd, sync_point_name)
+                if (unlikely(opt_debug_sync_timeout))
+                  debug_sync(thd, STRING_WITH_LEN(sync_point_name))
+
+  The sync point performs a binary search in a sorted array of actions
+  for this thread.
+
+  The SET DEBUG_SYNC statement adds a requested action to the array or
+  overwrites an existing action for the same sync point. When it adds a
+  new action, the array is sorted again.
+
+
+  === A typical synchronization pattern ===
+
+  There are quite a few places in MySQL, where we use a synchronization
+  pattern like this:
+
+  mysql_mutex_lock(&mutex);
+  thd->enter_cond(&condition_variable, &mutex, new_message);
+  #if defined(ENABLE_DEBUG_SYNC)
+  if (!thd->killed && !end_of_wait_condition)
+     DEBUG_SYNC(thd, "sync_point_name");
+  #endif
+  while (!thd->killed && !end_of_wait_condition)
+    mysql_cond_wait(&condition_variable, &mutex);
+  thd->exit_cond(old_message);
+
+  Here some explanations:
+
+  thd->enter_cond() is used to register the condition variable and the
+  mutex in thd->mysys_var. This is done to allow the thread to be
+  interrupted (killed) from its sleep. Another thread can find the
+  condition variable to signal and mutex to use for synchronization in
+  this thread's THD::mysys_var.
+
+  thd->enter_cond() requires the mutex to be acquired in advance.
+
+  thd->exit_cond() unregisters the condition variable and mutex and
+  releases the mutex.
+
+  If you want to have a Debug Sync point with the wait, please place it
+  behind enter_cond(). Only then you can safely decide, if the wait will
+  be taken. Also you will have THD::proc_info correct when the sync
+  point emits a signal. DEBUG_SYNC sets its own proc_info, but restores
+  the previous one before releasing its internal mutex. As soon as
+  another thread sees the signal, it does also see the proc_info from
+  before entering the sync point. In this case it will be "new_message",
+  which is associated with the wait that is to be synchronized.
+
+  In the example above, the wait condition is repeated before the sync
+  point. This is done to skip the sync point, if no wait takes place.
+  The sync point is before the loop (not inside the loop) to have it hit
+  once only. It is possible that the condition variable is signaled
+  multiple times without the wait condition to be true.
+
+  A bit off-topic: At some places, the loop is taken around the whole
+  synchronization pattern:
+
+  while (!thd->killed && !end_of_wait_condition)
+  {
+    mysql_mutex_lock(&mutex);
+    thd->enter_cond(&condition_variable, &mutex, new_message);
+    if (!thd->killed [&& !end_of_wait_condition])
+    {
+      [DEBUG_SYNC(thd, "sync_point_name");]
+      mysql_cond_wait(&condition_variable, &mutex);
+    }
+    thd->exit_cond(old_message);
+  }
+
+  Note that it is important to repeat the test for thd->killed after
+  enter_cond(). Otherwise the killing thread may kill this thread after
+  it tested thd->killed in the loop condition and before it registered
+  the condition variable and mutex in enter_cond(). In this case, the
+  killing thread does not know that this thread is going to wait on a
+  condition variable. It would just set THD::killed. But if we would not
+  test it again, we would go asleep though we are killed. If the killing
+  thread would kill us when we are after the second test, but still
+  before sleeping, we hold the mutex, which is registered in mysys_var.
+  The killing thread would try to acquire the mutex before signaling
+  the condition variable. Since the mutex is only released implicitly in
+  mysql_cond_wait(), the signaling happens at the right place. We
+  have a safe synchronization.
+
+  === Co-work with the DBUG facility ===
+
+  When running the MySQL test suite with the --debug-dbug command line
+  option, the Debug Sync Facility writes trace messages to the DBUG
+  trace. The following shell commands proved very useful in extracting
+  relevant information:
+
+  egrep 'query:|debug_sync_exec:' mysql-test/var/log/mysqld.1.trace
+
+  It shows all executed SQL statements and all actions executed by
+  synchronization points.
+
+  Sometimes it is also useful to see, which synchronization points have
+  been run through (hit) with or without executing actions. Then add
+  "|debug_sync_point:" to the egrep pattern.
+
+  === Further reading ===
+
+  For a discussion of other methods to synchronize threads see
+  http://forge.mysql.com/wiki/MySQL_Internals_Test_Synchronization
+
+  For complete syntax tests, functional tests, and examples see the test
+  case debug_sync.test.
+
+  See also http://forge.mysql.com/worklog/task.php?id=4259
+*/
+
+#ifndef MYSQL_ABI_CHECK
+#include <stdlib.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+extern void (*debug_sync_service)(MYSQL_THD, const char *, size_t);
+#else
+#define debug_sync_service debug_sync_C_callback_ptr
+extern void (*debug_sync_C_callback_ptr)(MYSQL_THD, const char *, size_t);
+#endif
+
+#ifdef ENABLED_DEBUG_SYNC
+#define DEBUG_SYNC(thd, name)                           \
+  do {                                                  \
+    if (debug_sync_service)                             \
+      debug_sync_service(thd, name, sizeof(name)-1);    \
+  } while(0)
+#else
+#define DEBUG_SYNC(thd,name)            do { } while(0)
+#endif
+
+/* compatibility macro */
+#define DEBUG_SYNC_C(name) DEBUG_SYNC(NULL, name)
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_DEBUG_SYNC_INCLUDED
+#endif

=== modified file 'include/mysql/services.h'
--- a/include/mysql/services.h	2012-03-13 20:55:56 +0000
+++ b/include/mysql/services.h	2012-03-28 17:26:00 +0000
@@ -23,8 +23,7 @@
 #include <mysql/service_thd_wait.h>
 #include <mysql/service_thread_scheduler.h>
 #include <mysql/service_progress_report.h>
-#include <mysql/service_logger.h>
-
+#include <mysql/service_debug_sync.h>
 
 #ifdef __cplusplus
 }

=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h	2012-02-21 21:15:44 +0000
+++ b/include/mysql_com.h	2012-03-26 10:33:49 +0000
@@ -435,10 +435,7 @@
   /* flush InnoDB buffers and other storage engines' buffers*/
   SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
   /* don't flush InnoDB buffers, flush other storage engines' buffers*/
-  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
-  /* Now the 2 levels of the KILL command */
-  SHUTDOWN_KILL_QUERY= 254,
-  SHUTDOWN_KILL_CONNECTION= 255
+  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1
 };
 
 /* Compatibility */

=== modified file 'include/service_versions.h'
--- a/include/service_versions.h	2012-03-13 20:55:56 +0000
+++ b/include/service_versions.h	2012-03-28 17:26:00 +0000
@@ -24,4 +24,4 @@
 #define VERSION_thd_wait        0x0100
 #define VERSION_my_thread_scheduler 0x0100
 #define VERSION_progress_report 0x0100
-#define VERSION_logger          0x0100
+#define VERSION_debug_sync      0x1000

=== modified file 'include/welcome_copyright_notice.h'
--- a/include/welcome_copyright_notice.h	2012-01-13 14:50:02 +0000
+++ b/include/welcome_copyright_notice.h	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'libmysql/CMakeLists.txt'
--- a/libmysql/CMakeLists.txt	2012-03-09 07:06:59 +0000
+++ b/libmysql/CMakeLists.txt	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates.
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates.
 # 
 # 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

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2012-03-19 08:35:32 +0000
+++ b/libmysqld/CMakeLists.txt	2012-04-12 03:44:52 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates.
 # 
 # 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
@@ -96,7 +96,6 @@
            ../sql/create_options.cc ../sql/rpl_utility.cc
            ../sql/rpl_reporting.cc
            ../sql/sql_expression_cache.cc
-           ../sql/sql_logger.cc
            ${GEN_SOURCES}
            ${MYSYS_LIBWRAP_SOURCE}
 )

=== modified file 'libmysqld/examples/CMakeLists.txt'
--- a/libmysqld/examples/CMakeLists.txt	2012-03-16 19:52:17 +0000
+++ b/libmysqld/examples/CMakeLists.txt	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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

=== modified file 'libservices/CMakeLists.txt'
--- a/libservices/CMakeLists.txt	2012-03-13 20:55:56 +0000
+++ b/libservices/CMakeLists.txt	2012-03-28 17:26:00 +0000
@@ -21,7 +21,7 @@
   thd_wait_service.c
   my_thread_scheduler_service.c
   progress_report_service.c
-  logger_service.c)
+  debug_sync_service.c)
 
 ADD_CONVENIENCE_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
 INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)

=== modified file 'libservices/HOWTO'
--- a/libservices/HOWTO	2011-06-30 15:46:53 +0000
+++ b/libservices/HOWTO	2012-03-28 17:26:00 +0000
@@ -34,19 +34,19 @@
   #endif
 
   extern struct foo_service_st {
-    int (*foo_func1_type)(...);  /* fix the prototype as appropriate */
-    void (*foo_func2_type)(...); /* fix the prototype as appropriate */
+    int (*foo_func1_ptr)(...);  /* fix the prototype as appropriate */
+    void (*foo_func2_ptr)(...); /* fix the prototype as appropriate */
   } *foo_service;
 
   #ifdef MYSQL_DYNAMIC_PLUGIN
 
-  #define foo_func1(...) foo_service->foo_func1_type(...)
-  #define foo_func2(...) foo_service->foo_func2_type(...)
+  #define foo_func1(...) foo_service->foo_func1_ptr(...)
+  #define foo_func2(...) foo_service->foo_func2_ptr(...)
 
   #else
 
-  int foo_func1_type(...);  /* fix the prototype as appropriate */
-  void foo_func2_type(...); /* fix the prototype as appropriate */
+  int foo_func1(...);  /* fix the prototype as appropriate */
+  void foo_func2(...); /* fix the prototype as appropriate */
 
   #endif
 
@@ -64,27 +64,26 @@
 it should also declare all the accompanying data structures, as necessary
 (e.g. thd_alloc_service declares MYSQL_LEX_STRING).
 
-3. add the new file to include/Makefile.am (pkginclude_HEADERS)
-4. add the new file to include/mysql/services.h
-5. increase the minor plugin ABI version in include/mysql/plugin.h
-   (MYSQL_PLUGIN_INTERFACE_VERSION = MYSQL_PLUGIN_INTERFACE_VERSION+1)
-6. add the version of your service to include/service_versions.h:
+3. add the new file to include/mysql/services.h
+4. increase the minor plugin ABI version in include/mysql/plugin.h
+   (MARIA_PLUGIN_INTERFACE_VERSION = MARIA_PLUGIN_INTERFACE_VERSION+1)
+5. add the version of your service to include/service_versions.h:
 ==================================================================
     #define VERSION_foo 0x0100
 ==================================================================
 
-7. create a new file libservices/foo_service.h using the following template:
+6. create a new file libservices/foo_service.h using the following template:
 ==================================================================
   /* GPL header */
   #include <service_versions.h>
   SERVICE_VERSION *foo_service= (void*)VERSION_foo;
 ==================================================================
 
-8. add the new file to libservices/CMakeLists.txt (MYSQLSERVICES_SOURCES)
-9. add the new file to libservices/Makefile.am (libmysqlservices_a_SOURCES)
-10. and finally, register your service for dynamic linking in
-    sql/sql_plugin_services.h
-10.1 fill in the service structure:
+7. add the new file to libservices/CMakeLists.txt (MYSQLSERVICES_SOURCES)
+8. Add all new files to repository (bzr add)
+9. and finally, register your service for dynamic linking in
+    sql/sql_plugin_services.h as follows:
+9.1 fill in the service structure:
 ==================================================================
   static struct foo_service_st foo_handler = {
     foo_func1,
@@ -92,7 +91,7 @@
   }
 ==================================================================
 
-10.2 and add it to the list of services
+9.2 and add it to the list of services
 
 ==================================================================
     { "foo_service", VERSION_foo, &foo_handler }

=== added file 'libservices/debug_sync_service.c'
--- a/libservices/debug_sync_service.c	1970-01-01 00:00:00 +0000
+++ b/libservices/debug_sync_service.c	2012-03-28 17:26:00 +0000
@@ -0,0 +1,18 @@
+/* Copyright (c) 2012, Monty Program Ab
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include <service_versions.h>
+SERVICE_VERSION *debug_sync_service= (void*)VERSION_debug_sync;

=== modified file 'mysql-test/CMakeLists.txt'
--- a/mysql-test/CMakeLists.txt	2011-09-29 08:42:23 +0000
+++ b/mysql-test/CMakeLists.txt	2012-02-16 09:48:16 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 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

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2012-03-09 07:06:59 +0000
+++ b/mysql-test/collections/default.experimental	2012-03-27 23:04:46 +0000
@@ -12,7 +12,6 @@
 main.sp @solaris                         # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.wait_timeout @solaris               # Bug#11758972 2010-04-26 alik wait_timeout fails on OpenSolaris
 
-rpl.rpl_heartbeat_basic                  # BUG#12403008 2011-04-27 sven fails sporadically
 rpl.rpl_innodb_bug28430                  # Bug#11754425
 rpl.rpl_row_sp011  @solaris              # Bug#11753919 2011-07-25 sven Several test cases fail on Solaris with error Thread stack overrun
 

=== modified file 'mysql-test/extra/rpl_tests/rpl_insert_id_pk.test'
--- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test	2012-03-27 23:04:46 +0000
@@ -10,6 +10,8 @@
 # We also check how the foreign_key_check variable is replicated
 
 -- source include/master-slave.inc
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
+
 #should work for both SBR and RBR
 
 create table t1(a int auto_increment, primary key(a));
@@ -50,6 +52,7 @@
 insert into t1 values (10);
 insert into t1 values (null),(null),(null);
 insert into t2 values (5,0);
+--disable_warnings ONCE
 insert into t2 (c) select * from t1 ORDER BY a;
 select * from t2 ORDER BY b;
 sync_slave_with_master;

=== modified file 'mysql-test/extra/rpl_tests/rpl_multi_update.test'
--- a/mysql-test/extra/rpl_tests/rpl_multi_update.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update.test	2012-02-09 17:58:33 +0000
@@ -1,5 +1,7 @@
 source include/master-slave.inc;
 
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
+
 eval CREATE TABLE t1 (
  a int unsigned not null auto_increment primary key,
  b int unsigned
@@ -11,6 +13,7 @@
 ) ENGINE=$engine_type;
 
 INSERT INTO t1 VALUES (NULL, 0);
+--disable_warnings ONCE
 INSERT INTO t1 SELECT NULL, 0 FROM t1;
 
 INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
@@ -18,6 +21,7 @@
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;
 
+--disable_warnings ONCE
 UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a;
 sync_slave_with_master;
 

=== modified file 'mysql-test/extra/rpl_tests/rpl_multi_update2.test'
--- a/mysql-test/extra/rpl_tests/rpl_multi_update2.test	2007-06-18 13:36:10 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update2.test	2012-02-09 17:58:33 +0000
@@ -17,6 +17,8 @@
 ) ENGINE=$engine_type;
 
 INSERT INTO t1 VALUES (NULL, 0);
+
+--disable_warnings ONCE
 INSERT INTO t1 SELECT NULL, 0 FROM t1;
 
 INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
@@ -24,6 +26,7 @@
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;
 
+--disable_warnings ONCE
 UPDATE t1, t2 SET t1.b = (t2.b+4) WHERE t1.a = t2.a;
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;

=== modified file 'mysql-test/extra/rpl_tests/rpl_multi_update3.test'
--- a/mysql-test/extra/rpl_tests/rpl_multi_update3.test	2007-06-18 13:36:10 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update3.test	2012-02-09 17:58:33 +0000
@@ -18,6 +18,8 @@
 ) ENGINE=$engine_type;
 
 INSERT INTO t1 VALUES (NULL, 0);
+
+--disable_warnings ONCE
 INSERT INTO t1 SELECT NULL, 0 FROM t1;
 
 INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
@@ -25,6 +27,7 @@
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;
 
+--disable_warnings ONCE
 UPDATE t2, (SELECT a FROM t1 ORDER BY a) AS t SET t2.b = t.a+5 ;
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;

=== modified file 'mysql-test/extra/rpl_tests/rpl_start_stop_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test	2012-03-09 07:06:59 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test	2012-03-27 23:04:46 +0000
@@ -182,7 +182,8 @@
 sync_slave_with_master;
 
 #
-# bug#3593869-64035 uninitialized event_coordinates instance crashes server
+# bug#3593869-64035 attempt to read a member of event_coordinates
+# referenced by NULL pointer crashes server.
 # Testing how out of valid range position value is handled with an error.
 #
 

=== modified file 'mysql-test/include/mtr_check.sql'
--- a/mysql-test/include/mtr_check.sql	2012-02-23 06:50:11 +0000
+++ b/mysql-test/include/mtr_check.sql	2012-04-07 13:58:46 +0000
@@ -1,4 +1,4 @@
--- Copyright (c) 2008, 2010, Oracle and/or its affiliates
+-- Copyright (c) 2008, 2011, Oracle and/or its affiliates
 --
 -- 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

=== modified file 'mysql-test/include/not_crashrep.inc'
--- a/mysql-test/include/not_crashrep.inc	2011-03-15 15:06:59 +0000
+++ b/mysql-test/include/not_crashrep.inc	2012-03-27 23:04:46 +0000
@@ -22,3 +22,9 @@
 if ($crashrep) {
   --skip CrashReporter would popup a window
 }
+
+# the test will crash mysqld. flush tables now to make sure that
+# system tables aren't corrupted by the crash
+--disable_query_log ONCE
+FLUSH TABLES;
+

=== modified file 'mysql-test/include/query_cache.inc'
--- a/mysql-test/include/query_cache.inc	2009-12-22 09:35:56 +0000
+++ b/mysql-test/include/query_cache.inc	2012-02-29 20:18:50 +0000
@@ -4,6 +4,9 @@
 #     $engine_type       -- storage engine to be tested
 #     $test_foreign_keys -- 0, skip foreign key tests
 #                        -- 1, do not skip foreign key tests
+#     $partitions_a      -- partition by column 'a'
+#     $partitions_id     -- partition by column 'id'
+#     $partitions_s1     -- partition by column 's1'
 # have to be set before sourcing this script.
 #
 # Last update:
@@ -19,47 +22,61 @@
 drop table if exists t1,t2,t3;
 --enable_warnings
 
+set @save_query_cache_size = @@global.query_cache_size;
+set GLOBAL query_cache_size = 1355776;
+
 #
 # Without auto_commit.
 #
 flush status;
 set autocommit=0;
-create table t1 (a int not null);
+eval create table t1 (a int not null)$partitions_a;
 insert into t1 values (1),(2),(3);
+--sorted_result
 select * from t1;
 show status like "Qcache_queries_in_cache";
 drop table t1;
 commit;
 set autocommit=1;
 begin;
-create table t1 (a int not null);
+eval create table t1 (a int not null)$partitions_a;
 insert into t1 values (1),(2),(3);
+--sorted_result
 select * from t1;
 show status like "Qcache_queries_in_cache";
 drop table t1;
 commit;
-create table t1 (a int not null);
-create table t2 (a int not null);
-create table t3 (a int not null);
+eval create table t1 (a int not null)$partitions_a;
+eval create table t2 (a int not null)$partitions_a;
+eval create table t3 (a int not null)$partitions_a;
 insert into t1 values (1),(2);
 insert into t2 values (1),(2);
 insert into t3 values (1),(2);
+--sorted_result
 select * from t1;
+--sorted_result
 select * from t2;
+--sorted_result
 select * from t3;
 show status like "Qcache_queries_in_cache";
 show status like "Qcache_hits";
 begin;
+--sorted_result
 select * from t1;
+--sorted_result
 select * from t2;
+--sorted_result
 select * from t3;
 show status like "Qcache_queries_in_cache";
 show status like "Qcache_hits";
 insert into t1 values (3);
 insert into t2 values (3);
 insert into t1 values (4);
+--sorted_result
 select * from t1;
+--sorted_result
 select * from t2;
+--sorted_result
 select * from t3;
 show status like "Qcache_queries_in_cache";
 show status like "Qcache_hits";
@@ -67,7 +84,7 @@
 show status like "Qcache_queries_in_cache";
 drop table t3,t2,t1;
 
-CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY  (id));
+eval CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id))$partitions_id;
 select count(*) from t1;
 insert into t1 (id) values (0);
 select count(*) from t1;
@@ -78,8 +95,6 @@
 #
 # one statement roll back inside transation
 #
-let $save_query_cache_size=`select @@global.query_cache_size`;
-set GLOBAL query_cache_size=1355776;
 CREATE TABLE t1 ( id int(10) NOT NULL auto_increment, a varchar(25) default NULL, PRIMARY KEY  (id), UNIQUE KEY a (a));
 CREATE TABLE t2 ( id int(10) NOT NULL auto_increment, b varchar(25) default NULL, PRIMARY KEY  (id), UNIQUE KEY b (b));
 CREATE TABLE t3 ( id int(10) NOT NULL auto_increment, t1_id int(10) NOT NULL default '0', t2_id int(10) NOT NULL default '0', state int(11) default NULL, PRIMARY KEY  (id), UNIQUE KEY t1_id (t1_id,t2_id), KEY t2_id (t2_id,t1_id), CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`), CONSTRAINT `t3_ibfk_2` FOREIGN KEY (`t2_id`) REFERENCES `t2` (`id`));
@@ -95,9 +110,6 @@
 commit;
 select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc;
 drop table t3,t2,t1;
---disable_query_log
-eval set GLOBAL query_cache_size=$save_query_cache_size;
---enable_query_log
 }
 
 #
@@ -118,7 +130,7 @@
 flush status;
 SET @@autocommit=1;
 eval SET SESSION STORAGE_ENGINE = $engine_type;
-CREATE TABLE t2 (s1 int, s2 varchar(1000), key(s1));
+eval CREATE TABLE t2 (s1 int, s2 varchar(1000), key(s1))$partitions_s1;
 INSERT INTO t2 VALUES (1,repeat('a',10)),(2,repeat('a',10)),(3,repeat('a',10)),(4,repeat('a',10));
 COMMIT;
 START TRANSACTION;
@@ -176,8 +188,8 @@
 show status like "Qcache_hits";
 
 # Final cleanup
-eval set GLOBAL query_cache_size=$save_query_cache_size;
 disconnect connection1;
 --source include/wait_until_disconnected.inc
 connection default;
+set @@global.query_cache_size = @save_query_cache_size;
 drop table t2;

=== added file 'mysql-test/include/show_slave_hosts.inc'
--- a/mysql-test/include/show_slave_hosts.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/show_slave_hosts.inc	2012-02-28 08:32:27 +0000
@@ -0,0 +1,3 @@
+--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
+--replace_regex /[0-9, a-f]{8}-[0-9, a-f]{4}-[0-9, a-f]{4}-[0-9, a-f]{4}-[0-9, a-f]{12}/SLAVE_UUID/
+SHOW SLAVE HOSTS;

=== modified file 'mysql-test/mysql-stress-test.pl'
--- a/mysql-test/mysql-stress-test.pl	2011-11-03 18:17:05 +0000
+++ b/mysql-test/mysql-stress-test.pl	2012-03-27 23:04:46 +0000
@@ -1,5 +1,21 @@
 #!/usr/bin/perl
 
+# Copyright (c) 2005, 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 Library 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
+# Library 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
+
 # ======================================================================
 #                     MySQL server stress test system 
 # ======================================================================

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2012-03-16 16:47:31 +0000
+++ b/mysql-test/mysql-test-run.pl	2012-04-07 13:58:46 +0000
@@ -1,8 +1,8 @@
 #!/usr/bin/perl
 # -*- cperl -*-
 
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates.
-# Copyright (c) 2009-2011 Monty Program Ab
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates.
+# Copyright (c) 2009, 2012, Monty Program Ab
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

=== added file 'mysql-test/r/bug13633383.result'
--- a/mysql-test/r/bug13633383.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/bug13633383.result	2012-02-14 07:11:28 +0000
@@ -0,0 +1,53 @@
+#
+# Bug#13633383 63183: SMALL SORT_BUFFER_SIZE CRASH IN MERGE_BUFFERS
+#
+CREATE TABLE t1 (
+`a` int(11) DEFAULT NULL,
+`col432` bit(8) DEFAULT NULL,
+`col433` multipoint DEFAULT NULL,
+`col434` polygon DEFAULT NULL,
+`col435` decimal(50,17) unsigned DEFAULT NULL,
+`col436` geometry NOT NULL,
+`col437` tinyblob NOT NULL,
+`col438` multipolygon DEFAULT NULL,
+`col439` mediumblob NOT NULL,
+`col440` tinyblob NOT NULL,
+`col441` double unsigned DEFAULT NULL
+);
+CREATE TABLE t2 (
+`a` multipoint DEFAULT NULL,
+`col460` date DEFAULT NULL,
+`col461` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+`col462` date NOT NULL,
+`col463` varbinary(89) NOT NULL,
+`col464` year(4) DEFAULT NULL,
+`col465` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+`col466` varchar(236) CHARACTER SET utf8 NOT NULL,
+`col467` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
+);
+CREATE TABLE t3 (
+`FTS_DOC_ID` bigint(20) unsigned NOT NULL,
+`col577` datetime DEFAULT NULL,
+`col579` bit(38) NOT NULL,
+`col580` varchar(93) NOT NULL,
+`col581` datetime DEFAULT NULL,
+`col583` multipolygon DEFAULT NULL,
+`col584` bit(47) NOT NULL
+);
+set session sort_buffer_size= 32768;
+select  col435
+from t3
+natural right outer join t1
+natural right outer join t2 a
+left outer join t2 b on 1
+group by
+repeat('a',10000) desc,
+repeat('a',10000)
+with rollup
+;
+col435
+0.00000000000000000
+0.00000000000000000
+0.00000000000000000
+set session sort_buffer_size= default;
+DROP TABLE  t1, t2, t3;

=== modified file 'mysql-test/r/cache_innodb.result'
--- a/mysql-test/r/cache_innodb.result	2010-10-06 09:01:24 +0000
+++ b/mysql-test/r/cache_innodb.result	2012-02-29 20:18:50 +0000
@@ -1,5 +1,7 @@
 SET SESSION STORAGE_ENGINE = InnoDB;
 drop table if exists t1,t2,t3;
+set @save_query_cache_size = @@global.query_cache_size;
+set GLOBAL query_cache_size = 1355776;
 flush status;
 set autocommit=0;
 create table t1 (a int not null);
@@ -100,7 +102,7 @@
 Variable_name	Value
 Qcache_queries_in_cache	2
 drop table t3,t2,t1;
-CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY  (id));
+CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id));
 select count(*) from t1;
 count(*)
 0
@@ -109,7 +111,6 @@
 count(*)
 1
 drop table t1;
-set GLOBAL query_cache_size=1355776;
 CREATE TABLE t1 ( id int(10) NOT NULL auto_increment, a varchar(25) default NULL, PRIMARY KEY  (id), UNIQUE KEY a (a));
 CREATE TABLE t2 ( id int(10) NOT NULL auto_increment, b varchar(25) default NULL, PRIMARY KEY  (id), UNIQUE KEY b (b));
 CREATE TABLE t3 ( id int(10) NOT NULL auto_increment, t1_id int(10) NOT NULL default '0', t2_id int(10) NOT NULL default '0', state int(11) default NULL, PRIMARY KEY  (id), UNIQUE KEY t1_id (t1_id,t2_id), KEY t2_id (t2_id,t1_id), CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`), CONSTRAINT `t3_ibfk_2` FOREIGN KEY (`t2_id`) REFERENCES `t2` (`id`));
@@ -218,7 +219,7 @@
 show status like "Qcache_hits";
 Variable_name	Value
 Qcache_hits	1
-set GLOBAL query_cache_size=1048576;
+set @@global.query_cache_size = @save_query_cache_size;
 drop table t2;
 CREATE TABLE t1 (a INT) ENGINE=InnoDB;
 BEGIN;

=== modified file 'mysql-test/r/csv.result'
--- a/mysql-test/r/csv.result	2011-10-19 19:45:18 +0000
+++ b/mysql-test/r/csv.result	2012-04-07 13:58:46 +0000
@@ -5415,6 +5415,19 @@
 
 
 DROP TABLE t1;
+CREATE TABLE t1 ( b TEXT NOT NULL ) ENGINE=MYISAM;
+INSERT INTO t1 VALUES ('x'),('y');
+CREATE TABLE t2 ( a VARCHAR(1) NOT NULL ) ENGINE=CSV;
+INSERT INTO t2 VALUES ('r'),('t');
+SELECT * FROM t2 ORDER BY a;
+a
+r
+t
+SELECT * FROM t1 LEFT JOIN t2 ON ( b = a );
+b	a
+x	NULL
+y	NULL
+drop table t1,t2;
 #
 # Test for the following cases
 # 1) integers and strings enclosed in quotes

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/r/ctype_ucs.result	2012-04-10 06:28:13 +0000
@@ -4157,5 +4157,16 @@
 SET sql_mode=default;
 SET NAMES latin1;
 #
+# Bug #13832953 	MY_STRNXFRM_UNICODE: ASSERTION `SRC' FAILED
+#
+CREATE TABLE t1 (c1 SET('','') CHARACTER SET ucs2);
+Warnings:
+Note	1291	Column 'c1' has duplicated value '' in SET
+INSERT INTO t1 VALUES ('');
+SELECT COALESCE(c1) FROM t1 ORDER BY 1;
+COALESCE(c1)
+
+DROP TABLE t1;
+#
 # End of 5.5 tests
 #

=== modified file 'mysql-test/r/derived_view.result'
--- a/mysql-test/r/derived_view.result	2012-03-17 08:26:58 +0000
+++ b/mysql-test/r/derived_view.result	2012-04-07 13:58:46 +0000
@@ -2007,5 +2007,44 @@
 SET SESSION optimizer_switch= @save_optimizer_switch;
 DROP VIEW v;
 DROP TABLE t1,t2;
+#
+# LP BUG#968720 crash due to converting to materialized and
+# natural join made only once
+#
+SET @save968720_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'derived_merge=on';
+CREATE TABLE t1 (a int, INDEX(a));
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (a int, INDEX(a));
+INSERT INTO t2 VALUES (1), (2);
+INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN
+t2 AS s2;
+SELECT * FROM t1;
+a
+1
+1
+DELETE FROM t1;
+INSERT INTO t1 VALUES (1);
+PREPARE stmt FROM "
+INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN
+t2 AS s2;
+";
+EXECUTE stmt;
+SELECT * FROM t1;
+a
+1
+1
+EXECUTE stmt;
+SELECT * FROM t1;
+a
+1
+1
+1
+1
+drop table t1,t2;
+set optimizer_switch=@save968720_optimizer_switch;
+#
+# end of 5.3 tests
+#
 set optimizer_switch=@exit_optimizer_switch;
 set join_cache_level=@exit_join_cache_level;

=== modified file 'mysql-test/r/error_simulation.result'
--- a/mysql-test/r/error_simulation.result	2012-01-13 14:50:02 +0000
+++ b/mysql-test/r/error_simulation.result	2012-03-23 19:49:47 +0000
@@ -13,7 +13,7 @@
 ('AAAAAAAAAH','AAAAAAAAAH'), ('AAAAAAAAAI','AAAAAAAAAI'),
 ('AAAAAAAAAJ','AAAAAAAAAJ'), ('AAAAAAAAAK','AAAAAAAAAK');
 set tmp_table_size=1024;
-set session debug_dbug="d,raise_error";
+set session debug_dbug="+d,raise_error";
 SELECT MAX(a) FROM t1 GROUP BY a,b;
 ERROR 23000: Can't write; duplicate key in table 'tmp_table'
 set tmp_table_size=default;

=== modified file 'mysql-test/r/filesort_debug.result'
--- a/mysql-test/r/filesort_debug.result	2011-12-15 21:07:58 +0000
+++ b/mysql-test/r/filesort_debug.result	2012-04-10 06:28:13 +0000
@@ -4,7 +4,7 @@
 #
 CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
 INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
-SET session debug_dbug= '+d,make_char_array_fail';
+SET session debug_dbug= '+d,make_sort_keys_alloc_fail';
 CALL mtr.add_suppression("Out of sort memory");
 SELECT * FROM t1 ORDER BY f1 ASC, f0;
 ERROR HY001: Out of sort memory, consider increasing server sort buffer size
@@ -31,3 +31,46 @@
 # connection default
 SET DEBUG_SYNC= "RESET";
 DROP TABLE t1;
+#
+# Bug#13832772 ASSERTION `THD->IS_ERROR() || KILL_ERRNO'
+#              FAILED IN FILESORT/MYSQL_DELETE
+#
+CREATE TABLE t1 (
+c1 BLOB,
+c2 TEXT,
+c3 TEXT,
+c4 TEXT,
+c5 TEXT,
+c6 TEXT,
+c7 TEXT,
+c8 BLOB,
+c9 TEXT,
+c19 TEXT,
+pk INT,
+c20 TEXT,
+c21 BLOB,
+c22 TEXT,
+c23 TEXT,
+c24 TEXT,
+c25 TEXT,
+c26 BLOB,
+c27 TEXT,
+c28 TEXT,
+primary key (pk)
+);
+CALL mtr.add_suppression("Out of sort memory");
+DELETE IGNORE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
+c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
+ERROR HY001: Out of sort memory, consider increasing server sort buffer size
+SHOW WARNINGS;
+Level	Code	Message
+Error	1038	Out of sort memory, consider increasing server sort buffer size
+Error	1028	Sort aborted: Out of sort memory, consider increasing server sort buffer size
+DELETE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
+c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
+ERROR HY001: Out of sort memory, consider increasing server sort buffer size
+SHOW WARNINGS;
+Level	Code	Message
+Error	1038	Out of sort memory, consider increasing server sort buffer size
+Error	1028	Sort aborted: Out of sort memory, consider increasing server sort buffer size
+DROP TABLE t1;

=== modified file 'mysql-test/r/func_in.result'
--- a/mysql-test/r/func_in.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/r/func_in.result	2012-04-10 06:28:13 +0000
@@ -778,4 +778,14 @@
 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1)
 1
 #
+#
+# Bug#13012483: EXPLAIN EXTENDED, PREPARED STATEMENT, CRASH IN CHECK_SIMPLE_EQUALITY
+#
+CREATE TABLE t1 (a INT);
+PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
+EXECUTE s;
+1
+DROP TABLE t1;
+# End of test  BUG#13012483
+#
 End of 5.1 tests

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/r/func_time.result	2012-04-07 13:58:46 +0000
@@ -885,18 +885,12 @@
 select last_day('2005-00-00');
 last_day('2005-00-00')
 NULL
-Warnings:
-Warning	1292	Incorrect datetime value: '2005-00-00'
 select last_day('2005-00-01');
 last_day('2005-00-01')
 NULL
-Warnings:
-Warning	1292	Incorrect datetime value: '2005-00-01'
 select last_day('2005-01-00');
 last_day('2005-01-00')
-NULL
-Warnings:
-Warning	1292	Incorrect datetime value: '2005-01-00'
+2005-01-31
 select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
 monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
 monthname(str_to_date(null, '%m'))	monthname(str_to_date(null, '%m'))	monthname(str_to_date(1, '%m'))	monthname(str_to_date(0, '%m'))
@@ -1435,7 +1429,7 @@
 #
 DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5);
 Warnings:
-Warning	1292	Truncated incorrect date value: '0000-00-00'
+Warning	1292	Incorrect datetime value: '0'
 #
 # BUG#13458237 INCONSISTENT HANDLING OF INVALIDE DATES WITH ZERO DAY
 # SIMILAR TO '2009-10-00' 
@@ -1469,9 +1463,9 @@
 TO_DAYs(STR_TO_DATE('200910','%Y%m'));
 DATE('20091000')	2009-10-00
 STR_TO_DATE('200910','%Y%m')	2009-10-00
-LAST_DAY('2009-10-00')	NULL
-LAST_DAY(DATE('2009-10-00'))	NULL
-LAST_DAY(DATE'2009-10-00')	NULL
+LAST_DAY('2009-10-00')	2009-10-31
+LAST_DAY(DATE('2009-10-00'))	2009-10-31
+LAST_DAY(DATE'2009-10-00')	2009-10-31
 LAST_DAY(STR_TO_DATE('200910','%Y%m'))	2009-10-31
 WEEK('2009-10-00')	NULL
 WEEK(DATE('2009-10-00'))	NULL
@@ -1499,64 +1493,55 @@
 Message	Incorrect datetime value: '2009-10-00'
 Level	Warning
 Code	1292
-Message	Truncated incorrect date value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '200910' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '200910' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '200910' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '200910' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '2009-10-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '2009-10-00'
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '200910' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '200910' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '200910' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '200910' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '2009-10-00'
 Level	Warning
 Code	1292
 Message	Incorrect datetime value: '2009-10-00'
@@ -1592,9 +1577,9 @@
 TO_DAYs(STR_TO_DATE('000001','%Y%m'));
 DATE('00000100')	0000-01-00
 STR_TO_DATE('000001','%Y%m')	0000-01-00
-LAST_DAY('0000-01-00')	NULL
-LAST_DAY(DATE('0000-01-00'))	NULL
-LAST_DAY(DATE'0000-01-00')	NULL
+LAST_DAY('0000-01-00')	0000-01-31
+LAST_DAY(DATE('0000-01-00'))	0000-01-31
+LAST_DAY(DATE'0000-01-00')	0000-01-31
 LAST_DAY(STR_TO_DATE('000001','%Y%m'))	0000-01-31
 WEEK('0000-01-00')	NULL
 WEEK(DATE('0000-01-00'))	NULL
@@ -1622,64 +1607,55 @@
 Message	Incorrect datetime value: '0000-01-00'
 Level	Warning
 Code	1292
-Message	Truncated incorrect date value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '000001' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '000001' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '000001' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1411
-Message	Incorrect datetime value: '000001' for function str_to_date
-Level	Warning
-Code	1292
-Message	Incorrect datetime value: '0000-01-00'
-Level	Warning
-Code	1292
-Message	Truncated incorrect date value: '0000-01-00'
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '000001' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '000001' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '000001' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1411
+Message	Incorrect datetime value: '000001' for function str_to_date
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
+Level	Warning
+Code	1292
+Message	Incorrect datetime value: '0000-01-00'
 Level	Warning
 Code	1292
 Message	Incorrect datetime value: '0000-01-00'
@@ -1912,7 +1888,7 @@
 timestampadd(week, 1, date("0000-00-00"))
 NULL
 Warnings:
-Warning	1292	Truncated incorrect date value: '0000-00-00'
+Warning	1292	Incorrect datetime value: '0000-00-00'
 drop table t1;
 create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
 insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');

=== modified file 'mysql-test/r/innodb_ext_key.result'
--- a/mysql-test/r/innodb_ext_key.result	2012-03-02 23:03:20 +0000
+++ b/mysql-test/r/innodb_ext_key.result	2012-03-28 18:25:31 +0000
@@ -681,9 +681,9 @@
 WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t	index	a,b	b	7	NULL	10	Using index
-1	PRIMARY	t1	ref	b	b	3	test.t.b	2	Using index; FirstMatch(t)
+1	PRIMARY	t1	ref	b	b	3	test.t.b	2	Using index
+1	PRIMARY	t2	index	NULL	PRIMARY	4	NULL	11	Using index; FirstMatch(t)
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t.a	1	Using index
-1	PRIMARY	t2	index	NULL	PRIMARY	4	NULL	11	Using index; FirstMatch(t2)
 SELECT a FROM t1 AS t, t2 
 WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
 a
@@ -694,9 +694,9 @@
 WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t	index	a,b	b	7	NULL	10	Using index
-1	PRIMARY	t1	ref	b	b	3	test.t.b	2	Using index; FirstMatch(t)
+1	PRIMARY	t1	ref	b	b	3	test.t.b	2	Using index
+1	PRIMARY	t2	index	NULL	PRIMARY	4	NULL	11	Using index; FirstMatch(t)
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t.a	1	Using index
-1	PRIMARY	t2	index	NULL	PRIMARY	4	NULL	11	Using index; FirstMatch(t2)
 SELECT a FROM t1 AS t, t2 
 WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
 a

=== modified file 'mysql-test/r/join.result'
--- a/mysql-test/r/join.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/join.result	2012-03-24 17:21:22 +0000
@@ -1402,4 +1402,74 @@
 i
 01:01:01
 drop table t1,t2;
+#
+# BUG#954900: unexpected empty set due to an invalid build of key ref
+#                   
+CREATE TABLE t1 (dog_id int(10), birthday date, PRIMARY KEY (dog_id,birthday));
+INSERT INTO t1 VALUES (5918,'2004-07-22');
+CREATE TABLE t2 (dog_id int(10) unsigned, t_id char(1), birthday date, a_id int(10),
+PRIMARY KEY (dog_id,t_id,birthday,a_id));
+INSERT INTO t2 VALUES 
+(5918,'N','2004-07-22',5216551), (5918,'N','2004-07-22',5223640),
+(5918,'N','2004-07-22',5389491), (5918,'N','2004-07-22',5749434),
+(5918,'N','2004-07-22',5992424), (5922,'N','2005-06-30',5076957),
+(5924,'N','2000-08-11',20264), (5924,'N','2000-08-11',64251),
+(5924,'N','2000-08-11',74748), (5924,'N','2000-08-11',87590),
+(5924,'N','2000-08-11',104695), (5924,'N','2000-08-11',133136),
+(5924,'N','2000-08-11',5027806), (5924,'N','2000-08-11',5076957),
+(5924,'N','2000-08-11',5166821), (5924,'N','2000-08-11',5181896),
+(5924,'N','2000-08-11',5217908), (5924,'N','2000-08-11',5220812),
+(5924,'N','2000-08-11',5226473), (5924,'N','2000-08-11',5339111),
+(5925,'N','2005-02-10',19227), (5925,'N','2005-02-10',74529),
+(5925,'N','2005-02-10',74748), (5927,'N','2005-08-18',20264),
+(5927,'N','2005-08-18',58364), (5929,'N','2005-01-19',58364),
+(5935,'N','2006-03-10',19227), (5935,'N','2006-03-10',64251),
+(5935,'N','2006-03-10',5222400), (5935,'N','2006-03-10',5226473),
+(5936,'N','2004-10-29',5015032), (5937,'N','2002-04-05',11237),
+(5937,'N','2002-04-05',23911), (5937,'N','2002-04-05',112133),
+(5937,'N','2002-04-05',169721), (5937,'N','2002-04-05',170650),
+(5937,'N','2002-04-05',5014494), (5937,'N','2002-04-05',5166009),
+(5937,'N','2002-04-05',5181871), (5937,'N','2002-04-05',5213380),
+(5937,'N','2002-04-05',5214875), (5937,'N','2002-04-05',5895062),
+(5938,'N','2006-03-24',11237), (5938,'N','2006-03-24',19227),
+(5938,'N','2006-03-24',23911), (5938,'N','2006-03-24',58364),
+(5938,'N','2006-03-24',64251), (5938,'N','2006-03-24',111716),
+(5938,'N','2006-03-24',112702), (5938,'N','2006-03-24',133136),
+(5938,'N','2006-03-24',168718), (5938,'N','2006-03-24',5137136),
+(5938,'N','2006-03-24',5161519), (5938,'N','2006-03-24',5168120),
+(5938,'N','2006-03-24',5219034), (6234,'N','2006-06-02',103058),
+(6234,'N','2006-06-02',5146844), (6235,'N','2006-06-01',12900),
+(6235,'N','2006-06-01',20264), (6235,'N','2006-06-01',64251),
+(6235,'N','2006-06-01',75160), (6235,'N','2006-06-01',5014494),
+(6235,'N','2006-06-01',5181638), (6236,'N','2006-06-06',112595),
+(6236,'N','2006-06-06',5219601), (6236,'N','2006-06-06',5808374);
+CREATE TABLE t3 (dog_id int(10) unsigned);
+INSERT INTO t3 VALUES (5918);
+CREATE TABLE t4 (dog_id int(10), t_id char(1), birthday date, KEY (t_id));
+INSERT INTO t4 VALUES (5918,'N','2004-07-22'), (5919,'N','2004-07-20');
+CREATE TABLE t5 (dog_id int(10) unsigned, UNIQUE KEY (dog_id));
+INSERT INTO t5 VALUES (5918);
+SET @tmp_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch='index_condition_pushdown=off';
+EXPLAIN
+SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR
+WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND
+DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	DU	system	dog_id	NULL	NULL	NULL	1	
+1	SIMPLE	D	system	PRIMARY	NULL	NULL	NULL	1	
+1	SIMPLE	DSAR	system	NULL	NULL	NULL	NULL	1	
+1	SIMPLE	DT	range	t_id	t_id	2	NULL	2	Using where
+1	SIMPLE	DSA	ref	PRIMARY	PRIMARY	8	const,test.DT.t_id,test.D.birthday	1	Using index
+SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR
+WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND
+DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id;
+dog_id	dog_id	birthday	dog_id	t_id	birthday	dog_id	t_id	birthday	a_id	dog_id
+5918	5918	2004-07-22	5918	N	2004-07-22	5918	N	2004-07-22	5216551	5918
+5918	5918	2004-07-22	5918	N	2004-07-22	5918	N	2004-07-22	5223640	5918
+5918	5918	2004-07-22	5918	N	2004-07-22	5918	N	2004-07-22	5389491	5918
+5918	5918	2004-07-22	5918	N	2004-07-22	5918	N	2004-07-22	5749434	5918
+5918	5918	2004-07-22	5918	N	2004-07-22	5918	N	2004-07-22	5992424	5918
+SET optimizer_switch=@tmp_optimizer_switch;
+DROP TABLE t1,t2,t3,t4,t5;
 SET optimizer_switch=@save_optimizer_switch;

=== modified file 'mysql-test/r/join_cache.result'
--- a/mysql-test/r/join_cache.result	2012-03-06 19:46:07 +0000
+++ b/mysql-test/r/join_cache.result	2012-04-07 13:58:46 +0000
@@ -5261,8 +5261,8 @@
 EXPLAIN
 SELECT * FROM (SELECT t1.* FROM t1, t2) t WHERE t.a IN (SELECT * FROM t3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery3>	ALL	distinct_key	NULL	NULL	NULL	2	
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	
+1	PRIMARY	<subquery3>	eq_ref	distinct_key	distinct_key	4	func	1	
 3	MATERIALIZED	t3	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	2	
@@ -5480,8 +5480,8 @@
 SELECT * FROM t1 WHERE t1.i IN 
 (SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	2	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
 2	MATERIALIZED	t3	ALL	NULL	NULL	NULL	NULL	2	
 2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 SELECT * FROM t1 WHERE t1.i IN 
@@ -5494,8 +5494,8 @@
 SELECT * FROM t1 WHERE t1.i IN 
 (SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	2	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
 2	MATERIALIZED	t3	ALL	NULL	NULL	NULL	NULL	2	
 2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (flat, BNL join)
 SELECT * FROM t1 WHERE t1.i IN 

=== modified file 'mysql-test/r/join_outer.result'
--- a/mysql-test/r/join_outer.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/join_outer.result	2012-04-07 13:58:46 +0000
@@ -1648,6 +1648,64 @@
 NULL
 NULL
 DROP TABLE h,m,k;
+
+# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN
+# USED IN GROUP BY
+
+CREATE TABLE t1 (
+col_varchar_1024_latin1_key varchar(1024),
+col_varchar_10_latin1 varchar(10),
+col_int int(11),
+pk int(11)
+);
+CREATE TABLE t2 (
+col_int_key int(11),
+col_int int(11),
+pk int(11)
+);
+PREPARE prep_stmt_9846 FROM '
+SELECT alias1.pk AS field1 FROM
+t1 AS alias1
+LEFT JOIN
+( 
+  t2 AS alias2
+  RIGHT  JOIN
+  ( 
+    t2 AS alias3
+    JOIN t1 AS alias4
+    ON 1
+  )
+  ON 1
+)
+ON 1
+GROUP BY field1';
+execute prep_stmt_9846;
+field1
+execute prep_stmt_9846;
+field1
+drop table t1,t2;
+#
+# Bug #11765810	58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY
+# IS EXECUTED TWICE FROM P
+#
+CREATE TABLE t1 ( a INT ) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1);
+PREPARE prep_stmt FROM '
+ SELECT 1 AS f FROM t1
+ LEFT JOIN t1 t2
+  RIGHT JOIN t1 t3
+    JOIN t1 t4
+   ON 1
+  ON 1
+ ON 1
+ GROUP BY f';
+EXECUTE prep_stmt;
+f
+1
+EXECUTE prep_stmt;
+f
+1
+DROP TABLE t1;
 #
 # Bug#49600: outer join of two single-row tables with joining attributes
 #            evaluated to nulls

=== modified file 'mysql-test/r/join_outer_jcl6.result'
--- a/mysql-test/r/join_outer_jcl6.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/join_outer_jcl6.result	2012-04-07 13:58:46 +0000
@@ -1659,6 +1659,64 @@
 NULL
 NULL
 DROP TABLE h,m,k;
+
+# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN
+# USED IN GROUP BY
+
+CREATE TABLE t1 (
+col_varchar_1024_latin1_key varchar(1024),
+col_varchar_10_latin1 varchar(10),
+col_int int(11),
+pk int(11)
+);
+CREATE TABLE t2 (
+col_int_key int(11),
+col_int int(11),
+pk int(11)
+);
+PREPARE prep_stmt_9846 FROM '
+SELECT alias1.pk AS field1 FROM
+t1 AS alias1
+LEFT JOIN
+( 
+  t2 AS alias2
+  RIGHT  JOIN
+  ( 
+    t2 AS alias3
+    JOIN t1 AS alias4
+    ON 1
+  )
+  ON 1
+)
+ON 1
+GROUP BY field1';
+execute prep_stmt_9846;
+field1
+execute prep_stmt_9846;
+field1
+drop table t1,t2;
+#
+# Bug #11765810	58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY
+# IS EXECUTED TWICE FROM P
+#
+CREATE TABLE t1 ( a INT ) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1);
+PREPARE prep_stmt FROM '
+ SELECT 1 AS f FROM t1
+ LEFT JOIN t1 t2
+  RIGHT JOIN t1 t3
+    JOIN t1 t4
+   ON 1
+  ON 1
+ ON 1
+ GROUP BY f';
+EXECUTE prep_stmt;
+f
+1
+EXECUTE prep_stmt;
+f
+1
+DROP TABLE t1;
 #
 # Bug#49600: outer join of two single-row tables with joining attributes
 #            evaluated to nulls

=== modified file 'mysql-test/r/multi_update.result'
--- a/mysql-test/r/multi_update.result	2012-01-13 14:50:02 +0000
+++ b/mysql-test/r/multi_update.result	2012-03-27 23:04:46 +0000
@@ -1,3 +1,4 @@
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
 drop table if exists t1,t2,t3;
 drop database if exists mysqltest;
 drop view if exists v1;
@@ -605,7 +606,8 @@
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; UPDATE t2,t1 SET t2.a=t1.a+2
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
 delete from t1;
 delete from t2;
@@ -617,7 +619,8 @@
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; UPDATE t2,t1  SET t2.a=t2.b where t2.a=t1.a
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
 drop table t1, t2;
 set @@session.binlog_format= @sav_binlog_format;

=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2012-01-16 19:16:35 +0000
+++ b/mysql-test/r/myisam.result	2012-04-07 13:58:46 +0000
@@ -2494,6 +2494,19 @@
 test.t1	check	status	OK
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
+#
+# BUG 11756869 - 48848: MYISAMCHK DOING SORT RECOVER IN CERTAIN
+#                       CASES RESETS DATA POINTER TO SMAL
+#
+CREATE TABLE t1(a INT, KEY(a));
+ALTER TABLE t1 DISABLE KEYS;
+SET @before:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+FLUSH TABLES;
+SET @after:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+SELECT @before=@after;
+ at before=@after
+1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # Bug#51327 MyISAM table is automatically repaired on ALTER

=== modified file 'mysql-test/r/mysqld--help.result'
--- a/mysql-test/r/mysqld--help.result	2012-03-19 08:35:32 +0000
+++ b/mysql-test/r/mysqld--help.result	2012-04-12 03:44:52 +0000
@@ -1043,7 +1043,7 @@
 replicate-same-server-id FALSE
 report-host (No default value)
 report-password (No default value)
-report-port 3306
+report-port 0
 report-user (No default value)
 rowid-merge-buff-size 8388608
 rpl-recovery-rank 0

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2012-02-15 17:08:08 +0000
+++ b/mysql-test/r/partition.result	2012-04-07 13:58:46 +0000
@@ -2354,6 +2354,46 @@
 INSERT INTO t1 VALUES(0);
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
+#
+# Bug#13580775 ASSERTION FAILED: RECORD_LENGTH == M_RECORD_LENGTH,
+# FILE FILESORT_UTILS.CC
+#
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+c CHAR(1),
+d INT,
+KEY (c,d)
+) PARTITION BY KEY () PARTITIONS 1;
+INSERT INTO t1 VALUES (1,1,'a',1), (2,2,'a',1);
+SELECT 1 FROM t1 WHERE 1 IN
+(SELECT  group_concat(b)
+FROM t1
+WHERE c > geomfromtext('point(1 1)')
+GROUP BY b
+);
+1
+1
+1
+DROP TABLE t1;
+#
+# Bug#13011410 CRASH IN FILESORT CODE WITH GROUP BY/ROLLUP
+#
+CREATE TABLE t1 (
+a INT,
+b MEDIUMINT,
+c VARCHAR(300) CHARACTER SET hp8 COLLATE hp8_bin,
+PRIMARY KEY (a,c(299))) 
+ENGINE=myisam
+PARTITION BY LINEAR KEY () PARTITIONS 2;
+INSERT INTO t1 VALUES (1,2,'test'), (2,3,'hi'), (4,5,'bye');
+SELECT 1 FROM t1 WHERE b < SOME
+( SELECT 1 FROM t1 WHERE a >= 1
+GROUP BY b WITH ROLLUP
+HAVING b > geomfromtext("")
+);
+1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # BUG#55385: UPDATE statement throws an error, but still updates

=== added file 'mysql-test/r/partition_cache.result'
--- a/mysql-test/r/partition_cache.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/partition_cache.result	2012-02-29 20:18:50 +0000
@@ -0,0 +1,205 @@
+SET SESSION STORAGE_ENGINE = InnoDB;
+drop table if exists t1,t2,t3;
+set @save_query_cache_size = @@global.query_cache_size;
+set GLOBAL query_cache_size = 1355776;
+flush status;
+set autocommit=0;
+create table t1 (a int not null) PARTITION BY KEY (a) PARTITIONS 3;
+insert into t1 values (1),(2),(3);
+select * from t1;
+a
+1
+2
+3
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+drop table t1;
+commit;
+set autocommit=1;
+begin;
+create table t1 (a int not null) PARTITION BY KEY (a) PARTITIONS 3;
+insert into t1 values (1),(2),(3);
+select * from t1;
+a
+1
+2
+3
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+drop table t1;
+commit;
+create table t1 (a int not null) PARTITION BY KEY (a) PARTITIONS 3;
+create table t2 (a int not null) PARTITION BY KEY (a) PARTITIONS 3;
+create table t3 (a int not null) PARTITION BY KEY (a) PARTITIONS 3;
+insert into t1 values (1),(2);
+insert into t2 values (1),(2);
+insert into t3 values (1),(2);
+select * from t1;
+a
+1
+2
+select * from t2;
+a
+1
+2
+select * from t3;
+a
+1
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+begin;
+select * from t1;
+a
+1
+2
+select * from t2;
+a
+1
+2
+select * from t3;
+a
+1
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+insert into t1 values (3);
+insert into t2 values (3);
+insert into t1 values (4);
+select * from t1;
+a
+1
+2
+3
+4
+select * from t2;
+a
+1
+2
+3
+select * from t3;
+a
+1
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+commit;
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+drop table t3,t2,t1;
+CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) PARTITION BY HASH (id) PARTITIONS 3;
+select count(*) from t1;
+count(*)
+0
+insert into t1 (id) values (0);
+select count(*) from t1;
+count(*)
+1
+drop table t1;
+SET SESSION STORAGE_ENGINE = InnoDB;
+SET @@autocommit=1;
+connection default
+SHOW VARIABLES LIKE 'have_query_cache';
+Variable_name	Value
+have_query_cache	YES
+SET GLOBAL query_cache_size = 204800;
+flush status;
+SET @@autocommit=1;
+SET SESSION STORAGE_ENGINE = InnoDB;
+CREATE TABLE t2 (s1 int, s2 varchar(1000), key(s1)) PARTITION BY KEY (s1) PARTITIONS 3;
+INSERT INTO t2 VALUES (1,repeat('a',10)),(2,repeat('a',10)),(3,repeat('a',10)),(4,repeat('a',10));
+COMMIT;
+START TRANSACTION;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+0
+UPDATE t2 SET s2 = 'w' WHERE s1 = 3;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+1
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+connection connection1
+START TRANSACTION;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+0
+INSERT INTO t2 VALUES (5,'w');
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+1
+COMMIT;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+1
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+connection default
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+1
+COMMIT;
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+connection connection1
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+2
+START TRANSACTION;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+2
+INSERT INTO t2 VALUES (6,'w');
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+3
+connection default
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+2
+START TRANSACTION;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+2
+DELETE from t2 WHERE s1=3;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+1
+COMMIT;
+connection connection1
+COMMIT;
+SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
+count(*)
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+set @@global.query_cache_size = @save_query_cache_size;
+drop table t2;

=== modified file 'mysql-test/r/partition_error.result'
--- a/mysql-test/r/partition_error.result	2011-12-12 22:58:40 +0000
+++ b/mysql-test/r/partition_error.result	2012-03-27 23:04:46 +0000
@@ -1,5 +1,31 @@
 drop table if exists t1, t2;
 #
+# Bug#13608188 - 64038: CRASH IN HANDLER::HA_THD ON ALTER TABLE AFTER
+#                       REPAIR NON-EXISTING PARTITION
+#
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES (5,3),(5,6);
+ALTER TABLE t1 PARTITION BY KEY(b) PARTITIONS 3 ;
+ALTER TABLE t1 REPAIR PARTITION p1, p3;
+Table	Op	Msg_type	Msg_text
+test.t1	repair	error	Error in list of partitions to test.t1
+ALTER TABLE t1 ORDER BY b;
+DROP TABLE t1;
+#
+# Bug#13593865 - 64037: CRASH IN HA_PARTITION::CREATE_HANDLERS ON
+#                       ALTER TABLE AFTER DROP PARTITION
+#
+CREATE TABLE t1 (a INT)
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (0),
+PARTITION p1 VALUES LESS THAN MAXVALUE ) ;
+ALTER TABLE t1 DROP PARTITION p1;
+ALTER TABLE t1 ANALYZE PARTITION p0, p1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	error	Error in list of partitions to test.t1
+ALTER TABLE t1 COMMENT 'altered';
+DROP TABLE t1;
+#
 # Bug#57924: crash when creating partitioned table with
 #            multiple columns in the partition key
 #

=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2011-10-19 19:45:18 +0000
+++ b/mysql-test/r/partition_innodb.result	2012-04-10 06:28:13 +0000
@@ -2,6 +2,35 @@
 set session default_storage_engine='innodb';
 drop table if exists t1, t2;
 #
+# Bug#13694811: THE OPTIMIZER WRONGLY USES THE FIRST
+#               INNODB PARTITION STATISTICS
+#
+CREATE TABLE t1
+(a INT,
+b varchar(64),
+PRIMARY KEY (a),
+KEY (b))
+ENGINE = InnoDB
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 10
+(PARTITION pNeg VALUES LESS THAN (0),
+PARTITION p0 VALUES LESS THAN (1000),
+PARTITION pMAX VALUES LESS THAN MAXVALUE);
+# Only one row in the first 10 subpartitions
+INSERT INTO t1 VALUES (-1, 'Only negative pk value');
+INSERT INTO t1 VALUES (0, 'Mod Zero'), (1, 'One'), (2, 'Two'), (3, 'Three'),
+(10, 'Zero'), (11, 'Mod One'), (12, 'Mod Two'), (13, 'Mod Three'),
+(20, '0'), (21, '1'), (22, '2'), (23, '3'),
+(4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9');
+INSERT INTO t1 SELECT a + 30, b FROM t1 WHERE a >= 0;
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+EXPLAIN SELECT b FROM t1 WHERE b between 'L' and 'N' AND a > -100;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY,b	b	67	NULL	18	Using where; Using index
+DROP TABLE t1;
+#
 # Bug#56287: crash when using Partition datetime in sub in query
 #
 CREATE TABLE t1
@@ -148,13 +177,13 @@
 ERROR HY000: Table has no partition for value 110
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	3	Using where
@@ -163,16 +192,16 @@
 1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 DROP TABLE t1;
 #
 # Bug#50104: Partitioned table with just 1 partion works with fk

=== modified file 'mysql-test/r/partition_pruning.result'
--- a/mysql-test/r/partition_pruning.result	2012-02-15 17:08:08 +0000
+++ b/mysql-test/r/partition_pruning.result	2012-04-10 06:28:13 +0000
@@ -18,7 +18,7 @@
 #	#	#	#	#	#	#	#	#	3	#
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-#	#	#	#	#	#	#	#	#	9	#
+#	#	#	#	#	#	#	#	#	10	#
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 #	#	#	#	#	#	#	#	#	3	#
@@ -105,7 +105,7 @@
 6
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,max	range	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
 SELECT * FROM t1 WHERE a <= 1;
 a
 -1
@@ -168,7 +168,7 @@
 6
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,max	range	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
 SELECT * FROM t1 WHERE a <= 7;
 a
 -1
@@ -182,7 +182,7 @@
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 7;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,max	range	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
 SELECT * FROM t1 WHERE a = 1;
 a
 1
@@ -424,7 +424,7 @@
 5
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,max	range	PRIMARY	PRIMARY	4	NULL	8	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
 SELECT * FROM t1 WHERE a <= 1;
 a
 -1
@@ -474,7 +474,7 @@
 5
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,max	range	PRIMARY	PRIMARY	4	NULL	8	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
 SELECT * FROM t1 WHERE a <= 6;
 a
 -1
@@ -487,7 +487,7 @@
 6
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,max	range	PRIMARY	PRIMARY	4	NULL	8	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
 SELECT * FROM t1 WHERE a = 1;
 a
 1
@@ -744,13 +744,13 @@
 1001-01-01
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	index	a	a	4	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	index	a	a	4	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL,p2001-01-01	range	a	a	4	NULL	3	Using where; Using index
@@ -759,26 +759,26 @@
 1	SIMPLE	t1	p1001-01-01	system	a	NULL	NULL	NULL	1	
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	index	a	a	4	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	index	a	a	4	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL	ref	a	a	4	const	1	Using index
 # Disabling warnings for the invalid date
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL,p2001-01-01	index	a	a	4	NULL	4	Using where; Using index
@@ -790,16 +790,16 @@
 1	SIMPLE	t1	pNULL	ref	a	a	4	const	1	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	index	a	a	4	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	index	a	a	4	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	index	a	a	4	NULL	6	Using where; Using index
 # test without index
 ALTER TABLE t1 DROP KEY a;
 SELECT * FROM t1 WHERE a < '1001-01-01';
@@ -1076,7 +1076,7 @@
 1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
@@ -1104,10 +1104,10 @@
 # Disabling warnings for the invalid date
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p2001-01-01,pNULL	index	a	a	4	NULL	4	Using where; Using index
@@ -1119,10 +1119,10 @@
 1	SIMPLE	t1	pNULL	ref	a	a	4	const	1	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL,p1001-01-01	index	a	a	4	NULL	4	Using where; Using index
@@ -1405,7 +1405,7 @@
 1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
@@ -1433,10 +1433,10 @@
 # Disabling warnings for the invalid date
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p2001-01-01,pNULL	index	a	a	4	NULL	4	Using where; Using index
@@ -1448,10 +1448,10 @@
 1	SIMPLE	t1	pNULL	ref	a	a	4	const	1	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL,p1001-01-01	index	a	a	4	NULL	4	Using where; Using index
@@ -2867,18 +2867,18 @@
 1	SIMPLE	t2	p0,p1,p2	ALL	NULL	NULL	NULL	NULL	510	Using where
 explain partitions select * from t2 where b = 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0,p1,p2,p3,p4	ref	b	b	5	const	76	
+1	SIMPLE	t2	p0,p1,p2,p3,p4	ref	b	b	5	const	96	
 explain extended select * from t2 where b = 6;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ref	b	b	5	const	76	100.00	
+1	SIMPLE	t2	ref	b	b	5	const	96	100.00	
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = 6)
 explain partitions select * from t2 where b = 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0,p1,p2,p3,p4	ref	b	b	5	const	76	
+1	SIMPLE	t2	p0,p1,p2,p3,p4	ref	b	b	5	const	96	
 explain extended select * from t2 where b in (1,3,5);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	40.66	Using where
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	51.65	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` in (1,3,5))
 explain partitions select * from t2 where b in (1,3,5);
@@ -2886,7 +2886,7 @@
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	b	NULL	NULL	NULL	910	Using where
 explain extended select * from t2 where b in (2,4,6);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	25.05	Using where
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	31.65	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` in (2,4,6))
 explain partitions select * from t2 where b in (2,4,6);
@@ -2894,7 +2894,7 @@
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	b	NULL	NULL	NULL	910	Using where
 explain extended select * from t2 where b in (7,8,9);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	36.70	Using where
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	19.12	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` in (7,8,9))
 explain partitions select * from t2 where b in (7,8,9);
@@ -2902,7 +2902,7 @@
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	b	NULL	NULL	NULL	910	Using where
 explain extended select * from t2 where b > 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	44.84	Using where
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	29.23	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` > 5)
 explain partitions select * from t2 where b > 5;
@@ -2910,7 +2910,7 @@
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	b	NULL	NULL	NULL	910	Using where
 explain extended select * from t2 where b > 5 and b < 8;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	22.09	Using where
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	28.13	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` > 5) and (`test`.`t2`.`b` < 8))
 explain partitions select * from t2 where b > 5 and b < 8;
@@ -2918,15 +2918,15 @@
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	b	NULL	NULL	NULL	910	Using where
 explain extended select * from t2 where b > 5 and b < 7;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	range	b	b	5	NULL	76	100.00	Using where
+1	SIMPLE	t2	range	b	b	5	NULL	96	100.00	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` > 5) and (`test`.`t2`.`b` < 7))
 explain partitions select * from t2 where b > 5 and b < 7;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0,p1,p2,p3,p4	range	b	b	5	NULL	76	Using where
+1	SIMPLE	t2	p0,p1,p2,p3,p4	range	b	b	5	NULL	96	Using where
 explain extended select * from t2 where b > 0 and b < 5;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	41.65	Using where
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	910	53.19	Using where
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` > 0) and (`test`.`t2`.`b` < 5))
 explain partitions select * from t2 where b > 0 and b < 5;
@@ -2960,10 +2960,10 @@
 delete from t2 where b = 7;
 show status like 'Handler_read_rnd_next';
 Variable_name	Value
-Handler_read_rnd_next	0
+Handler_read_rnd_next	915
 show status like 'Handler_read_key';
 Variable_name	Value
-Handler_read_key	5
+Handler_read_key	0
 flush status;
 delete from t2 where b > 5;
 show status like 'Handler_read_rnd_next';

=== modified file 'mysql-test/r/plugin.result'
--- a/mysql-test/r/plugin.result	2012-03-14 05:40:54 +0000
+++ b/mysql-test/r/plugin.result	2012-03-28 17:26:00 +0000
@@ -15,7 +15,7 @@
 PLUGIN_TYPE	STORAGE ENGINE
 PLUGIN_TYPE_VERSION	#
 PLUGIN_LIBRARY	ha_example.so
-PLUGIN_LIBRARY_VERSION	1.2
+PLUGIN_LIBRARY_VERSION	1.3
 PLUGIN_AUTHOR	Brian Aker, MySQL AB
 PLUGIN_DESCRIPTION	Example storage engine
 PLUGIN_LICENSE	GPL
@@ -28,7 +28,7 @@
 PLUGIN_TYPE	DAEMON
 PLUGIN_TYPE_VERSION	#
 PLUGIN_LIBRARY	ha_example.so
-PLUGIN_LIBRARY_VERSION	1.2
+PLUGIN_LIBRARY_VERSION	1.3
 PLUGIN_AUTHOR	Sergei Golubchik
 PLUGIN_DESCRIPTION	Unusable Daemon
 PLUGIN_LICENSE	GPL
@@ -57,7 +57,7 @@
 PLUGIN_TYPE	STORAGE ENGINE
 PLUGIN_TYPE_VERSION	#
 PLUGIN_LIBRARY	ha_example.so
-PLUGIN_LIBRARY_VERSION	1.2
+PLUGIN_LIBRARY_VERSION	1.3
 PLUGIN_AUTHOR	Brian Aker, MySQL AB
 PLUGIN_DESCRIPTION	Example storage engine
 PLUGIN_LICENSE	GPL

=== modified file 'mysql-test/r/ps.result'
--- a/mysql-test/r/ps.result	2012-02-15 17:08:08 +0000
+++ b/mysql-test/r/ps.result	2012-04-10 06:28:13 +0000
@@ -1,3 +1,4 @@
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
 drop table if exists t1,t2,t3,t4;
 drop database if exists client_test_db;
 create table t1
@@ -3754,6 +3755,109 @@
 1
 1
 2
+
+# Bug#13805127: Stored program cache produces wrong result in same THD
+
+PREPARE s1 FROM 
+"
+SELECT c1, t2.c2, count(c3)
+FROM
+  (
+  SELECT 3 as c2 FROM dual WHERE @x = 1
+  UNION
+  SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+  ) AS t1,
+  (
+  SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+  UNION
+  SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+  UNION
+  SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+  ) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2
+";
+
+SET @x = 1;
+SELECT c1, t2.c2, count(c3)
+FROM
+(
+SELECT 3 as c2 FROM dual WHERE @x = 1
+UNION
+SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+) AS t1,
+(
+SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+UNION
+SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+UNION
+SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2;
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+2012-03-01 01:00:00	3	1
+2012-03-01 02:00:00	3	1
+
+EXECUTE s1;
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+2012-03-01 01:00:00	3	1
+2012-03-01 02:00:00	3	1
+
+SET @x = 2;
+SELECT c1, t2.c2, count(c3)
+FROM
+(
+SELECT 3 as c2 FROM dual WHERE @x = 1
+UNION
+SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+) AS t1,
+(
+SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+UNION
+SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+UNION
+SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2;
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+
+EXECUTE s1;
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+
+SET @x = 1;
+SELECT c1, t2.c2, count(c3)
+FROM
+(
+SELECT 3 as c2 FROM dual WHERE @x = 1
+UNION
+SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+) AS t1,
+(
+SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+UNION
+SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+UNION
+SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2;
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+2012-03-01 01:00:00	3	1
+2012-03-01 02:00:00	3	1
+
+EXECUTE s1;
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+2012-03-01 01:00:00	3	1
+2012-03-01 02:00:00	3	1
+DEALLOCATE PREPARE s1;
 #
 # End of 5.5 tests.
 prepare stmt from "select date('2010-10-10') between '2010-09-09' and ?";

=== modified file 'mysql-test/r/range_vs_index_merge.result'
--- a/mysql-test/r/range_vs_index_merge.result	2011-11-21 13:16:16 +0000
+++ b/mysql-test/r/range_vs_index_merge.result	2012-03-21 00:03:28 +0000
@@ -1045,6 +1045,182 @@
 4030	Sandy	USA	101853
 4031	Athens-Clarke County	USA	101489
 4032	Cambridge	USA	101355
+set @save_optimizer_switch=@@optimizer_switch;
+CREATE INDEX CityName on City(Name);
+EXPLAIN SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	City	index_merge	Country,CountryPopulation,CountryName,CityName	CountryName,CityName	38,35	NULL	28	Using sort_union(CountryName,CityName); Using where
+SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+Name	Country	Population
+Addis Abeba	ETH	2495000
+Manila	PHL	1581082
+Jakarta	IDN	9604900
+Delhi	IND	7206704
+Bangalore	IND	2660088
+Teheran	IRN	6758845
+Roma	ITA	2643581
+Venezia	ITA	277305
+Tokyo	JPN	7980230
+Toronto	CAN	688275
+Vancouver	CAN	514008
+Peking	CHN	7472000
+Seoul	KOR	9981619
+Kaunas	LTU	412639
+Rabat	MAR	623457
+Tijuana	MEX	1212232
+Lagos	NGA	1518000
+Paris	FRA	2125246
+Dresden	DEU	476668
+Dakar	SEN	785071
+Basel	CHE	166700
+Praha	CZE	1181126
+Ankara	TUR	3038159
+Lugansk	UKR	469000
+Caracas	VEN	1975294
+Samara	RUS	1156100
+Seattle	USA	563374
+set optimizer_switch='index_merge=off';
+EXPLAIN SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	29	Using index condition; Using where
+SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+Name	Country	Population
+Toronto	CAN	688275
+Vancouver	CAN	514008
+Basel	CHE	166700
+Peking	CHN	7472000
+Praha	CZE	1181126
+Dresden	DEU	476668
+Addis Abeba	ETH	2495000
+Paris	FRA	2125246
+Jakarta	IDN	9604900
+Bangalore	IND	2660088
+Delhi	IND	7206704
+Teheran	IRN	6758845
+Roma	ITA	2643581
+Venezia	ITA	277305
+Tokyo	JPN	7980230
+Seoul	KOR	9981619
+Kaunas	LTU	412639
+Rabat	MAR	623457
+Tijuana	MEX	1212232
+Lagos	NGA	1518000
+Manila	PHL	1581082
+Samara	RUS	1156100
+Dakar	SEN	785071
+Ankara	TUR	3038159
+Lugansk	UKR	469000
+Seattle	USA	563374
+Caracas	VEN	1975294
+set optimizer_switch=@save_optimizer_switch;
 DROP DATABASE world;
 use test;
 CREATE TABLE t1 (

=== modified file 'mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff'
--- a/mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff	2012-03-01 16:04:57 +0000
+++ b/mysql-test/r/range_vs_index_merge_innodb,innodb_plugin.rdiff	2012-03-24 17:21:22 +0000
@@ -1,5 +1,5 @@
---- r/range_vs_index_merge_innodb.result	2012-02-23 15:57:49.000000000 +0100
-+++ r/range_vs_index_merge_innodb,innodb_plugin.reject	2012-02-23 19:46:02.000000000 +0100
+--- r/range_vs_index_merge_innodb.result	2012-03-24 17:12:02.124422000 +0100
++++ r/range_vs_index_merge_innodb,innodb_plugin.reject	2012-03-24 18:00:13.647902620 +0100
 @@ -50,14 +50,14 @@
  WHERE (Population >= 100000 OR Name LIKE 'P%') AND Country='CAN' OR
  (Population < 100000 OR Name Like 'T%') AND Country='ARG';
@@ -251,3 +251,21 @@
  SELECT * FROM City USE INDEX ()
  WHERE ((Population > 101000 AND Population < 11000) OR
  ID BETWEEN 3500 AND 3800) AND Country='USA'
+@@ -1077,7 +1077,7 @@
+ (Name='Samara' AND Country='RUS') OR  
+ (Name='Seattle' AND Country='USA');
+ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+-1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	27	Using index condition; Using where
++1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	27	Using where
+ SELECT Name, Country, Population FROM City WHERE
+ (Name='Manila' AND Country='PHL') OR
+ (Name='Addis Abeba' AND Country='ETH') OR          
+@@ -1164,7 +1164,7 @@
+ (Name='Samara' AND Country='RUS') OR  
+ (Name='Seattle' AND Country='USA');
+ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+-1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	27	Using index condition; Using where
++1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	27	Using where
+ SELECT Name, Country, Population FROM City WHERE
+ (Name='Manila' AND Country='PHL') OR
+ (Name='Addis Abeba' AND Country='ETH') OR          

=== modified file 'mysql-test/r/range_vs_index_merge_innodb.result'
--- a/mysql-test/r/range_vs_index_merge_innodb.result	2012-02-21 19:51:56 +0000
+++ b/mysql-test/r/range_vs_index_merge_innodb.result	2012-03-24 17:21:22 +0000
@@ -1046,6 +1046,182 @@
 4030	Sandy	USA	101853
 4031	Athens-Clarke County	USA	101489
 4032	Cambridge	USA	101355
+set @save_optimizer_switch=@@optimizer_switch;
+CREATE INDEX CityName on City(Name);
+EXPLAIN SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	27	Using index condition; Using where
+SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+Name	Country	Population
+Toronto	CAN	688275
+Vancouver	CAN	514008
+Basel	CHE	166700
+Peking	CHN	7472000
+Praha	CZE	1181126
+Dresden	DEU	476668
+Addis Abeba	ETH	2495000
+Paris	FRA	2125246
+Jakarta	IDN	9604900
+Bangalore	IND	2660088
+Delhi	IND	7206704
+Teheran	IRN	6758845
+Roma	ITA	2643581
+Venezia	ITA	277305
+Tokyo	JPN	7980230
+Seoul	KOR	9981619
+Kaunas	LTU	412639
+Rabat	MAR	623457
+Tijuana	MEX	1212232
+Lagos	NGA	1518000
+Manila	PHL	1581082
+Samara	RUS	1156100
+Dakar	SEN	785071
+Ankara	TUR	3038159
+Lugansk	UKR	469000
+Seattle	USA	563374
+Caracas	VEN	1975294
+set optimizer_switch='index_merge=off';
+EXPLAIN SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	City	range	Country,CountryPopulation,CountryName,CityName	CountryName	38	NULL	27	Using index condition; Using where
+SELECT Name, Country, Population FROM City WHERE
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA');
+Name	Country	Population
+Toronto	CAN	688275
+Vancouver	CAN	514008
+Basel	CHE	166700
+Peking	CHN	7472000
+Praha	CZE	1181126
+Dresden	DEU	476668
+Addis Abeba	ETH	2495000
+Paris	FRA	2125246
+Jakarta	IDN	9604900
+Bangalore	IND	2660088
+Delhi	IND	7206704
+Teheran	IRN	6758845
+Roma	ITA	2643581
+Venezia	ITA	277305
+Tokyo	JPN	7980230
+Seoul	KOR	9981619
+Kaunas	LTU	412639
+Rabat	MAR	623457
+Tijuana	MEX	1212232
+Lagos	NGA	1518000
+Manila	PHL	1581082
+Samara	RUS	1156100
+Dakar	SEN	785071
+Ankara	TUR	3038159
+Lugansk	UKR	469000
+Seattle	USA	563374
+Caracas	VEN	1975294
+set optimizer_switch=@save_optimizer_switch;
 DROP DATABASE world;
 use test;
 CREATE TABLE t1 (

=== modified file 'mysql-test/r/sp-bugs.result'
--- a/mysql-test/r/sp-bugs.result	2010-11-11 05:06:16 +0000
+++ b/mysql-test/r/sp-bugs.result	2012-03-28 08:05:08 +0000
@@ -111,4 +111,114 @@
 DROP TABLE db1.t1;
 DROP DATABASE db1;
 DROP DATABASE db2;
+USE test;
+#
+# Bug#13105873:valgrind warning:possible crash in foreign 
+# key handling on subsequent create table if not exists 
+#
+DROP DATABASE IF EXISTS testdb;
+CREATE DATABASE testdb;
+USE testdb;
+CREATE TABLE t1 (id1 INT PRIMARY KEY);
+CREATE PROCEDURE `p1`()
+BEGIN
+CREATE TABLE IF NOT EXISTS t2(id INT PRIMARY KEY,
+CONSTRAINT FK FOREIGN KEY (id) REFERENCES t1( id1 ));
+END$
+CALL p1();
+# below stmt should not return valgrind warnings
+CALL p1();
+Warnings:
+Note	1050	Table 't2' already exists
+DROP DATABASE testdb;
+USE test;
 End of 5.1 tests
+#
+# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
+#
+SET @@SQL_MODE = '';
+CREATE FUNCTION testf_bug11763507() RETURNS INT
+BEGIN
+RETURN 0;
+END
+$
+CREATE PROCEDURE testp_bug11763507()
+BEGIN
+SELECT "PROCEDURE testp_bug11763507";
+END
+$
+SELECT testf_bug11763507();
+testf_bug11763507()
+0
+SELECT TESTF_bug11763507();
+TESTF_bug11763507()
+0
+SHOW FUNCTION STATUS LIKE  'testf_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testf_bug11763507	FUNCTION	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW FUNCTION STATUS WHERE NAME='testf_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testf_bug11763507	FUNCTION	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW FUNCTION STATUS LIKE  'TESTF_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testf_bug11763507	FUNCTION	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW FUNCTION STATUS WHERE NAME='TESTF_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testf_bug11763507	FUNCTION	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW CREATE FUNCTION testf_bug11763507;
+Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
+testf_bug11763507		CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11)
+BEGIN
+RETURN 0;
+END	latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW CREATE FUNCTION TESTF_bug11763507;
+Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
+testf_bug11763507		CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11)
+BEGIN
+RETURN 0;
+END	latin1	latin1_swedish_ci	latin1_swedish_ci
+CALL testp_bug11763507();
+PROCEDURE testp_bug11763507
+PROCEDURE testp_bug11763507
+CALL TESTP_bug11763507();
+PROCEDURE testp_bug11763507
+PROCEDURE testp_bug11763507
+SHOW PROCEDURE STATUS LIKE  'testp_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testp_bug11763507	PROCEDURE	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW PROCEDURE STATUS WHERE NAME='testp_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testp_bug11763507	PROCEDURE	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW PROCEDURE STATUS LIKE  'TESTP_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testp_bug11763507	PROCEDURE	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW PROCEDURE STATUS WHERE NAME='TESTP_bug11763507';
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+test	testp_bug11763507	PROCEDURE	root at localhost	#	#	DEFINER		latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW CREATE PROCEDURE testp_bug11763507;
+Procedure	sql_mode	Create Procedure	character_set_client	collation_connection	Database Collation
+testp_bug11763507		CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`()
+BEGIN
+SELECT "PROCEDURE testp_bug11763507";
+END	latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW CREATE PROCEDURE TESTP_bug11763507;
+Procedure	sql_mode	Create Procedure	character_set_client	collation_connection	Database Collation
+testp_bug11763507		CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`()
+BEGIN
+SELECT "PROCEDURE testp_bug11763507";
+END	latin1	latin1_swedish_ci	latin1_swedish_ci
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
+specific_name
+testf_bug11763507
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
+specific_name
+testf_bug11763507
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
+specific_name
+testf_bug11763507
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
+specific_name
+testf_bug11763507
+DROP PROCEDURE testp_bug11763507;
+DROP FUNCTION testf_bug11763507;
+#END OF BUG#11763507 test.

=== modified file 'mysql-test/r/sp-code.result'
--- a/mysql-test/r/sp-code.result	2011-12-15 21:07:58 +0000
+++ b/mysql-test/r/sp-code.result	2012-04-10 06:28:13 +0000
@@ -945,3 +945,32 @@
 SET SESSION debug_dbug="-d,bug23032_emit_warning";
 DROP PROCEDURE p1;
 DROP TABLE t1;
+#
+# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
+#
+SET @@SQL_MODE = '';
+CREATE FUNCTION testf_bug11763507() RETURNS INT
+BEGIN
+RETURN 0;
+END
+$
+CREATE PROCEDURE testp_bug11763507()
+BEGIN
+SELECT "PROCEDURE testp_bug11763507";
+END
+$
+SHOW FUNCTION CODE testf_bug11763507;
+Pos	Instruction
+0	freturn 3 0
+SHOW FUNCTION CODE TESTF_bug11763507;
+Pos	Instruction
+0	freturn 3 0
+SHOW PROCEDURE CODE testp_bug11763507;
+Pos	Instruction
+0	stmt 0 "SELECT "PROCEDURE testp_bug11763507""
+SHOW PROCEDURE CODE TESTP_bug11763507;
+Pos	Instruction
+0	stmt 0 "SELECT "PROCEDURE testp_bug11763507""
+DROP PROCEDURE testp_bug11763507;
+DROP FUNCTION testf_bug11763507;
+#END OF BUG#11763507 test.

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2012-01-16 19:16:35 +0000
+++ b/mysql-test/r/sp.result	2012-04-10 06:28:13 +0000
@@ -7745,4 +7745,65 @@
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 DROP TABLE t1;
+
+# Bug#13805127: Stored program cache produces wrong result in same THD
+
+CREATE PROCEDURE p1(x INT UNSIGNED)
+BEGIN
+SELECT c1, t2.c2, count(c3)
+FROM
+(
+SELECT 3 as c2 FROM dual WHERE x = 1
+UNION
+SELECT 2       FROM dual WHERE x = 1 OR x = 2
+) AS t1,
+(
+SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+UNION
+SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+UNION
+SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2
+;
+END|
+
+CALL p1(1);
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+2012-03-01 01:00:00	3	1
+2012-03-01 02:00:00	3	1
+CALL p1(2);
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+CALL p1(1);
+c1	c2	count(c3)
+2012-03-01 01:00:00	2	1
+2012-03-01 01:00:00	3	1
+2012-03-01 02:00:00	3	1
+DROP PROCEDURE p1;
 # End of 5.5 test
+#
+# Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS
+#
+DROP FUNCTION IF EXISTS f1;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1();
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1();
+RETURN f1();
+END;
+END;
+RETURN 1;
+END $
+SELECT f1();
+f1()
+1
+Warnings:
+Error	1424	Recursive stored functions and triggers are not allowed.
+Error	1305	FUNCTION test.f1 does not exist
+DROP FUNCTION f1;

=== modified file 'mysql-test/r/sp_notembedded.result'
--- a/mysql-test/r/sp_notembedded.result	2011-07-02 20:12:12 +0000
+++ b/mysql-test/r/sp_notembedded.result	2012-04-10 06:28:13 +0000
@@ -258,4 +258,25 @@
 2
 # Switching to default connection.
 DROP DATABASE `my.db`;
+USE test;
 set @@global.concurrent_insert= @old_concurrent_insert;
+#
+# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
+#
+SET @@SQL_MODE = '';
+CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR 
+DO SELECT 1 $
+SHOW EVENTS LIKE 'teste_bug11763507';
+Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
+test	teste_bug11763507	root at localhost	SYSTEM	ONE TIME	#	#	#	#	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW EVENTS LIKE 'TESTE_bug11763507';
+Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
+test	teste_bug11763507	root at localhost	SYSTEM	ONE TIME	#	#	#	#	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW CREATE EVENT teste_bug11763507;
+Event	sql_mode	time_zone	Create Event	character_set_client	collation_connection	Database Collation
+teste_bug11763507		SYSTEM	#	latin1	latin1_swedish_ci	latin1_swedish_ci
+SHOW CREATE EVENT TESTE_bug11763507;
+Event	sql_mode	time_zone	Create Event	character_set_client	collation_connection	Database Collation
+teste_bug11763507		SYSTEM	#	latin1	latin1_swedish_ci	latin1_swedish_ci
+DROP EVENT teste_bug11763507;
+#END OF BUG#11763507 test.

=== modified file 'mysql-test/r/sql_mode.result'
--- a/mysql-test/r/sql_mode.result	2009-10-09 14:52:02 +0000
+++ b/mysql-test/r/sql_mode.result	2012-02-29 08:45:15 +0000
@@ -533,3 +533,207 @@
 Host	Db	User	Table_name	Column_name	Timestamp	Column_priv
 DROP TABLE t1;
 DROP TABLE t2;
+
+#
+# Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES
+# IGNORED AND BREAKS REPLICATION
+#
+DROP TABLE IF EXISTS test_table;
+DROP FUNCTION IF EXISTS test_function;
+CREATE TABLE test_table (c1 CHAR(50));
+SET @org_mode=@@sql_mode;
+SET @@sql_mode='';
+PREPARE insert_stmt FROM 'INSERT INTO test_table VALUES (?)';
+PREPARE update_stmt FROM 'UPDATE test_table SET c1= ? WHERE c1= ?';
+CREATE FUNCTION test_function(var CHAR(50)) RETURNS CHAR(50)
+BEGIN
+DECLARE char_val CHAR(50);
+SELECT c1 INTO char_val FROM test_table WHERE c1=var;
+RETURN char_val;
+END
+$
+SET @var1='abcd\'ef';
+SET @var2='abcd\"ef';
+SET @var3='abcd\bef';
+SET @var4='abcd\nef';
+SET @var5='abcd\ref';
+SET @var6='abcd\tef';
+SET @var7='abcd\\ef';
+SET @var8='abcd\%ef';
+SET @var9='abcd\_ef';
+SET @to_var1='wxyz\'ef';
+SET @to_var2='wxyz\"ef';
+SET @to_var3='wxyz\bef';
+SET @to_var4='wxyz\nef';
+SET @to_var5='wxyz\ref';
+SET @to_var6='wxyz\tef';
+SET @to_var7='wxyz\\ef';
+SET @to_var8='wxyz\%ef';
+SET @to_var9='wxyz\_ef';
+# STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+EXECUTE insert_stmt USING @var1;
+EXECUTE insert_stmt USING @var2;
+EXECUTE insert_stmt USING @var3;
+EXECUTE insert_stmt USING @var4;
+EXECUTE insert_stmt USING @var5;
+EXECUTE insert_stmt USING @var6;
+EXECUTE insert_stmt USING @var7;
+EXECUTE insert_stmt USING @var8;
+EXECUTE insert_stmt USING @var9;
+SELECT * FROM test_table;
+c1
+abcd'ef
+abcd"ef
+abcdef
+abcd
+ef
+abcd
ef
+abcd	ef
+abcd\ef
+abcd\%ef
+abcd\_ef
+EXECUTE update_stmt USING @to_var1, @var1;
+EXECUTE update_stmt USING @to_var2, @var2;
+EXECUTE update_stmt USING @to_var3, @var3;
+EXECUTE update_stmt USING @to_var4, @var4;
+EXECUTE update_stmt USING @to_var5, @var5;
+EXECUTE update_stmt USING @to_var6, @var6;
+EXECUTE update_stmt USING @to_var7, @var7;
+EXECUTE update_stmt USING @to_var8, @var8;
+EXECUTE update_stmt USING @to_var9, @var9;
+SELECT * FROM test_table;
+c1
+wxyz'ef
+wxyz"ef
+wxyzef
+wxyz
+ef
+wxyz
ef
+wxyz	ef
+wxyz\ef
+wxyz\%ef
+wxyz\_ef
+
+# END OF CASE - STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+# STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+select test_function(@to_var1);
+test_function(@to_var1)
+wxyz'ef
+SELECT test_function(@to_var2);
+test_function(@to_var2)
+wxyz"ef
+SELECT test_function(@to_var3);
+test_function(@to_var3)
+wxyzef
+SELECT test_function(@to_var4);
+test_function(@to_var4)
+wxyz
+ef
+SELECT test_function(@to_var5);
+test_function(@to_var5)
+wxyz
ef
+SELECT test_function(@to_var6);
+test_function(@to_var6)
+wxyz	ef
+SELECT test_function(@to_var7);
+test_function(@to_var7)
+wxyz\ef
+SELECT test_function(@to_var8);
+test_function(@to_var8)
+wxyz\%ef
+SELECT test_function(@to_var9);
+test_function(@to_var9)
+wxyz\_ef
+
+# END OF CASE - STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+DELETE FROM test_table;
+DROP FUNCTION test_function;
+SET @@sql_mode='NO_BACKSLASH_ESCAPES';
+CREATE FUNCTION test_function(var CHAR(50)) RETURNS CHAR(50)
+BEGIN
+DECLARE char_val CHAR(50);
+SELECT c1 INTO char_val FROM test_table WHERE c1=var;
+RETURN char_val;
+END
+$
+# STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+EXECUTE insert_stmt USING @var1;
+EXECUTE insert_stmt USING @var2;
+EXECUTE insert_stmt USING @var3;
+EXECUTE insert_stmt USING @var4;
+EXECUTE insert_stmt USING @var5;
+EXECUTE insert_stmt USING @var6;
+EXECUTE insert_stmt USING @var7;
+EXECUTE insert_stmt USING @var8;
+EXECUTE insert_stmt USING @var9;
+SELECT * FROM test_table;
+c1
+abcd'ef
+abcd"ef
+abcdef
+abcd
+ef
+abcd
ef
+abcd	ef
+abcd\ef
+abcd\%ef
+abcd\_ef
+EXECUTE update_stmt USING @to_var1, @var1;
+EXECUTE update_stmt USING @to_var2, @var2;
+EXECUTE update_stmt USING @to_var3, @var3;
+EXECUTE update_stmt USING @to_var4, @var4;
+EXECUTE update_stmt USING @to_var5, @var5;
+EXECUTE update_stmt USING @to_var6, @var6;
+EXECUTE update_stmt USING @to_var7, @var7;
+EXECUTE update_stmt USING @to_var8, @var8;
+EXECUTE update_stmt USING @to_var9, @var9;
+SELECT * FROM test_table;
+c1
+wxyz'ef
+wxyz"ef
+wxyzef
+wxyz
+ef
+wxyz
ef
+wxyz	ef
+wxyz\ef
+wxyz\%ef
+wxyz\_ef
+
+# END OF CASE - STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+# STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+select test_function(@to_var1);
+test_function(@to_var1)
+wxyz'ef
+SELECT test_function(@to_var2);
+test_function(@to_var2)
+wxyz"ef
+SELECT test_function(@to_var3);
+test_function(@to_var3)
+wxyzef
+SELECT test_function(@to_var4);
+test_function(@to_var4)
+wxyz
+ef
+SELECT test_function(@to_var5);
+test_function(@to_var5)
+wxyz
ef
+SELECT test_function(@to_var6);
+test_function(@to_var6)
+wxyz	ef
+SELECT test_function(@to_var7);
+test_function(@to_var7)
+wxyz\ef
+SELECT test_function(@to_var8);
+test_function(@to_var8)
+wxyz\%ef
+SELECT test_function(@to_var9);
+test_function(@to_var9)
+wxyz\_ef
+
+# END OF CASE - STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+DROP TABLE test_table;
+DROP FUNCTION test_function;
+SET @@sql_mode= @org_mode;
+
+#End of Test for Bug#12601974 

=== modified file 'mysql-test/r/strict.result'
--- a/mysql-test/r/strict.result	2011-10-19 19:45:18 +0000
+++ b/mysql-test/r/strict.result	2012-04-07 13:58:46 +0000
@@ -260,11 +260,11 @@
 INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
 INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
 INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE));
-ERROR 22007: Truncated incorrect date value: '2004-10-00'
+ERROR 22007: Incorrect datetime value: '2004-10-0'
 INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
-ERROR 22007: Truncated incorrect date value: '2004-00-10'
+ERROR 22007: Incorrect datetime value: '2004-0-10'
 INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
-ERROR 22007: Truncated incorrect date value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00'
 INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
 INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
 ERROR 22007: Incorrect datetime value: '2004-10-0 15:30'
@@ -287,13 +287,13 @@
 INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
 INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
 INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
-ERROR 22007: Truncated incorrect date value: '2004-10-00'
+ERROR 22007: Incorrect datetime value: '2004-10-0'
 INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
-ERROR 22007: Truncated incorrect date value: '2004-00-10'
+ERROR 22007: Incorrect datetime value: '2004-0-10'
 INSERT INTO t1 (col1) VALUES('2004-0-10');
 ERROR 22007: Incorrect date value: '2004-0-10' for column 'col1' at row 1
 INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
-ERROR 22007: Truncated incorrect date value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00'
 INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
 INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
 ERROR 22007: Incorrect datetime value: '2004-10-0 15:30'
@@ -1137,9 +1137,9 @@
 insert into t1 values (0.0,0.0,0.0);
 ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1
 insert into t1 (col1) values (convert('0000-00-00',date));
-ERROR 22007: Truncated incorrect date value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00'
 insert into t1 (col1) values (cast('0000-00-00' as date));
-ERROR 22007: Truncated incorrect date value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00'
 set sql_mode='no_zero_date';
 insert into t1 values (0,0,0);
 Warnings:
@@ -1164,7 +1164,7 @@
 Warning	1264	Out of range value for column 'col1' at row 1
 insert ignore into t1 (col1) values (cast('0000-00-00' as date));
 Warnings:
-Warning	1292	Truncated incorrect date value: '0000-00-00'
+Warning	1292	Incorrect datetime value: '0000-00-00'
 insert into t1 select * from t1;
 ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
 alter table t1 modify col1 datetime;

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2012-03-06 19:46:07 +0000
+++ b/mysql-test/r/subselect.result	2012-04-10 06:28:13 +0000
@@ -4645,6 +4645,55 @@
 SET SESSION sql_mode=@old_sql_mode;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+CREATE TABLE t1(a1 int);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2(a1 int);
+INSERT INTO t2 VALUES (3);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
+1
+1
+1
+SET SESSION sql_mode=@old_sql_mode;
+DROP TABLE t1, t2;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+create table t2(i int);
+insert into t2 values(0);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+CREATE VIEW v1 AS  
+SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
+;
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+);
+SELECT t1.pk
+FROM t1
+WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
+;
+pk
+SET SESSION sql_mode=@old_sql_mode;
+drop table t2, t1;
+drop view v1;
 End of 5.0 tests.
 create table t_out (subcase char(3),
 a1 char(2), b1 char(2), c1 char(2));
@@ -5595,8 +5644,8 @@
 FROM it2,it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	ot1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	24	Using where
-1	PRIMARY	ot4	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	ot4	ALL	NULL	NULL	NULL	NULL	8	Using join buffer (flat, BNL join)
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	8	func,func	1	
 2	MATERIALIZED	it2	ALL	NULL	NULL	NULL	NULL	4	
 2	MATERIALIZED	it3	ALL	NULL	NULL	NULL	NULL	6	Using join buffer (flat, BNL join)
 DROP TABLE IF EXISTS ot1, ot4, it2, it3;

=== modified file 'mysql-test/r/subselect3.result'
--- a/mysql-test/r/subselect3.result	2012-02-15 17:08:08 +0000
+++ b/mysql-test/r/subselect3.result	2012-04-07 13:58:46 +0000
@@ -1144,9 +1144,9 @@
 explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
 and t4.pk=t1.c);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t1	range	kp1	kp1	5	NULL	48	Using index condition; Using where; LooseScan
-1	PRIMARY	t4	eq_ref	PRIMARY	PRIMARY	4	test.t1.c	1	Using index; FirstMatch(t1)
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where
+1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using where
+1	PRIMARY	t4	eq_ref	PRIMARY	PRIMARY	4	test.t1.c	1	Using index; FirstMatch(t3)
 drop table t1, t3, t4;
 set @@optimizer_switch=@save_optimizer_switch;
 create table t1 (a int) as select * from t0 where a < 5;
@@ -1155,11 +1155,11 @@
 set @@max_heap_table_size= 16384;
 explain select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	E	ALL	NULL	NULL	NULL	NULL	5	Start temporary
-1	PRIMARY	A	ALL	NULL	NULL	NULL	NULL	10	Using join buffer (flat, BNL join)
+1	PRIMARY	A	ALL	NULL	NULL	NULL	NULL	10	
 1	PRIMARY	B	ALL	NULL	NULL	NULL	NULL	10	Using join buffer (flat, BNL join)
-1	PRIMARY	C	ALL	NULL	NULL	NULL	NULL	10	Using where; Using join buffer (flat, BNL join)
-1	PRIMARY	D	ALL	NULL	NULL	NULL	NULL	10	Using where; End temporary; Using join buffer (flat, BNL join)
+1	PRIMARY	E	ALL	NULL	NULL	NULL	NULL	5	Start temporary; Using join buffer (flat, BNL join)
+1	PRIMARY	D	ALL	NULL	NULL	NULL	NULL	10	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	C	ALL	NULL	NULL	NULL	NULL	10	Using where; End temporary; Using join buffer (flat, BNL join)
 flush status;
 select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a);
 count(*)

=== modified file 'mysql-test/r/subselect3_jcl6.result'
--- a/mysql-test/r/subselect3_jcl6.result	2012-02-15 17:08:08 +0000
+++ b/mysql-test/r/subselect3_jcl6.result	2012-04-07 13:58:46 +0000
@@ -1154,9 +1154,9 @@
 explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
 and t4.pk=t1.c);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t1	range	kp1	kp1	5	NULL	48	Using index condition; Using where; LooseScan
-1	PRIMARY	t4	eq_ref	PRIMARY	PRIMARY	4	test.t1.c	1	Using index; FirstMatch(t1)
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where
+1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using where
+1	PRIMARY	t4	eq_ref	PRIMARY	PRIMARY	4	test.t1.c	1	Using index; FirstMatch(t3)
 drop table t1, t3, t4;
 set @@optimizer_switch=@save_optimizer_switch;
 create table t1 (a int) as select * from t0 where a < 5;
@@ -1165,11 +1165,11 @@
 set @@max_heap_table_size= 16384;
 explain select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	E	ALL	NULL	NULL	NULL	NULL	5	Using where; Start temporary
-1	PRIMARY	A	ALL	NULL	NULL	NULL	NULL	10	Using join buffer (flat, BNL join)
-1	PRIMARY	B	ALL	NULL	NULL	NULL	NULL	10	Using join buffer (incremental, BNL join)
-1	PRIMARY	C	ALL	NULL	NULL	NULL	NULL	10	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	D	hash_ALL	NULL	#hash#$hj	5	test.E.a	10	Using where; End temporary; Using join buffer (incremental, BNLH join)
+1	PRIMARY	A	ALL	NULL	NULL	NULL	NULL	10	
+1	PRIMARY	B	ALL	NULL	NULL	NULL	NULL	10	Using join buffer (flat, BNL join)
+1	PRIMARY	E	ALL	NULL	NULL	NULL	NULL	5	Using where; Start temporary; Using join buffer (incremental, BNL join)
+1	PRIMARY	D	hash_ALL	NULL	#hash#$hj	5	test.E.a	10	Using where; Using join buffer (incremental, BNLH join)
+1	PRIMARY	C	ALL	NULL	NULL	NULL	NULL	10	Using where; End temporary; Using join buffer (incremental, BNL join)
 flush status;
 select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a);
 count(*)

=== modified file 'mysql-test/r/subselect_no_mat.result'
--- a/mysql-test/r/subselect_no_mat.result	2012-03-06 19:46:07 +0000
+++ b/mysql-test/r/subselect_no_mat.result	2012-04-10 06:28:13 +0000
@@ -4647,6 +4647,55 @@
 SET SESSION sql_mode=@old_sql_mode;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+CREATE TABLE t1(a1 int);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2(a1 int);
+INSERT INTO t2 VALUES (3);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
+1
+1
+1
+SET SESSION sql_mode=@old_sql_mode;
+DROP TABLE t1, t2;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+create table t2(i int);
+insert into t2 values(0);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+CREATE VIEW v1 AS  
+SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
+;
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+);
+SELECT t1.pk
+FROM t1
+WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
+;
+pk
+SET SESSION sql_mode=@old_sql_mode;
+drop table t2, t1;
+drop view v1;
 End of 5.0 tests.
 create table t_out (subcase char(3),
 a1 char(2), b1 char(2), c1 char(2));
@@ -5597,9 +5646,9 @@
 FROM it2,it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	ot1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	it2	ALL	NULL	NULL	NULL	NULL	4	Using where; Start temporary; Using join buffer (flat, BNL join)
-1	PRIMARY	it3	ALL	NULL	NULL	NULL	NULL	6	Using join buffer (flat, BNL join)
-1	PRIMARY	ot4	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (flat, BNL join)
+1	PRIMARY	ot4	ALL	NULL	NULL	NULL	NULL	8	Using join buffer (flat, BNL join)
+1	PRIMARY	it2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	PRIMARY	it3	ALL	NULL	NULL	NULL	NULL	6	Using where; FirstMatch(ot4)
 DROP TABLE IF EXISTS ot1, ot4, it2, it3;
 #
 # Bug#729039: NULL keys used to evaluate subquery

=== modified file 'mysql-test/r/subselect_no_opts.result'
--- a/mysql-test/r/subselect_no_opts.result	2012-03-06 19:46:07 +0000
+++ b/mysql-test/r/subselect_no_opts.result	2012-04-10 06:28:13 +0000
@@ -4643,6 +4643,55 @@
 SET SESSION sql_mode=@old_sql_mode;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+CREATE TABLE t1(a1 int);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2(a1 int);
+INSERT INTO t2 VALUES (3);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
+1
+1
+1
+SET SESSION sql_mode=@old_sql_mode;
+DROP TABLE t1, t2;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+create table t2(i int);
+insert into t2 values(0);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+CREATE VIEW v1 AS  
+SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
+;
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+);
+SELECT t1.pk
+FROM t1
+WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
+;
+pk
+SET SESSION sql_mode=@old_sql_mode;
+drop table t2, t1;
+drop view v1;
 End of 5.0 tests.
 create table t_out (subcase char(3),
 a1 char(2), b1 char(2), c1 char(2));

=== modified file 'mysql-test/r/subselect_no_scache.result'
--- a/mysql-test/r/subselect_no_scache.result	2012-03-06 19:46:07 +0000
+++ b/mysql-test/r/subselect_no_scache.result	2012-04-10 06:28:13 +0000
@@ -4651,6 +4651,55 @@
 SET SESSION sql_mode=@old_sql_mode;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+CREATE TABLE t1(a1 int);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2(a1 int);
+INSERT INTO t2 VALUES (3);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
+1
+1
+1
+SET SESSION sql_mode=@old_sql_mode;
+DROP TABLE t1, t2;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+create table t2(i int);
+insert into t2 values(0);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+CREATE VIEW v1 AS  
+SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
+;
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+);
+SELECT t1.pk
+FROM t1
+WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
+;
+pk
+SET SESSION sql_mode=@old_sql_mode;
+drop table t2, t1;
+drop view v1;
 End of 5.0 tests.
 create table t_out (subcase char(3),
 a1 char(2), b1 char(2), c1 char(2));
@@ -5601,8 +5650,8 @@
 FROM it2,it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	ot1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	24	Using where
-1	PRIMARY	ot4	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	ot4	ALL	NULL	NULL	NULL	NULL	8	Using join buffer (flat, BNL join)
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	8	func,func	1	
 2	MATERIALIZED	it2	ALL	NULL	NULL	NULL	NULL	4	
 2	MATERIALIZED	it3	ALL	NULL	NULL	NULL	NULL	6	Using join buffer (flat, BNL join)
 DROP TABLE IF EXISTS ot1, ot4, it2, it3;

=== modified file 'mysql-test/r/subselect_no_semijoin.result'
--- a/mysql-test/r/subselect_no_semijoin.result	2012-03-06 19:46:07 +0000
+++ b/mysql-test/r/subselect_no_semijoin.result	2012-04-10 06:28:13 +0000
@@ -4643,6 +4643,55 @@
 SET SESSION sql_mode=@old_sql_mode;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+CREATE TABLE t1(a1 int);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2(a1 int);
+INSERT INTO t2 VALUES (3);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
+1
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
+1
+1
+1
+SET SESSION sql_mode=@old_sql_mode;
+DROP TABLE t1, t2;
+#
+# Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+#
+create table t2(i int);
+insert into t2 values(0);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+CREATE VIEW v1 AS  
+SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
+;
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY col_varchar_key (col_varchar_key)
+);
+SELECT t1.pk
+FROM t1
+WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
+;
+pk
+SET SESSION sql_mode=@old_sql_mode;
+drop table t2, t1;
+drop view v1;
 End of 5.0 tests.
 create table t_out (subcase char(3),
 a1 char(2), b1 char(2), c1 char(2));

=== modified file 'mysql-test/r/subselect_sj.result'
--- a/mysql-test/r/subselect_sj.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/subselect_sj.result	2012-04-07 13:58:46 +0000
@@ -760,16 +760,16 @@
 select a from t1
 where a in (select c from t2 where d >= some(select e from t3 where b=e));
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	6	100.00	Start temporary
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	7	100.00	Using where; End temporary; Using join buffer (flat, BNL join)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	7	100.00	
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	6	100.00	Using where; FirstMatch(t1)
 3	DEPENDENT SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	4	100.00	Using where
 Warnings:
 Note	1276	Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
 show warnings;
 Level	Code	Message
 Note	1276	Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
 select a from t1
 where a in (select c from t2 where d >= some(select e from t3 where b=e));
 a
@@ -2168,10 +2168,10 @@
 explain
 SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t5	index	a	a	10	NULL	2	Using where; Using index; LooseScan
+1	PRIMARY	t5	index	a	a	10	NULL	2	Using index; Start temporary
 1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	3	
-1	PRIMARY	t2	ref	b	b	5	test.t5.b	2	Using where; FirstMatch(t5)
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	t2	ALL	b	NULL	NULL	NULL	10	Using where
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	15	Using where; End temporary; Using join buffer (flat, BNL join)
 SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b);
 a
 0
@@ -2250,11 +2250,11 @@
 FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2)
 LIMIT 100;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	20	
+1	PRIMARY	SQ3_alias1	ALL	NULL	NULL	NULL	NULL	20	Start temporary
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	SQ3_alias2	index	NULL	PRIMARY	4	NULL	20	Using index; End temporary
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (flat, BNL join)
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (flat, BNL join)
-1	PRIMARY	SQ3_alias1	ALL	NULL	NULL	NULL	NULL	20	Using where; Start temporary
-1	PRIMARY	SQ3_alias2	index	NULL	PRIMARY	4	NULL	20	Using index; End temporary
 2	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	20	
 create table t3 as
 SELECT 
@@ -2638,4 +2638,37 @@
 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (flat, BNL join)
 drop table t0,t1,t3;
 set optimizer_switch= @tmp_923246;
+#
+# BUG#952583: Server crashes in Item_field::fix_after_pullout on INSERT .. SELECT
+# 
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 ( b INT );
+INSERT INTO t2 VALUES (3),(4);
+INSERT INTO t1
+SELECT * FROM ( SELECT * FROM t1 ) AS alias
+WHERE a IN ( SELECT b FROM t2 );
+DROP TABLE t1, t2;
+#
+# BUG#952372: Server crashes on 2nd execution of PS in find_field_in_tables with semijoin+materialization
+#
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (2),(3);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 ( b VARCHAR(1) );
+INSERT INTO t2 VALUES ('v'),('v');
+PREPARE pstmt FROM
+'SELECT DISTINCT a FROM v1, t2
+   WHERE b IN ( SELECT MIN(b) FROM t2 )';
+EXECUTE pstmt;
+a
+2
+3
+EXECUTE pstmt;
+a
+2
+3
+DEALLOCATE PREPARE pstmt;
+DROP VIEW v1;
+DROP TABLE t1, t2;
 set optimizer_switch=@subselect_sj_tmp;

=== modified file 'mysql-test/r/subselect_sj2.result'
--- a/mysql-test/r/subselect_sj2.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/subselect_sj2.result	2012-04-07 13:58:46 +0000
@@ -49,9 +49,9 @@
 19	14
 explain select * from t2 where b in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
-1	PRIMARY	t2	ref	b	b	5	test.t1.a	2	
-2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	PRIMARY	t2	ALL	b	NULL	NULL	NULL	20	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	
 select * from t2 where b in (select a from t1);
 a	b
 1	1
@@ -69,9 +69,9 @@
 insert into t3 select a,a, a+100,a+100,a+100 from t0;
 explain select * from t3 where b in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
-1	PRIMARY	t3	ref	b	b	5	test.t1.a	1	
-2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	PRIMARY	t3	ALL	b	NULL	NULL	NULL	20	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	
 select * from t3 where b in (select a from t1);
 a	b	pk1	pk2	pk3
 1	1	1	1	1
@@ -95,13 +95,17 @@
 from t0 A, t0 B where B.a <5;
 explain select * from t3 where b in (select a from t0);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	10	
-1	PRIMARY	t3	ref	b	b	5	test.t0.a	1	
-2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	PRIMARY	t3	ALL	b	NULL	NULL	NULL	#	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	#	
+2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	#	
 select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
 a	b	pk1	pk2
 0	0	0	0
 1	1	1	1
+10	10	10	10
+11	11	11	11
+12	12	12	12
+13	13	13	13
 2	2	2	2
 3	3	3	3
 4	4	4	4
@@ -110,10 +114,6 @@
 7	7	7	7
 8	8	8	8
 9	9	9	9
-10	10	10	10
-11	11	11	11
-12	12	12	12
-13	13	13	13
 set join_buffer_size= @save_join_buffer_size;
 set max_heap_table_size= @save_max_heap_table_size;
 explain select * from t1 where a in (select b from t2);
@@ -745,8 +745,8 @@
 c1 in (select convert(c6,char(1)) from t2);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t2)
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	FirstMatch(t2)
 drop table t2, t3;
 #
@@ -900,5 +900,199 @@
 3	1	1
 4	1	1
 DROP TABLE t1,t2;
+# 
+# BUG#962667: Assertion `0' failed in QUICK_INDEX_SORT_SELECT::need_sorted_output() 
+#   with index_merge+index_merge_sort_union+loosescan+semijoin
+#
+CREATE TABLE t1 (
+a INT, b VARCHAR(1), c INT,
+KEY(a), KEY(b)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
+(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
+(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
+(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
+CREATE TABLE t2 (
+pk INT, d VARCHAR(1), e INT,
+PRIMARY KEY(pk), KEY(d,e)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
+(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
+(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
+(15,'g',6),(16,'x',7),(17,'f',8);
+explain
+SELECT * FROM t1 WHERE b IN (
+SELECT d FROM t2, t1
+WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	b	NULL	NULL	NULL	19	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t2	index	PRIMARY,d	d	9	NULL	17	Using where; Using index
+2	MATERIALIZED	t1	ref	a	a	5	test.t2.d	1	Using where; Using index
+SELECT * FROM t1 WHERE b IN (
+SELECT d FROM t2, t1
+WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+a	b	c
+DROP TABLE t1, t2;
+#
+# BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view
+#
+CREATE TABLE t1 (
+a VARCHAR(1),
+b VARCHAR(1) NOT NULL,
+KEY(a)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+('j','j'),('v','v'),('c','c'),('m','m'),('d','d'),
+('y','y'),('t','t'),('d','d'),('s','s'),('r','r'),
+('m','m'),('b','b'),('x','x'),('g','g'),('p','p'),
+('q','q'),('w','w'),('d','d'),('e','e');
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+# This query returned 6 rows instead of 19
+SELECT * FROM v1
+WHERE ( a, a ) IN (
+SELECT alias2.b, alias2.a
+FROM t1 AS alias1, t1 AS alias2
+WHERE alias2.b = alias1.a
+AND ( alias1.b >= alias1.a OR alias2.b = 'z' )
+);
+a	b
+b	b
+c	c
+d	d
+d	d
+d	d
+e	e
+g	g
+j	j
+m	m
+m	m
+p	p
+q	q
+r	r
+s	s
+t	t
+v	v
+w	w
+x	x
+y	y
+# Another testcase, without the VIEW:
+CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(1) NOT NULL, KEY(a)) ENGINE=InnoDB;
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 SELECT * FROM t1;
+EXPLAIN 
+SELECT * FROM t2 
+WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+WHERE 
+alias2.b = alias1.a AND 
+(alias1.b >= alias1.a OR alias2.b = 'z'));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	ALL	a	NULL	NULL	NULL	38	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	8	func,func	1	
+2	MATERIALIZED	alias1	ALL	a	NULL	NULL	NULL	19	Using where
+2	MATERIALIZED	alias2	ref	a	a	4	test.alias1.a	1	Using where
+SELECT * FROM t2 
+WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+WHERE 
+alias2.b = alias1.a AND 
+(alias1.b >= alias1.a OR alias2.b = 'z'));
+a	b
+b	b
+b	b
+c	c
+c	c
+d	d
+d	d
+d	d
+d	d
+d	d
+d	d
+e	e
+e	e
+g	g
+g	g
+j	j
+j	j
+m	m
+m	m
+m	m
+m	m
+p	p
+p	p
+q	q
+q	q
+r	r
+r	r
+s	s
+s	s
+t	t
+t	t
+v	v
+v	v
+w	w
+w	w
+x	x
+x	x
+y	y
+y	y
+DROP VIEW v1;
+DROP TABLE t1, t2;
+# 
+# BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR  
+#  (this is a regression caused by the fix for BUG#951937)
+CREATE TABLE t1 ( a INT, b INT, c INT, d INT );
+INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8);
+SELECT * FROM t1
+WHERE a = d AND ( b = 50 AND b = d OR a = c );
+a	b	c	d
+DROP TABLE t1;
+#
+# BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery
+#
+set @tmp_951283=@@optimizer_prune_level;
+SET optimizer_prune_level=0;
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(10),(11),(12),(13),(14),(15),(16),
+(17),(18),(19),(20),(21),(22),(23);
+CREATE TABLE t2 (
+b INT PRIMARY KEY,
+c VARCHAR(1),
+d VARCHAR(1),
+KEY(c)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,'j','j'),(2,'v','v'),(3,'c','c'),(4,'m','m'),
+(5,'d','d'),(6,'d','d'),(7,'y','y'),(8,'t','t'),
+(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
+(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
+(17,'q','q'),(18,'w','w'),(19,'d','d');
+EXPLAIN
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+WHERE alias5.b = alias4.b
+AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	alias3	ALL	PRIMARY	NULL	NULL	NULL	19	Using where
+1	PRIMARY	alias4	ref	PRIMARY,c	c	4	test.alias3.d	1	Using index
+1	PRIMARY	alias5	eq_ref	PRIMARY	PRIMARY	4	test.alias4.b	1	Using where; FirstMatch(alias3)
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	14	Using join buffer (flat, BNL join)
+1	PRIMARY	alias1	ALL	NULL	NULL	NULL	NULL	14	Using join buffer (flat, BNL join)
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+WHERE alias5.b = alias4.b
+AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+COUNT(*)
+3724
+set optimizer_prune_level=@tmp_951283;
+DROP TABLE t1,t2;
 # This must be the last in the file:
 set optimizer_switch=@subselect_sj2_tmp;

=== modified file 'mysql-test/r/subselect_sj2_jcl6,innodb_plugin.rdiff'
--- a/mysql-test/r/subselect_sj2_jcl6,innodb_plugin.rdiff	2012-02-07 15:22:36 +0000
+++ b/mysql-test/r/subselect_sj2_jcl6,innodb_plugin.rdiff	2012-04-07 13:58:46 +0000
@@ -1,20 +1,11 @@
---- r/subselect_sj2_jcl6.result	2012-01-11 18:05:14.000000000 +0100
-+++ r/subselect_sj2_jcl6.reject	2012-02-07 12:52:32.000000000 +0100
-@@ -81,7 +81,7 @@
- explain select * from t3 where b in (select a from t1);
- id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
- 1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
--1	PRIMARY	t3	ref	b	b	5	test.t1.a	1	Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-+1	PRIMARY	t3	ref	b	b	5	test.t1.a	1	
- 2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
- select * from t3 where b in (select a from t1);
- a	b	pk1	pk2	pk3
-@@ -107,7 +107,7 @@
- explain select * from t3 where b in (select a from t0);
- id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
- 1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	10	
--1	PRIMARY	t3	ref	b	b	5	test.t0.a	1	Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-+1	PRIMARY	t3	ref	b	b	5	test.t0.a	1	
- 2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
- select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
- a	b	pk1	pk2
+--- r/subselect_sj2_jcl6.result	2012-04-07 12:45:03.000000000 +0200
++++ r/subselect_sj2_jcl6,innodb_plugin.reject	2012-04-07 13:10:38.000000000 +0200
+@@ -1009,7 +1009,7 @@
+ 1	PRIMARY	t2	ALL	a	NULL	NULL	NULL	38	
+ 1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	8	func,func	1	
+ 2	MATERIALIZED	alias1	ALL	a	NULL	NULL	NULL	19	Using where
+-2	MATERIALIZED	alias2	ref	a	a	4	test.alias1.a	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
++2	MATERIALIZED	alias2	ref	a	a	4	test.alias1.a	1	Using where
+ SELECT * FROM t2 
+ WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+ WHERE 

=== modified file 'mysql-test/r/subselect_sj2_jcl6.result'
--- a/mysql-test/r/subselect_sj2_jcl6.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/subselect_sj2_jcl6.result	2012-04-07 13:58:46 +0000
@@ -60,9 +60,9 @@
 19	14
 explain select * from t2 where b in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
-1	PRIMARY	t2	ref	b	b	5	test.t1.a	2	Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	PRIMARY	t2	ALL	b	NULL	NULL	NULL	20	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	
 select * from t2 where b in (select a from t1);
 a	b
 1	1
@@ -80,9 +80,9 @@
 insert into t3 select a,a, a+100,a+100,a+100 from t0;
 explain select * from t3 where b in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
-1	PRIMARY	t3	ref	b	b	5	test.t1.a	1	Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	PRIMARY	t3	ALL	b	NULL	NULL	NULL	20	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	
 select * from t3 where b in (select a from t1);
 a	b	pk1	pk2	pk3
 1	1	1	1	1
@@ -106,13 +106,17 @@
 from t0 A, t0 B where B.a <5;
 explain select * from t3 where b in (select a from t0);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	10	
-1	PRIMARY	t3	ref	b	b	5	test.t0.a	1	Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	PRIMARY	t3	ALL	b	NULL	NULL	NULL	#	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	#	
+2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	#	
 select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
 a	b	pk1	pk2
 0	0	0	0
 1	1	1	1
+10	10	10	10
+11	11	11	11
+12	12	12	12
+13	13	13	13
 2	2	2	2
 3	3	3	3
 4	4	4	4
@@ -121,10 +125,6 @@
 7	7	7	7
 8	8	8	8
 9	9	9	9
-10	10	10	10
-11	11	11	11
-12	12	12	12
-13	13	13	13
 set join_buffer_size= @save_join_buffer_size;
 set max_heap_table_size= @save_max_heap_table_size;
 explain select * from t1 where a in (select b from t2);
@@ -759,9 +759,10 @@
 c1 in (select convert(c6,char(1)) from t2);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	<subquery3>	eq_ref	distinct_key	distinct_key	4	func	1	Using where
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using join buffer (flat, BNL join)
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (incremental, BNL join)
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	FirstMatch(t2); Using join buffer (incremental, BNL join)
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	FirstMatch((sj-nest)); Using join buffer (incremental, BNL join)
+3	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	1	
 drop table t2, t3;
 #
 # BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
@@ -914,6 +915,200 @@
 3	1	1
 4	1	1
 DROP TABLE t1,t2;
+# 
+# BUG#962667: Assertion `0' failed in QUICK_INDEX_SORT_SELECT::need_sorted_output() 
+#   with index_merge+index_merge_sort_union+loosescan+semijoin
+#
+CREATE TABLE t1 (
+a INT, b VARCHAR(1), c INT,
+KEY(a), KEY(b)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
+(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
+(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
+(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
+CREATE TABLE t2 (
+pk INT, d VARCHAR(1), e INT,
+PRIMARY KEY(pk), KEY(d,e)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
+(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
+(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
+(15,'g',6),(16,'x',7),(17,'f',8);
+explain
+SELECT * FROM t1 WHERE b IN (
+SELECT d FROM t2, t1
+WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	b	NULL	NULL	NULL	19	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t2	index	PRIMARY,d	d	9	NULL	17	Using where; Using index
+2	MATERIALIZED	t1	ref	a	a	5	test.t2.d	1	Using where; Using index
+SELECT * FROM t1 WHERE b IN (
+SELECT d FROM t2, t1
+WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+a	b	c
+DROP TABLE t1, t2;
+#
+# BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view
+#
+CREATE TABLE t1 (
+a VARCHAR(1),
+b VARCHAR(1) NOT NULL,
+KEY(a)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+('j','j'),('v','v'),('c','c'),('m','m'),('d','d'),
+('y','y'),('t','t'),('d','d'),('s','s'),('r','r'),
+('m','m'),('b','b'),('x','x'),('g','g'),('p','p'),
+('q','q'),('w','w'),('d','d'),('e','e');
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+# This query returned 6 rows instead of 19
+SELECT * FROM v1
+WHERE ( a, a ) IN (
+SELECT alias2.b, alias2.a
+FROM t1 AS alias1, t1 AS alias2
+WHERE alias2.b = alias1.a
+AND ( alias1.b >= alias1.a OR alias2.b = 'z' )
+);
+a	b
+b	b
+c	c
+d	d
+d	d
+d	d
+e	e
+g	g
+j	j
+m	m
+m	m
+p	p
+q	q
+r	r
+s	s
+t	t
+v	v
+w	w
+x	x
+y	y
+# Another testcase, without the VIEW:
+CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(1) NOT NULL, KEY(a)) ENGINE=InnoDB;
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 SELECT * FROM t1;
+EXPLAIN 
+SELECT * FROM t2 
+WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+WHERE 
+alias2.b = alias1.a AND 
+(alias1.b >= alias1.a OR alias2.b = 'z'));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	ALL	a	NULL	NULL	NULL	38	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	8	func,func	1	
+2	MATERIALIZED	alias1	ALL	a	NULL	NULL	NULL	19	Using where
+2	MATERIALIZED	alias2	ref	a	a	4	test.alias1.a	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+SELECT * FROM t2 
+WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+WHERE 
+alias2.b = alias1.a AND 
+(alias1.b >= alias1.a OR alias2.b = 'z'));
+a	b
+b	b
+b	b
+c	c
+c	c
+d	d
+d	d
+d	d
+d	d
+d	d
+d	d
+e	e
+e	e
+g	g
+g	g
+j	j
+j	j
+m	m
+m	m
+m	m
+m	m
+p	p
+p	p
+q	q
+q	q
+r	r
+r	r
+s	s
+s	s
+t	t
+t	t
+v	v
+v	v
+w	w
+w	w
+x	x
+x	x
+y	y
+y	y
+DROP VIEW v1;
+DROP TABLE t1, t2;
+# 
+# BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR  
+#  (this is a regression caused by the fix for BUG#951937)
+CREATE TABLE t1 ( a INT, b INT, c INT, d INT );
+INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8);
+SELECT * FROM t1
+WHERE a = d AND ( b = 50 AND b = d OR a = c );
+a	b	c	d
+DROP TABLE t1;
+#
+# BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery
+#
+set @tmp_951283=@@optimizer_prune_level;
+SET optimizer_prune_level=0;
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(10),(11),(12),(13),(14),(15),(16),
+(17),(18),(19),(20),(21),(22),(23);
+CREATE TABLE t2 (
+b INT PRIMARY KEY,
+c VARCHAR(1),
+d VARCHAR(1),
+KEY(c)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,'j','j'),(2,'v','v'),(3,'c','c'),(4,'m','m'),
+(5,'d','d'),(6,'d','d'),(7,'y','y'),(8,'t','t'),
+(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
+(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
+(17,'q','q'),(18,'w','w'),(19,'d','d');
+EXPLAIN
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+WHERE alias5.b = alias4.b
+AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	alias3	ALL	PRIMARY	NULL	NULL	NULL	19	Using where
+1	PRIMARY	alias4	ref	PRIMARY,c	c	4	test.alias3.d	1	Using index
+1	PRIMARY	alias5	eq_ref	PRIMARY	PRIMARY	4	test.alias4.b	1	Using where; FirstMatch(alias3)
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	14	Using join buffer (flat, BNL join)
+1	PRIMARY	alias1	ALL	NULL	NULL	NULL	NULL	14	Using join buffer (incremental, BNL join)
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+WHERE alias5.b = alias4.b
+AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+COUNT(*)
+3724
+set optimizer_prune_level=@tmp_951283;
+DROP TABLE t1,t2;
 # This must be the last in the file:
 set optimizer_switch=@subselect_sj2_tmp;
 #
@@ -935,9 +1130,9 @@
 WHERE c IN (SELECT t4.b FROM t4 JOIN t2);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	FirstMatch(t3)
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using join buffer (flat, BNL join)
+1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t3); Using join buffer (incremental, BNL join)
 1	PRIMARY	t1	ref	b	b	4	test.t3.b	1	Using index
-1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT t3.* FROM t1 JOIN t3 ON t3.b = t1.b
 WHERE c IN (SELECT t4.b FROM t4 JOIN t2);
 b	c
@@ -963,9 +1158,9 @@
 SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t2)
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	eq_ref	PRIMARY	PRIMARY	4	test.t4.b	1	Using where; FirstMatch(t1)
+1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t3	eq_ref	PRIMARY	PRIMARY	4	test.t4.b	1	Using where; FirstMatch(t2)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (flat, BNL join)
 SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk);
 pk	a	b
 1	6	8

=== modified file 'mysql-test/r/subselect_sj2_mat.result'
--- a/mysql-test/r/subselect_sj2_mat.result	2012-03-02 23:03:20 +0000
+++ b/mysql-test/r/subselect_sj2_mat.result	2012-04-07 13:58:46 +0000
@@ -51,9 +51,9 @@
 19	14
 explain select * from t2 where b in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
-1	PRIMARY	t2	ref	b	b	5	test.t1.a	2	
-2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	PRIMARY	t2	ALL	b	NULL	NULL	NULL	20	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	
 select * from t2 where b in (select a from t1);
 a	b
 1	1
@@ -71,9 +71,9 @@
 insert into t3 select a,a, a+100,a+100,a+100 from t0;
 explain select * from t3 where b in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	3	
-1	PRIMARY	t3	ref	b	b	5	test.t1.a	1	
-2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	PRIMARY	t3	ALL	b	NULL	NULL	NULL	20	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	3	
 select * from t3 where b in (select a from t1);
 a	b	pk1	pk2	pk3
 1	1	1	1	1
@@ -97,13 +97,17 @@
 from t0 A, t0 B where B.a <5;
 explain select * from t3 where b in (select a from t0);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	10	
-1	PRIMARY	t3	ref	b	b	5	test.t0.a	1	
-2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	PRIMARY	t3	ALL	b	NULL	NULL	NULL	#	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	#	
+2	MATERIALIZED	t0	ALL	NULL	NULL	NULL	NULL	#	
 select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
 a	b	pk1	pk2
 0	0	0	0
 1	1	1	1
+10	10	10	10
+11	11	11	11
+12	12	12	12
+13	13	13	13
 2	2	2	2
 3	3	3	3
 4	4	4	4
@@ -112,10 +116,6 @@
 7	7	7	7
 8	8	8	8
 9	9	9	9
-10	10	10	10
-11	11	11	11
-12	12	12	12
-13	13	13	13
 set join_buffer_size= @save_join_buffer_size;
 set max_heap_table_size= @save_max_heap_table_size;
 explain select * from t1 where a in (select b from t2);
@@ -747,8 +747,8 @@
 c1 in (select convert(c6,char(1)) from t2);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t2)
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	FirstMatch(t2)
 drop table t2, t3;
 #
@@ -902,6 +902,200 @@
 3	1	1
 4	1	1
 DROP TABLE t1,t2;
+# 
+# BUG#962667: Assertion `0' failed in QUICK_INDEX_SORT_SELECT::need_sorted_output() 
+#   with index_merge+index_merge_sort_union+loosescan+semijoin
+#
+CREATE TABLE t1 (
+a INT, b VARCHAR(1), c INT,
+KEY(a), KEY(b)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
+(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
+(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
+(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
+CREATE TABLE t2 (
+pk INT, d VARCHAR(1), e INT,
+PRIMARY KEY(pk), KEY(d,e)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
+(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
+(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
+(15,'g',6),(16,'x',7),(17,'f',8);
+explain
+SELECT * FROM t1 WHERE b IN (
+SELECT d FROM t2, t1
+WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	b	NULL	NULL	NULL	19	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
+2	MATERIALIZED	t2	index	PRIMARY,d	d	9	NULL	17	Using where; Using index
+2	MATERIALIZED	t1	ref	a	a	5	test.t2.d	1	Using where; Using index
+SELECT * FROM t1 WHERE b IN (
+SELECT d FROM t2, t1
+WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+a	b	c
+DROP TABLE t1, t2;
+#
+# BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view
+#
+CREATE TABLE t1 (
+a VARCHAR(1),
+b VARCHAR(1) NOT NULL,
+KEY(a)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+('j','j'),('v','v'),('c','c'),('m','m'),('d','d'),
+('y','y'),('t','t'),('d','d'),('s','s'),('r','r'),
+('m','m'),('b','b'),('x','x'),('g','g'),('p','p'),
+('q','q'),('w','w'),('d','d'),('e','e');
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+# This query returned 6 rows instead of 19
+SELECT * FROM v1
+WHERE ( a, a ) IN (
+SELECT alias2.b, alias2.a
+FROM t1 AS alias1, t1 AS alias2
+WHERE alias2.b = alias1.a
+AND ( alias1.b >= alias1.a OR alias2.b = 'z' )
+);
+a	b
+b	b
+c	c
+d	d
+d	d
+d	d
+e	e
+g	g
+j	j
+m	m
+m	m
+p	p
+q	q
+r	r
+s	s
+t	t
+v	v
+w	w
+x	x
+y	y
+# Another testcase, without the VIEW:
+CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(1) NOT NULL, KEY(a)) ENGINE=InnoDB;
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 SELECT * FROM t1;
+EXPLAIN 
+SELECT * FROM t2 
+WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+WHERE 
+alias2.b = alias1.a AND 
+(alias1.b >= alias1.a OR alias2.b = 'z'));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	ALL	a	NULL	NULL	NULL	38	
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	8	func,func	1	
+2	MATERIALIZED	alias1	ALL	a	NULL	NULL	NULL	19	Using where
+2	MATERIALIZED	alias2	ref	a	a	4	test.alias1.a	1	Using where
+SELECT * FROM t2 
+WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+WHERE 
+alias2.b = alias1.a AND 
+(alias1.b >= alias1.a OR alias2.b = 'z'));
+a	b
+b	b
+b	b
+c	c
+c	c
+d	d
+d	d
+d	d
+d	d
+d	d
+d	d
+e	e
+e	e
+g	g
+g	g
+j	j
+j	j
+m	m
+m	m
+m	m
+m	m
+p	p
+p	p
+q	q
+q	q
+r	r
+r	r
+s	s
+s	s
+t	t
+t	t
+v	v
+v	v
+w	w
+w	w
+x	x
+x	x
+y	y
+y	y
+DROP VIEW v1;
+DROP TABLE t1, t2;
+# 
+# BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR  
+#  (this is a regression caused by the fix for BUG#951937)
+CREATE TABLE t1 ( a INT, b INT, c INT, d INT );
+INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8);
+SELECT * FROM t1
+WHERE a = d AND ( b = 50 AND b = d OR a = c );
+a	b	c	d
+DROP TABLE t1;
+#
+# BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery
+#
+set @tmp_951283=@@optimizer_prune_level;
+SET optimizer_prune_level=0;
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(10),(11),(12),(13),(14),(15),(16),
+(17),(18),(19),(20),(21),(22),(23);
+CREATE TABLE t2 (
+b INT PRIMARY KEY,
+c VARCHAR(1),
+d VARCHAR(1),
+KEY(c)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,'j','j'),(2,'v','v'),(3,'c','c'),(4,'m','m'),
+(5,'d','d'),(6,'d','d'),(7,'y','y'),(8,'t','t'),
+(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
+(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
+(17,'q','q'),(18,'w','w'),(19,'d','d');
+EXPLAIN
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+WHERE alias5.b = alias4.b
+AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	alias3	ALL	PRIMARY	NULL	NULL	NULL	19	Using where
+1	PRIMARY	alias4	ref	PRIMARY,c	c	4	test.alias3.d	1	Using index
+1	PRIMARY	alias5	eq_ref	PRIMARY	PRIMARY	4	test.alias4.b	1	Using where; FirstMatch(alias3)
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	14	Using join buffer (flat, BNL join)
+1	PRIMARY	alias1	ALL	NULL	NULL	NULL	NULL	14	Using join buffer (flat, BNL join)
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+WHERE alias5.b = alias4.b
+AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+COUNT(*)
+3724
+set optimizer_prune_level=@tmp_951283;
+DROP TABLE t1,t2;
 # This must be the last in the file:
 set optimizer_switch=@subselect_sj2_tmp;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subselect_sj_jcl6.result'
--- a/mysql-test/r/subselect_sj_jcl6.result	2012-03-01 22:22:22 +0000
+++ b/mysql-test/r/subselect_sj_jcl6.result	2012-04-07 13:58:46 +0000
@@ -773,16 +773,16 @@
 select a from t1
 where a in (select c from t2 where d >= some(select e from t3 where b=e));
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	6	100.00	Start temporary
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	7	100.00	Using where; End temporary; Using join buffer (flat, BNL join)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	7	100.00	
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	6	100.00	Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
 3	DEPENDENT SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	4	100.00	Using where
 Warnings:
 Note	1276	Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
 show warnings;
 Level	Code	Message
 Note	1276	Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
 select a from t1
 where a in (select c from t2 where d >= some(select e from t3 where b=e));
 a
@@ -2182,10 +2182,10 @@
 explain
 SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t5	index	a	a	10	NULL	2	Using where; Using index; LooseScan
-1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	3	
-1	PRIMARY	t2	ref	b	b	5	test.t5.b	2	Using where; FirstMatch(t5)
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	t5	index	a	a	10	NULL	2	Using index; Start temporary
+1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	3	Using join buffer (flat, BNL join)
+1	PRIMARY	t2	ALL	b	NULL	NULL	NULL	10	Using where; Using join buffer (incremental, BNL join)
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	15	Using where; End temporary; Using join buffer (incremental, BNL join)
 SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b);
 a
 0
@@ -2264,11 +2264,11 @@
 FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2)
 LIMIT 100;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	20	
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (flat, BNL join)
+1	PRIMARY	SQ3_alias1	ALL	NULL	NULL	NULL	NULL	20	Start temporary
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (flat, BNL join)
+1	PRIMARY	SQ3_alias2	index	NULL	PRIMARY	4	NULL	20	Using index; End temporary; Using join buffer (incremental, BNL join)
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (incremental, BNL join)
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (incremental, BNL join)
-1	PRIMARY	SQ3_alias1	ALL	NULL	NULL	NULL	NULL	20	Using where; Start temporary; Using join buffer (incremental, BNL join)
-1	PRIMARY	SQ3_alias2	index	NULL	PRIMARY	4	NULL	20	Using index; End temporary; Using join buffer (incremental, BNL join)
 2	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	20	
 create table t3 as
 SELECT 
@@ -2652,6 +2652,39 @@
 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (flat, BNL join)
 drop table t0,t1,t3;
 set optimizer_switch= @tmp_923246;
+#
+# BUG#952583: Server crashes in Item_field::fix_after_pullout on INSERT .. SELECT
+# 
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 ( b INT );
+INSERT INTO t2 VALUES (3),(4);
+INSERT INTO t1
+SELECT * FROM ( SELECT * FROM t1 ) AS alias
+WHERE a IN ( SELECT b FROM t2 );
+DROP TABLE t1, t2;
+#
+# BUG#952372: Server crashes on 2nd execution of PS in find_field_in_tables with semijoin+materialization
+#
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (2),(3);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 ( b VARCHAR(1) );
+INSERT INTO t2 VALUES ('v'),('v');
+PREPARE pstmt FROM
+'SELECT DISTINCT a FROM v1, t2
+   WHERE b IN ( SELECT MIN(b) FROM t2 )';
+EXECUTE pstmt;
+a
+2
+3
+EXECUTE pstmt;
+a
+2
+3
+DEALLOCATE PREPARE pstmt;
+DROP VIEW v1;
+DROP TABLE t1, t2;
 set optimizer_switch=@subselect_sj_tmp;
 #
 # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
@@ -2859,8 +2892,8 @@
 SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
 GROUP BY a HAVING a != 'z';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	2	Using temporary; Using filesort
-1	PRIMARY	t	ref	idx_a	idx_a	4	test.t2.b	2	Using index
+1	PRIMARY	t	index	idx_a	idx_a	4	NULL	3	Using index; Using temporary; Using filesort
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
 2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 2	MATERIALIZED	t1	ref	idx_a	idx_a	4	test.t2.b	2	Using index
 SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
@@ -2873,8 +2906,8 @@
 SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
 GROUP BY a HAVING a != 'z';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	2	Using temporary; Using filesort
-1	PRIMARY	t	ref	idx_a	idx_a	4	test.t2.b	2	Using index
+1	PRIMARY	t	index	idx_a	idx_a	4	NULL	3	Using index; Using temporary; Using filesort
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	
 2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 2	MATERIALIZED	t1	ref	idx_a	idx_a	4	test.t2.b	2	Using index
 SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)

=== modified file 'mysql-test/r/subselect_sj_mat.result'
--- a/mysql-test/r/subselect_sj_mat.result	2012-03-17 08:26:58 +0000
+++ b/mysql-test/r/subselect_sj_mat.result	2012-04-07 13:58:46 +0000
@@ -505,15 +505,15 @@
 where (c1, c2) in (select b1, b2 from t2i where b2 > '0' or b2 = a2));
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary; End temporary; Using join buffer (flat, BNL join)
 1	PRIMARY	t2i	ref	it2i1,it2i2,it2i3	it2i3	18	test.t1.a1,test.t1.a2	2	100.00	Using index; Start temporary
 1	PRIMARY	t3c	ALL	NULL	NULL	NULL	NULL	4	100.00	Using where; End temporary; Using join buffer (flat, BNL join)
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary; End temporary; Using join buffer (flat, BNL join)
 4	MATERIALIZED	t3b	ALL	NULL	NULL	NULL	NULL	4	100.00	Using where
 3	DEPENDENT SUBQUERY	t3a	ALL	NULL	NULL	NULL	NULL	4	100.00	Using where
 Warnings:
 Note	1276	Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
 Note	1276	Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1
-Note	1003	select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b2` = `test`.`t1`.`a2`) and (`test`.`t3c`.`c2` = `test`.`t1`.`a2`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t1`.`a1`) and (`test`.`t3c`.`c1` = `test`.`t1`.`a1`) and (<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))))
+Note	1003	select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2i`.`b2` = `test`.`t1`.`a2`) and (`test`.`t3c`.`c2` = `test`.`t1`.`a2`) and (`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b1` = `test`.`t1`.`a1`) and (`test`.`t3c`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))))
 explain extended
 select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
@@ -1087,11 +1087,11 @@
 explain extended
 select a from t1 where a in (select c from t2 where d >= 20);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	6	100.00	
-1	PRIMARY	t1	ref	it1a	it1a	4	test.t2.c	2	100.00	Using index
+1	PRIMARY	t1	index	it1a	it1a	4	NULL	7	100.00	Using index
+1	PRIMARY	<subquery2>	eq_ref	distinct_key	distinct_key	4	func	1	100.00	
 2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	6	100.00	Using where
 Warnings:
-Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` >= 20))
+Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` >= 20))
 select a from t1 where a in (select c from t2 where d >= 20);
 a
 2

=== modified file 'mysql-test/r/subselect_sj_nonmerged.result'
--- a/mysql-test/r/subselect_sj_nonmerged.result	2012-02-25 00:50:22 +0000
+++ b/mysql-test/r/subselect_sj_nonmerged.result	2012-04-02 17:41:54 +0000
@@ -77,8 +77,8 @@
 t4.a in (select max(t2.a) from t1, t2 group by t2.b) and 
 t4.b in (select max(t2.a) from t1, t2 group by t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	5	
-1	PRIMARY	<subquery3>	ALL	distinct_key	NULL	NULL	NULL	5	Using join buffer (flat, BNL join)
+1	PRIMARY	<subquery3>	ALL	distinct_key	NULL	NULL	NULL	5	
+1	PRIMARY	<subquery2>	ALL	distinct_key	NULL	NULL	NULL	5	Using join buffer (flat, BNL join)
 1	PRIMARY	t4	ref	a	a	10	<subquery2>.max(t2.a),<subquery3>.max(t2.a)	12	
 3	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	5	Using temporary
 3	MATERIALIZED	t1	ALL	NULL	NULL	NULL	NULL	10	Using join buffer (flat, BNL join)

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2012-02-15 17:08:08 +0000
+++ b/mysql-test/r/view.result	2012-04-10 06:28:13 +0000
@@ -4609,6 +4609,13 @@
 DROP PROCEDURE p1;
 DROP TABLE t1;
 #
+# Bug#12626844: WRONG ERROR MESSAGE WHILE CREATING A VIEW ON A
+#               NON EXISTING DATABASE
+#
+DROP DATABASE IF EXISTS nodb;
+CREATE VIEW nodb.a AS SELECT 1;
+ERROR 42000: Unknown database 'nodb'
+#
 # lp:833600 Wrong result with view + outer join + uncorrelated subquery (non-semijoin) 
 #
 CREATE TABLE t1 ( a int, b int );
@@ -4628,6 +4635,45 @@
 NULL	NULL	1	0
 DROP VIEW v2;
 DROP TABLE t1, t2, t3;
+#
+# BUG#915222: Valgrind complains or crashes with INSERT SELECT
+#              within a trigger that uses a view
+#
+CREATE TABLE t1 (a char(1));
+CREATE TABLE t2 (d int, e char(1));
+INSERT INTO t2 VALUES (13,'z');
+CREATE TRIGGER tr AFTER UPDATE ON t2
+FOR EACH ROW
+REPLACE INTO t3
+SELECT f, a AS alias FROM t3, v;
+CREATE TABLE t3 (f int, g char(8));
+CREATE VIEW v AS SELECT a, e FROM t2, t1;
+UPDATE t2 SET d=7;
+UPDATE t2 SET d=7;
+UPDATE t2 SET d=7;
+UPDATE t2 SET d=7;
+DROP TRIGGER tr;
+DROP VIEW v;
+DROP TABLE t1,t2,t3;
+#
+# BUG#972943: Assertion failure with INSERT SELECT within a trigger 
+#             that uses derived table and materialized view
+#
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,0), (2,8);
+CREATE ALGORITHM=TEMPTABLE VIEW v1
+AS SELECT * FROM t1;
+CREATE TABLE t2 (c int);
+CREATE TABLE t3 (d int, e int);
+CREATE TRIGGER tr BEFORE INSERT ON t2 FOR EACH ROW
+INSERT INTO t3
+SELECT t1.*
+FROM (SELECT * FROM t1 WHERE b IN (SELECT b FROM v1)) AS alias1, t1
+WHERE t1.a = 3 OR t1.a > 5;
+INSERT INTO t2 VALUES (1);
+DROP TRIGGER tr;
+DROP VIEW v1;
+DROP TABLE t1,t2,t3;
 # -----------------------------------------------------------------
 # -- End of 5.3 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/r/xa.result'
--- a/mysql-test/r/xa.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/r/xa.result	2012-04-10 06:28:13 +0000
@@ -174,7 +174,6 @@
 XA START 'a';
 INSERT INTO t1 VALUES (1);
 SAVEPOINT savep;
-ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
 XA END 'a';
 SELECT * FROM t1;
 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  IDLE state

=== modified file 'mysql-test/suite/binlog/r/binlog_sql_mode.result'
--- a/mysql-test/suite/binlog/r/binlog_sql_mode.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/binlog/r/binlog_sql_mode.result	2012-02-29 06:53:15 +0000
@@ -38,3 +38,114 @@
 DROP TABLE t1;
 SET @@global.sql_mode= @old_sql_mode;
 SET @@session.binlog_format=@old_binlog_format;
+
+#
+# Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES
+# IGNORED AND BREAKS REPLICATION
+#
+DROP DATABASE IF EXISTS mysqltest_db;
+DROP TABLE IF EXISTS test_table;
+CREATE DATABASE mysqltest_db;
+USE mysqltest_db;
+CREATE TABLE test_table (c1 CHAR(50));
+SET @org_mode=@@sql_mode;
+SET @@sql_mode='';
+CREATE PROCEDURE proc_without_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50))
+BEGIN
+DECLARE var1 CHAR(50) DEFAULT param1;
+DECLARE var2 CHAR(50) DEFAULT param2;
+DECLARE var3 CHAR(50) DEFAULT 'abcd\bef';
+DECLARE var4 CHAR(50) DEFAULT 'abcd\nef';
+DECLARE var5 CHAR(50) DEFAULT 'abcd\ref';
+DECLARE var6 CHAR(50) DEFAULT 'abcd\tef';
+DECLARE var7 CHAR(50) DEFAULT 'abcd\\ef';
+DECLARE var8 CHAR(50) DEFAULT 'abcd\%ef';
+DECLARE var9 CHAR(50) DEFAULT 'abcd\_ef';
+INSERT INTO test_table VALUES (var1);
+INSERT INTO test_table VALUES (var2);
+INSERT INTO test_table VALUES (var3);
+INSERT INTO test_table VALUES (var4);
+INSERT INTO test_table VALUES (var5);
+INSERT INTO test_table VALUES (var6);
+INSERT INTO test_table VALUES (var7);
+INSERT INTO test_table VALUES (var8);
+INSERT INTO test_table VALUES (var9);
+END
+$
+SET @@sql_mode='NO_BACKSLASH_ESCAPES'$
+CREATE PROCEDURE proc_with_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50))
+BEGIN
+DECLARE var1 CHAR(50) DEFAULT param1;
+DECLARE var2 CHAR(50) DEFAULT param2;
+DECLARE var3 CHAR(50) DEFAULT 'wxyz\bef';
+DECLARE var4 CHAR(50) DEFAULT 'wxyz\nef';
+DECLARE var5 CHAR(50) DEFAULT 'wxyz\ref';
+DECLARE var6 CHAR(50) DEFAULT 'wxyz\tef';
+DECLARE var7 CHAR(50) DEFAULT 'wxyz\\ef';
+DECLARE var8 CHAR(50) DEFAULT 'wxyz\%ef';
+DECLARE var9 CHAR(50) DEFAULT 'wxyz\_ef';
+INSERT INTO test_table VALUES (var1);
+INSERT INTO test_table VALUES (var2);
+INSERT INTO test_table VALUES (var3);
+INSERT INTO test_table VALUES (var4);
+INSERT INTO test_table VALUES (var5);
+INSERT INTO test_table VALUES (var6);
+INSERT INTO test_table VALUES (var7);
+INSERT INTO test_table VALUES (var8);
+INSERT INTO test_table VALUES (var9);
+END
+$
+SET @@sql_mode='';
+CALL proc_without_sql_mode('abcd\'ef', 'abcd\"ef');
+CALL proc_with_sql_mode('wxyz\'ef', 'wxyz\"ef');
+SELECT * FROM test_table;
+c1
+abcd'ef
+abcd"ef
+abcdef
+abcd
+ef
+abcd
ef
+abcd	ef
+abcd\ef
+abcd\%ef
+abcd\_ef
+wxyz'ef
+wxyz"ef
+wxyz\bef
+wxyz\nef
+wxyz\ref
+wxyz\tef
+wxyz\\ef
+wxyz\%ef
+wxyz\_ef
+"Dropping table test_table"
+DROP TABLE test_table;
+#"test_table" content after replaying the binlog
+SELECT * FROM test_table;
+c1
+abcd'ef
+abcd"ef
+abcdef
+abcd
+ef
+abcd
ef
+abcd	ef
+abcd\ef
+abcd\%ef
+abcd\_ef
+wxyz'ef
+wxyz"ef
+wxyz\bef
+wxyz\nef
+wxyz\ref
+wxyz\tef
+wxyz\\ef
+wxyz\%ef
+wxyz\_ef
+#Clean up
+DROP DATABASE mysqltest_db;
+SET @@sql_mode= @org_mode;
+use test;
+
+#End of Test for Bug#12601974 

=== modified file 'mysql-test/suite/binlog/r/binlog_unsafe.result'
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result	2011-11-03 18:17:05 +0000
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result	2012-03-27 23:04:46 +0000
@@ -1760,7 +1760,7 @@
 
 Invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; RETURN 0; END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO t1 SELECT func_sidef_1();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1769,12 +1769,13 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
 Invoking function func_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); RETURN 0; END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1783,13 +1784,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_2() BEGIN INSERT INTO t1 SELECT func_sidef_1(); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 CALL proc_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1798,13 +1800,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1813,6 +1816,7 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP TRIGGER trig_2;
@@ -1826,7 +1830,8 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
-* binlog_format = STATEMENT: expect 6 warnings.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO t2 SELECT * FROM view_sidef_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1835,13 +1840,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP VIEW view_sidef_2;
 
 Invoking prepared statement prep_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()";
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 EXECUTE prep_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1850,6 +1856,7 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_2;
@@ -1857,7 +1864,7 @@
 
 Invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_1() BEGIN INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; INSERT INTO ta1 VALUES (47); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 CALL proc_1();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1866,12 +1873,13 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
 Invoking function func_sidef_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1880,13 +1888,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_2() BEGIN CALL proc_1(); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 CALL proc_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1895,13 +1904,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1910,13 +1920,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP TRIGGER trig_2;
 
 Invoking prepared statement prep_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 PREPARE prep_2 FROM "CALL proc_1()";
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 EXECUTE prep_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1925,6 +1936,7 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_2;
@@ -1932,7 +1944,7 @@
 
 Invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO trigger_table_1 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1941,12 +1953,13 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
 Invoking function func_sidef_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); RETURN 0; END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1955,13 +1968,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_2() BEGIN INSERT INTO trigger_table_1 VALUES (1); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 CALL proc_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1970,13 +1984,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END;
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -1985,13 +2000,14 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP TRIGGER trig_2;
 
 Invoking prepared statement prep_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)";
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 EXECUTE prep_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -2000,6 +2016,7 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_2;
@@ -2007,7 +2024,7 @@
 
 Invoking prepared statement prep_1 invoking statement that is unsafe in many ways.
 PREPARE prep_1 FROM "INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1";
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 EXECUTE prep_1;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -2016,12 +2033,13 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_1;
 
 Invoking statement that is unsafe in many ways.
-* binlog_format = STATEMENT: expect 6 warnings.
+* binlog_format = STATEMENT: expect 7 warnings.
 INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
@@ -2030,6 +2048,7 @@
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 

=== modified file 'mysql-test/suite/binlog/t/binlog_sql_mode.test'
--- a/mysql-test/suite/binlog/t/binlog_sql_mode.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/binlog/t/binlog_sql_mode.test	2012-02-29 06:53:15 +0000
@@ -73,3 +73,99 @@
 
 SET @@global.sql_mode= @old_sql_mode;
 SET @@session.binlog_format=@old_binlog_format;
+
+--echo 
+--echo #
+--echo # Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES
+--echo # IGNORED AND BREAKS REPLICATION
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest_db;
+DROP TABLE IF EXISTS test_table;
+--enable_warnings
+
+CREATE DATABASE mysqltest_db;
+USE mysqltest_db;
+CREATE TABLE test_table (c1 CHAR(50));
+
+SET @org_mode=@@sql_mode;
+
+SET @@sql_mode='';
+DELIMITER $;
+CREATE PROCEDURE proc_without_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50))
+BEGIN
+  DECLARE var1 CHAR(50) DEFAULT param1;
+  DECLARE var2 CHAR(50) DEFAULT param2;
+  DECLARE var3 CHAR(50) DEFAULT 'abcd\bef';
+  DECLARE var4 CHAR(50) DEFAULT 'abcd\nef';
+  DECLARE var5 CHAR(50) DEFAULT 'abcd\ref';
+  DECLARE var6 CHAR(50) DEFAULT 'abcd\tef';
+  DECLARE var7 CHAR(50) DEFAULT 'abcd\\ef';
+  DECLARE var8 CHAR(50) DEFAULT 'abcd\%ef';
+  DECLARE var9 CHAR(50) DEFAULT 'abcd\_ef';
+
+  INSERT INTO test_table VALUES (var1);
+  INSERT INTO test_table VALUES (var2);
+  INSERT INTO test_table VALUES (var3);
+  INSERT INTO test_table VALUES (var4);
+  INSERT INTO test_table VALUES (var5);
+  INSERT INTO test_table VALUES (var6);
+  INSERT INTO test_table VALUES (var7);
+  INSERT INTO test_table VALUES (var8);
+  INSERT INTO test_table VALUES (var9);
+END
+$
+
+SET @@sql_mode='NO_BACKSLASH_ESCAPES'$
+CREATE PROCEDURE proc_with_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50))
+BEGIN
+  DECLARE var1 CHAR(50) DEFAULT param1;
+  DECLARE var2 CHAR(50) DEFAULT param2;
+  DECLARE var3 CHAR(50) DEFAULT 'wxyz\bef';
+  DECLARE var4 CHAR(50) DEFAULT 'wxyz\nef';
+  DECLARE var5 CHAR(50) DEFAULT 'wxyz\ref';
+  DECLARE var6 CHAR(50) DEFAULT 'wxyz\tef';
+  DECLARE var7 CHAR(50) DEFAULT 'wxyz\\ef';
+  DECLARE var8 CHAR(50) DEFAULT 'wxyz\%ef';
+  DECLARE var9 CHAR(50) DEFAULT 'wxyz\_ef';
+
+  INSERT INTO test_table VALUES (var1);
+  INSERT INTO test_table VALUES (var2);
+  INSERT INTO test_table VALUES (var3);
+  INSERT INTO test_table VALUES (var4);
+  INSERT INTO test_table VALUES (var5);
+  INSERT INTO test_table VALUES (var6);
+  INSERT INTO test_table VALUES (var7);
+  INSERT INTO test_table VALUES (var8);
+  INSERT INTO test_table VALUES (var9);
+END
+$
+
+DELIMITER ;$
+SET @@sql_mode='';
+CALL proc_without_sql_mode('abcd\'ef', 'abcd\"ef');
+CALL proc_with_sql_mode('wxyz\'ef', 'wxyz\"ef');
+SELECT * FROM test_table;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYSQL_BINLOG --force-if-open -d mysqltest_db $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug12601974.binlog
+
+--echo "Dropping table test_table"
+DROP TABLE test_table;
+
+--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug12601974.binlog"
+
+--echo #"test_table" content after replaying the binlog
+SELECT * FROM test_table;
+
+--echo #Clean up
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug12601974.binlog
+DROP DATABASE mysqltest_db;
+SET @@sql_mode= @org_mode;
+use test;
+
+--echo 
+--echo #End of Test for Bug#12601974 
+
+

=== modified file 'mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test'
--- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test	2012-04-07 13:58:46 +0000
@@ -141,7 +141,7 @@
   use strict;
   use Cwd;
   my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
-  open(FILE, "$log_error") or die("Unable to open '$log_error' from directory " . cwd() . "\n");
+  open(FILE, "$log_error") or die("Unable to open '$log_error' from directory " . cwd() . " :$! \n");
   my $binlog_counter= $ENV{'BINLOG_COUNTER1'} or die "BINLOG_COUNTER1 not set";
   my $count = () = grep(/$binlog_counter/g,<FILE>); 
   # Grep the timestamp value from the error file.

=== modified file 'mysql-test/suite/binlog/t/binlog_unsafe.test'
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test	2011-11-03 18:17:05 +0000
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test	2012-03-27 23:04:46 +0000
@@ -233,7 +233,7 @@
     --let $value_0=
     --let $sel_sidef_0=
     --let $sel_retval_0=
-    --let $CRC_ARG_expected_number_of_warnings= 6
+    --let $CRC_ARG_expected_number_of_warnings= 7
   }
 
   if ($unsafe_type == 8) {

=== modified file 'mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result'
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result	2010-05-04 18:10:17 +0000
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result	2012-02-02 12:25:48 +0000
@@ -77,6 +77,7 @@
 utf8_esperanto_ci	utf8	209		#	#
 utf8_hungarian_ci	utf8	210		#	#
 utf8_sinhala_ci	utf8	211		#	#
+utf8_general_mysql500_ci	utf8	223		#	#
 ucs2_general_ci	ucs2	35	Yes	#	#
 ucs2_bin	ucs2	90		#	#
 ucs2_unicode_ci	ucs2	128		#	#
@@ -99,6 +100,7 @@
 ucs2_esperanto_ci	ucs2	145		#	#
 ucs2_hungarian_ci	ucs2	146		#	#
 ucs2_sinhala_ci	ucs2	147		#	#
+ucs2_general_mysql500_ci	ucs2	159		#	#
 cp866_general_ci	cp866	36	Yes	#	#
 cp866_bin	cp866	68		#	#
 keybcs2_general_ci	keybcs2	37	Yes	#	#

=== modified file 'mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result'
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result	2010-05-04 18:10:17 +0000
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result	2012-02-02 12:25:48 +0000
@@ -77,6 +77,7 @@
 utf8_esperanto_ci	utf8	209		#	#
 utf8_hungarian_ci	utf8	210		#	#
 utf8_sinhala_ci	utf8	211		#	#
+utf8_general_mysql500_ci	utf8	223		#	#
 ucs2_general_ci	ucs2	35	Yes	#	#
 ucs2_bin	ucs2	90		#	#
 ucs2_unicode_ci	ucs2	128		#	#
@@ -99,6 +100,7 @@
 ucs2_esperanto_ci	ucs2	145		#	#
 ucs2_hungarian_ci	ucs2	146		#	#
 ucs2_sinhala_ci	ucs2	147		#	#
+ucs2_general_mysql500_ci	ucs2	159		#	#
 cp866_general_ci	cp866	36	Yes	#	#
 cp866_bin	cp866	68		#	#
 keybcs2_general_ci	keybcs2	37	Yes	#	#

=== removed file 'mysql-test/suite/innodb/include/innodb-index.inc'
--- a/mysql-test/suite/innodb/include/innodb-index.inc	2009-06-10 13:51:20 +0000
+++ b/mysql-test/suite/innodb/include/innodb-index.inc	1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
---eval create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=$charset
-insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
-commit;
---error ER_DUP_ENTRY
-alter table t1 add unique index (b);
-insert into t1 values(8,9,'fff','fff');
-select * from t1;
-show create table t1;
-alter table t1 add index (b);
-insert into t1 values(10,10,'kkk','iii');
-select * from t1;
-select * from t1 force index(b) order by b;
-explain select * from t1 force index(b) order by b;
-show create table t1;
-alter table t1 add unique index (c), add index (d);
-insert into t1 values(11,11,'aaa','mmm');
-select * from t1;
-select * from t1 force index(b) order by b;
-select * from t1 force index(c) order by c;
-select * from t1 force index(d) order by d;
-explain select * from t1 force index(b) order by b;
-explain select * from t1 force index(c) order by c;
-explain select * from t1 force index(d) order by d;
-show create table t1;
-check table t1;
-drop table t1;

=== modified file 'mysql-test/suite/innodb/r/group_commit_crash.result'
--- a/mysql-test/suite/innodb/r/group_commit_crash.result	2011-12-15 21:07:58 +0000
+++ b/mysql-test/suite/innodb/r/group_commit_crash.result	2012-03-27 23:04:46 +0000
@@ -2,7 +2,7 @@
 b CHAR(255),
 c CHAR(255),
 d CHAR(255),
-id INT AUTO_INCREMENT,
+id INT,
 PRIMARY KEY(id)) ENGINE=InnoDB;
 create table t2 like t1;
 create procedure setcrash(IN i INT)
@@ -17,16 +17,16 @@
 END CASE;
 end //
 FLUSH TABLES;
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 9+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 8+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 7+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 6+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 5+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 4+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 3+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 2+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 0+1);
 SET binlog_format= mixed;
 RESET MASTER;
 START TRANSACTION;

=== modified file 'mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result'
--- a/mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result	2011-12-15 21:07:58 +0000
+++ b/mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result	2012-03-27 23:04:46 +0000
@@ -2,7 +2,7 @@
 b CHAR(255),
 c CHAR(255),
 d CHAR(255),
-id INT AUTO_INCREMENT,
+id INT,
 PRIMARY KEY(id)) ENGINE=InnoDB;
 create table t2 like t1;
 create procedure setcrash(IN i INT)
@@ -17,16 +17,16 @@
 END CASE;
 end //
 FLUSH TABLES;
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
-INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+9);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+8);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+7);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+6);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+5);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+4);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+3);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+2);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+1);
+INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+0);
 SET binlog_format= mixed;
 RESET MASTER;
 START TRANSACTION;

=== added file 'mysql-test/suite/innodb/r/innodb-autoinc-61209.result'
--- a/mysql-test/suite/innodb/r/innodb-autoinc-61209.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb-autoinc-61209.result	2012-04-10 06:30:20 +0000
@@ -0,0 +1,28 @@
+DROP TABLE IF EXISTS bug_61209;
+CREATE TABLE bug_61209 (a INT auto_increment, PRIMARY KEY(a)) ENGINE=InnoDB;
+INSERT INTO bug_61209 VALUES (), (), (), ();
+
+# Connect con1
+
+# Connect con2
+
+# Connection con1
+SET SESSION auto_increment_increment=3;
+SET SESSION auto_increment_offset=2;
+SELECT GET_LOCK('a', 9);
+GET_LOCK('a', 9)
+1
+
+# Connection con2
+SET SESSION auto_increment_increment=3;
+SET SESSION auto_increment_offset=2;
+INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL + GET_LOCK('a', 10));
+
+# Connection con1 reap
+INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL);
+SELECT RELEASE_LOCK('a');
+RELEASE_LOCK('a')
+1
+
+# Connection con2 reap
+DROP TABLE bug_61209;

=== modified file 'mysql-test/suite/innodb/r/innodb-autoinc.result'
--- a/mysql-test/suite/innodb/r/innodb-autoinc.result	2011-07-02 20:08:51 +0000
+++ b/mysql-test/suite/innodb/r/innodb-autoinc.result	2012-04-10 06:28:13 +0000
@@ -648,198 +648,198 @@
   `n` int(10) unsigned NOT NULL,
   `o` enum('FALSE','TRUE') DEFAULT NULL,
   PRIMARY KEY (`m`)
-) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-23	1	FALSE
-24	2	FALSE
-25	3	FALSE
-26	4	FALSE
-27	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-23	1	FALSE
-24	2	FALSE
-25	3	FALSE
-26	4	FALSE
-27	5	FALSE
-30	1	FALSE
-31	2	FALSE
-32	3	FALSE
-33	4	FALSE
-34	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-23	1	FALSE
-24	2	FALSE
-25	3	FALSE
-26	4	FALSE
-27	5	FALSE
-30	1	FALSE
-31	2	FALSE
-32	3	FALSE
-33	4	FALSE
-34	5	FALSE
-37	1	FALSE
-38	2	FALSE
-39	3	FALSE
-40	4	FALSE
-41	5	FALSE
-44	1	FALSE
-45	2	FALSE
-46	3	FALSE
-47	4	FALSE
-48	5	FALSE
-51	1	FALSE
-52	2	FALSE
-53	3	FALSE
-54	4	FALSE
-55	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1
+) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+16	1	TRUE
+17	1	FALSE
+18	2	TRUE
+19	2	FALSE
+20	3	TRUE
+21	3	FALSE
+22	4	TRUE
+23	4	FALSE
+24	5	TRUE
+25	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+16	1	TRUE
+17	1	FALSE
+18	2	TRUE
+19	2	FALSE
+20	3	TRUE
+21	3	FALSE
+22	4	TRUE
+23	4	FALSE
+24	5	TRUE
+25	5	FALSE
+31	1	FALSE
+32	2	FALSE
+33	3	FALSE
+34	4	FALSE
+35	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+16	1	TRUE
+17	1	FALSE
+18	2	TRUE
+19	2	FALSE
+20	3	TRUE
+21	3	FALSE
+22	4	TRUE
+23	4	FALSE
+24	5	TRUE
+25	5	FALSE
+31	1	FALSE
+32	2	FALSE
+33	3	FALSE
+34	4	FALSE
+35	5	FALSE
+38	1	FALSE
+39	2	FALSE
+40	3	FALSE
+41	4	FALSE
+42	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+16	1	TRUE
+17	1	FALSE
+18	2	TRUE
+19	2	FALSE
+20	3	TRUE
+21	3	FALSE
+22	4	TRUE
+23	4	FALSE
+24	5	TRUE
+25	5	FALSE
+31	1	FALSE
+32	2	FALSE
+33	3	FALSE
+34	4	FALSE
+35	5	FALSE
+38	1	FALSE
+39	2	FALSE
+40	3	FALSE
+41	4	FALSE
+42	5	FALSE
+45	1	FALSE
+46	2	FALSE
+47	3	FALSE
+48	4	FALSE
+49	5	FALSE
+52	1	FALSE
+53	2	FALSE
+54	3	FALSE
+55	4	FALSE
+56	5	FALSE
+59	1	FALSE
+60	2	FALSE
+61	3	FALSE
+62	4	FALSE
+63	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=latin1
 DROP TABLE t1;
 DROP TABLE t2;
 DROP TABLE IF EXISTS t1;
@@ -1251,3 +1251,21 @@
   PRIMARY KEY (`c1`)
 ) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1
 DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=256;
+SHOW VARIABLES LIKE "%auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	256
+CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1, NULL);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` tinyint(4) NOT NULL AUTO_INCREMENT,
+  `c2` varchar(10) DEFAULT NULL,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+c1	c2
+1	NULL
+DROP TABLE t1;

=== added file 'mysql-test/suite/innodb/r/innodb-blob.result'
--- a/mysql-test/suite/innodb/r/innodb-blob.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb-blob.result	2012-03-27 23:04:46 +0000
@@ -0,0 +1,119 @@
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,REPEAT('a',30000)),(2,REPEAT('b',40000));
+SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR go1';
+BEGIN;
+UPDATE t1 SET a=a+2;
+ROLLBACK;
+BEGIN;
+UPDATE t1 SET b=CONCAT(b,'foo');
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+SELECT a, RIGHT(b,20) FROM t1;
+SET DEBUG_SYNC='now SIGNAL go1';
+a	RIGHT(b,20)
+1	aaaaaaaaaaaaaaaaaaaa
+2	bbbbbbbbbbbbbbbbbbbb
+SET DEBUG_DBUG='+d,row_ins_extern_checkpoint';
+SET DEBUG_SYNC='before_row_ins_extern_latch SIGNAL rec_not_blob WAIT_FOR crash';
+ROLLBACK;
+BEGIN;
+INSERT INTO t1 VALUES (3,REPEAT('c',50000));
+SET DEBUG_SYNC='now WAIT_FOR rec_not_blob';
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-UNCOMMITTED
+SELECT a, RIGHT(b,20) FROM t1;
+a	RIGHT(b,20)
+1	aaaaaaaaaaaaaaaaaaaa
+2	bbbbbbbbbbbbbbbbbbbb
+SELECT a FROM t1;
+a
+1
+2
+3
+SET DEBUG_DBUG='+d,crash_commit_before';
+INSERT INTO t2 VALUES (42);
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+INSERT INTO t3 VALUES
+(1,REPEAT('d',7000),REPEAT('e',100)),
+(2,REPEAT('g',7000),REPEAT('h',100));
+SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR go';
+UPDATE t3 SET c=REPEAT('f',3000) WHERE a=1;
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-UNCOMMITTED
+SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
+SET DEBUG_SYNC='now SIGNAL go';
+a	RIGHT(b,20)	RIGHT(c,20)
+1	dddddddddddddddddddd	ffffffffffffffffffff
+2	gggggggggggggggggggg	hhhhhhhhhhhhhhhhhhhh
+CHECK TABLE t1,t2,t3;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+test.t2	check	status	OK
+test.t3	check	status	OK
+BEGIN;
+INSERT INTO t2 VALUES (347);
+SET DEBUG_DBUG='+d,row_upd_extern_checkpoint';
+SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR crash';
+UPDATE t3 SET c=REPEAT('i',3000) WHERE a=2;
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+SELECT info FROM information_schema.processlist
+WHERE state = 'debug sync point: before_row_upd_extern';
+info
+UPDATE t3 SET c=REPEAT('i',3000) WHERE a=2
+SET DEBUG_DBUG='+d,crash_commit_before';
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1,t2,t3;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+test.t2	check	status	OK
+test.t3	check	status	OK
+SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
+a	RIGHT(b,20)	RIGHT(c,20)
+1	dddddddddddddddddddd	ffffffffffffffffffff
+2	gggggggggggggggggggg	hhhhhhhhhhhhhhhhhhhh
+SELECT a FROM t3;
+a
+1
+2
+BEGIN;
+INSERT INTO t2 VALUES (33101);
+SET DEBUG_DBUG='+d,row_upd_extern_checkpoint';
+SET DEBUG_SYNC='after_row_upd_extern SIGNAL have_latch WAIT_FOR crash';
+UPDATE t3 SET c=REPEAT('j',3000) WHERE a=2;
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+SELECT info FROM information_schema.processlist
+WHERE state = 'debug sync point: after_row_upd_extern';
+info
+UPDATE t3 SET c=REPEAT('j',3000) WHERE a=2
+SET DEBUG_DBUG='+d,crash_commit_before';
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+CHECK TABLE t1,t2,t3;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+test.t2	check	status	OK
+test.t3	check	status	OK
+SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
+a	RIGHT(b,20)	RIGHT(c,20)
+1	dddddddddddddddddddd	ffffffffffffffffffff
+2	gggggggggggggggggggg	hhhhhhhhhhhhhhhhhhhh
+SELECT a FROM t3;
+a
+1
+2
+SELECT * FROM t2;
+a
+DROP TABLE t1,t2,t3;

=== modified file 'mysql-test/suite/innodb/r/innodb-index.result'
--- a/mysql-test/suite/innodb/r/innodb-index.result	2012-01-16 19:16:35 +0000
+++ b/mysql-test/suite/innodb/r/innodb-index.result	2012-04-07 13:58:46 +0000
@@ -114,6 +114,10 @@
   KEY `ndx_o` (`o`(500)),
   KEY `ndx_p` (`p`(500))
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+create table t1(a varchar(2) primary key) engine=innodb;
+insert into t1 values('');
+create index t1a1 on t1(a(1));
+drop table t1;
 set global innodb_file_per_table=0;
 set global innodb_file_format=Antelope;
 create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;

=== modified file 'mysql-test/suite/innodb/r/innodb.result'
--- a/mysql-test/suite/innodb/r/innodb.result	2012-02-21 19:51:56 +0000
+++ b/mysql-test/suite/innodb/r/innodb.result	2012-04-02 07:53:09 +0000
@@ -1685,7 +1685,7 @@
 drop table t1;
 SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
 variable_value
-511
+ok
 SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
 variable_value
 16384

=== added file 'mysql-test/suite/innodb/r/innodb_bug11754376.result'
--- a/mysql-test/suite/innodb/r/innodb_bug11754376.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug11754376.result	2012-03-27 23:04:46 +0000
@@ -0,0 +1,4 @@
+CREATE TABLE bug11754376 (c INT) ENGINE=INNODB;
+SET SESSION DEBUG_DBUG='+d,test_normalize_table_name_low';
+DROP TABLE bug11754376;
+SET SESSION DEBUG_DBUG='-d,test_normalize_table_name_low';

=== added file 'mysql-test/suite/innodb/r/innodb_bug11766634.result'
--- a/mysql-test/suite/innodb/r/innodb_bug11766634.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug11766634.result	2012-04-10 06:28:13 +0000
@@ -0,0 +1,5 @@
+create table t1 (f1 char(255)) engine innodb;
+drop table t1;
+create table t1 (f1 char(255)) engine innodb;
+1
+drop table t1;

=== added file 'mysql-test/suite/innodb/r/innodb_bug13510739.result'
--- a/mysql-test/suite/innodb/r/innodb_bug13510739.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug13510739.result	2011-12-22 11:05:33 +0000
@@ -0,0 +1,10 @@
+CREATE TABLE bug13510739 (c INTEGER NOT NULL, PRIMARY KEY (c)) ENGINE=INNODB;
+INSERT INTO bug13510739 VALUES (1), (2), (3), (4);
+DELETE FROM bug13510739 WHERE c=2;
+HANDLER bug13510739 OPEN;
+HANDLER bug13510739 READ `primary` = (2);
+c
+HANDLER bug13510739 READ `primary` NEXT;
+c
+4
+DROP TABLE bug13510739;

=== modified file 'mysql-test/suite/innodb/t/group_commit_crash.test'
--- a/mysql-test/suite/innodb/t/group_commit_crash.test	2012-02-07 15:22:36 +0000
+++ b/mysql-test/suite/innodb/t/group_commit_crash.test	2012-03-27 23:04:46 +0000
@@ -14,7 +14,7 @@
                 b CHAR(255),
                 c CHAR(255),
                 d CHAR(255),
-                id INT AUTO_INCREMENT,
+                id INT,
                 PRIMARY KEY(id)) ENGINE=InnoDB;
 create table t2 like t1;
 delimiter //;
@@ -39,7 +39,7 @@
 while ($numinserts)
 {
   dec $numinserts;
-  INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
+  eval INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', $numinserts+1);
 }
 
 --enable_reconnect

=== modified file 'mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test'
--- a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test	2012-02-07 15:22:36 +0000
+++ b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test	2012-03-27 23:04:46 +0000
@@ -14,7 +14,7 @@
                 b CHAR(255),
                 c CHAR(255),
                 d CHAR(255),
-                id INT AUTO_INCREMENT,
+                id INT,
                 PRIMARY KEY(id)) ENGINE=InnoDB;
 create table t2 like t1;
 delimiter //;
@@ -39,7 +39,7 @@
 while ($numinserts)
 {
   dec $numinserts;
-  INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
+  eval INSERT INTO t2(a, b, c, d, id) VALUES ('a', 'b', 'c', 'd', 1+$numinserts);
 }
 
 --enable_reconnect

=== added file 'mysql-test/suite/innodb/t/innodb-autoinc-61209.test'
--- a/mysql-test/suite/innodb/t/innodb-autoinc-61209.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-autoinc-61209.test	2012-04-10 06:30:20 +0000
@@ -0,0 +1,55 @@
+# This is the test case for bug #61209 - duplicate key errors
+# when using auto_increment_increment > 1 and auto_increment_offset > 1
+#
+--source include/have_innodb.inc
+
+#
+# Precautionary clean up.
+#
+--disable_warnings
+DROP TABLE IF EXISTS bug_61209;
+--enable_warnings
+
+#
+# Create test data.
+#
+CREATE TABLE bug_61209 (a INT auto_increment, PRIMARY KEY(a)) ENGINE=InnoDB;
+
+INSERT INTO bug_61209 VALUES (), (), (), ();
+
+--echo
+--echo # Connect con1
+--connect (con1,localhost,root,,)
+--echo
+--echo # Connect con2
+--connect (con2,localhost,root,,)
+
+--echo
+--echo # Connection con1
+--connection con1
+SET SESSION auto_increment_increment=3;
+SET SESSION auto_increment_offset=2;
+SELECT GET_LOCK('a', 9);
+
+--echo
+--echo # Connection con2
+--connection con2
+SET SESSION auto_increment_increment=3;
+SET SESSION auto_increment_offset=2;
+send INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL + GET_LOCK('a', 10));
+
+--echo
+--echo # Connection con1 reap
+--connection con1
+INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL);
+SELECT RELEASE_LOCK('a');
+
+--echo
+--echo # Connection con2 reap
+--connection con2
+reap;
+
+#
+# Clean up
+#
+DROP TABLE bug_61209;

=== modified file 'mysql-test/suite/innodb/t/innodb-autoinc.test'
--- a/mysql-test/suite/innodb/t/innodb-autoinc.test	2012-02-07 15:22:36 +0000
+++ b/mysql-test/suite/innodb/t/innodb-autoinc.test	2012-04-10 06:28:13 +0000
@@ -637,3 +637,14 @@
 -- source include/restart_mysqld.inc
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
+
+
+# Check if we handl offset > column max value properly
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=256;
+SHOW VARIABLES LIKE "%auto_inc%";
+# TINYINT
+CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1, NULL);
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;

=== added file 'mysql-test/suite/innodb/t/innodb-blob.test'
--- a/mysql-test/suite/innodb/t/innodb-blob.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-blob.test	2012-03-27 23:04:46 +0000
@@ -0,0 +1,221 @@
+# Bug#13721257 RACE CONDITION IN UPDATES OR INSERTS OF WIDE RECORDS
+# Test what happens when a record is inserted or updated so that some
+# columns are stored off-page.
+
+--source include/have_innodb.inc
+
+if (`select plugin_auth_version <= "1.1.8-24.1" from information_schema.plugins where plugin_name='innodb'`)
+{
+  --skip Not fixed in XtraDB 1.1.8-24.1 or earlier
+}
+
+# DEBUG_SYNC must be compiled in.
+--source include/have_debug_sync.inc
+
+# Valgrind would complain about memory leaks when we crash on purpose.
+--source include/not_valgrind.inc
+# Embedded server does not support crashing
+--source include/not_embedded.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (1,REPEAT('a',30000)),(2,REPEAT('b',40000));
+SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR go1';
+BEGIN;
+# This will not block, because it will not store new BLOBs.
+UPDATE t1 SET a=a+2;
+ROLLBACK;
+BEGIN;
+--send
+UPDATE t1 SET b=CONCAT(b,'foo');
+
+connect (con1,localhost,root,,);
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+
+# this one should block due to the clustered index tree and leaf page latches
+--send
+SELECT a, RIGHT(b,20) FROM t1;
+
+connect (con2,localhost,root,,);
+
+# Check that the above SELECT is blocked
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = 'Sending data' and
+        info = 'SELECT a, RIGHT(b,20) FROM t1';
+--source include/wait_condition.inc
+
+SET DEBUG_SYNC='now SIGNAL go1';
+
+connection con1;
+reap;
+connection default;
+reap;
+SET DEBUG_DBUG='+d,row_ins_extern_checkpoint';
+SET DEBUG_SYNC='before_row_ins_extern_latch SIGNAL rec_not_blob WAIT_FOR crash';
+ROLLBACK;
+BEGIN;
+--send
+INSERT INTO t1 VALUES (3,REPEAT('c',50000));
+
+connection con1;
+SET DEBUG_SYNC='now WAIT_FOR rec_not_blob';
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT @@tx_isolation;
+
+# this one should see (3,NULL_BLOB)
+SELECT a, RIGHT(b,20) FROM t1;
+SELECT a FROM t1;
+
+# Request a crash, and restart the server.
+SET DEBUG_DBUG='+d,crash_commit_before';
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+INSERT INTO t2 VALUES (42);
+
+disconnect con1;
+disconnect con2;
+connection default;
+# This connection should notice the crash as well.
+--error 2013
+reap;
+
+# Write file to make mysql-test-run.pl restart the server
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+CHECK TABLE t1;
+
+INSERT INTO t3 VALUES
+       (1,REPEAT('d',7000),REPEAT('e',100)),
+       (2,REPEAT('g',7000),REPEAT('h',100));
+SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR go';
+# This should move column b off-page.
+--send
+UPDATE t3 SET c=REPEAT('f',3000) WHERE a=1;
+
+connect (con1,localhost,root,,);
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT @@tx_isolation;
+
+# this one should block
+-- send
+SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
+
+connect (con2,localhost,root,,);
+
+# Check that the above SELECT is blocked
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = 'Sending data' and
+        info = 'SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3';
+--source include/wait_condition.inc
+
+SET DEBUG_SYNC='now SIGNAL go';
+
+connection con1;
+reap;
+disconnect con1;
+
+connection default;
+reap;
+
+CHECK TABLE t1,t2,t3;
+
+connection con2;
+BEGIN;
+INSERT INTO t2 VALUES (347);
+connection default;
+
+# The row_upd_extern_checkpoint was removed in Bug#13721257,
+# because the mini-transaction of the B-tree modification would
+# remain open while we are writing the off-page columns and are
+# stuck in the DEBUG_SYNC. A checkpoint involves a flush, which
+# would wait for the buffer-fix to cease.
+SET DEBUG_DBUG='+d,row_upd_extern_checkpoint';
+SET DEBUG_SYNC='before_row_upd_extern SIGNAL have_latch WAIT_FOR crash';
+# This should move column b off-page.
+--send
+UPDATE t3 SET c=REPEAT('i',3000) WHERE a=2;
+
+connection con2;
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+
+# Check that the above UPDATE is blocked
+SELECT info FROM information_schema.processlist
+WHERE state = 'debug sync point: before_row_upd_extern';
+
+# Request a crash, and restart the server.
+SET DEBUG_DBUG='+d,crash_commit_before';
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+COMMIT;
+
+disconnect con2;
+connection default;
+# This connection should notice the crash as well.
+--error 2013
+reap;
+
+# Write file to make mysql-test-run.pl restart the server
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+CHECK TABLE t1,t2,t3;
+SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
+SELECT a FROM t3;
+
+connect (con2,localhost,root,,);
+BEGIN;
+INSERT INTO t2 VALUES (33101);
+connection default;
+
+# The row_upd_extern_checkpoint was removed in Bug#13721257,
+# because the mini-transaction of the B-tree modification would
+# remain open while we are writing the off-page columns and are
+# stuck in the DEBUG_SYNC. A checkpoint involves a flush, which
+# would wait for the buffer-fix to cease.
+SET DEBUG_DBUG='+d,row_upd_extern_checkpoint';
+SET DEBUG_SYNC='after_row_upd_extern SIGNAL have_latch WAIT_FOR crash';
+# This should move column b off-page.
+--send
+UPDATE t3 SET c=REPEAT('j',3000) WHERE a=2;
+
+connection con2;
+SET DEBUG_SYNC='now WAIT_FOR have_latch';
+
+# Check that the above UPDATE is blocked
+SELECT info FROM information_schema.processlist
+WHERE state = 'debug sync point: after_row_upd_extern';
+
+# Request a crash, and restart the server.
+SET DEBUG_DBUG='+d,crash_commit_before';
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+COMMIT;
+
+disconnect con2;
+connection default;
+# This connection should notice the crash as well.
+--error 2013
+reap;
+
+# Write file to make mysql-test-run.pl restart the server
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+CHECK TABLE t1,t2,t3;
+SELECT a, RIGHT(b,20), RIGHT(c,20) FROM t3;
+SELECT a FROM t3;
+
+SELECT * FROM t2;
+
+DROP TABLE t1,t2,t3;

=== modified file 'mysql-test/suite/innodb/t/innodb-index.test'
--- a/mysql-test/suite/innodb/t/innodb-index.test	2012-02-07 15:22:36 +0000
+++ b/mysql-test/suite/innodb/t/innodb-index.test	2012-04-07 13:58:46 +0000
@@ -119,6 +119,11 @@
 # this file complete before dropping the table.  By then, the purge thread
 # will have delt with the updates above.
 
+# Bug#13654923 BOGUS DEBUG ASSERTION IN INDEX CREATION FOR ZERO-LENGTH RECORD
+create table t1(a varchar(2) primary key) engine=innodb;
+insert into t1 values('');
+create index t1a1 on t1(a(1));
+drop table t1;
 
 eval set global innodb_file_per_table=$per_table;
 eval set global innodb_file_format=$format;

=== modified file 'mysql-test/suite/innodb/t/innodb.test'
--- a/mysql-test/suite/innodb/t/innodb.test	2012-02-21 19:51:56 +0000
+++ b/mysql-test/suite/innodb/t/innodb.test	2012-04-02 07:53:09 +0000
@@ -1339,7 +1339,7 @@
 
 # Test for testable InnoDB status variables. This test
 # uses previous ones(pages_created, rows_deleted, ...).
---replace_result 512 511 2047 511
+--replace_result 511 ok 512 ok 2047 ok 513 ok
 SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
 SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
 SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';

=== added file 'mysql-test/suite/innodb/t/innodb_bug11754376.test'
--- a/mysql-test/suite/innodb/t/innodb_bug11754376.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug11754376.test	2012-03-27 23:04:46 +0000
@@ -0,0 +1,16 @@
+#
+# Bug#11754376 45976: INNODB LOST FILES FOR TEMPORARY TABLES ON GRACEFUL SHUTDOWN
+#
+
+-- source include/have_debug.inc
+-- source include/have_innodb.inc
+
+CREATE TABLE bug11754376 (c INT) ENGINE=INNODB;
+
+# This will invoke test_normalize_table_name_low() in debug builds
+
+SET SESSION DEBUG_DBUG='+d,test_normalize_table_name_low';
+
+DROP TABLE bug11754376;
+
+SET SESSION DEBUG_DBUG='-d,test_normalize_table_name_low';

=== added file 'mysql-test/suite/innodb/t/innodb_bug11766634.test'
--- a/mysql-test/suite/innodb/t/innodb_bug11766634.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug11766634.test	2012-04-10 06:28:13 +0000
@@ -0,0 +1,59 @@
+# Bug 11766634 59783: InnoDB data grows unexpectedly when inserting,
+# truncating, inserting the same set of rows.
+#
+# Scenario:
+# create table t1.  Insert $recs records.  check size of ibdata1.
+# drop table t1.  create table t1.  Insert the same set of $recs
+# records.  The size of ibdata1 must not increase.
+#
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+create table t1 (f1 char(255)) engine innodb;
+let $MYSQLD_DATADIR=`select @@datadir`;
+let IBDATA1=$MYSQLD_DATADIR/ibdata1;
+
+let $recs = 36262;
+
+--disable_query_log
+let $c = $recs;
+start transaction;
+while ($c)
+{
+  insert into t1 values ('Hello World');
+  dec $c;
+}
+commit work;
+--enable_query_log
+
+perl;
+my $filesize = -s $ENV{'IBDATA1'};
+my $filename = $ENV{MYSQL_TMP_DIR} . '/innodb_bug11766634.txt';
+open F, '>', $filename or die "open(>$filename): $!";
+print F $filesize;
+EOF
+
+drop table t1;
+create table t1 (f1 char(255)) engine innodb;
+
+--disable_query_log
+let $c = $recs;
+start transaction;
+while ($c)
+{
+  insert into t1 values ('Hello World');
+  dec $c;
+}
+commit work;
+--enable_query_log
+
+perl;
+my $filesize = -s $ENV{'IBDATA1'};
+my $filename = $ENV{MYSQL_TMP_DIR} . '/innodb_bug11766634.txt';
+$_=do $filename;
+print $_ == $filesize, "\n";
+EOF
+
+drop table t1;
+

=== added file 'mysql-test/suite/innodb/t/innodb_bug13510739.test'
--- a/mysql-test/suite/innodb/t/innodb_bug13510739.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug13510739.test	2011-12-22 11:05:33 +0000
@@ -0,0 +1,20 @@
+#
+# Bug#13510739 63775: SERVER CRASH ON HANDLER READ NEXT AFTER DELETE RECORD.
+#
+
+-- source include/have_innodb.inc
+
+CREATE TABLE bug13510739 (c INTEGER NOT NULL, PRIMARY KEY (c)) ENGINE=INNODB;
+
+INSERT INTO bug13510739 VALUES (1), (2), (3), (4);
+
+DELETE FROM bug13510739 WHERE c=2;
+
+HANDLER bug13510739 OPEN;
+
+HANDLER bug13510739 READ `primary` = (2);
+
+# this one crashes the server if the bug is present
+HANDLER bug13510739 READ `primary` NEXT;
+
+DROP TABLE bug13510739;

=== modified file 'mysql-test/suite/innodb/t/innodb_bug34300.test'
--- a/mysql-test/suite/innodb/t/innodb_bug34300.test	2012-02-07 15:22:36 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug34300.test	2012-04-10 06:28:13 +0000
@@ -7,6 +7,9 @@
 -- disable_query_log
 -- disable_result_log
 
+call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:");
+call mtr.add_suppression("the age of the last checkpoint is");
+
 # set packet size and reconnect 
 let $max_packet=`select @@global.max_allowed_packet`;
 SET @@global.max_allowed_packet=16777216;

=== modified file 'mysql-test/suite/innodb/t/innodb_bug53756.test'
--- a/mysql-test/suite/innodb/t/innodb_bug53756.test	2012-02-07 15:22:36 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug53756.test	2012-03-27 23:04:46 +0000
@@ -137,6 +137,9 @@
 # Request a crash on next execution of commit.
 SET SESSION debug_dbug="+d,crash_commit_before";
 #
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+#
 # Execute the statement that causes the crash.
 --error 2013
 COMMIT;
@@ -152,9 +155,6 @@
 --echo #
 --echo # Restart server.
 #
-# Write file to make mysql-test-run.pl start up the server again
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-#
 # Turn on reconnect
 --enable_reconnect
 #

=== modified file 'mysql-test/suite/maria/r/maria-autozerofill.result'
--- a/mysql-test/suite/maria/r/maria-autozerofill.result	2011-12-02 15:22:17 +0000
+++ b/mysql-test/suite/maria/r/maria-autozerofill.result	2012-03-30 10:54:33 +0000
@@ -4,17 +4,59 @@
 use mysqltest;
 create table t1(a int) engine=aria;
 insert into t1 values(1);
-flush table t1;
+create table t2 (a int) engine=aria;
+INSERT INTO t2 VALUES (1),(2);
+create table t3 (a int) engine=aria;
+INSERT INTO t3 VALUES (1),(2);
+create table t4 (a int) engine=aria;
+INSERT INTO t4 VALUES (1),(2);
+create table t5 (a int) engine=aria;
+INSERT INTO t5 VALUES (1),(2);
+flush tables;
 create_rename_lsn has non-magic value
 * shut down mysqld, removed logs, restarted it
 select * from t1;
 a
 1
 Warnings:
-Error	1194	t1' is marked as crashed and should be repaired
+Note	1194	Zerofilling moved table ./mysqltest/t1
 flush table t1;
 Status:              changed,sorted index pages,zerofilled
 insert into t1 values(2);
 flush table t1;
 create_rename_lsn has non-magic value
+check table t2;
+Table	Op	Msg_type	Msg_text
+mysqltest.t2	check	error	Table is from another system and must be zerofilled or repaired to be usable on this system
+mysqltest.t2	check	error	Corrupt
+check table t2;
+Table	Op	Msg_type	Msg_text
+mysqltest.t2	check	error	Table is from another system and must be zerofilled or repaired to be usable on this system
+mysqltest.t2	check	error	Corrupt
+repair table t2;
+Table	Op	Msg_type	Msg_text
+mysqltest.t2	repair	status	OK
+check table t2;
+Table	Op	Msg_type	Msg_text
+mysqltest.t2	check	status	OK
+optimize table t3;
+Table	Op	Msg_type	Msg_text
+mysqltest.t3	optimize	Note	Zerofilling moved table ./mysqltest/t3
+mysqltest.t3	optimize	status	OK
+analyze table t4;
+Table	Op	Msg_type	Msg_text
+mysqltest.t4	analyze	Note	Zerofilling moved table ./mysqltest/t4
+mysqltest.t4	analyze	status	OK
+repair table t5;
+Table	Op	Msg_type	Msg_text
+mysqltest.t5	repair	status	OK
+check table t5;
+Table	Op	Msg_type	Msg_text
+mysqltest.t5	check	status	OK
+repair table t5;
+Table	Op	Msg_type	Msg_text
+mysqltest.t5	repair	status	OK
+check table t5;
+Table	Op	Msg_type	Msg_text
+mysqltest.t5	check	status	OK
 drop database mysqltest;

=== modified file 'mysql-test/suite/maria/r/maria-recovery2.result'
--- a/mysql-test/suite/maria/r/maria-recovery2.result	2011-12-15 21:07:58 +0000
+++ b/mysql-test/suite/maria/r/maria-recovery2.result	2012-03-20 14:04:50 +0000
@@ -84,10 +84,11 @@
 mysqltest.t1	check	status	OK
 * testing that checksum after recovery is as expected
 Checksum-check
-ok
+failure
 use mysqltest;
 select * from t1;
 a
+1
 3
 drop table t1;
 * TEST of recovery when crash before bulk-insert-with-repair is committed

=== modified file 'mysql-test/suite/maria/t/maria-autozerofill.test'
--- a/mysql-test/suite/maria/t/maria-autozerofill.test	2011-02-28 17:39:30 +0000
+++ b/mysql-test/suite/maria/t/maria-autozerofill.test	2012-03-30 10:54:33 +0000
@@ -22,9 +22,19 @@
 use mysqltest;
 --enable_reconnect
 
+# Create some tables for future tests
 create table t1(a int) engine=aria;
 insert into t1 values(1);
-flush table t1;
+create table t2 (a int) engine=aria;
+INSERT INTO t2 VALUES (1),(2);
+create table t3 (a int) engine=aria;
+INSERT INTO t3 VALUES (1),(2);
+create table t4 (a int) engine=aria;
+INSERT INTO t4 VALUES (1),(2);
+create table t5 (a int) engine=aria;
+INSERT INTO t5 VALUES (1),(2);
+flush tables;
+
 # Check that table is not zerofilled, not movable
 let $MYSQLD_DATADIR= `select @@datadir`;
 --exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt
@@ -46,6 +56,7 @@
 
 disable_ps_protocol; # see aria-recover.test
 replace_regex /Table.*t1/t1/ ;
+replace_result \\ /;
 select * from t1;
 enable_ps_protocol;
 flush table t1;
@@ -80,4 +91,21 @@
     close FILE;
 EOF
 
+#
+# BUG#44422 "mysql_upgrade destroys Maria tables?"
+# Check repair and optimize of moved table
+#
+check table t2;
+check table t2;
+repair table t2;
+check table t2;
+replace_result \\ /;
+optimize table t3;
+replace_result \\ /;
+analyze table t4;
+repair table t5;
+check table t5;
+repair table t5;
+check table t5;
+
 drop database mysqltest;

=== modified file 'mysql-test/suite/oqgraph/suite.opt'
--- a/mysql-test/suite/oqgraph/suite.opt	2010-09-15 15:29:57 +0000
+++ b/mysql-test/suite/oqgraph/suite.opt	2012-03-30 20:15:44 +0000
@@ -1,1 +1,1 @@
---plugin-load=$HA_OQGRAPH_SO
+--plugin-load=$HA_OQGRAPH_SO --enable-oqgraph

=== modified file 'mysql-test/suite/oqgraph/suite.pm'
--- a/mysql-test/suite/oqgraph/suite.pm	2010-09-15 15:29:57 +0000
+++ b/mysql-test/suite/oqgraph/suite.pm	2012-03-30 20:15:44 +0000
@@ -2,7 +2,8 @@
 
 @ISA = qw(My::Suite);
 
-return "No OQGraph" unless $ENV{HA_OQGRAPH_SO};
+return "No OQGraph" unless $ENV{HA_OQGRAPH_SO} or
+                           $::mysqld_variables{'oqgraph'} eq "ON";
 
 bless { };
 

=== modified file 'mysql-test/suite/rpl/r/rpl_auto_increment_11932.result'
--- a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result	2012-02-09 17:58:33 +0000
@@ -1,5 +1,6 @@
 include/master-slave.inc
 [connection master]
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
 drop database if exists test1;
 create database test1;
 use test1;

=== modified file 'mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result'
--- a/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result	2012-03-27 23:04:46 +0000
@@ -11,7 +11,7 @@
 start slave;
 include/wait_for_slave_param.inc [Last_IO_Errno]
 Last_IO_Errno = '1236'
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the start event position from '.' at XXX, the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the first event '.' at XXX, the last event read from 'master-bin.000001' at XXX, the last byte read from 'master-bin.000001' at XXX.''
 reset master;
 stop slave;
 reset slave;

=== modified file 'mysql-test/suite/rpl/r/rpl_checksum.result'
--- a/mysql-test/suite/rpl/r/rpl_checksum.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_checksum.result	2012-03-29 14:02:19 +0000
@@ -71,7 +71,7 @@
 set @@global.debug_dbug='d,simulate_slave_unaware_checksum';
 start slave;
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log; the start event position from 'master-bin.000009' at 245, the last event was read from 'master-bin.000010' at 245, the last byte read was read from 'master-bin.000010' at 245.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log; the first event 'master-bin.000009' at 245, the last event read from 'master-bin.000010' at 245, the last byte read from 'master-bin.000010' at 245.''
 select count(*) as zero from t1;
 zero
 0
@@ -87,8 +87,7 @@
 create table t2 (a int);
 set @@global.debug_dbug='d,simulate_checksum_test_failure';
 start slave io_thread;
-include/wait_for_slave_io_error.inc [errno=1595]
-Last_IO_Error = 'Relay log write failure: could not queue event from master'
+include/wait_for_slave_io_error.inc [errno=1595,1913]
 set @@global.debug_dbug='';
 start slave io_thread;
 include/wait_for_slave_param.inc [Read_Master_Log_Pos]

=== added file 'mysql-test/suite/rpl/r/rpl_filter_dbs_dynamic.result'
--- a/mysql-test/suite/rpl/r/rpl_filter_dbs_dynamic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_filter_dbs_dynamic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,40 @@
+include/master-slave.inc
+[connection master]
+SET @@GLOBAL.replicate_do_db="db1";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
+SET @@GLOBAL.replicate_ignore_db="db2";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
+include/stop_slave.inc
+SET @@GLOBAL.replicate_do_db="db1";
+SET @@GLOBAL.replicate_ignore_db="db2";
+include/start_slave.inc
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE DATABASE db3;
+USE db1;
+CREATE TABLE t1 (a INT);
+USE db2;
+CREATE TABLE t2 (a INT);
+USE db3;
+CREATE TABLE t3 (a INT);
+USE db1;
+INSERT INTO t1 VALUES (1);
+USE db2;
+INSERT INTO t2 VALUES (2);
+USE db3;
+INSERT INTO t3 VALUES (3);
+[on slave]
+SHOW DATABASES LIKE 'db%';
+Database (db%)
+db1
+SHOW TABLES IN db1 LIKE 't%';
+Tables_in_db1 (t%)
+t1
+[on master]
+[on master]
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+DROP DATABASE IF EXISTS db3;
+include/rpl_end.inc
+SET @@GLOBAL.replicate_do_db="";
+SET @@GLOBAL.replicate_ignore_db="";

=== added file 'mysql-test/suite/rpl/r/rpl_filter_tables_dynamic.result'
--- a/mysql-test/suite/rpl/r/rpl_filter_tables_dynamic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_filter_tables_dynamic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,127 @@
+include/master-slave.inc
+[connection master]
+SET @@GLOBAL.replicate_do_table="test.t1,test.t2,test.t3";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
+SET @@GLOBAL.replicate_ignore_table="test.t4,test.t5,test.t6";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
+include/stop_slave.inc
+SET @@GLOBAL.replicate_do_table="test.t1,test.t2,test.t3";
+SET @@GLOBAL.replicate_ignore_table="test.t4,test.t5,test.t6";
+include/start_slave.inc
+CREATE TABLE t1 (id int, a int);
+CREATE TABLE t2 (id int, b int);
+CREATE TABLE t3 (id int, c int);
+CREATE TABLE t4 (id int, d int);
+CREATE TABLE t5 (id int, e int);
+CREATE TABLE t6 (id int, f int);
+CREATE TABLE t7 (id int, g int);
+CREATE TABLE t8 (id int, h int);
+CREATE TABLE t9 (id int, i int);
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t5 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t6 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t7 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t8 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t9 VALUES (1, 1), (2, 2), (3, 3);
+[on slave]
+SHOW TABLES LIKE 't%';
+Tables_in_test (t%)
+t1
+t2
+t3
+[on master]
+UPDATE t7 LEFT JOIN t4 ON (t4.id=t7.id) SET d=0, g=0 where t7.id=1;
+UPDATE t7 LEFT JOIN (t4, t5, t6) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t6.id) SET d=0, e=0, f=0, g=0 where t7.id=1;
+UPDATE t4 LEFT JOIN (t7, t8, t9) ON (t4.id=t7.id and t4.id=t8.id and t4.id=t9.id) SET d=0, g=0, h=0, i=0 where t4.id=1;
+UPDATE t7 LEFT JOIN (t8, t9) ON (t7.id=t8.id and t7.id=t9.id) SET g=0, h=0, i=0 where t7.id=1;
+UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET d=0 where t1.id=1;
+UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET g=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET d=0, e=0, f=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t4, t5, t8) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t8.id) SET d=0, e=0, h=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t7, t8, t5) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t5.id) SET g=0, h=0, e=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t2, t3, t5) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t5.id) SET e=0 where t1.id=1;
+UPDATE t4 LEFT JOIN t1 ON (t1.id=t4.id) SET a=0, d=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t7) ON (t4.id=t1.id and t7.id=t4.id) SET a = 0, d=0, g=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t2, t3) ON (t1.id=t4.id and t2.id=t4.id and t3.id=t4.id) SET a=0, b=0, c=0, d=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t2, t5) ON (t1.id=t4.id and t2.id=t4.id and t5.id=t4.id) SET a=0, b=0, e=0, d=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t6, t7) ON (t4.id=t1.id and t4.id=t6.id and t4.id=t7.id) SET a=0, d=0, f=0, g=0 where t4.id=1;
+UPDATE t7 LEFT JOIN (t4, t1, t2) ON (t7.id=t4.id and t7.id=t1.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1;
+UPDATE t7 LEFT JOIN (t8, t4, t1) ON (t7.id=t8.id and t7.id=t4.id and t7.id=t1.id) SET a=0, d=0, g=0, h=0 where t7.id=1;
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t[47]. doesn.t exist. on query.* Error_code: 1146");
+UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0 where t1.id=1''
+UPDATE t1 LEFT JOIN (t4, t7) ON (t1.id=t4.id and t1.id=t7.id) SET a=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t4, t7) ON (t1.id=t4.id and t1.id=t7.id) SET a=0 where t1.id=1''
+UPDATE t1 LEFT JOIN (t2, t4, t7) ON (t1.id=t2.id and t1.id=t4.id and t1.id=t7.id) SET a=0, b=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t2, t4, t7) ON (t1.id=t2.id and t1.id=t4.id and t1.id=t7.id) SET a=0, b=0 where t1.id=1''
+UPDATE t1 LEFT JOIN (t2, t3, t7) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t7.id) SET a=0, b=0, c=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t2, t3, t7) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t7.id) SET a=0, b=0, c=0 where t1.id=1''
+UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET a=0, g=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET a=0, g=0 where t1.id=1''
+UPDATE t7 LEFT JOIN t1 ON (t1.id=t7.id) SET a=0, g=0 where t7.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t7 LEFT JOIN t1 ON (t1.id=t7.id) SET a=0, g=0 where t7.id=1''
+UPDATE t1 LEFT JOIN (t4, t5, t7) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t7.id) SET a=0, g=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t4, t5, t7) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t7.id) SET a=0, g=0 where t1.id=1''
+UPDATE t1 LEFT JOIN (t4, t7, t8) ON (t1.id=t4.id and t1.id=t7.id and t1.id=t8.id) SET a=0, g=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t4, t7, t8) ON (t1.id=t4.id and t1.id=t7.id and t1.id=t8.id) SET a=0, g=0 where t1.id=1''
+UPDATE t1 LEFT JOIN (t7, t8, t9) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t9.id) SET a=0, g=0, h=0, i=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t7, t8, t9) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t9.id) SET a=0, g=0, h=0, i=0 where t1.id=1''
+UPDATE t7 LEFT JOIN (t1, t2, t3) ON (t7.id=t1.id and t7.id=t2.id and t7.id=t3.id) SET g=0, a=0, b=0, c=0 where t7.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t7 LEFT JOIN (t1, t2, t3) ON (t7.id=t1.id and t7.id=t2.id and t7.id=t3.id) SET g=0, a=0, b=0, c=0 where t7.id=1''
+UPDATE t7 LEFT JOIN (t4, t5, t3) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t3.id) SET g=0, c=0 where t7.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t7 LEFT JOIN (t4, t5, t3) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t3.id) SET g=0, c=0 where t7.id=1''
+UPDATE t7 LEFT JOIN (t8, t9, t3) ON (t7.id=t8.id and t7.id=t9.id and t7.id=t3.id) SET g=0, h=0, i=0, c=0 where t7.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t7 LEFT JOIN (t8, t9, t3) ON (t7.id=t8.id and t7.id=t9.id and t7.id=t3.id) SET g=0, h=0, i=0, c=0 where t7.id=1''
+UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0, d=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0, d=0 where t1.id=1''
+UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET a=0, d=0, e=0, f=0 where t1.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET a=0, d=0, e=0, f=0 where t1.id=1''
+UPDATE t4 LEFT JOIN (t1, t5, t6) ON (t4.id=t1.id and t4.id=t5.id and t4.id=t6.id) SET a=0, e=0, f=0 where t4.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t4 LEFT JOIN (t1, t5, t6) ON (t4.id=t1.id and t4.id=t5.id and t4.id=t6.id) SET a=0, e=0, f=0 where t4.id=1''
+UPDATE t7 LEFT JOIN (t1, t4, t2) ON (t7.id=t1.id and t7.id=t4.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1;
+include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
+Last_SQL_Error = 'Error 'Table 'test.t7' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t7 LEFT JOIN (t1, t4, t2) ON (t7.id=t1.id and t7.id=t4.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1''
+[on slave]
+show tables like 't%';
+Tables_in_test (t%)
+t1
+t2
+t3
+SELECT * FROM t1;
+id	a
+1	1
+2	2
+3	3
+SELECT * FROM t2;
+id	b
+1	1
+2	2
+3	3
+SELECT * FROM t3;
+id	c
+1	1
+2	2
+3	3
+[on master]
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+include/rpl_end.inc
+SET @@GLOBAL.replicate_do_table="";
+SET @@GLOBAL.replicate_ignore_table="";

=== added file 'mysql-test/suite/rpl/r/rpl_filter_wild_tables_dynamic.result'
--- a/mysql-test/suite/rpl/r/rpl_filter_wild_tables_dynamic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_filter_wild_tables_dynamic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,26 @@
+include/master-slave.inc
+[connection master]
+SET @@GLOBAL.replicate_wild_do_table="test.a%";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
+SET @@GLOBAL.replicate_wild_ignore_table="test.b%";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
+include/stop_slave.inc
+SET @@GLOBAL.replicate_wild_do_table="test.a%";
+SET @@GLOBAL.replicate_wild_ignore_table="test.b%";
+include/start_slave.inc
+CREATE TABLE a1 (a INT);
+CREATE TABLE b1 (a INT);
+CREATE TABLE c1 (a INT);
+INSERT INTO a1 VALUES (1);
+INSERT INTO b1 VALUES (2);
+INSERT INTO c1 VALUES (3);
+[on slave]
+SHOW TABLES LIKE '%1';
+Tables_in_test (%1)
+a1
+[on master]
+[on master]
+DROP TABLE IF EXISTS a1,b1,c1;
+include/rpl_end.inc
+SET @@GLOBAL.replicate_wild_do_table="";
+SET @@GLOBAL.replicate_wild_ignore_table="";

=== modified file 'mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result'
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2012-02-13 08:42:13 +0000
@@ -861,7 +861,8 @@
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test_rpl`; INSERT INTO t2 SELECT * FROM t1
+master-bin.000001	#	Table_map	#	#	table_id: # (test_rpl.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test_rpl`; INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1'

=== modified file 'mysql-test/suite/rpl/r/rpl_insert_id_pk.result'
--- a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result	2012-02-09 17:58:33 +0000
@@ -1,5 +1,6 @@
 include/master-slave.inc
 [connection master]
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
 create table t1(a int auto_increment, primary key(a));
 create table t2(b int auto_increment, c int, primary key(b));
 insert into t1 values (1),(2),(3);

=== modified file 'mysql-test/suite/rpl/r/rpl_known_bugs_detection.result'
--- a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result	2012-01-16 19:16:35 +0000
+++ b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result	2012-03-27 23:04:46 +0000
@@ -46,6 +46,7 @@
 t1.field_3 = t2.field_c;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f');
 INSERT INTO t1 (field_1, field_2, field_3)
 SELECT t2.field_a, t2.field_b, t2.field_c
@@ -54,6 +55,7 @@
 t1.field_3 = t2.field_c;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave.
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.
 SELECT * FROM t1;
 id	field_1	field_2	field_3
 1	1	a	1a

=== modified file 'mysql-test/suite/rpl/r/rpl_log_pos.result'
--- a/mysql-test/suite/rpl/r/rpl_log_pos.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_log_pos.result	2012-03-27 23:04:46 +0000
@@ -11,7 +11,7 @@
 change master to master_log_pos=MASTER_LOG_POS;
 start slave;
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the start event position from 'master-bin.000001' at XXX, the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the first event 'master-bin.000001' at XXX, the last event read from 'master-bin.000001' at XXX, the last byte read from 'master-bin.000001' at XXX.''
 include/stop_slave_sql.inc
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB

=== modified file 'mysql-test/suite/rpl/r/rpl_manual_change_index_file.result'
--- a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result	2012-03-27 23:04:46 +0000
@@ -5,7 +5,7 @@
 FLUSH LOGS;
 call mtr.add_suppression('Got fatal error 1236 from master when reading data from binary log: .*could not find next log');
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log; the start event position from 'master-bin.000001' at XXX, the last event was read from 'master-bin.000002' at XXX, the last byte read was read from 'master-bin.000002' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log; the first event 'master-bin.000001' at XXX, the last event read from 'master-bin.000002' at XXX, the last byte read from 'master-bin.000002' at XXX.''
 CREATE TABLE t2(c1 INT);
 FLUSH LOGS;
 CREATE TABLE t3(c1 INT);

=== modified file 'mysql-test/suite/rpl/r/rpl_multi_update.result'
--- a/mysql-test/suite/rpl/r/rpl_multi_update.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_multi_update.result	2012-02-09 17:58:33 +0000
@@ -1,5 +1,6 @@
 include/master-slave.inc
 [connection master]
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
 CREATE TABLE t1 (
 a int unsigned not null auto_increment primary key,
 b int unsigned

=== modified file 'mysql-test/suite/rpl/r/rpl_multi_update2.result'
--- a/mysql-test/suite/rpl/r/rpl_multi_update2.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_multi_update2.result	2012-02-09 17:58:33 +0000
@@ -1,5 +1,6 @@
 include/master-slave.inc
 [connection master]
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
 drop table if exists t1,t2;
 CREATE TABLE t1 (
 a int unsigned not null auto_increment primary key,

=== modified file 'mysql-test/suite/rpl/r/rpl_multi_update3.result'
--- a/mysql-test/suite/rpl/r/rpl_multi_update3.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_multi_update3.result	2012-02-09 17:58:33 +0000
@@ -1,5 +1,6 @@
 include/master-slave.inc
 [connection master]
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
 
 -------- Test for BUG#9361 --------
 CREATE TABLE t1 (

=== modified file 'mysql-test/suite/rpl/r/rpl_packet.result'
--- a/mysql-test/suite/rpl/r/rpl_packet.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_packet.result	2012-03-27 23:04:46 +0000
@@ -37,7 +37,7 @@
 CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
 INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the start event position from '.' at XXX, the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the first event '.' at XXX, the last event read from 'master-bin.000001' at XXX, the last byte read from 'master-bin.000001' at XXX.''
 STOP SLAVE;
 RESET SLAVE;
 RESET MASTER;

=== added file 'mysql-test/suite/rpl/r/rpl_report_port.result'
--- a/mysql-test/suite/rpl/r/rpl_report_port.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_report_port.result	2012-03-09 02:37:16 +0000
@@ -0,0 +1,8 @@
+include/master-slave.inc
+[connection master]
+include/assert.inc [The default value shown for the slave's port number is the actual port number of the slave.]
+include/rpl_restart_server.inc [server_number=2 parameters: --report-port=9000]
+include/start_slave.inc
+[Slave restarted with the report-port set to some value]
+include/assert.inc [The value shown for the slave's port number is 9000 which is the value set for report-port.]
+include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_rotate_logs.result'
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result	2011-12-12 22:58:40 +0000
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result	2012-03-27 23:04:46 +0000
@@ -1,3 +1,4 @@
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
 start slave;
 Got one of the listed errors
 start slave;

=== modified file 'mysql-test/suite/rpl/r/rpl_show_slave_hosts.result'
--- a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result	2011-05-10 11:41:09 +0000
+++ b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result	2012-02-28 08:32:27 +0000
@@ -6,7 +6,7 @@
 include/wait_for_slave_io_to_start.inc
 SHOW SLAVE HOSTS;
 Server_id	Host	Port	Master_id
-3	slave2	DEFAULT_PORT	1
+3	slave2	SLAVE_PORT	1
 2		SLAVE_PORT	1
 include/stop_slave_io.inc
 SHOW SLAVE HOSTS;

=== added file 'mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_relay_ign_space.result	2012-03-12 23:15:01 +0000
@@ -0,0 +1,5 @@
+include/master-slave.inc
+[connection master]
+include/assert.inc [Assert that relay log space is close to the limit]
+include/diff_tables.inc [master:test.t1,slave:test.t1]
+include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result	2012-03-09 07:06:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result	2012-03-27 23:04:46 +0000
@@ -75,7 +75,7 @@
 START SLAVE;
 include/wait_for_slave_param.inc [Last_IO_Errno]
 Last_IO_Errno = '1236'
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the start event position from 'master-bin.000001' at XXX, the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the first event 'master-bin.000001' at XXX, the last event read from 'master-bin.000001' at XXX, the last byte read from 'master-bin.000001' at XXX.''
 include/stop_slave.inc
 RESET SLAVE;
 RESET MASTER;

=== modified file 'mysql-test/suite/rpl/t/rpl_auto_increment_11932.test'
--- a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test	2012-02-09 17:58:33 +0000
@@ -8,6 +8,7 @@
 # Test supplied by Are Casilla
 
 source include/master-slave.inc;
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
 --disable_warnings
 connection master;
 drop database if exists test1;
@@ -42,12 +43,16 @@
     $
 DELIMITER ;$
 
+--disable_warnings
 CALL simpleproc3();
+--enable_warnings
 
 select * from t2;
 
 TRUNCATE TABLE `t1`;
+--disable_warnings
 CALL simpleproc3();
+--enable_warnings
 
 select * from t1;
 

=== modified file 'mysql-test/suite/rpl/t/rpl_checksum.test'
--- a/mysql-test/suite/rpl/t/rpl_checksum.test	2011-12-15 21:07:58 +0000
+++ b/mysql-test/suite/rpl/t/rpl_checksum.test	2012-03-29 14:02:19 +0000
@@ -143,8 +143,12 @@
 # instruction to io thread
 set @@global.debug_dbug='d,simulate_checksum_test_failure';
 start slave io_thread;
---let $slave_io_errno= 1595
---let $show_slave_io_error= 1
+# When the checksum error is detected, the slave sets error code 1913
+# (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE) in queue_event(), then immediately
+# sets error 1595 (ER_SLAVE_RELAY_LOG_WRITE_FAILURE) in handle_slave_io().
+# So we usually get 1595, but it is occasionally possible to get 1913.
+--let $slave_io_errno= 1595,1913
+--let $show_slave_io_error= 0
 source include/wait_for_slave_io_error.inc;
 set @@global.debug_dbug='';
 

=== added file 'mysql-test/suite/rpl/t/rpl_filter_dbs_dynamic.test'
--- a/mysql-test/suite/rpl/t/rpl_filter_dbs_dynamic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_filter_dbs_dynamic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,65 @@
+#
+# Test if dynamic replication database filter rules are properly evaluated.
+#
+
+source include/have_binlog_format_statement.inc;
+source include/master-slave.inc;
+
+connection slave;
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.replicate_do_db="db1";
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.replicate_ignore_db="db2";
+
+connection slave;
+source include/stop_slave.inc;
+SET @@GLOBAL.replicate_do_db="db1";
+SET @@GLOBAL.replicate_ignore_db="db2";
+source include/start_slave.inc;
+connection master;
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE DATABASE db3;
+
+# db is mentioned in do-db rules
+USE db1;
+CREATE TABLE t1 (a INT);
+
+# db is mentioned in ignore-db rules
+USE db2;
+CREATE TABLE t2 (a INT);
+
+# db is not mentioned in do-db or ignore-db rules
+USE db3;
+CREATE TABLE t3 (a INT);
+
+USE db1;
+INSERT INTO t1 VALUES (1);
+
+USE db2;
+INSERT INTO t2 VALUES (2);
+
+USE db3;
+INSERT INTO t3 VALUES (3);
+
+# Only db1 should be replicated to slave
+sync_slave_with_master;
+echo [on slave];
+SHOW DATABASES LIKE 'db%';
+SHOW TABLES IN db1 LIKE 't%';
+
+connection master;
+echo [on master];
+
+# Clean up
+connection master;
+echo [on master];
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+DROP DATABASE IF EXISTS db3;
+--source include/rpl_end.inc
+
+connection slave;
+SET @@GLOBAL.replicate_do_db="";
+SET @@GLOBAL.replicate_ignore_db="";

=== added file 'mysql-test/suite/rpl/t/rpl_filter_tables_dynamic.test'
--- a/mysql-test/suite/rpl/t/rpl_filter_tables_dynamic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_filter_tables_dynamic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,218 @@
+# Test evaluation of replication table filter rules
+#
+# ==== Purpose ====
+#
+# Test if dynamic replication table filter rules are properly evaluated
+# when some of the tables referenced by the multiple-table update do not
+# exist on slave.
+#
+# ==== Method ====
+#
+# Master creates tables t1, t2, t3, t4, t5, t6, t7, t8, t9 and the
+# slave is started with the following replication table filter rules:
+#
+# SET @@GLOBAL.replicate_do_table="test.t1,test.t2,test.t3";
+#
+# and
+#
+# SET @@GLOBAL.replicate_ignore_table="test.t4,test.t5,test.t6";
+#
+# So the slave only replicate changes to tables t1, t2 and t3 and only
+# these tables exist on slave.
+#
+# From now on, tables t1, t2, and t3 are referenced as do tables,
+# tables t4, t5, t6 are referenced as ignore tables, and tables t7,
+# t8, t9 are referenced as other tables.
+#
+# All multi-table update tests reference tables that are not do
+# tables, which do not exist on slave. And the following situations
+# of multi-table update will be tested:
+#
+# 1. Do tables are not referenced at all
+# 2. Do tables are not referenced for update
+# 3. Ignore tables are referenced for update before do tables
+# 4. Only do tables are referenced for update
+# 5. Do tables and other tables are referenced for update
+# 6. Do tables are referenced for update before ignore tables
+#
+# For 1, 2 and 3, the statement should be ignored by slave, for 4, 5
+# and 6 the statement should be accepted by slave and cause an error
+# because of non-exist tables.
+#
+
+source include/have_binlog_format_statement.inc;
+source include/master-slave.inc;
+
+connection slave;
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.replicate_do_table="test.t1,test.t2,test.t3";
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.replicate_ignore_table="test.t4,test.t5,test.t6";
+
+connection slave;
+source include/stop_slave.inc;
+SET @@GLOBAL.replicate_do_table="test.t1,test.t2,test.t3";
+SET @@GLOBAL.replicate_ignore_table="test.t4,test.t5,test.t6";
+source include/start_slave.inc;
+connection master;
+
+# These tables are mentioned in do-table rules
+CREATE TABLE t1 (id int, a int);
+CREATE TABLE t2 (id int, b int);
+CREATE TABLE t3 (id int, c int);
+
+# These tables are mentioned in ignore-table rules
+CREATE TABLE t4 (id int, d int);
+CREATE TABLE t5 (id int, e int);
+CREATE TABLE t6 (id int, f int);
+
+# These tables are not mentioned in do-table or ignore-table rules
+CREATE TABLE t7 (id int, g int);
+CREATE TABLE t8 (id int, h int);
+CREATE TABLE t9 (id int, i int);
+
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3);
+
+INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t5 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t6 VALUES (1, 1), (2, 2), (3, 3);
+
+INSERT INTO t7 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t8 VALUES (1, 1), (2, 2), (3, 3);
+INSERT INTO t9 VALUES (1, 1), (2, 2), (3, 3);
+
+# Only t1, t2, t3 should be replicated to slave
+sync_slave_with_master;
+echo [on slave];
+SHOW TABLES LIKE 't%';
+
+connection master;
+echo [on master];
+
+#
+# Do tables are not referenced, these statements should be ignored by
+# slave.
+#
+UPDATE t7 LEFT JOIN t4 ON (t4.id=t7.id) SET d=0, g=0 where t7.id=1;
+UPDATE t7 LEFT JOIN (t4, t5, t6) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t6.id) SET d=0, e=0, f=0, g=0 where t7.id=1;
+UPDATE t4 LEFT JOIN (t7, t8, t9) ON (t4.id=t7.id and t4.id=t8.id and t4.id=t9.id) SET d=0, g=0, h=0, i=0 where t4.id=1;
+UPDATE t7 LEFT JOIN (t8, t9) ON (t7.id=t8.id and t7.id=t9.id) SET g=0, h=0, i=0 where t7.id=1;
+
+#
+# Do tables are not referenced for update, these statements should be
+# ignored by slave.
+#
+UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET d=0 where t1.id=1;
+UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET g=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET d=0, e=0, f=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t4, t5, t8) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t8.id) SET d=0, e=0, h=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t7, t8, t5) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t5.id) SET g=0, h=0, e=0 where t1.id=1;
+UPDATE t1 LEFT JOIN (t2, t3, t5) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t5.id) SET e=0 where t1.id=1;
+
+#
+# Ignore tables are referenced for update before do tables, these
+# statements should be ignore by slave.
+#
+UPDATE t4 LEFT JOIN t1 ON (t1.id=t4.id) SET a=0, d=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t7) ON (t4.id=t1.id and t7.id=t4.id) SET a = 0, d=0, g=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t2, t3) ON (t1.id=t4.id and t2.id=t4.id and t3.id=t4.id) SET a=0, b=0, c=0, d=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t2, t5) ON (t1.id=t4.id and t2.id=t4.id and t5.id=t4.id) SET a=0, b=0, e=0, d=0 where t4.id=1;
+UPDATE t4 LEFT JOIN (t1, t6, t7) ON (t4.id=t1.id and t4.id=t6.id and t4.id=t7.id) SET a=0, d=0, f=0, g=0 where t4.id=1;
+UPDATE t7 LEFT JOIN (t4, t1, t2) ON (t7.id=t4.id and t7.id=t1.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1;
+UPDATE t7 LEFT JOIN (t8, t4, t1) ON (t7.id=t8.id and t7.id=t4.id and t7.id=t1.id) SET a=0, d=0, g=0, h=0 where t7.id=1;
+
+# Sync slave to make sure all above statements are correctly ignored,
+# if any of the above statement are not ignored, it would cause error
+# and stop slave sql thread.
+sync_slave_with_master;
+connection slave;
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t[47]. doesn.t exist. on query.* Error_code: 1146");
+connection master;
+
+# Parameters for include/wait_for_slave_sql_error_and_skip.inc:
+# Ask it to show SQL error message.
+let $show_slave_sql_error= 1;
+# The expected error will always be 1146 (ER_NO_SUCH_TABLE).
+let $slave_sql_errno= 1146;
+
+#
+# Only do tables are referenced for update, these statements should
+# cause error on slave
+#
+UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t4, t7) ON (t1.id=t4.id and t1.id=t7.id) SET a=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t2, t4, t7) ON (t1.id=t2.id and t1.id=t4.id and t1.id=t7.id) SET a=0, b=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t2, t3, t7) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t7.id) SET a=0, b=0, c=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+#
+# Do tables and other tables are referenced for update, these
+# statements should cause error on slave
+#
+UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET a=0, g=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t7 LEFT JOIN t1 ON (t1.id=t7.id) SET a=0, g=0 where t7.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t4, t5, t7) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t7.id) SET a=0, g=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t4, t7, t8) ON (t1.id=t4.id and t1.id=t7.id and t1.id=t8.id) SET a=0, g=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t7, t8, t9) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t9.id) SET a=0, g=0, h=0, i=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t7 LEFT JOIN (t1, t2, t3) ON (t7.id=t1.id and t7.id=t2.id and t7.id=t3.id) SET g=0, a=0, b=0, c=0 where t7.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t7 LEFT JOIN (t4, t5, t3) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t3.id) SET g=0, c=0 where t7.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t7 LEFT JOIN (t8, t9, t3) ON (t7.id=t8.id and t7.id=t9.id and t7.id=t3.id) SET g=0, h=0, i=0, c=0 where t7.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+#
+# Do tables are referenced for update before ignore tables
+#
+UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0, d=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET a=0, d=0, e=0, f=0 where t1.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t4 LEFT JOIN (t1, t5, t6) ON (t4.id=t1.id and t4.id=t5.id and t4.id=t6.id) SET a=0, e=0, f=0 where t4.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+UPDATE t7 LEFT JOIN (t1, t4, t2) ON (t7.id=t1.id and t7.id=t4.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1;
+source include/wait_for_slave_sql_error_and_skip.inc;
+
+sync_slave_with_master;
+echo [on slave];
+
+# We should only have tables t1, t2, t3 on slave
+show tables like 't%';
+
+# The rows in these tables should remain untouched
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+# Clean up
+connection master;
+echo [on master];
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+--source include/rpl_end.inc
+
+connection slave;
+SET @@GLOBAL.replicate_do_table="";
+SET @@GLOBAL.replicate_ignore_table="";

=== added file 'mysql-test/suite/rpl/t/rpl_filter_wild_tables_dynamic.test'
--- a/mysql-test/suite/rpl/t/rpl_filter_wild_tables_dynamic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_filter_wild_tables_dynamic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,50 @@
+#
+# Test if dynamic replication wild table filter rules are properly evaluated.
+#
+
+source include/have_binlog_format_statement.inc;
+source include/master-slave.inc;
+
+connection slave;
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.replicate_wild_do_table="test.a%";
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.replicate_wild_ignore_table="test.b%";
+
+connection slave;
+source include/stop_slave.inc;
+SET @@GLOBAL.replicate_wild_do_table="test.a%";
+SET @@GLOBAL.replicate_wild_ignore_table="test.b%";
+source include/start_slave.inc;
+connection master;
+
+# Table is mentioned in wild-do-table rules
+CREATE TABLE a1 (a INT);
+
+# Table is mentioned in wild-ignore-table rules
+CREATE TABLE b1 (a INT);
+
+# Table is not mentioned in wild-do-table or wild-ignore-table rules
+CREATE TABLE c1 (a INT);
+
+INSERT INTO a1 VALUES (1);
+INSERT INTO b1 VALUES (2);
+INSERT INTO c1 VALUES (3);
+
+# Only a1 should be replicated to slave
+sync_slave_with_master;
+echo [on slave];
+SHOW TABLES LIKE '%1';
+
+connection master;
+echo [on master];
+
+# Clean up
+connection master;
+echo [on master];
+DROP TABLE IF EXISTS a1,b1,c1;
+--source include/rpl_end.inc
+
+connection slave;
+SET @@GLOBAL.replicate_wild_do_table="";
+SET @@GLOBAL.replicate_wild_ignore_table="";

=== modified file 'mysql-test/suite/rpl/t/rpl_multi_update2.test'
--- a/mysql-test/suite/rpl/t/rpl_multi_update2.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_multi_update2.test	2012-02-09 17:58:33 +0000
@@ -6,6 +6,7 @@
 #######################################################
 --source include/not_ndb_default.inc
 --source include/master-slave.inc
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
 let $engine_type=MyISAM;
 --source extra/rpl_tests/rpl_multi_update2.test
 --source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_multi_update3.test'
--- a/mysql-test/suite/rpl/t/rpl_multi_update3.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_multi_update3.test	2012-02-09 17:58:33 +0000
@@ -6,6 +6,7 @@
 #######################################################
 --source include/not_ndb_default.inc
 --source include/master-slave.inc
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
 let $engine_type=MyISAM;
 -- source extra/rpl_tests/rpl_multi_update3.test
 --source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_optimize.test'
--- a/mysql-test/suite/rpl/t/rpl_optimize.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/suite/rpl/t/rpl_optimize.test	2012-03-27 23:04:46 +0000
@@ -25,19 +25,21 @@
 
 create table t1 (a int not null auto_increment primary key, b int, key(b));
 INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
-INSERT INTO t1 (a) SELECT null FROM t1;
+--disable_warnings
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+--enable_warnings
 save_master_pos;
 # a few updates to force OPTIMIZE to do something
 --disable_warnings

=== added file 'mysql-test/suite/rpl/t/rpl_report_port-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_report_port-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_report_port-slave.opt	2012-02-28 08:32:27 +0000
@@ -0,0 +1,1 @@
+--report-port=

=== added file 'mysql-test/suite/rpl/t/rpl_report_port.test'
--- a/mysql-test/suite/rpl/t/rpl_report_port.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_report_port.test	2012-03-09 02:37:16 +0000
@@ -0,0 +1,49 @@
+#
+#BUG#13333431 : INCORRECT DEFAULT PORT IN 'SHOW SLAVE HOSTS' OUTPUT 
+#
+# ==== Purpose ====
+#
+# The test show the default value printed for the slave's port number if the 
+# --report-port= <some value> is not set on the slave. This is different from
+# the present scenario which show 3306 as the default value if the report-port 
+# is not set on the slave. 
+#
+#====Method====
+#
+# Start replication with report port not set.This will give the actual port 
+# number of the slave (ie. SLAVE_PORT) for the on doing SHOW SLAVE HOSTS on 
+# the master.
+# Restart the slave server with report port set to 9000 and start the slave.
+# In this case on doing SHOW SLAVE HOSTS on the master, we get the port number
+# of the slave to be 9000.
+
+source include/master-slave.inc;
+
+connection master;
+
+--let $report_port= query_get_value(SHOW SLAVE HOSTS, Port, 1)
+--let assert_text= The default value shown for the slave's port number is the actual port number of the slave.
+--let assert_cond= $report_port = "$SLAVE_MYPORT"
+--source include/assert.inc
+
+# Start the server with some value being passed to the report_port= <option>
+# this will be used incase we have to mask the value of the slave's port
+# number in certain situations.
+
+--let $rpl_server_number= 2
+--let $rpl_server_parameters= --report-port=9000
+--source include/rpl_restart_server.inc
+
+connection slave;
+--source include/start_slave.inc
+
+--echo [Slave restarted with the report-port set to some value]
+connection master;
+
+# 9000 is the value of the port we should get.
+--let $report_port= query_get_value(SHOW SLAVE HOSTS, Port, 1)
+--let assert_text= The value shown for the slave's port number is 9000 which is the value set for report-port.
+--let assert_cond= $report_port = "9000"
+--source include/assert.inc
+
+--source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_rotate_logs.test'
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test	2012-03-27 23:04:46 +0000
@@ -27,6 +27,7 @@
 chmod 0000 $MYSQLD_SLAVE_DATADIR/master.info;
 connection slave;
 
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
 # START SLAVE will fail because it can't read the file (mode 000)
 # (system error 13)
 --replace_result $MYSQL_TEST_DIR TESTDIR

=== modified file 'mysql-test/suite/rpl/t/rpl_semi_sync_event.test'
--- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test	2011-07-02 20:08:51 +0000
+++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test	2012-03-27 23:04:46 +0000
@@ -52,9 +52,10 @@
 replace_result $engine_type ENGINE_TYPE;
 eval CREATE TABLE t1 (i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f varchar(8)) ENGINE=$engine_type;
 INSERT INTO t1 (f) VALUES ('a'),('a'),('a'),('a'),('a');
+--disable_warnings
 INSERT INTO t1 SELECT i+5, f FROM t1;
 INSERT INTO t1 SELECT i+10, f FROM t1;
-
+--enable_warnings
 CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND
 DO INSERT INTO t1 VALUES (SLEEP(5),CONCAT('ev1_',CONNECTION_ID()));
 CREATE EVENT ev2 ON SCHEDULE EVERY 1 SECOND

=== modified file 'mysql-test/suite/rpl/t/rpl_show_slave_hosts.test'
--- a/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test	2011-05-10 11:41:09 +0000
+++ b/mysql-test/suite/rpl/t/rpl_show_slave_hosts.test	2012-02-28 08:32:27 +0000
@@ -25,6 +25,7 @@
 # 3 is server_id of slave2.
 let $condition= ='3';
 source include/wait_show_condition.inc;
+--replace_column 3 'SLAVE_PORT'
 --replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
 SHOW SLAVE HOSTS;
 

=== modified file 'mysql-test/suite/rpl/t/rpl_start_stop_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test	2012-03-16 16:47:31 +0000
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test	2012-03-21 14:41:20 +0000
@@ -28,7 +28,8 @@
 
 --replace_regex /kill [0-9]*/kill <connection_id>/
 --eval kill $connection_id
-
+let $wait_condition= SELECT COUNT(*) = 0 FROM information_schema.processlist where id=$connection_id;
+--source include/wait_condition.inc
 set @time_after_kill := (select CURRENT_TIMESTAMP);
 
 --echo [Time after the query]
@@ -38,10 +39,9 @@
 --echo # assert : The difference between the timestamps 'time_after_kill' and 'time_before_kill' should be less than 60sec.
 --die
 }
-
 --echo [Killing of the slave IO thread was successful]
---disable_warnings
+
 START SLAVE IO_THREAD;
---enable_warnings
+
 # End of test
 --source include/rpl_end.inc

=== added file 'mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space-slave.opt	2012-03-12 12:28:27 +0000
@@ -0,0 +1,1 @@
+--relay-log-space-limit=8192 --relay-log-purge --max-relay-log-size=4096

=== added file 'mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_relay_ign_space.test	2012-03-12 23:26:00 +0000
@@ -0,0 +1,101 @@
+#
+# BUG#12400313 / BUG#64503 test case
+#
+#
+# Description
+# -----------
+#  
+# This test case starts the slave server with: 
+# --relay-log-space-limit=8192 --relay-log-purge --max-relay-log-size=4096
+# 
+# Then it issues some queries that will cause the slave to reach
+# relay-log-space-limit. We lock the table so that the SQL thread is
+# not able to purge the log and then we issue some more statements.
+#
+# The purpose is to show that the IO thread will honor the limits
+# while the SQL thread is not able to purge the relay logs, which did
+# not happen before this patch. In addition we assert that while
+# ignoring the limit (SQL thread needs to rotate before purging), the
+# IO thread does not do it in an uncontrolled manner.
+
+--source include/have_binlog_format_statement.inc
+--source include/master-slave.inc
+--source include/have_innodb.inc
+
+--disable_query_log
+CREATE TABLE t1 (c1 TEXT) engine=InnoDB;
+
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+
+--sync_slave_with_master
+
+# wait for the SQL thread to sleep
+--let $show_statement= SHOW PROCESSLIST
+--let $field= State
+--let $condition= = 'Slave has read all relay log; waiting for the slave I/O thread to update it'
+--source include/wait_show_condition.inc
+
+# now the io thread has set rli->ignore_space_limit
+# lets lock the table so that once the SQL thread awakes
+# it blocks there and does not set rli->ignore_space_limit
+# back to zero
+LOCK TABLE t1 WRITE;
+
+# now issue more statements that will overflow the 
+# rli->log_space_limit (in this case ~10K)
+--connection master
+
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+INSERT INTO t1 VALUES ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
+
+--connection slave
+
+# ASSERT that the IO thread waits for the SQL thread to release some 
+# space before continuing
+--let $show_statement= SHOW PROCESSLIST
+--let $field= State
+--let $condition= LIKE 'Waiting for %'
+# before the patch (IO would have transfered everything)
+#--let $condition= = 'Waiting for master to send event'
+# after the patch (now it waits for space to be freed)
+#--let $condition= = 'Waiting for the slave SQL thread to free enough relay log space'
+--source include/wait_show_condition.inc
+
+# without the patch we can uncomment the following two lines and
+# watch the IO thread synchronize with the master, thus writing 
+# relay logs way over the space limit
+#--connection master
+#--source include/sync_slave_io_with_master.inc
+
+## ASSERT that the IO thread has honored the limit+few bytes required to be able to purge
+--let $relay_log_space_while_sql_is_executing = query_get_value(SHOW SLAVE STATUS, Relay_Log_Space, 1)
+--let $relay_log_space_limit = query_get_value(SHOW VARIABLES LIKE "relay_log_space_limit", Value, 1)
+--let $assert_text= Assert that relay log space is close to the limit
+--let $assert_cond= $relay_log_space_while_sql_is_executing <= $relay_log_space_limit * 1.15
+--source include/assert.inc
+
+# unlock the table and let SQL thread continue applying events
+UNLOCK TABLES;
+
+--connection master
+--sync_slave_with_master
+--let $diff_tables=master:test.t1,slave:test.t1
+--source include/diff_tables.inc
+
+--connection master
+DROP TABLE t1;
+--enable_query_log
+--sync_slave_with_master
+
+--source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_timezone.test'
--- a/mysql-test/suite/rpl/t/rpl_timezone.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/t/rpl_timezone.test	2012-02-09 17:58:33 +0000
@@ -13,14 +13,14 @@
 # timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem
 # and possibly Konstantin).
 
+source include/master-slave.inc;
+
 --disable_query_log
 CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
 --enable_query_log
 
 --disable_ps_protocol
 
-source include/master-slave.inc;
-
 # Save original timezone
 set @my_time_zone= @@global.time_zone;
 
@@ -90,6 +90,7 @@
 # from originally inserted)
 #
 set time_zone='MET';
+--disable_warnings ONCE
 insert into t2 (select * from t1);
 SELECT * FROM t1 ORDER BY n;
 sync_slave_with_master;

=== modified file 'mysql-test/suite/sys_vars/r/debug_dbug_func.result'
--- a/mysql-test/suite/sys_vars/r/debug_dbug_func.result	2012-02-23 06:52:27 +0000
+++ b/mysql-test/suite/sys_vars/r/debug_dbug_func.result	2012-03-23 19:49:47 +0000
@@ -51,13 +51,13 @@
 SET @old_globaldebug = @@global.debug;
 SET @old_sessiondebug= @@session.debug;
 # Test 1 - Bug test case, single connection
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.1.trace';
+SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.1.trace';
 SET SESSION debug_dbug= '-d:-t:-i';
 SET GLOBAL  debug_dbug= '';
 SET SESSION debug_dbug= '';
 # Test 2 - Bug test case, two connections
 # Connection default
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.2.trace';
+SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.2.trace';
 SET SESSION debug_dbug= '-d:-t:-i';
 # Connection con1
 SET GLOBAL  debug_dbug= '';
@@ -68,12 +68,21 @@
 SET GLOBAL  debug_dbug= '';
 # Test 3 - Active session trace file on disconnect
 # Connection con1
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.3.trace';
-SET SESSION debug_dbug= '-d:-t:-i';
+SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.3.trace';
+SELECT @@global.debug_dbug, @@session.debug_dbug;
+@@global.debug_dbug	@@session.debug_dbug
+O,MYSQL_TMP_DIR/bug46165.3.trace	O,MYSQL_TMP_DIR/bug46165.3.trace
+SET SESSION debug_dbug= '+T';
+SELECT @@global.debug_dbug, @@session.debug_dbug;
+@@global.debug_dbug	@@session.debug_dbug
+O,MYSQL_TMP_DIR/bug46165.3.trace	O,MYSQL_TMP_DIR/bug46165.3.trace:T
 SET GLOBAL  debug_dbug= '';
+SELECT @@global.debug_dbug, @@session.debug_dbug;
+@@global.debug_dbug	@@session.debug_dbug
+	O,MYSQL_TMP_DIR/bug46165.3.trace:T
 # Test 4 - Active session trace file on two connections
 # Connection default
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.4.trace';
+SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.4.trace';
 SET SESSION debug_dbug= '-d:-t:-i';
 # Connection con1
 SET SESSION debug_dbug= '-d:-t:-i';
@@ -84,8 +93,8 @@
 # Connection con1
 # Connection default
 # Test 5 - Different trace files
-SET SESSION debug_dbug= '+O,../../log/bug46165.5.trace';
-SET SESSION debug_dbug= '+O,../../log/bug46165.6.trace';
+SET SESSION debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.5.trace';
+SET SESSION debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.6.trace';
 SET SESSION debug_dbug= '-O';
 SET GLOBAL  debug_dbug= @old_globaldebug;
 SET SESSION debug_dbug= @old_sessiondebug;

=== modified file 'mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_basic.result	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_basic.result	2012-04-02 10:33:16 +0000
@@ -73,8 +73,8 @@
 ERROR 42000: Incorrect argument type to variable 'innodb_adaptive_flushing'
 set global innodb_adaptive_flushing=2;
 ERROR 42000: Variable 'innodb_adaptive_flushing' can't be set to the value of '2'
-NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
 set global innodb_adaptive_flushing=-3;
+ERROR 42000: Variable 'innodb_adaptive_flushing' can't be set to the value of '-3'
 select @@global.innodb_adaptive_flushing;
 @@global.innodb_adaptive_flushing
 1

=== modified file 'mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_basic.result	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_basic.result	2012-04-02 10:33:16 +0000
@@ -73,8 +73,8 @@
 ERROR 42000: Incorrect argument type to variable 'innodb_adaptive_hash_index'
 set global innodb_adaptive_hash_index=2;
 ERROR 42000: Variable 'innodb_adaptive_hash_index' can't be set to the value of '2'
-NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
 set global innodb_adaptive_hash_index=-3;
+ERROR 42000: Variable 'innodb_adaptive_hash_index' can't be set to the value of '-3'
 select @@global.innodb_adaptive_hash_index;
 @@global.innodb_adaptive_hash_index
 1

=== modified file 'mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result	2011-08-17 03:51:40 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result	2012-04-02 10:33:16 +0000
@@ -73,8 +73,8 @@
 ERROR 42000: Incorrect argument type to variable 'innodb_large_prefix'
 set global innodb_large_prefix=2;
 ERROR 42000: Variable 'innodb_large_prefix' can't be set to the value of '2'
-NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
 set global innodb_large_prefix=-3;
+ERROR 42000: Variable 'innodb_large_prefix' can't be set to the value of '-3'
 select @@global.innodb_large_prefix;
 @@global.innodb_large_prefix
 1

=== modified file 'mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result	2011-07-19 14:54:59 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result	2012-04-02 10:33:16 +0000
@@ -73,17 +73,17 @@
 ERROR 42000: Incorrect argument type to variable 'innodb_random_read_ahead'
 set global innodb_random_read_ahead=2;
 ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of '2'
-NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
 set global innodb_random_read_ahead=-3;
+ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of '-3'
 select @@global.innodb_random_read_ahead;
 @@global.innodb_random_read_ahead
-1
+0
 select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
 VARIABLE_NAME	VARIABLE_VALUE
-INNODB_RANDOM_READ_AHEAD	ON
+INNODB_RANDOM_READ_AHEAD	OFF
 select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
 VARIABLE_NAME	VARIABLE_VALUE
-INNODB_RANDOM_READ_AHEAD	ON
+INNODB_RANDOM_READ_AHEAD	OFF
 set global innodb_random_read_ahead='AUTO';
 ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of 'AUTO'
 SET @@global.innodb_random_read_ahead = @start_global_value;

=== modified file 'mysql-test/suite/sys_vars/r/innodb_stats_on_metadata_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_stats_on_metadata_basic.result	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_stats_on_metadata_basic.result	2012-04-02 10:33:16 +0000
@@ -73,8 +73,8 @@
 ERROR 42000: Incorrect argument type to variable 'innodb_stats_on_metadata'
 set global innodb_stats_on_metadata=2;
 ERROR 42000: Variable 'innodb_stats_on_metadata' can't be set to the value of '2'
-NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
 set global innodb_stats_on_metadata=-3;
+ERROR 42000: Variable 'innodb_stats_on_metadata' can't be set to the value of '-3'
 select @@global.innodb_stats_on_metadata;
 @@global.innodb_stats_on_metadata
 1

=== modified file 'mysql-test/suite/sys_vars/r/innodb_strict_mode_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_strict_mode_basic.result	2010-08-13 19:07:22 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_strict_mode_basic.result	2012-04-02 10:33:16 +0000
@@ -99,9 +99,10 @@
 ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of 'AUTO'
 set session innodb_strict_mode='AUTO';
 ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of 'AUTO'
-NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
 set global innodb_strict_mode=-3;
+ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of '-3'
 set session innodb_strict_mode=-7;
+ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of '-7'
 select @@global.innodb_strict_mode;
 @@global.innodb_strict_mode
 1

=== modified file 'mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result	2012-04-02 10:33:16 +0000
@@ -73,6 +73,7 @@
 SET @@session.innodb_support_xa = ?FF;
 ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of '?FF'
 SET @@global.innodb_support_xa = -1;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of '-1'
 SELECT @@global.innodb_support_xa;
 @@global.innodb_support_xa
 1

=== modified file 'mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result	2012-04-02 10:33:16 +0000
@@ -55,6 +55,7 @@
 1
 '#--------------------FN_DYNVARS_046_04-------------------------#'
 SET @@session.innodb_table_locks = -6;
+ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '-6'
 SET @@session.innodb_table_locks = 1.6;
 ERROR 42000: Incorrect argument type to variable 'innodb_table_locks'
 SET @@session.innodb_table_locks = "T";
@@ -72,6 +73,7 @@
 SET @@session.innodb_table_locks = ?FF;
 ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '?FF'
 SET @@global.innodb_table_locks = -1;
+ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '-1'
 SET @@global.innodb_table_locks = 2;
 ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '2'
 SET @@global.innodb_table_locks = "T";

=== added file 'mysql-test/suite/sys_vars/r/replicate_do_db_basic.result'
--- a/mysql-test/suite/sys_vars/r/replicate_do_db_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/replicate_do_db_basic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,37 @@
+#
+# Basic testing of replicate_do_db.
+#
+SET @save_replicate_do_db = @@GLOBAL.replicate_do_db;
+SELECT @save_replicate_do_db;
+ at save_replicate_do_db
+
+# Scope.
+SET @@SESSION.replicate_do_db = "";
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@SESSION.replicate_do_db;
+ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable
+# Incorrect type.
+SET @@GLOBAL.replicate_do_db=1;
+ERROR 42000: Incorrect argument type to variable 'replicate_do_db'
+SET @@GLOBAL.replicate_do_db=1.1;
+ERROR 42000: Incorrect argument type to variable 'replicate_do_db'
+SET @@GLOBAL.replicate_do_db=1e1;
+ERROR 42000: Incorrect argument type to variable 'replicate_do_db'
+# Argument syntax.
+SET @@GLOBAL.replicate_do_db="db1,,,,,db3";
+SELECT @@GLOBAL.replicate_do_db;
+@@GLOBAL.replicate_do_db
+db1,db3
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_do_db';
+VARIABLE_NAME	VARIABLE_VALUE
+REPLICATE_DO_DB	db1,db3
+SET @@GLOBAL.replicate_do_db="db1,,,db2,,,db3";
+SELECT @@GLOBAL.replicate_do_db;
+@@GLOBAL.replicate_do_db
+db1,db2,db3
+SET @@GLOBAL.replicate_do_db="";
+SELECT @@GLOBAL.replicate_do_db;
+@@GLOBAL.replicate_do_db
+
+# Cleanup.
+SET @@GLOBAL.replicate_do_db = @save_replicate_do_db;

=== added file 'mysql-test/suite/sys_vars/r/replicate_do_table_basic.result'
--- a/mysql-test/suite/sys_vars/r/replicate_do_table_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/replicate_do_table_basic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,44 @@
+#
+# Basic testing of replicate_do_table.
+#
+SET @save_replicate_do_table = @@GLOBAL.replicate_do_table;
+SELECT @save_replicate_do_table;
+ at save_replicate_do_table
+
+# Scope.
+SET @@SESSION.replicate_do_table = "";
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@SESSION.replicate_do_table;
+ERROR HY000: Variable 'replicate_do_table' is a GLOBAL variable
+# Incorrect type.
+SET @@GLOBAL.replicate_do_table=1;
+ERROR 42000: Incorrect argument type to variable 'replicate_do_table'
+SET @@GLOBAL.replicate_do_table=1.1;
+ERROR 42000: Incorrect argument type to variable 'replicate_do_table'
+SET @@GLOBAL.replicate_do_table=1e1;
+ERROR 42000: Incorrect argument type to variable 'replicate_do_table'
+# Incorrect arguments.
+SET @@GLOBAL.replicate_do_table="t1";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_do_table="test.t1, t2";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_do_table="test.,t1";
+ERROR HY000: Incorrect arguments to SET
+# Argument syntax.
+SET @@GLOBAL.replicate_do_table="test.t1,,,,,test.t3";
+SELECT @@GLOBAL.replicate_do_table;
+@@GLOBAL.replicate_do_table
+test.t3,test.t1
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_do_table';
+VARIABLE_NAME	VARIABLE_VALUE
+REPLICATE_DO_TABLE	test.t3,test.t1
+SET @@GLOBAL.replicate_do_table="test.t1,,,test2.t2,,,test.t3";
+SELECT @@GLOBAL.replicate_do_table;
+@@GLOBAL.replicate_do_table
+test.t3,test.t1,test2.t2
+SET @@GLOBAL.replicate_do_table="";
+SELECT @@GLOBAL.replicate_do_table;
+@@GLOBAL.replicate_do_table
+
+# Cleanup.
+SET @@GLOBAL.replicate_do_table = @save_replicate_do_table;

=== added file 'mysql-test/suite/sys_vars/r/replicate_ignore_db_basic.result'
--- a/mysql-test/suite/sys_vars/r/replicate_ignore_db_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/replicate_ignore_db_basic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,37 @@
+#
+# Basic testing of replicate_ignore_db.
+#
+SET @save_replicate_ignore_db = @@GLOBAL.replicate_ignore_db;
+SELECT @save_replicate_ignore_db;
+ at save_replicate_ignore_db
+
+# Scope.
+SET @@SESSION.replicate_ignore_db = "";
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@SESSION.replicate_ignore_db;
+ERROR HY000: Variable 'replicate_ignore_db' is a GLOBAL variable
+# Incorrect type.
+SET @@GLOBAL.replicate_ignore_db=1;
+ERROR 42000: Incorrect argument type to variable 'replicate_ignore_db'
+SET @@GLOBAL.replicate_ignore_db=1.1;
+ERROR 42000: Incorrect argument type to variable 'replicate_ignore_db'
+SET @@GLOBAL.replicate_ignore_db=1e1;
+ERROR 42000: Incorrect argument type to variable 'replicate_ignore_db'
+# Argument syntax.
+SET @@GLOBAL.replicate_ignore_db="db1,,,,,db3";
+SELECT @@GLOBAL.replicate_ignore_db;
+@@GLOBAL.replicate_ignore_db
+db1,db3
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_ignore_db';
+VARIABLE_NAME	VARIABLE_VALUE
+REPLICATE_IGNORE_DB	db1,db3
+SET @@GLOBAL.replicate_ignore_db="db1,,,db2,,,db3";
+SELECT @@GLOBAL.replicate_ignore_db;
+@@GLOBAL.replicate_ignore_db
+db1,db2,db3
+SET @@GLOBAL.replicate_ignore_db="";
+SELECT @@GLOBAL.replicate_ignore_db;
+@@GLOBAL.replicate_ignore_db
+
+# Cleanup.
+SET @@GLOBAL.replicate_ignore_db = @save_replicate_ignore_db;

=== added file 'mysql-test/suite/sys_vars/r/replicate_ignore_table_basic.result'
--- a/mysql-test/suite/sys_vars/r/replicate_ignore_table_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/replicate_ignore_table_basic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,44 @@
+#
+# Basic testing of replicate_ignore_table.
+#
+SET @save_replicate_ignore_table = @@GLOBAL.replicate_ignore_table;
+SELECT @save_replicate_ignore_table;
+ at save_replicate_ignore_table
+
+# Scope.
+SET @@SESSION.replicate_ignore_table = "";
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@SESSION.replicate_ignore_table;
+ERROR HY000: Variable 'replicate_ignore_table' is a GLOBAL variable
+# Incorrect type.
+SET @@GLOBAL.replicate_ignore_table=1;
+ERROR 42000: Incorrect argument type to variable 'replicate_ignore_table'
+SET @@GLOBAL.replicate_ignore_table=1.1;
+ERROR 42000: Incorrect argument type to variable 'replicate_ignore_table'
+SET @@GLOBAL.replicate_ignore_table=1e1;
+ERROR 42000: Incorrect argument type to variable 'replicate_ignore_table'
+# Incorrect arguments.
+SET @@GLOBAL.replicate_ignore_table="t1";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_ignore_table="test.t1, t2";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_ignore_table="test.,t1";
+ERROR HY000: Incorrect arguments to SET
+# Argument syntax.
+SET @@GLOBAL.replicate_ignore_table="test.t1,,,,,test.t3";
+SELECT @@GLOBAL.replicate_ignore_table;
+@@GLOBAL.replicate_ignore_table
+test.t3,test.t1
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_ignore_table';
+VARIABLE_NAME	VARIABLE_VALUE
+REPLICATE_IGNORE_TABLE	test.t3,test.t1
+SET @@GLOBAL.replicate_ignore_table="test.t1,,,test2.t2,,,test.t3";
+SELECT @@GLOBAL.replicate_ignore_table;
+@@GLOBAL.replicate_ignore_table
+test.t3,test.t1,test2.t2
+SET @@GLOBAL.replicate_ignore_table="";
+SELECT @@GLOBAL.replicate_ignore_table;
+@@GLOBAL.replicate_ignore_table
+
+# Cleanup.
+SET @@GLOBAL.replicate_ignore_table = @save_replicate_ignore_table;

=== added file 'mysql-test/suite/sys_vars/r/replicate_wild_do_table_basic.result'
--- a/mysql-test/suite/sys_vars/r/replicate_wild_do_table_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/replicate_wild_do_table_basic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,44 @@
+#
+# Basic testing of replicate_wild_do_table.
+#
+SET @save_replicate_wild_do_table = @@GLOBAL.replicate_wild_do_table;
+SELECT @save_replicate_wild_do_table;
+ at save_replicate_wild_do_table
+
+# Scope.
+SET @@SESSION.replicate_wild_do_table = "";
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@SESSION.replicate_wild_do_table;
+ERROR HY000: Variable 'replicate_wild_do_table' is a GLOBAL variable
+# Incorrect type.
+SET @@GLOBAL.replicate_wild_do_table=1;
+ERROR 42000: Incorrect argument type to variable 'replicate_wild_do_table'
+SET @@GLOBAL.replicate_wild_do_table=1.1;
+ERROR 42000: Incorrect argument type to variable 'replicate_wild_do_table'
+SET @@GLOBAL.replicate_wild_do_table=1e1;
+ERROR 42000: Incorrect argument type to variable 'replicate_wild_do_table'
+# Incorrect arguments.
+SET @@GLOBAL.replicate_wild_do_table="t1";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_wild_do_table="test.t, t2";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_wild_do_table="test.,t1";
+ERROR HY000: Incorrect arguments to SET
+# Argument syntax.
+SET @@GLOBAL.replicate_wild_do_table="test.%,,,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_do_table;
+@@GLOBAL.replicate_wild_do_table
+test.%,test.t3
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_wild_do_table';
+VARIABLE_NAME	VARIABLE_VALUE
+REPLICATE_WILD_DO_TABLE	test.%,test.t3
+SET @@GLOBAL.replicate_wild_do_table="test.t1,,,test2.%,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_do_table;
+@@GLOBAL.replicate_wild_do_table
+test.t1,test2.%,test.t3
+SET @@GLOBAL.replicate_wild_do_table="";
+SELECT @@GLOBAL.replicate_wild_do_table;
+@@GLOBAL.replicate_wild_do_table
+
+# Cleanup.
+SET @@GLOBAL.replicate_wild_do_table = @save_replicate_wild_do_table;

=== added file 'mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_basic.result'
--- a/mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/replicate_wild_ignore_table_basic.result	2012-03-19 22:00:23 +0000
@@ -0,0 +1,44 @@
+#
+# Basic testing of replicate_wild_ignore_table.
+#
+SET @save_replicate_wild_ignore_table = @@GLOBAL.replicate_wild_ignore_table;
+SELECT @save_replicate_wild_ignore_table;
+ at save_replicate_wild_ignore_table
+
+# Scope.
+SET @@SESSION.replicate_wild_ignore_table = "";
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@SESSION.replicate_wild_ignore_table;
+ERROR HY000: Variable 'replicate_wild_ignore_table' is a GLOBAL variable
+# Incorrect type.
+SET @@GLOBAL.replicate_wild_ignore_table=1;
+ERROR 42000: Incorrect argument type to variable 'replicate_wild_ignore_table'
+SET @@GLOBAL.replicate_wild_ignore_table=1.1;
+ERROR 42000: Incorrect argument type to variable 'replicate_wild_ignore_table'
+SET @@GLOBAL.replicate_wild_ignore_table=1e1;
+ERROR 42000: Incorrect argument type to variable 'replicate_wild_ignore_table'
+# Incorrect arguments.
+SET @@GLOBAL.replicate_wild_ignore_table="t1";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_wild_ignore_table="test.t, t2";
+ERROR HY000: Incorrect arguments to SET
+SET @@GLOBAL.replicate_wild_ignore_table="test.,t1";
+ERROR HY000: Incorrect arguments to SET
+# Argument syntax.
+SET @@GLOBAL.replicate_wild_ignore_table="test.%,,,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_ignore_table;
+@@GLOBAL.replicate_wild_ignore_table
+test.%,test.t3
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_wild_ignore_table';
+VARIABLE_NAME	VARIABLE_VALUE
+REPLICATE_WILD_IGNORE_TABLE	test.%,test.t3
+SET @@GLOBAL.replicate_wild_ignore_table="test.t1,,,test2.%,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_ignore_table;
+@@GLOBAL.replicate_wild_ignore_table
+test.t1,test2.%,test.t3
+SET @@GLOBAL.replicate_wild_ignore_table="";
+SELECT @@GLOBAL.replicate_wild_ignore_table;
+@@GLOBAL.replicate_wild_ignore_table
+
+# Cleanup.
+SET @@GLOBAL.replicate_wild_ignore_table = @save_replicate_wild_ignore_table;

=== modified file 'mysql-test/suite/sys_vars/r/rpl_semi_sync_master_enabled_basic.result'
--- a/mysql-test/suite/sys_vars/r/rpl_semi_sync_master_enabled_basic.result	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/r/rpl_semi_sync_master_enabled_basic.result	2012-04-02 10:33:16 +0000
@@ -45,7 +45,7 @@
 ERROR HY000: Variable 'rpl_semi_sync_master_enabled' is a GLOBAL variable and should be set with SET GLOBAL
 select @@global.rpl_semi_sync_master_enabled;
 @@global.rpl_semi_sync_master_enabled
--1
+1
 select @@session.rpl_semi_sync_master_enabled;
 ERROR HY000: Variable 'rpl_semi_sync_master_enabled' is a GLOBAL variable
 show global variables like 'rpl_semi_sync_master_enabled';

=== modified file 'mysql-test/suite/sys_vars/r/rpl_semi_sync_slave_enabled_basic.result'
--- a/mysql-test/suite/sys_vars/r/rpl_semi_sync_slave_enabled_basic.result	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/r/rpl_semi_sync_slave_enabled_basic.result	2012-04-02 10:33:16 +0000
@@ -45,7 +45,7 @@
 ERROR HY000: Variable 'rpl_semi_sync_slave_enabled' is a GLOBAL variable and should be set with SET GLOBAL
 select @@global.rpl_semi_sync_slave_enabled;
 @@global.rpl_semi_sync_slave_enabled
--1
+1
 select @@session.rpl_semi_sync_slave_enabled;
 ERROR HY000: Variable 'rpl_semi_sync_slave_enabled' is a GLOBAL variable
 show global variables like 'rpl_semi_sync_slave_enabled';

=== modified file 'mysql-test/suite/sys_vars/t/debug_dbug_func.test'
--- a/mysql-test/suite/sys_vars/t/debug_dbug_func.test	2012-02-23 06:52:27 +0000
+++ b/mysql-test/suite/sys_vars/t/debug_dbug_func.test	2012-03-23 19:49:47 +0000
@@ -59,7 +59,8 @@
 SET @old_sessiondebug= @@session.debug;
 
 --echo # Test 1 - Bug test case, single connection
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.1.trace';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval SET GLOBAL  debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.1.trace';
 SET SESSION debug_dbug= '-d:-t:-i';
 
 SET GLOBAL  debug_dbug= '';
@@ -68,7 +69,8 @@
 --echo # Test 2 - Bug test case, two connections
 --echo # Connection default
 connection default;
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.2.trace';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval SET GLOBAL  debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.2.trace';
 SET SESSION debug_dbug= '-d:-t:-i';
 
 --echo # Connection con1
@@ -89,16 +91,24 @@
 --echo # Test 3 - Active session trace file on disconnect
 --echo # Connection con1
 connect (con1, localhost, root);
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.3.trace';
-SET SESSION debug_dbug= '-d:-t:-i';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval SET GLOBAL  debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.3.trace';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT @@global.debug_dbug, @@session.debug_dbug;
+SET SESSION debug_dbug= '+T';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT @@global.debug_dbug, @@session.debug_dbug;
 SET GLOBAL  debug_dbug= '';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT @@global.debug_dbug, @@session.debug_dbug;
 disconnect con1;
 --source include/wait_until_disconnected.inc
 
 --echo # Test 4 - Active session trace file on two connections
 --echo # Connection default
 connection default;
-SET GLOBAL  debug_dbug= '+O,../../log/bug46165.4.trace';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval SET GLOBAL  debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.4.trace';
 SET SESSION debug_dbug= '-d:-t:-i';
 
 --echo # Connection con1
@@ -118,8 +128,10 @@
 connection default;
 
 --echo # Test 5 - Different trace files
-SET SESSION debug_dbug= '+O,../../log/bug46165.5.trace';
-SET SESSION debug_dbug= '+O,../../log/bug46165.6.trace';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval SET SESSION debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.5.trace';
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval SET SESSION debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.6.trace';
 SET SESSION debug_dbug= '-O';
 
 SET GLOBAL  debug_dbug= @old_globaldebug;

=== modified file 'mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_basic.test	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_basic.test	2012-04-02 10:33:16 +0000
@@ -54,7 +54,7 @@
 set global innodb_adaptive_flushing=1e1;
 --error ER_WRONG_VALUE_FOR_VAR
 set global innodb_adaptive_flushing=2;
---echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+--error ER_WRONG_VALUE_FOR_VAR
 set global innodb_adaptive_flushing=-3;
 select @@global.innodb_adaptive_flushing;
 select * from information_schema.global_variables where variable_name='innodb_adaptive_flushing';

=== modified file 'mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_basic.test	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_basic.test	2012-04-02 10:33:16 +0000
@@ -54,7 +54,7 @@
 set global innodb_adaptive_hash_index=1e1;
 --error ER_WRONG_VALUE_FOR_VAR
 set global innodb_adaptive_hash_index=2;
---echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+--error ER_WRONG_VALUE_FOR_VAR
 set global innodb_adaptive_hash_index=-3;
 select @@global.innodb_adaptive_hash_index;
 select * from information_schema.global_variables where variable_name='innodb_adaptive_hash_index';

=== modified file 'mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test	2011-08-17 03:51:40 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test	2012-04-02 10:33:16 +0000
@@ -54,7 +54,7 @@
 set global innodb_large_prefix=1e1;
 --error ER_WRONG_VALUE_FOR_VAR
 set global innodb_large_prefix=2;
---echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+--error ER_WRONG_VALUE_FOR_VAR
 set global innodb_large_prefix=-3;
 select @@global.innodb_large_prefix;
 select * from information_schema.global_variables where variable_name='innodb_large_prefix';

=== modified file 'mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test	2011-07-19 14:54:59 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test	2012-04-02 10:33:16 +0000
@@ -54,7 +54,7 @@
 set global innodb_random_read_ahead=1e1;
 --error ER_WRONG_VALUE_FOR_VAR
 set global innodb_random_read_ahead=2;
---echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+--error ER_WRONG_VALUE_FOR_VAR
 set global innodb_random_read_ahead=-3;
 select @@global.innodb_random_read_ahead;
 select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';

=== modified file 'mysql-test/suite/sys_vars/t/innodb_stats_on_metadata_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_stats_on_metadata_basic.test	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_stats_on_metadata_basic.test	2012-04-02 10:33:16 +0000
@@ -54,7 +54,7 @@
 set global innodb_stats_on_metadata=1e1;
 --error ER_WRONG_VALUE_FOR_VAR
 set global innodb_stats_on_metadata=2;
---echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+--error ER_WRONG_VALUE_FOR_VAR
 set global innodb_stats_on_metadata=-3;
 select @@global.innodb_stats_on_metadata;
 select * from information_schema.global_variables where variable_name='innodb_stats_on_metadata';

=== modified file 'mysql-test/suite/sys_vars/t/innodb_strict_mode_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_strict_mode_basic.test	2010-01-29 06:33:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_strict_mode_basic.test	2012-04-02 10:33:16 +0000
@@ -68,8 +68,9 @@
 set global innodb_strict_mode='AUTO';
 --error ER_WRONG_VALUE_FOR_VAR
 set session innodb_strict_mode='AUTO';
---echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+--error ER_WRONG_VALUE_FOR_VAR
 set global innodb_strict_mode=-3;
+--error ER_WRONG_VALUE_FOR_VAR
 set session innodb_strict_mode=-7;
 select @@global.innodb_strict_mode;
 select @@session.innodb_strict_mode;

=== modified file 'mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test	2012-04-02 10:33:16 +0000
@@ -127,6 +127,7 @@
 # for global
 
 
+--error ER_WRONG_VALUE_FOR_VAR
 SET @@global.innodb_support_xa = -1;
 SELECT @@global.innodb_support_xa;
 

=== modified file 'mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test	2012-04-02 10:33:16 +0000
@@ -106,6 +106,7 @@
 
 # for session
 
+--error ER_WRONG_VALUE_FOR_VAR
 SET @@session.innodb_table_locks = -6;
 --Error ER_WRONG_TYPE_FOR_VAR
 SET @@session.innodb_table_locks = 1.6;
@@ -127,6 +128,7 @@
 # for global
 
 
+--error ER_WRONG_VALUE_FOR_VAR
 SET @@global.innodb_table_locks = -1;
 --Error ER_WRONG_VALUE_FOR_VAR
 SET @@global.innodb_table_locks = 2;

=== added file 'mysql-test/suite/sys_vars/t/replicate_do_db_basic.test'
--- a/mysql-test/suite/sys_vars/t/replicate_do_db_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/replicate_do_db_basic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,39 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Basic testing of replicate_do_db.
+--echo #
+
+SET @save_replicate_do_db = @@GLOBAL.replicate_do_db;
+SELECT @save_replicate_do_db;
+
+--echo # Scope.
+
+--error ER_GLOBAL_VARIABLE
+SET @@SESSION.replicate_do_db = "";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@SESSION.replicate_do_db;
+
+--echo # Incorrect type.
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_do_db=1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_do_db=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_do_db=1e1;
+
+--echo # Argument syntax.
+
+SET @@GLOBAL.replicate_do_db="db1,,,,,db3";
+SELECT @@GLOBAL.replicate_do_db;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_do_db';
+
+SET @@GLOBAL.replicate_do_db="db1,,,db2,,,db3";
+SELECT @@GLOBAL.replicate_do_db;
+
+SET @@GLOBAL.replicate_do_db="";
+SELECT @@GLOBAL.replicate_do_db;
+
+--echo # Cleanup.
+SET @@GLOBAL.replicate_do_db = @save_replicate_do_db;

=== added file 'mysql-test/suite/sys_vars/t/replicate_do_table_basic.test'
--- a/mysql-test/suite/sys_vars/t/replicate_do_table_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/replicate_do_table_basic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,48 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Basic testing of replicate_do_table.
+--echo #
+
+SET @save_replicate_do_table = @@GLOBAL.replicate_do_table;
+SELECT @save_replicate_do_table;
+
+--echo # Scope.
+
+--error ER_GLOBAL_VARIABLE
+SET @@SESSION.replicate_do_table = "";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@SESSION.replicate_do_table;
+
+--echo # Incorrect type.
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_do_table=1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_do_table=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_do_table=1e1;
+
+--echo # Incorrect arguments.
+
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_do_table="t1";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_do_table="test.t1, t2";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_do_table="test.,t1";
+
+--echo # Argument syntax.
+
+SET @@GLOBAL.replicate_do_table="test.t1,,,,,test.t3";
+SELECT @@GLOBAL.replicate_do_table;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_do_table';
+
+SET @@GLOBAL.replicate_do_table="test.t1,,,test2.t2,,,test.t3";
+SELECT @@GLOBAL.replicate_do_table;
+
+SET @@GLOBAL.replicate_do_table="";
+SELECT @@GLOBAL.replicate_do_table;
+
+--echo # Cleanup.
+SET @@GLOBAL.replicate_do_table = @save_replicate_do_table;

=== added file 'mysql-test/suite/sys_vars/t/replicate_ignore_db_basic.test'
--- a/mysql-test/suite/sys_vars/t/replicate_ignore_db_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/replicate_ignore_db_basic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,39 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Basic testing of replicate_ignore_db.
+--echo #
+
+SET @save_replicate_ignore_db = @@GLOBAL.replicate_ignore_db;
+SELECT @save_replicate_ignore_db;
+
+--echo # Scope.
+
+--error ER_GLOBAL_VARIABLE
+SET @@SESSION.replicate_ignore_db = "";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@SESSION.replicate_ignore_db;
+
+--echo # Incorrect type.
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_ignore_db=1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_ignore_db=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_ignore_db=1e1;
+
+--echo # Argument syntax.
+
+SET @@GLOBAL.replicate_ignore_db="db1,,,,,db3";
+SELECT @@GLOBAL.replicate_ignore_db;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_ignore_db';
+
+SET @@GLOBAL.replicate_ignore_db="db1,,,db2,,,db3";
+SELECT @@GLOBAL.replicate_ignore_db;
+
+SET @@GLOBAL.replicate_ignore_db="";
+SELECT @@GLOBAL.replicate_ignore_db;
+
+--echo # Cleanup.
+SET @@GLOBAL.replicate_ignore_db = @save_replicate_ignore_db;

=== added file 'mysql-test/suite/sys_vars/t/replicate_ignore_table_basic.test'
--- a/mysql-test/suite/sys_vars/t/replicate_ignore_table_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/replicate_ignore_table_basic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,48 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Basic testing of replicate_ignore_table.
+--echo #
+
+SET @save_replicate_ignore_table = @@GLOBAL.replicate_ignore_table;
+SELECT @save_replicate_ignore_table;
+
+--echo # Scope.
+
+--error ER_GLOBAL_VARIABLE
+SET @@SESSION.replicate_ignore_table = "";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@SESSION.replicate_ignore_table;
+
+--echo # Incorrect type.
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_ignore_table=1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_ignore_table=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_ignore_table=1e1;
+
+--echo # Incorrect arguments.
+
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_ignore_table="t1";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_ignore_table="test.t1, t2";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_ignore_table="test.,t1";
+
+--echo # Argument syntax.
+
+SET @@GLOBAL.replicate_ignore_table="test.t1,,,,,test.t3";
+SELECT @@GLOBAL.replicate_ignore_table;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_ignore_table';
+
+SET @@GLOBAL.replicate_ignore_table="test.t1,,,test2.t2,,,test.t3";
+SELECT @@GLOBAL.replicate_ignore_table;
+
+SET @@GLOBAL.replicate_ignore_table="";
+SELECT @@GLOBAL.replicate_ignore_table;
+
+--echo # Cleanup.
+SET @@GLOBAL.replicate_ignore_table = @save_replicate_ignore_table;

=== added file 'mysql-test/suite/sys_vars/t/replicate_wild_do_table_basic.test'
--- a/mysql-test/suite/sys_vars/t/replicate_wild_do_table_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/replicate_wild_do_table_basic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,48 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Basic testing of replicate_wild_do_table.
+--echo #
+
+SET @save_replicate_wild_do_table = @@GLOBAL.replicate_wild_do_table;
+SELECT @save_replicate_wild_do_table;
+
+--echo # Scope.
+
+--error ER_GLOBAL_VARIABLE
+SET @@SESSION.replicate_wild_do_table = "";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@SESSION.replicate_wild_do_table;
+
+--echo # Incorrect type.
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_wild_do_table=1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_wild_do_table=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_wild_do_table=1e1;
+
+--echo # Incorrect arguments.
+
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_wild_do_table="t1";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_wild_do_table="test.t, t2";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_wild_do_table="test.,t1";
+
+--echo # Argument syntax.
+
+SET @@GLOBAL.replicate_wild_do_table="test.%,,,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_do_table;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_wild_do_table';
+
+SET @@GLOBAL.replicate_wild_do_table="test.t1,,,test2.%,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_do_table;
+
+SET @@GLOBAL.replicate_wild_do_table="";
+SELECT @@GLOBAL.replicate_wild_do_table;
+
+--echo # Cleanup.
+SET @@GLOBAL.replicate_wild_do_table = @save_replicate_wild_do_table;

=== added file 'mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_basic.test'
--- a/mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/replicate_wild_ignore_table_basic.test	2012-03-19 22:00:23 +0000
@@ -0,0 +1,48 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Basic testing of replicate_wild_ignore_table.
+--echo #
+
+SET @save_replicate_wild_ignore_table = @@GLOBAL.replicate_wild_ignore_table;
+SELECT @save_replicate_wild_ignore_table;
+
+--echo # Scope.
+
+--error ER_GLOBAL_VARIABLE
+SET @@SESSION.replicate_wild_ignore_table = "";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@SESSION.replicate_wild_ignore_table;
+
+--echo # Incorrect type.
+
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_wild_ignore_table=1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_wild_ignore_table=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@GLOBAL.replicate_wild_ignore_table=1e1;
+
+--echo # Incorrect arguments.
+
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_wild_ignore_table="t1";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_wild_ignore_table="test.t, t2";
+--error ER_WRONG_ARGUMENTS
+SET @@GLOBAL.replicate_wild_ignore_table="test.,t1";
+
+--echo # Argument syntax.
+
+SET @@GLOBAL.replicate_wild_ignore_table="test.%,,,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_ignore_table;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_wild_ignore_table';
+
+SET @@GLOBAL.replicate_wild_ignore_table="test.t1,,,test2.%,,,test.t3";
+SELECT @@GLOBAL.replicate_wild_ignore_table;
+
+SET @@GLOBAL.replicate_wild_ignore_table="";
+SELECT @@GLOBAL.replicate_wild_ignore_table;
+
+--echo # Cleanup.
+SET @@GLOBAL.replicate_wild_ignore_table = @save_replicate_wild_ignore_table;

=== modified file 'mysql-test/suite/sys_vars/t/report_port_basic.test'
--- a/mysql-test/suite/sys_vars/t/report_port_basic.test	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/t/report_port_basic.test	2012-02-28 08:32:27 +0000
@@ -2,18 +2,19 @@
 #
 # only global
 #
---replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
+--replace_regex s/[0-9]+/DEFAULT_MASTER_PORT/
 select @@global.report_port;
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
 select @@session.report_port;
---replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
+--replace_column 2 'DEFAULT_MASTER_PORT'
 show global variables like 'report_port';
---replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
+--replace_column 2 'DEFAULT_MASTER_PORT'
 show session variables like 'report_port';
---replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
+--replace_column 2 'DEFAULT_MASTER_PORT'
 select * from information_schema.global_variables where variable_name='report_port';
---replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
+--replace_column 2 'DEFAULT_MASTER_PORT'
 select * from information_schema.session_variables where variable_name='report_port';
+--replace_column 2 'DEFAULT_MASTER_PORT'
 
 #
 # show that it's read-only

=== added file 'mysql-test/t/bug13633383.test'
--- a/mysql-test/t/bug13633383.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/bug13633383.test	2012-02-14 07:11:28 +0000
@@ -0,0 +1,82 @@
+--echo #
+--echo # Bug#13633383 63183: SMALL SORT_BUFFER_SIZE CRASH IN MERGE_BUFFERS
+--echo #
+
+CREATE TABLE t1 (
+  `a` int(11) DEFAULT NULL,
+  `col432` bit(8) DEFAULT NULL,
+  `col433` multipoint DEFAULT NULL,
+  `col434` polygon DEFAULT NULL,
+  `col435` decimal(50,17) unsigned DEFAULT NULL,
+  `col436` geometry NOT NULL,
+  `col437` tinyblob NOT NULL,
+  `col438` multipolygon DEFAULT NULL,
+  `col439` mediumblob NOT NULL,
+  `col440` tinyblob NOT NULL,
+  `col441` double unsigned DEFAULT NULL
+);
+
+CREATE TABLE t2 (
+  `a` multipoint DEFAULT NULL,
+  `col460` date DEFAULT NULL,
+  `col461` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `col462` date NOT NULL,
+  `col463` varbinary(89) NOT NULL,
+  `col464` year(4) DEFAULT NULL,
+  `col465` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `col466` varchar(236) CHARACTER SET utf8 NOT NULL,
+  `col467` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
+);
+
+CREATE TABLE t3 (
+  `FTS_DOC_ID` bigint(20) unsigned NOT NULL,
+  `col577` datetime DEFAULT NULL,
+  `col579` bit(38) NOT NULL,
+  `col580` varchar(93) NOT NULL,
+  `col581` datetime DEFAULT NULL,
+  `col583` multipolygon DEFAULT NULL,
+  `col584` bit(47) NOT NULL
+);
+
+--disable_query_log
+
+INSERT INTO t1 VALUES (0,0xFF,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 J??',NULL,0.00000000000000000,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0??\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?C\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?C\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',0xB623A952C5,'\0\0\0\0\0\0\0\0\0\0\0?i??\0\0\0\0j??',0x22,0xD81F72A9,56403);
+INSERT INTO t1 VALUES (-32768,0x00,'\0\0\0\0\0\0\0\0\0\0\0?r?@\0\0\0\0j??','\0\0\0\0\0\0\0\0\0\0\0\0???\0\0\0\0j??',NULL,'\0\0\0\0\0\0\0\0\0\0\0?6?@\0\0\0\0\0j??',0xC80876AF04,'\0\0\0\0\0\0\0\0\0\0\0?[??\0\0\0\0?i??',0x016C576E34,0x1B,0);
+INSERT INTO t1 VALUES (-2147483648,0x17,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0]??',NULL,0.00000000000000000,'\0\0\0\0\0\0\0\0\0\0\0?i????FQ??C?',0x68D352,'\0\0\0\0\0\0\0\n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0??\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?C\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0??\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?C\0\0\0\0\0??\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0','','',0);
+INSERT INTO t1 VALUES (1,0xFF,'\0\0\0\0\0\0\0\0\0\0\0???\0\0\0\0????','\0\0\0\0\0\0\0\0\0\0\0`6?@\0\0\0\0???@',32767.00000000000000000,'\0\0\0\0\0\0\0\0\0\0\0?i?@???{??',0x1406B0C524,'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0??\0\0\0\0\0?C\0\0\0\0\0?C',0xC04B75CCFD,0xC4CD,1);
+INSERT INTO t1 VALUES (0,0xFF,NULL,'\0\0\0\0\0\0\0\0\0\0\0\0j?@\0\0\0\0\0(??',0.06140000000000000,'\0\0\0\0\0\0\0\0\0\0\0?i?@$7?H#??1',0x3F,'\0\0\0\0\0\0\0\0\0\0\0j??CHK
??$?',0x1E87C5DA,0xCC870E,NULL);
+
+
+INSERT INTO t2 VALUES ('\0\0\0\0\0\0\0\0\0\0\0\0k??\0\0\0\0\0j?@','2011-02-19','2011-08-10 14:21:44','2012-09-25',0xCCC3,0000,'2012-07-28 16:25:23','idpapxbfjrigkfqnhnfmhvtewlvxfmjhfqizhhsowbetimmkhukpzeixbfyzmsalaafssdovflpvxldldmuamfoulanivuxigbjwkzbapcxmmprpyasaozdqwqjuixajzmiepkcvnvtewdvyodupziffgzbcmsfhikbuehyhzfnxlsdzulbsrqmtszzzupcmxlvcpxahuiotgadwhpcuqmyzgrbkxzxwriqkymdaqnzz','2012-01-20 09:01:25');
+INSERT INTO t2 VALUES (NULL,'2011-05-14','2012-10-17 04:33:30','2012-01-20','',0000,'2012-05-08 11:06:53','otbywkbfwwtgpfgurtqwgfcwmmntsdxkounuzueoclrpnadghfzmbrh','2012-03-24 21:01:09');
+INSERT INTO t2 VALUES ('\0\0\0\0\0\0\06??PVh,;b???$??','2012-07-21','2011-11-21 04:23:27','2011-06-18',0x21,0000,'2011-09-10 14:01:05','goybgohrexhfqwerpknkbyiqowvcdpyxvbklkbeeuvfbjtkmontmkmgcjutkjphewnvvobzilamtjqjbtvqgczozqcmvbbzvoxkycsvplfykmzpwljdcromsilspjuoyhxwduymxkymvmijehtutftqmpfpbesonppacogyogjqhyonizbsgzwubzgeoehryqswzkftgzhzssnlstuszpwauxmdhgjcawabnjcynzrrh','2012-11-19 18:30:51');
+INSERT INTO t2 VALUES ('\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0????','2012-09-01','2012-01-20 09:01:34','2011-02-12',0x1FDF59DC65,0000,'2011-07-07 19:48:34','xohwzrslzxbpxdvqfsumavjwwmsdcgczlmxrtxavsqtnpggxesvekbcelnnrxkvvlwqwbydlhwzltwaurkfltafeijstmzueiqddjdxzddymhsungndmojndbspkezvdfhqxijxxrwiolqgnsedenszkiljgropmcbxsjntjmnonnltyiysuejsznuurmonebslawybppziavystrylwunselezpbslmkzggpziffrud','2012-01-19 22:00:00');
+INSERT INTO t2 VALUES ('\0\0\0\0\0\0\0\0\0\0\0\0j?@\0\0\0\0\0\0\0\0','0000-00-00','2012-05-21 09:59:10','2011-04-17',0x02307EDF,0000,'2012-01-20 09:01:34','vjcwlxxeydntegsdqhxgriarmbvzwzwdexcalvacxhilaejpmxdpkuvblukchagzoellbdndelfednqktzobyhjqweqaugqnfikdalmaytyunjqvxcsirhaqnvqsstgrgfscnsemseebdemfditoswccsxthnddzslgjkyujxoqsvzrssymoovqmibcmbboruyxlvopengdqqgqwekrflhvjcpondxivnshvhrnqvfls','2012-09-23 23:54:02');
+
+
+INSERT INTO t3 VALUES (11787,'2012-07-24 15:22:50',0x00000000FF,'qbdydwxepydtonqnghurnuntughjwfygzttqwtmfzfbtifjcearpatksofbrfgnaccvapahywhsstdplphrxbcubhktov','2011-08-27 19:28:03',NULL,0x00000000001C);
+
+INSERT INTO t3 VALUES (11788,'2012-05-17 08:38:13',0x3FFFFFFFFF,'jkvkjxaikruljqalyvnbfjptxgbpsgnxlzthhcrswwdcfrhilwwgqmxynxjnehwmyfzdyywjzfyasuvjbrevkxtnyodiu','2012-05-09 11:09:52',NULL,0x0000000000B8);
+
+INSERT INTO t3 VALUES (1,'2011-02-17 19:55:19',0x000098FAF3,'rnzhemtrqjdrappwbmxnzkfatcgtvqklrpfpdqiwjnjbeaxpcbhqqunbzmtmitdszxyrdvkeedqwpbiefqnwvhiznwfyq','2012-11-10 18:00:25','\0\0\0\0\0\0\0\0\0\0\0\0j??\0\0\0\0?1?@',0x7FFFFFFFFFFF);
+
+INSERT INTO t3 VALUES (11789,'2011-12-26 01:30:56',0x0000000001,'dhryqjghgixymqywclxpovwnlgnltuzdvggmlaxtzrsbpxkahkiahpkrddpoeftqqwejbjxrdzfgvkzvhcalopgumspgg','2011-03-21 06:25:44',NULL,0x00000000293A);
+
+INSERT INTO t3 VALUES (4294967296,'2011-04-12 21:05:37',0x0000CE3238,'xwcplgaxcpgfsmcjftxffxgmjwabpmrcycbxmwjvqtlvtlwuipuwgbuygnxomjplqohyuqyzsoiggroigcnchzpiilyhe','2012-03-20 05:35:39',NULL,0x00000000006E);
+
+--enable_query_log
+
+set session sort_buffer_size= 32768;
+select  col435
+from t3
+natural right outer join t1
+natural right outer join t2 a
+left outer join t2 b on 1
+group by
+    repeat('a',10000) desc,
+    repeat('a',10000)
+with rollup
+;
+set session sort_buffer_size= default;
+
+DROP TABLE  t1, t2, t3;

=== removed file 'mysql-test/t/cache_innodb-master.opt'
--- a/mysql-test/t/cache_innodb-master.opt	2010-03-03 19:22:02 +0000
+++ b/mysql-test/t/cache_innodb-master.opt	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
---query_cache_size=1M

=== modified file 'mysql-test/t/csv.test'
--- a/mysql-test/t/csv.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/t/csv.test	2012-04-07 13:58:46 +0000
@@ -1820,6 +1820,21 @@
 SELECT * FROM t1;
 DROP TABLE t1;
 
+#
+# Bug#970528 
+# Server crashes in my_strnncollsp_simple on LEFT JOIN with CSV table,
+# TEXT field
+#
+
+CREATE TABLE t1 ( b TEXT NOT NULL ) ENGINE=MYISAM;
+INSERT INTO t1 VALUES ('x'),('y');
+
+CREATE TABLE t2 ( a VARCHAR(1) NOT NULL ) ENGINE=CSV;
+INSERT INTO t2 VALUES ('r'),('t');
+
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t1 LEFT JOIN t2 ON ( b = a );
+drop table t1,t2;
 
 #
 # Bug #40814 CSV engine does not parse \X characters when they occur in unquoted fields

=== modified file 'mysql-test/t/ctype_ucs.test'
--- a/mysql-test/t/ctype_ucs.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/t/ctype_ucs.test	2012-04-10 06:28:13 +0000
@@ -796,5 +796,14 @@
 SET NAMES latin1;
 
 --echo #
+--echo # Bug #13832953 	MY_STRNXFRM_UNICODE: ASSERTION `SRC' FAILED
+--echo #
+CREATE TABLE t1 (c1 SET('','') CHARACTER SET ucs2);
+INSERT INTO t1 VALUES ('');
+SELECT COALESCE(c1) FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+
+--echo #
 --echo # End of 5.5 tests
 --echo #

=== modified file 'mysql-test/t/derived_view.test'
--- a/mysql-test/t/derived_view.test	2012-03-13 20:34:20 +0000
+++ b/mysql-test/t/derived_view.test	2012-04-05 20:32:57 +0000
@@ -1380,6 +1380,43 @@
 DROP VIEW v;
 DROP TABLE t1,t2;
 
+--echo #
+--echo # LP BUG#968720 crash due to converting to materialized and
+--echo # natural join made only once
+--echo #
+
+SET @save968720_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'derived_merge=on';
+
+CREATE TABLE t1 (a int, INDEX(a));
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (a int, INDEX(a));
+INSERT INTO t2 VALUES (1), (2);
+
+INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN
+t2 AS s2;
+SELECT * FROM t1;
+
+DELETE FROM t1;
+INSERT INTO t1 VALUES (1);
+
+PREPARE stmt FROM "
+INSERT INTO t1 SELECT a FROM (SELECT a FROM test.t1) AS s1 NATURAL JOIN
+t2 AS s2;
+";
+EXECUTE stmt;
+SELECT * FROM t1;
+EXECUTE stmt;
+SELECT * FROM t1;
+
+drop table t1,t2;
+set optimizer_switch=@save968720_optimizer_switch;
+
+--echo #
+--echo # end of 5.3 tests
+--echo #
+
 # The following command must be the last one the file 
 set optimizer_switch=@exit_optimizer_switch;
 set join_cache_level=@exit_join_cache_level;

=== modified file 'mysql-test/t/error_simulation.test'
--- a/mysql-test/t/error_simulation.test	2012-01-13 14:50:02 +0000
+++ b/mysql-test/t/error_simulation.test	2012-03-23 19:49:47 +0000
@@ -23,7 +23,7 @@
 
 # Set debug flag so an error is returned when
 # tmp table in query is converted from heap to myisam
-set session debug_dbug="d,raise_error";
+set session debug_dbug="+d,raise_error";
 
 --replace_regex /in table '[^']+'/in table 'tmp_table'/
 --error ER_DUP_KEY

=== modified file 'mysql-test/t/events_restart.test'
--- a/mysql-test/t/events_restart.test	2011-05-04 12:59:24 +0000
+++ b/mysql-test/t/events_restart.test	2012-02-09 20:13:47 +0000
@@ -106,3 +106,4 @@
   select count(*) = 0 from information_schema.processlist
   where db='events_test' and command = 'Connect' and user=current_user();
 --source include/wait_condition.inc
+

=== modified file 'mysql-test/t/filesort_debug.test'
--- a/mysql-test/t/filesort_debug.test	2011-12-15 21:07:58 +0000
+++ b/mysql-test/t/filesort_debug.test	2012-04-10 06:28:13 +0000
@@ -11,7 +11,7 @@
 CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
 INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
 
-SET session debug_dbug= '+d,make_char_array_fail';
+SET session debug_dbug= '+d,make_sort_keys_alloc_fail';
 CALL mtr.add_suppression("Out of sort memory");
 --error ER_OUT_OF_SORTMEMORY
 SELECT * FROM t1 ORDER BY f1 ASC, f0;
@@ -57,3 +57,46 @@
 --source include/wait_until_count_sessions.inc
 SET DEBUG_SYNC= "RESET";
 DROP TABLE t1;
+
+--echo #
+--echo # Bug#13832772 ASSERTION `THD->IS_ERROR() || KILL_ERRNO'
+--echo #              FAILED IN FILESORT/MYSQL_DELETE
+--echo #
+
+CREATE TABLE t1 (
+  c1 BLOB,
+  c2 TEXT,
+  c3 TEXT,
+  c4 TEXT,
+  c5 TEXT,
+  c6 TEXT,
+  c7 TEXT,
+  c8 BLOB,
+  c9 TEXT,
+  c19 TEXT,
+  pk INT,
+  c20 TEXT,
+  c21 BLOB,
+  c22 TEXT,
+  c23 TEXT,
+  c24 TEXT,
+  c25 TEXT,
+  c26 BLOB,
+  c27 TEXT,
+  c28 TEXT,
+  primary key (pk)
+);
+
+CALL mtr.add_suppression("Out of sort memory");
+
+--error ER_OUT_OF_SORTMEMORY
+DELETE IGNORE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
+c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
+SHOW WARNINGS;
+
+--error ER_OUT_OF_SORTMEMORY
+DELETE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
+c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2; 
+SHOW WARNINGS;
+
+DROP TABLE t1;

=== modified file 'mysql-test/t/func_in.test'
--- a/mysql-test/t/func_in.test	2012-03-09 07:06:59 +0000
+++ b/mysql-test/t/func_in.test	2012-04-10 06:28:13 +0000
@@ -562,5 +562,18 @@
 
 --echo #
 
+--echo #
+--echo # Bug#13012483: EXPLAIN EXTENDED, PREPARED STATEMENT, CRASH IN CHECK_SIMPLE_EQUALITY
+--echo #
+
+CREATE TABLE t1 (a INT);
+PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
+EXECUTE s;
+
+DROP TABLE t1;
+
+--echo # End of test  BUG#13012483
+
+--echo #
 --echo End of 5.1 tests
 

=== modified file 'mysql-test/t/join.test'
--- a/mysql-test/t/join.test	2012-02-24 16:07:12 +0000
+++ b/mysql-test/t/join.test	2012-03-23 02:56:17 +0000
@@ -1067,4 +1067,72 @@
 select t2.i from t1 left join t2 on t2.i = t1.i where t1.i = '1:1:1';
 drop table t1,t2;
 
+--echo #
+--echo # BUG#954900: unexpected empty set due to an invalid build of key ref
+--echo #                   
+
+CREATE TABLE t1 (dog_id int(10), birthday date, PRIMARY KEY (dog_id,birthday));
+INSERT INTO t1 VALUES (5918,'2004-07-22');
+
+CREATE TABLE t2 (dog_id int(10) unsigned, t_id char(1), birthday date, a_id int(10),
+PRIMARY KEY (dog_id,t_id,birthday,a_id));
+INSERT INTO t2 VALUES 
+(5918,'N','2004-07-22',5216551), (5918,'N','2004-07-22',5223640),
+(5918,'N','2004-07-22',5389491), (5918,'N','2004-07-22',5749434),
+(5918,'N','2004-07-22',5992424), (5922,'N','2005-06-30',5076957),
+(5924,'N','2000-08-11',20264), (5924,'N','2000-08-11',64251),
+(5924,'N','2000-08-11',74748), (5924,'N','2000-08-11',87590),
+(5924,'N','2000-08-11',104695), (5924,'N','2000-08-11',133136),
+(5924,'N','2000-08-11',5027806), (5924,'N','2000-08-11',5076957),
+(5924,'N','2000-08-11',5166821), (5924,'N','2000-08-11',5181896),
+(5924,'N','2000-08-11',5217908), (5924,'N','2000-08-11',5220812),
+(5924,'N','2000-08-11',5226473), (5924,'N','2000-08-11',5339111),
+(5925,'N','2005-02-10',19227), (5925,'N','2005-02-10',74529),
+(5925,'N','2005-02-10',74748), (5927,'N','2005-08-18',20264),
+(5927,'N','2005-08-18',58364), (5929,'N','2005-01-19',58364),
+(5935,'N','2006-03-10',19227), (5935,'N','2006-03-10',64251),
+(5935,'N','2006-03-10',5222400), (5935,'N','2006-03-10',5226473),
+(5936,'N','2004-10-29',5015032), (5937,'N','2002-04-05',11237),
+(5937,'N','2002-04-05',23911), (5937,'N','2002-04-05',112133),
+(5937,'N','2002-04-05',169721), (5937,'N','2002-04-05',170650),
+(5937,'N','2002-04-05',5014494), (5937,'N','2002-04-05',5166009),
+(5937,'N','2002-04-05',5181871), (5937,'N','2002-04-05',5213380),
+(5937,'N','2002-04-05',5214875), (5937,'N','2002-04-05',5895062),
+(5938,'N','2006-03-24',11237), (5938,'N','2006-03-24',19227),
+(5938,'N','2006-03-24',23911), (5938,'N','2006-03-24',58364),
+(5938,'N','2006-03-24',64251), (5938,'N','2006-03-24',111716),
+(5938,'N','2006-03-24',112702), (5938,'N','2006-03-24',133136),
+(5938,'N','2006-03-24',168718), (5938,'N','2006-03-24',5137136),
+(5938,'N','2006-03-24',5161519), (5938,'N','2006-03-24',5168120),
+(5938,'N','2006-03-24',5219034), (6234,'N','2006-06-02',103058),
+(6234,'N','2006-06-02',5146844), (6235,'N','2006-06-01',12900),
+(6235,'N','2006-06-01',20264), (6235,'N','2006-06-01',64251),
+(6235,'N','2006-06-01',75160), (6235,'N','2006-06-01',5014494),
+(6235,'N','2006-06-01',5181638), (6236,'N','2006-06-06',112595),
+(6236,'N','2006-06-06',5219601), (6236,'N','2006-06-06',5808374);
+
+CREATE TABLE t3 (dog_id int(10) unsigned);
+INSERT INTO t3 VALUES (5918);
+
+CREATE TABLE t4 (dog_id int(10), t_id char(1), birthday date, KEY (t_id));
+INSERT INTO t4 VALUES (5918,'N','2004-07-22'), (5919,'N','2004-07-20');
+
+CREATE TABLE t5 (dog_id int(10) unsigned, UNIQUE KEY (dog_id));
+INSERT INTO t5 VALUES (5918);
+
+SET @tmp_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch='index_condition_pushdown=off';
+
+EXPLAIN
+SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR
+WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND
+      DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id;
+SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR
+WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND
+      DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id;
+
+SET optimizer_switch=@tmp_optimizer_switch;
+
+DROP TABLE t1,t2,t3,t4,t5;
+
 SET optimizer_switch=@save_optimizer_switch;

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2012-03-01 22:22:22 +0000
+++ b/mysql-test/t/join_outer.test	2012-04-07 13:58:46 +0000
@@ -1260,6 +1260,62 @@
 
 DROP TABLE h,m,k;
 
+--echo
+--echo # BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN
+--echo # USED IN GROUP BY
+--echo 
+CREATE TABLE t1 (
+  col_varchar_1024_latin1_key varchar(1024),
+  col_varchar_10_latin1 varchar(10),
+  col_int int(11),
+  pk int(11)
+);
+CREATE TABLE t2 (
+  col_int_key int(11),
+  col_int int(11),
+  pk int(11)
+);
+
+PREPARE prep_stmt_9846 FROM '
+SELECT alias1.pk AS field1 FROM
+t1 AS alias1
+LEFT JOIN
+( 
+  t2 AS alias2
+  RIGHT  JOIN
+  ( 
+    t2 AS alias3
+    JOIN t1 AS alias4
+    ON 1
+  )
+  ON 1
+)
+ON 1
+GROUP BY field1';
+execute prep_stmt_9846;
+execute prep_stmt_9846;
+drop table t1,t2;
+
+--echo #
+--echo # Bug #11765810	58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY
+--echo # IS EXECUTED TWICE FROM P
+--echo #
+CREATE TABLE t1 ( a INT ) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1);
+PREPARE prep_stmt FROM '
+ SELECT 1 AS f FROM t1
+ LEFT JOIN t1 t2
+  RIGHT JOIN t1 t3
+    JOIN t1 t4
+   ON 1
+  ON 1
+ ON 1
+ GROUP BY f';
+EXECUTE prep_stmt;
+EXECUTE prep_stmt;
+
+DROP TABLE t1;
+
 --echo #
 --echo # Bug#49600: outer join of two single-row tables with joining attributes
 --echo #            evaluated to nulls

=== modified file 'mysql-test/t/multi_update.test'
--- a/mysql-test/t/multi_update.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/t/multi_update.test	2012-03-27 23:04:46 +0000
@@ -6,6 +6,8 @@
 source include/not_embedded.inc;
 source include/have_log_bin.inc;
 
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
+
 --disable_warnings
 drop table if exists t1,t2,t3;
 drop database if exists mysqltest;
@@ -142,6 +144,7 @@
 
 select * from t2;
 
+--disable_warnings ONCE
 UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id;
 
 select * from t2;
@@ -299,6 +302,7 @@
 
 create table t1 (a int not null auto_increment primary key, b int not null);
 insert into t1 (b) values (1),(2),(3),(4);
+--disable_warnings ONCE
 update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a;
 select * from t1;
 drop table t1;
@@ -356,6 +360,7 @@
 insert into t1 values (0,'A01-Comp',1);
 insert into t1 values (0,'B01-Comp',1);
 insert into t2 values (0,1,'A Note',1);
+--disable_warnings ONCE
 update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2;
 select * from t1;
 select * from t2;

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2012-01-16 19:16:35 +0000
+++ b/mysql-test/t/myisam.test	2012-04-07 13:58:46 +0000
@@ -1718,6 +1718,20 @@
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
 
+--echo #
+--echo # BUG 11756869 - 48848: MYISAMCHK DOING SORT RECOVER IN CERTAIN
+--echo #                       CASES RESETS DATA POINTER TO SMAL
+--echo #
+CREATE TABLE t1(a INT, KEY(a));
+ALTER TABLE t1 DISABLE KEYS;
+let $MYSQLD_DATADIR= `select @@datadir`;
+SET @before:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+FLUSH TABLES;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+--exec $MYISAMCHK -sn $MYSQLD_DATADIR/test/t1
+SET @after:= (SELECT MAX_DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test');
+SELECT @before=@after;
+DROP TABLE t1;
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/mysqldump-no-binlog.test'
--- a/mysql-test/t/mysqldump-no-binlog.test	2008-03-07 09:15:49 +0000
+++ b/mysql-test/t/mysqldump-no-binlog.test	2012-03-23 09:53:25 +0000
@@ -2,5 +2,6 @@
 --source include/not_embedded.inc
 
 --replace_regex /MASTER_LOG_POS=[0-9]+/XX/
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --master-data=2 test 2>&1

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2012-03-09 07:06:59 +0000
+++ b/mysql-test/t/mysqldump.test	2012-04-07 13:58:46 +0000
@@ -601,48 +601,62 @@
 --disable_query_log
 select '------ Testing with illegal table names ------' as test_sequence ;
 --enable_query_log
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\d-2-1.sql" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db  "\t1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db  "\\t1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db  "\\\\t1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db  "t\1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments  mysqldump_test_db  "t\\1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db  "t/1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "T_1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "T%1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "T'1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "T_1" 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "T_" 2>&1
 
 --disable_query_log
 select '------ Testing with illegal database names ------' as test_sequence ;
 --enable_query_log
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_d 2>&1
 
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --skip-comments "mysqld\ump_test_db" 2>&1
 
@@ -728,6 +742,7 @@
 create table t1(a int);
 create table t2(a int);
 create table t3(a int);
+--replace_result mysqldump.exe mysqldump
 --error 6
 --exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
 drop table t1, t2, t3;
@@ -738,6 +753,7 @@
 --echo #
 
 create table t1 (a int);
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --skip-comments --force test t1 --where="xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 2>&1
 drop table t1;
@@ -1279,6 +1295,7 @@
 drop table t1;
 # mysqldump gets 1356 from server, but gives us 2
 --echo mysqldump {
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --force -N --compact --skip-comments test
 --echo } mysqldump
@@ -1376,11 +1393,13 @@
 reset master;
 
 # Execute mysqldump, will fail on FLUSH TABLES
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
 
 # Execute mysqldump, will fail on FLUSH TABLES
 # use --force, should no affect behaviour
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1
 
@@ -1388,11 +1407,13 @@
 grant RELOAD on *.* to mysqltest_1 at localhost;
 
 # Execute mysqldump, will fail on SHOW MASTER STATUS
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
 
 # Execute mysqldump, will fail on SHOW MASTER STATUS.
 # use --force, should not alter behaviour
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1
 
@@ -1507,14 +1528,18 @@
 INSERT INTO t1 VALUES (1), (2);
 
 # too long a file path causes an error
+--replace_result mysqldump.exe mysqldump
 --error 1
 --exec $MYSQL_DUMP --tab=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test 2>&1
 
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-optionally-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --lines-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test
@@ -1588,6 +1613,7 @@
 
 create procedure mysqldump_test_db.sp1() select 'hello';
 
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP -f --compact --user=user2 --password=  -h 127.0.0.1 -P $MASTER_MYPORT --routines mysqldump_test_db
 
@@ -1693,6 +1719,7 @@
 
 CREATE TABLE `??????????????????????????????????????????????` ( f1 INT );
 --exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=utf8 --compatible=mysql323 test
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=latin1 --compatible=mysql323 test
 DROP TABLE `??????????????????????????????????????????????`;
@@ -1748,6 +1775,7 @@
 # Drop table "words" and run with threads, should fail
 drop table words;
 --replace_regex /.*mysqlimport(\.exe)*/mysqlimport/
+--replace_result mysqldump.exe mysqldump
 --error 1
 --exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data/words.dat $MYSQLTEST_VARDIR/std_data/words2.dat 2>&1
 
@@ -2086,10 +2114,12 @@
 
 --echo # error on multi-character ENCLOSED/ESCAPED BY
 
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by='12345' test t1
 --remove_file $file
 
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by='12345' test t1
 --remove_file $file
@@ -2302,6 +2332,7 @@
 
 --echo # Running 'replace_regex on timestamp'
 --replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/
+--replace_result mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --user=user1 -R -E --triggers -X BUG52792
 

=== modified file 'mysql-test/t/openssl_1.test'
--- a/mysql-test/t/openssl_1.test	2012-01-27 14:13:38 +0000
+++ b/mysql-test/t/openssl_1.test	2012-03-23 09:53:25 +0000
@@ -197,7 +197,7 @@
 --exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test
 
 # With wrong parameters
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR mysqldump.exe mysqldump
 --error 2
 --exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1
 

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2012-01-13 14:50:02 +0000
+++ b/mysql-test/t/partition.test	2012-04-07 13:58:46 +0000
@@ -2350,6 +2350,51 @@
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
 
+--echo #
+--echo # Bug#13580775 ASSERTION FAILED: RECORD_LENGTH == M_RECORD_LENGTH,
+--echo # FILE FILESORT_UTILS.CC
+--echo #
+
+CREATE TABLE t1 (
+  a INT PRIMARY KEY,
+  b INT,
+  c CHAR(1),
+  d INT,
+  KEY (c,d)
+) PARTITION BY KEY () PARTITIONS 1;
+
+INSERT INTO t1 VALUES (1,1,'a',1), (2,2,'a',1);
+
+SELECT 1 FROM t1 WHERE 1 IN
+(SELECT  group_concat(b)
+ FROM t1
+ WHERE c > geomfromtext('point(1 1)')
+ GROUP BY b
+);
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#13011410 CRASH IN FILESORT CODE WITH GROUP BY/ROLLUP
+--echo #
+
+CREATE TABLE t1 (
+  a INT,
+  b MEDIUMINT,
+  c VARCHAR(300) CHARACTER SET hp8 COLLATE hp8_bin,
+  PRIMARY KEY (a,c(299))) 
+ENGINE=myisam
+PARTITION BY LINEAR KEY () PARTITIONS 2;
+
+INSERT INTO t1 VALUES (1,2,'test'), (2,3,'hi'), (4,5,'bye');
+SELECT 1 FROM t1 WHERE b < SOME
+( SELECT 1 FROM t1 WHERE a >= 1
+  GROUP BY b WITH ROLLUP
+  HAVING b > geomfromtext("")
+);
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 --echo #

=== added file 'mysql-test/t/partition_cache.test'
--- a/mysql-test/t/partition_cache.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/partition_cache.test	2012-02-20 21:59:11 +0000
@@ -0,0 +1,21 @@
+# t/cache_innodb.test
+#
+# Last update:
+# 2006-07-26 ML test refactored (MySQL 5.1)
+#               main code t/innodb_cache.test --> include/query_cache.inc
+#               new wrapper t/cache_innodb.test
+#
+
+--source include/have_query_cache.inc
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+let $engine_type= InnoDB;
+# Using SELECT to get a space as first character.
+let $partitions_a= `SELECT ' PARTITION BY KEY (a) PARTITIONS 3'`;
+let $partitions_id= `SELECT ' PARTITION BY HASH (id) PARTITIONS 3'`;
+let $partitions_s1= `SELECT ' PARTITION BY KEY (s1) PARTITIONS 3'`;
+# partitioning does not support FOREIGN KEYs
+let $test_foreign_keys= 0;
+
+--source include/query_cache.inc

=== modified file 'mysql-test/t/partition_error.test'
--- a/mysql-test/t/partition_error.test	2012-02-29 20:55:04 +0000
+++ b/mysql-test/t/partition_error.test	2012-03-27 23:04:46 +0000
@@ -11,6 +11,34 @@
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 
 --echo #
+--echo # Bug#13608188 - 64038: CRASH IN HANDLER::HA_THD ON ALTER TABLE AFTER
+--echo #                       REPAIR NON-EXISTING PARTITION
+--echo #
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES (5,3),(5,6);
+ALTER TABLE t1 PARTITION BY KEY(b) PARTITIONS 3 ;
+ALTER TABLE t1 REPAIR PARTITION p1, p3;
+ALTER TABLE t1 ORDER BY b;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#13593865 - 64037: CRASH IN HA_PARTITION::CREATE_HANDLERS ON
+--echo #                       ALTER TABLE AFTER DROP PARTITION
+--echo #
+
+CREATE TABLE t1 (a INT)
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (0),
+ PARTITION p1 VALUES LESS THAN MAXVALUE ) ;
+
+ALTER TABLE t1 DROP PARTITION p1;
+ALTER TABLE t1 ANALYZE PARTITION p0, p1;
+
+ALTER TABLE t1 COMMENT 'altered';
+
+DROP TABLE t1;
+
+--echo #
 --echo # Bug#57924: crash when creating partitioned table with
 --echo #            multiple columns in the partition key
 --echo #

=== modified file 'mysql-test/t/partition_innodb.test'
--- a/mysql-test/t/partition_innodb.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/t/partition_innodb.test	2012-04-10 06:28:13 +0000
@@ -12,6 +12,35 @@
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 
 --echo #
+--echo # Bug#13694811: THE OPTIMIZER WRONGLY USES THE FIRST
+--echo #               INNODB PARTITION STATISTICS
+--echo #
+
+CREATE TABLE t1
+(a INT,
+ b varchar(64),
+ PRIMARY KEY (a),
+ KEY (b))
+ENGINE = InnoDB
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a) SUBPARTITIONS 10
+(PARTITION pNeg VALUES LESS THAN (0),
+ PARTITION p0 VALUES LESS THAN (1000),
+ PARTITION pMAX VALUES LESS THAN MAXVALUE);
+
+--echo # Only one row in the first 10 subpartitions
+INSERT INTO t1 VALUES (-1, 'Only negative pk value');
+
+INSERT INTO t1 VALUES (0, 'Mod Zero'), (1, 'One'), (2, 'Two'), (3, 'Three'),
+(10, 'Zero'), (11, 'Mod One'), (12, 'Mod Two'), (13, 'Mod Three'),
+(20, '0'), (21, '1'), (22, '2'), (23, '3'),
+(4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9');
+INSERT INTO t1 SELECT a + 30, b FROM t1 WHERE a >= 0;
+ANALYZE TABLE t1;
+EXPLAIN SELECT b FROM t1 WHERE b between 'L' and 'N' AND a > -100;
+DROP TABLE t1;
+
+--echo #
 --echo # Bug#56287: crash when using Partition datetime in sub in query
 --echo #
 

=== modified file 'mysql-test/t/ps.test'
--- a/mysql-test/t/ps.test	2012-03-05 20:48:06 +0000
+++ b/mysql-test/t/ps.test	2012-04-10 06:28:13 +0000
@@ -1,5 +1,6 @@
 -- source include/not_embedded.inc
 -- source include/have_log_bin.inc
+call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); 
 #
 # SQL Syntax for Prepared Statements test
 #
@@ -249,8 +250,10 @@
 execute stmt1;
 execute stmt1;
 prepare stmt1 from "create table t1 select 1 as i";
+--disable_warnings ONCE
 execute stmt1;
 drop table t1;
+--disable_warnings ONCE
 execute stmt1;
 prepare stmt1 from "insert into t1 select i from t1";
 execute stmt1;
@@ -443,6 +446,7 @@
 create table t1 (a int); 
 insert into t1 values (1),(2),(3);
 create table t2 select * from t1;
+--disable_warnings
 prepare stmt FROM 'create table t2 select * from t1';
 drop table t2;
 execute stmt;
@@ -452,6 +456,7 @@
 execute stmt;
 drop table t2;
 execute stmt;
+--enable_warnings
 drop table t1,t2;
 deallocate prepare stmt;
 
@@ -1187,6 +1192,7 @@
 prepare stmt1 from "create table mysqltest.t1 (c char(10))";
 prepare stmt2 from "create table mysqltest.t2 select 'test'";
 execute stmt1;
+--disable_warnings ONCE
 execute stmt2;
 show create table mysqltest.t1;
 show create table mysqltest.t2;
@@ -1194,6 +1200,7 @@
 drop table mysqltest.t2;
 alter database mysqltest character set latin1;
 execute stmt1;
+--disable_warnings ONCE
 execute stmt2;
 show create table mysqltest.t1;
 show create table mysqltest.t2;
@@ -3370,6 +3377,94 @@
 SELECT *
 FROM (SELECT 1 UNION SELECT 2) t;
 
+--echo
+--echo # Bug#13805127: Stored program cache produces wrong result in same THD
+--echo
+
+PREPARE s1 FROM 
+"
+SELECT c1, t2.c2, count(c3)
+FROM
+  (
+  SELECT 3 as c2 FROM dual WHERE @x = 1
+  UNION
+  SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+  ) AS t1,
+  (
+  SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+  UNION
+  SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+  UNION
+  SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+  ) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2
+";
+
+--echo
+SET @x = 1;
+SELECT c1, t2.c2, count(c3)
+FROM
+  (
+  SELECT 3 as c2 FROM dual WHERE @x = 1
+  UNION
+  SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+  ) AS t1,
+  (
+  SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+  UNION
+  SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+  UNION
+  SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+  ) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2;
+--echo
+EXECUTE s1;
+
+--echo
+SET @x = 2;
+SELECT c1, t2.c2, count(c3)
+FROM
+  (
+  SELECT 3 as c2 FROM dual WHERE @x = 1
+  UNION
+  SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+  ) AS t1,
+  (
+  SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+  UNION
+  SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+  UNION
+  SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+  ) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2;
+--echo
+EXECUTE s1;
+
+--echo
+SET @x = 1;
+SELECT c1, t2.c2, count(c3)
+FROM
+  (
+  SELECT 3 as c2 FROM dual WHERE @x = 1
+  UNION
+  SELECT 2       FROM dual WHERE @x = 1 OR @x = 2
+  ) AS t1,
+  (
+  SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+  UNION
+  SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+  UNION
+  SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+  ) AS t2
+WHERE t2.c2 = t1.c2
+GROUP BY c1, c2;
+--echo
+EXECUTE s1;
+
+DEALLOCATE PREPARE s1;
 
 --echo #
 --echo # End of 5.5 tests.

=== modified file 'mysql-test/t/range_vs_index_merge.test'
--- a/mysql-test/t/range_vs_index_merge.test	2011-11-18 17:35:51 +0000
+++ b/mysql-test/t/range_vs_index_merge.test	2012-03-21 00:03:28 +0000
@@ -621,6 +621,62 @@
         (Population BETWEEN 101000 AND 102000 OR Name LIKE 'Pa%');
 
 
+#
+# LP bug #954262: index merge oover long disjunction in WHERE    
+#  
+
+set @save_optimizer_switch=@@optimizer_switch;
+
+CREATE INDEX CityName on City(Name);  
+
+let $cond =
+(Name='Manila' AND Country='PHL') OR
+(Name='Addis Abeba' AND Country='ETH') OR          
+(Name='Jakarta' AND Country='IDN') OR  
+(Name='Bangalore' AND Country='IND') OR
+(Name='Teheran' AND Country='IRN') OR          
+(Name='Roma' AND Country='ITA') OR  
+(Name='Delhi' AND Country='IND') OR  
+(Name='Venezia' AND Country='ITA') OR  
+(Name='Tokyo' AND Country='JPN') OR
+(Name='Toronto' AND Country='CAN') OR  
+(Name='Peking' AND Country='CHN') OR  
+(Name='Lagos' AND Country='NGA') OR  
+(Name='Tijuana' AND Country='MEX') OR
+(Name='Rabat' AND Country='MAR') OR          
+(Name='Seoul' AND Country='KOR') OR  
+(Name='Vancouver' AND Country='CAN') OR  
+(Name='Kaunas' AND Country='LTU') OR  
+(Name='Paris' AND Country='FRA') OR
+(Name='Dakar' AND Country='SEN') OR          
+(Name='Basel' AND Country='CHE') OR  
+(Name='Praha' AND Country='CZE') OR  
+(Name='Ankara' AND Country='TUR') OR  
+(Name='Dresden' AND Country='DEU') OR
+(Name='Lugansk' AND Country='UKR') OR          
+(Name='Caracas' AND Country='VEN') OR  
+(Name='Samara' AND Country='RUS') OR  
+(Name='Seattle' AND Country='USA'); 
+
+eval
+EXPLAIN SELECT Name, Country, Population FROM City WHERE
+$cond;
+eval 
+SELECT Name, Country, Population FROM City WHERE
+$cond;
+
+set optimizer_switch='index_merge=off';
+
+eval
+EXPLAIN SELECT Name, Country, Population FROM City WHERE
+$cond;
+eval
+SELECT Name, Country, Population FROM City WHERE
+$cond;
+
+set optimizer_switch=@save_optimizer_switch;
+          
+
 DROP DATABASE world;
 
 use test;

=== modified file 'mysql-test/t/sp-bugs.test'
--- a/mysql-test/t/sp-bugs.test	2010-11-11 04:52:51 +0000
+++ b/mysql-test/t/sp-bugs.test	2012-03-28 06:35:31 +0000
@@ -138,4 +138,93 @@
 DROP TABLE db1.t1;
 DROP DATABASE db1;
 DROP DATABASE db2;
+USE test;
+
+--echo #
+--echo # Bug#13105873:valgrind warning:possible crash in foreign 
+--echo # key handling on subsequent create table if not exists 
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS testdb;
+--enable_warnings
+CREATE DATABASE testdb;
+USE testdb;
+CREATE TABLE t1 (id1 INT PRIMARY KEY);
+DELIMITER $;
+CREATE PROCEDURE `p1`()
+BEGIN
+    CREATE TABLE IF NOT EXISTS t2(id INT PRIMARY KEY,
+    CONSTRAINT FK FOREIGN KEY (id) REFERENCES t1( id1 ));
+END$
+DELIMITER ;$
+CALL p1();
+--echo # below stmt should not return valgrind warnings
+CALL p1(); 
+DROP DATABASE testdb;
+USE test;
+
 --echo End of 5.1 tests
+
+--echo #
+--echo # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
+--echo #
+SET @@SQL_MODE = '';
+DELIMITER $;
+CREATE FUNCTION testf_bug11763507() RETURNS INT
+BEGIN
+    RETURN 0;
+END
+$
+
+CREATE PROCEDURE testp_bug11763507()
+BEGIN
+    SELECT "PROCEDURE testp_bug11763507";
+END
+$
+
+DELIMITER ;$
+
+# STORED FUNCTIONS
+SELECT testf_bug11763507();
+SELECT TESTF_bug11763507();
+
+--replace_column 5 # 6 #
+SHOW FUNCTION STATUS LIKE  'testf_bug11763507';
+--replace_column 5 # 6 #
+SHOW FUNCTION STATUS WHERE NAME='testf_bug11763507';
+--replace_column 5 # 6 #
+SHOW FUNCTION STATUS LIKE  'TESTF_bug11763507';
+--replace_column 5 # 6 #
+SHOW FUNCTION STATUS WHERE NAME='TESTF_bug11763507';
+
+SHOW CREATE FUNCTION testf_bug11763507;
+SHOW CREATE FUNCTION TESTF_bug11763507;
+
+# STORED PROCEDURE
+CALL testp_bug11763507();
+CALL TESTP_bug11763507();
+
+--replace_column 5 # 6 #
+SHOW PROCEDURE STATUS LIKE  'testp_bug11763507';
+--replace_column 5 # 6 #
+SHOW PROCEDURE STATUS WHERE NAME='testp_bug11763507';
+--replace_column 5 # 6 #
+SHOW PROCEDURE STATUS LIKE  'TESTP_bug11763507';
+--replace_column 5 # 6 #
+SHOW PROCEDURE STATUS WHERE NAME='TESTP_bug11763507';
+
+SHOW CREATE PROCEDURE testp_bug11763507;
+SHOW CREATE PROCEDURE TESTP_bug11763507;
+
+# INFORMATION SCHEMA 
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'testf_bug11763507';
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE 'TESTF_bug11763507';
+
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='testf_bug11763507';
+SELECT specific_name FROM INFORMATION_SCHEMA.ROUTINES WHERE specific_name='TESTF_bug11763507';
+
+DROP PROCEDURE testp_bug11763507;
+DROP FUNCTION testf_bug11763507;
+
+--echo #END OF BUG#11763507 test.

=== modified file 'mysql-test/t/sp-code.test'
--- a/mysql-test/t/sp-code.test	2011-12-15 21:07:58 +0000
+++ b/mysql-test/t/sp-code.test	2012-04-10 06:28:13 +0000
@@ -702,3 +702,35 @@
 
 DROP PROCEDURE p1;
 DROP TABLE t1;
+
+--echo #
+--echo # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
+--echo #
+SET @@SQL_MODE = '';
+DELIMITER $;
+CREATE FUNCTION testf_bug11763507() RETURNS INT
+BEGIN
+    RETURN 0;
+END
+$
+
+CREATE PROCEDURE testp_bug11763507()
+BEGIN
+    SELECT "PROCEDURE testp_bug11763507";
+END
+$
+
+DELIMITER ;$
+
+# STORED FUNCTIONS
+SHOW FUNCTION CODE testf_bug11763507;
+SHOW FUNCTION CODE TESTF_bug11763507;
+
+# STORED PROCEDURE
+SHOW PROCEDURE CODE testp_bug11763507;
+SHOW PROCEDURE CODE TESTP_bug11763507;
+
+DROP PROCEDURE testp_bug11763507;
+DROP FUNCTION testf_bug11763507;
+
+--echo #END OF BUG#11763507 test.

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2012-03-17 08:26:58 +0000
+++ b/mysql-test/t/sp.test	2012-04-10 06:28:13 +0000
@@ -9039,4 +9039,69 @@
 DROP PROCEDURE p2;
 DROP TABLE t1;
 
+--echo
+--echo # Bug#13805127: Stored program cache produces wrong result in same THD
+--echo
+
+delimiter |;
+
+CREATE PROCEDURE p1(x INT UNSIGNED)
+BEGIN
+  SELECT c1, t2.c2, count(c3)
+  FROM
+    (
+    SELECT 3 as c2 FROM dual WHERE x = 1
+    UNION
+    SELECT 2       FROM dual WHERE x = 1 OR x = 2
+    ) AS t1,
+    (
+    SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
+    UNION
+    SELECT '2012-03-01 02:00:00',       3,       2       FROM dual
+    UNION
+    SELECT '2012-03-01 01:00:00',       2,       1       FROM dual
+    ) AS t2
+  WHERE t2.c2 = t1.c2
+  GROUP BY c1, c2
+  ;
+END|
+
+delimiter ;|
+
+--echo
+CALL p1(1);
+CALL p1(2);
+CALL p1(1);
+
+DROP PROCEDURE p1;
+
 --echo # End of 5.5 test
+
+
+--echo #
+--echo # Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS
+--echo #
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+delimiter $;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+  DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+  BEGIN
+    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1();
+    BEGIN
+     DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1();
+     RETURN f1();
+    END;
+  END;
+RETURN 1;
+END $ 
+delimiter ;$
+
+# This used to cause an assertion.
+SELECT f1();
+
+DROP FUNCTION f1;

=== modified file 'mysql-test/t/sp_notembedded.test'
--- a/mysql-test/t/sp_notembedded.test	2011-10-19 19:45:18 +0000
+++ b/mysql-test/t/sp_notembedded.test	2012-04-10 06:28:13 +0000
@@ -427,6 +427,7 @@
 connection default;
 disconnect addcon;
 DROP DATABASE `my.db`;
+USE test;
 
 #
 # Restore global concurrent_insert value. Keep in the end of the test file.
@@ -437,3 +438,26 @@
 # Wait till all disconnects are completed
 --source include/wait_until_count_sessions.inc
 
+--echo #
+--echo # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
+--echo #
+SET @@SQL_MODE = '';
+DELIMITER $;
+
+CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR 
+DO SELECT 1 $
+
+DELIMITER ;$
+# EVENTS
+--replace_column 6 # 7 # 8 # 9 #
+SHOW EVENTS LIKE 'teste_bug11763507';
+--replace_column 6 # 7 # 8 # 9 #
+SHOW EVENTS LIKE 'TESTE_bug11763507';
+
+--replace_column 4 # 
+SHOW CREATE EVENT teste_bug11763507;
+--replace_column 4 # 
+SHOW CREATE EVENT TESTE_bug11763507;
+
+DROP EVENT teste_bug11763507;
+--echo #END OF BUG#11763507 test.

=== modified file 'mysql-test/t/sql_mode.test'
--- a/mysql-test/t/sql_mode.test	2009-10-09 14:52:02 +0000
+++ b/mysql-test/t/sql_mode.test	2012-02-29 08:45:15 +0000
@@ -359,3 +359,157 @@
 # Cleanup
 DROP TABLE t1;
 DROP TABLE t2;
+
+
+--echo 
+--echo #
+--echo # Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES
+--echo # IGNORED AND BREAKS REPLICATION
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS test_table;
+DROP FUNCTION IF EXISTS test_function;
+--enable_warnings
+
+CREATE TABLE test_table (c1 CHAR(50));
+
+SET @org_mode=@@sql_mode;
+
+SET @@sql_mode='';
+
+PREPARE insert_stmt FROM 'INSERT INTO test_table VALUES (?)';
+PREPARE update_stmt FROM 'UPDATE test_table SET c1= ? WHERE c1= ?';
+DELIMITER $;
+CREATE FUNCTION test_function(var CHAR(50)) RETURNS CHAR(50)
+BEGIN
+  DECLARE char_val CHAR(50);
+  SELECT c1 INTO char_val FROM test_table WHERE c1=var;
+  RETURN char_val;
+END
+$
+DELIMITER ;$
+
+SET @var1='abcd\'ef';
+SET @var2='abcd\"ef';
+SET @var3='abcd\bef';
+SET @var4='abcd\nef';
+SET @var5='abcd\ref';
+SET @var6='abcd\tef';
+SET @var7='abcd\\ef';
+SET @var8='abcd\%ef';
+SET @var9='abcd\_ef';
+
+SET @to_var1='wxyz\'ef';
+SET @to_var2='wxyz\"ef';
+SET @to_var3='wxyz\bef';
+SET @to_var4='wxyz\nef';
+SET @to_var5='wxyz\ref';
+SET @to_var6='wxyz\tef';
+SET @to_var7='wxyz\\ef';
+SET @to_var8='wxyz\%ef';
+SET @to_var9='wxyz\_ef';
+
+--echo # STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+EXECUTE insert_stmt USING @var1;
+EXECUTE insert_stmt USING @var2;
+EXECUTE insert_stmt USING @var3;
+EXECUTE insert_stmt USING @var4;
+EXECUTE insert_stmt USING @var5;
+EXECUTE insert_stmt USING @var6;
+EXECUTE insert_stmt USING @var7;
+EXECUTE insert_stmt USING @var8;
+EXECUTE insert_stmt USING @var9;
+
+SELECT * FROM test_table;
+
+EXECUTE update_stmt USING @to_var1, @var1;
+EXECUTE update_stmt USING @to_var2, @var2;
+EXECUTE update_stmt USING @to_var3, @var3;
+EXECUTE update_stmt USING @to_var4, @var4;
+EXECUTE update_stmt USING @to_var5, @var5;
+EXECUTE update_stmt USING @to_var6, @var6;
+EXECUTE update_stmt USING @to_var7, @var7;
+EXECUTE update_stmt USING @to_var8, @var8;
+EXECUTE update_stmt USING @to_var9, @var9;
+
+SELECT * FROM test_table;
+
+--echo 
+--echo # END OF CASE - STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+
+--echo # STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+select test_function(@to_var1);
+SELECT test_function(@to_var2);
+SELECT test_function(@to_var3);
+SELECT test_function(@to_var4);
+SELECT test_function(@to_var5);
+SELECT test_function(@to_var6);
+SELECT test_function(@to_var7);
+SELECT test_function(@to_var8);
+SELECT test_function(@to_var9);
+
+--echo 
+--echo # END OF CASE - STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+DELETE FROM test_table;
+DROP FUNCTION test_function;
+
+SET @@sql_mode='NO_BACKSLASH_ESCAPES';
+DELIMITER $;
+CREATE FUNCTION test_function(var CHAR(50)) RETURNS CHAR(50)
+BEGIN
+  DECLARE char_val CHAR(50);
+  SELECT c1 INTO char_val FROM test_table WHERE c1=var;
+  RETURN char_val;
+END
+$
+DELIMITER ;$
+
+--echo # STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+EXECUTE insert_stmt USING @var1;
+EXECUTE insert_stmt USING @var2;
+EXECUTE insert_stmt USING @var3;
+EXECUTE insert_stmt USING @var4;
+EXECUTE insert_stmt USING @var5;
+EXECUTE insert_stmt USING @var6;
+EXECUTE insert_stmt USING @var7;
+EXECUTE insert_stmt USING @var8;
+EXECUTE insert_stmt USING @var9;
+
+SELECT * FROM test_table;
+
+EXECUTE update_stmt USING @to_var1, @var1;
+EXECUTE update_stmt USING @to_var2, @var2;
+EXECUTE update_stmt USING @to_var3, @var3;
+EXECUTE update_stmt USING @to_var4, @var4;
+EXECUTE update_stmt USING @to_var5, @var5;
+EXECUTE update_stmt USING @to_var6, @var6;
+EXECUTE update_stmt USING @to_var7, @var7;
+EXECUTE update_stmt USING @to_var8, @var8;
+EXECUTE update_stmt USING @to_var9, @var9;
+
+SELECT * FROM test_table;
+
+--echo 
+--echo # END OF CASE - STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
+
+--echo # STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+select test_function(@to_var1);
+SELECT test_function(@to_var2);
+SELECT test_function(@to_var3);
+SELECT test_function(@to_var4);
+SELECT test_function(@to_var5);
+SELECT test_function(@to_var6);
+SELECT test_function(@to_var7);
+SELECT test_function(@to_var8);
+SELECT test_function(@to_var9);
+
+--echo 
+--echo # END OF CASE - STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
+
+DROP TABLE test_table;
+DROP FUNCTION test_function;
+SET @@sql_mode= @org_mode;
+
+--echo 
+--echo #End of Test for Bug#12601974 

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2012-03-06 19:46:07 +0000
+++ b/mysql-test/t/subselect.test	2012-04-10 06:28:13 +0000
@@ -3542,6 +3542,61 @@
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+--echo #
+
+CREATE TABLE t1(a1 int);
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2(a1 int);
+INSERT INTO t2 VALUES (3);
+
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+
+## All these are subject to the transformation
+## '1 < some (...)' => '1 < max(...)'
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2 FROM t2);
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 2.0 FROM t2);
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT 'a' FROM t2);
+SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t2);
+
+SET SESSION sql_mode=@old_sql_mode;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER
+--echo #
+
+create table t2(i int);
+insert into t2 values(0);
+
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+
+CREATE VIEW v1 AS  
+SELECT 'f' FROM t2 UNION SELECT 'x' FROM t2
+;
+
+CREATE TABLE t1 (
+  pk int NOT NULL,
+  col_varchar_key varchar(1) DEFAULT NULL,
+  PRIMARY KEY (pk),
+  KEY col_varchar_key (col_varchar_key)
+);
+
+SELECT t1.pk
+FROM t1
+WHERE t1.col_varchar_key < ALL ( SELECT * FROM v1 )
+;
+
+SET SESSION sql_mode=@old_sql_mode;
+
+drop table t2, t1;
+drop view v1;
+
 --echo End of 5.0 tests.
 
 #

=== modified file 'mysql-test/t/subselect_sj.test'
--- a/mysql-test/t/subselect_sj.test	2012-01-30 16:34:47 +0000
+++ b/mysql-test/t/subselect_sj.test	2012-03-21 07:18:20 +0000
@@ -2331,5 +2331,40 @@
 drop table t0,t1,t3;
 set optimizer_switch= @tmp_923246;
 
+--echo #
+--echo # BUG#952583: Server crashes in Item_field::fix_after_pullout on INSERT .. SELECT
+--echo # 
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 ( b INT );
+INSERT INTO t2 VALUES (3),(4);
+
+INSERT INTO t1
+SELECT * FROM ( SELECT * FROM t1 ) AS alias
+WHERE a IN ( SELECT b FROM t2 );
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # BUG#952372: Server crashes on 2nd execution of PS in find_field_in_tables with semijoin+materialization
+--echo #
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (2),(3);
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+CREATE TABLE t2 ( b VARCHAR(1) );
+INSERT INTO t2 VALUES ('v'),('v');
+
+PREPARE pstmt FROM
+  'SELECT DISTINCT a FROM v1, t2
+   WHERE b IN ( SELECT MIN(b) FROM t2 )';
+
+EXECUTE pstmt;
+EXECUTE pstmt;
+
+DEALLOCATE PREPARE pstmt;
+DROP VIEW v1;
+DROP TABLE t1, t2;
+
 # The following command must be the last one the file 
 set optimizer_switch=@subselect_sj_tmp;

=== modified file 'mysql-test/t/subselect_sj2.test'
--- a/mysql-test/t/subselect_sj2.test	2012-02-15 17:08:08 +0000
+++ b/mysql-test/t/subselect_sj2.test	2012-04-07 13:58:46 +0000
@@ -78,13 +78,7 @@
   A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a 
 from t0 A, t0 B where B.a <5;
 
-#
-# InnoDB does not use join buffer here, XtraDB does
-# (despite the comment above which says "no join buffering",
-# because it does not hold when this file is included
-# into subselect_sj2_jcl6.test)
-#
-#--replace_regex /Using join buffer//
+--replace_column 9 #
 explain select * from t3 where b in (select a from t0);
 select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
 
@@ -1093,5 +1087,143 @@
 
 DROP TABLE t1,t2;
 
+--echo # 
+--echo # BUG#962667: Assertion `0' failed in QUICK_INDEX_SORT_SELECT::need_sorted_output() 
+--echo #   with index_merge+index_merge_sort_union+loosescan+semijoin
+--echo #
+CREATE TABLE t1 (
+  a INT, b VARCHAR(1), c INT,
+  KEY(a), KEY(b)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES
+(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
+(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
+(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
+(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
+
+CREATE TABLE t2 (
+  pk INT, d VARCHAR(1), e INT,
+  PRIMARY KEY(pk), KEY(d,e)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES
+(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
+(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
+(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
+(15,'g',6),(16,'x',7),(17,'f',8);
+
+explain
+SELECT * FROM t1 WHERE b IN (
+  SELECT d FROM t2, t1
+  WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+SELECT * FROM t1 WHERE b IN (
+  SELECT d FROM t2, t1
+  WHERE a = d AND ( pk < 2 OR d = 'z' )
+);
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view
+--echo #
+CREATE TABLE t1 (
+  a VARCHAR(1),
+  b VARCHAR(1) NOT NULL,
+  KEY(a)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+('j','j'),('v','v'),('c','c'),('m','m'),('d','d'),
+('y','y'),('t','t'),('d','d'),('s','s'),('r','r'),
+('m','m'),('b','b'),('x','x'),('g','g'),('p','p'),
+('q','q'),('w','w'),('d','d'),('e','e');
+
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+
+--echo # This query returned 6 rows instead of 19
+--sorted_result
+SELECT * FROM v1
+WHERE ( a, a ) IN (
+  SELECT alias2.b, alias2.a
+  FROM t1 AS alias1, t1 AS alias2
+  WHERE alias2.b = alias1.a
+    AND ( alias1.b >= alias1.a OR alias2.b = 'z' )
+);
+
+--echo # Another testcase, without the VIEW:
+CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(1) NOT NULL, KEY(a)) ENGINE=InnoDB;
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 SELECT * FROM t1;
+EXPLAIN 
+SELECT * FROM t2 
+ WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+                  WHERE 
+                    alias2.b = alias1.a AND 
+                    (alias1.b >= alias1.a OR alias2.b = 'z'));
+
+--sorted_result
+SELECT * FROM t2 
+ WHERE (a, a) IN (SELECT alias2.b, alias2.a FROM t1 AS alias1, t1 AS alias2 
+                  WHERE 
+                    alias2.b = alias1.a AND 
+                    (alias1.b >= alias1.a OR alias2.b = 'z'));
+
+DROP VIEW v1;
+DROP TABLE t1, t2;
+
+--echo # 
+--echo # BUG#965872: Server crashes in embedding_sjm on a simple 1-table select with AND and OR  
+--echo #  (this is a regression caused by the fix for BUG#951937)
+CREATE TABLE t1 ( a INT, b INT, c INT, d INT );
+INSERT INTO t1 VALUES (4,2,8,9),(4,2,7,8);
+
+SELECT * FROM t1
+WHERE a = d AND ( b = 50 AND b = d OR a = c );
+DROP TABLE t1;
+
+--echo #
+--echo # BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery
+--echo #
+set @tmp_951283=@@optimizer_prune_level;
+SET optimizer_prune_level=0;
+
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+  (10),(11),(12),(13),(14),(15),(16),
+  (17),(18),(19),(20),(21),(22),(23);
+
+CREATE TABLE t2 (
+  b INT PRIMARY KEY,
+  c VARCHAR(1),
+  d VARCHAR(1),
+  KEY(c)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES
+  (1,'j','j'),(2,'v','v'),(3,'c','c'),(4,'m','m'),
+  (5,'d','d'),(6,'d','d'),(7,'y','y'),(8,'t','t'),
+  (9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
+  (13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
+  (17,'q','q'),(18,'w','w'),(19,'d','d');
+
+EXPLAIN
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+  SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+  WHERE alias5.b = alias4.b
+    AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+  SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+  WHERE alias5.b = alias4.b
+    AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+
+set optimizer_prune_level=@tmp_951283;
+DROP TABLE t1,t2;
+
 --echo # This must be the last in the file:
 set optimizer_switch=@subselect_sj2_tmp;

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2012-02-15 17:08:08 +0000
+++ b/mysql-test/t/view.test	2012-04-10 06:28:13 +0000
@@ -4521,6 +4521,18 @@
 disconnect con2;
 disconnect con3;
 
+
+--echo #
+--echo # Bug#12626844: WRONG ERROR MESSAGE WHILE CREATING A VIEW ON A
+--echo #               NON EXISTING DATABASE
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS nodb;
+--enable_warnings
+--error ER_BAD_DB_ERROR
+CREATE VIEW nodb.a AS SELECT 1;
+
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc
@@ -4546,6 +4558,61 @@
 DROP VIEW v2;
 DROP TABLE t1, t2, t3;
 
+--echo #
+--echo # BUG#915222: Valgrind complains or crashes with INSERT SELECT
+--echo #              within a trigger that uses a view
+--echo #
+
+CREATE TABLE t1 (a char(1));
+
+CREATE TABLE t2 (d int, e char(1));
+
+INSERT INTO t2 VALUES (13,'z');
+
+CREATE TRIGGER tr AFTER UPDATE ON t2
+  FOR EACH ROW
+  REPLACE INTO t3
+  SELECT f, a AS alias FROM t3, v;
+
+CREATE TABLE t3 (f int, g char(8));
+
+CREATE VIEW v AS SELECT a, e FROM t2, t1;
+
+UPDATE t2 SET d=7;
+UPDATE t2 SET d=7;
+UPDATE t2 SET d=7;
+UPDATE t2 SET d=7;
+
+DROP TRIGGER tr;
+DROP VIEW v;
+DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # BUG#972943: Assertion failure with INSERT SELECT within a trigger 
+--echo #             that uses derived table and materialized view
+--echo #
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,0), (2,8);
+
+CREATE ALGORITHM=TEMPTABLE VIEW v1
+  AS SELECT * FROM t1;
+
+CREATE TABLE t2 (c int);
+CREATE TABLE t3 (d int, e int);
+
+CREATE TRIGGER tr BEFORE INSERT ON t2 FOR EACH ROW
+  INSERT INTO t3
+  SELECT t1.*
+    FROM (SELECT * FROM t1 WHERE b IN (SELECT b FROM v1)) AS alias1, t1
+    WHERE t1.a = 3 OR t1.a > 5;
+
+INSERT INTO t2 VALUES (1);
+
+DROP TRIGGER tr;
+DROP VIEW v1;
+DROP TABLE t1,t2,t3;
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.3 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'mysql-test/t/xa.test'
--- a/mysql-test/t/xa.test	2012-03-09 07:06:59 +0000
+++ b/mysql-test/t/xa.test	2012-04-10 06:28:13 +0000
@@ -298,7 +298,6 @@
 XA START 'a';
 INSERT INTO t1 VALUES (1);
 
---error ER_XAER_RMFAIL
 SAVEPOINT savep;
 
 XA END 'a';

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2012-03-13 12:28:08 +0000
+++ b/mysql-test/valgrind.supp	2012-03-27 23:04:46 +0000
@@ -1061,7 +1061,7 @@
    fun:my_b_flush_io_cache
    fun:_my_b_write
    fun:_Z*10write_keysP13st_sort_paramPPhjP11st_io_cacheS4_
-   fun:_Z*13find_all_keysP13st_sort_paramP10SQL_SELECTPPhP11st_io_cacheS6_S6_
+   fun:_Z*13find_all_keysP13st_sort_paramP10SQL_SELECTPPhP11st_io_cacheS6_
    fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPy
 }
 

=== modified file 'mysys/charset-def.c'
--- a/mysys/charset-def.c	2012-03-09 07:06:59 +0000
+++ b/mysys/charset-def.c	2012-04-07 13:58:46 +0000
@@ -1,5 +1,4 @@
-/* Copyright (c) 2000, 2003-2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc.
-   Use is subject to license terms.
+/* Copyright (c) 2000, 2012, 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

=== modified file 'mysys/lf_alloc-pin.c'
--- a/mysys/lf_alloc-pin.c	2011-11-03 18:17:05 +0000
+++ b/mysys/lf_alloc-pin.c	2012-04-10 06:28:13 +0000
@@ -211,13 +211,16 @@
   LF_PINBOX *pinbox= pins->pinbox;
   uint32 top_ver, nr;
   nr= pins->link;
-#ifdef MY_LF_EXTRA_DEBUG
+
+#ifndef DBUG_OFF
   {
+    /* This thread should not hold any pin. */
     int i;
     for (i= 0; i < LF_PINBOX_PINS; i++)
       DBUG_ASSERT(pins->pin[i] == 0);
   }
-#endif
+#endif /* DBUG_OFF */
+
   /*
     XXX this will deadlock if other threads will wait for
     the caller to do something after _lf_pinbox_put_pins(),

=== modified file 'mysys/my_addr_resolve.c'
--- a/mysys/my_addr_resolve.c	2012-03-13 12:34:24 +0000
+++ b/mysys/my_addr_resolve.c	2012-03-27 23:04:46 +0000
@@ -134,13 +134,13 @@
 #include <ctype.h>
 static int in[2], out[2];
 static int initialized= 0;
+static char output[1024];
 int my_addr_resolve(void *ptr, my_addr_loc *loc)
 {
   char input[32], *s;
-  char output[1024];
   size_t len;
 
-  len= my_safe_snprintf(input, sizeof(input), "0x%p\n", ptr);
+  len= my_snprintf(input, sizeof(input), "%p\n", ptr);
   if (write(in[1], input, len) <= 0)
     return 1;
   if (read(out[0], output, sizeof(output)) <= 0)

=== modified file 'mysys/my_getsystime.c'
--- a/mysys/my_getsystime.c	2012-01-23 16:12:25 +0000
+++ b/mysys/my_getsystime.c	2012-04-02 10:33:16 +0000
@@ -119,7 +119,6 @@
 ulonglong my_getcputime()
 {
 #ifdef CLOCK_THREAD_CPUTIME_ID
-#ifdef HAVE_CLOCK_GETTIME
   struct timespec tp;
   if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp))
     return 0;
@@ -129,8 +128,6 @@
   if (syscall(__NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &tp))
     return 0;
   return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100;
-#endif /* HAVE_CLOCK_GETTIME */
-#else /* HAVE_THREAD_CPUTIME_ID */
+#endif /* CLOCK_THREAD_CPUTIME_ID */
   return 0;
-#endif 
 }

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2012-02-17 11:19:38 +0000
+++ b/mysys/my_init.c	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates
    Copyright (c) 2009, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
@@ -201,11 +201,12 @@
 #endif
   }
 
+  my_thread_end();
+  my_thread_global_end();
+
   if (!(infoflag & MY_DONT_FREE_DBUG))
     DBUG_END();                /* Must be done as late as possible */
 
-  my_thread_end();
-  my_thread_global_end();
   my_mutex_end();
 #if defined(SAFE_MUTEX)
   /*

=== modified file 'mysys/my_new.cc'
--- a/mysys/my_new.cc	2012-01-20 21:32:31 +0000
+++ b/mysys/my_new.cc	2012-03-30 20:15:44 +0000
@@ -23,6 +23,7 @@
 */
 
 #include "mysys_priv.h"
+#include <new>
 
 #ifdef USE_MYSYS_NEW
 
@@ -36,6 +37,16 @@
   return (void *) my_malloc (sz ? sz : 1, MYF(0));
 }
 
+void* operator new(std::size_t sz, const std::nothrow_t&) throw()
+{
+  return (void *) my_malloc (sz ? sz : 1, MYF(0));
+}
+
+void* operator new[](std::size_t sz, const std::nothrow_t&) throw()
+{
+  return (void *) my_malloc (sz ? sz : 1, MYF(0));
+}
+
 void operator delete (void *ptr)
 {
   my_free(ptr);
@@ -46,6 +57,16 @@
   my_free(ptr);
 }
 
+void operator delete(void* ptr, const std::nothrow_t&) throw()
+{
+  my_free(ptr);
+}
+
+void operator delete[](void* ptr, const std::nothrow_t&) throw()
+{
+  my_free(ptr);
+}
+
 C_MODE_START
 
 int __cxa_pure_virtual()

=== modified file 'mysys/my_static.c'
--- a/mysys/my_static.c	2012-01-13 14:50:02 +0000
+++ b/mysys/my_static.c	2012-03-28 17:26:00 +0000
@@ -90,13 +90,7 @@
 /* this is to be able to call set_thd_proc_info from the C code */
 const char *(*proc_info_hook)(void *, const char *, const char *, const char *,
                               const unsigned int)= proc_info_dummy;
-#if defined(ENABLED_DEBUG_SYNC)
-/**
-  Global pointer to be set if callback function is defined
-  (e.g. in mysqld). See sql/debug_sync.cc.
-*/
-void (*debug_sync_C_callback_ptr)(const char *, size_t);
-#endif /* defined(ENABLED_DEBUG_SYNC) */
+void (*debug_sync_C_callback_ptr)(MYSQL_THD, const char *, size_t)= 0;
 
 	/* How to disable options */
 my_bool my_disable_locking=0;

=== modified file 'mysys/my_symlink.c'
--- a/mysys/my_symlink.c	2012-01-13 14:50:02 +0000
+++ b/mysys/my_symlink.c	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2001, 2010, Oracle and/or its affiliates
+   Copyright (c) 2001, 2011, Oracle and/or its affiliates
 
    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

=== modified file 'mysys/ptr_cmp.c'
--- a/mysys/ptr_cmp.c	2011-06-30 15:46:53 +0000
+++ b/mysys/ptr_cmp.c	2012-03-25 17:27:24 +0000
@@ -21,17 +21,23 @@
 
 #include "mysys_priv.h"
 #include <myisampack.h>
-
-#ifdef __sun
 /*
- * On Solaris, memcmp() is normally faster than the unrolled ptr_compare_N
+ * On some platforms, memcmp() is faster than the unrolled ptr_compare_N
  * functions, as memcmp() is usually a platform-specific implementation
- * written in assembler, provided in /usr/lib/libc/libc_hwcap*.so.1.
- * This implementation is also usually faster than the built-in memcmp
- * supplied by GCC, so it is recommended to build with "-fno-builtin-memcmp"
- * in CFLAGS if building with GCC on Solaris.
+ * written in assembler. for example one in /usr/lib/libc/libc_hwcap*.so.1.
+ * on Solaris, or on Windows inside C runtime linrary.
+ *
+ * On Solaris, native implementation is also usually faster than the 
+ * built-in memcmp supplied by GCC, so it is recommended to build 
+ * with "-fno-builtin-memcmp"in CFLAGS if building with GCC on Solaris.
  */
 
+#if defined (__sun) || defined (_WIN32)
+#define USE_NATIVE_MEMCMP 1
+#endif
+
+#ifdef USE_NATIVE_MEMCMP
+
 #include <string.h>
 
 static int native_compare(size_t *length, unsigned char **a, unsigned char **b)
@@ -39,7 +45,7 @@
   return memcmp(*a, *b, *length);
 }
 
-#else	/* __sun */
+#else	/* USE_NATIVE_MEMCMP */
 
 static int ptr_compare(size_t *compare_length, uchar **a, uchar **b);
 static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b);
@@ -50,7 +56,7 @@
 
 	/* Get a pointer to a optimal byte-compare function for a given size */
 
-#ifdef __sun
+#ifdef USE_NATIVE_MEMCMP
 qsort2_cmp get_ptr_compare (size_t size __attribute__((unused)))
 {
   return (qsort2_cmp) native_compare;
@@ -68,7 +74,7 @@
     }
   return 0;					/* Impossible */
 }
-#endif /* __sun */
+#endif /* USE_NATIVE_MEMCMP */
 
 
 	/*
@@ -78,7 +84,7 @@
 
 #define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N]
 
-#ifndef __sun
+#ifndef USE_NATIVE_MEMCMP
 
 static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
 {

=== modified file 'mysys/stacktrace.c'
--- a/mysys/stacktrace.c	2012-03-17 08:26:58 +0000
+++ b/mysys/stacktrace.c	2012-04-10 06:28:13 +0000
@@ -661,9 +661,10 @@
       my_safe_printf_stderr("%s!", base_image_name);
     }
     if(have_symbol)
-      fprintf(stderr, "%s()", package.sym.Name);
+      my_safe_printf_stderr("%s()", package.sym.Name);
+
     else if(have_module)
-      fprintf(stderr,"%s", "???");
+      my_safe_printf_stderr("%s", "???");
 
     if(have_source)
     {
@@ -671,7 +672,7 @@
       my_safe_printf_stderr("[%s:%u]",
                             base_file_name, line.LineNumber);
     }
-    fprintf(stderr,"%s", "\n");
+    my_safe_printf_stderr("%s", "\n");
   }
 }
 
@@ -742,189 +743,10 @@
 #endif /*__WIN__*/
 
 
-#ifdef __WIN__
-size_t my_write_stderr(const void *buf, size_t count)
-{
-  return fwrite(buf, 1, count, stderr);
-}
-#else
 size_t my_write_stderr(const void *buf, size_t count)
 {
   return (size_t) write(STDERR_FILENO, buf, count);
 }
-#endif
-
-
-static const char digits[]= "0123456789abcdef";
-
-char *my_safe_utoa(int base, ulonglong val, char *buf)
-{
-  *buf--= 0;
-  do {
-    *buf--= digits[val % base];
-  } while ((val /= base) != 0);
-  return buf + 1;
-}
-
-
-char *my_safe_itoa(int base, longlong val, char *buf)
-{
-  char *orig_buf= buf;
-  const my_bool is_neg= (val < 0);
-  *buf--= 0;
-
-  if (is_neg)
-    val= -val;
-  if (is_neg && base == 16)
-  {
-    int ix;
-    val-= 1;
-    for (ix= 0; ix < 16; ++ix)
-      buf[-ix]= '0';
-  }
-  
-  do {
-    *buf--= digits[val % base];
-  } while ((val /= base) != 0);
-
-  if (is_neg && base == 10)
-    *buf--= '-';
-
-  if (is_neg && base == 16)
-  {
-    int ix;
-    buf= orig_buf - 1;
-    for (ix= 0; ix < 16; ++ix, --buf)
-    {
-      switch (*buf)
-      {
-      case '0': *buf= 'f'; break;
-      case '1': *buf= 'e'; break;
-      case '2': *buf= 'd'; break;
-      case '3': *buf= 'c'; break;
-      case '4': *buf= 'b'; break;
-      case '5': *buf= 'a'; break;
-      case '6': *buf= '9'; break;
-      case '7': *buf= '8'; break;
-      case '8': *buf= '7'; break;
-      case '9': *buf= '6'; break;
-      case 'a': *buf= '5'; break;
-      case 'b': *buf= '4'; break;
-      case 'c': *buf= '3'; break;
-      case 'd': *buf= '2'; break;
-      case 'e': *buf= '1'; break;
-      case 'f': *buf= '0'; break;
-      }
-    }
-  }
-  return buf+1;
-}
-
-
-static const char *check_longlong(const char *fmt, my_bool *have_longlong)
-{
-  *have_longlong= FALSE;
-  if (*fmt == 'l')
-  {
-    fmt++;
-    if (*fmt != 'l')
-      *have_longlong= (sizeof(long) == sizeof(longlong));
-    else
-    {
-      fmt++;
-      *have_longlong= TRUE;
-    }
-  }
-  return fmt;
-}
-
-static size_t my_safe_vsnprintf(char *to, size_t size,
-                                const char* format, va_list ap)
-{
-  char *start= to;
-  char *end= start + size - 1;
-  for (; *format; ++format)
-  {
-    my_bool have_longlong = FALSE;
-    if (*format != '%')
-    {
-      if (to == end)                            /* end of buffer */
-        break;
-      *to++= *format;                           /* copy ordinary char */
-      continue;
-    }
-    ++format;                                   /* skip '%' */
-
-    format= check_longlong(format, &have_longlong);
-
-    switch (*format)
-    {
-    case 'd':
-    case 'i':
-    case 'u':
-    case 'x':
-    case 'p':
-      {
-        longlong ival= 0;
-        ulonglong uval = 0;
-        if (*format == 'p')
-          have_longlong= (sizeof(void *) == sizeof(longlong));
-        if (have_longlong)
-        {
-          if (*format == 'u')
-            uval= va_arg(ap, ulonglong);
-          else
-            ival= va_arg(ap, longlong);
-        }
-        else
-        {
-          if (*format == 'u')
-            uval= va_arg(ap, unsigned int);
-          else
-            ival= va_arg(ap, int);
-        }
-
-        {
-          char buff[22];
-          const int base= (*format == 'x' || *format == 'p') ? 16 : 10;
-          char *val_as_str= (*format == 'u') ?
-            my_safe_utoa(base, uval, &buff[sizeof(buff)-1]) :
-            my_safe_itoa(base, ival, &buff[sizeof(buff)-1]);
-
-          /* Strip off "ffffffff" if we have 'x' format without 'll' */
-          if (*format == 'x' && !have_longlong && ival < 0)
-            val_as_str+= 8;
-
-          while (*val_as_str && to < end)
-            *to++= *val_as_str++;
-          continue;
-        }
-      }
-    case 's':
-      {
-        const char *val= va_arg(ap, char*);
-        if (!val)
-          val= "(null)";
-        while (*val && to < end)
-          *to++= *val++;
-        continue;
-      }
-    }
-  }
-  *to= 0;
-  return to - start;
-}
-
-
-size_t my_safe_snprintf(char* to, size_t n, const char* fmt, ...)
-{
-  size_t result;
-  va_list args;
-  va_start(args,fmt);
-  result= my_safe_vsnprintf(to, n, fmt, args);
-  va_end(args);
-  return result;
-}
 
 
 size_t my_safe_printf_stderr(const char* fmt, ...)
@@ -933,7 +755,7 @@
   size_t result;
   va_list args;
   va_start(args,fmt);
-  result= my_safe_vsnprintf(to, sizeof(to), fmt, args);
+  result= my_vsnprintf(to, sizeof(to), fmt, args);
   va_end(args);
   my_write_stderr(to, result);
   return result;

=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c	2012-02-27 18:32:44 +0000
+++ b/mysys/thr_lock.c	2012-03-28 18:25:31 +0000
@@ -1168,6 +1168,9 @@
     if (result != THR_LOCK_SUCCESS)
     {						/* Aborted */
       thr_multi_unlock(data,(uint) (pos-data), 0);
+      /* Mark all requested locks as TL_UNLOCK (to simplify lock checking) */
+      for ( ; pos < end ; pos++)
+        (*pos)->type= TL_UNLOCK;
       DBUG_RETURN(result);
     }
     DEBUG_SYNC_C("thr_multi_lock_after_thr_lock");

=== modified file 'packaging/WiX/custom_ui.wxs'
--- a/packaging/WiX/custom_ui.wxs	2011-06-30 15:46:53 +0000
+++ b/packaging/WiX/custom_ui.wxs	2012-03-01 00:05:05 +0000
@@ -2,7 +2,7 @@
          xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
 
 <!--
-   Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+   Copyright (c) 2010, 2012, 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
@@ -30,7 +30,7 @@
       <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" Disabled="yes" />
       <Control Id="Description" Type="Text" X="135" Y="80" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgDescription)" />
       <Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgTitle)" />
-      <Control Id="CopyrightText" Type="Text" X="135" Y="200" Width="220" Height="40" Transparent="yes" Text="Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved." />
+      <Control Id="CopyrightText" Type="Text" X="135" Y="200" Width="220" Height="40" Transparent="yes" Text="Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved." />
       <Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.WelcomeDlgBitmap)" />
       <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
     </Dialog>

=== modified file 'plugin/auth_examples/dialog_examples.c'
--- a/plugin/auth_examples/dialog_examples.c	2011-11-03 18:17:05 +0000
+++ b/plugin/auth_examples/dialog_examples.c	2012-03-27 23:04:46 +0000
@@ -1,5 +1,5 @@
 /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
-   Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+   Copyright (c) 2010, 2011, Oracle and/or its affiliates.
 
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as

=== modified file 'plugin/auth_examples/qa_auth_interface.c'
--- a/plugin/auth_examples/qa_auth_interface.c	2011-11-03 18:17:05 +0000
+++ b/plugin/auth_examples/qa_auth_interface.c	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/*  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+/*  Copyright (c) 2010, 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

=== modified file 'plugin/auth_examples/qa_auth_server.c'
--- a/plugin/auth_examples/qa_auth_server.c	2011-11-03 18:17:05 +0000
+++ b/plugin/auth_examples/qa_auth_server.c	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/*  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+/*  Copyright (c) 2010, 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

=== modified file 'plugin/daemon_example/CMakeLists.txt'
--- a/plugin/daemon_example/CMakeLists.txt	2012-03-16 19:52:17 +0000
+++ b/plugin/daemon_example/CMakeLists.txt	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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

=== modified file 'plugin/daemon_example/daemon_example.cc'
--- a/plugin/daemon_example/daemon_example.cc	2011-11-03 18:17:05 +0000
+++ b/plugin/daemon_example/daemon_example.cc	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 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

=== modified file 'plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp'
--- a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp	2011-09-24 12:45:49 +0000
+++ b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp	2012-03-30 13:00:10 +0000
@@ -7,6 +7,7 @@
  */
 
 #include <my_config.h>
+#include <sys/types.h>
 #include <netinet/in.h>
 #include <errno.h>
 #include <poll.h>

=== modified file 'plugin/handler_socket/libhsclient/fatal.cpp'
--- a/plugin/handler_socket/libhsclient/fatal.cpp	2011-02-20 13:22:10 +0000
+++ b/plugin/handler_socket/libhsclient/fatal.cpp	2012-03-29 19:58:40 +0000
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <syslog.h>
+#include <unistd.h>
 
 #include "fatal.hpp"
 

=== modified file 'plugin/semisync/semisync_master.cc'
--- a/plugin/semisync/semisync_master.cc	2011-11-03 22:39:53 +0000
+++ b/plugin/semisync/semisync_master.cc	2012-03-27 14:16:44 +0000
@@ -626,7 +626,7 @@
                             (int)is_on());
     }
 
-    while (is_on())
+    while (is_on() && !thd_killed(NULL))
     {
       if (reply_file_name_inited_)
       {
@@ -743,7 +743,8 @@
       At this point, the binlog file and position of this transaction
       must have been removed from ActiveTranx.
     */
-    assert(!active_tranxs_->is_tranx_end_pos(trx_wait_binlog_name,
+    assert(thd_killed(NULL) ||
+           !active_tranxs_->is_tranx_end_pos(trx_wait_binlog_name,
                                              trx_wait_binlog_pos));
     
     /* Update the status counter. */

=== modified file 'plugin/sql_errlog/CMakeLists.txt'
--- a/plugin/sql_errlog/CMakeLists.txt	2012-03-13 20:55:56 +0000
+++ b/plugin/sql_errlog/CMakeLists.txt	2012-03-24 10:24:20 +0000
@@ -13,4 +13,4 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
-MYSQL_ADD_PLUGIN(sql_errlog sql_errlog.c MODULE_ONLY)
+MYSQL_ADD_PLUGIN(sql_errlog sql_errlog.c sql_logger.cc service_logger.h MODULE_ONLY)

=== renamed file 'libservices/logger_service.c' => 'plugin/sql_errlog/logger_service.c'
--- a/libservices/logger_service.c	2012-03-13 20:55:56 +0000
+++ b/plugin/sql_errlog/logger_service.c	2012-03-24 10:24:20 +0000
@@ -16,5 +16,6 @@
 #include <service_versions.h>
 
 
+/* file reserved for the future use */
 SERVICE_VERSION *logger_service= (void *) VERSION_logger;
 

=== renamed file 'include/mysql/service_logger.h' => 'plugin/sql_errlog/service_logger.h'
--- a/include/mysql/service_logger.h	2012-03-14 12:37:49 +0000
+++ b/plugin/sql_errlog/service_logger.h	2012-03-24 10:24:20 +0000
@@ -69,7 +69,7 @@
   int (*rotate)(LOGGER_HANDLE *log);
 } *logger_service;
 
-#ifdef MYSQL_DYNAMIC_PLUGIN
+#if 0 /*MYSQL_DYNAMIC_PLUGIN*/
 
 #define logger_open(path, size_limit, rotations) \
   (logger_service->open(path, size_limit, rotations))
@@ -87,6 +87,8 @@
   int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
   int logger_rotate(LOGGER_HANDLE *log); 
   int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
+
+  void init_logger_mutexes();
 #endif
 
 

=== modified file 'plugin/sql_errlog/sql_errlog.c'
--- a/plugin/sql_errlog/sql_errlog.c	2012-03-14 12:37:49 +0000
+++ b/plugin/sql_errlog/sql_errlog.c	2012-03-24 10:24:20 +0000
@@ -16,6 +16,7 @@
 #include <mysql/plugin_audit.h>
 #include <stdio.h>
 #include <time.h>
+#include "service_logger.h"
 
 /*
  Disable __attribute__() on non-gcc compilers.
@@ -32,6 +33,7 @@
   rate 0 means the logging was disabled.
 */
 
+
 static char *filename;
 static unsigned int rate;
 static unsigned long long size_limit;
@@ -50,7 +52,7 @@
 
 static MYSQL_SYSVAR_ULONGLONG(size_limit, size_limit,
        PLUGIN_VAR_READONLY, "Log file size limit", NULL, NULL,
-       1000000, 100, 0, 1);
+       1000000, 100, ((long long) 0x7FFFFFFFFFFFFFFFLL), 1);
 
 static MYSQL_SYSVAR_UINT(rotations, rotations,
        PLUGIN_VAR_READONLY, "Number of rotations before log is removed.",
@@ -104,6 +106,8 @@
 
 static int sql_error_log_init(void *p __attribute__((unused)))
 {
+  init_logger_mutexes();
+
   logfile= logger_open(filename, size_limit, rotations);
   if (logfile == NULL) {
     fprintf(stderr, "Could not create file '%s'\n",
@@ -117,7 +121,8 @@
 
 static int sql_error_log_deinit(void *p __attribute__((unused)))
 {
-  logger_close(logfile);
+  if (logfile)
+    logger_close(logfile);
   return 0;
 }
 
@@ -139,6 +144,24 @@
   { MYSQL_AUDIT_GENERAL_CLASSMASK }
 };
 
+mysql_declare_plugin(sql_errlog)
+{
+  MYSQL_AUDIT_PLUGIN,
+  &descriptor,
+  "SQL_ERROR_LOG",
+  "Alexey Botchkov",
+  "Log SQL level errors to a file with rotation",
+  PLUGIN_LICENSE_GPL,
+  sql_error_log_init,
+  sql_error_log_deinit,
+  0x0100,
+  NULL,
+  vars,
+  NULL,
+  0
+}
+mysql_declare_plugin_end;
+
 maria_declare_plugin(sql_errlog)
 {
   MYSQL_AUDIT_PLUGIN,

=== renamed file 'sql/sql_logger.cc' => 'plugin/sql_errlog/sql_logger.cc'
--- a/sql/sql_logger.cc	2012-03-14 23:37:37 +0000
+++ b/plugin/sql_errlog/sql_logger.cc	2012-03-24 10:24:20 +0000
@@ -16,10 +16,15 @@
 
 #include "my_global.h"
 #include <my_sys.h>
-#include <mysql/service_logger.h>
-
-extern char *mysql_data_home;
-extern PSI_mutex_key key_LOCK_logger_service;
+#include "service_logger.h"
+#include <my_pthread.h>
+
+extern MYSQL_PLUGIN_IMPORT char  *mysql_data_home;
+
+/* These belong to the service initialization */
+static PSI_mutex_key key_LOCK_logger_service;
+static PSI_mutex_info mutex_list[]=
+{{ &key_LOCK_logger_service, "logger_service_file_st::lock", PSI_FLAG_GLOBAL}};
 
 typedef struct logger_handle_st {
   File file;
@@ -181,3 +186,9 @@
   return result;
 }
 
+void init_logger_mutexes()
+{
+  if (PSI_server)
+    PSI_server->register_mutex("sql_logger", mutex_list, 1);
+}
+

=== modified file 'scripts/mysql_install_db.pl.in'
--- a/scripts/mysql_install_db.pl.in	2012-01-13 14:50:02 +0000
+++ b/scripts/mysql_install_db.pl.in	2012-04-07 13:58:46 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # -*- cperl -*-
 #
-# Copyright (C) 2007 MySQL AB
+# Copyright (c) 2007, 2011, Oracle and/or its affiliates.
 #
 # 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

=== modified file 'scripts/mysql_install_db.sh'
--- a/scripts/mysql_install_db.sh	2012-01-13 14:50:02 +0000
+++ b/scripts/mysql_install_db.sh	2012-04-07 13:58:46 +0000
@@ -1,7 +1,6 @@
 #!/bin/sh
-# Copyright (c) 2000-2008 MySQL AB, 2009, 2010 Sun Microsystems, Inc.
-# Copyright (c) 2009-2011 Monty Program Ab
-# Use is subject to license terms.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+# Copyright (c) 2009, 2011, Monty Program Ab
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

=== modified file 'scripts/mysqld_safe.sh'
--- a/scripts/mysqld_safe.sh	2012-03-09 07:06:59 +0000
+++ b/scripts/mysqld_safe.sh	2012-04-02 09:09:22 +0000
@@ -15,6 +15,7 @@
 KILL_MYSQLD=1;
 MYSQLD=
 niceness=0
+nowatch=0
 mysqld_ld_preload=
 mysqld_ld_library_path=
 
@@ -44,16 +45,18 @@
         cat <<EOF
 Usage: $0 [OPTIONS]
   --no-defaults              Don't read the system defaults file
+  --core-file-size=LIMIT     Limit core files to the specified size
   --defaults-file=FILE       Use the specified defaults file
   --defaults-extra-file=FILE Also use defaults from the specified file
   --ledir=DIRECTORY          Look for mysqld in the specified directory
   --open-files-limit=LIMIT   Limit the number of open files
-  --core-file-size=LIMIT     Limit core files to the specified size
   --timezone=TZ              Set the system timezone
   --malloc-lib=LIB           Preload shared library LIB if available
   --mysqld=FILE              Use the specified file as mysqld
   --mysqld-version=VERSION   Use "mysqld-VERSION" as mysqld
   --nice=NICE                Set the scheduling priority of mysqld
+  --no-auto-restart          Exit after starting mysqld
+  --nowatch                  Exit after starting mysqld
   --plugin-dir=DIR           Plugins are under DIR or DIR/VERSION, if
                              VERSION is given
   --skip-kill-mysqld         Don't try to kill stray mysqld processes
@@ -140,8 +143,16 @@
       ;;
   esac
 
-  #echo "Running mysqld: [$cmd]"
-  eval "$cmd"
+  if test $nowatch -eq 1
+  then
+    # We'd prefer to exec $cmd here, but SELinux needs to be fixed first
+    #/usr/bin/logger "Running mysqld: $cmd"
+    eval "$cmd &"
+    exit 0
+  else
+    #echo "Running mysqld: [$cmd]"
+    eval "$cmd"
+  fi
 }
 
 shell_quote_string() {
@@ -202,6 +213,7 @@
         fi
         ;;
       --nice=*) niceness="$val" ;;
+      --nowatch|--no-watch|--no-auto-restart) nowatch=1 ;;
       --open-files-limit=*) open_files="$val" ;;
       --open_files_limit=*) open_files="$val" ;;
       --skip-kill-mysqld*) KILL_MYSQLD=0 ;;

=== modified file 'scripts/mytop.sh'
--- a/scripts/mytop.sh	2011-12-03 21:06:16 +0000
+++ b/scripts/mytop.sh	2012-03-27 13:06:00 +0000
@@ -18,8 +18,10 @@
 use Getopt::Long;
 use Socket;
 use List::Util qw(min max);
+use File::Basename;
 
 $main::VERSION = "1.9a";
+my $path_for_script= dirname($0);
 
 $|=1;
 $0 = 'mytop';
@@ -95,7 +97,8 @@
     slow	  => 10,	# slow query time
     socket        => '',
     sort          => 0,         # default or reverse sort ("s")
-    user          => 'root'
+    user          => 'root',
+    fullqueries   => 0
 );
 
 my %qcache = ();    ## The query cache--used for full query info support.
@@ -112,6 +115,17 @@
 my $RM_RESET   = 0;
 my $RM_NOBLKRD = 3; ## using 4 traps Ctrl-C :-(
 
+# Add options from .my.cnf first
+
+my $my_print_defaults;
+if (!defined($my_print_defaults=my_which("my_print_defaults")))
+{
+  print "Warning: Can't find my_print_defaults. Please add it to your PATH!\n";
+  exit(1);
+}
+
+unshift @ARGV, split "\n", `$my_print_defaults client mytop`;
+
 ## Read the user's config file, if it exists.
 
 my $config = "$ENV{HOME}/.mytop";
@@ -160,7 +174,8 @@
     "long_nums!"          => \$config{long_nums},
     "mode|m=s"            => \$config{mode},
     "slow=i"		  => \$config{slow},
-    "sort=s"              => \$config{sort}
+    "sort=s"              => \$config{sort},
+    "fullqueries|L!"      => \$config{fullqueries}
 );
 
 ## User may have put the port with the host.
@@ -744,6 +759,25 @@
     {
         $config{mode} = 'status';
     }
+
+   ## L - full queries toggle
+
+    if ($key eq 'L')
+    {
+        if ($config{fullqueries})
+        {
+            $config{fullqueries} = 0;
+            print RED(), "-- full queries OFF --", RESET();
+            sleep 1;
+        }
+        else
+        {
+            $config{fullqueries} = 1;
+            print RED(), "-- full queries ON --", RESET();
+            sleep 1;
+        }
+    }
+
 }
 
 ReadMode($RM_RESET) unless $config{batchmode};
@@ -1115,7 +1149,13 @@
     my $state= $width <= 80 ? 6 : int(min(6+($width-80)/3, 15));
     my $free = $width - $used - ($state - 6);
     my $format= "%9s %8s %15s %9s %6s %5s %6s %${state}s %-.${free}s\n";
-    my $format2= "%9d %8.8s %15.15s %9.9s %6d %5.1f %6.6s %${state}.${state}s %-${free}.${free}s\n";
+    my $format2;
+    if ($config{fullqueries})
+    {
+         $format2 = "%9d %8.8s %15.15s %9.9s %6d %5.1f %6.6s %${state}.${state}s %-${free}s\n";
+    } else {
+         $format2 = "%9d %8.8s %15.15s %9.9s %6d %5.1f %6.6s %${state}.${state}s %-${free}.${free}s\n";
+    }
     print BOLD() if ($HAS_COLOR);
 
     printf $format,
@@ -1244,7 +1284,12 @@
 
         if ($thread->{Info})
         {
-            $smInfo = substr $thread->{Info}, 0, $free;
+            if ($config{fullqueries})
+            {
+                $smInfo = $thread->{Info};
+            } else {
+                $smInfo = substr $thread->{Info}, 0, $free;
+            }
         }
 #        if ($thread->{State})
 #        {
@@ -1690,6 +1735,7 @@
   u - show only a specific user
   V - show variablesi
   : - enter a command (not yet implemented)
+  L - show full queries (do not strip to terminal width)
 
 Base version from ${GREEN}http://www.mysqlfanboy.com/mytop${RESET}
 This version comes as part of the ${GREEN}MariaDB${RESET} distribution.
@@ -1789,6 +1835,35 @@
     return $found;
 }
 
+####
+#### my_which is used, because we can't assume that every system has the
+#### which -command. my_which can take only one argument at a time.
+#### Return values: requested system command with the first found path,
+#### or undefined, if not found.
+####
+
+sub my_which
+{
+  my ($command) = @_;
+  my (@paths, $path);
+
+  return $command if (-f $command && -x $command);
+
+  # Check first if this is a source distribution, then if this binary
+  # distribution and last in the path
+
+  push @paths, "./extra";
+  push @paths, $path_for_script;
+  push @paths, split(':', $ENV{'PATH'});
+
+  foreach $path (@paths)
+  {
+    $path .= "/$command";
+    return $path if (-f $path && -x $path);
+  }
+  return undef();
+}
+
 =pod
 
 =head1 SYNOPSIS
@@ -2056,11 +2131,15 @@
 =head2 Config File
 
 Instead of always using bulky command-line parameters, you can also
-use a config file in your home directory (C<~/.mytop>). If present,
-B<mytop> will read it automatically. It is read I<before> any of your
+use a config files for the default value of your options.
+
+mytop will first read the [client] and [mytop] sections from your
+my.cnf files. After that it will read the (C<~/.mytop>) file from your
+home directory (if present). These are read I<before> any of your
 command-line arguments are processed, so your command-line arguments
 will override directives in the config file.
 
+
 Here is a sample config file C<~/.mytop> which implements the defaults
 described above.
 
@@ -2275,6 +2354,10 @@
 
 =over
 
+=Item Jean Weisbuch
+
+Added --fullqueries and reading of .my.cnf
+
 =item Sami Ahlroos (sami at avis-net.de)
 
 Suggested the idle/noidle stuff.

=== modified file 'sql-common/my_time.c'
--- a/sql-common/my_time.c	2012-03-09 07:06:59 +0000
+++ b/sql-common/my_time.c	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2004, 2012, Oracle and/or its affiliates.
 
  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

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2012-03-19 08:35:32 +0000
+++ b/sql/CMakeLists.txt	2012-04-12 03:44:52 +0000
@@ -86,7 +86,6 @@
                gcalc_slicescan.cc gcalc_tools.cc
 			   threadpool_common.cc 
 			   ../sql-common/mysql_async.c
-                           sql_logger.cc
                ${GEN_SOURCES}
                ${MYSYS_LIBWRAP_SOURCE}
 			   )

=== modified file 'sql/debug_sync.cc'
--- a/sql/debug_sync.cc	2012-01-13 14:50:02 +0000
+++ b/sql/debug_sync.cc	2012-03-28 17:26:00 +0000
@@ -13,307 +13,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
-/**
-  == Debug Sync Facility ==
-
-  The Debug Sync Facility allows placement of synchronization points in
-  the server code by using the DEBUG_SYNC macro:
-
-      open_tables(...)
-
-      DEBUG_SYNC(thd, "after_open_tables");
-
-      lock_tables(...)
-
-  When activated, a sync point can
-
-    - Emit a signal and/or
-    - Wait for a signal
-
-  Nomenclature:
-
-    - signal:             A value of a global variable that persists
-                          until overwritten by a new signal. The global
-                          variable can also be seen as a "signal post"
-                          or "flag mast". Then the signal is what is
-                          attached to the "signal post" or "flag mast".
-
-    - emit a signal:      Assign the value (the signal) to the global
-                          variable ("set a flag") and broadcast a
-                          global condition to wake those waiting for
-                          a signal.
-
-    - wait for a signal:  Loop over waiting for the global condition until
-                          the global value matches the wait-for signal.
-
-  By default, all sync points are inactive. They do nothing (except to
-  burn a couple of CPU cycles for checking if they are active).
-
-  A sync point becomes active when an action is requested for it.
-  To do so, put a line like this in the test case file:
-
-      SET DEBUG_SYNC= 'after_open_tables SIGNAL opened WAIT_FOR flushed';
-
-  This activates the sync point 'after_open_tables'. It requests it to
-  emit the signal 'opened' and wait for another thread to emit the signal
-  'flushed' when the thread's execution runs through the sync point.
-
-  For every sync point there can be one action per thread only. Every
-  thread can request multiple actions, but only one per sync point. In
-  other words, a thread can activate multiple sync points.
-
-  Here is an example how to activate and use the sync points:
-
-      --connection conn1
-      SET DEBUG_SYNC= 'after_open_tables SIGNAL opened WAIT_FOR flushed';
-      send INSERT INTO t1 VALUES(1);
-          --connection conn2
-          SET DEBUG_SYNC= 'now WAIT_FOR opened';
-          SET DEBUG_SYNC= 'after_abort_locks SIGNAL flushed';
-          FLUSH TABLE t1;
-
-  When conn1 runs through the INSERT statement, it hits the sync point
-  'after_open_tables'. It notices that it is active and executes its
-  action. It emits the signal 'opened' and waits for another thread to
-  emit the signal 'flushed'.
-
-  conn2 waits immediately at the special sync point 'now' for another
-  thread to emit the 'opened' signal.
-
-  A signal remains in effect until it is overwritten. If conn1 signals
-  'opened' before conn2 reaches 'now', conn2 will still find the 'opened'
-  signal. It does not wait in this case.
-
-  When conn2 reaches 'after_abort_locks', it signals 'flushed', which lets
-  conn1 awake.
-
-  Normally the activation of a sync point is cleared when it has been
-  executed. Sometimes it is necessary to keep the sync point active for
-  another execution. You can add an execute count to the action:
-
-      SET DEBUG_SYNC= 'name SIGNAL sig EXECUTE 3';
-
-  This sets the signal point's activation counter to 3. Each execution
-  decrements the counter. After the third execution the sync point
-  becomes inactive.
-
-  One of the primary goals of this facility is to eliminate sleeps from
-  the test suite. In most cases it should be possible to rewrite test
-  cases so that they do not need to sleep. (But this facility cannot
-  synchronize multiple processes.) However, to support test development,
-  and as a last resort, sync point waiting times out. There is a default
-  timeout, but it can be overridden:
-
-      SET DEBUG_SYNC= 'name WAIT_FOR sig TIMEOUT 10 EXECUTE 2';
-
-  TIMEOUT 0 is special: If the signal is not present, the wait times out
-  immediately.
-
-  When a wait timed out (even on TIMEOUT 0), a warning is generated so
-  that it shows up in the test result.
-
-  You can throw an error message and kill the query when a synchronization
-  point is hit a certain number of times:
-
-      SET DEBUG_SYNC= 'name HIT_LIMIT 3';
-
-  Or combine it with signal and/or wait:
-
-      SET DEBUG_SYNC= 'name SIGNAL sig EXECUTE 2 HIT_LIMIT 3';
-
-  Here the first two hits emit the signal, the third hit returns the error
-  message and kills the query.
-
-  For cases where you are not sure that an action is taken and thus
-  cleared in any case, you can force to clear (deactivate) a sync point:
-
-      SET DEBUG_SYNC= 'name CLEAR';
-
-  If you want to clear all actions and clear the global signal, use:
-
-      SET DEBUG_SYNC= 'RESET';
-
-  This is the only way to reset the global signal to an empty string.
-
-  For testing of the facility itself you can execute a sync point just
-  as if it had been hit:
-
-      SET DEBUG_SYNC= 'name TEST';
-
-
-  === Formal Syntax ===
-
-  The string to "assign" to the DEBUG_SYNC variable can contain:
-
-      {RESET |
-       <sync point name> TEST |
-       <sync point name> CLEAR |
-       <sync point name> {{SIGNAL <signal name> |
-                           WAIT_FOR <signal name> [TIMEOUT <seconds>]}
-                          [EXECUTE <count>] &| HIT_LIMIT <count>}
-
-  Here '&|' means 'and/or'. This means that one of the sections
-  separated by '&|' must be present or both of them.
-
-
-  === Activation/Deactivation ===
-
-  The facility is an optional part of the MySQL server.
-  It is enabled in a debug server by default.
-
-      ./configure --enable-debug-sync
-
-  The Debug Sync Facility, when compiled in, is disabled by default. It
-  can be enabled by a mysqld command line option:
-
-      --debug-sync-timeout[=default_wait_timeout_value_in_seconds]
-
-  'default_wait_timeout_value_in_seconds' is the default timeout for the
-  WAIT_FOR action. If set to zero, the facility stays disabled.
-
-  The facility is enabled by default in the test suite, but can be
-  disabled with:
-
-      mysql-test-run.pl ... --debug-sync-timeout=0 ...
-
-  Likewise the default wait timeout can be set:
-
-      mysql-test-run.pl ... --debug-sync-timeout=10 ...
-
-  The command line option influences the readable value of the system
-  variable 'debug_sync'.
-
-  * If the facility is not compiled in, the system variable does not exist.
-
-  * If --debug-sync-timeout=0 the value of the variable reads as "OFF".
-
-  * Otherwise the value reads as "ON - current signal: " followed by the
-    current signal string, which can be empty.
-
-  The readable variable value is the same, regardless if read as global
-  or session value.
-
-  Setting the 'debug-sync' system variable requires 'SUPER' privilege.
-  You can never read back the string that you assigned to the variable,
-  unless you assign the value that the variable does already have. But
-  that would give a parse error. A syntactically correct string is
-  parsed into a debug sync action and stored apart from the variable value.
-
-
-  === Implementation ===
-
-  Pseudo code for a sync point:
-
-      #define DEBUG_SYNC(thd, sync_point_name)
-                if (unlikely(opt_debug_sync_timeout))
-                  debug_sync(thd, STRING_WITH_LEN(sync_point_name))
-
-  The sync point performs a binary search in a sorted array of actions
-  for this thread.
-
-  The SET DEBUG_SYNC statement adds a requested action to the array or
-  overwrites an existing action for the same sync point. When it adds a
-  new action, the array is sorted again.
-
-
-  === A typical synchronization pattern ===
-
-  There are quite a few places in MySQL, where we use a synchronization
-  pattern like this:
-
-  mysql_mutex_lock(&mutex);
-  thd->enter_cond(&condition_variable, &mutex, new_message);
-  #if defined(ENABLE_DEBUG_SYNC)
-  if (!thd->killed && !end_of_wait_condition)
-     DEBUG_SYNC(thd, "sync_point_name");
-  #endif
-  while (!thd->killed && !end_of_wait_condition)
-    mysql_cond_wait(&condition_variable, &mutex);
-  thd->exit_cond(old_message);
-
-  Here some explanations:
-
-  thd->enter_cond() is used to register the condition variable and the
-  mutex in thd->mysys_var. This is done to allow the thread to be
-  interrupted (killed) from its sleep. Another thread can find the
-  condition variable to signal and mutex to use for synchronization in
-  this thread's THD::mysys_var.
-
-  thd->enter_cond() requires the mutex to be acquired in advance.
-
-  thd->exit_cond() unregisters the condition variable and mutex and
-  releases the mutex.
-
-  If you want to have a Debug Sync point with the wait, please place it
-  behind enter_cond(). Only then you can safely decide, if the wait will
-  be taken. Also you will have THD::proc_info correct when the sync
-  point emits a signal. DEBUG_SYNC sets its own proc_info, but restores
-  the previous one before releasing its internal mutex. As soon as
-  another thread sees the signal, it does also see the proc_info from
-  before entering the sync point. In this case it will be "new_message",
-  which is associated with the wait that is to be synchronized.
-
-  In the example above, the wait condition is repeated before the sync
-  point. This is done to skip the sync point, if no wait takes place.
-  The sync point is before the loop (not inside the loop) to have it hit
-  once only. It is possible that the condition variable is signaled
-  multiple times without the wait condition to be true.
-
-  A bit off-topic: At some places, the loop is taken around the whole
-  synchronization pattern:
-
-  while (!thd->killed && !end_of_wait_condition)
-  {
-    mysql_mutex_lock(&mutex);
-    thd->enter_cond(&condition_variable, &mutex, new_message);
-    if (!thd->killed [&& !end_of_wait_condition])
-    {
-      [DEBUG_SYNC(thd, "sync_point_name");]
-      mysql_cond_wait(&condition_variable, &mutex);
-    }
-    thd->exit_cond(old_message);
-  }
-
-  Note that it is important to repeat the test for thd->killed after
-  enter_cond(). Otherwise the killing thread may kill this thread after
-  it tested thd->killed in the loop condition and before it registered
-  the condition variable and mutex in enter_cond(). In this case, the
-  killing thread does not know that this thread is going to wait on a
-  condition variable. It would just set THD::killed. But if we would not
-  test it again, we would go asleep though we are killed. If the killing
-  thread would kill us when we are after the second test, but still
-  before sleeping, we hold the mutex, which is registered in mysys_var.
-  The killing thread would try to acquire the mutex before signaling
-  the condition variable. Since the mutex is only released implicitly in
-  mysql_cond_wait(), the signaling happens at the right place. We
-  have a safe synchronization.
-
-  === Co-work with the DBUG facility ===
-
-  When running the MySQL test suite with the --debug-dbug command line
-  option, the Debug Sync Facility writes trace messages to the DBUG
-  trace. The following shell commands proved very useful in extracting
-  relevant information:
-
-  egrep 'query:|debug_sync_exec:' mysql-test/var/log/mysqld.1.trace
-
-  It shows all executed SQL statements and all actions executed by
-  synchronization points.
-
-  Sometimes it is also useful to see, which synchronization points have
-  been run through (hit) with or without executing actions. Then add
-  "|debug_sync_point:" to the egrep pattern.
-
-  === Further reading ===
-
-  For a discussion of other methods to synchronize threads see
-  http://forge.mysql.com/wiki/MySQL_Internals_Test_Synchronization
-
-  For complete syntax tests, functional tests, and examples see the test
-  case debug_sync.test.
-
-  See also worklog entry WL#4259 - Test Synchronization Facility
-*/
+/* see include/mysql/service_debug_sync.h for debug sync documentation */
 
 #include "debug_sync.h"
 
@@ -382,57 +82,16 @@
 };
 static st_debug_sync_globals debug_sync_global; /* All globals in one object */
 
-/**
-  Callback pointer for C files.
-*/
-extern "C" void (*debug_sync_C_callback_ptr)(const char *, size_t);
+extern uint opt_debug_sync_timeout;
 
 /**
   Callbacks from C files.
 */
 C_MODE_START
-static void debug_sync_C_callback(const char *, size_t);
+static void debug_sync(THD *thd, const char *sync_point_name, size_t name_len);
 static int debug_sync_qsort_cmp(const void *, const void *);
 C_MODE_END
 
-/**
-  Callback for debug sync, to be used by C files. See thr_lock.c for example.
-
-  @description
-
-    We cannot place a sync point directly in C files (like those in mysys or
-    certain storage engines written mostly in C like MyISAM or Maria). Because
-    they are C code and do not include sql_priv.h. So they do not know the
-    macro DEBUG_SYNC(thd, sync_point_name). The macro needs a 'thd' argument.
-    Hence it cannot be used in files outside of the sql/ directory.
-
-    The workaround is to call back simple functions like this one from
-    non-sql/ files.
-
-    We want to allow modules like thr_lock to be used without sql/ and
-    especially without Debug Sync. So we cannot just do a simple call
-    of the callback function. Instead we provide a global pointer in
-    the other file, which is to be set to the callback by Debug Sync.
-    If the pointer is not set, no call back will be done. If Debug
-    Sync sets the pointer to a callback function like this one, it will
-    be called. That way thr_lock.c does not have an undefined reference
-    to Debug Sync and can be used without it. Debug Sync, in contrast,
-    has an undefined reference to that pointer and thus requires
-    thr_lock to be linked too. But this is not a problem as it is part
-    of the MySQL server anyway.
-
-  @note
-    The callback pointer in C files is set only if debug sync is
-    initialized. And this is done only if opt_debug_sync_timeout is set.
-*/
-
-static void debug_sync_C_callback(const char *sync_point_name,
-                                  size_t name_len)
-{
-  if (unlikely(opt_debug_sync_timeout))
-    debug_sync(current_thd, sync_point_name, name_len);
-}
-
 #ifdef HAVE_PSI_INTERFACE
 static PSI_mutex_key key_debug_sync_globals_ds_mutex;
 
@@ -495,7 +154,7 @@
       DBUG_RETURN(rc); /* purecov: inspected */
 
     /* Set the call back pointer in C files. */
-    debug_sync_C_callback_ptr= debug_sync_C_callback;
+    debug_sync_C_callback_ptr= debug_sync;
   }
 
   DBUG_RETURN(0);
@@ -1857,12 +1516,14 @@
   @param[in]     name_len           length of sync point name
 */
 
-void debug_sync(THD *thd, const char *sync_point_name, size_t name_len)
+static void debug_sync(THD *thd, const char *sync_point_name, size_t name_len)
 {
+  if (!thd)
+    thd= current_thd;
+
   st_debug_sync_control *ds_control= thd->debug_sync_control;
   st_debug_sync_action  *action;
   DBUG_ENTER("debug_sync");
-  DBUG_ASSERT(thd);
   DBUG_ASSERT(sync_point_name);
   DBUG_ASSERT(name_len);
   DBUG_ASSERT(ds_control);

=== modified file 'sql/debug_sync.h'
--- a/sql/debug_sync.h	2012-01-13 14:50:02 +0000
+++ b/sql/debug_sync.h	2012-03-28 17:26:00 +0000
@@ -32,15 +32,6 @@
 
 #if defined(ENABLED_DEBUG_SYNC)
 
-/* Macro to be put in the code at synchronization points. */
-#define DEBUG_SYNC(_thd_, _sync_point_name_)                            \
-          do { if (unlikely(opt_debug_sync_timeout))                    \
-               debug_sync(_thd_, STRING_WITH_LEN(_sync_point_name_));   \
-             } while (0)
-
-/* Command line option --debug-sync-timeout. See mysqld.cc. */
-extern MYSQL_PLUGIN_IMPORT uint opt_debug_sync_timeout;
-
 /* Default WAIT_FOR timeout if command line option is given without argument. */
 #define DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT 300
 
@@ -49,13 +40,8 @@
 extern void debug_sync_end(void);
 extern void debug_sync_init_thread(THD *thd);
 extern void debug_sync_end_thread(THD *thd);
-extern void debug_sync(THD *thd, const char *sync_point_name, size_t name_len);
 extern bool debug_sync_set_action(THD *thd, const char *action_str, size_t len);
 
-#else /* defined(ENABLED_DEBUG_SYNC) */
-
-#define DEBUG_SYNC(_thd_, _sync_point_name_)    /* disabled DEBUG_SYNC */
-
 #endif /* defined(ENABLED_DEBUG_SYNC) */
 
 #endif /* DEBUG_SYNC_INCLUDED */

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2012-03-19 08:35:32 +0000
+++ b/sql/field.cc	2012-04-12 03:44:52 +0000
@@ -7876,8 +7876,7 @@
   ulonglong tmp=(ulonglong) Field_enum::val_int();
   uint bitnr=0;
 
-  val_buffer->length(0);
-  val_buffer->set_charset(field_charset);
+  val_buffer->set("", 0, field_charset);
   while (tmp && bitnr < (uint) typelib->count)
   {
     if (tmp & 1)

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2012-03-17 08:26:58 +0000
+++ b/sql/filesort.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2011, Oracle and/or its affiliates.  
 
    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
@@ -44,13 +44,11 @@
 
 	/* functions defined in this file */
 
-static char **make_char_array(char **old_pos, register uint fields,
-                              uint length, myf my_flag);
 static uchar *read_buffpek_from_file(IO_CACHE *buffer_file, uint count,
                                      uchar *buf);
 static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select,
-			     uchar * *sort_keys, IO_CACHE *buffer_file,
-			     IO_CACHE *tempfile,IO_CACHE *indexfile);
+			     uchar * *sort_keys, uchar *sort_keys_buf,
+                             IO_CACHE *buffer_file, IO_CACHE *tempfile);
 static int write_keys(SORTPARAM *param,uchar * *sort_keys,
 		      uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile);
 static void make_sortkey(SORTPARAM *param,uchar *to, uchar *ref_pos);
@@ -86,8 +84,6 @@
 			(Needed by UPDATE/INSERT or ALTER TABLE)
   @param examined_rows	Store number of examined rows here
 
-  @todo
-    check why we do this (param.keys--)
   @note
     If we sort by position (like if sort_positions is 1) filesort() will
     call table->prepare_for_position().
@@ -105,12 +101,13 @@
                  bool sort_positions, ha_rows *examined_rows)
 {
   int error;
-  ulong memavl, min_sort_memory;
+  ulong memory_available= thd->variables.sortbuff_size;
+  ulong min_sort_memory;
   uint maxbuffer;
   BUFFPEK *buffpek;
-  ha_rows records= HA_POS_ERROR;
+  ha_rows num_rows= HA_POS_ERROR;
   uchar **sort_keys= 0;
-  IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile; 
+  IO_CACHE tempfile, buffpek_pointers, *outfile; 
   SORTPARAM param;
   bool multi_byte_charset;
   DBUG_ENTER("filesort");
@@ -183,75 +180,67 @@
   param.max_rows= max_rows;
 
   if (select && select->quick)
-  {
     status_var_increment(thd->status_var.filesort_range_count);
-  }
   else
-  {
     status_var_increment(thd->status_var.filesort_scan_count);
-  }
   thd->query_plan_flags|= QPLAN_FILESORT;
-#ifdef CAN_TRUST_RANGE
-  if (select && select->quick && select->quick->records > 0L)
-  {
-    records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-		table->file->stats.records)+EXTRA_RECORDS;
-    selected_records_file=0;
-  }
-  else
-#endif
-  {
-    records= table->file->estimate_rows_upper_bound();
-    /*
-      If number of records is not known, use as much of sort buffer 
-      as possible. 
-    */
-    if (records == HA_POS_ERROR)
-      records--;  // we use 'records+1' below.
-    selected_records_file= 0;
-  }
+
+  // If number of rows is not known, use as much of sort buffer as possible. 
+  num_rows= table->file->estimate_rows_upper_bound();
 
   if (multi_byte_charset &&
       !(param.tmp_buffer= (char*) my_malloc(param.sort_length,MYF(MY_WME))))
     goto err;
 
-  memavl= thd->variables.sortbuff_size;
-  min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-  while (memavl >= min_sort_memory)
+  min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length * MERGEBUFF2);
+  if (!table_sort.sort_keys)
   {
-    ulong old_memavl;
-    ulong keys= memavl/(param.rec_length+sizeof(char*));
-    param.keys=(uint) min(records+1, keys);
-    if ((table_sort.sort_keys=
-	 (uchar **) make_char_array((char **) table_sort.sort_keys,
-                                    param.keys, param.rec_length, MYF(0))))
-      break;
-    old_memavl=memavl;
-    if ((memavl=memavl/4*3) < min_sort_memory && old_memavl > min_sort_memory)
-      memavl= min_sort_memory;
+    while (memory_available >= min_sort_memory)
+    {
+      ulong keys= memory_available / (param.rec_length + sizeof(char*));
+      table_sort.keys= (uint) min(num_rows, keys);
+
+      DBUG_EXECUTE_IF("make_sort_keys_alloc_fail",
+                      DBUG_SET("+d,simulate_out_of_memory"););
+
+      if ((table_sort.sort_keys=
+           (uchar**) my_malloc(table_sort.keys*(param.rec_length+sizeof(char*)),
+                               MYF(0))))
+        break;
+      ulong old_memory_available= memory_available;
+      memory_available= memory_available/4*3;
+      if (memory_available < min_sort_memory &&
+          old_memory_available > min_sort_memory)
+        memory_available= min_sort_memory;
+    }
   }
+
   sort_keys= table_sort.sort_keys;
-  if (memavl < min_sort_memory)
+  param.keys= table_sort.keys;
+  if (memory_available < min_sort_memory)
   {
-    my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR+ME_WAITTANG));
+    my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR + ME_FATALERROR));
     goto err;
   }
   if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX,
 		       DISK_BUFFER_SIZE, MYF(ME_ERROR | MY_WME)))
     goto err;
 
-  param.keys--;  			/* TODO: check why we do this */
   param.sort_form= table;
   param.end=(param.local_sortorder=sortorder)+s_length;
-  if ((records=find_all_keys(&param,select,sort_keys, &buffpek_pointers,
-			     &tempfile, selected_records_file)) ==
-      HA_POS_ERROR)
+  num_rows= find_all_keys(&param,
+                          select,
+                          sort_keys,
+                          (uchar *)(sort_keys+param.keys),
+                          &buffpek_pointers,
+                          &tempfile);
+  if (num_rows == HA_POS_ERROR)
     goto err;
   maxbuffer= (uint) (my_b_tell(&buffpek_pointers)/sizeof(*buffpek));
 
   if (maxbuffer == 0)			// The whole set is in memory
   {
-    if (save_index(&param,sort_keys,(uint) records, &table_sort))
+    if (save_index(&param,sort_keys,(uint) num_rows, &table_sort))
       goto err;
   }
   else
@@ -285,8 +274,9 @@
       Use also the space previously used by string pointers in sort_buffer
       for temporary key storage.
     */
-    param.keys=((param.keys*(param.rec_length+sizeof(char*))) /
-		param.rec_length-1);
+    param.keys=((param.keys *
+                 (param.rec_length+sizeof(char*))) /
+		param.rec_length - 1);
     maxbuffer--;				// Offset from 0
     if (merge_many_buff(&param,(uchar*) sort_keys,buffpek,&maxbuffer,
 			&tempfile))
@@ -294,13 +284,21 @@
     if (flush_io_cache(&tempfile) ||
 	reinit_io_cache(&tempfile,READ_CACHE,0L,0,0))
       goto err;
-    if (merge_index(&param,(uchar*) sort_keys,buffpek,maxbuffer,&tempfile,
+    if (merge_index(&param,
+                    (uchar*) sort_keys,
+                    buffpek,
+                    maxbuffer,
+                    &tempfile,
 		    outfile))
       goto err;
   }
-  if (records > param.max_rows)
-    records=param.max_rows;
-  error =0;
+
+  if (num_rows > param.max_rows)
+  {
+    // If find_all_keys() produced more results than the query LIMIT.
+    num_rows= param.max_rows;
+  }
+  error= 0;
 
  err:
   my_free(param.tmp_buffer);
@@ -349,15 +347,15 @@
   }
   else
     statistic_add(thd->status_var.filesort_rows,
-		  (ulong) records, &LOCK_status);
+		  (ulong) num_rows, &LOCK_status);
   *examined_rows= param.examined_rows;
 #ifdef SKIP_DBUG_IN_FILESORT
   DBUG_POP();			/* Ok to DBUG */
 #endif
   memcpy(&table->sort, &table_sort, sizeof(FILESORT_INFO));
-  DBUG_PRINT("exit",("records: %ld", (long) records));
-  MYSQL_FILESORT_DONE(error, records);
-  DBUG_RETURN(error ? HA_POS_ERROR : records);
+  DBUG_PRINT("exit",("num_rows: %ld", (long) num_rows));
+  MYSQL_FILESORT_DONE(error, num_rows);
+  DBUG_RETURN(error ? HA_POS_ERROR : num_rows);
 } /* filesort */
 
 
@@ -381,29 +379,6 @@
   table->sort.addon_field= NULL;
 }
 
-/** Make a array of string pointers. */
-
-static char **make_char_array(char **old_pos, register uint fields,
-                              uint length, myf my_flag)
-{
-  register char **pos;
-  char *char_pos;
-  DBUG_ENTER("make_char_array");
-
-  DBUG_EXECUTE_IF("make_char_array_fail",
-                  DBUG_SET("+d,simulate_out_of_memory"););
-
-  if (old_pos ||
-      (old_pos= (char**) my_malloc((uint) fields*(length+sizeof(char*)),
-				   my_flag)))
-  {
-    pos=old_pos; char_pos=((char*) (pos+fields)) -length;
-    while (fields--) *(pos++) = (char_pos+= length);
-  }
-
-  DBUG_RETURN(old_pos);
-} /* make_char_array */
-
 
 /** Read 'count' number of buffer pointers into memory. */
 
@@ -490,7 +465,6 @@
   @param buffpek_pointers  File to write BUFFPEKs describing sorted segments
                            in tempfile.
   @param tempfile          File to write sorted sequences of sortkeys to.
-  @param indexfile         If !NULL, use it for source data (contains rowids)
 
   @note
     Basic idea:
@@ -518,9 +492,9 @@
 */
 
 static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
-			     uchar **sort_keys,
+			     uchar **sort_keys, uchar *sort_keys_buf,
 			     IO_CACHE *buffpek_pointers,
-			     IO_CACHE *tempfile, IO_CACHE *indexfile)
+			     IO_CACHE *tempfile)
 {
   int error,flag,quick_select;
   uint idx,indexpos,ref_length;
@@ -531,6 +505,7 @@
   volatile killed_state *killed= &thd->killed;
   handler *file;
   MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set;
+  uchar *next_sort_key= sort_keys_buf;
   DBUG_ENTER("find_all_keys");
   DBUG_PRINT("info",("using: %s",
                      (select ? select->quick ? "ranges" : "where":
@@ -544,12 +519,11 @@
   ref_pos= ref_buff;
   quick_select=select && select->quick;
   record=0;
-  flag= ((!indexfile && (file->ha_table_flags() & HA_REC_NOT_IN_SEQ))
-	 || quick_select);
-  if (indexfile || flag)
+  flag= ((file->ha_table_flags() & HA_REC_NOT_IN_SEQ) || quick_select);
+  if (flag)
     ref_pos= &file->ref[0];
   next_pos=ref_pos;
-  if (! indexfile && ! quick_select)
+  if (!quick_select)
   {
     next_pos=(uchar*) 0;			/* Find records in sequence */
     if (file->ha_rnd_init_with_error(1))
@@ -589,26 +563,16 @@
     {
       if ((error= select->quick->get_next()))
         break;
-      if (!error)
+      if (!error && sort_form->vfield)
         update_virtual_fields(thd, sort_form);
       file->position(sort_form->record[0]);
       DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE););
     }
     else					/* Not quick-select */
     {
-      if (indexfile)
-      {
-	if (my_b_read(indexfile,(uchar*) ref_pos,ref_length)) /* purecov: deadcode */
-	{
-	  error= my_errno ? my_errno : -1;		/* Abort */
-	  break;
-	}
-	error=file->ha_rnd_pos(sort_form->record[0],next_pos);
-      }
-      else
-      {
-	error=file->ha_rnd_next(sort_form->record[0]);
-	if (!error)
+      {
+	error= file->ha_rnd_next(sort_form->record[0]);
+	if (!error && sort_form->vfield)
 	  update_virtual_fields(thd, sort_form);
 	if (!flag)
 	{
@@ -625,7 +589,7 @@
     if (*killed)
     {
       DBUG_PRINT("info",("Sort killed by user"));
-      if (!indexfile && !quick_select)
+      if (!quick_select)
       {
         (void) file->extra(HA_EXTRA_NO_CACHE);
         file->ha_rnd_end();
@@ -669,12 +633,16 @@
     {
       if (idx == param->keys)
       {
-	if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
+	if (write_keys(param, sort_keys,
+                       idx, buffpek_pointers, tempfile))
 	  DBUG_RETURN(HA_POS_ERROR);
-	idx=0;
+	idx= 0;
+        next_sort_key= sort_keys_buf;
 	indexpos++;
       }
-      make_sortkey(param,sort_keys[idx++],ref_pos);
+      sort_keys[idx++]= next_sort_key;
+      make_sortkey(param, next_sort_key, ref_pos);
+      next_sort_key+= param->rec_length;
     }
     else
       file->unlock_row();
@@ -699,15 +667,17 @@
   DBUG_PRINT("test",("error: %d  indexpos: %d",error,indexpos));
   if (error != HA_ERR_END_OF_FILE)
   {
-    file->print_error(error,MYF(ME_ERROR | ME_WAITTANG)); /* purecov: inspected */
+    file->print_error(error,MYF(ME_ERROR | ME_WAITTANG)); // purecov: inspected
     DBUG_RETURN(HA_POS_ERROR);			/* purecov: inspected */
   }
   if (indexpos && idx &&
-      write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
+      write_keys(param, sort_keys,
+                 idx, buffpek_pointers, tempfile))
     DBUG_RETURN(HA_POS_ERROR);			/* purecov: inspected */
-  DBUG_RETURN(my_b_inited(tempfile) ?
-	      (ha_rows) (my_b_tell(tempfile)/param->rec_length) :
-	      idx);
+  const ha_rows retval=
+    my_b_inited(tempfile) ?
+    (ha_rows) (my_b_tell(tempfile)/param->rec_length) : idx;
+  DBUG_RETURN(retval);
 } /* find_all_keys */
 
 
@@ -1310,8 +1280,9 @@
   {
     buffpek->base= strpos;
     buffpek->max_keys= maxcount;
-    strpos+= (uint) (error= (int) read_to_buffer(from_file, buffpek,
-                                                 rec_length));
+    strpos+=
+      (uint) (error= (int) read_to_buffer(from_file, buffpek, rec_length));
+
     if (error == -1)
       goto err;					/* purecov: inspected */
     buffpek->max_keys= buffpek->mem_count;	// If less data in buffers than expected

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2011-11-03 18:17:05 +0000
+++ b/sql/ha_ndbcluster.h	2012-03-27 23:04:46 +0000
@@ -1,8 +1,7 @@
 #ifndef HA_NDBCLUSTER_INCLUDED
 #define HA_NDBCLUSTER_INCLUDED
 
-/* Copyright (c) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc.
-   Use is subject to license terms.
+/* Copyright (c) 2000, 2010, 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

=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h	2011-06-30 15:46:53 +0000
+++ b/sql/ha_ndbcluster_binlog.h	2012-02-16 09:48:16 +0000
@@ -1,8 +1,7 @@
 #ifndef HA_NDBCLUSTER_BINLOG_INCLUDED
 #define HA_NDBCLUSTER_BINLOG_INCLUDED
 
-/* Copyright (c) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc.
-   Use is subject to license terms.
+/* Copyright (c) 2000, 2010, 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

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2012-02-15 17:08:08 +0000
+++ b/sql/ha_partition.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+  Copyright (c) 2005, 2012, Oracle and/or its affiliates.
 
   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
@@ -289,6 +289,7 @@
   m_is_sub_partitioned= 0;
   m_is_clone_of= NULL;
   m_clone_mem_root= NULL;
+  m_part_ids_sorted_by_num_of_records= NULL;
 
 #ifdef DONT_HAVE_TO_BE_INITALIZED
   m_start_key.flag= 0;
@@ -325,6 +326,7 @@
   }
   my_free(m_ordered_rec_buffer);
   m_ordered_rec_buffer= NULL;
+  my_free(m_part_ids_sorted_by_num_of_records);
 
   clear_handler_file();
 
@@ -1259,7 +1261,7 @@
   @retval FALSE Cannot be auto repaired
 */
 
-bool ha_partition::auto_repair() const
+bool ha_partition::auto_repair(int error) const
 {
   DBUG_ENTER("ha_partition::auto_repair");
 
@@ -1267,7 +1269,7 @@
     As long as we only support one storage engine per table,
     we can use the first partition for this function.
   */
-  DBUG_RETURN(m_file[0]->auto_repair());
+  DBUG_RETURN(m_file[0]->auto_repair(error));
 }
 
 
@@ -2741,6 +2743,16 @@
       m_start_key.key= (const uchar*)ptr;
     }
   }
+  if (!m_part_ids_sorted_by_num_of_records)
+  {
+    if (!(m_part_ids_sorted_by_num_of_records=
+            (uint32*) my_malloc(m_tot_parts * sizeof(uint32), MYF(MY_WME))))
+      DBUG_RETURN(error);
+    uint32 i;
+    /* Initialize it with all partition ids. */
+    for (i= 0; i < m_tot_parts; i++)
+      m_part_ids_sorted_by_num_of_records[i]= i;
+  }
 
   /* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */
   if (bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1, FALSE))
@@ -3670,27 +3682,23 @@
   uint num_parts= m_part_info->num_parts;
   uint num_subparts= m_part_info->num_subparts;
   uint i= 0;
-  uint num_parts_set= alter_info->partition_names.elements;
-  uint num_parts_found= set_part_state(alter_info, m_part_info,
-                                        PART_ADMIN);
   DBUG_ENTER("ha_partition::truncate_partition");
 
   /* Only binlog when it starts any call to the partitions handlers */
   *binlog_stmt= false;
 
-  /*
-    TRUNCATE also means resetting auto_increment. Hence, reset
-    it so that it will be initialized again at the next use.
-  */
-  lock_auto_increment();
-  table_share->ha_part_data->next_auto_inc_val= 0;
-  table_share->ha_part_data->auto_inc_initialized= FALSE;
-  unlock_auto_increment();
-
-  if (num_parts_set != num_parts_found &&
-      (!(alter_info->flags & ALTER_ALL_PARTITION)))
+  if (set_part_state(alter_info, m_part_info, PART_ADMIN))
     DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND);
 
+  /*
+    TRUNCATE also means resetting auto_increment. Hence, reset
+    it so that it will be initialized again at the next use.
+  */
+  lock_auto_increment();
+  table_share->ha_part_data->next_auto_inc_val= 0;
+  table_share->ha_part_data->auto_inc_initialized= FALSE;
+  unlock_auto_increment();
+
   *binlog_stmt= true;
 
   do
@@ -5318,6 +5326,24 @@
   and read_time calls
 */
 
+/**
+  Helper function for sorting according to number of rows in descending order.
+*/
+
+int ha_partition::compare_number_of_records(ha_partition *me,
+                                            const uint32 *a,
+                                            const uint32 *b)
+{
+  handler **file= me->m_file;
+  /* Note: sorting in descending order! */
+  if (file[*a]->stats.records > file[*b]->stats.records)
+    return -1;
+  if (file[*a]->stats.records < file[*b]->stats.records)
+    return 1;
+  return 0;
+}
+
+
 /*
   General method to gather info from handler
 
@@ -5562,6 +5588,15 @@
       }
       i++;
     } while (*(++file_array));
+    /*
+      Sort the array of part_ids by number of records in
+      in descending order.
+    */
+    my_qsort2((void*) m_part_ids_sorted_by_num_of_records,
+              m_tot_parts,
+              sizeof(uint32),
+              (qsort2_cmp) compare_number_of_records,
+              this);
 
     file= m_file[handler_instance];
     file->info(HA_STATUS_CONST | no_lock_flag);
@@ -6099,7 +6134,7 @@
     0                    Success
 
   DESCRIPTION
-    Called at end of each statement to reste buffers
+    Called at end of each statement to reset buffers
 */
 
 int ha_partition::reset(void)
@@ -6317,21 +6352,73 @@
   DBUG_RETURN(m_file[0]->keys_to_use_for_scanning());
 }
 
-#define MAX_PARTS_FOR_OPTIMIZER_CALLS 10
-/*
-  Prepare start variables for estimating optimizer costs.
-
-  @param[out] num_used_parts  Number of partitions after pruning.
-  @param[out] check_min_num   Number of partitions to call.
-  @param[out] first           first used partition.
-*/
-void ha_partition::partitions_optimizer_call_preparations(uint *first,
-                                                          uint *num_used_parts,
-                                                          uint *check_min_num)
-{
-  *first= bitmap_get_first_set(&(m_part_info->used_partitions));
-  *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-  *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
+
+/**
+  Minimum number of rows to base optimizer estimate on.
+*/
+
+ha_rows ha_partition::min_rows_for_estimate()
+{
+  uint i, max_used_partitions, tot_used_partitions;
+  DBUG_ENTER("ha_partition::min_rows_for_estimate");
+
+  tot_used_partitions= bitmap_bits_set(&m_part_info->used_partitions);
+  DBUG_ASSERT(tot_used_partitions);
+
+  /*
+    Allow O(log2(tot_partitions)) increase in number of used partitions.
+    This gives O(tot_rows/log2(tot_partitions)) rows to base the estimate on.
+    I.e when the total number of partitions doubles, allow one more
+    partition to be checked.
+  */
+  i= 2;
+  max_used_partitions= 1;
+  while (i < m_tot_parts)
+  {
+    max_used_partitions++;
+    i= i << 1;
+  }
+  if (max_used_partitions > tot_used_partitions)
+    max_used_partitions= tot_used_partitions;
+
+  /* stats.records is already updated by the info(HA_STATUS_VARIABLE) call. */
+  DBUG_PRINT("info", ("max_used_partitions: %u tot_rows: %lu",
+                      max_used_partitions,
+                      (ulong) stats.records));
+  DBUG_PRINT("info", ("tot_used_partitions: %u min_rows_to_check: %lu",
+                      tot_used_partitions,
+                      (ulong) stats.records * max_used_partitions
+                              / tot_used_partitions));
+  DBUG_RETURN(stats.records * max_used_partitions / tot_used_partitions);
+}
+
+
+/**
+  Get the biggest used partition.
+
+  Starting at the N:th biggest partition and skips all non used
+  partitions, returning the biggest used partition found
+
+  @param[in,out] part_index  Skip the *part_index biggest partitions
+
+  @return The biggest used partition with index not lower than *part_index.
+    @retval NO_CURRENT_PART_ID     No more partition used.
+    @retval != NO_CURRENT_PART_ID  partition id of biggest used partition with
+                                   index >= *part_index supplied. Note that
+                                   *part_index will be updated to the next
+                                   partition index to use.
+*/
+
+uint ha_partition::get_biggest_used_partition(uint *part_index)
+{
+  uint part_id;
+  while ((*part_index) < m_tot_parts)
+  {
+    part_id= m_part_ids_sorted_by_num_of_records[(*part_index)++];
+    if (bitmap_is_set(&m_part_info->used_partitions, part_id))
+      return part_id;
+  }
+  return NO_CURRENT_PART_ID;
 }
 
 
@@ -6347,115 +6434,107 @@
 
 double ha_partition::scan_time()
 {
-  double scan_time= 0.0;
-  uint first, part_id, num_used_parts, check_min_num, partitions_called= 0;
+  double scan_time= 0;
+  handler **file;
   DBUG_ENTER("ha_partition::scan_time");
 
-  partitions_optimizer_call_preparations(&first, &num_used_parts, &check_min_num);
-  for (part_id= first; partitions_called < num_used_parts ; part_id++)
-  {
-    if (!bitmap_is_set(&(m_part_info->used_partitions), part_id))
-      continue;
-    scan_time+= m_file[part_id]->scan_time();
-    partitions_called++;
-    if (partitions_called >= check_min_num && scan_time != 0.0)
-    {
-      DBUG_RETURN(scan_time *
-                      (double) num_used_parts / (double) partitions_called);
-    }
-  }
+  for (file= m_file; *file; file++)
+    if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+      scan_time+= (*file)->scan_time();
   DBUG_RETURN(scan_time);
 }
 
 
-/*
-  Estimate rows for records_in_range or estimate_rows_upper_bound.
-
-  @param is_records_in_range  call records_in_range instead of
-                              estimate_rows_upper_bound.
-  @param inx                  (only for records_in_range) index to use.
-  @param min_key              (only for records_in_range) start of range.
-  @param max_key              (only for records_in_range) end of range.
-
-  @return Number of rows or HA_POS_ERROR.
+/**
+  Find number of records in a range.
+  @param inx      Index number
+  @param min_key  Start of range
+  @param max_key  End of range
+
+  @return Number of rows in range.
+
+  Given a starting key, and an ending key estimate the number of rows that
+  will exist between the two. max_key may be empty which in case determine
+  if start_key matches any rows.
 */
-ha_rows ha_partition::estimate_rows(bool is_records_in_range, uint inx,
-                                    key_range *min_key, key_range *max_key)
+
+ha_rows ha_partition::records_in_range(uint inx, key_range *min_key,
+				       key_range *max_key)
 {
-  ha_rows rows, estimated_rows= 0;
-  uint first, part_id, num_used_parts, check_min_num, partitions_called= 0;
+  ha_rows min_rows_to_check, rows, estimated_rows=0, checked_rows= 0;
+  uint partition_index= 0, part_id;
   DBUG_ENTER("ha_partition::records_in_range");
 
-  partitions_optimizer_call_preparations(&first, &num_used_parts, &check_min_num);
-  for (part_id= first; partitions_called < num_used_parts ; part_id++)
+  min_rows_to_check= min_rows_for_estimate();
+
+  while ((part_id= get_biggest_used_partition(&partition_index))
+         != NO_CURRENT_PART_ID)
   {
-    if (!bitmap_is_set(&(m_part_info->used_partitions), part_id))
-      continue;
-    if (is_records_in_range)
-      rows= m_file[part_id]->records_in_range(inx, min_key, max_key);
-    else
-      rows= m_file[part_id]->estimate_rows_upper_bound();
+    rows= m_file[part_id]->records_in_range(inx, min_key, max_key);
+      
+    DBUG_PRINT("info", ("part %u match %lu rows of %lu", part_id, (ulong) rows,
+                        (ulong) m_file[part_id]->stats.records));
+
     if (rows == HA_POS_ERROR)
       DBUG_RETURN(HA_POS_ERROR);
     estimated_rows+= rows;
-    partitions_called++;
-    if (partitions_called >= check_min_num && estimated_rows)
+    checked_rows+= m_file[part_id]->stats.records;
+    /*
+      Returning 0 means no rows can be found, so we must continue
+      this loop as long as we have estimated_rows == 0.
+      Also many engines return 1 to indicate that there may exist
+      a matching row, we do not normalize this by dividing by number of
+      used partitions, but leave it to be returned as a sum, which will
+      reflect that we will need to scan each partition's index.
+
+      Note that this statistics may not always be correct, so we must
+      continue even if the current partition has 0 rows, since we might have
+      deleted rows from the current partition, or inserted to the next
+      partition.
+    */
+    if (estimated_rows && checked_rows &&
+        checked_rows >= min_rows_to_check)
     {
-      DBUG_RETURN(estimated_rows * num_used_parts / partitions_called);
+      DBUG_PRINT("info",
+                 ("records_in_range(inx %u): %lu (%lu * %lu / %lu)",
+                  inx,
+                  (ulong) (estimated_rows * stats.records / checked_rows),
+                  (ulong) estimated_rows,
+                  (ulong) stats.records,
+                  (ulong) checked_rows));
+      DBUG_RETURN(estimated_rows * stats.records / checked_rows);
     }
   }
+  DBUG_PRINT("info", ("records_in_range(inx %u): %lu",
+                      inx,
+                      (ulong) estimated_rows));
   DBUG_RETURN(estimated_rows);
 }
 
 
-/*
-  Find number of records in a range
-
-  SYNOPSIS
-    records_in_range()
-    inx                  Index number
-    min_key              Start of range
-    max_key              End of range
-
-  RETURN VALUE
-    Number of rows in range
-
-  DESCRIPTION
-    Given a starting key, and an ending key estimate the number of rows that
-    will exist between the two. end_key may be empty which in case determine
-    if start_key matches any rows.
-
-    Called from opt_range.cc by check_quick_keys().
-
-    monty: MUST be called for each range and added.
-          Note that MySQL will assume that if this returns 0 there is no
-          matching rows for the range!
-*/
-
-ha_rows ha_partition::records_in_range(uint inx, key_range *min_key,
-				       key_range *max_key)
-{
-  DBUG_ENTER("ha_partition::records_in_range");
-
-  DBUG_RETURN(estimate_rows(TRUE, inx, min_key, max_key));
-}
-
-
-/*
-  Estimate upper bound of number of rows
-
-  SYNOPSIS
-    estimate_rows_upper_bound()
-
-  RETURN VALUE
-    Number of rows
+/**
+  Estimate upper bound of number of rows.
+
+  @return Number of rows.
 */
 
 ha_rows ha_partition::estimate_rows_upper_bound()
 {
+  ha_rows rows, tot_rows= 0;
+  handler **file= m_file;
   DBUG_ENTER("ha_partition::estimate_rows_upper_bound");
 
-  DBUG_RETURN(estimate_rows(FALSE, 0, NULL, NULL));
+  do
+  {
+    if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+    {
+      rows= (*file)->estimate_rows_upper_bound();
+      if (rows == HA_POS_ERROR)
+        DBUG_RETURN(HA_POS_ERROR);
+      tot_rows+= rows;
+    }
+  } while (*(++file));
+  DBUG_RETURN(tot_rows);
 }
 
 

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2012-01-13 14:50:02 +0000
+++ b/sql/ha_partition.h	2012-04-10 06:28:13 +0000
@@ -2,7 +2,7 @@
 #define HA_PARTITION_INCLUDED
 
 /*
-   Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates.
 
   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
@@ -176,6 +176,12 @@
   ha_rows   m_bulk_inserted_rows;
   /** used for prediction of start_bulk_insert rows */
   enum_monotonicity_info m_part_func_monotonicity_info;
+  /** Sorted array of partition ids in descending order of number of rows. */
+  uint32 *m_part_ids_sorted_by_num_of_records;
+  /* Compare function for my_qsort2, for reversed order. */
+  static int compare_number_of_records(ha_partition *me,
+                                       const uint32 *a,
+                                       const uint32 *b);
 public:
   handler *clone(const char *name, MEM_ROOT *mem_root);
   virtual void set_part_info(partition_info *part_info)
@@ -196,9 +202,9 @@
   */
     ha_partition(handlerton *hton, TABLE_SHARE * table);
     ha_partition(handlerton *hton, partition_info * part_info);
-    ha_partition(handlerton *hton, TABLE_SHARE *share,
-                 partition_info *part_info_arg,
-                 ha_partition *clone_arg,
+    ha_partition(handlerton *hton, TABLE_SHARE *share,
+                 partition_info *part_info_arg,
+                 ha_partition *clone_arg,
                  MEM_ROOT *clone_mem_root_arg);
    ~ha_partition();
   /*
@@ -538,6 +544,20 @@
   virtual int extra(enum ha_extra_function operation);
   virtual int extra_opt(enum ha_extra_function operation, ulong cachesize);
   virtual int reset(void);
+  /*
+    Do not allow caching of partitioned tables, since we cannot return
+    a callback or engine_data that would work for a generic engine.
+  */
+  virtual my_bool register_query_cache_table(THD *thd, char *table_key,
+                                             uint key_length,
+                                             qc_engine_callback
+                                               *engine_callback,
+                                             ulonglong *engine_data)
+  {
+    *engine_callback= NULL;
+    *engine_data= 0;
+    return FALSE;
+  }
 
 private:
   static const uint NO_CURRENT_PART_ID;
@@ -567,15 +587,9 @@
   */
 
 private:
-  /*
-    Helper function to get the minimum number of partitions to use for
-    the optimizer hints/cost calls.
-  */
-  void partitions_optimizer_call_preparations(uint *num_used_parts,
-                                              uint *check_min_num,
-                                              uint *first);
-  ha_rows estimate_rows(bool is_records_in_range, uint inx,
-                        key_range *min_key, key_range *max_key);
+  /* Helper functions for optimizer hints. */
+  ha_rows min_rows_for_estimate();
+  uint get_biggest_used_partition(uint *part_index);
 public:
 
   /*
@@ -1085,7 +1099,7 @@
     virtual int check(THD* thd, HA_CHECK_OPT *check_opt);
     virtual int repair(THD* thd, HA_CHECK_OPT *check_opt);
     virtual bool check_and_repair(THD *thd);
-    virtual bool auto_repair() const;
+    virtual bool auto_repair(int error) const;
     virtual bool is_crashed() const;
 
     private:

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2012-03-02 23:03:20 +0000
+++ b/sql/handler.cc	2012-03-20 14:04:50 +0000
@@ -1185,7 +1185,7 @@
   }
 
 #ifdef WITH_ARIA_STORAGE_ENGINE
-    ha_maria::implicit_commit(thd, FALSE);
+    ha_maria::implicit_commit(thd, TRUE);
 #endif
 
   if (!ha_info)

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2012-03-07 15:38:47 +0000
+++ b/sql/handler.h	2012-04-02 10:33:16 +0000
@@ -2446,7 +2446,7 @@
 
   virtual uint checksum() const { return 0; }
   virtual bool is_crashed() const  { return 0; }
-  virtual bool auto_repair() const { return 0; }
+  virtual bool auto_repair(int error) const { return 0; }
 
   void update_global_table_stats();
   void update_global_index_stats();

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2012-03-09 07:06:59 +0000
+++ b/sql/item.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
    Copyright (c) 2010, 2012, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
@@ -1001,6 +1001,21 @@
 }
 
 
+void Item::set_name_for_rollback(THD *thd, const char *str, uint length,
+                                 CHARSET_INFO *cs)
+{
+  char *old_name, *new_name; 
+  old_name= name;
+  set_name(str, length, cs);
+  new_name= name;
+  if (old_name != new_name)
+  {
+    name= old_name;
+    thd->change_item_tree((Item **) &name, (Item *) new_name);
+  }
+}
+
+
 /**
   @details
   This function is called when:
@@ -2606,17 +2621,20 @@
 {
   if (new_parent == get_depended_from())
     depended_from= NULL;
-  Name_resolution_context *ctx= new Name_resolution_context();
-  ctx->outer_context= NULL; // We don't build a complete name resolver
-  ctx->table_list= NULL;    // We rely on first_name_resolution_table instead
-  ctx->select_lex= new_parent;
-  ctx->first_name_resolution_table= context->first_name_resolution_table;
-  ctx->last_name_resolution_table=  context->last_name_resolution_table;
-  ctx->error_processor=             context->error_processor;
-  ctx->error_processor_data=        context->error_processor_data;
-  ctx->resolve_in_select_list=      context->resolve_in_select_list;
-  ctx->security_ctx=                context->security_ctx;
-  this->context=ctx;
+  if (context)
+  {
+    Name_resolution_context *ctx= new Name_resolution_context();
+    ctx->outer_context= NULL; // We don't build a complete name resolver
+    ctx->table_list= NULL;    // We rely on first_name_resolution_table instead
+    ctx->select_lex= new_parent;
+    ctx->first_name_resolution_table= context->first_name_resolution_table;
+    ctx->last_name_resolution_table=  context->last_name_resolution_table;
+    ctx->error_processor=             context->error_processor;
+    ctx->error_processor_data=        context->error_processor_data;
+    ctx->resolve_in_select_list=      context->resolve_in_select_list;
+    ctx->security_ctx=                context->security_ctx;
+    this->context=ctx;
+  }
 }
 
 
@@ -3557,7 +3575,7 @@
     that binary log contains wrong statement 
 */
 
-const String *Item_param::query_val_str(String* str) const
+const String *Item_param::query_val_str(THD *thd, String* str) const
 {
   switch (state) {
   case INT_VALUE:
@@ -3595,7 +3613,8 @@
   case LONG_DATA_VALUE:
     {
       str->length(0);
-      append_query_string(value.cs_info.character_set_client, &str_value, str);
+      append_query_string(thd, value.cs_info.character_set_client, &str_value,
+                          str);
       break;
     }
   case NULL_VALUE:
@@ -3728,7 +3747,7 @@
     char buffer[STRING_BUFFER_USUAL_SIZE];
     String tmp(buffer, sizeof(buffer), &my_charset_bin);
     const String *res;
-    res= query_val_str(&tmp);
+    res= query_val_str(current_thd, &tmp);
     str->append(*res);
   }
 }

=== modified file 'sql/item.h'
--- a/sql/item.h	2012-03-01 22:22:22 +0000
+++ b/sql/item.h	2012-04-10 06:28:13 +0000
@@ -656,6 +656,8 @@
 #endif
   }		/*lint -e1509 */
   void set_name(const char *str, uint length, CHARSET_INFO *cs);
+  void set_name_for_rollback(THD *thd, const char *str, uint length,
+                             CHARSET_INFO *cs);
   void rename(char *new_name);
   void init_make_field(Send_field *tmp_field,enum enum_field_types type);
   virtual void cleanup();
@@ -2258,7 +2260,7 @@
   */
   void (*set_param_func)(Item_param *param, uchar **pos, ulong len);
 
-  const String *query_val_str(String *str) const;
+  const String *query_val_str(THD *thd, String *str) const;
 
   bool convert_str_value(THD *thd);
 

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2012-03-09 07:06:59 +0000
+++ b/sql/item_cmpfunc.cc	2012-03-28 18:25:31 +0000
@@ -5463,7 +5463,7 @@
 */
 
 Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item)
-  : Item_bool_func(), eval_item(0), cond_false(0)
+  : Item_bool_func(), eval_item(0), cond_false(0), context_field(NULL)
 {
   const_item_cache= 0;
   with_const= with_const_item;
@@ -5486,7 +5486,7 @@
 */
 
 Item_equal::Item_equal(Item_equal *item_equal)
-  : Item_bool_func(), eval_item(0), cond_false(0)
+  : Item_bool_func(), eval_item(0), cond_false(0), context_field(NULL)
 {
   const_item_cache= 0;
   List_iterator_fast<Item> li(item_equal->equal_items);

=== modified file 'sql/item_cmpfunc.h'
--- a/sql/item_cmpfunc.h	2012-02-15 17:08:08 +0000
+++ b/sql/item_cmpfunc.h	2012-04-10 06:28:13 +0000
@@ -1,7 +1,7 @@
 #ifndef ITEM_CMPFUNC_INCLUDED
 #define ITEM_CMPFUNC_INCLUDED
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
-   Copyright (c) 2009-2011, Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -249,7 +249,7 @@
   Item_in_optimizer(Item *a, Item_in_subselect *b):
     Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0), expr_cache(0),
     save_cache(0), result_for_null_param(UNKNOWN)
-  {}
+  { with_subselect= true; }
   bool fix_fields(THD *, Item **);
   bool fix_left(THD *thd, Item **ref);
   bool is_null();
@@ -1693,9 +1693,16 @@
     as datetimes. The comparator is used only if compare_as_dates=TRUE
   */
   Arg_comparator cmp;
+ 
+  /*
+    For Item_equal objects inside an OR clause: one of the fields that were
+    used in the original equality.
+  */
+  Item_field *context_field;
 public:
   inline Item_equal()
-    : Item_bool_func(), with_const(FALSE), eval_item(0), cond_false(0)
+    : Item_bool_func(), with_const(FALSE), eval_item(0), cond_false(0),
+      context_field(NULL)
   { const_item_cache=0 ;}
   Item_equal(Item *f1, Item *f2, bool with_const_item);
   Item_equal(Item_equal *item_equal);
@@ -1722,6 +1729,8 @@
   Item *transform(Item_transformer transformer, uchar *arg);
   virtual void print(String *str, enum_query_type query_type);
   CHARSET_INFO *compare_collation();
+
+  void set_context_field(Item_field *ctx_field) { context_field= ctx_field; }
   friend class Item_equal_fields_iterator;
   friend Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
                            Item_equal *item_equal);

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2012-01-16 19:16:35 +0000
+++ b/sql/item_func.cc	2012-03-26 10:33:49 +0000
@@ -6733,7 +6733,7 @@
   if (res)
     DBUG_RETURN(res);
 
-  if (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW)
+  if (thd->lex->is_view_context_analysis())
   {
     /*
       Here we check privileges of the stored routine only during view

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2012-03-17 08:26:58 +0000
+++ b/sql/item_subselect.cc	2012-04-10 06:28:13 +0000
@@ -2508,7 +2508,7 @@
     }
   }
 
-  if ((thd_arg->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
+  if (thd_arg->lex->is_view_context_analysis() &&
       left_expr && !left_expr->fixed &&
       left_expr->fix_fields(thd_arg, &left_expr))
     return TRUE;
@@ -2531,7 +2531,8 @@
 {
   Item_subselect::update_used_tables();
   left_expr->update_used_tables();
-  used_tables_cache |= left_expr->used_tables();
+  //used_tables_cache |= left_expr->used_tables();
+  used_tables_cache= Item_subselect::used_tables() | left_expr->used_tables();
 }
 
 

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2012-03-09 07:06:59 +0000
+++ b/sql/item_timefunc.cc	2012-04-07 13:58:46 +0000
@@ -1,6 +1,6 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2009-2011, Monty Program Ab
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -2435,7 +2435,7 @@
 
 bool Item_date_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
 {
-  if (get_arg0_date(ltime, TIME_FUZZY_DATE))
+  if (get_arg0_date(ltime, fuzzy_date & ~TIME_TIME_ONLY))
     return 1;
 
   ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
@@ -3145,7 +3145,7 @@
 
 bool Item_func_last_day::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
 {
-  if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
+  if (get_arg0_date(ltime, fuzzy_date) ||
       (ltime->month == 0))
     return (null_value=1);
   uint month_idx= ltime->month-1;

=== modified file 'sql/item_xmlfunc.cc'
--- a/sql/item_xmlfunc.cc	2012-01-13 14:50:02 +0000
+++ b/sql/item_xmlfunc.cc	2012-03-27 23:04:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2005, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2005, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/lock.cc'
--- a/sql/lock.cc	2012-02-24 13:37:00 +0000
+++ b/sql/lock.cc	2012-03-28 18:25:31 +0000
@@ -399,7 +399,7 @@
 {
   MYSQL_LOCK *sql_lock;
   if ((sql_lock= get_lock_data(thd, table, count, GET_LOCK_UNLOCK)))
-    mysql_unlock_tables(thd, sql_lock);
+    mysql_unlock_tables(thd, sql_lock, 1);
 }
 
 

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2012-02-21 19:51:56 +0000
+++ b/sql/log.cc	2012-04-10 06:28:13 +0000
@@ -3709,8 +3709,6 @@
   mysql_mutex_lock(&rli->log_space_lock);
   rli->relay_log.purge_logs(to_purge_if_included, included,
                             0, 0, &rli->log_space_total);
-  // Tell the I/O thread to take the relay_log_space_limit into account
-  rli->ignore_log_space_limit= 0;
   mysql_mutex_unlock(&rli->log_space_lock);
 
   /*

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2012-03-01 11:41:49 +0000
+++ b/sql/log_event.cc	2012-04-10 06:28:13 +0000
@@ -629,7 +629,7 @@
 */
 
 int
-append_query_string(CHARSET_INFO *csinfo,
+append_query_string(THD *thd, CHARSET_INFO *csinfo,
                     String const *from, String *to)
 {
   char *beg, *ptr;
@@ -644,9 +644,26 @@
   else
   {
     *ptr++= '\'';
-    ptr+= escape_string_for_mysql(csinfo, ptr, 0,
-                                  from->ptr(), from->length());
-    *ptr++='\'';
+    if (!(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES))
+    {
+      ptr+= escape_string_for_mysql(csinfo, ptr, 0,
+                                    from->ptr(), from->length());
+    }
+    else
+    {
+      const char *frm_str= from->ptr();
+
+      for (; frm_str < (from->ptr() + from->length()); frm_str++)
+      {
+        /* Using '' way to represent "'" */
+        if (*frm_str == '\'')
+          *ptr++= *frm_str;
+
+        *ptr++= *frm_str;
+      }
+    }
+
+    *ptr++= '\'';
   }
   to->length(orig_len + ptr - beg);
   return 0;

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2012-03-17 08:26:58 +0000
+++ b/sql/log_event.h	2012-04-10 06:28:13 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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
@@ -4261,7 +4260,7 @@
 };
 #endif
 
-int append_query_string(CHARSET_INFO *csinfo,
+int append_query_string(THD *thd, CHARSET_INFO *csinfo,
                         String const *from, String *to);
 
 bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,

=== added file 'sql/mem_root_array.h'
--- a/sql/mem_root_array.h	1970-01-01 00:00:00 +0000
+++ b/sql/mem_root_array.h	2012-03-29 13:07:54 +0000
@@ -0,0 +1,175 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+
+#ifndef MEM_ROOT_ARRAY_INCLUDED
+#define MEM_ROOT_ARRAY_INCLUDED
+
+#include <my_alloc.h>
+
+/**
+   A typesafe replacement for DYNAMIC_ARRAY.
+   We use MEM_ROOT for allocating storage, rather than the C++ heap.
+   The interface is chosen to be similar to std::vector.
+
+   @remark
+   Unlike DYNAMIC_ARRAY, elements are properly copied
+   (rather than memcpy()d) if the underlying array needs to be expanded.
+
+   @remark
+   Depending on has_trivial_destructor, we destroy objects which are
+   removed from the array (including when the array object itself is destroyed).
+
+   @remark
+   Note that MEM_ROOT has no facility for reusing free space,
+   so don't use this if multiple re-expansions are likely to happen.
+
+   @param Element_type The type of the elements of the container.
+          Elements must be copyable.
+   @param has_trivial_destructor If true, we don't destroy elements.
+          We could have used type traits to determine this.
+          __has_trivial_destructor is supported by some (but not all)
+          compilers we use.
+*/
+template<typename Element_type, bool has_trivial_destructor>
+class Mem_root_array
+{
+public:
+  Mem_root_array(MEM_ROOT *root)
+    : m_root(root), m_array(NULL), m_size(0), m_capacity(0)
+  {
+    DBUG_ASSERT(m_root != NULL);
+  }
+
+  ~Mem_root_array()
+  {
+    clear();
+  }
+
+  Element_type &at(size_t n)
+  {
+    DBUG_ASSERT(n < size());
+    return m_array[n];
+  }
+
+  const Element_type &at(size_t n) const
+  {
+    DBUG_ASSERT(n < size());
+    return m_array[n];
+  }
+
+  // Returns a pointer to the first element in the array.
+  Element_type *begin() { return &m_array[0]; }
+
+  // Returns a pointer to the past-the-end element in the array.
+  Element_type *end() { return &m_array[size()]; }
+
+  // Erases all of the elements. 
+  void clear()
+  {
+    if (!empty())
+      chop(0);
+  }
+
+  /*
+    Chops the tail off the array, erasing all tail elements.
+    @param pos Index of first element to erase.
+  */
+  void chop(const size_t pos)
+  {
+    DBUG_ASSERT(pos < m_size);
+    if (!has_trivial_destructor)
+    {
+      for (size_t ix= pos; ix < m_size; ++ix)
+      {
+        Element_type *p= &m_array[ix];
+        p->~Element_type();              // Destroy discarded element.
+      }
+    }
+    m_size= pos;
+  }
+
+  /*
+    Reserves space for array elements.
+    Copies over existing elements, in case we are re-expanding the array.
+
+    @param  n number of elements.
+    @retval true if out-of-memory, false otherwise.
+  */
+  bool reserve(size_t n)
+  {
+    if (n <= m_capacity)
+      return false;
+
+    void *mem= alloc_root(m_root, n * element_size());
+    if (!mem)
+      return true;
+    Element_type *array= static_cast<Element_type*>(mem);
+
+    // Copy all the existing elements into the new array.
+    for (size_t ix= 0; ix < m_size; ++ix)
+    {
+      Element_type *new_p= &array[ix];
+      Element_type *old_p= &m_array[ix];
+      new (new_p) Element_type(*old_p);         // Copy into new location.
+      if (!has_trivial_destructor)
+        old_p->~Element_type();                 // Destroy the old element.
+    }
+
+    // Forget the old array.
+    m_array= array;
+    m_capacity= n;
+    return false;
+  }
+
+  /*
+    Adds a new element at the end of the array, after its current last
+    element. The content of this new element is initialized to a copy of
+    the input argument.
+
+    @param  element Object to copy.
+    @retval true if out-of-memory, false otherwise.
+  */
+  bool push_back(const Element_type &element)
+  {
+    const size_t min_capacity= 20;
+    const size_t expansion_factor= 2;
+    if (0 == m_capacity && reserve(min_capacity))
+      return true;
+    if (m_size == m_capacity && reserve(m_capacity * expansion_factor))
+      return true;
+    Element_type *p= &m_array[m_size++];
+    new (p) Element_type(element);
+    return false;
+  }
+
+  size_t capacity()     const { return m_capacity; }
+  size_t element_size() const { return sizeof(Element_type); }
+  bool   empty()        const { return size() == 0; }
+  size_t size()         const { return m_size; }
+
+private:
+  MEM_ROOT *const m_root;
+  Element_type   *m_array;
+  size_t          m_size;
+  size_t          m_capacity;
+
+  // Not (yet) implemented.
+  Mem_root_array(const Mem_root_array&);
+  Mem_root_array &operator=(const Mem_root_array&);
+};
+
+
+#endif  // MEM_ROOT_ARRAY_INCLUDED

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2012-04-12 00:14:06 +0000
+++ b/sql/mysqld.cc	2012-04-12 03:44:52 +0000
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2008-2012 Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2012, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -677,7 +677,7 @@
 File_parser_dummy_hook file_parser_dummy_hook;
 
 /* replication parameters, if master_host is not NULL, we are a slave */
-uint report_port= MYSQL_PORT;
+uint report_port= 0;
 ulong master_retry_count=0;
 char *master_info_file;
 char *relay_log_info_file, *report_user, *report_password, *report_host;
@@ -686,9 +686,8 @@
 
 /* Static variables */
 
+static volatile sig_atomic_t kill_in_progress;
 my_bool opt_stack_trace;
-static volatile sig_atomic_t kill_in_progress;
-
 my_bool opt_expect_abort= 0;
 static my_bool opt_bootstrap, opt_myisam_log;
 static int cleanup_done;
@@ -749,7 +748,6 @@
   key_LOCK_wakeup_ready;
 
 PSI_mutex_key key_LOCK_prepare_ordered, key_LOCK_commit_ordered;
-PSI_mutex_key key_LOCK_logger_service;
 
 static PSI_mutex_info all_server_mutexes[]=
 {
@@ -809,8 +807,6 @@
   { &key_LOCK_commit_ordered, "LOCK_commit_ordered", PSI_FLAG_GLOBAL},
   { &key_LOG_INFO_lock, "LOG_INFO::lock", 0},
   { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL},
-  { &key_LOCK_logger_service, "logger_service_file_st::lock",
-    PSI_FLAG_GLOBAL},
   { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0}
 };
 
@@ -2234,6 +2230,11 @@
 
   set_ports();
 
+  if (report_port == 0)
+  {
+    report_port= mysqld_port;
+  }
+  DBUG_ASSERT(report_port != 0);
   if (!opt_disable_networking && !opt_bootstrap)
   {
     if (mysqld_port)
@@ -2338,10 +2339,6 @@
 }
 
 
-#endif /*!EMBEDDED_LIBRARY*/
-
-
-#ifndef EMBEDDED_LIBRARY
 /**
   Close a connection.
 
@@ -2755,10 +2752,6 @@
 
 #endif /* __WIN__ */
 
-#ifdef HAVE_LINUXTHREADS
-#define UNSAFE_DEFAULT_LINUX_THREADS 200
-#endif
-
 
 #if BACKTRACE_DEMANGLE
 #include <cxxabi.h>
@@ -2768,13 +2761,84 @@
 }
 #endif
 
+
+/*
+  pthread_attr_setstacksize() without so much platform-dependency
+
+  Return: The actual stack size if possible.
+*/
+
+#ifndef EMBEDDED_LIBRARY
+static size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize)
+{
+  size_t guard_size __attribute__((unused))= 0;
+
+#if defined(__ia64__) || defined(__ia64)
+  /*
+    On IA64, half of the requested stack size is used for "normal stack"
+    and half for "register stack".  The space measured by check_stack_overrun
+    is the "normal stack", so double the request to make sure we have the
+    caller-expected amount of normal stack.
+
+    NOTE: there is no guarantee that the register stack can't grow faster
+    than normal stack, so it's very unclear that we won't dump core due to
+    stack overrun despite check_stack_overrun's efforts.  Experimentation
+    shows that in the execution_constants test, the register stack grows
+    less than half as fast as normal stack, but perhaps other scenarios are
+    less forgiving.  If it turns out that more space is needed for the
+    register stack, that could be forced (rather inefficiently) by using a
+    multiplier higher than 2 here.
+  */
+  stacksize *= 2;
+#endif
+
+  /*
+    On many machines, the "guard space" is subtracted from the requested
+    stack size, and that space is quite large on some platforms.  So add
+    it to our request, if we can find out what it is.
+  */
+#ifdef HAVE_PTHREAD_ATTR_GETGUARDSIZE
+  if (pthread_attr_getguardsize(attr, &guard_size))
+    guard_size = 0;		/* if can't find it out, treat as 0 */
+#endif
+
+  pthread_attr_setstacksize(attr, stacksize + guard_size);
+
+  /* Retrieve actual stack size if possible */
+#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
+  {
+    size_t real_stack_size= 0;
+    /* We must ignore real_stack_size = 0 as Solaris 2.9 can return 0 here */
+    if (pthread_attr_getstacksize(attr, &real_stack_size) == 0 &&
+	real_stack_size > guard_size)
+    {
+      real_stack_size -= guard_size;
+      if (real_stack_size < stacksize)
+      {
+	if (global_system_variables.log_warnings)
+          sql_print_warning("Asked for %zu thread stack, but got %zu",
+                            stacksize, real_stack_size);
+	stacksize= real_stack_size;
+      }
+    }
+  }
+#endif /* !EMBEDDED_LIBRARY */
+
+#if defined(__ia64__) || defined(__ia64)
+  stacksize /= 2;
+#endif
+  return stacksize;
+}
+#endif
+
+
 #if !defined(__WIN__)
 #ifndef SA_RESETHAND
 #define SA_RESETHAND 0
-#endif
+#endif /* SA_RESETHAND */
 #ifndef SA_NODEFER
 #define SA_NODEFER 0
-#endif
+#endif /* SA_NODEFER */
 
 #ifndef EMBEDDED_LIBRARY
 
@@ -2792,9 +2856,7 @@
     sigemptyset(&sa.sa_mask);
     sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
 
-#ifdef HAVE_STACKTRACE
     my_init_stacktrace();
-#endif
 #if defined(__amiga__)
     sa.sa_handler=(void(*)())handle_fatal_signal;
 #else
@@ -2866,15 +2928,7 @@
 #if !defined(HAVE_DEC_3_2_THREADS)
   pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
   (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
-#if defined(__ia64__) || defined(__ia64)
-  /*
-    Peculiar things with ia64 platforms - it seems we only have half the
-    stack size in reality, so we have to double it here
-  */
-  pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2);
-#else
-  pthread_attr_setstacksize(&thr_attr,my_thread_stack_size);
-#endif
+  (void) my_setstacksize(&thr_attr,my_thread_stack_size);
 #endif
 
   mysql_mutex_lock(&LOCK_thread_count);
@@ -4700,37 +4754,9 @@
     unireg_abort(1);				// Will do exit
 
   init_signals();
-#if defined(__ia64__) || defined(__ia64)
-  /*
-    Peculiar things with ia64 platforms - it seems we only have half the
-    stack size in reality, so we have to double it here
-  */
-  pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size*2);
-#else
-  pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
-#endif
-#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
-  {
-    /* Retrieve used stack size;  Needed for checking stack overflows */
-    size_t stack_size= 0;
-    pthread_attr_getstacksize(&connection_attrib, &stack_size);
-#if defined(__ia64__) || defined(__ia64)
-    stack_size/= 2;
-#endif
-    /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
-    if (stack_size && stack_size < my_thread_stack_size)
-    {
-      if (global_system_variables.log_warnings)
-	sql_print_warning("Asked for %llu thread stack, but got %zu",
-			  my_thread_stack_size, stack_size);
-#if defined(__ia64__) || defined(__ia64)
-      my_thread_stack_size= stack_size*2;
-#else
-      my_thread_stack_size= stack_size;
-#endif
-    }
-  }
-#endif
+
+  my_thread_stack_size= my_setstacksize(&connection_attrib,
+                                        my_thread_stack_size);
 
   (void) thr_setconcurrency(concurrency);	// 10 by default
 
@@ -5427,8 +5453,10 @@
   uint error_count=0;
   THD *thd;
   struct sockaddr_storage cAddr;
-  int ip_flags=0,socket_flags=0,flags=0,retval;
-  int extra_ip_flags=0;
+  int ip_flags __attribute__((unused))=0;
+  int socket_flags __attribute__((unused))= 0;
+  int extra_ip_flags __attribute__((unused))=0;
+  int flags=0,retval;
   st_vio *vio_tmp;
 #ifdef HAVE_POLL
   int socket_count= 0;
@@ -6018,17 +6046,6 @@
   {"help", '?', "Display this help and exit.", 
    &opt_help, &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
    0, 0},
-#ifdef DBUG_OFF
-  {"debug", '#', "Built in DBUG debugger. Disabled in this build.",
-   &current_dbug_option, &current_dbug_option, 0, GET_STR, OPT_ARG,
-   0, 0, 0, 0, 0, 0},
-#endif
-#ifdef HAVE_REPLICATION
-  {"debug-abort-slave-event-count", 0,
-   "Option used by mysql-test for debugging and testing of replication.",
-   &abort_slave_event_count,  &abort_slave_event_count,
-   0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#endif /* HAVE_REPLICATION */
   {"allow-suspicious-udfs", 0,
    "Allows use of UDFs consisting of only one symbol xxx() "
    "without corresponding xxx_init() or xxx_deinit(). That also means "
@@ -6097,30 +6114,86 @@
   /* default-storage-engine should have "MyISAM" as def_value. Instead
      of initializing it here it is done in init_common_variables() due
      to a compiler bug in Sun Studio compiler. */
+#ifdef DBUG_OFF
+  {"debug", '#', "Built in DBUG debugger. Disabled in this build.",
+   &current_dbug_option, &current_dbug_option, 0, GET_STR, OPT_ARG,
+   0, 0, 0, 0, 0, 0},
+#endif
+#ifdef HAVE_REPLICATION
+  {"debug-abort-slave-event-count", 0,
+   "Option used by mysql-test for debugging and testing of replication.",
+   &abort_slave_event_count,  &abort_slave_event_count,
+   0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif /* HAVE_REPLICATION */
+#ifndef DBUG_OFF
+  {"debug-assert-on-error", 0,
+   "Do an assert in various functions if we get a fatal error",
+   &my_assert_on_error, &my_assert_on_error,
+   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"debug-assert-if-crashed-table", 0,
+   "Do an assert in handler::print_error() if we get a crashed table",
+   &debug_assert_if_crashed_table, &debug_assert_if_crashed_table,
+   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+#ifdef HAVE_REPLICATION
+  {"debug-disconnect-slave-event-count", 0,
+   "Option used by mysql-test for debugging and testing of replication.",
+   &disconnect_slave_event_count, &disconnect_slave_event_count,
+   0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif /* HAVE_REPLICATION */
+  {"debug-exit-info", 'T', "Used for debugging. Use at your own risk.",
+   0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"debug-gdb", 0,
+   "Set up signals usable for debugging.",
+   &opt_debugging, &opt_debugging,
+   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_REPLICATION
+  {"debug-max-binlog-dump-events", 0,
+   "Option used by mysql-test for debugging and testing of replication.",
+   &max_binlog_dump_events, &max_binlog_dump_events, 0,
+   GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif /* HAVE_REPLICATION */
+#ifdef SAFE_MUTEX
+  {"debug-mutex-deadlock-detector", 0,
+   "Enable checking of wrong mutex usage.",
+   &safe_mutex_deadlock_detector,
+   &safe_mutex_deadlock_detector,
+   0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+#endif
+  {"debug-no-sync", 0,
+   "Disables system sync calls. Only for running tests or debugging!",
+   &my_disable_sync, &my_disable_sync, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+#ifdef HAVE_REPLICATION
+  {"debug-sporadic-binlog-dump-fail", 0,
+   "Option used by mysql-test for debugging and testing of replication.",
+   &opt_sporadic_binlog_dump_fail,
+   &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+   0},
+#endif /* HAVE_REPLICATION */
   {"default-storage-engine", 0, "The default storage engine for new tables",
    &default_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0 },
   {"default-time-zone", 0, "Set the default time zone.",
    &default_tz_name, &default_tz_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+#if defined(ENABLED_DEBUG_SYNC)
+  {"debug-sync-timeout", OPT_DEBUG_SYNC_TIMEOUT,
+   "Enable the debug sync facility "
+   "and optionally specify a default wait timeout in seconds. "
+   "A zero value keeps the facility disabled.",
+   &opt_debug_sync_timeout, 0,
+   0, GET_UINT, OPT_ARG, 0, 0, UINT_MAX, 0, 0, 0},
+#endif /* defined(ENABLED_DEBUG_SYNC) */
 #ifdef HAVE_OPENSSL
   {"des-key-file", 0,
    "Load keys for des_encrypt() and des_encrypt from given file.",
    &des_key_file, &des_key_file, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
 #endif /* HAVE_OPENSSL */
-#ifdef HAVE_REPLICATION
-  {"debug-disconnect-slave-event-count", 0,
-   "Option used by mysql-test for debugging and testing of replication.",
-   &disconnect_slave_event_count, &disconnect_slave_event_count,
-   0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#endif /* HAVE_REPLICATION */
 #ifdef HAVE_STACKTRACE
   {"stack-trace", 0 , "Print a symbolic stack trace on failure",
    &opt_stack_trace, &opt_stack_trace, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
 #endif /* HAVE_STACKTRACE */
-  {"debug-exit-info", 'T', "Used for debugging. Use at your own risk.", 0, 0, 0,
-   GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"external-locking", 0, "Use system (external) locking (disabled by "
    "default).  With this option enabled you can run myisamchk to test "
    "(not repair) tables while the MySQL server is running. Disable with "
@@ -6132,10 +6205,6 @@
    "Set up signals usable for debugging. Deprecated, use --debug-gdb instead.",
    &opt_debugging, &opt_debugging,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"debug-gdb", 0,
-   "Set up signals usable for debugging.",
-   &opt_debugging, &opt_debugging,
-   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_LARGE_PAGE_OPTION
   {"super-large-pages", 0, "Enable support for super large pages.",
    &opt_super_large_pages, &opt_super_large_pages, 0,
@@ -6226,10 +6295,6 @@
   {"init-rpl-role", 0, "Set the replication role.",
    &rpl_status, &rpl_status, &rpl_role_typelib,
    GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"debug-max-binlog-dump-events", 0,
-   "Option used by mysql-test for debugging and testing of replication.",
-   &max_binlog_dump_events, &max_binlog_dump_events, 0,
-   GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif /* HAVE_REPLICATION */
   {"memlock", 0, "Lock mysqld in memory.", &locked_in_memory,
    &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -6340,13 +6405,6 @@
    "(Default: 15000).", &slow_start_timeout, &slow_start_timeout, 0,
    GET_ULONG, REQUIRED_ARG, 15000, 0, 0, 0, 0, 0},
 #endif
-#ifdef HAVE_REPLICATION
-  {"debug-sporadic-binlog-dump-fail", 0,
-   "Option used by mysql-test for debugging and testing of replication.",
-   &opt_sporadic_binlog_dump_fail,
-   &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
-   0},
-#endif /* HAVE_REPLICATION */
 #ifdef HAVE_OPENSSL
   {"ssl", 0,
    "Enable SSL for connection (automatically enabled with other flags).",
@@ -6368,9 +6426,6 @@
      files.
    */
    IF_VALGRIND(0,IF_WIN(0,1)), 0, 0, 0, 0, 0},
-  {"debug-no-sync", 0,
-   "Disables system sync calls. Only for running tests or debugging!",
-   &my_disable_sync, &my_disable_sync, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
   {"sysdate-is-now", 0,
    "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. "
    "Since 5.0, SYSDATE() returns a `dynamic' value different for different "
@@ -6381,14 +6436,6 @@
    "Decision to use in heuristic recover process. Possible values are COMMIT "
    "or ROLLBACK.", &tc_heuristic_recover, &tc_heuristic_recover,
    &tc_heuristic_recover_typelib, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#if defined(ENABLED_DEBUG_SYNC)
-  {"debug-sync-timeout", OPT_DEBUG_SYNC_TIMEOUT,
-   "Enable the debug sync facility "
-   "and optionally specify a default wait timeout in seconds. "
-   "A zero value keeps the facility disabled.",
-   &opt_debug_sync_timeout, 0,
-   0, GET_UINT, OPT_ARG, 0, 0, UINT_MAX, 0, 0, 0},
-#endif /* defined(ENABLED_DEBUG_SYNC) */
   {"temp-pool", 0,
 #if (ENABLE_TEMP_POOL)
    "Using this option will cause most temporary files created to use a small "
@@ -6418,16 +6465,6 @@
   {"table_cache", 0, "Deprecated; use --table-open-cache instead.",
    &table_cache_size, &table_cache_size, 0, GET_ULONG,
    REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
-#ifndef DBUG_OFF
-  {"debug-assert-on-error", 0,
-   "Do an assert in various functions if we get a fatal error",
-   &my_assert_on_error, &my_assert_on_error,
-   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"debug-assert-if-crashed-table", 0,
-   "Do an assert in handler::print_error() if we get a crashed table",
-   &debug_assert_if_crashed_table, &debug_assert_if_crashed_table,
-   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-#endif
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 
@@ -7911,6 +7948,14 @@
   one_thread_scheduler(thread_scheduler);
   one_thread_scheduler(extra_thread_scheduler);
 #else
+
+#ifdef _WIN32
+  /* workaround: disable thread pool on XP */
+  if (GetProcAddress(GetModuleHandle("kernel32"),"CreateThreadpool") == 0 &&
+      thread_handling > SCHEDULER_NO_THREADS)
+    thread_handling = SCHEDULER_ONE_THREAD_PER_CONNECTION;
+#endif
+
   if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
     one_thread_per_connection_scheduler(thread_scheduler, &max_connections,
                                         &connection_count);

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2012-03-19 08:35:32 +0000
+++ b/sql/mysqld.h	2012-04-12 03:44:52 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2012, 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

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2012-04-12 00:14:06 +0000
+++ b/sql/opt_range.cc	2012-04-12 03:44:52 +0000
@@ -1396,7 +1396,7 @@
   for (SEL_TREE **tree = trees, **arg_tree= arg->trees; tree < trees_next; 
        tree++, arg_tree++)
   {
-    if (!(*tree= new SEL_TREE(*arg_tree, FALSE, param)))
+    if (!(*tree= new SEL_TREE(*arg_tree, TRUE, param)))
       goto mem_err;
   }
 

=== modified file 'sql/opt_subselect.cc'
--- a/sql/opt_subselect.cc	2012-03-01 22:22:22 +0000
+++ b/sql/opt_subselect.cc	2012-04-07 13:58:46 +0000
@@ -188,6 +188,252 @@
 
 */
 
+/*
+EqualityPropagationAndSjmNests
+******************************
+
+Equalities are used for:
+P1. Equality propagation 
+P2. Equality substitution [for a certain join order]
+
+The equality propagation is not affected by SJM nests. In fact, it is done 
+before we determine the execution plan, i.e. before we even know we will use
+SJM-nests for execution.
+
+The equality substitution is affected. 
+
+Substitution without SJMs
+=========================
+When one doesn't have SJM nests, tables have a strict join order:
+
+  ---------------------------------> 
+    t1 -- t2 -- t3 -- t4 --- t5 
+
+
+       ?  ^
+           \
+            --(part-of-WHERE)
+
+
+parts WHERE/ON and ref. expressions are attached at some point along the axis.
+Expression is allowed to refer to a table column if the table is to the left of
+the attachment point. For any given expression, we have a goal: 
+
+  "Move leftmost allowed attachment point as much as possible to the left"
+
+Substitution with SJMs - task setting
+=====================================
+
+When SJM nests are present, there is no global strict table ordering anymore:
+
+   
+  ---------------------------------> 
+
+    ot1 -- ot2 --- sjm -- ot4 --- ot5 
+                   |
+                   |                Main execution
+   - - - - - - - - - - - - - - - - - - - - - - - -                 
+                   |                 Materialization
+      it1 -- it2 --/    
+
+
+Besides that, we must take into account that
+ - values for outer table columns, otN.col, are inaccessible at
+   materialization step                                           (SJM-RULE)
+ - values for inner table columns, itN.col, are inaccessible at Main execution
+   step, except for SJ-Materialization-Scan and columns that are in the 
+   subquery's select list.                                        (SJM-RULE)
+
+Substitution with SJMs - solution
+=================================
+
+First, we introduce global strict table ordering like this:
+
+  ot1 - ot2 --\                    /--- ot3 -- ot5 
+               \--- it1 --- it2 --/
+
+Now, let's see how to meet (SJM-RULE).
+
+SJ-Materialization is only applicable for uncorrelated subqueries. From this, it
+follows that any multiple equality will either
+1. include only columns of outer tables, or
+2. include only columns of inner tables, or
+3. include columns of inner and outer tables, joined together through one 
+   of IN-equalities.
+
+Cases #1 and #2 can be handled in the same way as with regular inner joins.
+
+Case #3 requires special handling, so that we don't construct violations of
+(SJM-RULE). Let's consider possible ways to build violations.
+
+Equality propagation starts with the clause in this form
+
+   top_query_where AND subquery_where AND in_equalities
+
+First, it builds multi-equalities. It can also build a mixed multi-equality
+
+  multiple-equal(ot1.col, ot2.col, ... it1.col, itN.col) 
+
+Multi-equalities are pushed down the OR-clauses in top_query_where and in
+subquery_where, so it's possible that clauses like this one are built:
+
+   subquery_cond OR (multiple-equal(it1.col, ot1.col,...) AND ...)
+   ^^^^^^^^^^^^^                                 \
+         |                                        this must be evaluated
+         \- can only be evaluated                 at the main phase.
+            at the materialization phase
+
+Finally, equality substitution is started. It does two operations:
+
+
+1. Field reference substitution 
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+(In the code, this is Item_field::replace_equal_field)
+
+This is a process of replacing each reference to "tblX.col" 
+with the first element of the multi-equality.          (REF-SUBST-ORIG)
+
+This behaviour can cause problems with Semi-join nests. Suppose, we have a
+condition: 
+
+  func(it1.col, it2.col)
+
+and a multi-equality(ot1.col, it1.col). Then, reference to "it1.col" will be 
+replaced with "ot1.col", constructing a condition
+   
+   func(ot1.col, it2.col)
+
+which will be a violation of (SJM-RULE).
+
+In order to avoid this, (REF-SUBST-ORIG) is amended as follows: 
+
+- references to tables "itX.col" that are inner wrt some SJM nest, are
+  replaced with references to the first inner table from the same SJM nest.
+
+- references to top-level tables "otX.col" are replaced with references to
+  the first element of the multi-equality, no matter if that first element is
+  a column of a top-level table or of table from some SJM nest.
+                                                              (REF-SUBST-SJM)
+
+  The case where the first element is a table from an SJM nest $SJM is ok, 
+  because it can be proven that $SJM uses SJ-Materialization-Scan, and 
+  "unpacks" correct column values to the first element during the main
+  execution phase.
+
+2. Item_equal elimination
+~~~~~~~~~~~~~~~~~~~~~~~~~
+(In the code: eliminate_item_equal) This is a process of taking 
+
+  multiple-equal(a,b,c,d,e)
+
+and replacing it with an equivalent expression which is an AND of pair-wise 
+equalities:
+
+  a=b AND a=c AND ...
+
+The equalities are picked such that for any given join prefix (t1,t2...) the
+subset of equalities that can be evaluated gives the most restrictive
+filtering. 
+
+Without SJM nests, it is sufficient to compare every multi-equality member
+with the first one:
+
+  elem1=elem2 AND elem1=elem3 AND elem1=elem4 ... 
+
+When SJM nests are present, we should take care not to construct equalities
+that violate the (SJM-RULE). This is achieved by generating separate sets of
+equalites for top-level tables and for inner tables. That is, for the join
+order 
+
+  ot1 - ot2 --\                    /--- ot3 -- ot5 
+               \--- it1 --- it2 --/
+
+we will generate
+   ot1.col=ot2.col
+   ot1.col=ot3.col
+   ot1.col=ot5.col
+   it2.col=it1.col
+
+
+2.1 The problem with Item_equals and ORs
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+As has been mentioned above, multiple equalities are pushed down into OR
+clauses, possibly building clauses like this:
+
+   func(it.col2) OR multiple-equal(it1.col1, it1.col2, ot1.col)      (1)
+
+where the first part of the clause has references to inner tables, while the
+second has references to the top-level tables, which is a violation of
+(SJM-RULE).
+
+AND-clauses of this kind do not create problems, because make_cond_for_table()
+will take them apart. OR-clauses will not be split. It is possible to
+split-out the part that's dependent on the inner table:
+
+   func(it.col2) OR it1.col1=it1.col2
+
+but this is a less-restrictive condition than condition (1). Current execution
+scheme will still try to generate the "remainder" condition:
+
+   func(it.col2) OR it1.col1=ot1.col
+
+which is a violation of (SJM-RULE).
+
+QQ: "ot1.col=it1.col" is checked at the upper level. Why was it not removed
+here?
+AA: because has a proper subset of conditions that are found on this level.
+    consider a join order of  ot, sjm(it)
+    and a condition
+      ot.col=it.col AND ( ot.col=it.col='foo' OR it.col2='bar')
+
+    we will produce: 
+       table ot:  nothing
+       table it:  ot.col=it.col AND (ot.col='foo' OR it.col2='bar')
+                                     ^^^^        ^^^^^^^^^^^^^^^^       
+                                      |          \ the problem is that 
+                                      |            this part condition didnt
+                                      |            receive a substitution
+                                      |
+                                      +--- it was correct to subst, 'ot' is 
+                                           the left-most.
+
+
+Does it make sense to push "inner=outer" down into ORs?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Yes. Consider the query:
+
+  select * from ot 
+  where ot.col in (select it.col from it where (it.col='foo' OR it.col='bar'))
+
+here, it may be useful to infer that 
+
+   (ot.col='foo' OR ot.col='bar')       (CASE-FOR-SUBST)
+
+and attach that condition to the table 'ot'.
+
+Possible solutions for Item_equals and ORs
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Solution #1
+~~~~~~~~~~~
+Let make_cond_for_table() chop analyze the OR clauses it has produced and
+discard them if they violate (SJM-RULE). This solution would allow to handle
+cases like (CASE-FOR-SUBST) at the expense of making semantics of
+make_cond_for_table() complicated.
+
+Solution #2
+~~~~~~~~~~~
+Before the equality propagation phase, none of the OR clauses violate the
+(SJM-RULE). This way, if we remember which tables the original equality
+referred to, we can only generate equalities that refer to the outer (or inner)
+tables. Note that this will disallow handling of cases like (CASE-FOR-SUBST).
+
+Currently, solution #2 is implemented.
+
+*/
+
 
 static
 bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
@@ -346,8 +592,8 @@
     TODO: for PS, make the whole block execute only on the first execution
   */
   Item_subselect *subselect;
-  if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) && // (1)
-      (subselect= parent_unit->item))                                    // (2)
+  if (!thd->lex->is_view_context_analysis() &&          // (1)
+      (subselect= parent_unit->item))                   // (2)
   {
     Item_in_subselect *in_subs= NULL;
     Item_allany_subselect *allany_subs= NULL;
@@ -1229,6 +1475,8 @@
   sj_nest->embedding= emb_tbl_nest;
   sj_nest->alias= (char*) "(sj-nest)";
   sj_nest->sj_subq_pred= subq_pred;
+  sj_nest->original_subq_pred_used_tables= subq_pred->used_tables() |
+                                           subq_pred->left_expr->used_tables();
   /* Nests do not participate in those 'chains', so: */
   /* sj_nest->next_leaf= sj_nest->next_local= sj_nest->next_global == NULL*/
   emb_join_list->push_back(sj_nest);
@@ -1267,7 +1515,10 @@
     (a theory: a next_local chain always starts with ::leaf_tables
      because view's tables are inserted after the view)
   */
-  for (tl= parent_lex->leaf_tables.head(); tl->next_local; tl= tl->next_local) ;
+  
+  for (tl= (TABLE_LIST*)(parent_lex->table_list.first); tl->next_local; tl= tl->next_local)
+  {}
+
   tl->next_local= subq_lex->leaf_tables.head();
 
   /* A theory: no need to re-connect the next_global chain */
@@ -1480,7 +1731,7 @@
     (a theory: a next_local chain always starts with ::leaf_tables
      because view's tables are inserted after the view)
   */
-  for (tl= parent_lex->leaf_tables.head(); tl->next_local; tl= tl->next_local)
+  for (tl= (TABLE_LIST*)(parent_lex->table_list.first); tl->next_local; tl= tl->next_local)
   {}
   tl->next_local= jtbm;
 
@@ -2670,6 +2921,8 @@
       }
     }
   }
+  else
+    invalidate_firstmatch_prefix();
   return FALSE;
 }
 
@@ -3097,7 +3350,22 @@
                             record_count, join->best_positions + idx,
                             &loose_scan_pos);
            if (idx==first)
+           {
              join->best_positions[idx]= loose_scan_pos;
+             /*
+               If LooseScan is based on ref access (including the "degenerate"
+               one with 0 key parts), we should use full index scan.
+
+               Unfortunately, lots of code assumes that if tab->type==JT_ALL && 
+               tab->quick!=NULL, then quick select should be used. The only
+               simple way to fix this is to remove the quick select:
+             */
+             if (join->best_positions[idx].key)
+             {
+               delete join->best_positions[idx].table->quick;
+               join->best_positions[idx].table->quick= NULL;
+             }
+           }
         }
         rem_tables &= ~join->best_positions[idx].table->table->map;
         record_count *= join->best_positions[idx].records_read;
@@ -4950,7 +5218,6 @@
 
 bool JOIN::choose_subquery_plan(table_map join_tables)
 {
-  Join_plan_state save_qep; /* The original QEP of the subquery. */
   enum_reopt_result reopt_result= REOPT_NONE;
   Item_in_subselect *in_subs;
 
@@ -4969,12 +5236,16 @@
   }
   else
     return false;
+
   /* A strategy must be chosen earlier. */
   DBUG_ASSERT(in_subs->has_strategy());
   DBUG_ASSERT(in_to_exists_where || in_to_exists_having);
   DBUG_ASSERT(!in_to_exists_where || in_to_exists_where->fixed);
   DBUG_ASSERT(!in_to_exists_having || in_to_exists_having->fixed);
 
+  /* The original QEP of the subquery. */
+  Join_plan_state save_qep(table_count);
+
   /*
     Compute and compare the costs of materialization and in-exists if both
     strategies are possible and allowed by the user (checked during the prepare

=== modified file 'sql/password.c'
--- a/sql/password.c	2012-01-13 14:50:02 +0000
+++ b/sql/password.c	2012-04-07 13:58:46 +0000
@@ -503,7 +503,7 @@
   mysql_sha1_reset(&sha1_context);
   mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE);
   mysql_sha1_result(&sha1_context, hash_stage2_reassured);
-  return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE);
+  return test(memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE));
 }
 
 

=== modified file 'sql/protocol.cc'
--- a/sql/protocol.cc	2012-01-13 14:50:02 +0000
+++ b/sql/protocol.cc	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
-   Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/records.cc'
--- a/sql/records.cc	2012-03-17 08:26:58 +0000
+++ b/sql/records.cc	2012-03-24 17:21:22 +0000
@@ -344,7 +344,8 @@
       break;
     }
   }
-  update_virtual_fields(info->thd, info->table);
+  if (info->table->vfield)
+    update_virtual_fields(info->thd, info->table);
   return tmp;
 }
 
@@ -460,7 +461,7 @@
       break;
     }
   }
-  if (!tmp)
+  if (!tmp && info->table->vfield)
     update_virtual_fields(info->thd, info->table);
   return tmp;
 }

=== modified file 'sql/rpl_filter.cc'
--- a/sql/rpl_filter.cc	2012-01-13 14:50:02 +0000
+++ b/sql/rpl_filter.cc	2012-03-19 22:00:23 +0000
@@ -42,8 +42,8 @@
     free_string_array(&wild_do_table);
   if (wild_ignore_table_inited)
     free_string_array(&wild_ignore_table);
-  free_list(&do_db);
-  free_list(&ignore_db);
+  free_string_list(&do_db);
+  free_string_list(&ignore_db);
   free_list(&rewrite_db);
 }
 
@@ -263,6 +263,57 @@
 }
 
 
+/**
+  Parse and add the given comma-separated sequence of filter rules.
+
+  @param  spec  Comma-separated sequence of filter rules.
+  @param  add   Callback member function to add a filter rule.
+
+  @return true if error, false otherwise.
+*/
+
+int
+Rpl_filter::parse_filter_rule(const char* spec, Add_filter add)
+{
+  int status= 0;
+  char *arg, *ptr, *pstr;
+
+  if (! (ptr= my_strdup(spec, MYF(MY_WME))))
+    return true;
+
+  pstr= ptr;
+
+  while (pstr)
+  {
+    arg= pstr;
+
+    /* Parse token string. */
+    pstr= strpbrk(arg, ",");
+
+    /* NUL terminate the token string. */
+    if (pstr)
+      *pstr++= '\0';
+
+    /* Skip an empty token string. */
+    if (arg[0] == '\0')
+      continue;
+
+    /* Skip leading spaces.  */
+    while (my_isspace(system_charset_info, *arg))
+      arg++;
+
+    status= (this->*add)(arg);
+
+    if (status)
+      break;
+  }
+
+  my_free(ptr);
+
+  return status;
+}
+
+
 int 
 Rpl_filter::add_do_table(const char* table_spec) 
 {
@@ -285,6 +336,46 @@
 }
 
 
+int
+Rpl_filter::set_do_table(const char* table_spec)
+{
+  int status;
+
+  if (do_table_inited)
+    my_hash_reset(&do_table);
+
+  status= parse_filter_rule(table_spec, &Rpl_filter::add_do_table);
+
+  if (!do_table.records)
+  {
+    my_hash_free(&do_table);
+    do_table_inited= 0;
+  }
+
+  return status;
+}
+
+
+int
+Rpl_filter::set_ignore_table(const char* table_spec)
+{
+  int status;
+
+  if (ignore_table_inited)
+    my_hash_reset(&ignore_table);
+
+  status= parse_filter_rule(table_spec, &Rpl_filter::add_ignore_table);
+
+  if (!ignore_table.records)
+  {
+    my_hash_free(&ignore_table);
+    ignore_table_inited= 0;
+  }
+
+  return status;
+}
+
+
 int 
 Rpl_filter::add_wild_do_table(const char* table_spec)
 {
@@ -307,6 +398,46 @@
 }
 
 
+int
+Rpl_filter::set_wild_do_table(const char* table_spec)
+{
+  int status;
+
+  if (wild_do_table_inited)
+    free_string_array(&wild_do_table);
+
+  status= parse_filter_rule(table_spec, &Rpl_filter::add_wild_do_table);
+
+  if (!wild_do_table.elements)
+  {
+    delete_dynamic(&wild_do_table);
+    wild_do_table_inited= 0;
+  }
+
+  return status;
+}
+
+
+int
+Rpl_filter::set_wild_ignore_table(const char* table_spec)
+{
+  int status;
+
+  if (wild_ignore_table_inited)
+    free_string_array(&wild_ignore_table);
+
+  status= parse_filter_rule(table_spec, &Rpl_filter::add_wild_ignore_table);
+
+  if (!wild_ignore_table.elements)
+  {
+    delete_dynamic(&wild_ignore_table);
+    wild_ignore_table_inited= 0;
+  }
+
+  return status;
+}
+
+
 void
 Rpl_filter::add_db_rewrite(const char* from_db, const char* to_db)
 {
@@ -355,24 +486,58 @@
 }
 
 
-void
+int
+Rpl_filter::add_string_list(I_List<i_string> *list, const char* spec)
+{
+  char *str;
+  i_string *node;
+
+  if (! (str= my_strdup(spec, MYF(MY_WME))))
+    return true;
+
+  if (! (node= new i_string(str)))
+  {
+    my_free(str);
+    return true;
+  }
+
+  list->push_back(node);
+
+  return false;
+}
+
+
+int
 Rpl_filter::add_do_db(const char* table_spec)
 {
   DBUG_ENTER("Rpl_filter::add_do_db");
-  i_string *db = new i_string(table_spec);
-  do_db.push_back(db);
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(add_string_list(&do_db, table_spec));
 }
 
 
-void
+int
 Rpl_filter::add_ignore_db(const char* table_spec)
 {
   DBUG_ENTER("Rpl_filter::add_ignore_db");
-  i_string *db = new i_string(table_spec);
-  ignore_db.push_back(db);
-  DBUG_VOID_RETURN;
-}
+  DBUG_RETURN(add_string_list(&ignore_db, table_spec));
+}
+
+
+int
+Rpl_filter::set_do_db(const char* db_spec)
+{
+  free_string_list(&do_db);
+  return parse_filter_rule(db_spec, &Rpl_filter::add_do_db);
+}
+
+
+int
+Rpl_filter::set_ignore_db(const char* db_spec)
+{
+  free_string_list(&ignore_db);
+  return parse_filter_rule(db_spec, &Rpl_filter::add_ignore_db);
+}
+
 
 extern "C" uchar *get_table_key(const uchar *, size_t *, my_bool);
 extern "C" void free_table_ent(void* a);
@@ -448,6 +613,23 @@
 }
 
 
+void
+Rpl_filter::free_string_list(I_List<i_string> *l)
+{
+  void *ptr;
+  i_string *tmp;
+
+  while ((tmp= l->get()))
+  {
+    ptr= (void *) tmp->ptr;
+    my_free(ptr);
+    delete tmp;
+  }
+
+  l->empty();
+}
+
+
 /*
   Builds a String from a HASH of TABLE_RULE_ENT. Cannot be used for any other 
   hash, as it assumes that the hash entries are TABLE_RULE_ENT.
@@ -564,3 +746,37 @@
 {
   return &ignore_db;
 }
+
+
+void
+Rpl_filter::db_rule_ent_list_to_str(String* str, I_List<i_string>* list)
+{
+  I_List_iterator<i_string> it(*list);
+  i_string* s;
+
+  str->length(0);
+
+  while ((s= it++))
+  {
+    str->append(s->ptr);
+    str->append(',');
+  }
+
+  // Remove last ','
+  if (!str->is_empty())
+    str->chop();
+}
+
+
+void
+Rpl_filter::get_do_db(String* str)
+{
+  db_rule_ent_list_to_str(str, get_do_db());
+}
+
+
+void
+Rpl_filter::get_ignore_db(String* str)
+{
+  db_rule_ent_list_to_str(str, get_ignore_db());
+}

=== modified file 'sql/rpl_filter.h'
--- a/sql/rpl_filter.h	2011-11-03 18:17:05 +0000
+++ b/sql/rpl_filter.h	2012-03-19 22:00:23 +0000
@@ -61,11 +61,20 @@
   int add_do_table(const char* table_spec);
   int add_ignore_table(const char* table_spec);
 
+  int set_do_table(const char* table_spec);
+  int set_ignore_table(const char* table_spec);
+
   int add_wild_do_table(const char* table_spec);
   int add_wild_ignore_table(const char* table_spec);
 
-  void add_do_db(const char* db_spec);
-  void add_ignore_db(const char* db_spec);
+  int set_wild_do_table(const char* table_spec);
+  int set_wild_ignore_table(const char* table_spec);
+
+  int add_do_db(const char* db_spec);
+  int add_ignore_db(const char* db_spec);
+
+  int set_do_db(const char* db_spec);
+  int set_ignore_db(const char* db_spec);
 
   void add_db_rewrite(const char* from_db, const char* to_db);
 
@@ -83,6 +92,9 @@
   I_List<i_string>* get_do_db();
   I_List<i_string>* get_ignore_db();
 
+  void get_do_db(String* str);
+  void get_ignore_db(String* str);
+
 private:
   bool table_rules_on;
 
@@ -92,13 +104,21 @@
   int add_table_rule(HASH* h, const char* table_spec);
   int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec);
 
+  typedef int (Rpl_filter::*Add_filter)(char const*);
+
+  int parse_filter_rule(const char* spec, Add_filter func);
+
   void free_string_array(DYNAMIC_ARRAY *a);
+  void free_string_list(I_List<i_string> *l);
 
   void table_rule_ent_hash_to_str(String* s, HASH* h, bool inited);
   void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a,
                                            bool inited);
+  void db_rule_ent_list_to_str(String* s, I_List<i_string>* l);
   TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len);
 
+  int add_string_list(I_List<i_string> *list, const char* spec);
+
   /*
     Those 4 structures below are uninitialized memory unless the
     corresponding *_inited variables are "true".

=== modified file 'sql/rpl_handler.h'
--- a/sql/rpl_handler.h	2011-06-30 15:46:53 +0000
+++ b/sql/rpl_handler.h	2012-02-16 09:48:16 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 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

=== modified file 'sql/rpl_injector.cc'
--- a/sql/rpl_injector.cc	2012-01-16 19:16:35 +0000
+++ b/sql/rpl_injector.cc	2012-03-27 23:04:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2006, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2012-03-09 07:06:59 +0000
+++ b/sql/rpl_mi.cc	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2006, 2012, Oracle and/or its affiliates.
    Copyright (c) 2010, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify

=== modified file 'sql/rpl_mi.h'
--- a/sql/rpl_mi.h	2012-03-09 07:06:59 +0000
+++ b/sql/rpl_mi.h	2012-03-27 23:04:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2006, 2012, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2012-03-09 07:06:59 +0000
+++ b/sql/rpl_rli.cc	2012-03-27 23:04:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2006, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2006, 2012, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2012-03-09 07:06:59 +0000
+++ b/sql/rpl_rli.h	2012-04-10 06:28:13 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2005, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2005, 2012, Oracle and/or its affiliates.
 
    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
@@ -204,6 +203,13 @@
   bool ignore_log_space_limit;
 
   /*
+    Used by the SQL thread to instructs the IO thread to rotate 
+    the logs when the SQL thread needs to purge to release some
+    disk space.
+   */
+  bool sql_force_rotate_relay;
+
+  /*
     When it commits, InnoDB internally stores the master log position it has
     processed so far; the position to store is the one of the end of the
     committing event (the COMMIT query event, or the event if in autocommit

=== modified file 'sql/set_var.h'
--- a/sql/set_var.h	2012-03-01 11:41:49 +0000
+++ b/sql/set_var.h	2012-03-27 23:04:46 +0000
@@ -1,6 +1,6 @@
 #ifndef SET_VAR_INCLUDED
 #define SET_VAR_INCLUDED
-/* Copyright (c) 2002, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2002, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2012-03-11 22:45:18 +0000
+++ b/sql/share/errmsg-utf8.txt	2012-04-10 06:28:13 +0000
@@ -4701,14 +4701,14 @@
         spa "Esta versi??n de MariaDB no soporta todavia '%s'"
         swe "Denna version av MariaDB kan ??nnu inte utf??ra '%s'"
 ER_MASTER_FATAL_ERROR_READING_BINLOG  
-        nla "Kreeg fatale fout %d: '%-.512s' van master tijdens lezen van data uit binaire log"
-        eng "Got fatal error %d from master when reading data from binary log: '%-.512s'"
-        ger "Schwerer Fehler %d: '%-.512s vom Master beim Lesen des bin??ren Logs"
-        ita "Errore fatale %d: '%-.512s' dal master leggendo i dati dal log binario"
-        por "Obteve fatal erro %d: '%-.512s' do master quando lendo dados do binary log"
-        rus "???????????????? ???????????????????????? ???????????? %d: '%-.512s' ???? ?????????????????? ?????????????? ?? ???????????????? ?????????????? ???????????? ???? ?????????????????? ??????????????"
-        spa "Recibi?? fatal error %d: '%-.512s' del master cuando leyendo datos del binary log"
-        swe "Fick fatalt fel %d: '%-.512s' fr??n master vid l??sning av bin??rloggen"
+        nla "Kreeg fatale fout %d: '%-.320s' van master tijdens lezen van data uit binaire log"
+        eng "Got fatal error %d from master when reading data from binary log: '%-.320s'"
+        ger "Schwerer Fehler %d: '%-.320s vom Master beim Lesen des bin??ren Logs"
+        ita "Errore fatale %d: '%-.320s' dal master leggendo i dati dal log binario"
+        por "Obteve fatal erro %d: '%-.320s' do master quando lendo dados do binary log"
+        rus "???????????????? ???????????????????????? ???????????? %d: '%-.320s' ???? ?????????????????? ?????????????? ?? ???????????????? ?????????????? ???????????? ???? ?????????????????? ??????????????"
+        spa "Recibi?? fatal error %d: '%-.320s' del master cuando leyendo datos del binary log"
+        swe "Fick fatalt fel %d: '%-.320s' fr??n master vid l??sning av bin??rloggen"
 ER_SLAVE_IGNORED_TABLE  
         eng "Slave SQL thread ignored the query because of replicate-*-table rules"
         ger "Slave-SQL-Thread hat die Abfrage aufgrund von replicate-*-table-Regeln ignoriert"
@@ -6486,6 +6486,16 @@
 ER_PLUGIN_NO_INSTALL
   eng "Plugin '%s' is marked as not dynamically installable. You have to stop the server to install it."
 
+ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT
+  eng "Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave."
+
+ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC
+  eng "CREATE TABLE... SELECT...  on a table with an auto-increment column is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are inserted. This order cannot be predicted and may differ on master and the slave."
+
+#
+#  End of 5.5 error messages.
+#
+
 #
 # MariaDB error messages section starts here
 #

=== modified file 'sql/signal_handler.cc'
--- a/sql/signal_handler.cc	2012-03-17 08:26:58 +0000
+++ b/sql/signal_handler.cc	2012-04-10 06:28:13 +0000
@@ -77,7 +77,7 @@
   curr_time= my_time(0);
   localtime_r(&curr_time, &tm);
 
-  fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d ",
+  my_safe_printf_stderr("%02d%02d%02d %2d:%02d:%02d ",
                         tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
                         tm.tm_hour, tm.tm_min, tm.tm_sec);
   if (opt_expect_abort
@@ -139,6 +139,7 @@
     "Hope that's ok; if not, decrease some variables in the equation.\n\n");
 
 #if defined(HAVE_LINUXTHREADS)
+#define UNSAFE_DEFAULT_LINUX_THREADS 200
   if (sizeof(char*) == 4 && thread_count > UNSAFE_DEFAULT_LINUX_THREADS)
   {
     my_safe_printf_stderr(

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2012-03-09 07:06:59 +0000
+++ b/sql/slave.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1339,7 +1339,7 @@
                     const char act[]=
                       "now "
                       "wait_for signal.get_unix_timestamp";
-                    DBUG_ASSERT(opt_debug_sync_timeout > 0);
+                    DBUG_ASSERT(debug_sync_service);
                     DBUG_ASSERT(!debug_sync_set_action(current_thd,
                                                        STRING_WITH_LEN(act)));
                   };);
@@ -1389,7 +1389,7 @@
                     const char act[]=
                       "now "
                       "wait_for signal.get_server_id";
-                    DBUG_ASSERT(opt_debug_sync_timeout > 0);
+                    DBUG_ASSERT(debug_sync_service);
                     DBUG_ASSERT(!debug_sync_set_action(current_thd, 
                                                        STRING_WITH_LEN(act)));
                   };);
@@ -1788,6 +1788,54 @@
          !(slave_killed=io_slave_killed(thd,mi)) &&
          !rli->ignore_log_space_limit)
     mysql_cond_wait(&rli->log_space_cond, &rli->log_space_lock);
+
+  /* 
+    Makes the IO thread read only one event at a time
+    until the SQL thread is able to purge the relay 
+    logs, freeing some space.
+
+    Therefore, once the SQL thread processes this next 
+    event, it goes to sleep (no more events in the queue),
+    sets ignore_log_space_limit=true and wakes the IO thread. 
+    However, this event may have been enough already for 
+    the SQL thread to purge some log files, freeing 
+    rli->log_space_total .
+
+    This guarantees that the SQL and IO thread move
+    forward only one event at a time (to avoid deadlocks), 
+    when the relay space limit is reached. It also 
+    guarantees that when the SQL thread is prepared to
+    rotate (to be able to purge some logs), the IO thread
+    will know about it and will rotate.
+
+    NOTE: The ignore_log_space_limit is only set when the SQL
+          thread sleeps waiting for events.
+
+   */
+  if (rli->ignore_log_space_limit)
+  {
+#ifndef DBUG_OFF
+    {
+      char llbuf1[22], llbuf2[22];
+      DBUG_PRINT("info", ("log_space_limit=%s "
+                          "log_space_total=%s "
+                          "ignore_log_space_limit=%d "
+                          "sql_force_rotate_relay=%d", 
+                        llstr(rli->log_space_limit,llbuf1),
+                        llstr(rli->log_space_total,llbuf2),
+                        (int) rli->ignore_log_space_limit,
+                        (int) rli->sql_force_rotate_relay));
+    }
+#endif
+    if (rli->sql_force_rotate_relay)
+    {
+      rotate_relay_log(rli->mi);
+      rli->sql_force_rotate_relay= false;
+    }
+
+    rli->ignore_log_space_limit= false;
+  }
+
   thd->exit_cond(save_proc_info);
   DBUG_RETURN(slave_killed);
 }
@@ -3034,7 +3082,7 @@
                       const char act[]=
                         "now "
                         "wait_for signal.io_thread_let_running";
-                      DBUG_ASSERT(opt_debug_sync_timeout > 0);
+                      DBUG_ASSERT(debug_sync_service);
                       DBUG_ASSERT(!debug_sync_set_action(thd, 
                                                          STRING_WITH_LEN(act)));
                     };);
@@ -5058,19 +5106,45 @@
           constraint, because we do not want the I/O thread to block because of
           space (it's ok if it blocks for any other reason (e.g. because the
           master does not send anything). Then the I/O thread stops waiting
-          and reads more events.
-          The SQL thread decides when the I/O thread should take log_space_limit
-          into account again : ignore_log_space_limit is reset to 0
-          in purge_first_log (when the SQL thread purges the just-read relay
-          log), and also when the SQL thread starts. We should also reset
-          ignore_log_space_limit to 0 when the user does RESET SLAVE, but in
-          fact, no need as RESET SLAVE requires that the slave
+          and reads one more event and starts honoring log_space_limit again.
+
+          If the SQL thread needs more events to be able to rotate the log (it
+          might need to finish the current group first), then it can ask for one
+          more at a time. Thus we don't outgrow the relay log indefinitely,
+          but rather in a controlled manner, until the next rotate.
+
+          When the SQL thread starts it sets ignore_log_space_limit to false. 
+          We should also reset ignore_log_space_limit to 0 when the user does 
+          RESET SLAVE, but in fact, no need as RESET SLAVE requires that the slave
           be stopped, and the SQL thread sets ignore_log_space_limit to 0 when
           it stops.
         */
         mysql_mutex_lock(&rli->log_space_lock);
-        // prevent the I/O thread from blocking next times
-        rli->ignore_log_space_limit= 1;
+
+        /* 
+          If we have reached the limit of the relay space and we
+          are going to sleep, waiting for more events:
+
+          1. If outside a group, SQL thread asks the IO thread 
+             to force a rotation so that the SQL thread purges 
+             logs next time it processes an event (thus space is
+             freed).
+
+          2. If in a group, SQL thread asks the IO thread to 
+             ignore the limit and queues yet one more event 
+             so that the SQL thread finishes the group and 
+             is are able to rotate and purge sometime soon.
+         */
+        if (rli->log_space_limit && 
+            rli->log_space_limit < rli->log_space_total)
+        {
+          /* force rotation if not in an unfinished group */
+          rli->sql_force_rotate_relay= !rli->is_in_group();
+
+          /* ask for one more event */
+          rli->ignore_log_space_limit= true;
+        }
+
         /*
           If the I/O thread is blocked, unblock it.  Ok to broadcast
           after unlock, because the mutex is only destroyed in

=== modified file 'sql/sp_cache.cc'
--- a/sql/sp_cache.cc	2012-03-09 07:06:59 +0000
+++ b/sql/sp_cache.cc	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2002, 2012, 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

=== modified file 'sql/sp_cache.h'
--- a/sql/sp_cache.h	2012-03-09 07:06:59 +0000
+++ b/sql/sp_cache.h	2012-03-27 23:04:46 +0000
@@ -1,5 +1,5 @@
 /* -*- C++ -*- */
-/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2002, 2012, 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

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2012-01-16 19:16:35 +0000
+++ b/sql/sp_head.cc	2012-04-10 06:28:13 +0000
@@ -158,7 +158,7 @@
         buf.append(result->charset()->csname);
         if (cs->escape_with_backslash_is_dangerous)
           buf.append(' ');
-        append_query_string(cs, result, &buf);
+        append_query_string(thd, cs, result, &buf);
         buf.append(" COLLATE '");
         buf.append(item->collation.collation->name);
         buf.append('\'');
@@ -3557,6 +3557,23 @@
     m_optdest= sp->get_instr(m_dest);
   }
   sp->add_mark_lead(m_dest, leads);
+
+  /*
+    For continue handlers, all instructions in the scope of the handler
+    are possible leads. For example, the instruction after freturn might
+    be executed if the freturn triggers the condition handled by the
+    continue handler.
+
+    m_dest marks the start of the handler scope. It's added as a lead
+    above, so we start on m_dest+1 here.
+    m_opt_hpop is the hpop marking the end of the handler scope.
+  */
+  if (m_type == SP_HANDLER_CONTINUE)
+  {
+    for (uint scope_ip= m_dest+1; scope_ip <= m_opt_hpop; scope_ip++)
+      sp->add_mark_lead(scope_ip, leads);
+  }
+
   return m_ip+1;
 }
 

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2012-01-13 14:50:02 +0000
+++ b/sql/sp_head.h	2012-04-07 13:58:46 +0000
@@ -1017,7 +1017,7 @@
 public:
 
   sp_instr_hpush_jump(uint ip, sp_pcontext *ctx, int htype, uint fp)
-    : sp_instr_jump(ip, ctx), m_type(htype), m_frame(fp)
+    : sp_instr_jump(ip, ctx), m_type(htype), m_frame(fp), m_opt_hpop(0)
   {
     m_cond.empty();
   }
@@ -1039,6 +1039,15 @@
     return m_ip;
   }
 
+  virtual void backpatch(uint dest, sp_pcontext *dst_ctx)
+  {
+    DBUG_ASSERT(!m_dest || !m_opt_hpop);
+    if (!m_dest)
+      m_dest= dest;
+    else
+      m_opt_hpop= dest;
+  }
+
   inline void add_condition(struct sp_cond_type *cond)
   {
     m_cond.push_front(cond);
@@ -1048,6 +1057,7 @@
 
   int m_type;			///< Handler type
   uint m_frame;
+  uint m_opt_hpop;              // hpop marking end of handler scope.
   List<struct sp_cond_type> m_cond;
 
 }; // class sp_instr_hpush_jump : public sp_instr_jump

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2012-03-19 08:35:32 +0000
+++ b/sql/sql_admin.cc	2012-04-12 03:44:52 +0000
@@ -443,12 +443,7 @@
             my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
             DBUG_RETURN(TRUE);
           }
-          uint num_parts_found;
-          uint num_parts_opt= alter_info->partition_names.elements;
-          num_parts_found= set_part_state(alter_info, table->table->part_info,
-                                          PART_ADMIN);
-          if (num_parts_found != num_parts_opt &&
-              (!(alter_info->flags & ALTER_ALL_PARTITION)))
+          if (set_part_state(alter_info, table->table->part_info, PART_ADMIN))
           {
             char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
             size_t length;
@@ -910,6 +905,9 @@
   DBUG_RETURN(FALSE);
 
 err:
+  /* Make sure this table instance is not reused after the failure. */
+  if (table && table->table)
+    table->table->m_needs_reopen= true;
   trans_rollback_stmt(thd);
   trans_rollback(thd);
   close_thread_tables(thd);			// Shouldn't be needed

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2012-03-19 08:35:32 +0000
+++ b/sql/sql_base.cc	2012-04-12 03:44:52 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
    Copyright (c) 2010, 2011 Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
@@ -217,7 +217,8 @@
 static void free_cache_entry(TABLE *entry);
 static bool
 has_write_table_with_auto_increment(TABLE_LIST *tables);
-
+static bool
+has_write_table_with_auto_increment_and_select(TABLE_LIST *tables);
 
 uint cached_open_tables(void)
 {
@@ -520,7 +521,7 @@
 
 static void table_def_unuse_table(TABLE *table)
 {
-  THD *thd= table->in_use;
+  THD *thd __attribute__((unused))= table->in_use;
   DBUG_ASSERT(table->in_use);
 
   /* We shouldn't put the table to 'unused' list if the share is old. */
@@ -5736,9 +5737,20 @@
 	*(ptr++)= table->table;
     }
 
+    /*
+    DML statements that modify a table with an auto_increment column based on
+    rows selected from a table are unsafe as the order in which the rows are
+    fetched fron the select tables cannot be determined and may differ on
+    master and slave.
+    */
+    if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables &&
+        has_write_table_with_auto_increment_and_select(tables))
+      thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT);
+
     /* We have to emulate LOCK TABLES if we are statement needs prelocking. */
     if (thd->lex->requires_prelocking())
     {
+
       /*
         A query that modifies autoinc column in sub-statement can make the 
         master and slave inconsistent.
@@ -6157,15 +6169,22 @@
       */
       if (*ref && !(*ref)->is_autogenerated_name)
       {
-        if (register_tree_change &&
-            thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())
-          arena= thd->activate_stmt_arena_if_needed(&backup);
-        item->set_name((*ref)->name, (*ref)->name_length,
-                       system_charset_info);
-        item->real_item()->set_name((*ref)->name, (*ref)->name_length,
-                       system_charset_info);
-        if (arena)
-          thd->restore_active_arena(arena, &backup);
+        if (register_tree_change)
+	{
+          item->set_name_for_rollback(thd, (*ref)->name, 
+                                      (*ref)->name_length,
+                                      system_charset_info);
+          item->real_item()->set_name_for_rollback(thd, (*ref)->name,
+                                                   (*ref)->name_length,
+                                                   system_charset_info);
+        }
+        else
+	{
+          item->set_name((*ref)->name, (*ref)->name_length,
+                         system_charset_info);
+          item->real_item()->set_name((*ref)->name, (*ref)->name_length,
+                                      system_charset_info);
+        }
       }
       if (register_tree_change)
         thd->change_item_tree(ref, item);
@@ -7447,6 +7466,14 @@
   */
   result= FALSE;
 
+  /*
+    Save the lists made during natural join matching (because
+    the matching done only once but we need the list in case
+    of prepared statements).
+  */
+  table_ref_1->persistent_used_items= table_ref_1->used_items;
+  table_ref_2->persistent_used_items= table_ref_2->used_items;
+
 err:
   if (arena)
     thd->restore_active_arena(arena, &backup);
@@ -8810,14 +8837,9 @@
   }
   /* Update virtual fields*/
   thd->abort_on_warning= FALSE;
-  if (vcol_table)
-  {
-    if (vcol_table->vfield)
-    {
-      if (update_virtual_fields(thd, vcol_table, TRUE))
-        goto err;
-    }
-  }
+  if (vcol_table && vcol_table->vfield &&
+      update_virtual_fields(thd, vcol_table, TRUE))
+    goto err;
   thd->abort_on_warning= save_abort_on_warning;
   thd->no_errors=        save_no_errors;
   DBUG_RETURN(thd->is_error());
@@ -9418,6 +9440,41 @@
   return 0;
 }
 
+/*
+   checks if we have select tables in the table list and write tables
+   with auto-increment column.
+
+  SYNOPSIS
+   has_two_write_locked_tables_with_auto_increment_and_select
+      tables        Table list
+
+  RETURN VALUES
+
+   -true if the table list has atleast one table with auto-increment column
+
+
+         and atleast one table to select from.
+   -false otherwise
+*/
+
+static bool
+has_write_table_with_auto_increment_and_select(TABLE_LIST *tables)
+{
+  bool has_select= false;
+  bool has_auto_increment_tables = has_write_table_with_auto_increment(tables);
+  for(TABLE_LIST *table= tables; table; table= table->next_global)
+  {
+     if (!table->placeholder() &&
+        (table->lock_type <= TL_READ_NO_INSERT))
+      {
+        has_select= true;
+        break;
+      }
+  }
+  return(has_select && has_auto_increment_tables);
+}
+
+
 
 /*
   Open and lock system tables for read.

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2012-02-15 17:08:08 +0000
+++ b/sql/sql_cache.cc	2012-04-07 13:58:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2012-03-11 22:45:18 +0000
+++ b/sql/sql_class.cc	2012-04-07 13:58:46 +0000
@@ -142,9 +142,9 @@
 */
 
 Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root)
-  :Key(rhs),
+  :Key(rhs,mem_root),
   ref_table(rhs.ref_table),
-  ref_columns(rhs.ref_columns),
+  ref_columns(rhs.ref_columns,mem_root),
   delete_opt(rhs.delete_opt),
   update_opt(rhs.update_opt),
   match_opt(rhs.match_opt)
@@ -3735,6 +3735,9 @@
 
 extern "C" int thd_killed(const MYSQL_THD thd)
 {
+  if (!thd)
+    thd= current_thd;
+
   if (!(thd->killed & KILL_HARD_BIT))
     return 0;
   return thd->killed;

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2012-02-28 17:53:05 +0000
+++ b/sql/sql_connect.cc	2012-04-07 13:58:46 +0000
@@ -1,6 +1,6 @@
 /*
-   Copyright (c) 2007, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2008-2012 Monty Program Ab
+   Copyright (c) 2007, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2012, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2012-04-12 00:14:06 +0000
+++ b/sql/sql_delete.cc	2012-04-12 03:44:52 +0000
@@ -328,7 +328,8 @@
   while (!(error=info.read_record(&info)) && !thd->killed &&
 	 ! thd->is_error())
   {
-    update_virtual_fields(thd, table);
+    if (table->vfield)
+      update_virtual_fields(thd, table);
     thd->examined_row_count++;
     // thd->is_error() is tested to disallow delete row on error
     if (!select || select->skip_record(thd) > 0)

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2012-02-24 13:37:00 +0000
+++ b/sql/sql_handler.cc	2012-03-24 17:21:22 +0000
@@ -922,7 +922,8 @@
       goto ok;
     }
     /* Generate values for virtual fields */
-    update_virtual_fields(thd, table);
+    if (table->vfield)
+      update_virtual_fields(thd, table);
     if (cond && !cond->val_int())
     {
       if (thd->is_error())

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2012-04-12 00:14:06 +0000
+++ b/sql/sql_join_cache.cc	2012-04-12 03:44:52 +0000
@@ -3345,23 +3345,26 @@
   int skip_rc;
   READ_RECORD *info= &join_tab->read_record;
   SQL_SELECT *select= join_tab->cache_select;
+  TABLE *table= join_tab->table;
+  THD *thd= join->thd;
+
   if (is_first_record)
     is_first_record= FALSE;
   else
     err= info->read_record(info);
-  if (!err)
-    update_virtual_fields(join->thd, join_tab->table);
-  while (!err && select && (skip_rc= select->skip_record(join->thd)) <= 0)
+  if (!err && table->vfield)
+    update_virtual_fields(thd, table);
+  while (!err && select && (skip_rc= select->skip_record(thd)) <= 0)
   {
-    if (join->thd->killed || skip_rc < 0) 
+    if (thd->killed || skip_rc < 0) 
       return 1;
     /* 
       Move to the next record if the last retrieved record does not
       meet the condition pushed to the table join_tab.
     */
     err= info->read_record(info);
-    if (!err)
-      update_virtual_fields(join->thd, join_tab->table);
+    if (!err && table->vfield)
+      update_virtual_fields(thd, table);
   } 
   return err; 
 }
@@ -3875,7 +3878,8 @@
     */ 
     DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) &&
                 (uchar *) (*ptr) <= cache->end_pos);
-    update_virtual_fields(join->thd, join_tab->table);
+    if (join_tab->table->vfield)
+      update_virtual_fields(join->thd, join_tab->table);
   }
   return rc;
 }

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2012-03-11 22:45:18 +0000
+++ b/sql/sql_lex.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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
@@ -63,9 +62,11 @@
   ER_BINLOG_UNSAFE_MIXED_STATEMENT,
   ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT,
   ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE,
+  ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT,
   ER_BINLOG_UNSAFE_REPLACE_SELECT,
   ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT,
   ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT,
+  ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC,
   ER_BINLOG_UNSAFE_UPDATE_IGNORE
 };
 
@@ -470,6 +471,8 @@
   lex->select_lex.sql_cache= SELECT_LEX::SQL_CACHE_UNSPECIFIED;
   lex->select_lex.init_order();
   lex->select_lex.group_list.empty();
+  if (lex->select_lex.group_list_ptrs)
+    lex->select_lex.group_list_ptrs->clear();
   lex->describe= 0;
   lex->subqueries= FALSE;
   lex->context_analysis_only= 0;
@@ -1880,6 +1883,8 @@
   sj_nests.empty();
   sj_subselects.empty();
   group_list.empty();
+  if (group_list_ptrs)
+    group_list_ptrs->clear();
   type= db= 0;
   having= 0;
   table_join_options= 0;
@@ -3287,6 +3292,8 @@
     The passed WHERE and HAVING are to be saved for the future executions.
     This function saves it, and returns a copy which can be thrashed during
     this execution of the statement. By saving/thrashing here we mean only
+    We also save the chain of ORDER::next in group_list, in case
+    the list is modified by remove_const().
     AND/OR trees.
     The function also calls fix_prepare_info_in_table_list that saves all
     ON expressions.    
@@ -3298,6 +3305,19 @@
   if (!thd->stmt_arena->is_conventional() && first_execution)
   {
     first_execution= 0;
+    if (group_list.first)
+    {
+      if (!group_list_ptrs)
+      {
+        void *mem= thd->stmt_arena->alloc(sizeof(Group_list_ptrs));
+        group_list_ptrs= new (mem) Group_list_ptrs(thd->stmt_arena->mem_root);
+      }
+      group_list_ptrs->reserve(group_list.elements);
+      for (ORDER *order= group_list.first; order; order= order->next)
+      {
+        group_list_ptrs->push_back(order);
+      }
+    }
     if (*conds)
     {
       thd->check_and_register_item_tree(&prep_where, conds);
@@ -4186,3 +4206,7 @@
      BINLOG_DIRECT_OFF & TRX_CACHE_NOT_EMPTY);
 }
 #endif
+
+#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
+template class Mem_root_array<ORDER*, true>;
+#endif

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2012-03-11 22:45:18 +0000
+++ b/sql/sql_lex.h	2012-04-10 06:28:13 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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
@@ -25,6 +24,7 @@
 #include "sql_trigger.h"
 #include "item.h"               /* From item_subselect.h: subselect_union_engine */
 #include "thr_lock.h"                  /* thr_lock_type, TL_UNLOCK */
+#include "mem_root_array.h"
 
 /* YACC and LEX Definitions */
 
@@ -262,6 +262,7 @@
 #define TL_OPTION_ALIAS         8
 
 typedef List<Item> List_item;
+typedef Mem_root_array<ORDER*, true> Group_list_ptrs;
 
 /* SERVERS CACHE CHANGES */
 typedef struct st_lex_server_options
@@ -736,7 +737,16 @@
   enum olap_type olap;
   /* FROM clause - points to the beginning of the TABLE_LIST::next_local list. */
   SQL_I_List<TABLE_LIST>  table_list;
-  SQL_I_List<ORDER>       group_list; /* GROUP BY clause. */
+
+  /*
+    GROUP BY clause.
+    This list may be mutated during optimization (by remove_const()),
+    so for prepared statements, we keep a copy of the ORDER.next pointers in
+    group_list_ptrs, and re-establish the original list before each execution.
+  */
+  SQL_I_List<ORDER>       group_list;
+  Group_list_ptrs        *group_list_ptrs;
+
   List<Item>          item_list;  /* list of fields & expressions */
   List<String>        interval_list;
   bool	              is_item_list_lookup;
@@ -942,7 +952,8 @@
   bool test_limit();
 
   friend void lex_start(THD *thd);
-  st_select_lex() : n_sum_items(0), n_child_sum_items(0) {}
+  st_select_lex() : group_list_ptrs(NULL), n_sum_items(0), n_child_sum_items(0)
+  {}
   void make_empty_select()
   {
     init_query();
@@ -1374,6 +1385,13 @@
     BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE,
 
     /**
+     Query that writes to a table with auto_inc column after selecting from 
+     other tables are unsafe as the order in which the rows are retrieved by
+     select may differ on master and slave.
+    */
+    BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT,
+
+    /**
       INSERT...REPLACE SELECT is unsafe because which rows are replaced depends
       on the order that rows are retrieved by SELECT. This order cannot be
       predicted and may differ on master and the slave.
@@ -1395,6 +1413,14 @@
     BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT,
 
     /**
+      CREATE TABLE...SELECT on a table with auto-increment column is unsafe
+      because which rows are replaced depends on the order that rows are
+      retrieved from SELECT. This order cannot be predicted and may differ on
+      master and the slave
+    */
+    BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC,
+
+    /**
       UPDATE...IGNORE is unsafe because which rows are ignored depends on the
       order that rows are updated. This order cannot be predicted and may differ
       on master and the slave.

=== modified file 'sql/sql_list.h'
--- a/sql/sql_list.h	2012-02-21 19:51:56 +0000
+++ b/sql/sql_list.h	2012-04-07 13:58:46 +0000
@@ -260,6 +260,7 @@
       last= &first;
     return tmp->info;
   }
+
   /*
     Remove from this list elements that are contained in the passed list. 
     We assume that the passed list is a tail of this list (that is, the whole 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2012-03-11 22:45:18 +0000
+++ b/sql/sql_parse.cc	2012-04-10 06:28:13 +0000
@@ -1,6 +1,5 @@
-/*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2008-2012 Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2012, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -2935,7 +2934,7 @@
                       const char act2[]=
                         "now "
                         "signal signal.continued";
-                      DBUG_ASSERT(opt_debug_sync_timeout > 0);
+                      DBUG_ASSERT(debug_sync_service);
                       DBUG_ASSERT(!debug_sync_set_action(thd,
                                                          STRING_WITH_LEN(act1)));
                       DBUG_ASSERT(!debug_sync_set_action(thd,

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2012-01-17 08:11:20 +0000
+++ b/sql/sql_partition.cc	2012-03-27 23:04:46 +0000
@@ -4398,11 +4398,20 @@
 }
 
 
-/*
-  Sets which partitions to be used in the command
+/**
+  Sets which partitions to be used in the command.
+
+  @param alter_info     Alter_info pointer holding partition names and flags.
+  @param tab_part_info  partition_info holding all partitions.
+  @param part_state     Which state to set for the named partitions.
+
+  @return Operation status
+    @retval false  Success
+    @retval true   Failure
 */
-uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
-               enum partition_state part_state)
+
+bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
+                    enum partition_state part_state)
 {
   uint part_count= 0;
   uint num_parts_found= 0;
@@ -4428,7 +4437,21 @@
     else
       part_elem->part_state= PART_NORMAL;
   } while (++part_count < tab_part_info->num_parts);
-  return num_parts_found;
+
+  if (num_parts_found != alter_info->partition_names.elements &&
+      !(alter_info->flags & ALTER_ALL_PARTITION))
+  {
+    /* Not all given partitions found, revert and return failure */
+    part_it.rewind();
+    part_count= 0;
+    do
+    {
+      partition_element *part_elem= part_it++;
+      part_elem->part_state= PART_NORMAL;
+    } while (++part_count < tab_part_info->num_parts);
+    return true;
+  }
+  return false;
 }
 
 
@@ -4947,11 +4970,7 @@
     }
     else if (alter_info->flags & ALTER_REBUILD_PARTITION)
     {
-      uint num_parts_found;
-      uint num_parts_opt= alter_info->partition_names.elements;
-      num_parts_found= set_part_state(alter_info, tab_part_info, PART_CHANGED);
-      if (num_parts_found != num_parts_opt &&
-          (!(alter_info->flags & ALTER_ALL_PARTITION)))
+      if (set_part_state(alter_info, tab_part_info, PART_CHANGED))
       {
         my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), "REBUILD");
         goto err;

=== modified file 'sql/sql_partition.h'
--- a/sql/sql_partition.h	2012-01-13 14:50:02 +0000
+++ b/sql/sql_partition.h	2012-03-27 23:04:46 +0000
@@ -254,7 +254,7 @@
                                 char *db,
                                 const char *table_name,
                                 TABLE  *fast_alter_table);
-uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
+bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
                     enum partition_state part_state);
 uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
                            HA_CREATE_INFO *create_info,

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2012-03-09 07:06:59 +0000
+++ b/sql/sql_plugin.cc	2012-04-02 10:33:16 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates.
    Copyright (c) 2010, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
@@ -1520,6 +1520,10 @@
       goto err;
   }
 
+  /* prepare debug_sync service */
+  DBUG_ASSERT(strcmp(list_of_services[5].name, "debug_sync_service") == 0);
+  list_of_services[5].service= *(void**)&debug_sync_C_callback_ptr;
+
   mysql_mutex_lock(&LOCK_plugin);
 
   initialized= 1;
@@ -2381,11 +2385,11 @@
   {
     if (value->val_int(value, &tmp) < 0)
       goto err;
-    if (tmp > 1)
+    if (tmp != 0 && tmp != 1)
       goto err;
     result= (int) tmp;
   }
-  *(my_bool *) save= -result;
+  *(my_bool *) save= result ? 1 : 0;
   return 0;
 err:
   return 1;
@@ -2575,7 +2579,7 @@
 static void update_func_bool(THD *thd, struct st_mysql_sys_var *var,
                              void *tgt, const void *save)
 {
-  *(my_bool *) tgt= *(my_bool *) save ? TRUE : FALSE;
+  *(my_bool *) tgt= *(my_bool *) save ? 1 : 0;
 }
 
 

=== modified file 'sql/sql_plugin_services.h'
--- a/sql/sql_plugin_services.h	2012-03-13 20:55:56 +0000
+++ b/sql/sql_plugin_services.h	2012-03-28 17:26:00 +0000
@@ -54,14 +54,6 @@
   set_thd_proc_info
 };
 
-static struct logger_service_st logger_handler= {
-  logger_open,
-  logger_close,
-  logger_vprintf,
-  logger_printf,
-  logger_rotate
-};
-
 static struct st_service_ref list_of_services[]=
 {
   { "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
@@ -69,6 +61,6 @@
   { "thd_wait_service",    VERSION_thd_wait,    &thd_wait_handler },
   { "my_thread_scheduler_service", VERSION_my_thread_scheduler, &my_thread_scheduler_handler },
   { "progress_report_service", VERSION_progress_report, &progress_report_handler },
-  { "logger_service",   VERSION_logger,   &logger_handler },
+  { "debug_sync_service", VERSION_debug_sync, 0 } // updated in plugin_init()
 };
 

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2012-03-09 07:06:59 +0000
+++ b/sql/sql_prepare.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
-/* Copyright (c) 2002, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2002, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -888,7 +888,7 @@
     */
     else if (! is_param_long_data_type(param))
       DBUG_RETURN(1);
-    res= param->query_val_str(&str);
+    res= param->query_val_str(thd, &str);
     if (param->convert_str_value(thd))
       DBUG_RETURN(1);                           /* out of memory */
 
@@ -1062,7 +1062,7 @@
           DBUG_RETURN(1);
       }
     }
-    res= param->query_val_str(&str);
+    res= param->query_val_str(thd, &str);
     if (param->convert_str_value(thd))
       DBUG_RETURN(1);                           /* out of memory */
 
@@ -1208,7 +1208,7 @@
     setup_one_conversion_function(thd, param, param->param_type);
     if (param->set_from_user_var(thd, entry))
       DBUG_RETURN(1);
-    val= param->query_val_str(&buf);
+    val= param->query_val_str(thd, &buf);
 
     if (param->convert_str_value(thd))
       DBUG_RETURN(1);                           /* out of memory */
@@ -2512,6 +2512,14 @@
       DBUG_ASSERT(sl->join == 0);
       ORDER *order;
       /* Fix GROUP list */
+      if (sl->group_list_ptrs && sl->group_list_ptrs->size() > 0)
+      {
+        for (uint ix= 0; ix < sl->group_list_ptrs->size() - 1; ++ix)
+        {
+          order= sl->group_list_ptrs->at(ix);
+          order->next= sl->group_list_ptrs->at(ix+1);
+        }
+      }
       for (order= sl->group_list.first; order; order= order->next)
         order->item= &order->item_ptr;
       /* Fix ORDER list */

=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc	2012-01-13 14:50:02 +0000
+++ b/sql/sql_profile.cc	2012-03-27 23:04:46 +0000
@@ -1,6 +1,5 @@
-/*
-   Copyright (c) 2007, 2010, Oracle and/or its affiliates.
-   Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2007, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2012-03-09 07:06:59 +0000
+++ b/sql/sql_repl.cc	2012-03-28 17:26:00 +0000
@@ -1,6 +1,5 @@
-/*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -625,7 +624,6 @@
   String* const packet = &thd->packet;
   int error;
   const char *errmsg = "Unknown error", *tmp_msg;
-  char llbuff0[22], llbuff1[22], llbuff2[22];
   char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message()
   NET* net = &thd->net;
   mysql_mutex_t *log_lock;
@@ -906,7 +904,7 @@
                           const char act[]=
                             "now "
                             "wait_for signal.continue";
-                          DBUG_ASSERT(opt_debug_sync_timeout > 0);
+                          DBUG_ASSERT(debug_sync_service);
                           DBUG_ASSERT(!debug_sync_set_action(thd,
                                                              STRING_WITH_LEN(act)));
                           const char act2[]=
@@ -1181,12 +1179,14 @@
        detailing the fatal error message with coordinates 
        of the last position read.
     */
-    const char *fmt= "%s; the start event position from '%s' at %s, the last event was read from '%s' at %s, the last byte read was read from '%s' at %s.";
-    my_snprintf(error_text, sizeof(error_text), fmt, errmsg,
-                my_basename(p_start_coord->file_name),
-                (llstr(p_start_coord->pos, llbuff0), llbuff0),
-                my_basename(p_coord->file_name), (llstr(p_coord->pos, llbuff1), llbuff1),
-                my_basename(log_file_name),    (llstr(my_b_tell(&log), llbuff2), llbuff2));
+    my_snprintf(error_text, sizeof(error_text),
+                "%s; the first event '%s' at %lld, "
+                "the last event read from '%s' at %lld, "
+                "the last byte read from '%s' at %lld.",
+                errmsg,
+                my_basename(p_start_coord->file_name), p_start_coord->pos,
+                my_basename(p_coord->file_name), p_coord->pos,
+                my_basename(log_file_name), my_b_tell(&log));
   }
   else
     strcpy(error_text, errmsg);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-04-12 00:14:06 +0000
+++ b/sql/sql_select.cc	2012-04-12 03:44:52 +0000
@@ -643,7 +643,7 @@
   */
   if (select_lex->master_unit()->item &&                               // 1)
       select_lex->first_cond_optimization &&                           // 2)
-      !(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW)) // 3)
+      !thd->lex->is_view_context_analysis())                           // 3)
   {
     remove_redundant_subquery_clauses(select_lex);
   }
@@ -3085,12 +3085,11 @@
   key_map const_ref, eq_part;
   bool has_expensive_keyparts;
   TABLE **table_vector;
-  JOIN_TAB *stat,*stat_end,*s,**stat_ref;
+  JOIN_TAB *stat,*stat_end,*s,**stat_ref, **stat_vector;
   KEYUSE *keyuse,*start_keyuse;
   table_map outer_join=0;
   table_map no_rows_const_tables= 0;
   SARGABLE_PARAM *sargables= 0;
-  JOIN_TAB *stat_vector[MAX_TABLES+1];
   List_iterator<TABLE_LIST> ti(tables_list);
   TABLE_LIST *tables;
   DBUG_ENTER("make_join_statistics");
@@ -3099,9 +3098,19 @@
   table_count=join->table_count;
 
   stat=(JOIN_TAB*) join->thd->calloc(sizeof(JOIN_TAB)*(table_count));
-  stat_ref=(JOIN_TAB**) join->thd->alloc(sizeof(JOIN_TAB*)*MAX_TABLES);
+  stat_ref=(JOIN_TAB**) join->thd->alloc(sizeof(JOIN_TAB*)*
+                                         (MAX_TABLES + table_count + 1));
+  stat_vector= stat_ref + MAX_TABLES;
   table_vector=(TABLE**) join->thd->alloc(sizeof(TABLE*)*(table_count*2));
-  if (!stat || !stat_ref || !table_vector)
+  join->positions= new (join->thd->mem_root) POSITION[(table_count+1)];
+  /*
+    best_positions is ok to allocate with alloc() as we copy things to it with
+    memcpy()
+  */
+  join->best_positions= (POSITION*) join->thd->alloc(sizeof(POSITION)*
+                                                     (table_count +1));
+
+  if (join->thd->is_fatal_error)
     DBUG_RETURN(1);				// Eom /* purecov: inspected */
 
   join->best_ref=stat_vector;
@@ -3123,6 +3132,12 @@
     error= tables->fetch_number_of_rows();
     set_statistics_for_table(join->thd, table);
 
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+    const bool no_partitions_used= table->no_partitions_used;
+#else
+    const bool no_partitions_used= FALSE;
+#endif
+
     DBUG_EXECUTE_IF("bug11747970_raise_error",
                     {
                       if (!error)
@@ -3154,13 +3169,10 @@
     if (*s->on_expr_ref)
     {
       /* s is the only inner table of an outer join */
-#ifdef WITH_PARTITION_STORAGE_ENGINE
-      if (!table->is_filled_at_execution() &&
-	  (!table->stat_records() || table->no_partitions_used) && !embedding)
-#else
-      if (!table->is_filled_at_execution() &&
-          !table->stat_records() && !embedding)
-#endif
+      if (!table->is_filled_at_execution() &&
+          ((!table->file->stats.records &&
+            (table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) ||
+           no_partitions_used) && !embedding)
       {						// Empty table
         s->dependent= 0;                        // Ignore LEFT JOIN depend.
         no_rows_const_tables |= table->map;
@@ -3200,16 +3212,12 @@
       if (inside_an_outer_join)
         continue;
     }
-#ifdef WITH_PARTITION_STORAGE_ENGINE
-    const bool no_partitions_used= table->no_partitions_used;
-#else
-    const bool no_partitions_used= FALSE;
-#endif
-    if (!table->is_filled_at_execution() && 
-        (table->s->system || table->stat_records() <= 1 ||
+    if (!table->is_filled_at_execution() &&
+        (table->s->system ||
+         (table->file->stats.records <= 1 &&
+          (table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) ||
          no_partitions_used) &&
 	!s->dependent &&
-	(table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) &&
         !table->fulltext_searched && !join->no_const_tables)
     {
       set_position(join,const_count++,s,(KEYUSE*) 0);
@@ -5758,6 +5766,114 @@
 }
 
 
+/*
+  Find JOIN_TAB's embedding (i.e, parent) subquery.
+  - For merged semi-joins, tables inside the semi-join nest have their
+    semi-join nest as parent.  We intentionally ignore results of table 
+    pullout action here.
+  - For non-merged semi-joins (JTBM tabs), the embedding subquery is the 
+    JTBM join tab itself.
+*/
+
+static TABLE_LIST* get_emb_subq(JOIN_TAB *tab)
+{
+  TABLE_LIST *tlist= tab->table->pos_in_table_list;
+  if (tlist->jtbm_subselect)
+    return tlist;
+  TABLE_LIST *embedding= tlist->embedding;
+  if (!embedding || !embedding->sj_subq_pred)
+    return NULL;
+  return embedding;
+}
+
+
+/*
+  Choose initial table order that "helps" semi-join optimizations.
+
+  The idea is that we should start with the order that is the same as the one
+  we would have had if we had semijoin=off:
+  - Top-level tables go first
+  - subquery tables are grouped together by the subquery they are in,
+  - subquery tables are attached where the subquery predicate would have been
+    attached if we had semi-join off.
+  
+  This function relies on join_tab_cmp()/join_tab_cmp_straight() to produce
+  certain pre-liminary ordering, see compare_embedding_subqueries() for its
+  description.
+*/
+
+static void choose_initial_table_order(JOIN *join)
+{
+  TABLE_LIST *emb_subq;
+  JOIN_TAB **tab= join->best_ref + join->const_tables;
+  JOIN_TAB **tabs_end= tab + join->table_count - join->const_tables;
+  /* Find where the top-level JOIN_TABs end and subquery JOIN_TABs start */
+  for (; tab != tabs_end; tab++)
+  {
+    if ((emb_subq= get_emb_subq(*tab)))
+      break;
+  }
+  uint n_subquery_tabs= tabs_end - tab;
+
+  if (!n_subquery_tabs)
+    return;
+
+  /* Copy the subquery JOIN_TABs to a separate array */
+  JOIN_TAB *subquery_tabs[MAX_TABLES];
+  memcpy(subquery_tabs, tab, sizeof(JOIN_TAB*) * n_subquery_tabs);
+  
+  JOIN_TAB **last_top_level_tab= tab;
+  JOIN_TAB **subq_tab= subquery_tabs;
+  JOIN_TAB **subq_tabs_end= subquery_tabs + n_subquery_tabs;
+  TABLE_LIST *cur_subq_nest= NULL;
+  for (; subq_tab < subq_tabs_end; subq_tab++)
+  {
+    if (get_emb_subq(*subq_tab)!= cur_subq_nest)
+    {
+      /*
+        Reached the part of subquery_tabs that covers tables in some subquery.
+      */
+      cur_subq_nest= get_emb_subq(*subq_tab);
+
+      /* Determine how many tables the subquery has */
+      JOIN_TAB **last_tab_for_subq;
+      for (last_tab_for_subq= subq_tab;
+           last_tab_for_subq < subq_tabs_end && 
+           get_emb_subq(*last_tab_for_subq) == cur_subq_nest;
+           last_tab_for_subq++) {}
+      uint n_subquery_tables= last_tab_for_subq - subq_tab;
+
+      /* 
+        Walk the original array and find where this subquery would have been
+        attached to
+      */
+      table_map need_tables= cur_subq_nest->original_subq_pred_used_tables;
+      need_tables &= ~(join->const_table_map | PSEUDO_TABLE_BITS);
+      for (JOIN_TAB **top_level_tab= join->best_ref + join->const_tables;
+           top_level_tab < last_top_level_tab;
+           //top_level_tab < join->best_ref + join->table_count;
+           top_level_tab++)
+      {
+        need_tables &= ~(*top_level_tab)->table->map;
+        /* Check if this is the place where subquery should be attached */
+        if (!need_tables)
+        {
+          /* Move away the top-level tables that are after top_level_tab */
+          uint top_tail_len= last_top_level_tab - top_level_tab - 1;
+          memmove(top_level_tab + 1 + n_subquery_tables, top_level_tab + 1,
+                  sizeof(JOIN_TAB*)*top_tail_len);
+          last_top_level_tab += n_subquery_tables;
+          memcpy(top_level_tab + 1, subq_tab, sizeof(JOIN_TAB*)*n_subquery_tables);
+          break;
+        }
+      }
+      DBUG_ASSERT(!need_tables);
+      subq_tab += n_subquery_tables - 1;
+    }
+  }
+}
+
+
 /**
   Selects and invokes a search strategy for an optimal query plan.
 
@@ -5813,9 +5929,21 @@
     */
     jtab_sort_func= straight_join ? join_tab_cmp_straight : join_tab_cmp;
   }
+
+  /*
+    psergey-todo: if we're not optimizing an SJM nest, 
+     - sort that outer tables are first, and each sjm nest follows
+     - then, put each [sjm_table1, ... sjm_tableN] sub-array right where 
+       WHERE clause pushdown would have put it.
+  */
   my_qsort2(join->best_ref + join->const_tables,
             join->table_count - join->const_tables, sizeof(JOIN_TAB*),
             jtab_sort_func, (void*)join->emb_sjm_nest);
+
+  if (!join->emb_sjm_nest)
+  {
+    choose_initial_table_order(join);
+  }
   join->cur_sj_inner_tables= 0;
 
   if (straight_join)
@@ -5855,6 +5983,64 @@
 }
 
 
+/*
+  Compare two join tabs based on the subqueries they are from.
+   - top-level join tabs go first
+   - then subqueries are ordered by their select_id (we're using this 
+     criteria because we need a cross-platform, deterministic ordering)
+
+  @return 
+     0   -  equal
+     -1  -  jt1 < jt2
+     1   -  jt1 > jt2
+*/
+
+static int compare_embedding_subqueries(JOIN_TAB *jt1, JOIN_TAB *jt2)
+{
+  /* Determine if the first table is originally from a subquery */
+  TABLE_LIST *tbl1= jt1->table->pos_in_table_list;
+  uint tbl1_select_no;
+  if (tbl1->jtbm_subselect)
+  {
+    tbl1_select_no= 
+      tbl1->jtbm_subselect->unit->first_select()->select_number;
+  }
+  else if (tbl1->embedding && tbl1->embedding->sj_subq_pred)
+  {
+    tbl1_select_no= 
+      tbl1->embedding->sj_subq_pred->unit->first_select()->select_number;
+  }
+  else
+    tbl1_select_no= 1; /* Top-level */
+
+  /* Same for the second table */
+  TABLE_LIST *tbl2= jt2->table->pos_in_table_list;
+  uint tbl2_select_no;
+  if (tbl2->jtbm_subselect)
+  {
+    tbl2_select_no= 
+      tbl2->jtbm_subselect->unit->first_select()->select_number;
+  }
+  else if (tbl2->embedding && tbl2->embedding->sj_subq_pred)
+  {
+    tbl2_select_no= 
+      tbl2->embedding->sj_subq_pred->unit->first_select()->select_number;
+  }
+  else
+    tbl2_select_no= 1; /* Top-level */
+
+  /* 
+    Put top-level tables in front. Tables from within subqueries must follow,
+    grouped by their owner subquery. We don't care about the order that
+    subquery groups are in, because choose_initial_table_order() will re-order
+    the groups.
+  */
+  if (tbl1_select_no != tbl2_select_no)
+    return tbl1_select_no > tbl2_select_no ? 1 : -1;
+  return 0;
+}
+
+
 /**
   Compare two JOIN_TAB objects based on the number of accessed records.
 
@@ -5871,6 +6057,9 @@
       a: dependent = 0x0 table->map = 0x1 found_records = 3 ptr = 0x907e6b0
       b: dependent = 0x0 table->map = 0x2 found_records = 3 ptr = 0x907e838
       c: dependent = 0x6 table->map = 0x10 found_records = 2 ptr = 0x907ecd0
+
+   As for subuqueries, this function must produce order that can be fed to 
+   choose_initial_table_order().
      
   @retval
     1  if first is bigger
@@ -5885,7 +6074,15 @@
 {
   JOIN_TAB *jt1= *(JOIN_TAB**) ptr1;
   JOIN_TAB *jt2= *(JOIN_TAB**) ptr2;
+  int cmp;
 
+  if ((cmp= compare_embedding_subqueries(jt1, jt2)) != 0)
+    return cmp;
+  /*
+    After that,
+    take care about ordering imposed by LEFT JOIN constraints,
+    possible [eq]ref accesses, and numbers of matching records in the table.
+  */
   if (jt1->dependent & jt2->table->map)
     return 1;
   if (jt2->dependent & jt1->table->map)
@@ -5916,6 +6113,10 @@
   DBUG_ASSERT(!jt1->emb_sj_nest);
   DBUG_ASSERT(!jt2->emb_sj_nest);
 
+  int cmp;
+  if ((cmp= compare_embedding_subqueries(jt1, jt2)) != 0)
+    return cmp;
+
   if (jt1->dependent & jt2->table->map)
     return 1;
   if (jt2->dependent & jt1->table->map)
@@ -7636,7 +7837,7 @@
       if (keyuse->null_rejecting) 
         j->ref.null_rejecting |= 1 << i;
       keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
-      if (!keyuse->used_tables && !thd->lex->describe)
+      if (!keyuse->val->used_tables() && !thd->lex->describe)
       {					// Compare against constant
 	store_key_item tmp(thd, 
                            keyinfo->key_part[i].field,
@@ -10852,6 +11053,9 @@
     acceptable, as this happens rarely. The implementation without
     copying would be much more complicated.
 
+    For description of how equality propagation works with SJM nests, grep 
+    for EqualityPropagationAndSjmNests.
+
   @param left_item   left term of the quality to be checked
   @param right_item  right term of the equality to be checked
   @param item        equality item if the equality originates from a condition
@@ -10925,12 +11129,14 @@
     {
       /* left_item_equal of an upper level contains left_item */
       left_item_equal= new Item_equal(left_item_equal);
+      left_item_equal->set_context_field(((Item_field*) left_item));
       cond_equal->current_level.push_back(left_item_equal);
     }
     if (right_copyfl)
     {
       /* right_item_equal of an upper level contains right_item */
       right_item_equal= new Item_equal(right_item_equal);
+      right_item_equal->set_context_field(((Item_field*) right_item));
       cond_equal->current_level.push_back(right_item_equal);
     }
 
@@ -10960,6 +11166,7 @@
         Item_equal *item_equal= new Item_equal(orig_left_item,
                                                orig_right_item,
                                                FALSE);
+        item_equal->set_context_field((Item_field*)left_item);
         cond_equal->current_level.push_back(item_equal);
       }
     }
@@ -11016,6 +11223,7 @@
       {
         item_equal= new Item_equal(item_equal);
         cond_equal->current_level.push_back(item_equal);
+        item_equal->set_context_field(field_item);
       }
       if (item_equal)
       {
@@ -11029,6 +11237,7 @@
       else
       {
         item_equal= new Item_equal(const_item, orig_field_item, TRUE);
+        item_equal->set_context_field(field_item);
         cond_equal->current_level.push_back(item_equal);
       }
       return TRUE;
@@ -11665,6 +11874,8 @@
         Item_equal::get_first() also takes similar measures for dealing with
         equality substitution in presense of SJM nests.
 
+    Grep for EqualityPropagationAndSjmNests for a more verbose description.
+
   @return
     - The condition with generated simple equalities or
     a pointer to the simple generated equality, if success.
@@ -11728,9 +11939,13 @@
       on upper AND-levels.
     */
     if (upper)
-    { 
+    {
+      TABLE_LIST *native_sjm= embedding_sjm(item_equal->context_field);
       if (item_const && upper->get_const())
+      {
+        /* Upper item also has "field_item=const". Don't produce equality here */
         item= 0;
+      }
       else
       {
         Item_equal_fields_iterator li(*item_equal);
@@ -11741,6 +11956,8 @@
             break;
         }
       }
+      if (embedding_sjm(field_item) != native_sjm)
+        item= NULL; /* Don't produce equality */
     }
     
     bool produce_equality= test(item == field_item);
@@ -12436,11 +12653,9 @@
     Flatten nested joins that can be flattened.
     no ON expression and not a semi-join => can be flattened.
   */
-  TABLE_LIST *right_neighbor= NULL;
   li.rewind();
   while ((table= li++))
   {
-    bool fix_name_res= FALSE;
     nested_join= table->nested_join;
     if (table->sj_on_expr && !in_sj)
     {
@@ -12477,15 +12692,7 @@
         tbl->dep_tables|= table->dep_tables;
       }
       li.replace(repl_list);
-      /* Need to update the name resolution table chain when flattening joins */
-      fix_name_res= TRUE;
-      table= *li.ref();
     }
-    if (fix_name_res)
-      table->next_name_resolution_table= right_neighbor ?
-        right_neighbor->first_leaf_for_name_resolution() :
-        NULL;
-    right_neighbor= table;
   }
   DBUG_RETURN(conds); 
 }
@@ -15221,6 +15428,7 @@
     else
       entry->file->ha_delete_table(entry->s->table_name.str);
     delete entry->file;
+    entry->file= 0;
   }
 
   /* free blobs */
@@ -15834,7 +16042,8 @@
     DBUG_RETURN(NESTED_LOOP_KILLED);            /* purecov: inspected */
   }
 
-  update_virtual_fields(join->thd, join_tab->table);
+  if (join_tab->table->vfield)
+    update_virtual_fields(join->thd, join_tab->table);
 
   if (select_cond)
   {
@@ -16262,7 +16471,8 @@
       empty_record(table);			// Make empty record
       return -1;
     }
-    update_virtual_fields(tab->join->thd, table);
+    if (table->vfield)
+      update_virtual_fields(tab->join->thd, table);
     store_record(table,record[1]);
   }
   else if (!table->status)			// Only happens with left join
@@ -16311,7 +16521,8 @@
 	return report_error(table, error);
       return -1;
     }
-    update_virtual_fields(tab->join->thd, table);
+    if (table->vfield)
+      update_virtual_fields(tab->join->thd, table);
     store_record(table,record[1]);
   }
   else if (!(table->status & ~STATUS_NULL_ROW))	// Only happens with left join

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2012-02-15 17:08:08 +0000
+++ b/sql/sql_select.h	2012-03-24 17:21:22 +0000
@@ -742,7 +742,7 @@
   Information about a position of table within a join order. Used in join
   optimization.
 */
-typedef struct st_position
+typedef struct st_position :public Sql_alloc
 {
   /* The table that's put into join order */
   JOIN_TAB *table;
@@ -844,23 +844,36 @@
   */
   class Join_plan_state {
   public:
-    DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */
-    POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */
+    DYNAMIC_ARRAY keyuse;        /* Copy of the JOIN::keyuse array. */
+    POSITION *best_positions;    /* Copy of JOIN::best_positions */
     /* Copies of the JOIN_TAB::keyuse pointers for each JOIN_TAB. */
-    KEYUSE *join_tab_keyuse[MAX_TABLES];
+    KEYUSE **join_tab_keyuse;
     /* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */
-    key_map join_tab_checked_keys[MAX_TABLES];
-    SJ_MATERIALIZATION_INFO *sj_mat_info[MAX_TABLES];
+    key_map *join_tab_checked_keys;
+    SJ_MATERIALIZATION_INFO **sj_mat_info;
+    my_bool error;
   public:
-    Join_plan_state()
+    Join_plan_state(uint tables) : error(0)
     {   
       keyuse.elements= 0;
       keyuse.buffer= NULL;
+      best_positions= 0;                        /* To detect errors */
+      error= my_multi_malloc(MYF(MY_WME),
+                             &best_positions,
+                             sizeof(*best_positions) * (tables + 1),
+                             &join_tab_keyuse,
+                             sizeof(*join_tab_keyuse) * tables,
+                             &join_tab_checked_keys,
+                             sizeof(*join_tab_checked_keys) * tables,
+                             &sj_mat_info,
+                             sizeof(sj_mat_info) * tables,
+                             NullS) == 0;
     }
     Join_plan_state(JOIN *join);
     ~Join_plan_state()
     {
       delete_dynamic(&keyuse);
+      my_free(best_positions);
     }
   };
 
@@ -958,7 +971,7 @@
   */
   ha_rows  fetch_limit;
   /* Finally picked QEP. This is result of join optimization */
-  POSITION best_positions[MAX_TABLES+1];
+  POSITION *best_positions;
 
 /******* Join optimization state members start *******/
   /*
@@ -968,7 +981,7 @@
   TABLE_LIST *emb_sjm_nest;
   
   /* Current join optimization state */
-  POSITION positions[MAX_TABLES+1];
+  POSITION *positions;
   
   /*
     Bitmap of nested joins embedding the position at the end of the current 
@@ -1238,6 +1251,7 @@
     exec_const_cond= 0;
     group_optimized_away= 0;
     no_rows_in_result_called= 0;
+    positions= best_positions= 0;
 
     all_fields= fields_arg;
     if (&fields_list != &fields_arg)      /* Avoid valgrind-warning */

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2012-01-13 14:50:02 +0000
+++ b/sql/sql_show.cc	2012-04-10 06:28:13 +0000
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   2009-2011 Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1233,7 +1233,9 @@
   handler *file= table->file;
   TABLE_SHARE *share= table->s;
   HA_CREATE_INFO create_info;
-  bool show_table_options __attribute__ ((unused))= FALSE;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+  bool show_table_options= FALSE;
+#endif /* WITH_PARTITION_STORAGE_ENGINE */
   bool foreign_db_mode=  (thd->variables.sql_mode & (MODE_POSTGRESQL |
                                                      MODE_ORACLE |
                                                      MODE_MSSQL |
@@ -1467,7 +1469,9 @@
   packet->append(STRING_WITH_LEN("\n)"));
   if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
   {
+#ifdef WITH_PARTITION_STORAGE_ENGINE
     show_table_options= TRUE;
+#endif /* WITH_PARTITION_STORAGE_ENGINE */
 
     /*
       IF   check_create_info
@@ -3628,16 +3632,17 @@
     @retval       1           error
 */
 
-static int fill_schema_table_names(THD *thd, TABLE *table,
+static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
                                    LEX_STRING *db_name, LEX_STRING *table_name,
                                    bool with_i_schema)
 {
+  TABLE *table= tables->table;
   if (with_i_schema)
   {
     table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"),
                            system_charset_info);
   }
-  else
+  else if (tables->table_open_method != SKIP_OPEN_TABLE)
   {
     enum legacy_db_type not_used;
     char path[FN_REFLEN + 1];
@@ -4199,7 +4204,7 @@
           /* SHOW TABLE NAMES command */
           if (schema_table_idx == SCH_TABLE_NAMES)
           {
-            if (fill_schema_table_names(thd, tables->table, db_name,
+            if (fill_schema_table_names(thd, tables, db_name,
                                         table_name, with_i_schema))
               continue;
           }
@@ -5249,7 +5254,8 @@
       (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)
   {
     restore_record(table, s->default_values);
-    if (!wild || !wild[0] || !wild_compare(sp_name.c_ptr_safe(), wild, 0))
+    if (!wild || !wild[0] || !wild_case_compare(system_charset_info,
+                                                sp_name.c_ptr_safe(), wild))
     {
       int enum_idx= (int) proc_table->field[MYSQL_PROC_FIELD_ACCESS]->val_int();
       table->field[3]->store(sp_name.ptr(), sp_name.length(), cs);
@@ -6409,7 +6415,7 @@
     DBUG_RETURN(1);
   }
 
-  if (!(!wild || !wild[0] || !wild_compare(et.name.str, wild, 0)))
+  if (!(!wild || !wild[0] || !wild_case_compare(scs, et.name.str, wild)))
     DBUG_RETURN(0);
 
   /*
@@ -7498,6 +7504,8 @@
         join->error= 1;
         tab->read_record.table->file= table_list->table->file;
         table_list->schema_table_state= executed_place;
+        if (!thd->is_error())
+          my_error(ER_UNKNOWN_ERROR, MYF(0));
         break;
       }
       tab->read_record.table->file= table_list->table->file;
@@ -8385,7 +8393,7 @@
    get_all_tables, 0, get_schema_constraints_record, 3, 4, 0,
    OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
   {"TABLE_NAMES", table_names_fields_info, create_schema_table,
-   get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
+   get_all_tables, make_table_names_old_format, 0, 1, 2, 1, OPTIMIZE_I_S_TABLE},
   {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
    fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
   {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2012-03-19 08:35:32 +0000
+++ b/sql/sql_table.cc	2012-04-12 03:44:52 +0000
@@ -1,6 +1,6 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-   Copyright (c) 2010, 2011 Monty Program Ab
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2010, 2011, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -3144,6 +3144,15 @@
     DBUG_RETURN(TRUE);
   }
 
+  /*
+   CREATE TABLE[with auto_increment column] SELECT is unsafe as the rows
+   inserted in the created table depends on the order of the rows fetched
+   from the select tables. This order may differ on master and slave. We
+   therefore mark it as unsafe.
+  */
+  if (select_field_count > 0 && auto_increment)
+  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC);
+
   /* Create keys */
 
   List_iterator<Key> key_iterator(alter_info->key_list);
@@ -7274,7 +7283,8 @@
       error= 1;
       break;
     }
-    update_virtual_fields(thd, from);
+    if (from->vfield)
+      update_virtual_fields(thd, from);
     if (++thd->progress.counter >= time_to_report_progress)
     {
       time_to_report_progress+= MY_HOW_OFTEN_TO_WRITE/10;
@@ -7301,7 +7311,8 @@
       copy_ptr->do_copy(copy_ptr);
     }
     prev_insert_id= to->file->next_insert_id;
-    update_virtual_fields(thd, to, TRUE);
+    if (to->vfield)
+      update_virtual_fields(thd, to, TRUE);
     if (thd->is_error())
     {
       error= 1;

=== modified file 'sql/sql_udf.cc'
--- a/sql/sql_udf.cc	2012-03-09 07:06:59 +0000
+++ b/sql/sql_udf.cc	2012-03-27 23:04:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    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

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2012-02-15 17:08:08 +0000
+++ b/sql/sql_update.cc	2012-03-24 17:21:22 +0000
@@ -559,7 +559,8 @@
 
       while (!(error=info.read_record(&info)) && !thd->killed)
       {
-        update_virtual_fields(thd, table);
+        if (table->vfield)
+          update_virtual_fields(thd, table);
         thd->examined_row_count++;
 	if (!select || (error= select->skip_record(thd)) > 0)
 	{
@@ -674,7 +675,8 @@
 
   while (!(error=info.read_record(&info)) && !thd->killed)
   {
-    update_virtual_fields(thd, table);
+    if (table->vfield)
+      update_virtual_fields(thd, table);
     thd->examined_row_count++;
     if (!select || select->skip_record(thd) > 0)
     {

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	2012-03-11 22:45:18 +0000
+++ b/sql/sql_view.cc	2012-04-10 06:28:13 +0000
@@ -445,6 +445,13 @@
 
   view= lex->unlink_first_table(&link_to_local);
 
+  if (check_db_dir_existence(view->db))
+  {
+    my_error(ER_BAD_DB_ERROR, MYF(0), view->db);
+    res= TRUE;
+    goto err;
+  }
+
   if (mode == VIEW_ALTER && fill_defined_view_parts(thd, view))
   {
     res= TRUE;

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2012-03-11 22:45:18 +0000
+++ b/sql/sql_yacc.yy	2012-04-07 13:58:46 +0000
@@ -2772,9 +2772,15 @@
             sp_instr_hpush_jump *i=
               new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
                                       ctx->current_var_count());
-            if (i == NULL ||
-                sp->add_instr(i) ||
-                sp->push_backpatch(i, ctx->push_label((char *)"", 0)))
+            if (i == NULL || sp->add_instr(i))
+              MYSQL_YYABORT;
+
+            /* For continue handlers, mark end of handler scope. */
+            if ($2 == SP_HANDLER_CONTINUE &&
+                sp->push_backpatch(i, ctx->last_label()))
+              MYSQL_YYABORT;
+
+            if (sp->push_backpatch(i, ctx->push_label(empty_c_string, 0)))
               MYSQL_YYABORT;
           }
           sp_hcond_list sp_proc_stmt

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2012-03-19 08:35:32 +0000
+++ b/sql/sys_vars.cc	2012-04-12 03:44:52 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2002, 2012, Oracle and/or its affiliates.
    Copyright (c) 2012, Monty Program Ab
 
    This program is free software; you can redistribute it and/or modify
@@ -2954,7 +2954,7 @@
        "port or if you have a special tunnel from the master or other clients "
        "to the slave. If not sure, leave this option unset",
        READ_ONLY GLOBAL_VAR(report_port), CMD_LINE(REQUIRED_ARG),
-       VALID_RANGE(0, UINT_MAX), DEFAULT(MYSQL_PORT), BLOCK_SIZE(1));
+       VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
 #endif
 
 static Sys_var_mybool Sys_keep_files_on_create(
@@ -3255,6 +3255,150 @@
        "processed",
        GLOBAL_VAR(relay_log_recovery), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
 
+bool Sys_var_rpl_filter::do_check(THD *thd, set_var *var)
+{
+  bool status;
+
+  mysql_mutex_lock(&LOCK_active_mi);
+  mysql_mutex_lock(&active_mi->rli.run_lock);
+
+  status= active_mi->rli.slave_running;
+
+  mysql_mutex_unlock(&active_mi->rli.run_lock);
+  mysql_mutex_unlock(&LOCK_active_mi);
+
+  if (status)
+    my_error(ER_SLAVE_MUST_STOP, MYF(0));
+  else
+    status= Sys_var_charptr::do_string_check(thd, var, charset(thd));
+
+  return status;
+}
+
+bool Sys_var_rpl_filter::global_update(THD *thd, set_var *var)
+{
+  bool slave_running, status= false;
+
+  mysql_mutex_lock(&LOCK_active_mi);
+  mysql_mutex_lock(&active_mi->rli.run_lock);
+
+  if (! (slave_running= active_mi->rli.slave_running))
+    status= set_filter_value(var->save_result.string_value.str);
+
+  mysql_mutex_unlock(&active_mi->rli.run_lock);
+  mysql_mutex_unlock(&LOCK_active_mi);
+
+  if (slave_running)
+    my_error(ER_SLAVE_MUST_STOP, MYF(0));
+
+  return slave_running || status;
+}
+
+bool Sys_var_rpl_filter::set_filter_value(const char *value)
+{
+  bool status= true;
+
+  switch (opt_id) {
+  case OPT_REPLICATE_DO_DB:
+    status= rpl_filter->set_do_db(value);
+    break;
+  case OPT_REPLICATE_DO_TABLE:
+    status= rpl_filter->set_do_table(value);
+    break;
+  case OPT_REPLICATE_IGNORE_DB:
+    status= rpl_filter->set_ignore_db(value);
+    break;
+  case OPT_REPLICATE_IGNORE_TABLE:
+    status= rpl_filter->set_ignore_table(value);
+    break;
+  case OPT_REPLICATE_WILD_DO_TABLE:
+    status= rpl_filter->set_wild_do_table(value);
+    break;
+  case OPT_REPLICATE_WILD_IGNORE_TABLE:
+    status= rpl_filter->set_wild_ignore_table(value);
+    break;
+  }
+
+  return status;
+}
+
+uchar *Sys_var_rpl_filter::global_value_ptr(THD *thd, LEX_STRING *base)
+{
+  char buf[256];
+  String tmp(buf, sizeof(buf), &my_charset_bin);
+
+  tmp.length(0);
+
+  mysql_mutex_lock(&LOCK_active_mi);
+  mysql_mutex_lock(&active_mi->rli.run_lock);
+
+  switch (opt_id) {
+  case OPT_REPLICATE_DO_DB:
+    rpl_filter->get_do_db(&tmp);
+    break;
+  case OPT_REPLICATE_DO_TABLE:
+    rpl_filter->get_do_table(&tmp);
+    break;
+  case OPT_REPLICATE_IGNORE_DB:
+    rpl_filter->get_ignore_db(&tmp);
+    break;
+  case OPT_REPLICATE_IGNORE_TABLE:
+    rpl_filter->get_ignore_table(&tmp);
+    break;
+  case OPT_REPLICATE_WILD_DO_TABLE:
+    rpl_filter->get_wild_do_table(&tmp);
+    break;
+  case OPT_REPLICATE_WILD_IGNORE_TABLE:
+    rpl_filter->get_wild_ignore_table(&tmp);
+    break;
+  }
+
+  mysql_mutex_unlock(&active_mi->rli.run_lock);
+  mysql_mutex_unlock(&LOCK_active_mi);
+
+  return (uchar *) thd->strmake(tmp.ptr(), tmp.length());
+}
+
+static Sys_var_rpl_filter Sys_replicate_do_db(
+       "replicate_do_db", OPT_REPLICATE_DO_DB,
+       "Tell the slave to restrict replication to updates of tables "
+       "whose names appear in the comma-separated list. For "
+       "statement-based replication, only the default database (that "
+       "is, the one selected by USE) is considered, not any explicitly "
+       "mentioned tables in the query. For row-based replication, the "
+       "actual names of table(s) being updated are checked.");
+
+static Sys_var_rpl_filter Sys_replicate_do_table(
+       "replicate_do_table", OPT_REPLICATE_DO_TABLE,
+       "Tells the slave to restrict replication to tables in the "
+       "comma-separated list.");
+
+static Sys_var_rpl_filter Sys_replicate_ignore_db(
+       "replicate_ignore_db", OPT_REPLICATE_IGNORE_DB,
+       "Tell the slave to restrict replication to updates of tables "
+       "whose names do not appear in the comma-separated list. For "
+       "statement-based replication, only the default database (that "
+       "is, the one selected by USE) is considered, not any explicitly "
+       "mentioned tables in the query. For row-based replication, the "
+       "actual names of table(s) being updated are checked.");
+
+static Sys_var_rpl_filter Sys_replicate_ignore_table(
+       "replicate_ignore_table", OPT_REPLICATE_IGNORE_TABLE,
+       "Tells the slave thread not to replicate any statement that "
+       "updates the specified table, even if any other tables might be "
+       "updated by the same statement.");
+
+static Sys_var_rpl_filter Sys_replicate_wild_do_table(
+       "replicate_wild_do_table", OPT_REPLICATE_WILD_DO_TABLE,
+       "Tells the slave thread to restrict replication to statements "
+       "where any of the updated tables match the specified database "
+       "and table name patterns.");
+
+static Sys_var_rpl_filter Sys_replicate_wild_ignore_table(
+       "replicate_wild_ignore_table", OPT_REPLICATE_WILD_IGNORE_TABLE,
+       "Tells the slave thread to not replicate to the tables that "
+       "match the given wildcard pattern.");
+
 static Sys_var_charptr Sys_slave_load_tmpdir(
        "slave_load_tmpdir", "The location where the slave should put "
        "its temporary files when replicating a LOAD DATA INFILE command",

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2012-03-01 11:41:49 +0000
+++ b/sql/sys_vars.h	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2002, 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
@@ -430,11 +430,11 @@
       my_free(global_var(char*));
     flags&= ~ALLOCATED;
   }
-  bool do_check(THD *thd, set_var *var)
+  static bool do_string_check(THD *thd, set_var *var, CHARSET_INFO *charset)
   {
     char buff[STRING_BUFFER_USUAL_SIZE], buff2[STRING_BUFFER_USUAL_SIZE];
-    String str(buff, sizeof(buff), charset(thd));
-    String str2(buff2, sizeof(buff2), charset(thd)), *res;
+    String str(buff, sizeof(buff), charset);
+    String str2(buff2, sizeof(buff2), charset), *res;
 
     if (!(res=var->value->val_str(&str)))
       var->save_result.string_value.str= 0;
@@ -442,10 +442,10 @@
     {
       uint32 unused;
       if (String::needs_conversion(res->length(), res->charset(),
-                                   charset(thd), &unused))
+                                   charset, &unused))
       {
         uint errors;
-        str2.copy(res->ptr(), res->length(), res->charset(), charset(thd),
+        str2.copy(res->ptr(), res->length(), res->charset(), charset,
                   &errors);
         res=&str2;
 
@@ -456,6 +456,8 @@
 
     return false;
   }
+  bool do_check(THD *thd, set_var *var)
+  { return do_string_check(thd, var, charset(thd)); }
   bool session_update(THD *thd, set_var *var)
   {
     DBUG_ASSERT(FALSE);
@@ -550,6 +552,44 @@
   }
 };
 
+class Sys_var_rpl_filter: public sys_var
+{
+private:
+  int opt_id;
+
+public:
+  Sys_var_rpl_filter(const char *name, int getopt_id, const char *comment)
+    : sys_var(&all_sys_vars, name, comment, sys_var::GLOBAL, 0, -1,
+              NO_ARG, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG,
+              NULL, NULL, 0, NULL), opt_id(getopt_id)
+  {
+    option.var_type= GET_STR;
+  }
+
+  bool check_update_type(Item_result type)
+  { return type != STRING_RESULT; }
+
+  bool do_check(THD *thd, set_var *var);
+
+  void session_save_default(THD *thd, set_var *var)
+  { DBUG_ASSERT(FALSE); }
+
+  void global_save_default(THD *thd, set_var *var)
+  { DBUG_ASSERT(FALSE); }
+
+  bool session_update(THD *thd, set_var *var)
+  {
+    DBUG_ASSERT(FALSE);
+    return true;
+  }
+
+  bool global_update(THD *thd, set_var *var);
+
+protected:
+  uchar *global_value_ptr(THD *thd, LEX_STRING *base);
+  bool set_filter_value(const char *value);
+};
+
 /**
   The class for string variables. Useful for strings that aren't necessarily
   \0-terminated. Otherwise the same as Sys_var_charptr.

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2012-04-12 00:14:06 +0000
+++ b/sql/table.cc	2012-04-12 03:44:52 +0000
@@ -2490,30 +2490,35 @@
   /*
     Process virtual columns, if any.
   */
-  if (!(vfield_ptr = (Field **) alloc_root(&outparam->mem_root,
-                                          (uint) ((share->vfields+1)*
-                                                  sizeof(Field*)))))
-    goto err;
-
-  outparam->vfield= vfield_ptr;
-  
-  for (field_ptr= outparam->field; *field_ptr; field_ptr++)
+  if (!share->vfields)
+    outparam->vfield= NULL;
+  else
   {
-    if ((*field_ptr)->vcol_info)
+    if (!(vfield_ptr = (Field **) alloc_root(&outparam->mem_root,
+                                             (uint) ((share->vfields+1)*
+                                                     sizeof(Field*)))))
+      goto err;
+
+    outparam->vfield= vfield_ptr;
+
+    for (field_ptr= outparam->field; *field_ptr; field_ptr++)
     {
-      if (unpack_vcol_info_from_frm(thd,
-                                    outparam,
-                                    *field_ptr,
-                                    &(*field_ptr)->vcol_info->expr_str,
-                                    &error_reported))
+      if ((*field_ptr)->vcol_info)
       {
-        error= 4; // in case no error is reported
-        goto err;
+        if (unpack_vcol_info_from_frm(thd,
+                                      outparam,
+                                      *field_ptr,
+                                      &(*field_ptr)->vcol_info->expr_str,
+                                      &error_reported))
+        {
+          error= 4; // in case no error is reported
+          goto err;
+        }
+        *(vfield_ptr++)= *field_ptr;
       }
-      *(vfield_ptr++)= *field_ptr;
     }
+    *vfield_ptr= 0;                              // End marker
   }
-  *vfield_ptr= 0;                              // End marker
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   if (share->partition_info_str_len && outparam->file)
@@ -2626,8 +2631,7 @@
                            HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
     {
       /* Set a flag if the table is crashed and it can be auto. repaired */
-      share->crashed= ((ha_err == HA_ERR_CRASHED_ON_USAGE) &&
-                       outparam->file->auto_repair() &&
+      share->crashed= (outparam->file->auto_repair(ha_err) &&
                        !(ha_open_flags & HA_OPEN_FOR_REPAIR));
 
       switch (ha_err)
@@ -4063,7 +4067,21 @@
   Query_arena *arena= thd->stmt_arena, backup;
   bool res= FALSE;
 
-  used_items.empty();
+  if (thd->stmt_arena->is_conventional() ||
+      thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
+  {
+    /* initialize lists */
+    used_items.empty();
+    persistent_used_items.empty();
+  }
+  else
+  {
+    /*
+      Copy the list created by natural join procedure because the procedure
+      will not be repeated.
+    */
+    used_items= persistent_used_items;
+  }
 
   if (field_translation)
   {
@@ -5127,7 +5145,7 @@
   if (view->table && view->table->maybe_null)
     item->maybe_null= TRUE;
   /* Save item in case we will need to fall back to materialization. */
-  view->used_items.push_back(item);
+  view->used_items.push_front(item);
   DBUG_RETURN(item);
 }
 
@@ -6387,8 +6405,7 @@
   DBUG_ENTER("update_virtual_fields");
   Field **vfield_ptr, *vfield;
   int error __attribute__ ((unused))= 0;
-  if (!table || !table->vfield)
-    DBUG_RETURN(0);
+  DBUG_ASSERT(table && table->vfield);
 
   thd->reset_arena_for_cached_items(table->expr_arena);
   /* Iterate over virtual fields in the table */
@@ -6701,7 +6718,11 @@
       if (!materialized_items[idx])
         return TRUE;
     }
-    ref->ref= materialized_items + idx;
+    /*
+      We need to restore the pointers after the execution of the
+      prepared statement.
+    */
+    thd->change_item_tree((Item **)&ref->ref, (Item*)materialized_items + idx);
   }
 
   return FALSE;

=== modified file 'sql/table.h'
--- a/sql/table.h	2012-04-12 00:14:06 +0000
+++ b/sql/table.h	2012-04-12 03:44:52 +0000
@@ -303,6 +303,7 @@
 {
   IO_CACHE *io_cache;           /* If sorted through filesort */
   uchar     **sort_keys;        /* Buffer for sorting keys */
+  uint      keys;               /* Number of key pointers in buffer */
   uchar     *buffpek;           /* Buffer for buffpek structures */
   uint      buffpek_len;        /* Max number of buffpeks in the buffer */
   uchar     *addon_buf;         /* Pointer to a buffer if sorted with fields */
@@ -1596,6 +1597,8 @@
   /* If this is a non-jtbm semi-join nest: corresponding subselect predicate */
   Item_in_subselect  *sj_subq_pred;
 
+  table_map     original_subq_pred_used_tables;
+
   /* If this is a jtbm semi-join object: corresponding subselect predicate */
   Item_in_subselect  *jtbm_subselect;
   /* TODO: check if this can be joined with tablenr_exec */
@@ -1875,7 +1878,13 @@
   /* TRUE <=> don't prepare this derived table/view as it should be merged.*/
   bool          skip_prepare_derived;
 
+  /*
+    Items created by create_view_field and collected to change them in case
+    of materialization of the view/derived table
+  */
   List<Item>    used_items;
+  /* Sublist (tail) of persistent used_items */
+  List<Item>    persistent_used_items;
   Item          **materialized_items;
 
   /* View creation context. */

=== modified file 'sql/threadpool_unix.cc'
--- a/sql/threadpool_unix.cc	2012-02-17 22:27:15 +0000
+++ b/sql/threadpool_unix.cc	2012-04-11 23:40:44 +0000
@@ -295,7 +295,7 @@
 int io_poll_start_read(int pollfd, int fd, void *data)
 {
   struct kevent ke;
-  EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ENABLE|EV_CLEAR, 
+  EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT, 
          0, 0, data);
   return kevent(pollfd, &ke, 1, 0, 0, 0); 
 }
@@ -303,6 +303,9 @@
 
 int io_poll_associate_fd(int pollfd, int fd, void *data)
 {
+  struct kevent ke;
+  EV_SET(&ke, fd, EVFILT_READ, EV_ADD|EV_ONESHOT, 
+         0, 0, data);
   return io_poll_start_read(pollfd,fd, data); 
 }
 
@@ -330,17 +333,6 @@
                (timeout_ms >= 0)?&ts:NULL);
   }
   while (ret == -1 && errno == EINTR);
-  if (ret > 0)
-  {
-    /* Disable monitoring for the events we that we dequeued */
-    for (int i=0; i < ret; i++) 
-    {
-      struct kevent *ke = &events[i];
-      EV_SET(ke, ke->ident, EVFILT_READ, EV_ADD|EV_DISABLE, 
-        0, 0, ke->udata);    
-    }
-    kevent(pollfd, events, ret, 0, 0, 0);
-  }
   return ret;
 }
 

=== modified file 'sql/threadpool_win.cc'
--- a/sql/threadpool_win.cc	2012-02-17 22:23:54 +0000
+++ b/sql/threadpool_win.cc	2012-04-05 13:57:27 +0000
@@ -144,6 +144,9 @@
 WEAK_SYMBOL(VOID, CloseThreadpoolWork, PTP_WORK pwk);
 #define CloseThreadpoolWork my_CloseThreadpoolWork 
 
+WEAK_SYMBOL(BOOL, CallbackMayRunLong, PTP_CALLBACK_INSTANCE pci);
+#define CallbackMayRunLong my_CallbackMayRunLong
+
 #if _MSC_VER >= 1600
 /* Stack size manipulation available only on Win7+ /declarations in VS10 */
 WEAK_SYMBOL(BOOL, SetThreadpoolStackInformation, PTP_POOL, 
@@ -419,8 +422,10 @@
 
 
 /* Connection destructor */
-void destroy_connection(connection_t *connection)
+void destroy_connection(connection_t *connection, PTP_CALLBACK_INSTANCE instance)
 {
+  if (instance)
+    DisassociateCurrentThreadFromCallback(instance);
   if (connection->io)
   {
      WaitForThreadpoolIoCallbacks(connection->io, TRUE); 
@@ -583,10 +588,8 @@
 
 error:
   /* Some error has occured. */
-  if (instance)
-    DisassociateCurrentThreadFromCallback(instance);
 
-  destroy_connection(connection);
+  destroy_connection(connection, instance);
   free(connection);
 }
 
@@ -603,7 +606,7 @@
   connection_t *connection =(connection_t *)context;
   if (login(connection, instance) != 0)
   {
-    destroy_connection(connection);
+    destroy_connection(connection, instance);
     free(connection);
   }
 }

=== modified file 'sql/transaction.cc'
--- a/sql/transaction.cc	2011-04-14 08:13:28 +0000
+++ b/sql/transaction.cc	2012-03-15 09:10:57 +0000
@@ -390,7 +390,7 @@
     DBUG_RETURN(FALSE);
 
   enum xa_states xa_state= thd->transaction.xid_state.xa_state;
-  if (xa_state != XA_NOTR)
+  if (xa_state != XA_NOTR && xa_state != XA_ACTIVE)
   {
     my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[xa_state]);
     DBUG_RETURN(TRUE);

=== modified file 'sql/unireg.h'
--- a/sql/unireg.h	2012-01-13 14:50:02 +0000
+++ b/sql/unireg.h	2012-04-07 13:58:46 +0000
@@ -2,7 +2,7 @@
 #define UNIREG_INCLUDED
 
 /*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
 
    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

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2012-03-17 08:26:58 +0000
+++ b/storage/archive/ha_archive.cc	2012-04-07 13:58:46 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2004, 2011, Oracle and/or its affiliates
+   Copyright (c) 2004, 2012, Oracle and/or its affiliates
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -1399,6 +1399,8 @@
   char writer_filename[FN_REFLEN];
   DBUG_ENTER("ha_archive::optimize");
 
+  mysql_mutex_lock(&share->mutex);
+
   if (init_archive_reader())
     DBUG_RETURN(errno);
 
@@ -1414,7 +1416,10 @@
             MY_REPLACE_EXT | MY_UNPACK_FILENAME);
 
   if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY)))
+  {
+    mysql_mutex_unlock(&share->mutex);
     DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); 
+  }
 
   /*
     Transfer the embedded FRM so that the file can be discoverable.
@@ -1500,10 +1505,12 @@
   rc= my_rename(writer_filename, share->data_file_name, MYF(0));
 
 
+  mysql_mutex_unlock(&share->mutex);
   DBUG_RETURN(rc);
 error:
   DBUG_PRINT("ha_archive", ("Failed to recover, error was %d", rc));
   azclose(&writer);
+  mysql_mutex_unlock(&share->mutex);
 
   DBUG_RETURN(rc); 
 }

=== modified file 'storage/archive/ha_archive.h'
--- a/storage/archive/ha_archive.h	2011-11-03 18:17:05 +0000
+++ b/storage/archive/ha_archive.h	2012-04-02 10:33:16 +0000
@@ -126,7 +126,9 @@
   int free_share();
   int init_archive_writer();
   int init_archive_reader();
-  bool auto_repair() const { return 1; } // For the moment we just do this
+  // Always try auto_repair in case of HA_ERR_CRASHED_ON_USAGE
+  bool auto_repair(int error) const
+  { return error == HA_ERR_CRASHED_ON_USAGE; }
   int read_data_header(azio_stream *file_to_read);
   void position(const uchar *record);
   int info(uint);

=== modified file 'storage/blackhole/ha_blackhole.cc'
--- a/storage/blackhole/ha_blackhole.cc	2012-01-13 14:50:02 +0000
+++ b/storage/blackhole/ha_blackhole.cc	2012-03-27 23:04:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, 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

=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc	2012-01-13 14:50:02 +0000
+++ b/storage/csv/ha_tina.cc	2012-04-07 13:58:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2004, 2010, Oracle and/or its affiliates
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
 
   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
@@ -962,6 +961,7 @@
   */
   thr_lock_data_init(&share->lock, &lock, (void*) this);
   ref_length= sizeof(my_off_t);
+  init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0);
 
   share->lock.get_status= tina_get_status;
   share->lock.update_status= tina_update_status;
@@ -979,6 +979,7 @@
 {
   int rc= 0;
   DBUG_ENTER("ha_tina::close");
+  free_root(&blobroot, MYF(0));
   rc= mysql_file_close(data_file, MYF(0));
   DBUG_RETURN(free_share(share) || rc);
 }
@@ -1197,7 +1198,7 @@
 
   current_position= next_position= 0;
   stats.records= 0;
-  records_is_known= 0;
+  records_is_known= found_end_of_file= 0;
   chain_ptr= chain;
 
   DBUG_RETURN(0);
@@ -1247,6 +1248,7 @@
   stats.records++;
   rc= 0;
 end:
+  found_end_of_file= (rc == HA_ERR_END_OF_FILE);
   MYSQL_READ_ROW_DONE(rc);
   DBUG_RETURN(rc);
 }
@@ -1346,8 +1348,7 @@
   my_off_t file_buffer_start= 0;
   DBUG_ENTER("ha_tina::rnd_end");
 
-  free_root(&blobroot, MYF(0));
-  records_is_known= 1;
+  records_is_known= found_end_of_file;
 
   if ((chain_ptr - chain)  > 0)
   {
@@ -1760,6 +1761,13 @@
 }
 
 
+int ha_tina::reset(void)
+{
+  free_root(&blobroot, MYF(0));
+  return 0;
+}
+
+
 bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info,
 					   uint table_changes)
 {

=== modified file 'storage/csv/ha_tina.h'
--- a/storage/csv/ha_tina.h	2012-01-13 14:50:02 +0000
+++ b/storage/csv/ha_tina.h	2012-04-07 13:58:46 +0000
@@ -81,7 +81,7 @@
   uchar chain_alloced;
   uint32 chain_size;
   uint local_data_file_version;  /* Saved version of the data file used */
-  bool records_is_known;
+  bool records_is_known, found_end_of_file;
   MEM_ROOT blobroot;
 
 private:
@@ -150,9 +150,12 @@
   int rnd_end();
   int repair(THD* thd, HA_CHECK_OPT* check_opt);
   /* This is required for SQL layer to know that we support autorepair */
+  bool auto_repair(int error) const
+  { return error == HA_ERR_CRASHED_ON_USAGE; }
   bool auto_repair() const { return 1; }
   void position(const uchar *record);
   int info(uint);
+  int reset();
   int extra(enum ha_extra_function operation);
   int delete_all_rows(void);
   int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);

=== modified file 'storage/example/ha_example.cc'
--- a/storage/example/ha_example.cc	2012-03-05 20:48:06 +0000
+++ b/storage/example/ha_example.cc	2012-03-27 23:04:46 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (c) 2004, 2010, Oracle and/or its affiliates
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
 
   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

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2012-01-16 19:16:35 +0000
+++ b/storage/federated/ha_federated.cc	2012-04-07 13:58:46 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004, 2010, Oracle and/or its affiliates
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
 
   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

=== modified file 'storage/heap/_check.c'
--- a/storage/heap/_check.c	2007-05-10 09:59:39 +0000
+++ b/storage/heap/_check.c	2012-03-23 16:11:29 +0000
@@ -110,8 +110,13 @@
   for (i=found=max_links=seek=0 ; i < records ; i++)
   {
     hash_info=hp_find_hash(&keydef->block,i);
-    if (hp_mask(hp_rec_hashnr(keydef, hash_info->ptr_to_rec),
-		blength,records) == i)
+    if (hash_info->hash_of_key != hp_rec_hashnr(keydef, hash_info->ptr_to_rec))
+    {
+      DBUG_PRINT("error",
+                 ("Found row with wrong hash_of_key at position %lu", i));
+      error= 1;
+    }
+    if (hp_mask(hash_info->hash_of_key, blength, records) == i)
     {
       found++;
       seek++;
@@ -119,9 +124,7 @@
       while ((hash_info=hash_info->next_key) && found < records + 1)
       {
 	seek+= ++links;
-	if ((rec_link = hp_mask(hp_rec_hashnr(keydef, hash_info->ptr_to_rec),
-			        blength, records))
-	    != i)
+	if ((rec_link= hp_mask(hash_info->hash_of_key, blength, records)) != i)
 	{
 	  DBUG_PRINT("error",
                      ("Record in wrong link: Link %lu  Record: 0x%lx  Record-link %lu",
@@ -147,14 +150,14 @@
     error=1;
   }
   DBUG_PRINT("info",
-	     ("records: %ld   seeks: %lu   max links: %lu   hitrate: %.2f   "
-              "buckets: %lu",
-	      records,seek,max_links,
+	     ("key: %u  records: %ld  seeks: %lu  max links: %lu  "
+              "hitrate: %.2f  buckets: %lu",
+	      keynr, records,seek,max_links,
 	      (float) seek / (float) (records ? records : 1), 
               hash_buckets_found));
   if (print_status)
-    printf("Key: %d  records: %ld   seeks: %lu   max links: %lu   "
-           "hitrate: %.2f   buckets: %lu\n",
+    printf("Key: %u  records: %ld  seeks: %lu  max links: %lu  "
+           "hitrate: %.2f  buckets: %lu\n",
 	   keynr, records, seek, max_links,
 	   (float) seek / (float) (records ? records : 1), 
            hash_buckets_found);

=== modified file 'storage/heap/heapdef.h'
--- a/storage/heap/heapdef.h	2011-06-30 15:46:53 +0000
+++ b/storage/heap/heapdef.h	2012-03-24 17:21:22 +0000
@@ -48,6 +48,7 @@
 {
   struct st_hp_hash_info *next_key;
   uchar *ptr_to_rec;
+  ulong hash_of_key;
 } HASH_INFO;
 
 typedef struct {

=== modified file 'storage/heap/hp_create.c'
--- a/storage/heap/hp_create.c	2012-01-13 14:50:02 +0000
+++ b/storage/heap/hp_create.c	2012-04-07 13:58:46 +0000
@@ -250,12 +250,20 @@
     max_records= 1000;			/* As good as quess as anything */
   recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
   records_in_block= max_records / 10;
-  if (records_in_block < 10 && max_records)
+
+  /*
+    We don't want too few records_in_block as otherwise the overhead of
+    of the HP_PTRS block will be too notable
+  */
+  records_in_block= min(1000, max_records);
+  if (records_in_block < 10)
     records_in_block= 10;
-  if (!records_in_block || records_in_block*recbuffer >
+
+  /* The + 1 is there to ensure that we get at least 1 row per level */
+  if (records_in_block*recbuffer >
       (my_default_record_cache_size-sizeof(HP_PTRS)*HP_MAX_LEVELS))
     records_in_block= (my_default_record_cache_size - sizeof(HP_PTRS) *
-		      HP_MAX_LEVELS) / recbuffer + 1;
+                       HP_MAX_LEVELS) / recbuffer + 1;
   block->records_in_block= records_in_block;
   block->recbuffer= recbuffer;
   block->last_allocated= 0L;

=== modified file 'storage/heap/hp_delete.c'
--- a/storage/heap/hp_delete.c	2011-03-09 13:47:59 +0000
+++ b/storage/heap/hp_delete.c	2012-03-23 16:11:29 +0000
@@ -149,8 +149,9 @@
   else if (pos->next_key)
   {
     empty=pos->next_key;
-    pos->ptr_to_rec=empty->ptr_to_rec;
-    pos->next_key=empty->next_key;
+    pos->ptr_to_rec=  empty->ptr_to_rec;
+    pos->next_key=    empty->next_key;
+    pos->hash_of_key= empty->hash_of_key;
   }
   else
     keyinfo->hash_buckets--;
@@ -159,7 +160,7 @@
     DBUG_RETURN (0);
 
   /* Move the last key (lastpos) */
-  lastpos_hashnr = hp_rec_hashnr(keyinfo, lastpos->ptr_to_rec);
+  lastpos_hashnr= lastpos->hash_of_key;
   /* pos is where lastpos should be */
   pos=hp_find_hash(&keyinfo->block, hp_mask(lastpos_hashnr, share->blength,
 					    share->records));
@@ -168,7 +169,7 @@
     empty[0]=lastpos[0];
     DBUG_RETURN(0);
   }
-  pos_hashnr = hp_rec_hashnr(keyinfo, pos->ptr_to_rec);
+  pos_hashnr= pos->hash_of_key;
   /* pos3 is where the pos should be */
   pos3= hp_find_hash(&keyinfo->block,
 		     hp_mask(pos_hashnr, share->blength, share->records));

=== modified file 'storage/heap/hp_hash.c'
--- a/storage/heap/hp_hash.c	2012-01-13 14:50:02 +0000
+++ b/storage/heap/hp_hash.c	2012-03-24 17:21:22 +0000
@@ -148,8 +148,8 @@
       {
 	flag=0;					/* Reset flag */
 	if (hp_find_hash(&keyinfo->block,
-			 hp_mask(hp_rec_hashnr(keyinfo, pos->ptr_to_rec),
-				  share->blength, share->records)) != pos)
+			 hp_mask(pos->hash_of_key,
+                                 share->blength, share->records)) != pos)
 	  break;				/* Wrong link */
       }
     }
@@ -299,7 +299,9 @@
       }
     }
   }
+#ifdef ONLY_FOR_HASH_DEBUGGING
   DBUG_PRINT("exit", ("hash: 0x%lx", nr));
+#endif
   return((ulong) nr);
 }
 
@@ -366,7 +368,9 @@
       }
     }
   }
+#ifdef ONLY_FOR_HASH_DEBUGGING
   DBUG_PRINT("exit", ("hash: 0x%lx", nr));
+#endif
   return(nr);
 }
 
@@ -437,7 +441,9 @@
       }
     }
   }
+#ifdef ONLY_FOR_HASH_DEBUGGING
   DBUG_PRINT("exit", ("hash: 0x%lx", nr));
+#endif
   return(nr);
 }
 
@@ -490,7 +496,9 @@
       }
     }
   }
+#ifdef ONLY_FOR_HASH_DEBUGGING
   DBUG_PRINT("exit", ("hash: 0x%lx", nr));
+#endif
   return(nr);
 }
 

=== modified file 'storage/heap/hp_info.c'
--- a/storage/heap/hp_info.c	2011-09-27 12:08:51 +0000
+++ b/storage/heap/hp_info.c	2012-02-15 16:21:38 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2004 MySQL AB
+/* Copyright (c) 2000, 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

=== modified file 'storage/heap/hp_test2.c'
--- a/storage/heap/hp_test2.c	2012-01-13 14:50:02 +0000
+++ b/storage/heap/hp_test2.c	2012-03-24 17:21:22 +0000
@@ -65,7 +65,7 @@
   get_options(argc,argv);
 
   bzero(&hp_create_info, sizeof(hp_create_info));
-  hp_create_info.max_table_size= 1024L*1024L;
+  hp_create_info.max_table_size= 2*1024L*1024L;
   hp_create_info.keys= keys;
   hp_create_info.keydef= keyinfo;
   hp_create_info.reclength= reclength;
@@ -636,7 +636,7 @@
     case 'V':
     case 'I':
     case '?':
-      printf("%s  Ver 1.1 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE);
+      printf("%s  Ver 1.2 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE);
       puts("TCX Datakonsult AB, by Monty, for your professional use\n");
       printf("Usage: %s [-?ABIKLsWv] [-m#] [-t#]\n",progname);
       exit(0);

=== modified file 'storage/heap/hp_write.c'
--- a/storage/heap/hp_write.c	2012-01-13 14:50:02 +0000
+++ b/storage/heap/hp_write.c	2012-04-07 13:58:46 +0000
@@ -105,7 +105,7 @@
 		    uchar *recpos)
 {
   heap_rb_param custom_arg;
-  uint old_allocated;
+  size_t old_allocated;
 
   custom_arg.keyseg= keyinfo->seg;
   custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
@@ -152,6 +152,13 @@
     if ((info->records > info->max_records && info->max_records) ||
         (info->data_length + info->index_length >= info->max_table_size))
     {
+      DBUG_PRINT("error",
+                 ("record file full. records: %u  max_records: %lu  "
+                  "data_length: %llu  index_length: %llu  "
+                  "max_table_size: %llu",
+                  info->records, info->max_records,
+                  info->data_length, info->index_length,
+                  info->max_table_size));
       my_errno=HA_ERR_RECORD_FILE_FULL;
       DBUG_RETURN(NULL);
     }
@@ -198,6 +205,7 @@
   HP_SHARE *share = info->s;
   int flag;
   ulong halfbuff,hashnr,first_index;
+  ulong UNINIT_VAR(hash_of_key), UNINIT_VAR(hash_of_key2);
   uchar *UNINIT_VAR(ptr_to_rec),*UNINIT_VAR(ptr_to_rec2);
   HASH_INFO *empty,*UNINIT_VAR(gpos),*UNINIT_VAR(gpos2),*pos;
   DBUG_ENTER("hp_write_key");
@@ -228,7 +236,7 @@
   {
     do
     {
-      hashnr = hp_rec_hashnr(keyinfo, pos->ptr_to_rec);
+      hashnr = pos->hash_of_key;
       if (flag == 0)
       {
         /* 
@@ -260,7 +268,6 @@
 	    flag=LOWFIND | HIGHFIND;
 	    /* key shall be moved to the current empty position */
 	    gpos=empty;
-	    ptr_to_rec=pos->ptr_to_rec;
 	    empty=pos;				/* This place is now free */
 	  }
 	  else
@@ -271,7 +278,6 @@
             */
 	    flag=LOWFIND | LOWUSED;
 	    gpos=pos;
-	    ptr_to_rec=pos->ptr_to_rec;
 	  }
 	}
 	else
@@ -280,13 +286,15 @@
 	  if (!(flag & LOWUSED))
 	  {
 	    /* Change link of previous lower-list key */
-	    gpos->ptr_to_rec=ptr_to_rec;
-	    gpos->next_key=pos;
+	    gpos->ptr_to_rec=  ptr_to_rec;
+	    gpos->next_key=    pos;
+            gpos->hash_of_key= hash_of_key;
 	    flag= (flag & HIGHFIND) | (LOWFIND | LOWUSED);
 	  }
 	  gpos=pos;
-	  ptr_to_rec=pos->ptr_to_rec;
 	}
+        ptr_to_rec=  pos->ptr_to_rec;
+        hash_of_key= pos->hash_of_key;
       }
       else
       {
@@ -297,20 +305,21 @@
 	  /* key shall be moved to the last (empty) position */
 	  gpos2= empty;
           empty= pos;
-	  ptr_to_rec2=pos->ptr_to_rec;
 	}
 	else
 	{
 	  if (!(flag & HIGHUSED))
 	  {
 	    /* Change link of previous upper-list key and save */
-	    gpos2->ptr_to_rec=ptr_to_rec2;
-	    gpos2->next_key=pos;
+	    gpos2->ptr_to_rec=  ptr_to_rec2;
+	    gpos2->next_key=    pos;
+            gpos2->hash_of_key= hash_of_key2;
 	    flag= (flag & LOWFIND) | (HIGHFIND | HIGHUSED);
 	  }
 	  gpos2=pos;
-	  ptr_to_rec2=pos->ptr_to_rec;
 	}
+        ptr_to_rec2=  pos->ptr_to_rec;
+        hash_of_key2= pos->hash_of_key;
       }
     }
     while ((pos=pos->next_key));
@@ -326,23 +335,27 @@
 
     if ((flag & (LOWFIND | LOWUSED)) == LOWFIND)
     {
-      gpos->ptr_to_rec=ptr_to_rec;
-      gpos->next_key=0;
+      gpos->ptr_to_rec=  ptr_to_rec;
+      gpos->hash_of_key= hash_of_key;
+      gpos->next_key=    0;
     }
     if ((flag & (HIGHFIND | HIGHUSED)) == HIGHFIND)
     {
-      gpos2->ptr_to_rec=ptr_to_rec2;
-      gpos2->next_key=0;
+      gpos2->ptr_to_rec=  ptr_to_rec2;
+      gpos2->hash_of_key= hash_of_key2;
+      gpos2->next_key=    0;
     }
   }
   /* Check if we are at the empty position */
 
-  pos=hp_find_hash(&keyinfo->block, hp_mask(hp_rec_hashnr(keyinfo, record),
-					 share->blength, share->records + 1));
+  hash_of_key= hp_rec_hashnr(keyinfo, record);
+  pos=hp_find_hash(&keyinfo->block,
+                   hp_mask(hash_of_key, share->blength, share->records + 1));
   if (pos == empty)
   {
-    pos->ptr_to_rec=recpos;
-    pos->next_key=0;
+    pos->ptr_to_rec=  recpos;
+    pos->hash_of_key= hash_of_key;
+    pos->next_key=    0;
     keyinfo->hash_buckets++;
   }
   else
@@ -350,18 +363,17 @@
     /* Check if more records in same hash-nr family */
     empty[0]=pos[0];
     gpos=hp_find_hash(&keyinfo->block,
-		      hp_mask(hp_rec_hashnr(keyinfo, pos->ptr_to_rec),
+		      hp_mask(pos->hash_of_key,
 			      share->blength, share->records + 1));
+
+    pos->ptr_to_rec=  recpos;
+    pos->hash_of_key= hash_of_key;
     if (pos == gpos)
-    {
-      pos->ptr_to_rec=recpos;
       pos->next_key=empty;
-    }
     else
     {
       keyinfo->hash_buckets++;
-      pos->ptr_to_rec=recpos;
-      pos->next_key=0;
+      pos->next_key= 0;
       hp_movelink(pos, gpos, empty);
     }
 

=== modified file 'storage/innobase/btr/btr0btr.c'
--- a/storage/innobase/btr/btr0btr.c	2012-03-09 07:06:59 +0000
+++ b/storage/innobase/btr/btr0btr.c	2012-04-10 06:28:13 +0000
@@ -11,8 +11,8 @@
 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
 
 *****************************************************************************/
 
@@ -56,11 +56,12 @@
 		(unsigned) buf_block_get_space(block),
 		(unsigned) buf_block_get_page_no(block),
 		index->name, index->table_name);
-	buf_page_print(buf_block_get_frame(block), 0);
 	if (block->page.zip.data) {
 		buf_page_print(block->page.zip.data,
-			       buf_block_get_zip_size(block));
+			       buf_block_get_zip_size(block),
+			       BUF_PAGE_PRINT_NO_CRASH);
 	}
+	buf_page_print(buf_block_get_frame(block), 0, 0);
 }
 
 #ifdef UNIV_BLOB_DEBUG
@@ -926,28 +927,31 @@
 /**************************************************************//**
 Allocates a new file page to be used in an index tree. NOTE: we assume
 that the caller has made the reservation for free extents!
- at return	new allocated block, x-latched; NULL if out of space */
-UNIV_INTERN
+ at retval NULL if no page could be allocated
+ at retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded
+(init_mtr == mtr, or the page was not previously freed in mtr)
+ at retval block (not allocated or initialized) otherwise */
+static __attribute__((nonnull, warn_unused_result))
 buf_block_t*
-btr_page_alloc(
-/*===========*/
+btr_page_alloc_low(
+/*===============*/
 	dict_index_t*	index,		/*!< in: index */
 	ulint		hint_page_no,	/*!< in: hint of a good page */
 	byte		file_direction,	/*!< in: direction where a possible
 					page split is made */
 	ulint		level,		/*!< in: level where the page is placed
 					in the tree */
-	mtr_t*		mtr)		/*!< in: mtr */
+	mtr_t*		mtr,		/*!< in/out: mini-transaction
+					for the allocation */
+	mtr_t*		init_mtr)	/*!< in/out: mtr or another
+					mini-transaction in which the
+					page should be initialized.
+					If init_mtr!=mtr, but the page
+					is already X-latched in mtr, do
+					not initialize the page. */
 {
 	fseg_header_t*	seg_header;
 	page_t*		root;
-	buf_block_t*	new_block;
-	ulint		new_page_no;
-
-	if (dict_index_is_ibuf(index)) {
-
-		return(btr_page_alloc_for_ibuf(index, mtr));
-	}
 
 	root = btr_root_get(index, mtr);
 
@@ -961,62 +965,96 @@
 	reservation for free extents, and thus we know that a page can
 	be allocated: */
 
-	new_page_no = fseg_alloc_free_page_general(seg_header, hint_page_no,
-						   file_direction, TRUE, mtr);
-	if (new_page_no == FIL_NULL) {
-
-		return(NULL);
-	}
-
-	new_block = buf_page_get(dict_index_get_space(index),
-				 dict_table_zip_size(index->table),
-				 new_page_no, RW_X_LATCH, mtr);
-	buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
+	return(fseg_alloc_free_page_general(
+		       seg_header, hint_page_no, file_direction,
+		       TRUE, mtr, init_mtr));
+}
+
+/**************************************************************//**
+Allocates a new file page to be used in an index tree. NOTE: we assume
+that the caller has made the reservation for free extents!
+ at retval NULL if no page could be allocated
+ at retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded
+(init_mtr == mtr, or the page was not previously freed in mtr)
+ at retval block (not allocated or initialized) otherwise */
+UNIV_INTERN
+buf_block_t*
+btr_page_alloc(
+/*===========*/
+	dict_index_t*	index,		/*!< in: index */
+	ulint		hint_page_no,	/*!< in: hint of a good page */
+	byte		file_direction,	/*!< in: direction where a possible
+					page split is made */
+	ulint		level,		/*!< in: level where the page is placed
+					in the tree */
+	mtr_t*		mtr,		/*!< in/out: mini-transaction
+					for the allocation */
+	mtr_t*		init_mtr)	/*!< in/out: mini-transaction
+					for x-latching and initializing
+					the page */
+{
+	buf_block_t*	new_block;
+
+	if (dict_index_is_ibuf(index)) {
+
+		return(btr_page_alloc_for_ibuf(index, mtr));
+	}
+
+	new_block = btr_page_alloc_low(
+		index, hint_page_no, file_direction, level, mtr, init_mtr);
+
+	if (new_block) {
+		buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
+	}
 
 	return(new_block);
 }
 
 /**************************************************************//**
 Gets the number of pages in a B-tree.
- at return	number of pages */
+ at return	number of pages, or ULINT_UNDEFINED if the index is unavailable */
 UNIV_INTERN
 ulint
 btr_get_size(
 /*=========*/
 	dict_index_t*	index,	/*!< in: index */
-	ulint		flag)	/*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */
+	ulint		flag,	/*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */
+	mtr_t*		mtr)	/*!< in/out: mini-transaction where index
+				is s-latched */
 {
 	fseg_header_t*	seg_header;
 	page_t*		root;
 	ulint		n;
 	ulint		dummy;
-	mtr_t		mtr;
-
-	mtr_start(&mtr);
-
-	mtr_s_lock(dict_index_get_lock(index), &mtr);
-
-	root = btr_root_get(index, &mtr);
+
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_S_LOCK));
+
+	if (index->page == FIL_NULL
+	    || index->to_be_dropped
+	    || *index->name == TEMP_INDEX_PREFIX) {
+		return(ULINT_UNDEFINED);
+	}
+
+	root = btr_root_get(index, mtr);
 
 	if (flag == BTR_N_LEAF_PAGES) {
 		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
 
-		fseg_n_reserved_pages(seg_header, &n, &mtr);
+		fseg_n_reserved_pages(seg_header, &n, mtr);
 
 	} else if (flag == BTR_TOTAL_SIZE) {
 		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
 
-		n = fseg_n_reserved_pages(seg_header, &dummy, &mtr);
+		n = fseg_n_reserved_pages(seg_header, &dummy, mtr);
 
 		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
 
-		n += fseg_n_reserved_pages(seg_header, &dummy, &mtr);
+		n += fseg_n_reserved_pages(seg_header, &dummy, mtr);
 	} else {
 		ut_error;
 	}
 
-	mtr_commit(&mtr);
-
 	return(n);
 }
 
@@ -1098,10 +1136,10 @@
 	buf_block_t*	block,	/*!< in: block to be freed, x-latched */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
-	ulint		level;
-
-	level = btr_page_get_level(buf_block_get_frame(block), mtr);
-
+	const page_t*	page	= buf_block_get_frame(block);
+	ulint		level	= btr_page_get_level(page, mtr);
+
+	ut_ad(fil_page_get_type(block->frame) == FIL_PAGE_INDEX);
 	btr_page_free_low(index, block, level, mtr);
 }
 
@@ -1215,9 +1253,11 @@
 			  != page_no)) {
 		rec_t*	print_rec;
 		fputs("InnoDB: Dump of the child page:\n", stderr);
-		buf_page_print(page_align(user_rec), 0);
+		buf_page_print(page_align(user_rec), 0,
+			       BUF_PAGE_PRINT_NO_CRASH);
 		fputs("InnoDB: Dump of the parent page:\n", stderr);
-		b