summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--VERSION2
-rw-r--r--client/CMakeLists.txt2
-rw-r--r--client/mysql_plugin.c2
-rw-r--r--client/mysqldump.c6
-rw-r--r--client/sql_string.cc.dontuse2
-rw-r--r--cmake/build_configurations/mysql_release.cmake2
-rw-r--r--cmake/install_macros.cmake2
-rw-r--r--extra/yassl/INSTALL103
-rw-r--r--extra/yassl/README121
-rw-r--r--extra/yassl/certs/ca-cert.pem71
-rw-r--r--extra/yassl/certs/ca-key.pem9
-rw-r--r--extra/yassl/certs/client-cert.derbin699 -> 782 bytes
-rw-r--r--extra/yassl/certs/client-cert.pem69
-rw-r--r--extra/yassl/certs/client-key.derbin318 -> 319 bytes
-rw-r--r--extra/yassl/certs/client-key.pem14
-rw-r--r--extra/yassl/certs/client-keyEnc.pem12
-rw-r--r--extra/yassl/certs/client-keyEnc3.pem12
-rw-r--r--extra/yassl/certs/dsa-cert.pem58
-rw-r--r--extra/yassl/certs/dsa512.derbin250 -> 249 bytes
-rw-r--r--extra/yassl/certs/server-cert.pem49
-rw-r--r--extra/yassl/certs/server-key.pem14
-rw-r--r--extra/yassl/certs/server-keyEnc.pem12
-rw-r--r--extra/yassl/certs/taoCert.txt12
-rw-r--r--extra/yassl/examples/client/client.cpp22
-rw-r--r--extra/yassl/examples/echoclient/echoclient.cpp6
-rw-r--r--extra/yassl/examples/echoserver/echoserver.cpp12
-rw-r--r--extra/yassl/examples/server/server.cpp17
-rw-r--r--extra/yassl/include/buffer.hpp10
-rw-r--r--extra/yassl/include/openssl/ssl.h51
-rw-r--r--extra/yassl/include/socket_wrapper.hpp4
-rw-r--r--extra/yassl/include/yassl_int.hpp62
-rw-r--r--extra/yassl/include/yassl_types.hpp30
-rw-r--r--extra/yassl/src/buffer.cpp12
-rw-r--r--extra/yassl/src/cert_wrapper.cpp6
-rw-r--r--extra/yassl/src/crypto_wrapper.cpp5
-rw-r--r--extra/yassl/src/handshake.cpp47
-rwxr-xr-x[-rw-r--r--]extra/yassl/src/make.bat0
-rw-r--r--extra/yassl/src/socket_wrapper.cpp23
-rw-r--r--extra/yassl/src/ssl.cpp123
-rw-r--r--extra/yassl/src/yassl.cpp6
-rw-r--r--extra/yassl/src/yassl_error.cpp16
-rw-r--r--extra/yassl/src/yassl_imp.cpp58
-rw-r--r--extra/yassl/src/yassl_int.cpp52
-rw-r--r--extra/yassl/taocrypt/CMakeLists.txt6
-rw-r--r--extra/yassl/taocrypt/README2
-rw-r--r--extra/yassl/taocrypt/benchmark/benchmark.cpp18
-rw-r--r--extra/yassl/taocrypt/benchmark/benchmark.dsp10
-rw-r--r--extra/yassl/taocrypt/benchmark/dh1024.derbin140 -> 138 bytes
-rw-r--r--extra/yassl/taocrypt/benchmark/dsa1024.derbin448 -> 445 bytes
-rwxr-xr-x[-rw-r--r--]extra/yassl/taocrypt/benchmark/make.bat0
-rw-r--r--extra/yassl/taocrypt/benchmark/rsa1024.derbin610 -> 606 bytes
-rw-r--r--extra/yassl/taocrypt/certs/client-cert.derbin0 -> 782 bytes
-rw-r--r--extra/yassl/taocrypt/certs/client-key.derbin0 -> 319 bytes
-rw-r--r--extra/yassl/taocrypt/certs/dh1024.dat1
-rw-r--r--extra/yassl/taocrypt/certs/dsa512.derbin0 -> 249 bytes
-rw-r--r--extra/yassl/taocrypt/include/asn.hpp1
-rw-r--r--extra/yassl/taocrypt/include/block.hpp12
-rw-r--r--extra/yassl/taocrypt/include/blowfish.hpp8
-rw-r--r--extra/yassl/taocrypt/include/des.hpp2
-rw-r--r--extra/yassl/taocrypt/include/file.hpp21
-rw-r--r--extra/yassl/taocrypt/include/hash.hpp4
-rw-r--r--extra/yassl/taocrypt/include/hc128.hpp63
-rw-r--r--extra/yassl/taocrypt/include/integer.hpp7
-rw-r--r--extra/yassl/taocrypt/include/kernelc.hpp12
-rw-r--r--extra/yassl/taocrypt/include/misc.hpp45
-rw-r--r--extra/yassl/taocrypt/include/modes.hpp7
-rw-r--r--extra/yassl/taocrypt/include/pwdbased.hpp5
-rw-r--r--extra/yassl/taocrypt/include/rabbit.hpp65
-rw-r--r--extra/yassl/taocrypt/include/rsa.hpp4
-rw-r--r--extra/yassl/taocrypt/include/runtime.hpp5
-rw-r--r--extra/yassl/taocrypt/include/types.hpp2
-rw-r--r--extra/yassl/taocrypt/mySTL/stdexcept.hpp3
-rw-r--r--extra/yassl/taocrypt/mySTL/vector.hpp7
-rw-r--r--extra/yassl/taocrypt/src/aes.cpp39
-rw-r--r--extra/yassl/taocrypt/src/aestables.cpp2
-rw-r--r--extra/yassl/taocrypt/src/algebra.cpp3
-rw-r--r--extra/yassl/taocrypt/src/arc4.cpp2
-rw-r--r--extra/yassl/taocrypt/src/asn.cpp222
-rw-r--r--extra/yassl/taocrypt/src/blowfish.cpp36
-rw-r--r--extra/yassl/taocrypt/src/coding.cpp16
-rw-r--r--extra/yassl/taocrypt/src/dsa.cpp3
-rw-r--r--extra/yassl/taocrypt/src/hash.cpp17
-rw-r--r--extra/yassl/taocrypt/src/hc128.cpp317
-rw-r--r--extra/yassl/taocrypt/src/integer.cpp100
-rwxr-xr-x[-rw-r--r--]extra/yassl/taocrypt/src/make.bat0
-rw-r--r--extra/yassl/taocrypt/src/md4.cpp2
-rw-r--r--extra/yassl/taocrypt/src/md5.cpp18
-rw-r--r--extra/yassl/taocrypt/src/misc.cpp22
-rw-r--r--extra/yassl/taocrypt/src/rabbit.cpp250
-rw-r--r--extra/yassl/taocrypt/src/random.cpp6
-rw-r--r--extra/yassl/taocrypt/src/ripemd.cpp16
-rw-r--r--extra/yassl/taocrypt/src/rsa.cpp7
-rw-r--r--extra/yassl/taocrypt/src/sha.cpp16
-rw-r--r--extra/yassl/taocrypt/src/template_instnt.cpp1
-rw-r--r--extra/yassl/taocrypt/src/twofish.cpp2
-rw-r--r--extra/yassl/taocrypt/taocrypt.dsp16
-rwxr-xr-x[-rw-r--r--]extra/yassl/taocrypt/test/make.bat0
-rw-r--r--extra/yassl/taocrypt/test/memory.cpp29
-rw-r--r--extra/yassl/taocrypt/test/test.cpp158
-rwxr-xr-x[-rw-r--r--]extra/yassl/testsuite/make.bat0
-rw-r--r--extra/yassl/testsuite/test.hpp95
-rw-r--r--extra/yassl/testsuite/testsuite.cpp8
-rw-r--r--include/m_ctype.h2
-rw-r--r--include/m_string.h4
-rw-r--r--include/my_global.h2
-rw-r--r--include/myisam.h4
-rw-r--r--include/mysql/plugin.h4
-rw-r--r--include/welcome_copyright_notice.h2
-rw-r--r--libmysql/CMakeLists.txt2
-rw-r--r--libmysqld/CMakeLists.txt2
-rw-r--r--libmysqld/examples/CMakeLists.txt2
-rw-r--r--mysql-test/CMakeLists.txt2
-rw-r--r--mysql-test/collections/default.experimental1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_id_pk.test3
-rw-r--r--mysql-test/extra/rpl_tests/rpl_multi_update.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_multi_update2.test3
-rw-r--r--mysql-test/extra/rpl_tests/rpl_multi_update3.test3
-rw-r--r--mysql-test/extra/rpl_tests/rpl_start_stop_slave.test3
-rw-r--r--mysql-test/include/mtr_check.sql2
-rw-r--r--mysql-test/include/not_crashrep.inc6
-rwxr-xr-xmysql-test/mysql-stress-test.pl16
-rwxr-xr-xmysql-test/mysql-test-run.pl4
-rw-r--r--mysql-test/r/bug13633383.result53
-rw-r--r--mysql-test/r/join_outer.result58
-rw-r--r--mysql-test/r/join_outer_jcl6.result58
-rw-r--r--mysql-test/r/multi_update.result7
-rw-r--r--mysql-test/r/myisam.result13
-rw-r--r--mysql-test/r/partition.result40
-rw-r--r--mysql-test/r/partition_error.result26
-rw-r--r--mysql-test/r/ps.result1
-rw-r--r--mysql-test/r/sp-bugs.result19
-rw-r--r--mysql-test/r/sp.result23
-rw-r--r--mysql-test/suite/binlog/r/binlog_unsafe.result55
-rw-r--r--mysql-test/suite/binlog/t/binlog_unsafe.test2
-rw-r--r--mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result2
-rw-r--r--mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result2
-rw-r--r--mysql-test/suite/innodb/r/group_commit_crash.result22
-rw-r--r--mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result22
-rw-r--r--mysql-test/suite/innodb/r/innodb-blob.result119
-rw-r--r--mysql-test/suite/innodb/r/innodb-index.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug11754376.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug13510739.result10
-rw-r--r--mysql-test/suite/innodb/t/group_commit_crash.test4
-rw-r--r--mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test4
-rw-r--r--mysql-test/suite/innodb/t/innodb-blob.test221
-rw-r--r--mysql-test/suite/innodb/t/innodb-index.test5
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug11754376.test16
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug13510739.test20
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug34300.test2
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug53756.test6
-rw-r--r--mysql-test/suite/rpl/r/rpl_auto_increment_11932.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_checksum.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_insert_id_pk.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_known_bugs_detection.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_log_pos.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_manual_change_index_file.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_multi_update.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_multi_update2.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_multi_update3.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_packet.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_rotate_logs.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result2
-rw-r--r--mysql-test/suite/rpl/t/rpl_auto_increment_11932.test5
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update2.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update3.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_optimize.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_semi_sync_event.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_timezone.test5
-rw-r--r--mysql-test/t/bug13633383.test82
-rw-r--r--mysql-test/t/events_restart.test1
-rw-r--r--mysql-test/t/join_outer.test56
-rw-r--r--mysql-test/t/multi_update.test5
-rw-r--r--mysql-test/t/myisam.test14
-rw-r--r--mysql-test/t/partition.test45
-rw-r--r--mysql-test/t/partition_error.test28
-rw-r--r--mysql-test/t/ps.test7
-rw-r--r--mysql-test/t/sp-bugs.test24
-rw-r--r--mysql-test/t/sp.test29
-rw-r--r--mysql-test/valgrind.supp2
-rw-r--r--mysys/charset-def.c3
-rw-r--r--mysys/my_addr_resolve.c2
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_symlink.c2
-rw-r--r--mysys/stacktrace.c2
-rw-r--r--packaging/WiX/custom_ui.wxs4
-rw-r--r--plugin/auth_examples/dialog_examples.c2
-rw-r--r--plugin/auth_examples/qa_auth_interface.c2
-rw-r--r--plugin/auth_examples/qa_auth_server.c2
-rw-r--r--plugin/daemon_example/CMakeLists.txt2
-rw-r--r--plugin/daemon_example/daemon_example.cc2
-rw-r--r--scripts/mysql_install_db.pl.in2
-rw-r--r--scripts/mysql_install_db.sh3
-rw-r--r--sql-common/my_time.c2
-rw-r--r--sql/filesort.cc149
-rw-r--r--sql/ha_ndbcluster.h3
-rw-r--r--sql/ha_ndbcluster_binlog.h3
-rw-r--r--sql/ha_partition.cc12
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item_cmpfunc.h4
-rw-r--r--sql/item_timefunc.cc4
-rw-r--r--sql/item_xmlfunc.cc3
-rw-r--r--sql/log_event.h3
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/mysqld.h2
-rw-r--r--sql/rpl_handler.h2
-rw-r--r--sql/rpl_injector.cc3
-rw-r--r--sql/rpl_mi.cc2
-rw-r--r--sql/rpl_mi.h3
-rw-r--r--sql/rpl_rli.cc3
-rw-r--r--sql/rpl_rli.h3
-rw-r--r--sql/set_var.h2
-rw-r--r--sql/share/errmsg-utf8.txt23
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/sp_cache.cc2
-rw-r--r--sql/sp_cache.h2
-rw-r--r--sql/sp_head.cc17
-rw-r--r--sql/sp_head.h12
-rw-r--r--sql/sql_admin.cc10
-rw-r--r--sql/sql_base.cc51
-rw-r--r--sql/sql_cache.cc3
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_connect.cc4
-rw-r--r--sql/sql_lex.cc5
-rw-r--r--sql/sql_lex.h18
-rw-r--r--sql/sql_parse.cc5
-rw-r--r--sql/sql_partition.cc39
-rw-r--r--sql/sql_partition.h2
-rw-r--r--sql/sql_plugin.cc2
-rw-r--r--sql/sql_prepare.cc4
-rw-r--r--sql/sql_profile.cc5
-rw-r--r--sql/sql_repl.cc20
-rw-r--r--sql/sql_select.cc12
-rw-r--r--sql/sql_show.cc10
-rw-r--r--sql/sql_table.cc13
-rw-r--r--sql/sql_udf.cc3
-rw-r--r--sql/sql_yacc.yy12
-rw-r--r--sql/sys_vars.cc2
-rw-r--r--sql/sys_vars.h2
-rw-r--r--storage/archive/ha_archive.cc9
-rw-r--r--storage/blackhole/ha_blackhole.cc2
-rw-r--r--storage/csv/ha_tina.cc3
-rw-r--r--storage/example/ha_example.cc3
-rw-r--r--storage/federated/ha_federated.cc2
-rw-r--r--storage/heap/hp_info.c2
-rw-r--r--storage/innobase/btr/btr0btr.c237
-rw-r--r--storage/innobase/btr/btr0cur.c251
-rw-r--r--storage/innobase/btr/btr0sea.c8
-rw-r--r--storage/innobase/buf/buf0buf.c28
-rw-r--r--storage/innobase/buf/buf0flu.c3
-rw-r--r--storage/innobase/fil/fil0fil.c31
-rw-r--r--storage/innobase/fsp/fsp0fsp.c403
-rw-r--r--storage/innobase/handler/ha_innodb.cc96
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.c58
-rw-r--r--storage/innobase/include/btr0btr.h29
-rw-r--r--storage/innobase/include/btr0btr.ic2
-rw-r--r--storage/innobase/include/btr0cur.h88
-rw-r--r--storage/innobase/include/btr0cur.ic29
-rw-r--r--storage/innobase/include/buf0buf.h44
-rw-r--r--storage/innobase/include/buf0buf.ic21
-rw-r--r--storage/innobase/include/fsp0fsp.h41
-rw-r--r--storage/innobase/include/log0log.h6
-rw-r--r--storage/innobase/include/mtr0mtr.h13
-rw-r--r--storage/innobase/include/mtr0mtr.ic7
-rw-r--r--storage/innobase/include/page0page.h43
-rw-r--r--storage/innobase/include/page0page.ic38
-rw-r--r--storage/innobase/include/sync0sync.h10
-rw-r--r--storage/innobase/include/trx0rec.ic7
-rw-r--r--storage/innobase/include/trx0undo.h13
-rw-r--r--storage/innobase/lock/lock0lock.c2
-rw-r--r--storage/innobase/log/log0log.c6
-rw-r--r--storage/innobase/mtr/mtr0mtr.c6
-rw-r--r--storage/innobase/page/page0cur.c23
-rw-r--r--storage/innobase/page/page0page.c68
-rw-r--r--storage/innobase/row/row0ins.c83
-rw-r--r--storage/innobase/row/row0merge.c35
-rw-r--r--storage/innobase/row/row0row.c29
-rw-r--r--storage/innobase/row/row0sel.c9
-rw-r--r--storage/innobase/row/row0upd.c64
-rw-r--r--storage/innobase/srv/srv0start.c5
-rw-r--r--storage/innobase/sync/sync0rw.c10
-rw-r--r--storage/innobase/sync/sync0sync.c16
-rw-r--r--storage/innobase/trx/trx0rec.c37
-rw-r--r--storage/innobase/trx/trx0sys.c34
-rw-r--r--storage/innobase/trx/trx0trx.c2
-rw-r--r--storage/innobase/trx/trx0undo.c43
-rw-r--r--storage/myisam/ft_boolean_search.c2
-rw-r--r--storage/myisam/ft_nlq_search.c3
-rw-r--r--storage/myisam/ha_myisam.cc6
-rw-r--r--storage/myisam/ha_myisam.h3
-rw-r--r--storage/myisam/mi_check.c21
-rw-r--r--storage/myisam/mi_packrec.c2
-rw-r--r--storage/myisam/mi_preload.c2
-rw-r--r--storage/myisam/myisamchk.c7
-rw-r--r--storage/myisam/myisamdef.h2
-rw-r--r--storage/myisam/sort.c18
-rw-r--r--storage/perfschema/ha_perfschema.cc2
-rw-r--r--storage/perfschema/pfs.cc2
-rw-r--r--storage/perfschema/table_ews_global_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ews_global_by_event_name.h2
-rw-r--r--storage/xtradb/row/row0merge.c2
-rw-r--r--storage/xtradb/row/row0sel.c4
-rw-r--r--strings/ctype-uca.c5
-rw-r--r--strings/ctype-ucs2.c4
-rw-r--r--strings/ctype-utf8.c5
-rw-r--r--strings/dtoa.c2
-rw-r--r--unittest/mysys/bitmap-t.c3
-rw-r--r--unittest/mysys/my_atomic-t.c2
311 files changed, 4853 insertions, 1848 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b6d1acb45f..79de29ee61b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/VERSION b/VERSION
index d05c93f6e73..aa87ee35b40 100644
--- a/VERSION
+++ b/VERSION
@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
-MYSQL_VERSION_PATCH=21
+MYSQL_VERSION_PATCH=22
MYSQL_VERSION_EXTRA=
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index fb8b123b9d6..3f53158572f 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -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
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index 53be700e601..f4e3111b7b7 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -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
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 44cbb36dc1a..6834d16bde7 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -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
@@ -2367,10 +2367,10 @@ static uint dump_routines_for_db(char *db)
{
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;
diff --git a/client/sql_string.cc.dontuse b/client/sql_string.cc.dontuse
index 8d1e19de71c..64219886dd0 100644
--- a/client/sql_string.cc.dontuse
+++ b/client/sql_string.cc.dontuse
@@ -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
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake
index 6760f2c9c63..87fe47cac12 100644
--- a/cmake/build_configurations/mysql_release.cmake
+++ b/cmake/build_configurations/mysql_release.cmake
@@ -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
diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake
index da22ec818f8..14e43ee5e95 100644
--- a/cmake/install_macros.cmake
+++ b/cmake/install_macros.cmake
@@ -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
diff --git a/extra/yassl/INSTALL b/extra/yassl/INSTALL
index 54caf7c190f..5458714e1e2 100644
--- a/extra/yassl/INSTALL
+++ b/extra/yassl/INSTALL
@@ -1,13 +1,19 @@
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
+Installation Instructions
+*************************
- This file is free documentation; the Free Software Foundation gives
+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 @@ debugging `configure').
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 @@ some point `config.cache' contains results you don't want to keep, you
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 @@ The simplest way to compile this package is:
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 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
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 @@ you can use the `configure' options `--x-includes=DIR' and
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 @@ where SYSTEM can have one of these forms:
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 @@ eventually be run) with `--host=TYPE'.
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 @@ A warning: not all `configure' scripts look for a site script.
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 @@ them in the `configure' command line, using `VAR=value'. For example:
./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'
diff --git a/extra/yassl/README b/extra/yassl/README
index 6c4d101efc0..7720a9453dd 100644
--- a/extra/yassl/README
+++ b/extra/yassl/README
@@ -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 @@ See libcurl build instructions below under 1.3.0 and note in 1.5.8.
- 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 @@ in the source and include files.
*********************
Contact: please send comments or questions to Todd A Ouska at todd@yassl.com
-and/or Larry Stefonic at larry@yassl.com or 425-741-6858.
+and/or Larry Stefonic at larry@yassl.com.
diff --git a/extra/yassl/certs/ca-cert.pem b/extra/yassl/certs/ca-cert.pem
index e353d118712..6a0cf898e53 100644
--- a/extra/yassl/certs/ca-cert.pem
+++ b/extra/yassl/certs/ca-cert.pem
@@ -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@yassl.com
+ Issuer: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info@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@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@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@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@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-----
diff --git a/extra/yassl/certs/ca-key.pem b/extra/yassl/certs/ca-key.pem
new file mode 100644
index 00000000000..45d7b149857
--- /dev/null
+++ b/extra/yassl/certs/ca-key.pem
@@ -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-----
diff --git a/extra/yassl/certs/client-cert.der b/extra/yassl/certs/client-cert.der
index c2a75119e54..9c2ef138bf6 100644
--- a/extra/yassl/certs/client-cert.der
+++ b/extra/yassl/certs/client-cert.der
Binary files differ
diff --git a/extra/yassl/certs/client-cert.pem b/extra/yassl/certs/client-cert.pem
index 4d2bbff7ca5..7acc9a850d5 100644
--- a/extra/yassl/certs/client-cert.pem
+++ b/extra/yassl/certs/client-cert.pem
@@ -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@yassl.com
+ Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=programming, CN=www.yassl.com/emailAddress=info@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@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@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@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@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-----
diff --git a/extra/yassl/certs/client-key.der b/extra/yassl/certs/client-key.der
index 6e8b432a07c..649406c4417 100644
--- a/extra/yassl/certs/client-key.der
+++ b/extra/yassl/certs/client-key.der
Binary files differ
diff --git a/extra/yassl/certs/client-key.pem b/extra/yassl/certs/client-key.pem
index 6898b2796fa..92c052fef84 100644
--- a/extra/yassl/certs/client-key.pem
+++ b/extra/yassl/certs/client-key.pem
@@ -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-----
diff --git a/extra/yassl/certs/client-keyEnc.pem b/extra/yassl/certs/client-keyEnc.pem
new file mode 100644
index 00000000000..f6b857fc48c
--- /dev/null
+++ b/extra/yassl/certs/client-keyEnc.pem
@@ -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-----
diff --git a/extra/yassl/certs/client-keyEnc3.pem b/extra/yassl/certs/client-keyEnc3.pem
new file mode 100644
index 00000000000..0097c0760a5
--- /dev/null
+++ b/extra/yassl/certs/client-keyEnc3.pem
@@ -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-----
diff --git a/extra/yassl/certs/dsa-cert.pem b/extra/yassl/certs/dsa-cert.pem
index 788d263bb9f..ed1138dad01 100644
--- a/extra/yassl/certs/dsa-cert.pem
+++ b/extra/yassl/certs/dsa-cert.pem
@@ -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@yassl.com
+ Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=testing, CN=www.yassl.com/emailAddress=info@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@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@yassl.com
Subject Public Key Info:
Public Key Algorithm: dsaEncryption
DSA Public Key:
@@ -37,32 +38,33 @@ Certificate:
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@yassl.com
- serial:00
+ DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/OU=testing/CN=www.yassl.com/emailAddress=info@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-----
diff --git a/extra/yassl/certs/dsa512.der b/extra/yassl/certs/dsa512.der
index fe79ccb612b..027bedeffb1 100644
--- a/extra/yassl/certs/dsa512.der
+++ b/extra/yassl/certs/dsa512.der
Binary files differ
diff --git a/extra/yassl/certs/server-cert.pem b/extra/yassl/certs/server-cert.pem
index 30608f5f65b..1ec53c02628 100644
--- a/extra/yassl/certs/server-cert.pem
+++ b/extra/yassl/certs/server-cert.pem
@@ -3,36 +3,37 @@ Certificate:
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@yassl.com
+ Issuer: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info@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@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@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-----
diff --git a/extra/yassl/certs/server-key.pem b/extra/yassl/certs/server-key.pem
index d6055c4cfd8..154d661b1df 100644
--- a/extra/yassl/certs/server-key.pem
+++ b/extra/yassl/certs/server-key.pem
@@ -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-----
diff --git a/extra/yassl/certs/server-keyEnc.pem b/extra/yassl/certs/server-keyEnc.pem
new file mode 100644
index 00000000000..d3500a1b647
--- /dev/null
+++ b/extra/yassl/certs/server-keyEnc.pem
@@ -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-----
diff --git a/extra/yassl/certs/taoCert.txt b/extra/yassl/certs/taoCert.txt
index 585293e4f2b..f1132c0b5b8 100644
--- a/extra/yassl/certs/taoCert.txt
+++ b/extra/yassl/certs/taoCert.txt
@@ -47,4 +47,16 @@ to convert rsa private PEM to DER :
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
+
diff --git a/extra/yassl/examples/client/client.cpp b/extra/yassl/examples/client/client.cpp
index a80a8c2f1a2..d05c31d4d63 100644
--- a/extra/yassl/examples/client/client.cpp
+++ b/extra/yassl/examples/client/client.cpp
@@ -36,15 +36,20 @@ void ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
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 @@ void client_test(void* args)
#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 @@ void client_test(void* args)
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 @@ void client_test(void* args)
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);
diff --git a/extra/yassl/examples/echoclient/echoclient.cpp b/extra/yassl/examples/echoclient/echoclient.cpp
index 787e554f8bf..c2b8ff66ac9 100644
--- a/extra/yassl/examples/echoclient/echoclient.cpp
+++ b/extra/yassl/examples/echoclient/echoclient.cpp
@@ -74,10 +74,10 @@ void echoclient_test(void* args)
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 @@ void echoclient_test(void* args)
break;
}
- if (SSL_read(ssl, reply, sizeof(reply)) > 0)
+ if (SSL_read(ssl, reply, sizeof(reply)) > 0)
fputs(reply, fout);
}
diff --git a/extra/yassl/examples/echoserver/echoserver.cpp b/extra/yassl/examples/echoserver/echoserver.cpp
index a3ba8c12c60..bd044e70e8b 100644
--- a/extra/yassl/examples/echoserver/echoserver.cpp
+++ b/extra/yassl/examples/echoserver/echoserver.cpp
@@ -93,11 +93,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
#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 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
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 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
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 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
if (SSL_write(ssl, command, echoSz) != echoSz)
EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed");
-
+
break;
}
command[echoSz] = 0;
diff --git a/extra/yassl/examples/server/server.cpp b/extra/yassl/examples/server/server.cpp
index 8b8066eace5..3fac40e88c4 100644
--- a/extra/yassl/examples/server/server.cpp
+++ b/extra/yassl/examples/server/server.cpp
@@ -35,15 +35,20 @@ void ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
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 @@ THREAD_RETURN YASSL_API server_test(void* args)
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 @@ THREAD_RETURN YASSL_API server_test(void* args)
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!";
diff --git a/extra/yassl/include/buffer.hpp b/extra/yassl/include/buffer.hpp
index a51bca9a630..2d7817a7ca2 100644
--- a/extra/yassl/include/buffer.hpp
+++ b/extra/yassl/include/buffer.hpp
@@ -46,12 +46,6 @@ typedef unsigned int uint;
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 @@ struct NoCheck {
* 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 @@ private:
* 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
diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h
index ba5fa51f34c..0d99888da88 100644
--- a/extra/yassl/include/openssl/ssl.h
+++ b/extra/yassl/include/openssl/ssl.h
@@ -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 @@ extern "C" {
#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 @@ extern "C" {
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 @@ RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*);
/* 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 @@ typedef struct BIO BIO;
-/* 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 @@ SSL* SSL_new(SSL_CTX*);
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 @@ enum { /* ssl Constants */
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 @@ enum { /* ssl Constants */
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);
diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp
index 308704c2af0..2372e64e56c 100644
--- a/extra/yassl/include/socket_wrapper.hpp
+++ b/extra/yassl/include/socket_wrapper.hpp
@@ -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 @@ public:
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();
diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp
index 433649c545b..e5ee00bc21c 100644
--- a/extra/yassl/include/yassl_int.hpp
+++ b/extra/yassl/include/yassl_int.hpp
@@ -168,7 +168,7 @@ private:
// openSSL X509 names
class X509_NAME {
- char* name_;
+ char* name_;
size_t sz_;
ASN1_STRING entry_;
public:
@@ -246,11 +246,11 @@ public:
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 @@ class SSL_CTX {
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 @@ class Buffers {
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 @@ public:
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 @@ public:
void deriveKeys();
void deriveTLSKeys();
void Send(const byte*, uint);
+ void SendWriteBuffered();
uint bufferedData();
uint get_SEQIncrement(bool);
diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp
index c73a54a7c15..a9e22833eb1 100644
--- a/extra/yassl/include/yassl_types.hpp
+++ b/extra/yassl/include/yassl_types.hpp
@@ -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 @@ namespace yaSSL {
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 opaque byte;
typedef unsigned int uint;
-
+
#ifdef USE_SYS_STL
// use system STL
#define STL_VECTOR_FILE <vector>
diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp
index a5028e7bb53..d885c953207 100644
--- a/extra/yassl/src/buffer.cpp
+++ b/extra/yassl/src/buffer.cpp
@@ -35,14 +35,6 @@ namespace yaSSL {
-// 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 @@ input_buffer::~input_buffer()
// 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 @@ void input_buffer::set_current(uint i)
// 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 @@ void output_buffer::set_current(uint c)
// 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 @@ const byte* output_buffer::get_buffer() const
// 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_++];
}
diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp
index d8660533f2e..7e73464001a 100644
--- a/extra/yassl/src/cert_wrapper.cpp
+++ b/extra/yassl/src/cert_wrapper.cpp
@@ -250,7 +250,8 @@ int CertManager::Validate()
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 @@ int CertManager::Validate()
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 @@ int CertManager::SetPrivateKey(const x509& key)
// Store OpenSSL type peer's cert
void CertManager::setPeerX509(X509* x)
{
- assert(peerX509_ == 0);
if (x == 0) return;
X509_NAME* issuer = x->GetIssuer();
diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp
index afb492c83c5..bdd5f60c4ea 100644
--- a/extra/yassl/src/crypto_wrapper.cpp
+++ b/extra/yassl/src/crypto_wrapper.cpp
@@ -954,10 +954,7 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)
}
}
// get blank line
- if (fgets(line,sizeof(line), file) == 0)
- {
- /* Impossible case */
- }
+ if (fgets(line, sizeof(line), file))
begin = ftell(file);
}
diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp
index 08fae4ac17d..c1ee61d043e 100644
--- a/extra/yassl/src/handshake.cpp
+++ b/extra/yassl/src/handshake.cpp
@@ -50,7 +50,7 @@ void buildClientHello(SSL& ssl, ClientHello& hello)
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 @@ void ProcessOldClientHello(input_buffer& input, SSL& ssl)
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 @@ int DoProcessReply(SSL& ssl)
{
// 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 @@ int DoProcessReply(SSL& ssl)
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 @@ int DoProcessReply(SSL& ssl)
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 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
if (ssl.GetError()) return;
ServerKeyExchange sk(ssl);
sk.build(ssl);
+ if (ssl.GetError()) return;
RecordLayerHeader rlHeader;
HandShakeHeader hsHeader;
@@ -875,8 +876,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
// 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 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
}
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,12 +929,22 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
// send data
int sendData(SSL& ssl, const void* buffer, int sz)
{
+ 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;
- int sent = 0;
for (;;) {
int len = min(sz - sent, MAX_RECORD_SIZE);
@@ -943,6 +953,8 @@ int sendData(SSL& ssl, const void* buffer, int sz)
Data data;
+ if (sent == sz) break;
+
if (ssl.CompressionOn()) {
if (Compress(static_cast<const opaque*>(buffer) + sent, len,
tmp) == -1) {
@@ -957,9 +969,14 @@ int sendData(SSL& ssl, const void* buffer, int sz)
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 @@ int receiveData(SSL& ssl, Data& data, bool peek)
if (peek)
ssl.PeekData(data);
else
- ssl.fillData(data);
+ ssl.fillData(data);
ssl.useLog().ShowData(data.get_length());
if (ssl.GetError()) return -1;
diff --git a/extra/yassl/src/make.bat b/extra/yassl/src/make.bat
index cccd11dbd17..cccd11dbd17 100644..100755
--- a/extra/yassl/src/make.bat
+++ b/extra/yassl/src/make.bat
diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp
index 3cf6c14c4b3..d88df13c08e 100644
--- a/extra/yassl/src/socket_wrapper.cpp
+++ b/extra/yassl/src/socket_wrapper.cpp
@@ -109,19 +109,28 @@ uint Socket::get_ready() const
}
-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 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags)
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);
diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp
index 05c260e80ca..8401798534b 100644
--- a/extra/yassl/src/ssl.cpp
+++ b/extra/yassl/src/ssl.cpp
@@ -252,60 +252,73 @@ int SSL_connect(SSL* ssl)
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->getCrypto().get_certManager().sendVerify())
+ sendCertificate(*ssl);
- if (!ssl->getSecurity().get_resuming())
- sendClientKeyExchange(*ssl);
+ if (!ssl->getSecurity().get_resuming())
+ sendClientKeyExchange(*ssl);
- if(ssl->getCrypto().get_certManager().sendVerify())
- sendCertificateVerify(*ssl);
+ if(ssl->getCrypto().get_certManager().sendVerify())
+ sendCertificateVerify(*ssl);
- sendChangeCipher(*ssl);
- sendFinished(*ssl, client_end);
- ssl->flushBuffer();
+ 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 @@ int SSL_accept(SSL* ssl)
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);
+ sendServerHello(*ssl);
- if (!ssl->getSecurity().get_resuming()) {
- sendCertificate(*ssl);
+ if (!ssl->getSecurity().get_resuming()) {
+ sendCertificate(*ssl);
- if (ssl->getSecurity().get_connection().send_server_key_)
- sendServerKeyExchange(*ssl);
+ if (ssl->getSecurity().get_connection().send_server_key_)
+ sendServerKeyExchange(*ssl);
- if(ssl->getCrypto().get_certManager().verifyPeer())
- sendCertificateRequest(*ssl);
+ if(ssl->getCrypto().get_certManager().verifyPeer())
+ sendCertificateRequest(*ssl);
- sendServerHelloDone(*ssl);
- ssl->flushBuffer();
+ sendServerHelloDone(*ssl);
+ ssl->flushBuffer();
}
if (!ssl->GetError())
@@ -359,40 +381,40 @@ int SSL_accept(SSL* ssl)
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 @@ int EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt,
ivLeft -= store;
}
}
- assert(keyOutput == (keyLen + ivLen));
return keyOutput;
}
diff --git a/extra/yassl/src/yassl.cpp b/extra/yassl/src/yassl.cpp
index 815277ce6f3..99a1da5371b 100644
--- a/extra/yassl/src/yassl.cpp
+++ b/extra/yassl/src/yassl.cpp
@@ -69,13 +69,13 @@ void SetUpBase(Base& base, ConnectionEnd end, SOCKET_T s)
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);
diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp
index 2ff30f436f5..e55c10c68c0 100644
--- a/extra/yassl/src/yassl_error.cpp
+++ b/extra/yassl/src/yassl_error.cpp
@@ -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 @@ void SetErrorString(unsigned long error, char* buffer)
{
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 @@ void SetErrorString(unsigned long error, char* buffer)
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 @@ void SetErrorString(unsigned long error, char* buffer)
case badVersion_error :
strncpy(buffer, "protocol version mismatch", max);
break;
-
+
case compress_error :
strncpy(buffer, "compression error", max);
break;
@@ -148,6 +154,10 @@ void SetErrorString(unsigned long error, char* buffer)
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;
diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp
index 15d7ec5fb21..c0ef23a4e94 100644
--- a/extra/yassl/src/yassl_imp.cpp
+++ b/extra/yassl/src/yassl_imp.cpp
@@ -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 @@ void ClientDiffieHellmanPublic::build(SSL& ssl)
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 @@ void DH_Server::build(SSL& ssl)
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 @@ Data::Data(uint16 len, opaque* b)
void Data::SetData(uint16 len, const opaque* buffer)
{
- assert(write_buffer_ == 0);
-
length_ = len;
write_buffer_ = buffer;
}
@@ -992,6 +989,11 @@ void Data::Process(input_buffer& input, SSL& ssl)
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 @@ void Data::Process(input_buffer& input, SSL& ssl)
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 @@ void Certificate::Process(input_buffer& input, SSL& ssl)
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 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
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 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
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 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
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 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
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 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
// 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 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
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 @@ void Finished::Process(input_buffer& input, SSL& ssl)
// 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)) {
diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp
index 3d553e37337..65e17b01544 100644
--- a/extra/yassl/src/yassl_int.cpp
+++ b/extra/yassl/src/yassl_int.cpp
@@ -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 @@ SSL::SSL(SSL_CTX* ctx)
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::flushBuffer()
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 @@ void SSL::matchSuite(const opaque* peer, uint length)
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::addBuffer(output_buffer* b)
void SSL_SESSION::CopyX509(X509* x)
{
- assert(peerX509_ == 0);
if (x == 0) return;
X509_NAME* issuer = x->GetIssuer();
@@ -2232,7 +2251,7 @@ Hashes& sslHashes::use_certVerify()
}
-Buffers::Buffers() : rawInput_(0)
+Buffers::Buffers() : prevSent(0), plainSz(0), rawInput_(0), output_(0)
{}
@@ -2243,12 +2262,18 @@ Buffers::~Buffers()
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 @@ input_buffer* Buffers::TakeRawInput()
}
+output_buffer* Buffers::TakeOutput()
+{
+ output_buffer* ret = output_;
+ output_ = 0;
+
+ return ret;
+}
+
+
const Buffers::inputList& Buffers::getData() const
{
return dataList_;
@@ -2536,14 +2570,12 @@ ASN1_STRING* StringHolder::GetString()
// 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;
}
diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt
index 750731a0449..10ed614445e 100644
--- a/extra/yassl/taocrypt/CMakeLists.txt
+++ b/extra/yassl/taocrypt/CMakeLists.txt
@@ -20,12 +20,14 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
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)
diff --git a/extra/yassl/taocrypt/README b/extra/yassl/taocrypt/README
index 0a7ff301786..bd786b7ce54 100644
--- a/extra/yassl/taocrypt/README
+++ b/extra/yassl/taocrypt/README
@@ -21,7 +21,7 @@ Stream Ciphers: ARC4
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
diff --git a/extra/yassl/taocrypt/benchmark/benchmark.cpp b/extra/yassl/taocrypt/benchmark/benchmark.cpp
index 1d38b080d0d..6ed7351a56b 100644
--- a/extra/yassl/taocrypt/benchmark/benchmark.cpp
+++ b/extra/yassl/taocrypt/benchmark/benchmark.cpp
@@ -103,7 +103,7 @@ void bench_des()
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 @@ void bench_aes(bool show)
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 @@ void bench_twofish()
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 @@ void bench_blowfish()
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 @@ void bench_arc4()
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 @@ void bench_md5()
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 @@ void bench_sha()
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 @@ void bench_ripemd()
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 @@ void bench_rsa()
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();
diff --git a/extra/yassl/taocrypt/benchmark/benchmark.dsp b/extra/yassl/taocrypt/benchmark/benchmark.dsp
index 878dc2b2783..449299a1c8d 100644
--- a/extra/yassl/taocrypt/benchmark/benchmark.dsp
+++ b/extra/yassl/taocrypt/benchmark/benchmark.dsp
@@ -49,8 +49,8 @@ BSC32=bscmake.exe
# 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 @@ LINK32=link.exe
# 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 @@ BSC32=bscmake.exe
# 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
diff --git a/extra/yassl/taocrypt/benchmark/dh1024.der b/extra/yassl/taocrypt/benchmark/dh1024.der
index 1a85d90f3f7..09f81ee14c1 100644
--- a/extra/yassl/taocrypt/benchmark/dh1024.der
+++ b/extra/yassl/taocrypt/benchmark/dh1024.der
Binary files differ
diff --git a/extra/yassl/taocrypt/benchmark/dsa1024.der b/extra/yassl/taocrypt/benchmark/dsa1024.der
index 1fcb37fad6a..3a6dfca4b8f 100644
--- a/extra/yassl/taocrypt/benchmark/dsa1024.der
+++ b/extra/yassl/taocrypt/benchmark/dsa1024.der
Binary files differ
diff --git a/extra/yassl/taocrypt/benchmark/make.bat b/extra/yassl/taocrypt/benchmark/make.bat
index 1457521bce9..1457521bce9 100644..100755
--- a/extra/yassl/taocrypt/benchmark/make.bat
+++ b/extra/yassl/taocrypt/benchmark/make.bat
diff --git a/extra/yassl/taocrypt/benchmark/rsa1024.der b/extra/yassl/taocrypt/benchmark/rsa1024.der
index 8fc91814472..5ba3fbe6c9c 100644
--- a/extra/yassl/taocrypt/benchmark/rsa1024.der
+++ b/extra/yassl/taocrypt/benchmark/rsa1024.der
Binary files differ
diff --git a/extra/yassl/taocrypt/certs/client-cert.der b/extra/yassl/taocrypt/certs/client-cert.der
new file mode 100644
index 00000000000..9c2ef138bf6
--- /dev/null
+++ b/extra/yassl/taocrypt/certs/client-cert.der
Binary files differ
diff --git a/extra/yassl/taocrypt/certs/client-key.der b/extra/yassl/taocrypt/certs/client-key.der
new file mode 100644
index 00000000000..649406c4417
--- /dev/null
+++ b/extra/yassl/taocrypt/certs/client-key.der
Binary files differ
diff --git a/extra/yassl/taocrypt/certs/dh1024.dat b/extra/yassl/taocrypt/certs/dh1024.dat
new file mode 100644
index 00000000000..86a95518278
--- /dev/null
+++ b/extra/yassl/taocrypt/certs/dh1024.dat
@@ -0,0 +1 @@
+30818702818100DA9A18547FF03B385CC16508C173A7EF4EB61CB40EF8FEF3B31F145051676166BCDC3FE6B799FC394D08C26385F9413F896E09117E46209D6923602683CEA100924A6EE695281775C619DAA94EA8CB3691B4275B0183F1D39639EBC92995FE645D6C1BC28D409E585549BBD2C5DCDD6C208B04EADD8B7A6D997F72CBAD88390F020102 \ No newline at end of file
diff --git a/extra/yassl/taocrypt/certs/dsa512.der b/extra/yassl/taocrypt/certs/dsa512.der
new file mode 100644
index 00000000000..027bedeffb1
--- /dev/null
+++ b/extra/yassl/taocrypt/certs/dsa512.der
Binary files differ
diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp
index ece7140741a..c20387d86c7 100644
--- a/extra/yassl/taocrypt/include/asn.hpp
+++ b/extra/yassl/taocrypt/include/asn.hpp
@@ -167,6 +167,7 @@ public:
void Decode(RSA_PublicKey&);
private:
void ReadHeader();
+ void ReadHeaderOpenSSL();
};
diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp
index 9885c44d2c9..77017e9d5e4 100644
--- a/extra/yassl/taocrypt/include/block.hpp
+++ b/extra/yassl/taocrypt/include/block.hpp
@@ -61,10 +61,6 @@ public:
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 @@ public:
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 @@ public:
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; }
diff --git a/extra/yassl/taocrypt/include/blowfish.hpp b/extra/yassl/taocrypt/include/blowfish.hpp
index e03ed41aab8..e868872d3cf 100644
--- a/extra/yassl/taocrypt/include/blowfish.hpp
+++ b/extra/yassl/taocrypt/include/blowfish.hpp
@@ -59,11 +59,11 @@ public:
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;
diff --git a/extra/yassl/taocrypt/include/des.hpp b/extra/yassl/taocrypt/include/des.hpp
index f99a289392f..2bc41fc2628 100644
--- a/extra/yassl/taocrypt/include/des.hpp
+++ b/extra/yassl/taocrypt/include/des.hpp
@@ -84,7 +84,7 @@ private:
// 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);
diff --git a/extra/yassl/taocrypt/include/file.hpp b/extra/yassl/taocrypt/include/file.hpp
index e22040f60f0..c340c4fa3ea 100644
--- a/extra/yassl/taocrypt/include/file.hpp
+++ b/extra/yassl/taocrypt/include/file.hpp
@@ -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 @@ public:
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_; }
diff --git a/extra/yassl/taocrypt/include/hash.hpp b/extra/yassl/taocrypt/include/hash.hpp
index fa5f6c04720..4ebc82e073d 100644
--- a/extra/yassl/taocrypt/include/hash.hpp
+++ b/extra/yassl/taocrypt/include/hash.hpp
@@ -63,8 +63,8 @@ protected:
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;
diff --git a/extra/yassl/taocrypt/include/hc128.hpp b/extra/yassl/taocrypt/include/hc128.hpp
new file mode 100644
index 00000000000..d1cf5f075f2
--- /dev/null
+++ b/extra/yassl/taocrypt/include/hc128.hpp
@@ -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
+
diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp
index 186d62bb866..256573cf622 100644
--- a/extra/yassl/taocrypt/include/integer.hpp
+++ b/extra/yassl/taocrypt/include/integer.hpp
@@ -110,13 +110,6 @@ namespace TaoCrypt {
#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
diff --git a/extra/yassl/taocrypt/include/kernelc.hpp b/extra/yassl/taocrypt/include/kernelc.hpp
index daa3762d5dd..5bdf1cffa3f 100644
--- a/extra/yassl/taocrypt/include/kernelc.hpp
+++ b/extra/yassl/taocrypt/include/kernelc.hpp
@@ -30,17 +30,5 @@ extern "C" void* memcpy(void*, const void*, size_t);
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
diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp
index a375b17eb1e..b6925f916f8 100644
--- a/extra/yassl/taocrypt/include/misc.hpp
+++ b/extra/yassl/taocrypt/include/misc.hpp
@@ -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 @@ void CleanUp();
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 @@ inline bool IsPowerOf2(T n)
template <class T1, class T2>
inline T2 ModPowerOf2(T1 a, T2 b)
{
- assert(IsPowerOf2(b));
return T2(a) & (b-1);
}
@@ -409,14 +407,12 @@ inline bool IsAligned(const void* p, T* dummy = 0) // VC60 workaround
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 <class T> inline T rotrFixed(T x, unsigned int y)
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 @@ template<> inline word32 rotrFixed(word32 x, word32 y)
#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 @@ inline word64 ByteReverse(word64 value)
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 @@ inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,
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 @@ inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,
#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 @@ template <class T>
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 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte* block, T value,
{
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 T SafeLeftShift(T value)
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 @@ word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits)
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--)
diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp
index 2285bd0e845..5fd36b80d3e 100644
--- a/extra/yassl/taocrypt/include/modes.hpp
+++ b/extra/yassl/taocrypt/include/modes.hpp
@@ -61,9 +61,7 @@ public:
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 @@ inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz)
{
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
diff --git a/extra/yassl/taocrypt/include/pwdbased.hpp b/extra/yassl/taocrypt/include/pwdbased.hpp
index 5ece1a8f43b..f40a336e2c3 100644
--- a/extra/yassl/taocrypt/include/pwdbased.hpp
+++ b/extra/yassl/taocrypt/include/pwdbased.hpp
@@ -48,8 +48,9 @@ word32 PBKDF2_HMAC<T>::DeriveKey(byte* derived, word32 dLen, const byte* pwd,
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;
diff --git a/extra/yassl/taocrypt/include/rabbit.hpp b/extra/yassl/taocrypt/include/rabbit.hpp
new file mode 100644
index 00000000000..1e7276dd8ec
--- /dev/null
+++ b/extra/yassl/taocrypt/include/rabbit.hpp
@@ -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
+
diff --git a/extra/yassl/taocrypt/include/rsa.hpp b/extra/yassl/taocrypt/include/rsa.hpp
index c895ab6fd34..11a4ccfd039 100644
--- a/extra/yassl/taocrypt/include/rsa.hpp
+++ b/extra/yassl/taocrypt/include/rsa.hpp
@@ -178,7 +178,8 @@ void RSA_Encryptor<Pad>::Encrypt(const byte* plain, word32 sz, byte* cipher,
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 @@ word32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher, word32 sz, byte* plain,
RandomNumberGenerator& rng)
{
PK_Lengths lengths(key_.GetModulus());
- assert(sz == lengths.FixedCiphertextLength());
if (sz != lengths.FixedCiphertextLength())
return 0;
diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp
index 3b9d0d9b095..328c8e9e978 100644
--- a/extra/yassl/taocrypt/include/runtime.hpp
+++ b/extra/yassl/taocrypt/include/runtime.hpp
@@ -31,7 +31,6 @@
#ifdef __sun
-#include <assert.h>
// Handler for pure virtual functions
namespace __Crun {
@@ -46,9 +45,7 @@ namespace __Crun {
#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));
diff --git a/extra/yassl/taocrypt/include/types.hpp b/extra/yassl/taocrypt/include/types.hpp
index 3efdcdfbccb..5d8bc9f0683 100644
--- a/extra/yassl/taocrypt/include/types.hpp
+++ b/extra/yassl/taocrypt/include/types.hpp
@@ -62,7 +62,7 @@ typedef unsigned int word32;
// 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
diff --git a/extra/yassl/taocrypt/mySTL/stdexcept.hpp b/extra/yassl/taocrypt/mySTL/stdexcept.hpp
index 9696995248d..15533eebc02 100644
--- a/extra/yassl/taocrypt/mySTL/stdexcept.hpp
+++ b/extra/yassl/taocrypt/mySTL/stdexcept.hpp
@@ -26,7 +26,6 @@
#include <string.h> // strncpy
-#include <assert.h> // assert
#include <stdlib.h> // size_t
@@ -41,7 +40,7 @@ public:
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);
diff --git a/extra/yassl/taocrypt/mySTL/vector.hpp b/extra/yassl/taocrypt/mySTL/vector.hpp
index 8ba8813ca70..35b92610942 100644
--- a/extra/yassl/taocrypt/mySTL/vector.hpp
+++ b/extra/yassl/taocrypt/mySTL/vector.hpp
@@ -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 @@ private:
// 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_);
}
};
diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp
index bf40f414eaa..3b09c5280bf 100644
--- a/extra/yassl/taocrypt/src/aes.cpp
+++ b/extra/yassl/taocrypt/src/aes.cpp
@@ -79,7 +79,7 @@ void AES::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE;
in += BLOCK_SIZE;
}
- }
+ }
}
#endif // DO_AES_ASM
@@ -87,8 +87,13 @@ void AES::Process(byte* out, const byte* in, word32 sz)
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 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock,
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 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock,
(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) ^
diff --git a/extra/yassl/taocrypt/src/aestables.cpp b/extra/yassl/taocrypt/src/aestables.cpp
index e9d6b7a80cb..05c2c3b8e62 100644
--- a/extra/yassl/taocrypt/src/aestables.cpp
+++ b/extra/yassl/taocrypt/src/aestables.cpp
@@ -33,6 +33,4 @@ const word32 AES::rcon_[] = {
};
-
-
} // namespace
diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp
index b4afda44535..29754b27b5e 100644
--- a/extra/yassl/taocrypt/src/algebra.cpp
+++ b/extra/yassl/taocrypt/src/algebra.cpp
@@ -246,7 +246,6 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,
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 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,
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]);
diff --git a/extra/yassl/taocrypt/src/arc4.cpp b/extra/yassl/taocrypt/src/arc4.cpp
index 0944cc31837..4630adcb11a 100644
--- a/extra/yassl/taocrypt/src/arc4.cpp
+++ b/extra/yassl/taocrypt/src/arc4.cpp
@@ -104,7 +104,7 @@ void ARC4::Process(byte* out, const byte* in, word32 length)
#ifdef DO_ARC4_ASM
#ifdef _MSC_VER
- __declspec(naked)
+ __declspec(naked)
#else
__attribute__ ((noinline))
#endif
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index 1b81db4f0a4..a502666d15b 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -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 @@ bool ValidateDate(const byte* date, byte format, CertDecoder::DateType dt)
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 @@ word32 GetLength(Source& source)
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 @@ void PublicKey::AddToEnd(const byte* data, word32 len)
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 @@ void RSA_Public_Decoder::Decode(RSA_PublicKey& key)
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 @@ CertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers,
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 @@ void CertDecoder::Decode(SignerList* signers, CertType ct)
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 @@ void CertDecoder::StoreKey()
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 @@ void CertDecoder::AddDSA()
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 @@ word32 CertDecoder::GetAlgoId()
{
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 @@ word32 CertDecoder::GetAlgoId()
}
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 @@ word32 CertDecoder::GetSignature()
}
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 @@ word32 CertDecoder::GetDigest()
}
-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 @@ void CertDecoder::GetName(NameType nt)
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 @@ void CertDecoder::GetName(NameType nt)
}
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 @@ void CertDecoder::GetName(NameType nt)
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 @@ void CertDecoder::GetDate(DateType dt)
}
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 @@ void CertDecoder::GetDate(DateType dt)
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 @@ void CertDecoder::GetCompareHash(const byte* plain, word32 sz, byte* digest,
// 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 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
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 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
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 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
}
+/*
// Get Cert in PEM format from BEGIN to END
int GetCert(Source& source)
{
@@ -1174,12 +1247,10 @@ void PKCS12_Decoder::Decode()
// 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 @@ int GetPKCS_Cert(const char* password, Source& source)
return 0;
}
+*/
diff --git a/extra/yassl/taocrypt/src/blowfish.cpp b/extra/yassl/taocrypt/src/blowfish.cpp
index 2e68f7ffb5c..e1c7c852d19 100644
--- a/extra/yassl/taocrypt/src/blowfish.cpp
+++ b/extra/yassl/taocrypt/src/blowfish.cpp
@@ -87,7 +87,10 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz)
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 @@ void Blowfish::crypt_block(const word32 in[2], word32 out[2]) const
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 @@ typedef BlockGetAndPut<word32, BigEndian> gpBlock;
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];
diff --git a/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp
index 75c8f44f636..97c62ea12a7 100644
--- a/extra/yassl/taocrypt/src/coding.cpp
+++ b/extra/yassl/taocrypt/src/coding.cpp
@@ -95,7 +95,6 @@ void HexEncoder::Encode()
void HexDecoder::Decode()
{
word32 bytes = coded_.size();
- assert((bytes % 2) == 0);
decoded_.New(bytes / 2);
word32 i(0);
@@ -104,15 +103,9 @@ void HexDecoder::Decode()
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 @@ void Base64Encoder::Encode()
}
encoded_[i++] = '\n';
- assert(i == outSz);
-
- plain_.reset(encoded_);
+
+ if (i == outSz)
+ plain_.reset(encoded_);
}
@@ -197,7 +190,6 @@ void Base64Decoder::Decode()
byte e3 = coded_.next();
byte e4 = coded_.next();
- // do asserts first
if (e1 == 0) // end file 0's
break;
diff --git a/extra/yassl/taocrypt/src/dsa.cpp b/extra/yassl/taocrypt/src/dsa.cpp
index 79ee91e76f9..a4e9c9503e7 100644
--- a/extra/yassl/taocrypt/src/dsa.cpp
+++ b/extra/yassl/taocrypt/src/dsa.cpp
@@ -183,7 +183,8 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig,
Integer kInv = k.InverseMod(q);
s_ = (kInv * (H + x*r_)) % q;
- assert(!!r_ && !!s_);
+ if (!(!!r_ && !!s_))
+ return -1;
int rSz = r_.ByteCount();
diff --git a/extra/yassl/taocrypt/src/hash.cpp b/extra/yassl/taocrypt/src/hash.cpp
index c51dc42a909..b36a486368c 100644
--- a/extra/yassl/taocrypt/src/hash.cpp
+++ b/extra/yassl/taocrypt/src/hash.cpp
@@ -21,7 +21,6 @@
#include "runtime.hpp"
#include <string.h>
-#include <assert.h>
#include "hash.hpp"
@@ -31,8 +30,6 @@ namespace TaoCrypt {
HASHwithTransform::HASHwithTransform(word32 digSz, word32 buffSz)
{
- assert(digSz <= MaxDigestSz);
- assert(buffSz <= MaxBufferSz);
}
@@ -73,15 +70,15 @@ void HASHwithTransform::Update(const byte* data, word32 len)
// 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 @@ void HASHwithTransform::Final(byte* hash)
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 @@ void HASHwithTransform::Final(byte* hash)
HASH64withTransform::HASH64withTransform(word32 digSz, word32 buffSz)
{
- assert(digSz <= MaxDigestSz);
- assert(buffSz <= MaxBufferSz);
}
diff --git a/extra/yassl/taocrypt/src/hc128.cpp b/extra/yassl/taocrypt/src/hc128.cpp
new file mode 100644
index 00000000000..aac92f0abb4
--- /dev/null
+++ b/extra/yassl/taocrypt/src/hc128.cpp
@@ -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
diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp
index 04c4cefff98..15deb59d4f3 100644
--- a/extra/yassl/taocrypt/src/integer.cpp
+++ b/extra/yassl/taocrypt/src/integer.cpp
@@ -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 @@ template <class T>
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 @@ CPP_TYPENAME AlignedAllocator<T>::pointer AlignedAllocator<T>::allocate(
#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 @@ void AlignedAllocator<T>::deallocate(void* p, size_type n)
#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 @@ DWord() {}
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 @@ private:
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 @@ S DivideThreeWordsByTwo(S* A, S B0, S B1, D* dummy_VC6_WorkAround = 0)
A[1] = u.GetLowHalf();
A[2] += u.GetHighHalf();
Q++;
- assert(Q); // shouldn't overflow
}
return Q;
@@ -491,7 +484,6 @@ static int Compare(const word *A, const word *B, unsigned int N)
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 Increment(word *A, unsigned int N, word B=1)
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 LinearMultiply(word *C, const word *A, word B, unsigned int N)
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 @@ public:
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::Add(word *C, const word *A, const word *B, unsigned int N)
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 @@ void Portable::Multiply8Bottom(word *R, const word *A, const word *B)
static jmp_buf s_env;
static void SigIllHandler(int)
{
- longjmp(s_env, 1);
+ longjmp(s_env, 1);
}
#endif
@@ -2130,8 +2113,6 @@ void P4Optimized::Multiply8Bottom(word *C, const word *A, const word *B)
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 @@ void RecursiveMultiply(word *R, word *T, const word *A, const word *B,
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 RecursiveMultiply(word *R, word *T, const word *A, const word *B,
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 RecursiveSquare(word *R, word *T, const word *A, unsigned int N)
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 RecursiveMultiplyBottom(word *R, word *T, const word *A, const word *B,
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 @@ void RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A,
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 @@ void AsymmetricMultiply(word *R, word *T, const word *A, unsigned int NA,
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 @@ static inline unsigned int EvenWordCount(const word *X, unsigned int N)
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 @@ unsigned int AlmostInverse(word *R, word *T, const word *A, unsigned int NA,
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 @@ unsigned int AlmostInverse(word *R, word *T, const word *A, unsigned int NA,
{
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 @@ unsigned int AlmostInverse(word *R, word *T, const word *A, unsigned int NA,
{
b[bcLen] = 1;
bcLen+=2;
- assert(bcLen <= N);
}
}
}
@@ -2622,11 +2587,14 @@ void Integer::Decode(Source& source)
}
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, unsigned int nbits)
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 @@ Integer& Integer::operator++()
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 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
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 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
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 @@ bool Integer::GetBit(unsigned int n) const
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 @@ bool Integer::IsConvertableToLong() const
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 @@ static inline void AtomicDivide(word *Q, const word *A, const word *B)
{
// 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 inline void AtomicDivide(word *Q, const word *A, const word *B)
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 @@ static void CorrectQuotientEstimate(word *R, word *T, word *Q, const word *B,
}
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 @@ static void CorrectQuotientEstimate(word *R, word *T, word *Q, const word *B,
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 @@ void Divide(word* R, word* Q, word* T, const word* A, unsigned int NA,
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 @@ void Divide(word* R, word* Q, word* T, const word* A, unsigned int NA,
else
{
NA+=2;
- assert(Compare(TA+NA-NB, TB, NB) < 0);
}
word BT[2];
@@ -3340,8 +3290,6 @@ void PositiveDivide(Integer& remainder, Integer& quotient,
unsigned aSize = a.WordCount();
unsigned bSize = b.WordCount();
- assert(bSize);
-
if (a.PositiveCompare(b) == -1)
{
remainder = a;
@@ -3429,8 +3377,6 @@ Integer Integer::Modulo(const Integer &b) const
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 @@ Integer Integer::DividedBy(word b) const
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 @@ Integer Integer::SquareRoot() const
// overestimate square root
Integer x, y = Power2((BitCount()+1)/2);
- assert(y*y >= *this);
do
{
@@ -3562,8 +3505,6 @@ Integer Integer::Gcd(const Integer &a, const Integer &b)
Integer Integer::InverseMod(const Integer &m) const
{
- assert(m.NotNegative());
-
if (IsNegative() || *this>=m)
return (*this%m).InverseMod(m);
@@ -3806,7 +3747,7 @@ void MontgomeryReduce(word *R, word *T, const word *X, const word *M,
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 @@ MontgomeryRepresentation::MontgomeryRepresentation(const Integer &m)
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 @@ const Integer& MontgomeryRepresentation::Multiply(const Integer &a,
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 @@ const Integer& MontgomeryRepresentation::Square(const Integer &a) const
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 @@ Integer MontgomeryRepresentation::ConvertOut(const Integer &a) const
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 @@ const Integer& MontgomeryRepresentation::MultiplicativeInverse(
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());
diff --git a/extra/yassl/taocrypt/src/make.bat b/extra/yassl/taocrypt/src/make.bat
index ecd3023f5ab..ecd3023f5ab 100644..100755
--- a/extra/yassl/taocrypt/src/make.bat
+++ b/extra/yassl/taocrypt/src/make.bat
diff --git a/extra/yassl/taocrypt/src/md4.cpp b/extra/yassl/taocrypt/src/md4.cpp
index cf17c218809..54820f4c944 100644
--- a/extra/yassl/taocrypt/src/md4.cpp
+++ b/extra/yassl/taocrypt/src/md4.cpp
@@ -27,7 +27,7 @@
#include "algorithm.hpp"
#endif
-
+
namespace STL = STL_NAMESPACE;
diff --git a/extra/yassl/taocrypt/src/md5.cpp b/extra/yassl/taocrypt/src/md5.cpp
index f18e0290c90..4d0a8bd03be 100644
--- a/extra/yassl/taocrypt/src/md5.cpp
+++ b/extra/yassl/taocrypt/src/md5.cpp
@@ -30,7 +30,7 @@
namespace STL = STL_NAMESPACE;
-
+
namespace TaoCrypt {
@@ -108,14 +108,14 @@ void MD5::Update(const byte* data, word32 len)
// 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
diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp
index 07ef25ad773..1a4dd4a52d3 100644
--- a/extra/yassl/taocrypt/src/misc.cpp
+++ b/extra/yassl/taocrypt/src/misc.cpp
@@ -41,28 +41,28 @@ namespace STL = STL_NAMESPACE;
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 @@ namespace STL = STL_NAMESPACE;
// Handler for pure virtual functions
namespace __Crun {
void pure_error() {
- assert(!"Aborted: pure virtual method called.");
}
}
@@ -100,7 +99,6 @@ namespace __Crun {
extern "C" {
int __cxa_pure_virtual() {
- assert(!"Aborted: pure virtual method called.");
return 0;
}
@@ -205,8 +203,8 @@ bool HaveCpuId()
return true;
#else
word32 eax, ebx;
- __asm__ __volatile
- (
+ __asm__ __volatile
+ (
/* Put EFLAGS in eax and ebx */
"pushf;"
"pushf;"
@@ -223,9 +221,9 @@ bool HaveCpuId()
"pop %0;"
"popf"
: "=r" (eax), "=r" (ebx)
- :
+ :
: "cc"
- );
+ );
if (eax == ebx)
return false;
diff --git a/extra/yassl/taocrypt/src/rabbit.cpp b/extra/yassl/taocrypt/src/rabbit.cpp
new file mode 100644
index 00000000000..0ea4146618a
--- /dev/null
+++ b/extra/yassl/taocrypt/src/rabbit.cpp
@@ -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
diff --git a/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp
index 1be0fed612f..aa9be7f1985 100644
--- a/extra/yassl/taocrypt/src/random.cpp
+++ b/extra/yassl/taocrypt/src/random.cpp
@@ -96,13 +96,13 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz)
/* 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);
}
}
diff --git a/extra/yassl/taocrypt/src/ripemd.cpp b/extra/yassl/taocrypt/src/ripemd.cpp
index a738c197bf2..e012db43de5 100644
--- a/extra/yassl/taocrypt/src/ripemd.cpp
+++ b/extra/yassl/taocrypt/src/ripemd.cpp
@@ -110,14 +110,14 @@ void RIPEMD160::Update(const byte* data, word32 len)
// 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
diff --git a/extra/yassl/taocrypt/src/rsa.cpp b/extra/yassl/taocrypt/src/rsa.cpp
index 57d19a59c76..576146377a3 100644
--- a/extra/yassl/taocrypt/src/rsa.cpp
+++ b/extra/yassl/taocrypt/src/rsa.cpp
@@ -61,7 +61,6 @@ Integer RSA_PrivateKey::CalculateInverse(RandomNumberGenerator& rng,
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 @@ word32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
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 @@ word32 RSA_BlockType1::UnPad(const byte* pkcsBlock, word32 pkcsBlockLen,
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;
diff --git a/extra/yassl/taocrypt/src/sha.cpp b/extra/yassl/taocrypt/src/sha.cpp
index ef165a342ad..1ae42d94e4c 100644
--- a/extra/yassl/taocrypt/src/sha.cpp
+++ b/extra/yassl/taocrypt/src/sha.cpp
@@ -344,14 +344,14 @@ void SHA::Update(const byte* data, word32 len)
// 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
diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp
index 390da58e191..b472d18236f 100644
--- a/extra/yassl/taocrypt/src/template_instnt.cpp
+++ b/extra/yassl/taocrypt/src/template_instnt.cpp
@@ -61,7 +61,6 @@ template class PBKDF2_HMAC<SHA>;
template class HMAC<MD5>;
template class HMAC<SHA>;
template class HMAC<RIPEMD160>;
-
}
namespace mySTL {
diff --git a/extra/yassl/taocrypt/src/twofish.cpp b/extra/yassl/taocrypt/src/twofish.cpp
index 15bb778f444..4ae493624dc 100644
--- a/extra/yassl/taocrypt/src/twofish.cpp
+++ b/extra/yassl/taocrypt/src/twofish.cpp
@@ -141,8 +141,6 @@ inline word32 Twofish::h(word32 x, const word32* key, unsigned int kLen)
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);
diff --git a/extra/yassl/taocrypt/taocrypt.dsp b/extra/yassl/taocrypt/taocrypt.dsp
index 3f1b47990ad..9c8e74da8c8 100644
--- a/extra/yassl/taocrypt/taocrypt.dsp
+++ b/extra/yassl/taocrypt/taocrypt.dsp
@@ -138,6 +138,10 @@ SOURCE=.\src\hash.cpp
# 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 @@ SOURCE=.\src\misc.cpp
# 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 @@ SOURCE=.\include\hash.hpp
# 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 @@ SOURCE=.\include\pwdbased.hpp
# 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
diff --git a/extra/yassl/taocrypt/test/make.bat b/extra/yassl/taocrypt/test/make.bat
index d6d62b984a8..d6d62b984a8 100644..100755
--- a/extra/yassl/taocrypt/test/make.bat
+++ b/extra/yassl/taocrypt/test/make.bat
diff --git a/extra/yassl/taocrypt/test/memory.cpp b/extra/yassl/taocrypt/test/memory.cpp
index bac8f9c2e97..ec398a64c45 100644
--- a/extra/yassl/taocrypt/test/memory.cpp
+++ b/extra/yassl/taocrypt/test/memory.cpp
@@ -328,3 +328,32 @@ void operator delete[](void* ptr)
{
::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"
+
diff --git a/extra/yassl/taocrypt/test/test.cpp b/extra/yassl/taocrypt/test/test.cpp
index 09836a2ef56..807f91f32ae 100644
--- a/extra/yassl/taocrypt/test/test.cpp
+++ b/extra/yassl/taocrypt/test/test.cpp
@@ -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::PBKDF2_HMAC;
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 dsa_test();
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 @@ byte* cipher = 0; // block output
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 @@ void taocrypt_test(void* args)
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 taocrypt_test(void* args)
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 hmac_test()
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 @@ int arc4_test()
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 arc4_test()
}
+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 @@ int rsa_test()
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 @@ int rsa_test()
}
}
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 pwdbased_test()
}
+/*
int pkcs12_test()
{
Source cert;
@@ -1206,4 +1333,5 @@ int pkcs12_test()
return 0;
}
+*/
diff --git a/extra/yassl/testsuite/make.bat b/extra/yassl/testsuite/make.bat
index 941e499d7e6..941e499d7e6 100644..100755
--- a/extra/yassl/testsuite/make.bat
+++ b/extra/yassl/testsuite/make.bat
diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp
index a0a9fafc87e..559ebe54f1b 100644
--- a/extra/yassl/testsuite/test.hpp
+++ b/extra/yassl/testsuite/test.hpp
@@ -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 start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*);
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 @@ extern "C" {
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_set_nonblocking(SOCKET_T& sockfd)
}
-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 @@ inline void tcp_close(SOCKET_T& sockfd)
#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_connect(SOCKET_T& sockfd)
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 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args)
{
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 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args)
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 @@ inline void showPeer(SSL* ssl)
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 DH* set_tmpDH(SSL_CTX* ctx)
}
+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
diff --git a/extra/yassl/testsuite/testsuite.cpp b/extra/yassl/testsuite/testsuite.cpp
index 5ddb9bb4dab..fa8c997e7c2 100644
--- a/extra/yassl/testsuite/testsuite.cpp
+++ b/extra/yassl/testsuite/testsuite.cpp
@@ -119,7 +119,7 @@ int main(int argc, char** argv)
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 start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
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 @@ int test_openSSL_des()
{
/* 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,
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 8e0344356d5..37e15894432 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -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
diff --git a/include/m_string.h b/include/m_string.h
index 7c95c7319dc..9fc6cda4764 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -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
diff --git a/include/my_global.h b/include/my_global.h
index c6120cd7bf3..8170ce381af 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -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
diff --git a/include/myisam.h b/include/myisam.h
index 3d4eecb7cbe..eaa6b2dbd1f 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -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 flush_pending_blocks(MI_SORT_PARAM *param);
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
}
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 614bb028a0d..8fb0ef77eef 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -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
diff --git a/include/welcome_copyright_notice.h b/include/welcome_copyright_notice.h
index 9e40c17efca..739aeb4ede8 100644
--- a/include/welcome_copyright_notice.h
+++ b/include/welcome_copyright_notice.h
@@ -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
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 754603a2964..182c8748934 100644
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -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
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 14db8327897..f08159da20a 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -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
diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt
index e62b2a193e4..e607f3c685a 100644
--- a/libmysqld/examples/CMakeLists.txt
+++ b/libmysqld/examples/CMakeLists.txt
@@ -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
diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt
index 954e9c44311..f360ef1c616 100644
--- a/mysql-test/CMakeLists.txt
+++ b/mysql-test/CMakeLists.txt
@@ -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
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index b3623402065..1f4d29968a5 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -12,7 +12,6 @@ main.signal_demo3 @solaris # Bug#11753919 2010-01-20 alik Several
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
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
index c3ecd9381c9..f6152180e7a 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
@@ -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 @@ create table t2(b int auto_increment, c int, primary key(b));
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;
diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update.test b/mysql-test/extra/rpl_tests/rpl_multi_update.test
index bf7707f9d6d..cdbdbc191d7 100644
--- a/mysql-test/extra/rpl_tests/rpl_multi_update.test
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update.test
@@ -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 @@ eval CREATE TABLE t2 (
) 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 @@ INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
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;
diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update2.test b/mysql-test/extra/rpl_tests/rpl_multi_update2.test
index ae4261c0516..b85927a2aed 100644
--- a/mysql-test/extra/rpl_tests/rpl_multi_update2.test
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update2.test
@@ -17,6 +17,8 @@ eval CREATE TABLE t2 (
) 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 @@ INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
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;
diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update3.test b/mysql-test/extra/rpl_tests/rpl_multi_update3.test
index 6c7a980aecb..f7d4815e9e5 100644
--- a/mysql-test/extra/rpl_tests/rpl_multi_update3.test
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update3.test
@@ -18,6 +18,8 @@ eval CREATE TABLE t2 (
) 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 @@ INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
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;
diff --git a/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test b/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
index f828c79bc6a..40bc7746ccf 100644
--- a/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
+++ b/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
@@ -182,7 +182,8 @@ DROP TABLE t1;
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.
#
diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql
index bcbb9b94136..82c0514b7cd 100644
--- a/mysql-test/include/mtr_check.sql
+++ b/mysql-test/include/mtr_check.sql
@@ -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
diff --git a/mysql-test/include/not_crashrep.inc b/mysql-test/include/not_crashrep.inc
index e126f339a5f..7e0d6c19b85 100644
--- a/mysql-test/include/not_crashrep.inc
+++ b/mysql-test/include/not_crashrep.inc
@@ -22,3 +22,9 @@ EOF
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;
+
diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mysql-stress-test.pl
index 860be1c1251..74394e2afbd 100755
--- a/mysql-test/mysql-stress-test.pl
+++ b/mysql-test/mysql-stress-test.pl
@@ -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
# ======================================================================
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index bfa7f2bf4e6..fd695d1129f 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -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
diff --git a/mysql-test/r/bug13633383.result b/mysql-test/r/bug13633383.result
new file mode 100644
index 00000000000..89b522724f9
--- /dev/null
+++ b/mysql-test/r/bug13633383.result
@@ -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;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 163043c2cef..ebe8255fd8b 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -1648,6 +1648,64 @@ NULL
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
diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result
index b29c6241f14..3d0e4cbfc79 100644
--- a/mysql-test/r/join_outer_jcl6.result
+++ b/mysql-test/r/join_outer_jcl6.result
@@ -1659,6 +1659,64 @@ NULL
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
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index ca72521a819..e991326cdce 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -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 @@ a b
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 @@ ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
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;
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 2a2197e7f98..64c61d4ee36 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -2494,6 +2494,19 @@ Table Op Msg_type Msg_text
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;
+@before=@after
+1
+DROP TABLE t1;
End of 5.1 tests
#
# Bug#51327 MyISAM table is automatically repaired on ALTER
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 7c38fa18faa..1bc1ea31671 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -2354,6 +2354,46 @@ TRUNCATE TABLE t1;
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
diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result
index 5cba49645b4..851c97c5ec3 100644
--- a/mysql-test/r/partition_error.result
+++ b/mysql-test/r/partition_error.result
@@ -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
#
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index b4a09091aa6..5f04544e0fb 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -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
diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result
index 2425f40d9c2..7d08ffb2f71 100644
--- a/mysql-test/r/sp-bugs.result
+++ b/mysql-test/r/sp-bugs.result
@@ -111,4 +111,23 @@ DROP FUNCTION db1.f1;
DROP TABLE db1.t1;
DROP DATABASE db1;
DROP DATABASE db2;
+#
+# 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;
End of 5.1 tests
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index c8743ab112d..ad54f9c0fdf 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -7746,3 +7746,26 @@ DROP PROCEDURE p1;
DROP PROCEDURE p2;
DROP TABLE t1;
# 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;
diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
index 17ad4c6e5b1..2f994e9f5fc 100644
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result
@@ -1760,7 +1760,7 @@ SELECT COUNT(*) FROM mysql.general_log;
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 sinc
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 sinc
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 sinc
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 sinc
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 sinc
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 sinc
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 sinc
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 @@ DROP FUNCTION func_sidef_1;
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 sinc
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 sinc
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 sinc
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 sinc
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 sinc
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 @@ DROP PROCEDURE proc_1;
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 sinc
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 sinc
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 sinc
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 sinc
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 sinc
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 @@ DROP TRIGGER trig_1;
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 sinc
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 sinc
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.
diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test
index c64b9197b51..3353855fd0c 100644
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test
@@ -233,7 +233,7 @@ while ($unsafe_type < 9) {
--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) {
diff --git a/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result b/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
index fdd76f93c10..6a9bfae27db 100644
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
@@ -77,6 +77,7 @@ utf8_persian_ci utf8 208 # #
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_persian_ci ucs2 144 # #
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 # #
diff --git a/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result b/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
index 4a41ece1fe5..79d1d4cbac2 100644
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
@@ -77,6 +77,7 @@ utf8_persian_ci utf8 208 # #
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_persian_ci ucs2 144 # #
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 # #
diff --git a/mysql-test/suite/innodb/r/group_commit_crash.result b/mysql-test/suite/innodb/r/group_commit_crash.result
index 333e47f38ad..cd47ba62ff2 100644
--- a/mysql-test/suite/innodb/r/group_commit_crash.result
+++ b/mysql-test/suite/innodb/r/group_commit_crash.result
@@ -2,7 +2,7 @@ CREATE TABLE t1(a CHAR(255),
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 @@ ELSE BEGIN END;
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;
diff --git a/mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result b/mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result
index 333e47f38ad..c1ae510d45b 100644
--- a/mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result
+++ b/mysql-test/suite/innodb/r/group_commit_crash_no_optimize_thread.result
@@ -2,7 +2,7 @@ CREATE TABLE t1(a CHAR(255),
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 @@ ELSE BEGIN END;
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;
diff --git a/mysql-test/suite/innodb/r/innodb-blob.result b/mysql-test/suite/innodb/r/innodb-blob.result
new file mode 100644
index 00000000000..a90f83945e0
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-blob.result
@@ -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;
diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result
index a33099661aa..48390b14a82 100644
--- a/mysql-test/suite/innodb/r/innodb-index.result
+++ b/mysql-test/suite/innodb/r/innodb-index.result
@@ -114,6 +114,10 @@ t12963823 CREATE TABLE `t12963823` (
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;
diff --git a/mysql-test/suite/innodb/r/innodb_bug11754376.result b/mysql-test/suite/innodb/r/innodb_bug11754376.result
new file mode 100644
index 00000000000..034e4f07403
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug11754376.result
@@ -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';
diff --git a/mysql-test/suite/innodb/r/innodb_bug13510739.result b/mysql-test/suite/innodb/r/innodb_bug13510739.result
new file mode 100644
index 00000000000..8aa4323eeb0
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug13510739.result
@@ -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;
diff --git a/mysql-test/suite/innodb/t/group_commit_crash.test b/mysql-test/suite/innodb/t/group_commit_crash.test
index 3502ab41180..12c92d19244 100644
--- a/mysql-test/suite/innodb/t/group_commit_crash.test
+++ b/mysql-test/suite/innodb/t/group_commit_crash.test
@@ -14,7 +14,7 @@ CREATE TABLE t1(a CHAR(255),
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 @@ let $numinserts = 10;
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
diff --git a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test
index 3502ab41180..2de09d6b0b6 100644
--- a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test
+++ b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test
@@ -14,7 +14,7 @@ CREATE TABLE t1(a CHAR(255),
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 @@ let $numinserts = 10;
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
diff --git a/mysql-test/suite/innodb/t/innodb-blob.test b/mysql-test/suite/innodb/t/innodb-blob.test
new file mode 100644
index 00000000000..c81d4a8acf1
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-blob.test
@@ -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;
diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test
index cb4527d6cb2..cea9055b873 100644
--- a/mysql-test/suite/innodb/t/innodb-index.test
+++ b/mysql-test/suite/innodb/t/innodb-index.test
@@ -119,6 +119,11 @@ show create table t12963823;
# 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;
diff --git a/mysql-test/suite/innodb/t/innodb_bug11754376.test b/mysql-test/suite/innodb/t/innodb_bug11754376.test
new file mode 100644
index 00000000000..b740b7e08fe
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug11754376.test
@@ -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';
diff --git a/mysql-test/suite/innodb/t/innodb_bug13510739.test b/mysql-test/suite/innodb/t/innodb_bug13510739.test
new file mode 100644
index 00000000000..f10bcd8e272
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug13510739.test
@@ -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;
diff --git a/mysql-test/suite/innodb/t/innodb_bug34300.test b/mysql-test/suite/innodb/t/innodb_bug34300.test
index 3f496741c6a..7331c1233fc 100644
--- a/mysql-test/suite/innodb/t/innodb_bug34300.test
+++ b/mysql-test/suite/innodb/t/innodb_bug34300.test
@@ -7,6 +7,8 @@
-- disable_query_log
-- disable_result_log
+call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:");
+
# set packet size and reconnect
let $max_packet=`select @@global.max_allowed_packet`;
SET @@global.max_allowed_packet=16777216;
diff --git a/mysql-test/suite/innodb/t/innodb_bug53756.test b/mysql-test/suite/innodb/t/innodb_bug53756.test
index 2f778d45f61..c298c945434 100644
--- a/mysql-test/suite/innodb/t/innodb_bug53756.test
+++ b/mysql-test/suite/innodb/t/innodb_bug53756.test
@@ -137,6 +137,9 @@ INSERT INTO bug_53756 VALUES (666,666);
# 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 @@ COMMIT;
--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
#
diff --git a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result
index 62ff28e7159..1d378e2d864 100644
--- a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result
+++ b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result
@@ -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;
diff --git a/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result b/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result
index c132f80f58e..cc693bff752 100644
--- a/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result
+++ b/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result
@@ -11,7 +11,7 @@ reset slave;
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;
diff --git a/mysql-test/suite/rpl/r/rpl_checksum.result b/mysql-test/suite/rpl/r/rpl_checksum.result
index feabfc19631..bee43a2a2b3 100644
--- a/mysql-test/suite/rpl/r/rpl_checksum.result
+++ b/mysql-test/suite/rpl/r/rpl_checksum.result
@@ -71,7 +71,7 @@ insert into t1 values (1) /* will not be applied on slave due to simulation */;
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
diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
index d89bce479e5..193172912be 100644
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
@@ -861,7 +861,8 @@ master-bin.000001 # Table_map # # table_id: # (test_rpl.t1)
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'
diff --git a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result
index c2d6d2c9b0c..467b8c1e5cc 100644
--- a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result
+++ b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result
@@ -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);
diff --git a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
index f7aea20a34f..ea738b710fd 100644
--- a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
+++ b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
@@ -46,6 +46,7 @@ ON DUPLICATE KEY UPDATE
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 @@ ON DUPLICATE KEY UPDATE
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
diff --git a/mysql-test/suite/rpl/r/rpl_log_pos.result b/mysql-test/suite/rpl/r/rpl_log_pos.result
index 941dba2f5af..8910f7c8f74 100644
--- a/mysql-test/suite/rpl/r/rpl_log_pos.result
+++ b/mysql-test/suite/rpl/r/rpl_log_pos.result
@@ -11,7 +11,7 @@ include/stop_slave.inc
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
diff --git a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
index efe9bf076f0..d5331d0fc93 100644
--- a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
+++ b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
@@ -5,7 +5,7 @@ CREATE TABLE t1(c1 INT);
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);
diff --git a/mysql-test/suite/rpl/r/rpl_multi_update.result b/mysql-test/suite/rpl/r/rpl_multi_update.result
index 8634e86afed..74fb7952a2a 100644
--- a/mysql-test/suite/rpl/r/rpl_multi_update.result
+++ b/mysql-test/suite/rpl/r/rpl_multi_update.result
@@ -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
diff --git a/mysql-test/suite/rpl/r/rpl_multi_update2.result b/mysql-test/suite/rpl/r/rpl_multi_update2.result
index a3cab693322..03ed5de473d 100644
--- a/mysql-test/suite/rpl/r/rpl_multi_update2.result
+++ b/mysql-test/suite/rpl/r/rpl_multi_update2.result
@@ -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,
diff --git a/mysql-test/suite/rpl/r/rpl_multi_update3.result b/mysql-test/suite/rpl/r/rpl_multi_update3.result
index 6b9ec5c3947..bf9946f219f 100644
--- a/mysql-test/suite/rpl/r/rpl_multi_update3.result
+++ b/mysql-test/suite/rpl/r/rpl_multi_update3.result
@@ -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 (
diff --git a/mysql-test/suite/rpl/r/rpl_packet.result b/mysql-test/suite/rpl/r/rpl_packet.result
index 4b2a525de27..4d5ffae2d63 100644
--- a/mysql-test/suite/rpl/r/rpl_packet.result
+++ b/mysql-test/suite/rpl/r/rpl_packet.result
@@ -37,7 +37,7 @@ DROP TABLE t1;
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;
diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
index 4b830799dd1..f10e30c698d 100644
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
@@ -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;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result b/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result
index 8bf903b0713..2aa2ee3b573 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result
@@ -75,7 +75,7 @@ CHANGE MASTER TO master_log_pos=MASTER_POS;
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;
diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
index d1da69533ec..1e5f9e53478 100644
--- a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
@@ -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 @@ CREATE PROCEDURE simpleproc3 ()
$
DELIMITER ;$
+--disable_warnings
CALL simpleproc3();
+--enable_warnings
select * from t2;
TRUNCATE TABLE `t1`;
+--disable_warnings
CALL simpleproc3();
+--enable_warnings
select * from t1;
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update2.test b/mysql-test/suite/rpl/t/rpl_multi_update2.test
index 497568f2738..138c1455952 100644
--- a/mysql-test/suite/rpl/t/rpl_multi_update2.test
+++ b/mysql-test/suite/rpl/t/rpl_multi_update2.test
@@ -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
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update3.test b/mysql-test/suite/rpl/t/rpl_multi_update3.test
index f6e70f14b30..dc12d528c24 100644
--- a/mysql-test/suite/rpl/t/rpl_multi_update3.test
+++ b/mysql-test/suite/rpl/t/rpl_multi_update3.test
@@ -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
diff --git a/mysql-test/suite/rpl/t/rpl_optimize.test b/mysql-test/suite/rpl/t/rpl_optimize.test
index b48ef579b6b..47063539ffc 100644
--- a/mysql-test/suite/rpl/t/rpl_optimize.test
+++ b/mysql-test/suite/rpl/t/rpl_optimize.test
@@ -25,6 +25,7 @@ enable_query_log;
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);
+--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;
@@ -38,6 +39,7 @@ 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
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
index 77ce540ff36..393623888ec 100644
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
@@ -27,6 +27,7 @@ EOF
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
diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test
index c84f597c1ee..b4a9a9e6e59 100644
--- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test
+++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test
@@ -52,9 +52,10 @@ SET GLOBAL event_scheduler = ON;
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
diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test
index 7355106b6b4..1f0220421ab 100644
--- a/mysql-test/suite/rpl/t/rpl_timezone.test
+++ b/mysql-test/suite/rpl/t/rpl_timezone.test
@@ -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 @@ insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
# 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;
diff --git a/mysql-test/t/bug13633383.test b/mysql-test/t/bug13633383.test
new file mode 100644
index 00000000000..72eb2f81c98
--- /dev/null
+++ b/mysql-test/t/bug13633383.test
@@ -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;
diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test
index facf2912087..83d28c0812d 100644
--- a/mysql-test/t/events_restart.test
+++ b/mysql-test/t/events_restart.test
@@ -106,3 +106,4 @@ let $wait_condition=
select count(*) = 0 from information_schema.processlist
where db='events_test' and command = 'Connect' and user=current_user();
--source include/wait_condition.inc
+
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index d5c6d995b4c..a4469728c0f 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -1260,6 +1260,62 @@ WHERE TABLE1.pk IS NULL;
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
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 51bb64bd31d..48735304aad 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -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 @@ INSERT INTO t2(ParId) VALUES(1), (2), (3);
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 @@ drop table t1,t2;
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 @@ create table `t2` (`c2_id` int(10) unsigned NULL auto_increment, `c2_p_id` int(1
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;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 9bdd6faa422..4199d98073c 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1718,6 +1718,20 @@ CHECK TABLE t1;
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 #
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 3224f4d4081..d6d49c59255 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -2350,6 +2350,51 @@ INSERT INTO t1 VALUES(0);
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 #
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 39dd6773ce8..f8f09e4b5e7 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -11,6 +11,34 @@ drop table if exists t1, t2;
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 #
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 58e85c7a3a1..b89c4974b20 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -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 @@ prepare stmt1 from "select 1 into @var";
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 @@ deallocate prepare stmt;
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;
execute stmt;
drop table t2;
execute stmt;
+--enable_warnings
drop table t1,t2;
deallocate prepare stmt;
@@ -1187,6 +1192,7 @@ create database mysqltest character set utf8;
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.t1;
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;
diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test
index fe52632c784..a23ccea8189 100644
--- a/mysql-test/t/sp-bugs.test
+++ b/mysql-test/t/sp-bugs.test
@@ -138,4 +138,28 @@ DROP FUNCTION db1.f1;
DROP TABLE db1.t1;
DROP DATABASE db1;
DROP DATABASE db2;
+
+--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;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index cafa7f0a551..02182dbf0c6 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -9040,3 +9040,32 @@ DROP PROCEDURE p2;
DROP TABLE t1;
--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;
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 54f8c9b45f9..800a5a90b39 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -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
}
diff --git a/mysys/charset-def.c b/mysys/charset-def.c
index 65defb5d33b..4183b1fcd99 100644
--- a/mysys/charset-def.c
+++ b/mysys/charset-def.c
@@ -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
diff --git a/mysys/my_addr_resolve.c b/mysys/my_addr_resolve.c
index e74845c2808..e5a3a5fe13b 100644
--- a/mysys/my_addr_resolve.c
+++ b/mysys/my_addr_resolve.c
@@ -134,10 +134,10 @@ err:
#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_snprintf(input, sizeof(input), "%p\n", ptr);
diff --git a/mysys/my_init.c b/mysys/my_init.c
index cdd07ec6a8b..c16602318ca 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -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
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index 67b9e7d961f..b0e910f7ba0 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -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
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 6cede382b4b..846a90cc127 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -755,7 +755,7 @@ size_t my_safe_printf_stderr(const char* fmt, ...)
size_t result;
va_list args;
va_start(args,fmt);
- result= vsnprintf(to, sizeof(to), fmt, args);
+ result= my_vsnprintf(to, sizeof(to), fmt, args);
va_end(args);
my_write_stderr(to, result);
return result;
diff --git a/packaging/WiX/custom_ui.wxs b/packaging/WiX/custom_ui.wxs
index a77612c4e50..568053f4cf5 100644
--- a/packaging/WiX/custom_ui.wxs
+++ b/packaging/WiX/custom_ui.wxs
@@ -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>
diff --git a/plugin/auth_examples/dialog_examples.c b/plugin/auth_examples/dialog_examples.c
index 9c4728b7886..067244d6f7d 100644
--- a/plugin/auth_examples/dialog_examples.c
+++ b/plugin/auth_examples/dialog_examples.c
@@ -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
diff --git a/plugin/auth_examples/qa_auth_interface.c b/plugin/auth_examples/qa_auth_interface.c
index 303978f7b1f..ddf51a3dd19 100644
--- a/plugin/auth_examples/qa_auth_interface.c
+++ b/plugin/auth_examples/qa_auth_interface.c
@@ -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
diff --git a/plugin/auth_examples/qa_auth_server.c b/plugin/auth_examples/qa_auth_server.c
index a6a06cfa289..59b926b63dc 100644
--- a/plugin/auth_examples/qa_auth_server.c
+++ b/plugin/auth_examples/qa_auth_server.c
@@ -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
diff --git a/plugin/daemon_example/CMakeLists.txt b/plugin/daemon_example/CMakeLists.txt
index 06c39af4bdd..3d674c4ef3e 100644
--- a/plugin/daemon_example/CMakeLists.txt
+++ b/plugin/daemon_example/CMakeLists.txt
@@ -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
diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc
index ab374a4fb3f..ec2979de3c3 100644
--- a/plugin/daemon_example/daemon_example.cc
+++ b/plugin/daemon_example/daemon_example.cc
@@ -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
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
index 83756d686d2..3fdecc968e1 100644
--- a/scripts/mysql_install_db.pl.in
+++ b/scripts/mysql_install_db.pl.in
@@ -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
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index f0b09cc3e77..b4efbdcbe63 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -1,7 +1,6 @@
#!/bin/sh
-# Copyright (c) 2000-2008 MySQL AB, 2009, 2010 Sun Microsystems, Inc.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates.
# Copyright (c) 2009-2011 Monty Program Ab
-# Use is subject to license terms.
#
# 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
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 4574f1af6d6..6affd5c0ecf 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -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
diff --git a/sql/filesort.cc b/sql/filesort.cc
index c9b79701ea4..e2bd83f1ac4 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -48,8 +48,7 @@ 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, uchar *sort_keys_buf,
- IO_CACHE *buffer_file,
- IO_CACHE *tempfile,IO_CACHE *indexfile);
+ 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);
@@ -85,8 +84,6 @@ static void unpack_addon_fields(struct st_sort_addon_field *addon_field,
(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().
@@ -104,12 +101,13 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
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");
@@ -182,47 +180,25 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
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);
+ min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length * MERGEBUFF2);
if (!table_sort.sort_keys)
{
- while (memavl >= min_sort_memory)
+ while (memory_available >= min_sort_memory)
{
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
- table_sort.keys= (uint) min(records+1, keys);
+ 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"););
@@ -231,16 +207,17 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
(uchar**) my_malloc(table_sort.keys*(param.rec_length+sizeof(char*)),
MYF(0))))
break;
- old_memavl=memavl;
- if ((memavl=memavl/4*3) < min_sort_memory &&
- old_memavl > min_sort_memory)
- memavl= min_sort_memory;
+ 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;
- param.keys= table_sort.keys - 1; /* TODO: check why we do this " - 1" */
- 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));
goto err;
@@ -251,16 +228,19 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
param.sort_form= table;
param.end=(param.local_sortorder=sortorder)+s_length;
- if ((records=find_all_keys(&param,select,sort_keys,
- (uchar *)(sort_keys+param.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
@@ -294,8 +274,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
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))
@@ -303,13 +284,21 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
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);
@@ -358,15 +347,15 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
}
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 */
@@ -476,7 +465,6 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
@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:
@@ -506,7 +494,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
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,12 +519,11 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
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))
@@ -583,18 +570,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
}
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]);
+ error= file->ha_rnd_next(sort_form->record[0]);
if (!error && sort_form->vfield)
update_virtual_fields(thd, sort_form);
if (!flag)
@@ -612,7 +589,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
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();
@@ -656,9 +633,10 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
{
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++;
}
@@ -689,15 +667,17 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
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 */
@@ -1300,8 +1280,9 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
{
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
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index f3c9553f524..70e1e9dc7cf 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -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
diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h
index 1cc20c954cb..a02f687d76f 100644
--- a/sql/ha_ndbcluster_binlog.h
+++ b/sql/ha_ndbcluster_binlog.h
@@ -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
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 36d5da94b11..955d8b0fc90 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -3670,14 +3670,14 @@ int ha_partition::truncate_partition(Alter_info *alter_info, bool *binlog_stmt)
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;
+ 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.
@@ -3687,10 +3687,6 @@ int ha_partition::truncate_partition(Alter_info *alter_info, bool *binlog_stmt)
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)))
- DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND);
-
*binlog_stmt= true;
do
@@ -6099,7 +6095,7 @@ int ha_partition::extra(enum ha_extra_function operation)
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)
diff --git a/sql/item.cc b/sql/item.cc
index d5d5aeba970..8eb05d49d5d 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 384c91d5d2e..95d797c62cf 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -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
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 80914f499fe..633158ae06c 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -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
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 150c2c212d7..0fa2d39aea9 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -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
diff --git a/sql/log_event.h b/sql/log_event.h
index de9cd65514c..7a153a2d08e 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -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
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a73177f9fea..c493eb76111 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 988584f779a..f32b92633b7 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -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
diff --git a/sql/rpl_handler.h b/sql/rpl_handler.h
index 4d1bce45c54..4743fffb9a0 100644
--- a/sql/rpl_handler.h
+++ b/sql/rpl_handler.h
@@ -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
diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc
index c015ce62a99..ec1a96e8a2b 100644
--- a/sql/rpl_injector.cc
+++ b/sql/rpl_injector.cc
@@ -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
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index ae2a4bbec01..3c5a99121fa 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -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
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index c98f7253b18..a885576ef1c 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -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
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index da1fc98c3e1..e1efbc7ee4c 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -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
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index fef910de65d..9c9bee805eb 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -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
diff --git a/sql/set_var.h b/sql/set_var.h
index c074f3f4399..6edfd6adb39 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -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
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 73357b6c4a2..468f89dff06 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -4701,14 +4701,14 @@ ER_NOT_SUPPORTED_YET 42000
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,12 @@ ER_PLUGIN_NO_UNINSTALL
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."
+
#
# MariaDB error messages section starts here
#
@@ -6563,3 +6569,4 @@ ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION
eng "Cannot modify @@session.skip_replication inside a stored function or trigger"
ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT
eng "Query execution was interrupted. The query examined at least %llu rows, which exceeds LIMIT ROWS EXAMINED (%llu). The query result may be incomplete."
+
diff --git a/sql/slave.cc b/sql/slave.cc
index 56f9c14703c..cf550ac22e3 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -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
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc
index f88aed7ab3d..14f49ecc077 100644
--- a/sql/sp_cache.cc
+++ b/sql/sp_cache.cc
@@ -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
diff --git a/sql/sp_cache.h b/sql/sp_cache.h
index ba70bf32400..b21d4c4bf25 100644
--- a/sql/sp_cache.h
+++ b/sql/sp_cache.h
@@ -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
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 355b6f1788c..237ad589e4a 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3557,6 +3557,23 @@ sp_instr_hpush_jump::opt_mark(sp_head *sp, List<sp_instr> *leads)
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;
}
diff --git a/sql/sp_head.h b/sql/sp_head.h
index c79b5dfbd0b..409db33ef02 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -1017,7 +1017,7 @@ class sp_instr_hpush_jump : public sp_instr_jump
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 @@ public:
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 @@ private:
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
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 5897d74582a..f8c602e6482 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -442,12 +442,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
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;
@@ -896,6 +891,9 @@ send_result_message:
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
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index b5ede32e6fe..110f140afe0 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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 bool auto_repair_table(THD *thd, TABLE_LIST *table_list);
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)
{
@@ -5729,9 +5730,20 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count,
*(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.
@@ -9406,6 +9418,41 @@ has_write_table_with_auto_increment(TABLE_LIST *tables)
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.
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 9c86b2838c4..210d259f364 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -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
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 988c8b48c64..169c68c1918 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -142,9 +142,9 @@ Key::Key(const Key &rhs, MEM_ROOT *mem_root)
*/
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)
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 7157b1b109f..81a85f10a16 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -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
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index b2dfae5ded4..ae0832deb84 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -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 @@ Query_tables_list::binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT] =
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
};
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 718c9c7e6a2..7e4d76b4240 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -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
@@ -1374,6 +1373,13 @@ public:
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 +1401,14 @@ public:
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.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e0b2acd199d..90f6f0264a7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 070b48f7a7b..9ba0569f1e0 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4398,11 +4398,20 @@ error:
}
-/*
- 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 @@ uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
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 @@ that are reorganised.
}
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;
diff --git a/sql/sql_partition.h b/sql/sql_partition.h
index cc11d859903..2fd9b4c3d75 100644
--- a/sql/sql_partition.h
+++ b/sql/sql_partition.h
@@ -254,7 +254,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
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,
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 39f69b2656d..5f196e59c6f 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -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
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index e25751a4b88..27bd25680c4 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -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
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index e743e474747..b3348698a35 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -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
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index eb17ef0812c..199afb30344 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -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 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
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;
@@ -1181,12 +1179,14 @@ err:
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);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index bcbdb8332e6..c7af4a37e9a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -12443,11 +12443,9 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
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)
{
@@ -12484,15 +12482,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
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);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 38139bdec0c..f780a3b7c18 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -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 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
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 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
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
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index cf0e0e4c0ef..75f430b451e 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
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);
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 50c57b62067..169e0d9e418 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -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
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 5f9066afd39..34e015e1f9b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2772,9 +2772,15 @@ sp_decl:
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
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index a16769459b4..01afb477942 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -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
diff --git a/sql/sys_vars.h b/sql/sys_vars.h
index 647403a96e4..4ea6b1f036e 100644
--- a/sql/sys_vars.h
+++ b/sql/sys_vars.h
@@ -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
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 25812a7ad48..6b29c6d9d53 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -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 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
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 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
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 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
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);
}
diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc
index 7bdbb4349cd..036dd374cb0 100644
--- a/storage/blackhole/ha_blackhole.cc
+++ b/storage/blackhole/ha_blackhole.cc
@@ -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
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 64fd7102e93..9091c101183 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -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
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index dcbfb176c6a..17ac1e962aa 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -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
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 4294f4b094f..549001ab08b 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -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
diff --git a/storage/heap/hp_info.c b/storage/heap/hp_info.c
index c72dbaf2065..17f8c3fe97a 100644
--- a/storage/heap/hp_info.c
+++ b/storage/heap/hp_info.c
@@ -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
diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c
index 88371208230..3bbf74f3423 100644
--- a/storage/innobase/btr/btr0btr.c
+++ b/storage/innobase/btr/btr0btr.c
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -56,11 +56,12 @@ btr_corruption_report(
(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 @@ btr_page_alloc_for_ibuf(
/**************************************************************//**
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!
-@return new allocated block, x-latched; NULL if out of space */
-UNIV_INTERN
+@retval NULL if no page could be allocated
+@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)
+@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,17 +965,47 @@ btr_page_alloc(
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(fseg_alloc_free_page_general(
+ seg_header, hint_page_no, file_direction,
+ TRUE, mtr, init_mtr));
+}
- return(NULL);
+/**************************************************************//**
+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!
+@retval NULL if no page could be allocated
+@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)
+@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 = 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);
+ 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);
}
@@ -1098,10 +1132,10 @@ btr_page_free(
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 +1249,11 @@ btr_page_get_father_node_ptr_func(
!= 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);
- buf_page_print(page_align(node_ptr), 0);
+ buf_page_print(page_align(node_ptr), 0,
+ BUF_PAGE_PRINT_NO_CRASH);
fputs("InnoDB: Corruption of an index tree: table ", stderr);
ut_print_name(stderr, NULL, TRUE, index->table_name);
@@ -1341,16 +1377,12 @@ btr_create(
/* Allocate then the next page to the segment: it will be the
tree root page */
- page_no = fseg_alloc_free_page(buf_block_get_frame(
- ibuf_hdr_block)
- + IBUF_HEADER
- + IBUF_TREE_SEG_HEADER,
- IBUF_TREE_ROOT_PAGE_NO,
- FSP_UP, mtr);
- ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO);
-
- block = buf_page_get(space, zip_size, page_no,
- RW_X_LATCH, mtr);
+ block = fseg_alloc_free_page(
+ buf_block_get_frame(ibuf_hdr_block)
+ + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
+ IBUF_TREE_ROOT_PAGE_NO,
+ FSP_UP, mtr);
+ ut_ad(buf_block_get_page_no(block) == IBUF_TREE_ROOT_PAGE_NO);
} else {
#ifdef UNIV_BLOB_DEBUG
if ((type & DICT_CLUSTERED) && !index->blobs) {
@@ -1654,8 +1686,8 @@ btr_page_reorganize_low(
if (UNIV_UNLIKELY(data_size1 != data_size2)
|| UNIV_UNLIKELY(max_ins_size1 != max_ins_size2)) {
- buf_page_print(page, 0);
- buf_page_print(temp_page, 0);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(temp_page, 0, BUF_PAGE_PRINT_NO_CRASH);
fprintf(stderr,
"InnoDB: Error: page old data size %lu"
" new data size %lu\n"
@@ -1666,6 +1698,7 @@ btr_page_reorganize_low(
(unsigned long) data_size1, (unsigned long) data_size2,
(unsigned long) max_ins_size1,
(unsigned long) max_ins_size2);
+ ut_ad(0);
} else {
success = TRUE;
}
@@ -1829,7 +1862,7 @@ btr_root_raise_and_insert(
level = btr_page_get_level(root, mtr);
- new_block = btr_page_alloc(index, 0, FSP_NO_DIR, level, mtr);
+ new_block = btr_page_alloc(index, 0, FSP_NO_DIR, level, mtr, mtr);
new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block);
ut_a(!new_page_zip == !root_page_zip);
@@ -2565,7 +2598,7 @@ func_start:
/* 2. Allocate a new page to the index */
new_block = btr_page_alloc(cursor->index, hint_page_no, direction,
- btr_page_get_level(page, mtr), mtr);
+ btr_page_get_level(page, mtr), mtr, mtr);
new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block);
btr_page_create(new_block, new_page_zip, cursor->index,
@@ -3015,15 +3048,16 @@ btr_node_ptr_delete(
ut_a(err == DB_SUCCESS);
if (!compressed) {
- btr_cur_compress_if_useful(&cursor, mtr);
+ btr_cur_compress_if_useful(&cursor, FALSE, mtr);
}
}
/*************************************************************//**
If page is the only on its level, this function moves its records to the
-father page, thus reducing the tree height. */
+father page, thus reducing the tree height.
+@return father block */
static
-void
+buf_block_t*
btr_lift_page_up(
/*=============*/
dict_index_t* index, /*!< in: index tree */
@@ -3140,6 +3174,8 @@ btr_lift_page_up(
}
ut_ad(page_validate(father_page, index));
ut_ad(btr_check_node_ptr(index, father_block, mtr));
+
+ return(father_block);
}
/*************************************************************//**
@@ -3156,11 +3192,13 @@ UNIV_INTERN
ibool
btr_compress(
/*=========*/
- btr_cur_t* cursor, /*!< in: cursor on the page to merge or lift;
- the page must not be empty: in record delete
- use btr_discard_page if the page would become
- empty */
- mtr_t* mtr) /*!< in: mtr */
+ btr_cur_t* cursor, /*!< in/out: cursor on the page to merge
+ or lift; the page must not be empty:
+ when deleting records, use btr_discard_page()
+ if the page would become empty */
+ ibool adjust, /*!< in: TRUE if should adjust the
+ cursor position even if compression occurs */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
dict_index_t* index;
ulint space;
@@ -3178,6 +3216,7 @@ btr_compress(
ulint* offsets;
ulint data_size;
ulint n_recs;
+ ulint nth_rec = 0; /* remove bogus warning */
ulint max_ins_size;
ulint max_ins_size_reorg;
@@ -3205,6 +3244,10 @@ btr_compress(
offsets = btr_page_get_father_block(NULL, heap, index, block, mtr,
&father_cursor);
+ if (adjust) {
+ nth_rec = page_rec_get_n_recs_before(btr_cur_get_rec(cursor));
+ }
+
/* Decide the page to which we try to merge and which will inherit
the locks */
@@ -3231,9 +3274,9 @@ btr_compress(
} else {
/* The page is the only one on the level, lift the records
to the father */
- btr_lift_page_up(index, block, mtr);
- mem_heap_free(heap);
- return(TRUE);
+
+ merge_block = btr_lift_page_up(index, block, mtr);
+ goto func_exit;
}
n_recs = page_get_n_recs(page);
@@ -3315,6 +3358,10 @@ err_exit:
btr_node_ptr_delete(index, block, mtr);
lock_update_merge_left(merge_block, orig_pred, block);
+
+ if (adjust) {
+ nth_rec += page_rec_get_n_recs_before(orig_pred);
+ }
} else {
rec_t* orig_succ;
#ifdef UNIV_BTR_DEBUG
@@ -3379,7 +3426,6 @@ err_exit:
}
btr_blob_dbg_remove(page, index, "btr_compress");
- mem_heap_free(heap);
if (!dict_index_is_clust(index) && page_is_leaf(merge_page)) {
/* Update the free bits of the B-tree page in the
@@ -3431,6 +3477,16 @@ err_exit:
btr_page_free(index, block, mtr);
ut_ad(btr_check_node_ptr(index, merge_block, mtr));
+func_exit:
+ mem_heap_free(heap);
+
+ if (adjust) {
+ btr_cur_position(
+ index,
+ page_rec_get_nth(merge_block->frame, nth_rec),
+ merge_block, cursor);
+ }
+
return(TRUE);
}
@@ -3867,7 +3923,7 @@ btr_index_rec_validate(
(ulong) rec_get_n_fields_old(rec), (ulong) n);
if (dump_on_error) {
- buf_page_print(page, 0);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
fputs("InnoDB: corrupt record ", stderr);
rec_print_old(stderr, rec);
@@ -3905,7 +3961,8 @@ btr_index_rec_validate(
(ulong) i, (ulong) len, (ulong) fixed_size);
if (dump_on_error) {
- buf_page_print(page, 0);
+ buf_page_print(page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
fputs("InnoDB: corrupt record ", stderr);
rec_print_new(stderr, rec, offsets);
@@ -4115,8 +4172,8 @@ loop:
btr_validate_report2(index, level, block, right_block);
fputs("InnoDB: broken FIL_PAGE_NEXT"
" or FIL_PAGE_PREV links\n", stderr);
- buf_page_print(page, 0);
- buf_page_print(right_page, 0);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH);
ret = FALSE;
}
@@ -4125,8 +4182,8 @@ loop:
!= page_is_comp(page))) {
btr_validate_report2(index, level, block, right_block);
fputs("InnoDB: 'compact' flag mismatch\n", stderr);
- buf_page_print(page, 0);
- buf_page_print(right_page, 0);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH);
ret = FALSE;
@@ -4149,8 +4206,8 @@ loop:
fputs("InnoDB: records in wrong order"
" on adjacent pages\n", stderr);
- buf_page_print(page, 0);
- buf_page_print(right_page, 0);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH);
fputs("InnoDB: record ", stderr);
rec = page_rec_get_prev(page_get_supremum_rec(page));
@@ -4199,8 +4256,8 @@ loop:
fputs("InnoDB: node pointer to the page is wrong\n",
stderr);
- buf_page_print(father_page, 0);
- buf_page_print(page, 0);
+ buf_page_print(father_page, 0, BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
fputs("InnoDB: node ptr ", stderr);
rec_print(stderr, node_ptr, index);
@@ -4232,8 +4289,10 @@ loop:
btr_validate_report1(index, level, block);
- buf_page_print(father_page, 0);
- buf_page_print(page, 0);
+ buf_page_print(father_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
fputs("InnoDB: Error: node ptrs differ"
" on levels > 0\n"
@@ -4278,9 +4337,15 @@ loop:
btr_validate_report1(index, level,
block);
- buf_page_print(father_page, 0);
- buf_page_print(page, 0);
- buf_page_print(right_page, 0);
+ buf_page_print(
+ father_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ right_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
}
} else {
page_t* right_father_page
@@ -4298,10 +4363,18 @@ loop:
btr_validate_report1(index, level,
block);
- buf_page_print(father_page, 0);
- buf_page_print(right_father_page, 0);
- buf_page_print(page, 0);
- buf_page_print(right_page, 0);
+ buf_page_print(
+ father_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ right_father_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ right_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
}
if (page_get_page_no(right_father_page)
@@ -4315,10 +4388,18 @@ loop:
btr_validate_report1(index, level,
block);
- buf_page_print(father_page, 0);
- buf_page_print(right_father_page, 0);
- buf_page_print(page, 0);
- buf_page_print(right_page, 0);
+ buf_page_print(
+ father_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ right_father_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(
+ right_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
}
}
}
diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c
index 1551aee5426..e227e47b52f 100644
--- a/storage/innobase/btr/btr0cur.c
+++ b/storage/innobase/btr/btr0cur.c
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -1860,7 +1860,7 @@ btr_cur_update_in_place(
page_zip = buf_block_get_page_zip(block);
/* Check that enough space is available on the compressed page. */
- if (UNIV_LIKELY_NULL(page_zip)
+ if (page_zip
&& !btr_cur_update_alloc_zip(page_zip, block, index,
rec_offs_size(offsets), FALSE, mtr)) {
return(DB_ZIP_OVERFLOW);
@@ -2051,7 +2051,7 @@ any_extern:
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
- if (UNIV_LIKELY_NULL(page_zip)
+ if (page_zip
&& !btr_cur_update_alloc_zip(page_zip, block, index,
new_rec_size, TRUE, mtr)) {
err = DB_ZIP_OVERFLOW;
@@ -2209,7 +2209,9 @@ btr_cur_pessimistic_update(
/*=======================*/
ulint flags, /*!< in: undo logging, locking, and rollback
flags */
- btr_cur_t* cursor, /*!< in: cursor on the record to update */
+ btr_cur_t* cursor, /*!< in/out: cursor on the record to update;
+ cursor may become invalid if *big_rec == NULL
+ || !(flags & BTR_KEEP_POS_FLAG) */
mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
be stored externally by the caller, or NULL */
@@ -2348,10 +2350,10 @@ btr_cur_pessimistic_update(
record to be inserted: we have to remember which fields were such */
ut_ad(!page_is_comp(page) || !rec_get_node_ptr_flag(rec));
- offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, heap);
+ ut_ad(rec_offs_validate(rec, index, offsets));
n_ext += btr_push_update_extern_fields(new_entry, update, *heap);
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
ut_ad(page_is_comp(page));
if (page_zip_rec_needs_ext(
rec_get_converted_size(index, new_entry, n_ext),
@@ -2371,6 +2373,10 @@ make_external:
err = DB_TOO_BIG_RECORD;
goto return_after_reservations;
}
+
+ ut_ad(page_is_leaf(page));
+ ut_ad(dict_index_is_clust(index));
+ ut_ad(flags & BTR_KEEP_POS_FLAG);
}
/* Store state of explicit locks on rec on the page infimum record,
@@ -2398,6 +2404,8 @@ make_external:
rec = btr_cur_insert_if_possible(cursor, new_entry, n_ext, mtr);
if (rec) {
+ page_cursor->rec = rec;
+
lock_rec_restore_from_page_infimum(btr_cur_get_block(cursor),
rec, block);
@@ -2411,7 +2419,10 @@ make_external:
rec, index, offsets, mtr);
}
- btr_cur_compress_if_useful(cursor, mtr);
+ btr_cur_compress_if_useful(
+ cursor,
+ big_rec_vec != NULL && (flags & BTR_KEEP_POS_FLAG),
+ mtr);
if (page_zip && !dict_index_is_clust(index)
&& page_is_leaf(page)) {
@@ -2431,6 +2442,21 @@ make_external:
}
}
+ if (big_rec_vec) {
+ ut_ad(page_is_leaf(page));
+ ut_ad(dict_index_is_clust(index));
+ ut_ad(flags & BTR_KEEP_POS_FLAG);
+
+ /* btr_page_split_and_insert() in
+ btr_cur_pessimistic_insert() invokes
+ mtr_memo_release(mtr, index->lock, MTR_MEMO_X_LOCK).
+ We must keep the index->lock when we created a
+ big_rec, so that row_upd_clust_rec() can store the
+ big_rec in the same mini-transaction. */
+
+ mtr_x_lock(dict_index_get_lock(index), mtr);
+ }
+
/* Was the record to be updated positioned as the first user
record on its page? */
was_first = page_cur_is_before_first(page_cursor);
@@ -2446,6 +2472,7 @@ make_external:
ut_a(rec);
ut_a(err == DB_SUCCESS);
ut_a(dummy_big_rec == NULL);
+ page_cursor->rec = rec;
if (dict_index_is_sec_or_ibuf(index)) {
/* Update PAGE_MAX_TRX_ID in the index page header.
@@ -2880,10 +2907,12 @@ UNIV_INTERN
ibool
btr_cur_compress_if_useful(
/*=======================*/
- btr_cur_t* cursor, /*!< in: cursor on the page to compress;
- cursor does not stay valid if compression
- occurs */
- mtr_t* mtr) /*!< in: mtr */
+ btr_cur_t* cursor, /*!< in/out: cursor on the page to compress;
+ cursor does not stay valid if !adjust and
+ compression occurs */
+ ibool adjust, /*!< in: TRUE if should adjust the
+ cursor position even if compression occurs */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
ut_ad(mtr_memo_contains(mtr,
dict_index_get_lock(btr_cur_get_index(cursor)),
@@ -2892,7 +2921,7 @@ btr_cur_compress_if_useful(
MTR_MEMO_PAGE_X_FIX));
return(btr_cur_compress_recommendation(cursor, mtr)
- && btr_compress(cursor, mtr));
+ && btr_compress(cursor, adjust, mtr));
}
/*******************************************************//**
@@ -3134,7 +3163,7 @@ return_after_reservations:
mem_heap_free(heap);
if (ret == FALSE) {
- ret = btr_cur_compress_if_useful(cursor, mtr);
+ ret = btr_cur_compress_if_useful(cursor, FALSE, mtr);
}
if (n_extents > 0) {
@@ -3870,10 +3899,10 @@ btr_cur_set_ownership_of_extern_field(
byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
}
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
mach_write_to_1(data + local_len + BTR_EXTERN_LEN, byte_val);
page_zip_write_blob_ptr(page_zip, rec, index, offsets, i, mtr);
- } else if (UNIV_LIKELY(mtr != NULL)) {
+ } else if (mtr != NULL) {
mlog_write_ulint(data + local_len + BTR_EXTERN_LEN, byte_val,
MLOG_1BYTE, mtr);
@@ -4106,9 +4135,9 @@ The fields are stored on pages allocated from leaf node
file segment of the index tree.
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
UNIV_INTERN
-ulint
-btr_store_big_rec_extern_fields_func(
-/*=================================*/
+enum db_err
+btr_store_big_rec_extern_fields(
+/*============================*/
dict_index_t* index, /*!< in: index of rec; the index tree
MUST be X-latched */
buf_block_t* rec_block, /*!< in/out: block containing rec */
@@ -4117,38 +4146,37 @@ btr_store_big_rec_extern_fields_func(
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
-#ifdef UNIV_DEBUG
- mtr_t* local_mtr, /*!< in: mtr containing the
- latch to rec and to the tree */
-#endif /* UNIV_DEBUG */
-#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
- ibool update_in_place,/*! in: TRUE if the record is updated
- in place (not delete+insert) */
-#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
- const big_rec_t*big_rec_vec) /*!< in: vector containing fields
+ const big_rec_t*big_rec_vec, /*!< in: vector containing fields
to be stored externally */
-
+ mtr_t* btr_mtr, /*!< in: mtr containing the
+ latches to the clustered index */
+ enum blob_op op) /*! in: operation code */
{
- ulint rec_page_no;
- byte* field_ref;
- ulint extern_len;
- ulint store_len;
- ulint page_no;
- ulint space_id;
- ulint zip_size;
- ulint prev_page_no;
- ulint hint_page_no;
- ulint i;
- mtr_t mtr;
- mem_heap_t* heap = NULL;
+ ulint rec_page_no;
+ byte* field_ref;
+ ulint extern_len;
+ ulint store_len;
+ ulint page_no;
+ ulint space_id;
+ ulint zip_size;
+ ulint prev_page_no;
+ ulint hint_page_no;
+ ulint i;
+ mtr_t mtr;
+ mtr_t* alloc_mtr;
+ mem_heap_t* heap = NULL;
page_zip_des_t* page_zip;
- z_stream c_stream;
+ z_stream c_stream;
+ buf_block_t** freed_pages = NULL;
+ ulint n_freed_pages = 0;
+ enum db_err error = DB_SUCCESS;
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_any_extern(offsets));
- ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
+ ut_ad(btr_mtr);
+ ut_ad(mtr_memo_contains(btr_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
- ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
+ ut_ad(mtr_memo_contains(btr_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
ut_ad(buf_block_get_frame(rec_block) == page_align(rec));
ut_a(dict_index_is_clust(index));
@@ -4161,7 +4189,7 @@ btr_store_big_rec_extern_fields_func(
rec_page_no = buf_block_get_page_no(rec_block);
ut_a(fil_page_get_type(page_align(rec)) == FIL_PAGE_INDEX);
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
int err;
/* Zlib deflate needs 128 kilobytes for the default
@@ -4177,6 +4205,42 @@ btr_store_big_rec_extern_fields_func(
ut_a(err == Z_OK);
}
+ if (btr_blob_op_is_update(op)) {
+ /* Avoid reusing pages that have been previously freed
+ in btr_mtr. */
+ if (btr_mtr->n_freed_pages) {
+ if (heap == NULL) {
+ heap = mem_heap_create(
+ btr_mtr->n_freed_pages
+ * sizeof *freed_pages);
+ }
+
+ freed_pages = mem_heap_alloc(
+ heap,
+ btr_mtr->n_freed_pages
+ * sizeof *freed_pages);
+ n_freed_pages = 0;
+ }
+
+ /* Because btr_mtr will be committed after mtr, it is
+ possible that the tablespace has been extended when
+ the B-tree record was updated or inserted, or it will
+ be extended while allocating pages for big_rec.
+
+ TODO: In mtr (not btr_mtr), write a redo log record
+ about extending the tablespace to its current size,
+ and remember the current size. Whenever the tablespace
+ grows as pages are allocated, write further redo log
+ records to mtr. (Currently tablespace extension is not
+ covered by the redo log. If it were, the record would
+ only be written to btr_mtr, which is committed after
+ mtr.) */
+ alloc_mtr = btr_mtr;
+ } else {
+ /* Use the local mtr for allocations. */
+ alloc_mtr = &mtr;
+ }
+
#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
/* All pointers to externally stored columns in the record
must either be zero or they must be pointers to inherited
@@ -4191,7 +4255,7 @@ btr_store_big_rec_extern_fields_func(
/* Either this must be an update in place,
or the BLOB must be inherited, or the BLOB pointer
must be zero (will be written in this function). */
- ut_a(update_in_place
+ ut_a(op == BTR_STORE_UPDATE
|| (field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG)
|| !memcmp(field_ref, field_ref_zero,
BTR_EXTERN_FIELD_REF_SIZE));
@@ -4216,7 +4280,7 @@ btr_store_big_rec_extern_fields_func(
prev_page_no = FIL_NULL;
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
int err = deflateReset(&c_stream);
ut_a(err == Z_OK);
@@ -4236,18 +4300,24 @@ btr_store_big_rec_extern_fields_func(
hint_page_no = prev_page_no + 1;
}
+alloc_another:
block = btr_page_alloc(index, hint_page_no,
- FSP_NO_DIR, 0, &mtr);
+ FSP_NO_DIR, 0, alloc_mtr, &mtr);
if (UNIV_UNLIKELY(block == NULL)) {
-
mtr_commit(&mtr);
+ error = DB_OUT_OF_FILE_SPACE;
+ goto func_exit;
+ }
- if (UNIV_LIKELY_NULL(page_zip)) {
- deflateEnd(&c_stream);
- mem_heap_free(heap);
- }
-
- return(DB_OUT_OF_FILE_SPACE);
+ if (rw_lock_get_x_lock_count(&block->lock) > 1) {
+ /* This page must have been freed in
+ btr_mtr previously. Put it aside, and
+ allocate another page for the BLOB data. */
+ ut_ad(alloc_mtr == btr_mtr);
+ ut_ad(btr_blob_op_is_update(op));
+ ut_ad(n_freed_pages < btr_mtr->n_freed_pages);
+ freed_pages[n_freed_pages++] = block;
+ goto alloc_another;
}
page_no = buf_block_get_page_no(block);
@@ -4264,7 +4334,7 @@ btr_store_big_rec_extern_fields_func(
SYNC_EXTERN_STORAGE);
prev_page = buf_block_get_frame(prev_block);
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
mlog_write_ulint(
prev_page + FIL_PAGE_NEXT,
page_no, MLOG_4BYTES, &mtr);
@@ -4281,7 +4351,7 @@ btr_store_big_rec_extern_fields_func(
}
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
int err;
page_zip_des_t* blob_page_zip;
@@ -4364,11 +4434,15 @@ btr_store_big_rec_extern_fields_func(
goto next_zip_page;
}
- rec_block = buf_page_get(space_id, zip_size,
- rec_page_no,
- RW_X_LATCH, &mtr);
- buf_block_dbg_add_level(rec_block,
- SYNC_NO_ORDER_CHECK);
+ if (alloc_mtr == &mtr) {
+ rec_block = buf_page_get(
+ space_id, zip_size,
+ rec_page_no,
+ RW_X_LATCH, &mtr);
+ buf_block_dbg_add_level(
+ rec_block,
+ SYNC_NO_ORDER_CHECK);
+ }
if (err == Z_STREAM_END) {
mach_write_to_4(field_ref
@@ -4402,7 +4476,8 @@ btr_store_big_rec_extern_fields_func(
page_zip_write_blob_ptr(
page_zip, rec, index, offsets,
- big_rec_vec->fields[i].field_no, &mtr);
+ big_rec_vec->fields[i].field_no,
+ alloc_mtr);
next_zip_page:
prev_page_no = page_no;
@@ -4447,19 +4522,23 @@ next_zip_page:
extern_len -= store_len;
- rec_block = buf_page_get(space_id, zip_size,
- rec_page_no,
- RW_X_LATCH, &mtr);
- buf_block_dbg_add_level(rec_block,
- SYNC_NO_ORDER_CHECK);
+ if (alloc_mtr == &mtr) {
+ rec_block = buf_page_get(
+ space_id, zip_size,
+ rec_page_no,
+ RW_X_LATCH, &mtr);
+ buf_block_dbg_add_level(
+ rec_block,
+ SYNC_NO_ORDER_CHECK);
+ }
mlog_write_ulint(field_ref + BTR_EXTERN_LEN, 0,
- MLOG_4BYTES, &mtr);
+ MLOG_4BYTES, alloc_mtr);
mlog_write_ulint(field_ref
+ BTR_EXTERN_LEN + 4,
big_rec_vec->fields[i].len
- extern_len,
- MLOG_4BYTES, &mtr);
+ MLOG_4BYTES, alloc_mtr);
if (prev_page_no == FIL_NULL) {
btr_blob_dbg_add_blob(
@@ -4469,18 +4548,19 @@ next_zip_page:
mlog_write_ulint(field_ref
+ BTR_EXTERN_SPACE_ID,
- space_id,
- MLOG_4BYTES, &mtr);
+ space_id, MLOG_4BYTES,
+ alloc_mtr);
mlog_write_ulint(field_ref
+ BTR_EXTERN_PAGE_NO,
- page_no,
- MLOG_4BYTES, &mtr);
+ page_no, MLOG_4BYTES,
+ alloc_mtr);
mlog_write_ulint(field_ref
+ BTR_EXTERN_OFFSET,
FIL_PAGE_DATA,
- MLOG_4BYTES, &mtr);
+ MLOG_4BYTES,
+ alloc_mtr);
}
prev_page_no = page_no;
@@ -4494,8 +4574,23 @@ next_zip_page:
}
}
- if (UNIV_LIKELY_NULL(page_zip)) {
+func_exit:
+ if (page_zip) {
deflateEnd(&c_stream);
+ }
+
+ if (n_freed_pages) {
+ ulint i;
+
+ ut_ad(alloc_mtr == btr_mtr);
+ ut_ad(btr_blob_op_is_update(op));
+
+ for (i = 0; i < n_freed_pages; i++) {
+ btr_page_free_low(index, freed_pages[i], 0, alloc_mtr);
+ }
+ }
+
+ if (heap != NULL) {
mem_heap_free(heap);
}
@@ -4516,7 +4611,7 @@ next_zip_page:
ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
}
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
- return(DB_SUCCESS);
+ return(error);
}
/*******************************************************************//**
@@ -4719,7 +4814,7 @@ btr_free_externally_stored_field(
btr_page_free_low(index, ext_block, 0, &mtr);
- if (UNIV_LIKELY(page_zip != NULL)) {
+ if (page_zip) {
mach_write_to_4(field_ref + BTR_EXTERN_PAGE_NO,
next_page_no);
mach_write_to_4(field_ref + BTR_EXTERN_LEN + 4,
diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c
index 1825544a265..53a0c0eb5d9 100644
--- a/storage/innobase/btr/btr0sea.c
+++ b/storage/innobase/btr/btr0sea.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -1176,7 +1176,7 @@ cleanup:
index->name, (ulong) block->n_pointers);
rw_lock_x_unlock(&btr_search_latch);
- btr_search_validate();
+ ut_ad(btr_search_validate());
} else {
rw_lock_x_unlock(&btr_search_latch);
}
@@ -1908,7 +1908,9 @@ btr_search_validate(void)
(ulong) block->curr_left_side);
if (n_page_dumps < 20) {
- buf_page_print(page, 0);
+ buf_page_print(
+ page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
n_page_dumps++;
}
}
diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c
index 0721929abd3..7b13caf6216 100644
--- a/storage/innobase/buf/buf0buf.c
+++ b/storage/innobase/buf/buf0buf.c
@@ -605,8 +605,12 @@ void
buf_page_print(
/*===========*/
const byte* read_buf, /*!< in: a database page */
- ulint zip_size) /*!< in: compressed page size, or
- 0 for uncompressed pages */
+ ulint zip_size, /*!< in: compressed page size, or
+ 0 for uncompressed pages */
+ ulint flags) /*!< in: 0 or
+ BUF_PAGE_PRINT_NO_CRASH or
+ BUF_PAGE_PRINT_NO_FULL */
+
{
#ifndef UNIV_HOTBACKUP
dict_index_t* index;
@@ -615,17 +619,18 @@ buf_page_print(
ulint old_checksum;
ulint size = zip_size;
- ut_ad(0);
-
if (!size) {
size = UNIV_PAGE_SIZE;
}
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n",
- (ulong) size);
- ut_print_buf(stderr, read_buf, size);
- fputs("\nInnoDB: End of page dump\n", stderr);
+ if (!(flags & BUF_PAGE_PRINT_NO_FULL)) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Page dump in ascii and hex (%lu bytes):\n",
+ (ulong) size);
+ ut_print_buf(stderr, read_buf, size);
+ fputs("\nInnoDB: End of page dump\n", stderr);
+ }
if (zip_size) {
/* Print compressed page. */
@@ -797,6 +802,8 @@ buf_page_print(
stderr);
break;
}
+
+ ut_ad(flags & BUF_PAGE_PRINT_NO_CRASH);
}
#ifndef UNIV_HOTBACKUP
@@ -3557,7 +3564,8 @@ corrupt:
"InnoDB: You may have to recover"
" from a backup.\n",
(ulong) bpage->offset);
- buf_page_print(frame, buf_page_get_zip_size(bpage));
+ buf_page_print(frame, buf_page_get_zip_size(bpage),
+ BUF_PAGE_PRINT_NO_CRASH);
fprintf(stderr,
"InnoDB: Database page corruption on disk"
" or a failed\n"
diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c
index 06b3ec393c1..6e8e8fdda5a 100644
--- a/storage/innobase/buf/buf0flu.c
+++ b/storage/innobase/buf/buf0flu.c
@@ -757,7 +757,8 @@ buf_flush_buffered_writes(void)
if (UNIV_UNLIKELY
(!page_simple_validate_new(block->frame))) {
corrupted_page:
- buf_page_print(block->frame, 0);
+ buf_page_print(block->frame, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
ut_print_timestamp(stderr);
fprintf(stderr,
diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c
index 2e4c6aeeb60..091becca258 100644
--- a/storage/innobase/fil/fil0fil.c
+++ b/storage/innobase/fil/fil0fil.c
@@ -964,11 +964,6 @@ retry:
return;
}
- if (fil_system->n_open < fil_system->max_n_open) {
-
- return;
- }
-
space = fil_space_get_by_id(space_id);
if (space != NULL && space->stop_ios) {
@@ -985,6 +980,25 @@ retry:
mutex_exit(&fil_system->mutex);
+#ifndef UNIV_HOTBACKUP
+
+ /* Wake the i/o-handler threads to make sure pending
+ i/o's are performed */
+ os_aio_simulated_wake_handler_threads();
+
+ /* The sleep here is just to give IO helper threads a
+ bit of time to do some work. It is not required that
+ all IO related to the tablespace being renamed must
+ be flushed here as we do fil_flush() in
+ fil_rename_tablespace() as well. */
+ os_thread_sleep(20000);
+
+#endif /* UNIV_HOTBACKUP */
+
+ /* Flush tablespaces so that we can close modified
+ files in the LRU list */
+ fil_flush_file_spaces(FIL_TABLESPACE);
+
os_thread_sleep(20000);
count2++;
@@ -992,6 +1006,11 @@ retry:
goto retry;
}
+ if (fil_system->n_open < fil_system->max_n_open) {
+
+ return;
+ }
+
/* If the file is already open, no need to do anything; if the space
does not exist, we handle the situation in the function which called
this function */
@@ -2551,7 +2570,7 @@ fil_rename_tablespace(
retry:
count++;
- if (count > 1000) {
+ if (!(count % 1000)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: problems renaming ", stderr);
ut_print_filename(stderr, old_name);
diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c
index 2d626405c5c..6a3cd912141 100644
--- a/storage/innobase/fsp/fsp0fsp.c
+++ b/storage/innobase/fsp/fsp0fsp.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -250,28 +250,38 @@ fsp_fill_free_list(
descriptor page and ibuf bitmap page;
then we do not allocate more extents */
ulint space, /*!< in: space */
- fsp_header_t* header, /*!< in: space header */
- mtr_t* mtr); /*!< in: mtr */
+ fsp_header_t* header, /*!< in/out: space header */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+ __attribute__((nonnull));
/**********************************************************************//**
Allocates a single free page from a segment. This function implements
the intelligent allocation strategy which tries to minimize file space
fragmentation.
-@return the allocated page number, FIL_NULL if no page could be allocated */
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
static
-ulint
+buf_block_t*
fseg_alloc_free_page_low(
/*=====================*/
ulint space, /*!< in: space */
ulint zip_size,/*!< in: compressed page size in bytes
or 0 for uncompressed pages */
- fseg_inode_t* seg_inode, /*!< in: segment inode */
- ulint hint, /*!< in: hint of which page would be desirable */
+ fseg_inode_t* seg_inode, /*!< in/out: segment inode */
+ ulint hint, /*!< in: hint of which page would be
+ desirable */
byte direction, /*!< in: if the new page is needed because
of an index page split, and records are
inserted there in order, into which
direction they go alphabetically: FSP_DOWN,
FSP_UP, FSP_NO_DIR */
- mtr_t* mtr); /*!< in: mtr handle */
+ mtr_t* mtr, /*!< in/out: mini-transaction */
+ 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
+ latched in mtr, do not initialize the page. */
+ __attribute__((warn_unused_result, nonnull));
#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
@@ -639,17 +649,18 @@ list, if not free limit == space size. This adding is necessary to make the
descriptor defined, as they are uninitialized above the free limit.
@return pointer to the extent descriptor, NULL if the page does not
exist in the space or if the offset exceeds the free limit */
-UNIV_INLINE
+UNIV_INLINE __attribute__((nonnull, warn_unused_result))
xdes_t*
xdes_get_descriptor_with_space_hdr(
/*===============================*/
- fsp_header_t* sp_header,/*!< in/out: space header, x-latched */
- ulint space, /*!< in: space id */
- ulint offset, /*!< in: page offset;
- if equal to the free limit,
- we try to add new extents to
- the space free list */
- mtr_t* mtr) /*!< in: mtr handle */
+ fsp_header_t* sp_header, /*!< in/out: space header, x-latched
+ in mtr */
+ ulint space, /*!< in: space id */
+ ulint offset, /*!< in: page offset; if equal
+ to the free limit, we try to
+ add new extents to the space
+ free list */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
ulint limit;
ulint size;
@@ -657,11 +668,9 @@ xdes_get_descriptor_with_space_hdr(
ulint descr_page_no;
page_t* descr_page;
- ut_ad(mtr);
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
- ut_ad(mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_S_FIX)
- || mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_X_FIX));
+ ut_ad(mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_offset(sp_header) == FSP_HEADER_OFFSET);
/* Read free limit and space size */
limit = mach_read_from_4(sp_header + FSP_FREE_LIMIT);
@@ -711,7 +720,7 @@ is necessary to make the descriptor defined, as they are uninitialized
above the free limit.
@return pointer to the extent descriptor, NULL if the page does not
exist in the space or if the offset exceeds the free limit */
-static
+static __attribute__((nonnull, warn_unused_result))
xdes_t*
xdes_get_descriptor(
/*================*/
@@ -720,7 +729,7 @@ xdes_get_descriptor(
or 0 for uncompressed pages */
ulint offset, /*!< in: page offset; if equal to the free limit,
we try to add new extents to the space free list */
- mtr_t* mtr) /*!< in: mtr handle */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
buf_block_t* block;
fsp_header_t* sp_header;
@@ -1098,14 +1107,14 @@ fsp_header_get_tablespace_size(void)
Tries to extend a single-table tablespace so that a page would fit in the
data file.
@return TRUE if success */
-static
+static __attribute__((nonnull, warn_unused_result))
ibool
fsp_try_extend_data_file_with_pages(
/*================================*/
ulint space, /*!< in: space */
ulint page_no, /*!< in: page number */
- fsp_header_t* header, /*!< in: space header */
- mtr_t* mtr) /*!< in: mtr */
+ fsp_header_t* header, /*!< in/out: space header */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
ibool success;
ulint actual_size;
@@ -1130,7 +1139,7 @@ fsp_try_extend_data_file_with_pages(
/***********************************************************************//**
Tries to extend the last data file of a tablespace if it is auto-extending.
@return FALSE if not auto-extending */
-static
+static __attribute__((nonnull))
ibool
fsp_try_extend_data_file(
/*=====================*/
@@ -1140,8 +1149,8 @@ fsp_try_extend_data_file(
the actual file size rounded down to
megabyte */
ulint space, /*!< in: space */
- fsp_header_t* header, /*!< in: space header */
- mtr_t* mtr) /*!< in: mtr */
+ fsp_header_t* header, /*!< in/out: space header */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
ulint size;
ulint zip_size;
@@ -1277,7 +1286,7 @@ fsp_fill_free_list(
then we do not allocate more extents */
ulint space, /*!< in: space */
fsp_header_t* header, /*!< in/out: space header */
- mtr_t* mtr) /*!< in: mtr */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
ulint limit;
ulint size;
@@ -1476,29 +1485,120 @@ fsp_alloc_free_extent(
}
/**********************************************************************//**
-Allocates a single free page from a space. The page is marked as used.
-@return the page offset, FIL_NULL if no page could be allocated */
+Allocates a single free page from a space. */
+static __attribute__((nonnull))
+void
+fsp_alloc_from_free_frag(
+/*=====================*/
+ fsp_header_t* header, /*!< in/out: tablespace header */
+ xdes_t* descr, /*!< in/out: extent descriptor */
+ ulint bit, /*!< in: slot to allocate in the extent */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+{
+ ulint frag_n_used;
+
+ ut_ad(xdes_get_state(descr, mtr) == XDES_FREE_FRAG);
+ ut_a(xdes_get_bit(descr, XDES_FREE_BIT, bit, mtr));
+ xdes_set_bit(descr, XDES_FREE_BIT, bit, FALSE, mtr);
+
+ /* Update the FRAG_N_USED field */
+ frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
+ mtr);
+ frag_n_used++;
+ mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used, MLOG_4BYTES,
+ mtr);
+ if (xdes_is_full(descr, mtr)) {
+ /* The fragment is full: move it to another list */
+ flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
+ mtr);
+ xdes_set_state(descr, XDES_FULL_FRAG, mtr);
+
+ flst_add_last(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
+ mtr);
+ mlog_write_ulint(header + FSP_FRAG_N_USED,
+ frag_n_used - FSP_EXTENT_SIZE, MLOG_4BYTES,
+ mtr);
+ }
+}
+
+/**********************************************************************//**
+Gets a buffer block for an allocated page.
+
+NOTE: If init_mtr != mtr, the block will only be initialized if it was
+not previously x-latched. It is assumed that the block has been
+x-latched only by mtr, and freed in mtr in that case.
+
+@return block, initialized if init_mtr==mtr
+or rw_lock_x_lock_count(&block->lock) == 1 */
static
-ulint
+buf_block_t*
+fsp_page_create(
+/*============*/
+ ulint space, /*!< in: space id of the allocated page */
+ ulint zip_size, /*!< in: compressed page size in bytes
+ or 0 for uncompressed pages */
+ ulint page_no, /*!< in: page number of the allocated page */
+ mtr_t* mtr, /*!< in: mini-transaction of the allocation */
+ mtr_t* init_mtr) /*!< in: mini-transaction for initializing
+ the page */
+{
+ buf_block_t* block
+ = buf_page_create(space, page_no, zip_size, init_mtr);
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)
+ == rw_lock_own(&block->lock, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+ /* Mimic buf_page_get(), but avoid the buf_pool->page_hash lookup. */
+ rw_lock_x_lock(&block->lock);
+ mutex_enter(&block->mutex);
+ buf_block_buf_fix_inc(block, __FILE__, __LINE__);
+ mutex_exit(&block->mutex);
+ mtr_memo_push(init_mtr, block, MTR_MEMO_PAGE_X_FIX);
+
+ if (init_mtr == mtr
+ || rw_lock_get_x_lock_count(&block->lock) == 1) {
+
+ /* Initialize the page, unless it was already
+ X-latched in mtr. (In this case, we would want to
+ allocate another page that has not been freed in mtr.) */
+ ut_ad(init_mtr == mtr
+ || !mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+
+ fsp_init_file_page(block, init_mtr);
+ }
+
+ return(block);
+}
+
+/**********************************************************************//**
+Allocates a single free page from a space. The page is marked as used.
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
+static __attribute__((nonnull, warn_unused_result))
+buf_block_t*
fsp_alloc_free_page(
/*================*/
ulint space, /*!< in: space id */
ulint zip_size,/*!< in: compressed page size in bytes
or 0 for uncompressed pages */
ulint hint, /*!< in: hint of which page would be desirable */
- mtr_t* mtr) /*!< in: mtr handle */
+ mtr_t* mtr, /*!< in/out: mini-transaction */
+ mtr_t* init_mtr)/*!< in/out: mini-transaction in which the
+ page should be initialized
+ (may be the same as mtr) */
{
fsp_header_t* header;
fil_addr_t first;
xdes_t* descr;
- buf_block_t* block;
ulint free;
- ulint frag_n_used;
ulint page_no;
ulint space_size;
- ibool success;
ut_ad(mtr);
+ ut_ad(init_mtr);
header = fsp_get_space_header(space, zip_size, mtr);
@@ -1525,7 +1625,7 @@ fsp_alloc_free_page(
if (descr == NULL) {
/* No free space left */
- return(FIL_NULL);
+ return(NULL);
}
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
@@ -1570,50 +1670,18 @@ fsp_alloc_free_page(
" space size %lu. Page no %lu.\n",
(ulong) space, (ulong) space_size,
(ulong) page_no);
- return(FIL_NULL);
+ return(NULL);
}
- success = fsp_try_extend_data_file_with_pages(space, page_no,
- header, mtr);
- if (!success) {
+ if (!fsp_try_extend_data_file_with_pages(space, page_no,
+ header, mtr)) {
/* No disk space left */
- return(FIL_NULL);
+ return(NULL);
}
}
- xdes_set_bit(descr, XDES_FREE_BIT, free, FALSE, mtr);
+ fsp_alloc_from_free_frag(header, descr, free, mtr);
- /* Update the FRAG_N_USED field */
- frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
- mtr);
- frag_n_used++;
- mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used, MLOG_4BYTES,
- mtr);
- if (xdes_is_full(descr, mtr)) {
- /* The fragment is full: move it to another list */
- flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
- mtr);
- xdes_set_state(descr, XDES_FULL_FRAG, mtr);
-
- flst_add_last(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
- mtr);
- mlog_write_ulint(header + FSP_FRAG_N_USED,
- frag_n_used - FSP_EXTENT_SIZE, MLOG_4BYTES,
- mtr);
- }
-
- /* Initialize the allocated page to the buffer pool, so that it can
- be obtained immediately with buf_page_get without need for a disk
- read. */
-
- buf_page_create(space, page_no, zip_size, mtr);
-
- block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
- buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
-
- /* Prior contents of the page should be ignored */
- fsp_init_file_page(block, mtr);
-
- return(page_no);
+ return(fsp_page_create(space, zip_size, page_no, mtr, init_mtr));
}
/**********************************************************************//**
@@ -1652,6 +1720,9 @@ fsp_free_page(
fputs("InnoDB: Dump of descriptor: ", stderr);
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
putc('\n', stderr);
+ /* Crash in debug version, so that we get a core dump
+ of this corruption. */
+ ut_ad(0);
if (state == XDES_FREE) {
/* We put here some fault tolerance: if the page
@@ -1670,6 +1741,9 @@ fsp_free_page(
"InnoDB: Dump of descriptor: ", (ulong) page);
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
putc('\n', stderr);
+ /* Crash in debug version, so that we get a core dump
+ of this corruption. */
+ ut_ad(0);
/* We put here some fault tolerance: if the page
is already free, return without doing anything! */
@@ -1704,6 +1778,8 @@ fsp_free_page(
mtr);
fsp_free_extent(space, zip_size, page, mtr);
}
+
+ mtr->n_freed_pages++;
}
/**********************************************************************//**
@@ -1836,7 +1912,6 @@ fsp_alloc_seg_inode_page(
fseg_inode_t* inode;
buf_block_t* block;
page_t* page;
- ulint page_no;
ulint space;
ulint zip_size;
ulint i;
@@ -1847,15 +1922,15 @@ fsp_alloc_seg_inode_page(
zip_size = dict_table_flags_to_zip_size(
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
- page_no = fsp_alloc_free_page(space, zip_size, 0, mtr);
+ block = fsp_alloc_free_page(space, zip_size, 0, mtr, mtr);
- if (page_no == FIL_NULL) {
+ if (block == NULL) {
return(FALSE);
}
- block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
+ ut_ad(rw_lock_get_x_lock_count(&block->lock) == 1);
block->check_index_page_at_flush = FALSE;
@@ -2258,19 +2333,20 @@ fseg_create_general(
}
if (page == 0) {
- page = fseg_alloc_free_page_low(space, zip_size,
- inode, 0, FSP_UP, mtr);
+ block = fseg_alloc_free_page_low(space, zip_size,
+ inode, 0, FSP_UP, mtr, mtr);
- if (page == FIL_NULL) {
+ if (block == NULL) {
fsp_free_seg_inode(space, zip_size, inode, mtr);
goto funct_exit;
}
- block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
+ ut_ad(rw_lock_get_x_lock_count(&block->lock) == 1);
+
header = byte_offset + buf_block_get_frame(block);
- mlog_write_ulint(header - byte_offset + FIL_PAGE_TYPE,
+ mlog_write_ulint(buf_block_get_frame(block) + FIL_PAGE_TYPE,
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr);
}
@@ -2447,8 +2523,10 @@ fseg_fill_free_list(
Allocates a free extent for the segment: looks first in the free list of the
segment, then tries to allocate from the space free list. NOTE that the extent
returned still resides in the segment free list, it is not yet taken off it!
-@return allocated extent, still placed in the segment free list, NULL
-if could not be allocated */
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
static
xdes_t*
fseg_alloc_free_extent(
@@ -2500,22 +2578,30 @@ fseg_alloc_free_extent(
Allocates a single free page from a segment. This function implements
the intelligent allocation strategy which tries to minimize file space
fragmentation.
-@return the allocated page number, FIL_NULL if no page could be allocated */
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
static
-ulint
+buf_block_t*
fseg_alloc_free_page_low(
/*=====================*/
ulint space, /*!< in: space */
ulint zip_size,/*!< in: compressed page size in bytes
or 0 for uncompressed pages */
- fseg_inode_t* seg_inode, /*!< in: segment inode */
- ulint hint, /*!< in: hint of which page would be desirable */
+ fseg_inode_t* seg_inode, /*!< in/out: segment inode */
+ ulint hint, /*!< in: hint of which page would be
+ desirable */
byte direction, /*!< in: if the new page is needed because
of an index page split, and records are
inserted there in order, into which
direction they go alphabetically: FSP_DOWN,
FSP_UP, FSP_NO_DIR */
- mtr_t* mtr) /*!< in: mtr handle */
+ mtr_t* mtr, /*!< in/out: mini-transaction */
+ 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
+ latched in mtr, do not initialize the page. */
{
fsp_header_t* space_header;
ulint space_size;
@@ -2526,7 +2612,6 @@ fseg_alloc_free_page_low(
ulint ret_page; /*!< the allocated page offset, FIL_NULL
if could not be allocated */
xdes_t* ret_descr; /*!< the extent of the allocated page */
- ibool frag_page_allocated = FALSE;
ibool success;
ulint n;
@@ -2548,6 +2633,7 @@ fseg_alloc_free_page_low(
if (descr == NULL) {
/* Hint outside space or too high above free limit: reset
hint */
+ /* The file space header page is always allocated. */
hint = 0;
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
}
@@ -2558,15 +2644,19 @@ fseg_alloc_free_page_low(
&& mach_read_from_8(descr + XDES_ID) == seg_id
&& (xdes_get_bit(descr, XDES_FREE_BIT,
hint % FSP_EXTENT_SIZE, mtr) == TRUE)) {
-
+take_hinted_page:
/* 1. We can take the hinted page
=================================*/
ret_descr = descr;
ret_page = hint;
+ /* Skip the check for extending the tablespace. If the
+ page hint were not within the size of the tablespace,
+ we would have got (descr == NULL) above and reset the hint. */
+ goto got_hinted_page;
/*-----------------------------------------------------------*/
- } else if ((xdes_get_state(descr, mtr) == XDES_FREE)
- && ((reserved - used) < reserved / FSEG_FILLFACTOR)
- && (used >= FSEG_FRAG_LIMIT)) {
+ } else if (xdes_get_state(descr, mtr) == XDES_FREE
+ && reserved - used < reserved / FSEG_FILLFACTOR
+ && used >= FSEG_FRAG_LIMIT) {
/* 2. We allocate the free extent from space and can take
=========================================================
@@ -2584,7 +2674,7 @@ fseg_alloc_free_page_low(
/* Try to fill the segment free list */
fseg_fill_free_list(seg_inode, space, zip_size,
hint + FSP_EXTENT_SIZE, mtr);
- ret_page = hint;
+ goto take_hinted_page;
/*-----------------------------------------------------------*/
} else if ((direction != FSP_NO_DIR)
&& ((reserved - used) < reserved / FSEG_FILLFACTOR)
@@ -2632,7 +2722,7 @@ fseg_alloc_free_page_low(
first = flst_get_first(seg_inode + FSEG_FREE, mtr);
} else {
ut_error;
- return(FIL_NULL);
+ return(NULL);
}
ret_descr = xdes_lst_get_descriptor(space, zip_size,
@@ -2644,20 +2734,23 @@ fseg_alloc_free_page_low(
} else if (used < FSEG_FRAG_LIMIT) {
/* 6. We allocate an individual page from the space
===================================================*/
- ret_page = fsp_alloc_free_page(space, zip_size, hint, mtr);
- ret_descr = NULL;
+ buf_block_t* block = fsp_alloc_free_page(
+ space, zip_size, hint, mtr, init_mtr);
- frag_page_allocated = TRUE;
-
- if (ret_page != FIL_NULL) {
+ if (block != NULL) {
/* Put the page in the fragment page array of the
segment */
n = fseg_find_free_frag_page_slot(seg_inode, mtr);
- ut_a(n != FIL_NULL);
+ ut_a(n != ULINT_UNDEFINED);
- fseg_set_nth_frag_page_no(seg_inode, n, ret_page,
- mtr);
+ fseg_set_nth_frag_page_no(
+ seg_inode, n, buf_block_get_page_no(block),
+ mtr);
}
+
+ /* fsp_alloc_free_page() invoked fsp_init_file_page()
+ already. */
+ return(block);
/*-----------------------------------------------------------*/
} else {
/* 7. We allocate a new extent and take its first page
@@ -2675,7 +2768,7 @@ fseg_alloc_free_page_low(
if (ret_page == FIL_NULL) {
/* Page could not be allocated */
- return(FIL_NULL);
+ return(NULL);
}
if (space != 0) {
@@ -2693,38 +2786,22 @@ fseg_alloc_free_page_low(
" the space size %lu. Page no %lu.\n",
(ulong) space, (ulong) space_size,
(ulong) ret_page);
- return(FIL_NULL);
+ return(NULL);
}
success = fsp_try_extend_data_file_with_pages(
space, ret_page, space_header, mtr);
if (!success) {
/* No disk space left */
- return(FIL_NULL);
+ return(NULL);
}
}
}
- if (!frag_page_allocated) {
- /* Initialize the allocated page to buffer pool, so that it
- can be obtained immediately with buf_page_get without need
- for a disk read */
- buf_block_t* block;
- ulint zip_size = dict_table_flags_to_zip_size(
- mach_read_from_4(FSP_SPACE_FLAGS + space_header));
-
- block = buf_page_create(space, ret_page, zip_size, mtr);
- buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
-
- if (UNIV_UNLIKELY(block != buf_page_get(space, zip_size,
- ret_page, RW_X_LATCH,
- mtr))) {
- ut_error;
- }
-
- /* The prior contents of the page should be ignored */
- fsp_init_file_page(block, mtr);
-
+got_hinted_page:
+ /* ret_descr == NULL if the block was allocated from free_frag
+ (XDES_FREE_FRAG) */
+ if (ret_descr != NULL) {
/* At this point we know the extent and the page offset.
The extent is still in the appropriate list (FSEG_NOT_FULL
or FSEG_FREE), and the page is not yet marked as used. */
@@ -2737,22 +2814,28 @@ fseg_alloc_free_page_low(
fseg_mark_page_used(seg_inode, space, zip_size, ret_page, mtr);
}
- buf_reset_check_index_page_at_flush(space, ret_page);
-
- return(ret_page);
+ return(fsp_page_create(
+ space, dict_table_flags_to_zip_size(
+ mach_read_from_4(FSP_SPACE_FLAGS
+ + space_header)),
+ ret_page, mtr, init_mtr));
}
/**********************************************************************//**
Allocates a single free page from a segment. This function implements
the intelligent allocation strategy which tries to minimize file space
fragmentation.
-@return allocated page offset, FIL_NULL if no page could be allocated */
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
UNIV_INTERN
-ulint
+buf_block_t*
fseg_alloc_free_page_general(
/*=========================*/
- fseg_header_t* seg_header,/*!< in: segment header */
- ulint hint, /*!< in: hint of which page would be desirable */
+ fseg_header_t* seg_header,/*!< in/out: segment header */
+ ulint hint, /*!< in: hint of which page would be
+ desirable */
byte direction,/*!< in: if the new page is needed because
of an index page split, and records are
inserted there in order, into which
@@ -2763,15 +2846,18 @@ fseg_alloc_free_page_general(
with fsp_reserve_free_extents, then there
is no need to do the check for this individual
page */
- mtr_t* mtr) /*!< in: mtr handle */
+ mtr_t* mtr, /*!< in/out: mini-transaction handle */
+ 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
+ latched in mtr, do not initialize the page. */
{
fseg_inode_t* inode;
ulint space;
ulint flags;
ulint zip_size;
rw_lock_t* latch;
- ibool success;
- ulint page_no;
+ buf_block_t* block;
ulint n_reserved;
space = page_get_space_id(page_align(seg_header));
@@ -2796,43 +2882,20 @@ fseg_alloc_free_page_general(
inode = fseg_inode_get(seg_header, space, zip_size, mtr);
- if (!has_done_reservation) {
- success = fsp_reserve_free_extents(&n_reserved, space, 2,
- FSP_NORMAL, mtr);
- if (!success) {
- return(FIL_NULL);
- }
+ if (!has_done_reservation
+ && !fsp_reserve_free_extents(&n_reserved, space, 2,
+ FSP_NORMAL, mtr)) {
+ return(NULL);
}
- page_no = fseg_alloc_free_page_low(space, zip_size,
- inode, hint, direction, mtr);
+ block = fseg_alloc_free_page_low(space, zip_size,
+ inode, hint, direction,
+ mtr, init_mtr);
if (!has_done_reservation) {
fil_space_release_free_extents(space, n_reserved);
}
- return(page_no);
-}
-
-/**********************************************************************//**
-Allocates a single free page from a segment. This function implements
-the intelligent allocation strategy which tries to minimize file space
-fragmentation.
-@return allocated page offset, FIL_NULL if no page could be allocated */
-UNIV_INTERN
-ulint
-fseg_alloc_free_page(
-/*=================*/
- fseg_header_t* seg_header,/*!< in: segment header */
- ulint hint, /*!< in: hint of which page would be desirable */
- byte direction,/*!< in: if the new page is needed because
- of an index page split, and records are
- inserted there in order, into which
- direction they go alphabetically: FSP_DOWN,
- FSP_UP, FSP_NO_DIR */
- mtr_t* mtr) /*!< in: mtr handle */
-{
- return(fseg_alloc_free_page_general(seg_header, hint, direction,
- FALSE, mtr));
+ return(block);
}
/**********************************************************************//**
@@ -3344,6 +3407,8 @@ crash:
descr + XDES_FLST_NODE, mtr);
fsp_free_extent(space, zip_size, page, mtr);
}
+
+ mtr->n_freed_pages++;
}
/**********************************************************************//**
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 9fb7dd79f3d..c7b530f381a 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -26,8 +26,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -3345,37 +3345,114 @@ normalize_table_name_low(
{
char* name_ptr;
char* db_ptr;
+ ulint db_len;
char* ptr;
/* Scan name from the end */
- ptr = strend(name)-1;
+ ptr = strend(name) - 1;
+ /* seek to the last path separator */
while (ptr >= name && *ptr != '\\' && *ptr != '/') {
ptr--;
}
name_ptr = ptr + 1;
- DBUG_ASSERT(ptr > name);
+ /* skip any number of path separators */
+ while (ptr >= name && (*ptr == '\\' || *ptr == '/')) {
+ ptr--;
+ }
- ptr--;
+ DBUG_ASSERT(ptr >= name);
+ /* seek to the last but one path separator or one char before
+ the beginning of name */
+ db_len = 0;
while (ptr >= name && *ptr != '\\' && *ptr != '/') {
ptr--;
+ db_len++;
}
db_ptr = ptr + 1;
- memcpy(norm_name, db_ptr, strlen(name) + 1 - (db_ptr - name));
+ memcpy(norm_name, db_ptr, db_len);
+
+ norm_name[db_len] = '/';
- norm_name[name_ptr - db_ptr - 1] = '/';
+ memcpy(norm_name + db_len + 1, name_ptr, strlen(name_ptr) + 1);
if (set_lower_case) {
innobase_casedn_str(norm_name);
}
}
+#if !defined(DBUG_OFF)
+/*********************************************************************
+Test normalize_table_name_low(). */
+static
+void
+test_normalize_table_name_low()
+/*===========================*/
+{
+ char norm_name[128];
+ const char* test_data[][2] = {
+ /* input, expected result */
+ {"./mysqltest/t1", "mysqltest/t1"},
+ {"./test/#sql-842b_2", "test/#sql-842b_2"},
+ {"./test/#sql-85a3_10", "test/#sql-85a3_10"},
+ {"./test/#sql2-842b-2", "test/#sql2-842b-2"},
+ {"./test/bug29807", "test/bug29807"},
+ {"./test/foo", "test/foo"},
+ {"./test/innodb_bug52663", "test/innodb_bug52663"},
+ {"./test/t", "test/t"},
+ {"./test/t1", "test/t1"},
+ {"./test/t10", "test/t10"},
+ {"/a/b/db/table", "db/table"},
+ {"/a/b/db///////table", "db/table"},
+ {"/a/b////db///////table", "db/table"},
+ {"/var/tmp/mysqld.1/#sql842b_2_10", "mysqld.1/#sql842b_2_10"},
+ {"db/table", "db/table"},
+ {"ddd/t", "ddd/t"},
+ {"d/ttt", "d/ttt"},
+ {"d/t", "d/t"},
+ {".\\mysqltest\\t1", "mysqltest/t1"},
+ {".\\test\\#sql-842b_2", "test/#sql-842b_2"},
+ {".\\test\\#sql-85a3_10", "test/#sql-85a3_10"},
+ {".\\test\\#sql2-842b-2", "test/#sql2-842b-2"},
+ {".\\test\\bug29807", "test/bug29807"},
+ {".\\test\\foo", "test/foo"},
+ {".\\test\\innodb_bug52663", "test/innodb_bug52663"},
+ {".\\test\\t", "test/t"},
+ {".\\test\\t1", "test/t1"},
+ {".\\test\\t10", "test/t10"},
+ {"C:\\a\\b\\db\\table", "db/table"},
+ {"C:\\a\\b\\db\\\\\\\\\\\\\\table", "db/table"},
+ {"C:\\a\\b\\\\\\\\db\\\\\\\\\\\\\\table", "db/table"},
+ {"C:\\var\\tmp\\mysqld.1\\#sql842b_2_10", "mysqld.1/#sql842b_2_10"},
+ {"db\\table", "db/table"},
+ {"ddd\\t", "ddd/t"},
+ {"d\\ttt", "d/ttt"},
+ {"d\\t", "d/t"},
+ };
+
+ for (size_t i = 0; i < UT_ARR_SIZE(test_data); i++) {
+ printf("test_normalize_table_name_low(): "
+ "testing \"%s\", expected \"%s\"... ",
+ test_data[i][0], test_data[i][1]);
+
+ normalize_table_name_low(norm_name, test_data[i][0], FALSE);
+
+ if (strcmp(norm_name, test_data[i][1]) == 0) {
+ printf("ok\n");
+ } else {
+ printf("got \"%s\"\n", norm_name);
+ ut_error;
+ }
+ }
+}
+#endif /* !DBUG_OFF */
+
/********************************************************************//**
Get the upper limit of the MySQL integral and floating-point type.
@return maximum allowed value for the field */
@@ -7371,6 +7448,11 @@ ha_innobase::delete_table(
DBUG_ENTER("ha_innobase::delete_table");
+ DBUG_EXECUTE_IF(
+ "test_normalize_table_name_low",
+ test_normalize_table_name_low();
+ );
+
/* Strangely, MySQL passes the table name without the '.frm'
extension, in contrast to ::create */
normalize_table_name(norm_name, name);
diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c
index 96af9038be2..eea7bbb7eec 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.c
+++ b/storage/innobase/ibuf/ibuf0ibuf.c
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -2180,14 +2180,14 @@ ibool
ibuf_add_free_page(void)
/*====================*/
{
- mtr_t mtr;
- page_t* header_page;
- ulint flags;
- ulint zip_size;
- ulint page_no;
- page_t* page;
- page_t* root;
- page_t* bitmap_page;
+ mtr_t mtr;
+ page_t* header_page;
+ ulint flags;
+ ulint zip_size;
+ buf_block_t* block;
+ page_t* page;
+ page_t* root;
+ page_t* bitmap_page;
mtr_start(&mtr);
@@ -2208,28 +2208,23 @@ ibuf_add_free_page(void)
of a deadlock. This is the reason why we created a special ibuf
header page apart from the ibuf tree. */
- page_no = fseg_alloc_free_page(
+ block = fseg_alloc_free_page(
header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, 0, FSP_UP,
&mtr);
- if (UNIV_UNLIKELY(page_no == FIL_NULL)) {
+ if (block == NULL) {
mtr_commit(&mtr);
return(FALSE);
- } else {
- buf_block_t* block = buf_page_get(
- IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
-
- ibuf_enter(&mtr);
-
- mutex_enter(&ibuf_mutex);
-
- root = ibuf_tree_root_get(&mtr);
+ }
- buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW);
+ ut_ad(rw_lock_get_x_lock_count(&block->lock) == 1);
+ ibuf_enter(&mtr);
+ mutex_enter(&ibuf_mutex);
+ root = ibuf_tree_root_get(&mtr);
- page = buf_block_get_frame(block);
- }
+ buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW);
+ page = buf_block_get_frame(block);
/* Add the page to the free list and update the ibuf size data */
@@ -2246,12 +2241,13 @@ ibuf_add_free_page(void)
(level 2 page) */
bitmap_page = ibuf_bitmap_get_map_page(
- IBUF_SPACE_ID, page_no, zip_size, &mtr);
+ IBUF_SPACE_ID, buf_block_get_page_no(block), zip_size, &mtr);
mutex_exit(&ibuf_mutex);
ibuf_bitmap_page_set_bits(
- bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, TRUE, &mtr);
+ bitmap_page, buf_block_get_page_no(block), zip_size,
+ IBUF_BITMAP_IBUF, TRUE, &mtr);
ibuf_mtr_commit(&mtr);
@@ -3931,9 +3927,10 @@ ibuf_insert_to_index_page(
"InnoDB: but the number of fields does not match!\n",
stderr);
dump:
- buf_page_print(page, 0);
+ buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH);
dtuple_print(stderr, entry);
+ ut_ad(0);
fputs("InnoDB: The table where where"
" this index record belongs\n"
@@ -4506,12 +4503,14 @@ ibuf_merge_or_delete_for_page(
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
zip_size, &mtr);
- buf_page_print(bitmap_page, 0);
+ buf_page_print(bitmap_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
ibuf_mtr_commit(&mtr);
fputs("\nInnoDB: Dump of the page:\n", stderr);
- buf_page_print(block->frame, 0);
+ buf_page_print(block->frame, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
fprintf(stderr,
"InnoDB: Error: corruption in the tablespace."
@@ -4531,6 +4530,7 @@ ibuf_merge_or_delete_for_page(
(ulong) page_no,
(ulong)
fil_page_get_type(block->frame));
+ ut_ad(0);
}
}
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 93b59fdfafb..6b997a2b083 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -519,11 +519,14 @@ UNIV_INTERN
ibool
btr_compress(
/*=========*/
- btr_cur_t* cursor, /*!< in: cursor on the page to merge or lift;
- the page must not be empty: in record delete
- use btr_discard_page if the page would become
- empty */
- mtr_t* mtr); /*!< in: mtr */
+ btr_cur_t* cursor, /*!< in/out: cursor on the page to merge
+ or lift; the page must not be empty:
+ when deleting records, use btr_discard_page()
+ if the page would become empty */
+ ibool adjust, /*!< in: TRUE if should adjust the
+ cursor position even if compression occurs */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+ __attribute__((nonnull));
/*************************************************************//**
Discards a page from a B-tree. This is used to remove the last record from
a B-tree page: the whole page must be removed at the same time. This cannot
@@ -574,7 +577,10 @@ btr_get_size(
/**************************************************************//**
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!
-@return new allocated block, x-latched; NULL if out of space */
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
UNIV_INTERN
buf_block_t*
btr_page_alloc(
@@ -585,7 +591,12 @@ btr_page_alloc(
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: mini-transaction
+ for x-latching and initializing
+ the page */
+ __attribute__((nonnull, warn_unused_result));
/**************************************************************//**
Frees a file page used in an index tree. NOTE: cannot free field external
storage pages because the page must contain info on its level. */
diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic
index 1bd22a0ebc6..55bdb289b21 100644
--- a/storage/innobase/include/btr0btr.ic
+++ b/storage/innobase/include/btr0btr.ic
@@ -277,7 +277,7 @@ btr_node_ptr_get_child_page_no(
"InnoDB: a nonsensical page number 0"
" in a node ptr record at offset %lu\n",
(ulong) page_offset(rec));
- buf_page_print(page_align(rec), 0);
+ buf_page_print(page_align(rec), 0, 0);
}
return(page_no);
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index 4f33aacc48e..cbc6103c2ee 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -36,6 +36,9 @@ Created 10/16/1994 Heikki Tuuri
#define BTR_NO_LOCKING_FLAG 2 /* do no record lock checking */
#define BTR_KEEP_SYS_FLAG 4 /* sys fields will be found from the
update vector or inserted entry */
+#define BTR_KEEP_POS_FLAG 8 /* btr_cur_pessimistic_update()
+ must keep cursor position when
+ moving columns to big_rec */
#ifndef UNIV_HOTBACKUP
#include "que0types.h"
@@ -310,7 +313,9 @@ btr_cur_pessimistic_update(
/*=======================*/
ulint flags, /*!< in: undo logging, locking, and rollback
flags */
- btr_cur_t* cursor, /*!< in: cursor on the record to update */
+ btr_cur_t* cursor, /*!< in/out: cursor on the record to update;
+ cursor may become invalid if *big_rec == NULL
+ || !(flags & BTR_KEEP_POS_FLAG) */
mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
be stored externally by the caller, or NULL */
@@ -364,10 +369,13 @@ UNIV_INTERN
ibool
btr_cur_compress_if_useful(
/*=======================*/
- btr_cur_t* cursor, /*!< in: cursor on the page to compress;
+ btr_cur_t* cursor, /*!< in/out: cursor on the page to compress;
cursor does not stay valid if compression
occurs */
- mtr_t* mtr); /*!< in: mtr */
+ ibool adjust, /*!< in: TRUE if should adjust the
+ cursor position even if compression occurs */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+ __attribute__((nonnull));
/*******************************************************//**
Removes the record on which the tree cursor is positioned. It is assumed
that the mtr has an x-latch on the page where the cursor is positioned,
@@ -492,6 +500,27 @@ btr_cur_disown_inherited_fields(
const upd_t* update, /*!< in: update vector */
mtr_t* mtr) /*!< in/out: mini-transaction */
__attribute__((nonnull(2,3,4,5,6)));
+
+/** Operation code for btr_store_big_rec_extern_fields(). */
+enum blob_op {
+ /** Store off-page columns for a freshly inserted record */
+ BTR_STORE_INSERT = 0,
+ /** Store off-page columns for an insert by update */
+ BTR_STORE_INSERT_UPDATE,
+ /** Store off-page columns for an update */
+ BTR_STORE_UPDATE
+};
+
+/*******************************************************************//**
+Determine if an operation on off-page columns is an update.
+@return TRUE if op != BTR_STORE_INSERT */
+UNIV_INLINE
+ibool
+btr_blob_op_is_update(
+/*==================*/
+ enum blob_op op) /*!< in: operation */
+ __attribute__((warn_unused_result));
+
/*******************************************************************//**
Stores the fields in big_rec_vec to the tablespace and puts pointers to
them in rec. The extern flags in rec will have to be set beforehand.
@@ -499,52 +528,23 @@ The fields are stored on pages allocated from leaf node
file segment of the index tree.
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
UNIV_INTERN
-ulint
-btr_store_big_rec_extern_fields_func(
-/*=================================*/
+enum db_err
+btr_store_big_rec_extern_fields(
+/*============================*/
dict_index_t* index, /*!< in: index of rec; the index tree
MUST be X-latched */
buf_block_t* rec_block, /*!< in/out: block containing rec */
- rec_t* rec, /*!< in: record */
+ rec_t* rec, /*!< in/out: record */
const ulint* offsets, /*!< in: rec_get_offsets(rec, index);
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
-#ifdef UNIV_DEBUG
- mtr_t* local_mtr, /*!< in: mtr containing the
- latch to rec and to the tree */
-#endif /* UNIV_DEBUG */
-#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
- ibool update_in_place,/*! in: TRUE if the record is updated
- in place (not delete+insert) */
-#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
- const big_rec_t*big_rec_vec) /*!< in: vector containing fields
+ const big_rec_t*big_rec_vec, /*!< in: vector containing fields
to be stored externally */
- __attribute__((nonnull));
-
-/** Stores the fields in big_rec_vec to the tablespace and puts pointers to
-them in rec. The extern flags in rec will have to be set beforehand.
-The fields are stored on pages allocated from leaf node
-file segment of the index tree.
-@param index in: clustered index; MUST be X-latched by mtr
-@param b in/out: block containing rec; MUST be X-latched by mtr
-@param rec in/out: clustered index record
-@param offsets in: rec_get_offsets(rec, index);
- the "external storage" flags in offsets will not be adjusted
-@param mtr in: mini-transaction that holds x-latch on index and b
-@param upd in: TRUE if the record is updated in place (not delete+insert)
-@param big in: vector containing fields to be stored externally
-@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
-#ifdef UNIV_DEBUG
-# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
- btr_store_big_rec_extern_fields_func(index,b,rec,offsets,mtr,upd,big)
-#elif defined UNIV_BLOB_LIGHT_DEBUG
-# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
- btr_store_big_rec_extern_fields_func(index,b,rec,offsets,upd,big)
-#else
-# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
- btr_store_big_rec_extern_fields_func(index,b,rec,offsets,big)
-#endif
+ mtr_t* btr_mtr, /*!< in: mtr containing the
+ latches to the clustered index */
+ enum blob_op op) /*! in: operation code */
+ __attribute__((nonnull, warn_unused_result));
/*******************************************************************//**
Frees the space in an externally stored field to the file space
diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic
index 280583f6ccf..e31f77c77eb 100644
--- a/storage/innobase/include/btr0cur.ic
+++ b/storage/innobase/include/btr0cur.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -139,7 +139,7 @@ btr_cur_compress_recommendation(
btr_cur_t* cursor, /*!< in: btr cursor */
mtr_t* mtr) /*!< in: mtr */
{
- page_t* page;
+ const page_t* page;
ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
MTR_MEMO_PAGE_X_FIX));
@@ -197,4 +197,25 @@ btr_cur_can_delete_without_compress(
return(TRUE);
}
+
+/*******************************************************************//**
+Determine if an operation on off-page columns is an update.
+@return TRUE if op != BTR_STORE_INSERT */
+UNIV_INLINE
+ibool
+btr_blob_op_is_update(
+/*==================*/
+ enum blob_op op) /*!< in: operation */
+{
+ switch (op) {
+ case BTR_STORE_INSERT:
+ return(FALSE);
+ case BTR_STORE_INSERT_UPDATE:
+ case BTR_STORE_UPDATE:
+ return(TRUE);
+ }
+
+ ut_ad(0);
+ return(FALSE);
+}
#endif /* !UNIV_HOTBACKUP */
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 456f077a13d..5054429156a 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -596,6 +596,31 @@ buf_block_get_modify_clock(
#else /* !UNIV_HOTBACKUP */
# define buf_block_modify_clock_inc(block) ((void) 0)
#endif /* !UNIV_HOTBACKUP */
+/*******************************************************************//**
+Increments the bufferfix count. */
+UNIV_INLINE
+void
+buf_block_buf_fix_inc_func(
+/*=======================*/
+#ifdef UNIV_SYNC_DEBUG
+ const char* file, /*!< in: file name */
+ ulint line, /*!< in: line */
+#endif /* UNIV_SYNC_DEBUG */
+ buf_block_t* block) /*!< in/out: block to bufferfix */
+ __attribute__((nonnull));
+#ifdef UNIV_SYNC_DEBUG
+/** Increments the bufferfix count.
+@param b in/out: block to bufferfix
+@param f in: file name where requested
+@param l in: line number where requested */
+# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
+#else /* UNIV_SYNC_DEBUG */
+/** Increments the bufferfix count.
+@param b in/out: block to bufferfix
+@param f in: file name where requested
+@param l in: line number where requested */
+# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
+#endif /* UNIV_SYNC_DEBUG */
/********************************************************************//**
Calculates a page checksum which is stored to the page when it is written
to a file. Note that we must be careful to calculate the same value
@@ -680,6 +705,13 @@ buf_print(void);
/*============*/
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
#endif /* !UNIV_HOTBACKUP */
+enum buf_page_print_flags {
+ /** Do not crash at the end of buf_page_print(). */
+ BUF_PAGE_PRINT_NO_CRASH = 1,
+ /** Do not print the full page dump. */
+ BUF_PAGE_PRINT_NO_FULL = 2
+};
+
/********************************************************************//**
Prints a page to stderr. */
UNIV_INTERN
@@ -687,8 +719,12 @@ void
buf_page_print(
/*===========*/
const byte* read_buf, /*!< in: a database page */
- ulint zip_size); /*!< in: compressed page size, or
+ ulint zip_size, /*!< in: compressed page size, or
0 for uncompressed pages */
+ ulint flags) /*!< in: 0 or
+ BUF_PAGE_PRINT_NO_CRASH or
+ BUF_PAGE_PRINT_NO_FULL */
+ __attribute__((nonnull));
/********************************************************************//**
Decompress a block.
@return TRUE if successful */
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index 99e55df3312..917ee5dda84 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -988,19 +988,6 @@ buf_block_buf_fix_inc_func(
block->page.buf_fix_count++;
}
-#ifdef UNIV_SYNC_DEBUG
-/** Increments the bufferfix count.
-@param b in/out: block to bufferfix
-@param f in: file name where requested
-@param l in: line number where requested */
-# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
-#else /* UNIV_SYNC_DEBUG */
-/** Increments the bufferfix count.
-@param b in/out: block to bufferfix
-@param f in: file name where requested
-@param l in: line number where requested */
-# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
-#endif /* UNIV_SYNC_DEBUG */
/*******************************************************************//**
Decrements the bufferfix count. */
@@ -1251,7 +1238,7 @@ buf_block_dbg_add_level(
where we have acquired latch */
ulint level) /*!< in: latching order level */
{
- sync_thread_add_level(&block->lock, level);
+ sync_thread_add_level(&block->lock, level, FALSE);
}
#endif /* UNIV_SYNC_DEBUG */
/********************************************************************//**
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index 4efabacb2cb..f07e3decc66 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -260,30 +260,33 @@ fseg_n_reserved_pages(
Allocates a single free page from a segment. This function implements
the intelligent allocation strategy which tries to minimize
file space fragmentation.
-@return the allocated page offset FIL_NULL if no page could be allocated */
-UNIV_INTERN
-ulint
-fseg_alloc_free_page(
-/*=================*/
- fseg_header_t* seg_header, /*!< in: segment header */
- ulint hint, /*!< in: hint of which page would be desirable */
- byte direction, /*!< in: if the new page is needed because
+@param[in/out] seg_header segment header
+@param[in] hint hint of which page would be desirable
+@param[in] direction if the new page is needed because
of an index page split, and records are
inserted there in order, into which
direction they go alphabetically: FSP_DOWN,
- FSP_UP, FSP_NO_DIR */
- mtr_t* mtr); /*!< in: mtr handle */
+ FSP_UP, FSP_NO_DIR
+@param[in/out] mtr mini-transaction
+@return X-latched block, or NULL if no page could be allocated */
+#define fseg_alloc_free_page(seg_header, hint, direction, mtr) \
+ fseg_alloc_free_page_general(seg_header, hint, direction, \
+ FALSE, mtr, mtr)
/**********************************************************************//**
Allocates a single free page from a segment. This function implements
the intelligent allocation strategy which tries to minimize file space
fragmentation.
-@return allocated page offset, FIL_NULL if no page could be allocated */
+@retval NULL if no page could be allocated
+@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)
+@retval block (not allocated or initialized) otherwise */
UNIV_INTERN
-ulint
+buf_block_t*
fseg_alloc_free_page_general(
/*=========================*/
- fseg_header_t* seg_header,/*!< in: segment header */
- ulint hint, /*!< in: hint of which page would be desirable */
+ fseg_header_t* seg_header,/*!< in/out: segment header */
+ ulint hint, /*!< in: hint of which page would be
+ desirable */
byte direction,/*!< in: if the new page is needed because
of an index page split, and records are
inserted there in order, into which
@@ -294,8 +297,12 @@ fseg_alloc_free_page_general(
with fsp_reserve_free_extents, then there
is no need to do the check for this individual
page */
- mtr_t* mtr) /*!< in/out: mini-transaction */
- __attribute__((warn_unused_result, nonnull(1,5)));
+ mtr_t* mtr, /*!< in/out: mini-transaction */
+ 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
+ latched in mtr, do not initialize the page. */
+ __attribute__((warn_unused_result, nonnull));
/**********************************************************************//**
Reserves free pages from a tablespace. All mini-transactions which may
use several pages from the tablespace should call this function beforehand
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
index 1ae94a332e5..f2ab6a9898d 100644
--- a/storage/innobase/include/log0log.h
+++ b/storage/innobase/include/log0log.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 7f608546cc2..46f1ff9310c 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -50,7 +50,9 @@ first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
#define MTR_MEMO_PAGE_S_FIX RW_S_LATCH
#define MTR_MEMO_PAGE_X_FIX RW_X_LATCH
#define MTR_MEMO_BUF_FIX RW_NO_LATCH
-#define MTR_MEMO_MODIFY 54
+#ifdef UNIV_DEBUG
+# define MTR_MEMO_MODIFY 54
+#endif /* UNIV_DEBUG */
#define MTR_MEMO_S_LOCK 55
#define MTR_MEMO_X_LOCK 56
@@ -376,6 +378,9 @@ struct mtr_struct{
ulint n_log_recs;
/* count of how many page initial log records
have been written to the mtr log */
+ ulint n_freed_pages;
+ /* number of pages that have been freed in
+ this mini-transaction */
ulint log_mode; /* specifies which operations should be
logged; default value MTR_LOG_ALL */
ib_uint64_t start_lsn;/* start lsn of the possible log entry for
diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic
index 1db4a4bd735..755bd49057b 100644
--- a/storage/innobase/include/mtr0mtr.ic
+++ b/storage/innobase/include/mtr0mtr.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -46,6 +46,7 @@ mtr_start(
mtr->modifications = FALSE;
mtr->inside_ibuf = FALSE;
mtr->n_log_recs = 0;
+ mtr->n_freed_pages = 0;
ut_d(mtr->state = MTR_ACTIVE);
ut_d(mtr->magic_n = MTR_MAGIC_N);
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index 540ec7855bc..74e9ceca959 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -281,16 +281,42 @@ page_get_supremum_offset(
const page_t* page); /*!< in: page which must have record(s) */
#define page_get_infimum_rec(page) ((page) + page_get_infimum_offset(page))
#define page_get_supremum_rec(page) ((page) + page_get_supremum_offset(page))
+
/************************************************************//**
-Returns the middle record of record list. If there are an even number
-of records in the list, returns the first record of upper half-list.
-@return middle record */
+Returns the nth record of the record list.
+This is the inverse function of page_rec_get_n_recs_before().
+@return nth record */
UNIV_INTERN
+const rec_t*
+page_rec_get_nth_const(
+/*===================*/
+ const page_t* page, /*!< in: page */
+ ulint nth) /*!< in: nth record */
+ __attribute__((nonnull, warn_unused_result));
+/************************************************************//**
+Returns the nth record of the record list.
+This is the inverse function of page_rec_get_n_recs_before().
+@return nth record */
+UNIV_INLINE
+rec_t*
+page_rec_get_nth(
+/*=============*/
+ page_t* page, /*< in: page */
+ ulint nth) /*!< in: nth record */
+ __attribute__((nonnull, warn_unused_result));
+
+#ifndef UNIV_HOTBACKUP
+/************************************************************//**
+Returns the middle record of the records on the page. If there is an
+even number of records in the list, returns the first record of the
+upper half-list.
+@return middle record */
+UNIV_INLINE
rec_t*
page_get_middle_rec(
/*================*/
- page_t* page); /*!< in: page */
-#ifndef UNIV_HOTBACKUP
+ page_t* page) /*!< in: page */
+ __attribute__((nonnull, warn_unused_result));
/*************************************************************//**
Compares a data tuple to a physical record. Differs from the function
cmp_dtuple_rec_with_match in the way that the record must reside on an
@@ -345,6 +371,7 @@ page_get_n_recs(
/***************************************************************//**
Returns the number of records before the given record in chain.
The number includes infimum and supremum records.
+This is the inverse function of page_rec_get_nth().
@return number of records */
UNIV_INTERN
ulint
diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic
index 115cee64f8b..781ad029e87 100644
--- a/storage/innobase/include/page0page.ic
+++ b/storage/innobase/include/page0page.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -419,7 +419,37 @@ page_rec_is_infimum(
return(page_rec_is_infimum_low(page_offset(rec)));
}
+/************************************************************//**
+Returns the nth record of the record list.
+This is the inverse function of page_rec_get_n_recs_before().
+@return nth record */
+UNIV_INLINE
+rec_t*
+page_rec_get_nth(
+/*=============*/
+ page_t* page, /*!< in: page */
+ ulint nth) /*!< in: nth record */
+{
+ return((rec_t*) page_rec_get_nth_const(page, nth));
+}
+
#ifndef UNIV_HOTBACKUP
+/************************************************************//**
+Returns the middle record of the records on the page. If there is an
+even number of records in the list, returns the first record of the
+upper half-list.
+@return middle record */
+UNIV_INLINE
+rec_t*
+page_get_middle_rec(
+/*================*/
+ page_t* page) /*!< in: page */
+{
+ ulint middle = (page_get_n_recs(page) + PAGE_HEAP_NO_USER_LOW) / 2;
+
+ return(page_rec_get_nth(page, middle));
+}
+
/*************************************************************//**
Compares a data tuple to a physical record. Differs from the function
cmp_dtuple_rec_with_match in the way that the record must reside on an
@@ -710,7 +740,7 @@ page_rec_get_next_low(
(void*) rec,
(ulong) page_get_space_id(page),
(ulong) page_get_page_no(page));
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
ut_error;
}
diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h
index b5bf30e758c..9b07c4758c9 100644
--- a/storage/innobase/include/sync0sync.h
+++ b/storage/innobase/include/sync0sync.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -400,8 +400,10 @@ void
sync_thread_add_level(
/*==================*/
void* latch, /*!< in: pointer to a mutex or an rw-lock */
- ulint level); /*!< in: level in the latching order; if
+ ulint level, /*!< in: level in the latching order; if
SYNC_LEVEL_VARYING, nothing is done */
+ ibool relock) /*!< in: TRUE if re-entering an x-lock */
+ __attribute__((nonnull));
/******************************************************************//**
Removes a latch from the thread level array if it is found there.
@return TRUE if found in the array; it is no error if the latch is
diff --git a/storage/innobase/include/trx0rec.ic b/storage/innobase/include/trx0rec.ic
index f0b3276ed44..4fc5a7147f9 100644
--- a/storage/innobase/include/trx0rec.ic
+++ b/storage/innobase/include/trx0rec.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -107,6 +107,7 @@ trx_undo_rec_copy(
len = mach_read_from_2(undo_rec)
- ut_align_offset(undo_rec, UNIV_PAGE_SIZE);
+ ut_ad(len < UNIV_PAGE_SIZE);
return(mem_heap_dup(heap, undo_rec, len));
}
#endif /* !UNIV_HOTBACKUP */
diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h
index 50aa6d0ac09..4a1e40af505 100644
--- a/storage/innobase/include/trx0undo.h
+++ b/storage/innobase/include/trx0undo.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -194,16 +194,17 @@ trx_undo_get_first_rec(
mtr_t* mtr); /*!< in: mtr */
/********************************************************************//**
Tries to add a page to the undo log segment where the undo log is placed.
-@return page number if success, else FIL_NULL */
+@return X-latched block if success, else NULL */
UNIV_INTERN
-ulint
+buf_block_t*
trx_undo_add_page(
/*==============*/
trx_t* trx, /*!< in: transaction */
trx_undo_t* undo, /*!< in: undo log memory object */
- mtr_t* mtr); /*!< in: mtr which does not have a latch to any
+ mtr_t* mtr) /*!< in: mtr which does not have a latch to any
undo log page; the caller must have reserved
the rollback segment mutex */
+ __attribute__((nonnull, warn_unused_result));
/********************************************************************//**
Frees the last undo log page.
The caller must hold the rollback segment mutex. */
diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
index 263516ab5fd..a516b5545de 100644
--- a/storage/innobase/lock/lock0lock.c
+++ b/storage/innobase/lock/lock0lock.c
@@ -1615,7 +1615,7 @@ lock_sec_rec_some_has_impl_off_kernel(
if (!lock_check_trx_id_sanity(page_get_max_trx_id(page),
rec, index, offsets, TRUE)) {
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
/* The page is corrupt: try to avoid a crash by returning
NULL */
diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c
index fd2258945b6..c40292bcf1e 100644
--- a/storage/innobase/log/log0log.c
+++ b/storage/innobase/log/log0log.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c
index 08234609ff0..d852ed6f496 100644
--- a/storage/innobase/mtr/mtr0mtr.c
+++ b/storage/innobase/mtr/mtr0mtr.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
diff --git a/storage/innobase/page/page0cur.c b/storage/innobase/page/page0cur.c
index 936762b986a..d49b121afab 100644
--- a/storage/innobase/page/page0cur.c
+++ b/storage/innobase/page/page0cur.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -900,7 +900,7 @@ page_cur_parse_insert_rec(
ut_print_buf(stderr, ptr2, 300);
putc('\n', stderr);
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
ut_error;
}
@@ -1180,14 +1180,15 @@ page_cur_insert_rec_zip_reorg(
/* Before trying to reorganize the page,
store the number of preceding records on the page. */
pos = page_rec_get_n_recs_before(rec);
+ ut_ad(pos > 0);
if (page_zip_reorganize(block, index, mtr)) {
/* The page was reorganized: Find rec by seeking to pos,
and update *current_rec. */
- rec = page + PAGE_NEW_INFIMUM;
-
- while (--pos) {
- rec = page + rec_get_next_offs(rec, TRUE);
+ if (pos > 1) {
+ rec = page_rec_get_nth(page, pos - 1);
+ } else {
+ rec = page + PAGE_NEW_INFIMUM;
}
*current_rec = rec;
@@ -1283,6 +1284,12 @@ page_cur_insert_rec_zip(
insert_rec = page_cur_insert_rec_zip_reorg(
current_rec, block, index, insert_rec,
page, page_zip, mtr);
+#ifdef UNIV_DEBUG
+ if (insert_rec) {
+ rec_offs_make_valid(
+ insert_rec, index, offsets);
+ }
+#endif /* UNIV_DEBUG */
}
return(insert_rec);
diff --git a/storage/innobase/page/page0page.c b/storage/innobase/page/page0page.c
index e250bb359fe..5f0380cb55f 100644
--- a/storage/innobase/page/page0page.c
+++ b/storage/innobase/page/page0page.c
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -148,7 +148,7 @@ page_dir_find_owner_slot(
fputs("\n"
"InnoDB: on that page!\n", stderr);
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
ut_error;
}
@@ -569,8 +569,10 @@ page_copy_rec_list_end_no_locks(
/* Track an assertion failure reported on the mailing
list on June 18th, 2003 */
- buf_page_print(new_page, 0);
- buf_page_print(page_align(rec), 0);
+ buf_page_print(new_page, 0,
+ BUF_PAGE_PRINT_NO_CRASH);
+ buf_page_print(page_align(rec), 0,
+ BUF_PAGE_PRINT_NO_CRASH);
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -1452,55 +1454,54 @@ page_dir_balance_slot(
}
}
-#ifndef UNIV_HOTBACKUP
/************************************************************//**
-Returns the middle record of the record list. If there are an even number
-of records in the list, returns the first record of the upper half-list.
-@return middle record */
+Returns the nth record of the record list.
+This is the inverse function of page_rec_get_n_recs_before().
+@return nth record */
UNIV_INTERN
-rec_t*
-page_get_middle_rec(
-/*================*/
- page_t* page) /*!< in: page */
+const rec_t*
+page_rec_get_nth_const(
+/*===================*/
+ const page_t* page, /*!< in: page */
+ ulint nth) /*!< in: nth record */
{
- page_dir_slot_t* slot;
- ulint middle;
+ const page_dir_slot_t* slot;
ulint i;
ulint n_owned;
- ulint count;
- rec_t* rec;
-
- /* This many records we must leave behind */
- middle = (page_get_n_recs(page) + PAGE_HEAP_NO_USER_LOW) / 2;
+ const rec_t* rec;
- count = 0;
+ ut_ad(nth < UNIV_PAGE_SIZE / (REC_N_NEW_EXTRA_BYTES + 1));
for (i = 0;; i++) {
slot = page_dir_get_nth_slot(page, i);
n_owned = page_dir_slot_get_n_owned(slot);
- if (count + n_owned > middle) {
+ if (n_owned > nth) {
break;
} else {
- count += n_owned;
+ nth -= n_owned;
}
}
ut_ad(i > 0);
slot = page_dir_get_nth_slot(page, i - 1);
- rec = (rec_t*) page_dir_slot_get_rec(slot);
- rec = page_rec_get_next(rec);
-
- /* There are now count records behind rec */
+ rec = page_dir_slot_get_rec(slot);
- for (i = 0; i < middle - count; i++) {
- rec = page_rec_get_next(rec);
+ if (page_is_comp(page)) {
+ do {
+ rec = page_rec_get_next_low(rec, TRUE);
+ ut_ad(rec);
+ } while (nth--);
+ } else {
+ do {
+ rec = page_rec_get_next_low(rec, FALSE);
+ ut_ad(rec);
+ } while (nth--);
}
return(rec);
}
-#endif /* !UNIV_HOTBACKUP */
/***************************************************************//**
Returns the number of records before the given record in chain.
@@ -1562,6 +1563,7 @@ page_rec_get_n_recs_before(
n--;
ut_ad(n >= 0);
+ ut_ad(n < UNIV_PAGE_SIZE / (REC_N_NEW_EXTRA_BYTES + 1));
return((ulint) n);
}
@@ -1834,7 +1836,7 @@ page_check_dir(
fprintf(stderr,
"InnoDB: Page directory corruption:"
" infimum not pointed to\n");
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
}
if (UNIV_UNLIKELY(!page_rec_is_supremum_low(supremum_offs))) {
@@ -1842,7 +1844,7 @@ page_check_dir(
fprintf(stderr,
"InnoDB: Page directory corruption:"
" supremum not pointed to\n");
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
}
}
#endif /* !UNIV_HOTBACKUP */
@@ -2546,7 +2548,7 @@ func_exit2:
(ulong) page_get_space_id(page),
(ulong) page_get_page_no(page),
index->name);
- buf_page_print(page, 0);
+ buf_page_print(page, 0, 0);
}
return(ret);
diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c
index 67846ab6f69..d02d0e986aa 100644
--- a/storage/innobase/row/row0ins.c
+++ b/storage/innobase/row/row0ins.c
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -23,6 +23,8 @@ Insert into a table
Created 4/20/1996 Heikki Tuuri
*******************************************************/
+#include "m_string.h" /* for my_sys.h */
+#include "my_sys.h" /* DEBUG_SYNC_C */
#include "row0ins.h"
#ifdef UNIV_NONINL
@@ -348,9 +350,9 @@ row_ins_clust_index_entry_by_modify(
return(DB_LOCK_TABLE_FULL);
}
- err = btr_cur_pessimistic_update(0, cursor,
- heap, big_rec, update,
- 0, thr, mtr);
+ err = btr_cur_pessimistic_update(
+ BTR_KEEP_POS_FLAG, cursor, heap, big_rec, update,
+ 0, thr, mtr);
}
return(err);
@@ -1979,6 +1981,7 @@ row_ins_index_entry_low(
ulint modify = 0; /* remove warning */
rec_t* insert_rec;
rec_t* rec;
+ ulint* offsets;
ulint err;
ulint n_unique;
big_rec_t* big_rec = NULL;
@@ -2086,6 +2089,64 @@ row_ins_index_entry_low(
err = row_ins_clust_index_entry_by_modify(
mode, &cursor, &heap, &big_rec, entry,
thr, &mtr);
+
+ if (big_rec) {
+ ut_a(err == DB_SUCCESS);
+ /* Write out the externally stored
+ columns while still x-latching
+ index->lock and block->lock. Allocate
+ pages for big_rec in the mtr that
+ modified the B-tree, but be sure to skip
+ any pages that were freed in mtr. We will
+ write out the big_rec pages before
+ committing the B-tree mini-transaction. If
+ the system crashes so that crash recovery
+ will not replay the mtr_commit(&mtr), the
+ big_rec pages will be left orphaned until
+ the pages are allocated for something else.
+
+ TODO: If the allocation extends the
+ tablespace, it will not be redo
+ logged, in either mini-transaction.
+ Tablespace extension should be
+ redo-logged in the big_rec
+ mini-transaction, so that recovery
+ will not fail when the big_rec was
+ written to the extended portion of the
+ file, in case the file was somehow
+ truncated in the crash. */
+
+ rec = btr_cur_get_rec(&cursor);
+ offsets = rec_get_offsets(
+ rec, index, NULL,
+ ULINT_UNDEFINED, &heap);
+
+ DEBUG_SYNC_C("before_row_ins_upd_extern");
+ err = btr_store_big_rec_extern_fields(
+ index, btr_cur_get_block(&cursor),
+ rec, offsets, big_rec, &mtr,
+ BTR_STORE_INSERT_UPDATE);
+ DEBUG_SYNC_C("after_row_ins_upd_extern");
+ /* If writing big_rec fails (for
+ example, because of DB_OUT_OF_FILE_SPACE),
+ the record will be corrupted. Even if
+ we did not update any externally
+ stored columns, our update could cause
+ the record to grow so that a
+ non-updated column was selected for
+ external storage. This non-update
+ would not have been written to the
+ undo log, and thus the record cannot
+ be rolled back.
+
+ However, because we have not executed
+ mtr_commit(mtr) yet, the update will
+ not be replayed in crash recovery, and
+ the following assertion failure will
+ effectively "roll back" the operation. */
+ ut_a(err == DB_SUCCESS);
+ goto stored_big_rec;
+ }
} else {
ut_ad(!n_ext);
err = row_ins_sec_index_entry_by_modify(
@@ -2114,10 +2175,13 @@ function_exit:
mtr_commit(&mtr);
if (UNIV_LIKELY_NULL(big_rec)) {
- rec_t* rec;
- ulint* offsets;
+ DBUG_EXECUTE_IF(
+ "row_ins_extern_checkpoint",
+ log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE););
+
mtr_start(&mtr);
+ DEBUG_SYNC_C("before_row_ins_extern_latch");
btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE, &cursor, 0,
__FILE__, __LINE__, &mtr);
@@ -2125,10 +2189,13 @@ function_exit:
offsets = rec_get_offsets(rec, index, NULL,
ULINT_UNDEFINED, &heap);
+ DEBUG_SYNC_C("before_row_ins_extern");
err = btr_store_big_rec_extern_fields(
index, btr_cur_get_block(&cursor),
- rec, offsets, &mtr, FALSE, big_rec);
+ rec, offsets, big_rec, &mtr, BTR_STORE_INSERT);
+ DEBUG_SYNC_C("after_row_ins_extern");
+stored_big_rec:
if (modify) {
dtuple_big_rec_free(big_rec);
} else {
diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c
index d42f21241ca..82169e7efee 100644
--- a/storage/innobase/row/row0merge.c
+++ b/storage/innobase/row/row0merge.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2005, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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 the Free Software
@@ -582,7 +582,7 @@ row_merge_buf_write(
REC_STATUS_ORDINARY,
entry, n_fields,
&extra_size);
- ut_ad(size > extra_size);
+ ut_ad(size >= extra_size);
ut_ad(extra_size >= REC_N_NEW_EXTRA_BYTES);
extra_size -= REC_N_NEW_EXTRA_BYTES;
size -= REC_N_NEW_EXTRA_BYTES;
@@ -2010,7 +2010,7 @@ row_merge_drop_index(
tables in Innobase. Deleting a row from SYS_INDEXES table also
frees the file segments of the B-tree associated with the index. */
- static const char str1[] =
+ static const char sql[] =
"PROCEDURE DROP_INDEX_PROC () IS\n"
"BEGIN\n"
/* Rename the index, so that it will be dropped by
@@ -2034,9 +2034,19 @@ row_merge_drop_index(
ut_a(trx->dict_operation_lock_mode == RW_X_LATCH);
- err = que_eval_sql(info, str1, FALSE, trx);
+ err = que_eval_sql(info, sql, FALSE, trx);
- ut_a(err == DB_SUCCESS);
+
+ if (err != DB_SUCCESS) {
+ /* Even though we ensure that DDL transactions are WAIT
+ and DEADLOCK free, we could encounter other errors e.g.,
+ DB_TOO_MANY_TRANSACTIONS. */
+ trx->error_state = DB_SUCCESS;
+
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Error: row_merge_drop_index failed "
+ "with error code: %lu.\n", (ulint) err);
+ }
/* Replace this index with another equivalent index for all
foreign key constraints on this table where this index is used */
@@ -2336,7 +2346,7 @@ row_merge_rename_indexes(
/* We use the private SQL parser of Innobase to generate the
query graphs needed in renaming indexes. */
- static const char rename_indexes[] =
+ static const char sql[] =
"PROCEDURE RENAME_INDEXES_PROC () IS\n"
"BEGIN\n"
"UPDATE SYS_INDEXES SET NAME=SUBSTR(NAME,1,LENGTH(NAME)-1)\n"
@@ -2352,7 +2362,7 @@ row_merge_rename_indexes(
pars_info_add_ull_literal(info, "tableid", table->id);
- err = que_eval_sql(info, rename_indexes, FALSE, trx);
+ err = que_eval_sql(info, sql, FALSE, trx);
if (err == DB_SUCCESS) {
dict_index_t* index = dict_table_get_first_index(table);
@@ -2362,6 +2372,15 @@ row_merge_rename_indexes(
}
index = dict_table_get_next_index(index);
} while (index);
+ } else {
+ /* Even though we ensure that DDL transactions are WAIT
+ and DEADLOCK free, we could encounter other errors e.g.,
+ DB_TOO_MANY_TRANSACTIONS. */
+ trx->error_state = DB_SUCCESS;
+
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Error: row_merge_rename_indexes "
+ "failed with error code: %lu.\n", (ulint) err);
}
trx->op_info = "";
@@ -2399,7 +2418,7 @@ row_merge_rename_tables(
memcpy(old_name, old_table->name, strlen(old_table->name) + 1);
} else {
ut_print_timestamp(stderr);
- fprintf(stderr, "InnoDB: too long table name: '%s', "
+ fprintf(stderr, " InnoDB: too long table name: '%s', "
"max length is %d\n", old_table->name,
MAX_FULL_NAME_LEN);
ut_error;
diff --git a/storage/innobase/row/row0row.c b/storage/innobase/row/row0row.c
index 20fd475343e..85c46f26933 100644
--- a/storage/innobase/row/row0row.c
+++ b/storage/innobase/row/row0row.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -241,13 +241,22 @@ row_build(
ut_ad(rec_offs_validate(rec, index, offsets));
}
-#if 0 && defined UNIV_BLOB_NULL_DEBUG
- /* This one can fail in trx_rollback_active() if
- the server crashed during an insert before the
- btr_store_big_rec_extern_fields() did mtr_commit()
- all BLOB pointers to the clustered index record. */
- ut_a(!rec_offs_any_null_extern(rec, offsets));
-#endif /* 0 && UNIV_BLOB_NULL_DEBUG */
+#ifdef UNIV_BLOB_NULL_DEBUG
+ if (rec_offs_any_null_extern(rec, offsets)) {
+ /* This condition can occur during crash recovery
+ before trx_rollback_active() has completed execution.
+
+ This condition is possible if the server crashed
+ during an insert or update-by-delete-and-insert before
+ btr_store_big_rec_extern_fields() did mtr_commit() all
+ BLOB pointers to the freshly inserted clustered index
+ record. */
+ ut_a(trx_assert_recovered(
+ row_get_rec_trx_id(rec, index, offsets)));
+ ut_a(trx_undo_roll_ptr_is_insert(
+ row_get_rec_roll_ptr(rec, index, offsets)));
+ }
+#endif /* UNIV_BLOB_NULL_DEBUG */
if (type != ROW_COPY_POINTERS) {
/* Take a copy of rec to heap */
diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c
index 0d1d3aad1c6..7bec0a26225 100644
--- a/storage/innobase/row/row0sel.c
+++ b/storage/innobase/row/row0sel.c
@@ -3998,7 +3998,8 @@ rec_loop:
wrong_offs:
if (srv_force_recovery == 0 || moves_up == FALSE) {
ut_print_timestamp(stderr);
- buf_page_print(page_align(rec), 0);
+ buf_page_print(page_align(rec), 0,
+ BUF_PAGE_PRINT_NO_CRASH);
fprintf(stderr,
"\nInnoDB: rec address %p,"
" buf block fix count %lu\n",
@@ -4017,7 +4018,7 @@ wrong_offs:
"InnoDB: restore from a backup, or"
" dump + drop + reimport the table.\n",
stderr);
-
+ ut_ad(0);
err = DB_CORRUPTION;
goto lock_wait_or_error;
@@ -4369,7 +4370,9 @@ no_gap_lock:
applicable to unique secondary indexes. Current behaviour is
to widen the scope of a lock on an already delete marked record
if the same record is deleted twice by the same transaction */
- if (index == clust_index && unique_search) {
+ if (index == clust_index && unique_search
+ && !prebuilt->used_in_HANDLER) {
+
err = DB_RECORD_NOT_FOUND;
goto normal_return;
diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c
index c57b829a1ca..4f5096a162b 100644
--- a/storage/innobase/row/row0upd.c
+++ b/storage/innobase/row/row0upd.c
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -23,6 +23,8 @@ Update of a row
Created 12/27/1996 Heikki Tuuri
*******************************************************/
+#include "m_string.h" /* for my_sys.h */
+#include "my_sys.h" /* DEBUG_SYNC_C */
#include "row0upd.h"
#ifdef UNIV_NONINL
@@ -2000,28 +2002,62 @@ row_upd_clust_rec(
ut_ad(!rec_get_deleted_flag(btr_pcur_get_rec(pcur),
dict_table_is_comp(index->table)));
- err = btr_cur_pessimistic_update(BTR_NO_LOCKING_FLAG, btr_cur,
- &heap, &big_rec, node->update,
- node->cmpl_info, thr, mtr);
- mtr_commit(mtr);
-
- if (err == DB_SUCCESS && big_rec) {
- ulint offsets_[REC_OFFS_NORMAL_SIZE];
- rec_t* rec;
+ err = btr_cur_pessimistic_update(
+ BTR_NO_LOCKING_FLAG | BTR_KEEP_POS_FLAG, btr_cur,
+ &heap, &big_rec, node->update, node->cmpl_info, thr, mtr);
+ if (big_rec) {
+ ulint offsets_[REC_OFFS_NORMAL_SIZE];
+ rec_t* rec;
rec_offs_init(offsets_);
- mtr_start(mtr);
+ ut_a(err == DB_SUCCESS);
+ /* Write out the externally stored
+ columns while still x-latching
+ index->lock and block->lock. Allocate
+ pages for big_rec in the mtr that
+ modified the B-tree, but be sure to skip
+ any pages that were freed in mtr. We will
+ write out the big_rec pages before
+ committing the B-tree mini-transaction. If
+ the system crashes so that crash recovery
+ will not replay the mtr_commit(&mtr), the
+ big_rec pages will be left orphaned until
+ the pages are allocated for something else.
+
+ TODO: If the allocation extends the tablespace, it
+ will not be redo logged, in either mini-transaction.
+ Tablespace extension should be redo-logged in the
+ big_rec mini-transaction, so that recovery will not
+ fail when the big_rec was written to the extended
+ portion of the file, in case the file was somehow
+ truncated in the crash. */
- ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr));
rec = btr_cur_get_rec(btr_cur);
+ DEBUG_SYNC_C("before_row_upd_extern");
err = btr_store_big_rec_extern_fields(
index, btr_cur_get_block(btr_cur), rec,
rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap),
- mtr, TRUE, big_rec);
- mtr_commit(mtr);
+ big_rec, mtr, BTR_STORE_UPDATE);
+ DEBUG_SYNC_C("after_row_upd_extern");
+ /* If writing big_rec fails (for example, because of
+ DB_OUT_OF_FILE_SPACE), the record will be corrupted.
+ Even if we did not update any externally stored
+ columns, our update could cause the record to grow so
+ that a non-updated column was selected for external
+ storage. This non-update would not have been written
+ to the undo log, and thus the record cannot be rolled
+ back.
+
+ However, because we have not executed mtr_commit(mtr)
+ yet, the update will not be replayed in crash
+ recovery, and the following assertion failure will
+ effectively "roll back" the operation. */
+ ut_a(err == DB_SUCCESS);
}
+ mtr_commit(mtr);
+
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c
index edc655e93b9..343e41fe376 100644
--- a/storage/innobase/srv/srv0start.c
+++ b/storage/innobase/srv/srv0start.c
@@ -922,8 +922,9 @@ skip_size_check:
#endif /* UNIV_LOG_ARCHIVE */
min_flushed_lsn, max_flushed_lsn);
- if (UNIV_PAGE_SIZE
- != fsp_flags_get_page_size(flags)) {
+ if (!one_opened
+ && UNIV_PAGE_SIZE
+ != fsp_flags_get_page_size(flags)) {
ut_print_timestamp(stderr);
fprintf(stderr,
diff --git a/storage/innobase/sync/sync0rw.c b/storage/innobase/sync/sync0rw.c
index fc4f987fe65..8de9b40ef67 100644
--- a/storage/innobase/sync/sync0rw.c
+++ b/storage/innobase/sync/sync0rw.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -785,7 +785,9 @@ rw_lock_add_debug_info(
rw_lock_debug_mutex_exit();
if ((pass == 0) && (lock_type != RW_LOCK_WAIT_EX)) {
- sync_thread_add_level(lock, lock->level);
+ sync_thread_add_level(lock, lock->level,
+ lock_type == RW_LOCK_EX
+ && lock->lock_word < 0);
}
}
diff --git a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c
index 81efe50d9bd..fb7101fdb8d 100644
--- a/storage/innobase/sync/sync0sync.c
+++ b/storage/innobase/sync/sync0sync.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -693,7 +693,7 @@ mutex_set_debug_info(
ut_ad(mutex);
ut_ad(file_name);
- sync_thread_add_level(mutex, mutex->level);
+ sync_thread_add_level(mutex, mutex->level, FALSE);
mutex->file_name = file_name;
mutex->line = line;
@@ -1136,8 +1136,9 @@ void
sync_thread_add_level(
/*==================*/
void* latch, /*!< in: pointer to a mutex or an rw-lock */
- ulint level) /*!< in: level in the latching order; if
+ ulint level, /*!< in: level in the latching order; if
SYNC_LEVEL_VARYING, nothing is done */
+ ibool relock) /*!< in: TRUE if re-entering an x-lock */
{
ulint i;
sync_level_t* slot;
@@ -1188,6 +1189,10 @@ sync_thread_add_level(
array = thread_slot->levels;
+ if (relock) {
+ goto levels_ok;
+ }
+
/* NOTE that there is a problem with _NODE and _LEAF levels: if the
B-tree height changes, then a leaf can change to an internal node
or the other way around. We do not know at present if this can cause
@@ -1363,6 +1368,7 @@ sync_thread_add_level(
ut_error;
}
+levels_ok:
if (array->next_free == ULINT_UNDEFINED) {
ut_a(array->n_elems < array->max_elems);
diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c
index 786c7be36a4..2f1389ae263 100644
--- a/storage/innobase/trx/trx0rec.c
+++ b/storage/innobase/trx/trx0rec.c
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -1198,6 +1198,7 @@ trx_undo_report_row_operation(
trx_t* trx;
trx_undo_t* undo;
ulint page_no;
+ buf_block_t* undo_block;
trx_rseg_t* rseg;
mtr_t mtr;
ulint err = DB_SUCCESS;
@@ -1240,10 +1241,13 @@ trx_undo_report_row_operation(
if (UNIV_UNLIKELY(!undo)) {
/* Did not succeed */
+ ut_ad(err != DB_SUCCESS);
mutex_exit(&(trx->undo_mutex));
return(err);
}
+
+ ut_ad(err == DB_SUCCESS);
} else {
ut_ad(op_type == TRX_UNDO_MODIFY_OP);
@@ -1257,30 +1261,30 @@ trx_undo_report_row_operation(
if (UNIV_UNLIKELY(!undo)) {
/* Did not succeed */
+ ut_ad(err != DB_SUCCESS);
mutex_exit(&(trx->undo_mutex));
return(err);
}
+ ut_ad(err == DB_SUCCESS);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
}
- page_no = undo->last_page_no;
-
mtr_start(&mtr);
+ page_no = undo->last_page_no;
+ undo_block = buf_page_get_gen(
+ undo->space, undo->zip_size, page_no, RW_X_LATCH,
+ undo->guess_block, BUF_GET, __FILE__, __LINE__, &mtr);
+ buf_block_dbg_add_level(undo_block, SYNC_TRX_UNDO_PAGE);
+
do {
- buf_block_t* undo_block;
page_t* undo_page;
ulint offset;
- undo_block = buf_page_get_gen(undo->space, undo->zip_size,
- page_no, RW_X_LATCH,
- undo->guess_block, BUF_GET,
- __FILE__, __LINE__, &mtr);
- buf_block_dbg_add_level(undo_block, SYNC_TRX_UNDO_PAGE);
-
undo_page = buf_block_get_frame(undo_block);
+ ut_ad(page_no == buf_block_get_page_no(undo_block));
if (op_type == TRX_UNDO_INSERT_OP) {
offset = trx_undo_page_report_insert(
@@ -1357,12 +1361,11 @@ trx_undo_report_row_operation(
a pessimistic insert in a B-tree, and we must reserve the
counterpart of the tree latch, which is the rseg mutex. */
- mutex_enter(&(rseg->mutex));
-
- page_no = trx_undo_add_page(trx, undo, &mtr);
-
- mutex_exit(&(rseg->mutex));
- } while (UNIV_LIKELY(page_no != FIL_NULL));
+ mutex_enter(&rseg->mutex);
+ undo_block = trx_undo_add_page(trx, undo, &mtr);
+ mutex_exit(&rseg->mutex);
+ page_no = undo->last_page_no;
+ } while (undo_block != NULL);
/* Did not succeed: out of space */
err = DB_OUT_OF_FILE_SPACE;
diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c
index c0283448d10..90091c00228 100644
--- a/storage/innobase/trx/trx0sys.c
+++ b/storage/innobase/trx/trx0sys.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2011, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -255,9 +255,7 @@ trx_sys_create_doublewrite_buf(void)
{
buf_block_t* block;
buf_block_t* block2;
-#ifdef UNIV_SYNC_DEBUG
buf_block_t* new_block;
-#endif /* UNIV_SYNC_DEBUG */
byte* doublewrite;
byte* fseg_header;
ulint page_no;
@@ -336,10 +334,9 @@ start_again:
for (i = 0; i < 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
+ FSP_EXTENT_SIZE / 2; i++) {
- page_no = fseg_alloc_free_page(fseg_header,
- prev_page_no + 1,
- FSP_UP, &mtr);
- if (page_no == FIL_NULL) {
+ new_block = fseg_alloc_free_page(
+ fseg_header, prev_page_no + 1, FSP_UP, &mtr);
+ if (new_block == NULL) {
fprintf(stderr,
"InnoDB: Cannot create doublewrite"
" buffer: you must\n"
@@ -360,13 +357,8 @@ start_again:
the page position in the tablespace, then the page
has not been written to in doublewrite. */
-#ifdef UNIV_SYNC_DEBUG
- new_block =
-#endif /* UNIV_SYNC_DEBUG */
- buf_page_get(TRX_SYS_SPACE, 0, page_no,
- RW_X_LATCH, &mtr);
- buf_block_dbg_add_level(new_block,
- SYNC_NO_ORDER_CHECK);
+ ut_ad(rw_lock_get_x_lock_count(&new_block->lock) == 1);
+ page_no = buf_block_get_page_no(new_block);
if (i == FSP_EXTENT_SIZE / 2) {
ut_a(page_no == FSP_EXTENT_SIZE);
@@ -586,12 +578,16 @@ trx_sys_doublewrite_init_or_restore_pages(
if (buf_page_is_corrupted(page, zip_size)) {
fprintf(stderr,
"InnoDB: Dump of the page:\n");
- buf_page_print(read_buf, zip_size);
+ buf_page_print(
+ read_buf, zip_size,
+ BUF_PAGE_PRINT_NO_CRASH);
fprintf(stderr,
"InnoDB: Dump of"
" corresponding page"
" in doublewrite buffer:\n");
- buf_page_print(page, zip_size);
+ buf_page_print(
+ page, zip_size,
+ BUF_PAGE_PRINT_NO_CRASH);
fprintf(stderr,
"InnoDB: Also the page in the"
@@ -605,7 +601,7 @@ trx_sys_doublewrite_init_or_restore_pages(
"InnoDB: option:\n"
"InnoDB:"
" innodb_force_recovery=6\n");
- exit(1);
+ ut_error;
}
/* Write the good page from the
diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c
index ab7677b5b35..85246aa6d1f 100644
--- a/storage/innobase/trx/trx0trx.c
+++ b/storage/innobase/trx/trx0trx.c
@@ -1065,6 +1065,8 @@ trx_commit_off_kernel(
ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0);
UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
+
+ trx->error_state = DB_SUCCESS;
}
/****************************************************************//**
diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c
index dae0637f72c..3d794c69c8b 100644
--- a/storage/innobase/trx/trx0undo.c
+++ b/storage/innobase/trx/trx0undo.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 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 the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -876,9 +876,9 @@ trx_undo_discard_latest_update_undo(
#ifndef UNIV_HOTBACKUP
/********************************************************************//**
Tries to add a page to the undo log segment where the undo log is placed.
-@return page number if success, else FIL_NULL */
+@return X-latched block if success, else NULL */
UNIV_INTERN
-ulint
+buf_block_t*
trx_undo_add_page(
/*==============*/
trx_t* trx, /*!< in: transaction */
@@ -888,11 +888,10 @@ trx_undo_add_page(
the rollback segment mutex */
{
page_t* header_page;
+ buf_block_t* new_block;
page_t* new_page;
trx_rseg_t* rseg;
- ulint page_no;
ulint n_reserved;
- ibool success;
ut_ad(mutex_own(&(trx->undo_mutex)));
ut_ad(!mutex_own(&kernel_mutex));
@@ -902,37 +901,37 @@ trx_undo_add_page(
if (rseg->curr_size == rseg->max_size) {
- return(FIL_NULL);
+ return(NULL);
}
header_page = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no, mtr);
- success = fsp_reserve_free_extents(&n_reserved, undo->space, 1,
- FSP_UNDO, mtr);
- if (!success) {
+ if (!fsp_reserve_free_extents(&n_reserved, undo->space, 1,
+ FSP_UNDO, mtr)) {
- return(FIL_NULL);
+ return(NULL);
}
- page_no = fseg_alloc_free_page_general(header_page + TRX_UNDO_SEG_HDR
- + TRX_UNDO_FSEG_HEADER,
- undo->top_page_no + 1, FSP_UP,
- TRUE, mtr);
+ new_block = fseg_alloc_free_page_general(
+ TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER
+ + header_page,
+ undo->top_page_no + 1, FSP_UP, TRUE, mtr, mtr);
fil_space_release_free_extents(undo->space, n_reserved);
- if (page_no == FIL_NULL) {
+ if (new_block == NULL) {
/* No space left */
- return(FIL_NULL);
+ return(NULL);
}
- undo->last_page_no = page_no;
+ ut_ad(rw_lock_get_x_lock_count(&new_block->lock) == 1);
+ buf_block_dbg_add_level(new_block, SYNC_TRX_UNDO_PAGE);
+ undo->last_page_no = buf_block_get_page_no(new_block);
- new_page = trx_undo_page_get(undo->space, undo->zip_size,
- page_no, mtr);
+ new_page = buf_block_get_frame(new_block);
trx_undo_page_init(new_page, undo->type, mtr);
@@ -941,7 +940,7 @@ trx_undo_add_page(
undo->size++;
rseg->curr_size++;
- return(page_no);
+ return(new_block);
}
/********************************************************************//**
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 56d0149a748..f419ac3d689 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2001, 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
diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c
index 6b36891ccf6..e31075e55d1 100644
--- a/storage/myisam/ft_nlq_search.c
+++ b/storage/myisam/ft_nlq_search.c
@@ -1,5 +1,4 @@
-/*
- 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
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 87fccb6f449..3f99dfc2186 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -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
@@ -74,10 +74,10 @@ static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG,
"disables parallel repair", NULL, NULL,
1, 1, ULONG_MAX, 1);
-static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG,
+static MYSQL_THDVAR_ULONGLONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG,
"The buffer that is allocated when sorting the index when doing "
"a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", NULL, NULL,
- 8192*1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), ULONG_MAX, 1);
+ 8192 * 1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), SIZE_T_MAX, 1);
static MYSQL_SYSVAR_BOOL(use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG,
"Use memory mapping for reading and writing MyISAM tables", NULL, NULL, FALSE);
diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
index 7439ea290c6..aa00398e7e7 100644
--- a/storage/myisam/ha_myisam.h
+++ b/storage/myisam/ha_myisam.h
@@ -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
@@ -36,7 +36,6 @@ typedef struct st_ha_create_information HA_CREATE_INFO;
#define HA_RECOVER_FULL_BACKUP 16 /* Make a copy of index file too */
#define HA_RECOVER_OFF 32 /* No automatic recover */
-extern ulong myisam_sort_buffer_size;
extern TYPELIB myisam_recover_typelib;
extern const char *myisam_recover_names[];
extern ulonglong myisam_recover_options;
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index 04d2263ab5b..7e97a751376 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -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
@@ -2406,7 +2406,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
if (_create_index_by_sort(&sort_param,
(my_bool) (!(param->testflag & T_VERBOSE)),
- (uint) param->sort_buffer_length))
+ param->sort_buffer_length))
{
param->retry_repair= 1;
if (! param->error_printed)
@@ -4312,14 +4312,6 @@ int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename)
u_ptr->seg=keyseg;
keyseg+=u_ptr->keysegs+1;
}
- if (share.options & HA_OPTION_COMPRESS_RECORD)
- share.base.records=max_records=info.state->records;
- else if (share.base.min_pack_length)
- max_records=(ha_rows) (mysql_file_seek(info.dfile, 0L, MY_SEEK_END,
- MYF(0)) /
- (ulong) share.base.min_pack_length);
- else
- max_records=0;
unpack= (share.options & HA_OPTION_COMPRESS_RECORD) &&
(param->testflag & T_UNPACK);
share.options&= ~HA_OPTION_TEMP_COMPRESS_RECORD;
@@ -4329,10 +4321,17 @@ int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename)
set_if_bigger(file_length,param->max_data_file_length);
set_if_bigger(file_length,tmp_length);
set_if_bigger(file_length,(ulonglong) share.base.max_data_file_length);
+
+ if (share.options & HA_OPTION_COMPRESS_RECORD)
+ share.base.records= max_records= info.state->records;
+ else if (!(share.options & HA_OPTION_PACK_RECORD))
+ max_records= (ha_rows) (file_length / share.base.pack_reclength);
+ else
+ max_records= 0;
(void) mi_close(*org_info);
bzero((char*) &create_info,sizeof(create_info));
- create_info.max_rows=max(max_records,share.base.records);
+ create_info.max_rows= max_records;
create_info.reloc_rows=share.base.reloc;
create_info.old_options=(share.options |
(unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index c154ec3b817..7e2403b64c9 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* 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
diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c
index 767858a6ea0..1a2d5aac94f 100644
--- a/storage/myisam/mi_preload.c
+++ b/storage/myisam/mi_preload.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2003, 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
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index 32d39e5a09d..fa8cc679997 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -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
@@ -297,9 +296,9 @@ static struct my_option my_long_options[] =
INT_MAX32, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "",
&check_param.sort_buffer_length,
- &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
+ &check_param.sort_buffer_length, 0, GET_ULL, REQUIRED_ARG,
(long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD),
- ULONG_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
+ SIZE_T_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "",
&check_param.sort_key_blocks,
&check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG,
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index a72b329a4c0..e3c1647cd59 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -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
diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index 6da2c5c7816..2c4639b3143 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -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
@@ -100,10 +99,11 @@ my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs);
*/
int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
- ulong sortbuff_size)
+ ulonglong sortbuff_size)
{
int error,maxbuffer,skr;
- uint memavl,old_memavl,keys,sort_length;
+ uint sort_length, keys;
+ ulonglong memavl, old_memavl;
DYNAMIC_ARRAY buffpek;
ha_rows records;
uchar **sort_keys;
@@ -135,6 +135,9 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
sort_length= info->key_length;
LINT_INIT(keys);
+ if ((memavl - sizeof(BUFFPEK)) / (sort_length + sizeof(char *)) > UINT_MAX32)
+ memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *));
+
while (memavl >= MIN_SORT_BUFFER)
{
if ((records < UINT_MAX32) &&
@@ -311,7 +314,8 @@ pthread_handler_t thr_find_all_keys(void *arg)
{
MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg;
int error;
- uint memavl,old_memavl,keys,sort_length;
+ ulonglong memavl, old_memavl;
+ uint keys, sort_length;
uint idx, maxbuffer;
uchar **sort_keys=0;
@@ -352,6 +356,10 @@ pthread_handler_t thr_find_all_keys(void *arg)
sort_length= sort_param->key_length;
maxbuffer= 1;
+ if ((memavl - sizeof(BUFFPEK)) / (sort_length +
+ sizeof(char *)) > UINT_MAX32)
+ memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *));
+
while (memavl >= MIN_SORT_BUFFER)
{
if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <=
diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc
index d7771de7fb8..0fb86cfe5cd 100644
--- a/storage/perfschema/ha_perfschema.cc
+++ b/storage/perfschema/ha_perfschema.cc
@@ -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
diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc
index 27350c59604..9a6ada2f814 100644
--- a/storage/perfschema/pfs.cc
+++ b/storage/perfschema/pfs.cc
@@ -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
diff --git a/storage/perfschema/table_ews_global_by_event_name.cc b/storage/perfschema/table_ews_global_by_event_name.cc
index 01d9bc5678f..3177584231d 100644
--- a/storage/perfschema/table_ews_global_by_event_name.cc
+++ b/storage/perfschema/table_ews_global_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 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
diff --git a/storage/perfschema/table_ews_global_by_event_name.h b/storage/perfschema/table_ews_global_by_event_name.h
index 9b2b5cba5a8..7e66448e96c 100644
--- a/storage/perfschema/table_ews_global_by_event_name.h
+++ b/storage/perfschema/table_ews_global_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 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
diff --git a/storage/xtradb/row/row0merge.c b/storage/xtradb/row/row0merge.c
index 30cfa7c23af..9390946ad88 100644
--- a/storage/xtradb/row/row0merge.c
+++ b/storage/xtradb/row/row0merge.c
@@ -583,7 +583,7 @@ row_merge_buf_write(
REC_STATUS_ORDINARY,
entry, n_fields,
&extra_size);
- ut_ad(size > extra_size);
+ ut_ad(size >= extra_size);
ut_ad(extra_size >= REC_N_NEW_EXTRA_BYTES);
extra_size -= REC_N_NEW_EXTRA_BYTES;
size -= REC_N_NEW_EXTRA_BYTES;
diff --git a/storage/xtradb/row/row0sel.c b/storage/xtradb/row/row0sel.c
index f4a91e68024..8e6b01f2a6d 100644
--- a/storage/xtradb/row/row0sel.c
+++ b/storage/xtradb/row/row0sel.c
@@ -4604,7 +4604,9 @@ no_gap_lock:
applicable to unique secondary indexes. Current behaviour is
to widen the scope of a lock on an already delete marked record
if the same record is deleted twice by the same transaction */
- if (index == clust_index && unique_search) {
+ if (index == clust_index && unique_search
+ && !prebuilt->used_in_HANDLER) {
+
err = DB_RECORD_NOT_FOUND;
goto normal_return;
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index 7dc1527002f..e4a8d7a4067 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -1,6 +1,5 @@
-/* Copyright (c) 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc.
- Copyright (c) 2009-2011, Monty Program Ab
- Use is subject to license terms.
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 7fd1e595eca..83ea3739f4c 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2003, 2010, Oracle and/or its affiliates
- Copyright (c) 2009-2011, Monty Program Ab
+/* Copyright (c) 2003, 2012, Oracle and/or its affiliates
+ Copyright (c) 2009, 2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index b9f8b57c6b0..466114f9c6b 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -1,6 +1,5 @@
-/* Copyright (c) 2002-2008 MySQL AB, 2009 Sun Microsystems, Inc.
- Copyright (c) 2009-2011, Monty Program Ab
- Use is subject to license terms.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/dtoa.c b/strings/dtoa.c
index 2af561d0564..6b216056f66 100644
--- a/strings/dtoa.c
+++ b/strings/dtoa.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c
index 062a0963e76..bcfb9835c10 100644
--- a/unittest/mysys/bitmap-t.c
+++ b/unittest/mysys/bitmap-t.c
@@ -1,4 +1,5 @@
-/* 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
diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c
index ae9bb6903f5..35e782eb360 100644
--- a/unittest/mysys/my_atomic-t.c
+++ b/unittest/mysys/my_atomic-t.c
@@ -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