summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitKeeper/etc/logging_ok5
-rwxr-xr-xBitKeeper/triggers/pre-commit11
-rwxr-xr-xBuild-tools/Bootstrap42
-rwxr-xr-xBuild-tools/Do-compile10
-rw-r--r--Docs/mysqld_error.txt2
-rw-r--r--VC++Files/libmysqld/examples/test_libmysqld.dsp6
-rw-r--r--VC++Files/mysql.dsw18
-rw-r--r--VC++Files/mysql_ia64.dsw3
-rw-r--r--VC++Files/mysqlmanager/MySqlManager_ia64.dsp276
-rw-r--r--VC++Files/mysys/mysys.dsp4
-rw-r--r--bdb/btree/bt_open.c2
-rw-r--r--bdb/hash/hash_open.c2
-rw-r--r--client/mysql.cc7
-rw-r--r--client/mysqlbinlog.cc2
-rw-r--r--client/mysqldump.c34
-rw-r--r--client/mysqlshow.c78
-rw-r--r--client/mysqltest.c18
-rw-r--r--config/ac-macros/ha_blackhole.m429
-rw-r--r--config/ac-macros/misc.m428
-rw-r--r--configure.in7
-rw-r--r--include/config-netware.h3
-rw-r--r--include/decimal.h57
-rw-r--r--include/my_global.h27
-rw-r--r--include/my_sys.h11
-rw-r--r--include/violite.h4
-rw-r--r--innobase/include/trx0trx.h11
-rw-r--r--innobase/trx/trx0trx.c10
-rw-r--r--libmysql/Makefile.shared3
-rw-r--r--libmysql/libmysql.c17
-rw-r--r--libmysql/libmysql.def2
-rw-r--r--libmysqld/Makefile.am3
-rw-r--r--libmysqld/libmysqld.def6
-rw-r--r--myisam/mi_open.c4
-rw-r--r--myisam/mi_packrec.c2
-rw-r--r--myisam/myisamchk.c4
-rw-r--r--mysql-test/README2
-rw-r--r--mysql-test/include/have_blackhole.inc4
-rw-r--r--mysql-test/include/ps_query.inc5
-rw-r--r--mysql-test/lib/init_db.sql104
-rw-r--r--mysql-test/lib/mtr_cases.pl33
-rw-r--r--mysql-test/lib/mtr_diff.pl283
-rw-r--r--mysql-test/lib/mtr_report.pl11
-rwxr-xr-xmysql-test/mysql-test-run.pl37
-rw-r--r--mysql-test/mysql-test-run.sh16
-rw-r--r--mysql-test/r/blackhole.result86
-rw-r--r--mysql-test/r/ctype_big5.result7
-rw-r--r--mysql-test/r/ctype_cp1251.result4
-rw-r--r--mysql-test/r/ctype_ucs.result8
-rw-r--r--mysql-test/r/ctype_utf8.result14
-rw-r--r--mysql-test/r/date_formats.result39
-rw-r--r--mysql-test/r/federated.result2
-rw-r--r--mysql-test/r/func_group.result2
-rw-r--r--mysql-test/r/func_str.result20
-rw-r--r--mysql-test/r/func_system.result4
-rw-r--r--mysql-test/r/grant.result13
-rw-r--r--mysql-test/r/grant2.result61
-rw-r--r--mysql-test/r/grant3.result18
-rw-r--r--mysql-test/r/group_by.result25
-rw-r--r--mysql-test/r/have_blackhole.require2
-rw-r--r--mysql-test/r/information_schema.result11
-rw-r--r--mysql-test/r/kill.result6
-rw-r--r--mysql-test/r/metadata.result39
-rw-r--r--mysql-test/r/mix_innodb_myisam_binlog.result78
-rw-r--r--mysql-test/r/mysqlshow.result76
-rw-r--r--mysql-test/r/ndb_autodiscover.result4
-rw-r--r--mysql-test/r/olap.result45
-rw-r--r--mysql-test/r/openssl_1.result8
-rw-r--r--mysql-test/r/ps_1general.result7
-rw-r--r--mysql-test/r/ps_2myisam.result26
-rw-r--r--mysql-test/r/ps_3innodb.result26
-rw-r--r--mysql-test/r/ps_4heap.result26
-rw-r--r--mysql-test/r/ps_5merge.result52
-rw-r--r--mysql-test/r/ps_6bdb.result26
-rw-r--r--mysql-test/r/ps_7ndb.result26
-rw-r--r--mysql-test/r/rpl_change_master.result4
-rw-r--r--mysql-test/r/rpl_deadlock.result16
-rw-r--r--mysql-test/r/rpl_drop_temp.result1
-rw-r--r--mysql-test/r/rpl_error_ignored_table.result2
-rw-r--r--mysql-test/r/rpl_flush_log_loop.result2
-rw-r--r--mysql-test/r/rpl_loaddata.result27
-rw-r--r--mysql-test/r/rpl_log.result82
-rw-r--r--mysql-test/r/rpl_max_relay_size.result10
-rw-r--r--mysql-test/r/rpl_openssl.result4
-rw-r--r--mysql-test/r/rpl_relayrotate.result2
-rw-r--r--mysql-test/r/rpl_replicate_do.result2
-rw-r--r--mysql-test/r/rpl_rotate_logs.result8
-rw-r--r--mysql-test/r/rpl_temporary.result4
-rw-r--r--mysql-test/r/rpl_timezone.result81
-rw-r--r--mysql-test/r/rpl_until.result30
-rw-r--r--mysql-test/r/show_check.result42
-rw-r--r--mysql-test/r/sp-error.result9
-rw-r--r--mysql-test/r/sp.result21
-rw-r--r--mysql-test/r/strict.result60
-rw-r--r--mysql-test/r/subselect.result434
-rw-r--r--mysql-test/r/system_mysql_db.result1
-rw-r--r--mysql-test/r/type_bit.result2
-rw-r--r--mysql-test/r/type_blob.result6
-rw-r--r--mysql-test/r/type_decimal.result55
-rw-r--r--mysql-test/r/type_enum.result2
-rw-r--r--mysql-test/r/type_newdecimal.result11
-rw-r--r--mysql-test/r/type_varchar.result7
-rw-r--r--mysql-test/r/union.result48
-rw-r--r--mysql-test/r/user_var.result7
-rw-r--r--mysql-test/r/variables.result8
-rw-r--r--mysql-test/r/view.result6
-rw-r--r--mysql-test/r/warnings.result19
-rw-r--r--mysql-test/std_data/rpl_timezone.dat2
-rw-r--r--mysql-test/t/blackhole.test99
-rw-r--r--mysql-test/t/ctype_big5.test9
-rw-r--r--mysql-test/t/ctype_cp1251-master.opt2
-rw-r--r--mysql-test/t/ctype_cp1251.test4
-rw-r--r--mysql-test/t/ctype_ucs.test9
-rw-r--r--mysql-test/t/ctype_utf8.test11
-rw-r--r--mysql-test/t/date_formats.test1
-rw-r--r--mysql-test/t/federated.test1
-rw-r--r--mysql-test/t/func_str.test14
-rw-r--r--mysql-test/t/func_system.test2
-rw-r--r--mysql-test/t/grant2.test68
-rw-r--r--mysql-test/t/grant3-master.opt1
-rw-r--r--mysql-test/t/grant3.test33
-rw-r--r--mysql-test/t/group_by.test26
-rw-r--r--mysql-test/t/information_schema.test1
-rw-r--r--mysql-test/t/kill.test5
-rw-r--r--mysql-test/t/metadata.test13
-rw-r--r--mysql-test/t/mysqlbinlog.test4
-rw-r--r--mysql-test/t/mysqlbinlog2.test12
-rw-r--r--mysql-test/t/mysqlshow.test20
-rw-r--r--mysql-test/t/olap.test7
-rw-r--r--mysql-test/t/openssl_1.test8
-rw-r--r--mysql-test/t/rpl_deadlock.test8
-rw-r--r--mysql-test/t/rpl_drop_temp.test3
-rw-r--r--mysql-test/t/rpl_loaddata.test25
-rw-r--r--mysql-test/t/rpl_timezone-slave.opt2
-rw-r--r--mysql-test/t/rpl_timezone.test63
-rw-r--r--mysql-test/t/rpl_until.test8
-rw-r--r--mysql-test/t/sp-error.test17
-rw-r--r--mysql-test/t/sp.test22
-rw-r--r--mysql-test/t/strict.test93
-rw-r--r--mysql-test/t/subselect.test190
-rw-r--r--mysql-test/t/type_decimal.test41
-rw-r--r--mysql-test/t/type_newdecimal.test16
-rw-r--r--mysql-test/t/type_varchar.test9
-rw-r--r--mysql-test/t/union.test31
-rw-r--r--mysql-test/t/user_var.test7
-rw-r--r--mysql-test/t/variables.test9
-rw-r--r--mysql-test/t/warnings.test13
-rw-r--r--mysys/Makefile.am3
-rw-r--r--mysys/charset-def.c6
-rw-r--r--mysys/charset.c75
-rw-r--r--mysys/default.c130
-rw-r--r--mysys/my_mmap.c7
-rw-r--r--mysys/my_windac.c224
-rw-r--r--ndb/include/util/Vector.hpp8
-rw-r--r--ndb/src/kernel/blocks/dbdict/Dbdict.cpp4
-rw-r--r--ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp (renamed from ndb/src/kernel/blocks/dbdict/printSchemafile/printSchemafile.cpp)15
-rw-r--r--ndb/src/kernel/blocks/dbdict/printSchemafile/Makefile12
-rw-r--r--ndb/src/kernel/vm/VMSignal.cpp4
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp12
-rw-r--r--ndb/src/ndbapi/DictCache.cpp7
-rw-r--r--scripts/fill_func_tables.sh8
-rw-r--r--scripts/make_win_src_distribution.sh2
-rw-r--r--scripts/mysql_create_system_tables.sh23
-rw-r--r--scripts/mysql_fix_privilege_tables.sh2
-rw-r--r--scripts/mysql_fix_privilege_tables.sql54
-rw-r--r--server-tools/instance-manager/commands.cc7
-rw-r--r--server-tools/instance-manager/commands.h2
-rw-r--r--server-tools/instance-manager/factory.cc5
-rw-r--r--server-tools/instance-manager/guardian.cc2
-rw-r--r--server-tools/instance-manager/guardian.h3
-rw-r--r--server-tools/instance-manager/instance.cc5
-rw-r--r--server-tools/instance-manager/instance.h2
-rw-r--r--server-tools/instance-manager/instance_map.cc3
-rw-r--r--server-tools/instance-manager/instance_map.h7
-rw-r--r--server-tools/instance-manager/instance_options.cc2
-rw-r--r--server-tools/instance-manager/log.cc4
-rw-r--r--server-tools/instance-manager/manager.cc2
-rw-r--r--server-tools/instance-manager/messages.cc7
-rw-r--r--server-tools/instance-manager/messages.h3
-rw-r--r--server-tools/instance-manager/mysql_connection.cc17
-rw-r--r--server-tools/instance-manager/mysqlmanager.cc3
-rw-r--r--server-tools/instance-manager/options.cc5
-rw-r--r--server-tools/instance-manager/parse.cc1
-rw-r--r--server-tools/instance-manager/parse_output.cc2
-rw-r--r--server-tools/instance-manager/protocol.cc8
-rw-r--r--server-tools/instance-manager/protocol.h1
-rw-r--r--server-tools/instance-manager/thread_registry.cc3
-rw-r--r--server-tools/instance-manager/user_map.h3
-rw-r--r--sql-common/client.c15
-rw-r--r--sql/Makefile.am5
-rw-r--r--sql/field.cc1189
-rw-r--r--sql/field.h53
-rw-r--r--sql/ha_berkeley.cc7
-rw-r--r--sql/ha_blackhole.cc188
-rw-r--r--sql/ha_blackhole.h88
-rw-r--r--sql/ha_federated.cc1
-rw-r--r--sql/ha_innodb.cc81
-rw-r--r--sql/ha_innodb.h2
-rw-r--r--sql/ha_ndbcluster.cc70
-rw-r--r--sql/ha_ndbcluster.h3
-rw-r--r--sql/handler.cc38
-rw-r--r--sql/handler.h4
-rw-r--r--sql/item.cc466
-rw-r--r--sql/item.h35
-rw-r--r--sql/item_cmpfunc.cc14
-rw-r--r--sql/item_func.cc20
-rw-r--r--sql/item_func.h3
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/item_strfunc.h4
-rw-r--r--sql/item_subselect.cc261
-rw-r--r--sql/item_subselect.h12
-rw-r--r--sql/item_sum.cc28
-rw-r--r--sql/item_sum.h3
-rw-r--r--sql/item_timefunc.cc32
-rw-r--r--sql/log.cc61
-rw-r--r--sql/log_event.cc279
-rw-r--r--sql/log_event.h63
-rw-r--r--sql/my_decimal.cc4
-rw-r--r--sql/my_decimal.h48
-rw-r--r--sql/mysql_priv.h22
-rw-r--r--sql/mysqld.cc73
-rw-r--r--sql/opt_range.cc35
-rw-r--r--sql/set_var.cc59
-rw-r--r--sql/set_var.h6
-rw-r--r--sql/share/errmsg.txt12
-rw-r--r--sql/slave.cc43
-rw-r--r--sql/slave.h10
-rw-r--r--sql/sp_head.cc1
-rw-r--r--sql/sql_acl.cc79
-rw-r--r--sql/sql_acl.h39
-rw-r--r--sql/sql_cache.cc1
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_db.cc3
-rw-r--r--sql/sql_derived.cc2
-rw-r--r--sql/sql_help.cc1
-rw-r--r--sql/sql_insert.cc6
-rw-r--r--sql/sql_lex.h5
-rw-r--r--sql/sql_load.cc42
-rw-r--r--sql/sql_parse.cc93
-rw-r--r--sql/sql_prepare.cc20
-rw-r--r--sql/sql_select.cc79
-rw-r--r--sql/sql_select.h11
-rw-r--r--sql/sql_show.cc144
-rw-r--r--sql/sql_string.h5
-rw-r--r--sql/sql_table.cc11
-rw-r--r--sql/sql_union.cc14
-rw-r--r--sql/sql_update.cc4
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/sql_yacc.yy19
-rw-r--r--sql/structs.h2
-rw-r--r--sql/table.cc10
-rw-r--r--sql/table.h4
-rw-r--r--sql/tztime.cc56
-rw-r--r--sql/tztime.h7
-rw-r--r--strings/ctype-big5.c35
-rw-r--r--strings/ctype-simple.c2
-rw-r--r--strings/ctype-sjis.c7
-rw-r--r--strings/ctype-ucs2.c2
-rw-r--r--strings/ctype-utf8.c181
-rw-r--r--strings/decimal.c221
-rw-r--r--strings/my_strtoll10-x86.s2
-rw-r--r--support-files/mysql.server.sh21
-rw-r--r--support-files/mysql.spec.sh4
-rw-r--r--tests/mysql_client_test.c113
-rw-r--r--vio/test-ssl.c4
-rw-r--r--vio/test-sslclient.c4
-rw-r--r--zlib/ChangeLog42
-rw-r--r--zlib/FAQ88
-rw-r--r--zlib/INDEX3
-rw-r--r--zlib/README8
-rw-r--r--zlib/crc32.c76
-rw-r--r--zlib/deflate.c4
-rw-r--r--zlib/deflate.h1
-rw-r--r--zlib/gzio.c4
-rw-r--r--zlib/infback.c3
-rw-r--r--zlib/inffast.c4
-rw-r--r--zlib/inflate.c4
-rw-r--r--zlib/inftrees.c17
-rw-r--r--zlib/trees.c4
-rw-r--r--zlib/zconf.h83
-rw-r--r--zlib/zlib.36
-rw-r--r--zlib/zlib.h30
-rw-r--r--zlib/zutil.h7
283 files changed, 7063 insertions, 2543 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index ef063bd6ab7..1897af73735 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -25,6 +25,7 @@ bar@bar.intranet.mysql.r18.ru
bar@bar.mysql.r18.ru
bar@bar.udmsearch.izhnet.ru
bar@deer.(none)
+bar@eagle.intranet.mysql.r18.ru
bar@gw.udmsearch.izhnet.ru
bar@mysql.com
bar@noter.intranet.mysql.r18.ru
@@ -48,6 +49,7 @@ dlenev@build.mysql.com
dlenev@jabberwock.localdomain
dlenev@mysql.com
ejonore@mc03.ndb.mysql.com
+gbichot@production.mysql.com
gbichot@quadita2.mysql.com
gbichot@quadxeon.mysql.com
georg@beethoven.local
@@ -118,6 +120,7 @@ kostja@oak.local
lars@mysql.com
lenz@kallisto.mysql.com
lenz@mysql.com
+magnus@msdesk.mysql.com
magnus@neptunus.(none)
magnus@shellback.(none)
marko@hundin.mysql.fi
@@ -186,6 +189,7 @@ papa@gbichot.local
patg@krsna.
patg@krsna.patg.net
patg@patrick-galbraiths-computer.local
+patg@patrick.local
patg@pc248.lfp.kcls.org
paul@central.snake.net
paul@frost.snake.net
@@ -226,6 +230,7 @@ salle@vafla.online.bg
sasha@mysql.sashanet.com
serg@build.mysql.com
serg@build.mysql2.com
+serg@mysql.com
serg@serg.mylan
serg@serg.mysql.com
serg@sergbook.mylan
diff --git a/BitKeeper/triggers/pre-commit b/BitKeeper/triggers/pre-commit
index 2293dc55e2a..524321e8b80 100755
--- a/BitKeeper/triggers/pre-commit
+++ b/BitKeeper/triggers/pre-commit
@@ -1,5 +1,16 @@
#!/bin/sh
+if [ "$BK_USER" = "Administrator" -o "$BK_USER" = "mysqldev" ]
+then
+ echo "Error: you cannot commit as 'Administrator' or 'mysqldev' user."
+ echo "as a workaround set BK_USER to your nickname"
+ echo "e.g.: export BK_USER='bar'"
+ echo ""
+ echo "Checkin FAILED!"
+ echo "Set BK_USER and retry."
+ exit 1
+fi
+
if [ "$REAL_EMAIL" = "" ]
then
echo "Error: you must set REAL_EMAIL in your profile"
diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap
index 64f865362ca..32d371cc2c6 100755
--- a/Build-tools/Bootstrap
+++ b/Build-tools/Bootstrap
@@ -240,40 +240,52 @@ if (defined $opt_changelog)
# the last tagged ChangeSet (this relies heavily on our current tagging
# practice!)
#
- my $revision= "";
+ $opt_changelog=~ s/^=//; # Sometimes, a leading '=' was not stripped.
+ my $log_base= $opt_changelog;
+ my $changelogfile;
+ if ($target_dir =~ m:^/:) # we need an absolute path, as we change directory
+ {
+ $changelogfile= $target_dir. "/ChangeLog";
+ }
+ else
+ {
+ $changelogfile= cwd() . "/" . $target_dir . "/ChangeLog";
+ }
+
if ($opt_changelog eq "last")
{
if (!$opt_revision)
{
- $revision= `bk changes -t -d':REV:::TAG:' -n $REPO | grep mysql-$major.$minor | head -1 | cut -f1 -d ":"`;
+ $log_base= `bk changes -t -d':REV:::TAG:' -n $REPO | grep mysql-$major.$minor | head -1 | cut -f1 -d ":"`;
}
else
{
- $revision= `bk changes -r..$opt_revision -t -d':REV:' -n $REPO | head -2 | tail -1`;
+ $log_base= `bk changes -r..$opt_revision -t -d':REV:' -n $REPO | head -2 | tail -1`;
}
- chomp($revision);
- $opt_changelog= $revision;
+ chomp($log_base);
}
- $msg= "Adding $target_dir/ChangeLog";
- $msg.= " (down to revision $opt_changelog)" if $opt_changelog ne "";
+ $msg= "Adding $changelogfile";
+ $msg.= " (down to revision $log_base)" if $log_base ne "";
&logger($msg);
- $command= "bk changes -v";
- $command.= " -r" if ($opt_changelog ne "" || $opt_revision);
- $command.= $opt_changelog if $opt_changelog ne "";
- $command.= ".." if ($opt_changelog ne "" && !$opt_revision);
+ # Due to a BK error, "bk changes" must be run in $REPO !
+ $command= "cd $REPO ; ";
+ $command.= "bk changes -v";
+ $command.= " -r" if ($log_base ne "" || $opt_revision);
+ $command.= $log_base if $log_base ne "";
+ $command.= ".." if ($log_base ne "" && !$opt_revision);
$command.= ".." . $opt_revision if $opt_revision;
- $command.= " " . $REPO . " > $target_dir/ChangeLog";
+ $command.= " > $changelogfile";
&logger($command);
# We cannot use run_command here because of output redirection
unless ($opt_dry_run)
{
- system($command) == 0 or &abort("Could not create $target_dir/ChangeLog!");
+ system($command) == 0 or &abort("Could not create $changelogfile!");
}
}
#
-# Add the latest manual from the mysqldoc tree
+# Add the latest manual and tool from the mysqldoc tree
#
unless ($opt_skip_manual)
{
@@ -283,6 +295,8 @@ unless ($opt_skip_manual)
system ("bk cat $opt_docdir/Docs/$file.texi > $target_dir/Docs/$file.texi") == 0
or &abort("Could not update $file.texi in $target_dir/Docs/!");
}
+ &run_command("cp $opt_docdir/Docs/Support/texi2html $target_dir/Docs/Support",
+ "Could not copy $opt_docdir/Docs/Support/texi2html!");
&run_command("rm -f $target_dir/Docs/Images/Makefile*",
"Could not remove Makefiles in $target_dir/Docs/Images/!");
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 2dd7f3d4826..97ca0df87c0 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -10,8 +10,8 @@ use Sys::Hostname;
$opt_comment=$opt_distribution=$opt_user=$opt_config_env=$opt_config_extra_env="";
$opt_dbd_options=$opt_perl_options=$opt_config_options=$opt_make_options=$opt_suffix="";
$opt_tmp=$opt_version_suffix="";
-$opt_bundled_zlib=$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_one_error=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_archive=$opt_with_cluster=$opt_with_csv=$opt_with_example=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=$opt_without_embedded=$opt_readline=0;
-$opt_skip_embedded_test=$opt_skip_ps_test=$opt_innodb=$opt_bdb=$opt_raid=$opt_libwrap=$opt_clearlogs=$opt_with_federated=0;
+$opt_bundled_zlib=$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_one_error=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_archive=$opt_with_cluster=$opt_with_csv=$opt_with_example=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=$opt_without_embedded=$opt_readline=$opt_with_blackhole=0;
+$opt_skip_embedded_test=$opt_skip_ps_test=$opt_innodb=$opt_bdb=$opt_raid=$opt_libwrap=$opt_clearlogs=$opt_with_federated=$opt_with_big_tables=0;
$global_step="";
GetOptions(
@@ -58,11 +58,13 @@ GetOptions(
"user=s",
"version-suffix=s",
"with-archive",
+ "with-big-tables",
+ "with-blackhole",
"with-cluster",
"with-csv",
"with-debug",
"with-example",
- "with-federated",
+ "with-federated",
"with-low-memory",
"with-other-libc=s",
"with-small-disk",
@@ -275,6 +277,7 @@ if ($opt_stage <= 1)
$opt_config_options.= " --without-ndb-debug" if ($opt_with_debug && $opt_with_cluster);
$opt_config_options.= " --with-libwrap" if ($opt_libwrap);
$opt_config_options.= " --with-low-memory" if ($opt_with_low_memory);
+ $opt_config_options.= " --with-big-tables" if ($opt_with_big_tables);
$opt_config_options.= " --with-mysqld-ldflags=-all-static" if ($opt_static_server);
$opt_config_options.= " --with-raid" if ($opt_raid);
if ($opt_readline)
@@ -288,6 +291,7 @@ if ($opt_stage <= 1)
$opt_config_options.= " --with-embedded-server" unless ($opt_without_embedded);
$opt_skip_embedded_test= 1 if ($opt_without_embedded);
$opt_config_options.= " --with-archive-storage-engine" if ($opt_with_archive);
+ $opt_config_options.= " --with-blackhole-storage-engine" if ($opt_with_blackhole);
$opt_config_options.= " --with-ndbcluster" if ($opt_with_cluster);
$opt_config_options.= " --with-csv-storage-engine" if ($opt_with_csv);
$opt_config_options.= " --with-example-storage-engine" if ($opt_with_example);
diff --git a/Docs/mysqld_error.txt b/Docs/mysqld_error.txt
index 6370d8aac46..7f5560a5914 100644
--- a/Docs/mysqld_error.txt
+++ b/Docs/mysqld_error.txt
@@ -595,3 +595,5 @@ character-set=latin1
"Invalid ON UPDATE clause for '%-.64s' field",
#define ER_UNSUPPORTED_PS 1295
"This command is not supported in the prepared statement protocol yet",
+#define ER_CANT_CREATE_USER_WITH_GRANT 1296
+"You are not allowed to create a user with GRANT"
diff --git a/VC++Files/libmysqld/examples/test_libmysqld.dsp b/VC++Files/libmysqld/examples/test_libmysqld.dsp
index 6707b8cd8ee..013bc41409d 100644
--- a/VC++Files/libmysqld/examples/test_libmysqld.dsp
+++ b/VC++Files/libmysqld/examples/test_libmysqld.dsp
@@ -47,7 +47,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=xilink6.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 Wsock32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMTD" /out:"Release/mysql-server.exe"
+# 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 Wsock32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMTD" /out:"..\test_libmysqld.exe"
# Begin Target
# Name "test_libmysqld - Win32 Release"
@@ -71,9 +71,5 @@ SOURCE=..\..\client\readline.cpp
SOURCE=..\..\client\sql_string.cpp
# End Source File
# End Group
-# Begin Source File
-
-SOURCE=..\..\lib_release\libmysqld.lib
-# End Source File
# End Target
# End Project
diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw
index 43cfab4b915..73db9d095cb 100644
--- a/VC++Files/mysql.dsw
+++ b/VC++Files/mysql.dsw
@@ -3,21 +3,6 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
###############################################################################
-Project: "MySqlManager"=".\mysqlmanager\MySqlManager.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name mysqlclient
- End Project Dependency
-}}}
-
-###############################################################################
-
Project: "bdb"=".\bdb\bdb.dsp" - Package Owner=<4>
Package=<5>
@@ -420,9 +405,6 @@ Package=<4>
Project_Dep_Name mysqlimport
End Project Dependency
Begin Project Dependency
- Project_Dep_Name MySqlManager
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name mysqlshow
End Project Dependency
Begin Project Dependency
diff --git a/VC++Files/mysql_ia64.dsw b/VC++Files/mysql_ia64.dsw
index 8af4a7e5c42..dd86d498afe 100644
--- a/VC++Files/mysql_ia64.dsw
+++ b/VC++Files/mysql_ia64.dsw
@@ -508,9 +508,6 @@ Package=<4>
Project_Dep_Name mysqlimport
End Project Dependency
Begin Project Dependency
- Project_Dep_Name MySqlManager
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name mysqlshow
End Project Dependency
Begin Project Dependency
diff --git a/VC++Files/mysqlmanager/MySqlManager_ia64.dsp b/VC++Files/mysqlmanager/MySqlManager_ia64.dsp
deleted file mode 100644
index b0ffc9e48c6..00000000000
--- a/VC++Files/mysqlmanager/MySqlManager_ia64.dsp
+++ /dev/null
@@ -1,276 +0,0 @@
-# Microsoft Developer Studio Project File - Name="MySqlManager" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=MYSQLMANAGER - WinIA64 DEBUG
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "MySqlManager.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "MySqlManager.mak" CFG="MYSQLMANAGER - WinIA64 DEBUG"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "MySqlManager - WinIA64 Release" (based on "Win32 (x86) Application")
-!MESSAGE "MySqlManager - WinIA64 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "MySqlManager - WinIA64 Release"
-
-# PROP BASE Use_MFC 6
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 6
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "release"
-# PROP Intermediate_Dir "release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN64" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MT /W3 /Zi /O2 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
-# SUBTRACT CPP /WX /Fr /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win64
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win64
-# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
-# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:IA64
-# ADD LINK32 /nologo /subsystem:windows /out:"../client_release/MySqlManager.exe" /machine:IA64
-# SUBTRACT LINK32 /nodefaultlib
-
-!ELSEIF "$(CFG)" == "MySqlManager - WinIA64 Debug"
-
-# PROP BASE Use_MFC 6
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 6
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "debug"
-# PROP Intermediate_Dir "debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN64" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MTd /W3 /GR /Zi /Od /I "../include" /D "_DEBUG" /D "_WINDOWS" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
-# SUBTRACT CPP /Fr /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win64
-# ADD MTL /nologo /D "_DEBUG" /o "NUL" /win64
-# SUBTRACT MTL /mktyplib203
-# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:IA64
-# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:no /debug /out:"../client_debug/MySqlManager.exe" /libpath:"..\lib_debug\\" /machine:IA64
-
-!ENDIF
-
-# Begin Target
-
-# Name "MySqlManager - WinIA64 Release"
-# Name "MySqlManager - WinIA64 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\ChildFrm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE="..\strings\ctype-extra.c"
-# End Source File
-# Begin Source File
-
-SOURCE="..\strings\ctype-latin1.c"
-# End Source File
-# Begin Source File
-
-SOURCE="..\strings\ctype-mb.c"
-# End Source File
-# Begin Source File
-
-SOURCE=..\strings\is_prefix.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\MainFrm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\mysys\my_sleep.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\strings\my_vsnprintf.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManager.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManager.rc
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManagerDoc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManagerView.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegisterServer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.cpp
-# ADD CPP /Yc"stdafx.h"
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSql.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSqlQuery.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSqlResults.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSqlStatus.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\ChildFrm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MainFrm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManager.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManagerDoc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MySqlManagerView.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\RegisterServer.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSqlQuery.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSqlResults.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ToolSqlStatus.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\res\bitmap1.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\bitmap3.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\bmp00001.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\bmp00002.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\database.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\fontd.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\fontu.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\MySqlManager.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\MySqlManager.rc2
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\MySqlManagerDoc.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\query_ex.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\Toolbar.bmp
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\ReadMe.txt
-# End Source File
-# End Target
-# End Project
diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp
index 0a48b93b9ef..64c4378b678 100644
--- a/VC++Files/mysys/mysys.dsp
+++ b/VC++Files/mysys/mysys.dsp
@@ -536,6 +536,10 @@ SOURCE=.\my_wincond.c
# End Source File
# Begin Source File
+SOURCE=.\my_windac.c
+# End Source File
+# Begin Source File
+
SOURCE=.\my_winsem.c
# End Source File
# Begin Source File
diff --git a/bdb/btree/bt_open.c b/bdb/btree/bt_open.c
index 0b72391c267..24da41e9893 100644
--- a/bdb/btree/bt_open.c
+++ b/bdb/btree/bt_open.c
@@ -489,7 +489,7 @@ __bam_new_file(dbp, txn, fhp, name)
goto err;
} else {
#ifdef DIAGNOSTIC
- memset(buf, dbp->pgsize, 0);
+ memset(buf, 0, dbp->pgsize);
#endif
root = (PAGE *)buf;
}
diff --git a/bdb/hash/hash_open.c b/bdb/hash/hash_open.c
index 041a1df1e7b..f976f5b6816 100644
--- a/bdb/hash/hash_open.c
+++ b/bdb/hash/hash_open.c
@@ -409,7 +409,7 @@ __ham_new_file(dbp, txn, fhp, name)
goto err;
} else {
#ifdef DIAGNOSTIC
- memset(buf, dbp->pgsize, 0);
+ memset(buf, 0, dbp->pgsize);
#endif
page = (PAGE *)buf;
}
diff --git a/client/mysql.cc b/client/mysql.cc
index a1071daffea..8d5117a29e0 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -3090,9 +3090,14 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
#ifdef OS2
fflush( file);
#endif
+ va_end(args);
+
if (opt_outfile)
+ {
+ va_start(args, fmt);
(void) vfprintf(OUTFILE, fmt, args);
- va_end(args);
+ va_end(args);
+ }
}
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index c296447def9..59c90f59e8e 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -33,9 +33,9 @@
#undef MYSQL_SERVER
#include "client_priv.h"
#include <my_time.h>
-#include "log_event.h"
/* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */
#include "mysql_priv.h"
+#include "log_event.h"
#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 46337c99732..2017f923c2f 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1093,7 +1093,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
number of fields in table, 0 if error
*/
-static uint getTableStructure(char *table, char* db)
+static uint getTableStructure(char *table, char *db)
{
MYSQL_RES *tableRes;
MYSQL_ROW row;
@@ -1396,10 +1396,9 @@ static uint getTableStructure(char *table, char* db)
/* Get MySQL specific create options */
if (create_options)
{
- char show_name_buff[FN_REFLEN];
+ char show_name_buff[NAME_LEN*2+2+24];
/* Check memory for quote_for_like() */
- DBUG_ASSERT(2*sizeof(table) < sizeof(show_name_buff));
my_snprintf(buff, sizeof(buff), "show table status like %s",
quote_for_like(table, show_name_buff));
@@ -2219,13 +2218,14 @@ static my_bool dump_all_views_in_db(char *database)
different case (e.g. T1 vs t1)
RETURN
- void
+ int - 0 if a tablename was retrieved. 1 if not
*/
-static void get_actual_table_name(const char *old_table_name,
+static int get_actual_table_name(const char *old_table_name,
char *new_table_name,
int buf_size)
{
+ int retval;
MYSQL_RES *tableRes;
MYSQL_ROW row;
char query[50 + 2*NAME_LEN];
@@ -2243,9 +2243,19 @@ static void get_actual_table_name(const char *old_table_name,
}
tableRes= mysql_store_result( sock );
- row= mysql_fetch_row( tableRes );
- strmake(new_table_name, row[0], buf_size-1);
- mysql_free_result(tableRes);
+ retval = 1;
+ if (tableRes != NULL)
+ {
+ my_ulonglong numRows = mysql_num_rows(tableRes);
+ if (numRows > 0)
+ {
+ row= mysql_fetch_row( tableRes );
+ strmake(new_table_name, row[0], buf_size-1);
+ retval = 0;
+ }
+ mysql_free_result(tableRes);
+ }
+ return retval;
}
@@ -2285,11 +2295,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
char new_table_name[NAME_LEN];
/* the table name passed on commandline may be wrong case */
- get_actual_table_name( table_names[i], new_table_name, sizeof(new_table_name) );
+ if (!get_actual_table_name( table_names[i], new_table_name, sizeof(new_table_name) ))
+ {
- numrows = getTableStructure(new_table_name, db);
+ numrows = getTableStructure(new_table_name, db);
- dumpTable(numrows, new_table_name);
+ dumpTable(numrows, new_table_name);
+ }
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
order_by= 0;
}
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 8171cb95268..eee96a9c3eb 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -28,7 +28,8 @@
#include <sslopt-vars.h>
static my_string host=0,opt_password=0,user=0;
-static my_bool opt_show_keys=0,opt_compress=0,opt_status=0, tty_password=0;
+static my_bool opt_show_keys= 0, opt_compress= 0, opt_status= 0,
+ tty_password= 0, opt_table_type= 0;
static uint opt_verbose=0;
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
@@ -193,6 +194,9 @@ static struct my_option my_long_options[] =
"Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"show-table-type", 't', "Show table type column.",
+ (gptr*) &opt_table_type, (gptr*) &opt_table_type, 0, GET_BOOL,
+ NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -418,7 +422,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
{
const char *header;
uint head_length, counter = 0;
- char query[255], rows[64], fields[16];
+ char query[255], rows[NAME_LEN], fields[16];
MYSQL_FIELD *field;
MYSQL_RES *result;
MYSQL_ROW row, rrow;
@@ -429,7 +433,20 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
mysql_error(mysql));
return 1;
}
- if (!(result=mysql_list_tables(mysql,table)))
+ if (table)
+ {
+ /*
+ We just hijack the 'rows' variable for a bit to store the escaped
+ table name
+ */
+ mysql_escape_string(rows, table, sizeof(rows));
+ my_snprintf(query, sizeof(query), "show%s tables like '%s'",
+ opt_table_type ? " full" : "", rows);
+ }
+ else
+ my_snprintf(query, sizeof(query), "show%s tables",
+ opt_table_type ? " full" : "");
+ if (mysql_query(mysql, query) || !(result= mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot list tables in %s: %s\n",my_progname,db,
mysql_error(mysql));
@@ -446,12 +463,27 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
if (head_length < field->max_length)
head_length=field->max_length;
- if (!opt_verbose)
- print_header(header,head_length,NullS);
- else if (opt_verbose == 1)
- print_header(header,head_length,"Columns",8,NullS);
+ if (opt_table_type)
+ {
+ if (!opt_verbose)
+ print_header(header,head_length,"table_type",10,NullS);
+ else if (opt_verbose == 1)
+ print_header(header,head_length,"table_type",10,"Columns",8,NullS);
+ else
+ {
+ print_header(header,head_length,"table_type",10,"Columns",8,
+ "Total Rows",10,NullS);
+ }
+ }
else
- print_header(header,head_length,"Columns",8, "Total Rows",10,NullS);
+ {
+ if (!opt_verbose)
+ print_header(header,head_length,NullS);
+ else if (opt_verbose == 1)
+ print_header(header,head_length,"Columns",8,NullS);
+ else
+ print_header(header,head_length,"Columns",8, "Total Rows",10,NullS);
+ }
while ((row = mysql_fetch_row(result)))
{
@@ -500,17 +532,31 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
strmov(rows,"N/A");
}
}
- if (!opt_verbose)
- print_row(row[0],head_length,NullS);
- else if (opt_verbose == 1)
- print_row(row[0],head_length, fields,8, NullS);
- else
- print_row(row[0],head_length, fields,8, rows,10, NullS);
+ if (opt_table_type)
+ {
+ if (!opt_verbose)
+ print_row(row[0],head_length,row[1],10,NullS);
+ else if (opt_verbose == 1)
+ print_row(row[0],head_length,row[1],10,fields,8,NullS);
+ else
+ print_row(row[0],head_length,row[1],10,fields,8,rows,10,NullS);
+ }
+ else
+ {
+ if (!opt_verbose)
+ print_row(row[0],head_length,NullS);
+ else if (opt_verbose == 1)
+ print_row(row[0],head_length, fields,8, NullS);
+ else
+ print_row(row[0],head_length, fields,8, rows,10, NullS);
+ }
}
print_trailer(head_length,
- (opt_verbose > 0 ? 8 : 0),
- (opt_verbose > 1 ? 10 :0),
+ (opt_table_type ? 10 : opt_verbose > 0 ? 8 : 0),
+ (opt_table_type ? (opt_verbose > 0 ? 8 : 0)
+ : (opt_verbose > 1 ? 10 :0)),
+ !opt_table_type ? 0 : opt_verbose > 1 ? 10 :0,
0);
if (counter && opt_verbose)
diff --git a/client/mysqltest.c b/client/mysqltest.c
index f6f6f469e8c..4000f494c63 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2746,8 +2746,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
append_result(ds, res);
}
- /* Add all warnings to the result */
- if (!disable_warnings && mysql_warning_count(mysql))
+ /*
+ Add all warnings to the result. We can't do this if we are in
+ the middle of processing results from multi-statement, because
+ this will break protocol.
+ */
+ if (!disable_warnings && !mysql_more_results(mysql) &&
+ mysql_warning_count(mysql))
{
MYSQL_RES *warn_res=0;
uint count= mysql_warning_count(mysql);
@@ -3306,7 +3311,7 @@ static void run_query_display_metadata(MYSQL_FIELD *field, uint num_fields,
{
MYSQL_FIELD *field_end;
dynstr_append(ds,"Catalog\tDatabase\tTable\tTable_alias\tColumn\t"
- "Column_alias\tName\tType\tLength\tMax length\tIs_null\t"
+ "Column_alias\tType\tLength\tMax length\tIs_null\t"
"Flags\tDecimals\tCharsetnr\n");
for (field_end= field+num_fields ;
@@ -3363,6 +3368,13 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds)
if (!disable_warnings && (count= mysql_warning_count(mysql)))
{
+ /*
+ If one day we will support execution of multi-statements
+ through PS API we should not issue SHOW WARNINGS until
+ we have not read all results...
+ */
+ DBUG_ASSERT(!mysql_more_results(mysql));
+
if (mysql_real_query(mysql, "SHOW WARNINGS", 13) == 0)
{
MYSQL_RES *warn_res= mysql_store_result(mysql);
diff --git a/config/ac-macros/ha_blackhole.m4 b/config/ac-macros/ha_blackhole.m4
new file mode 100644
index 00000000000..cc4d360f5a8
--- /dev/null
+++ b/config/ac-macros/ha_blackhole.m4
@@ -0,0 +1,29 @@
+dnl ---------------------------------------------------------------------------
+dnl Macro: MYSQL_CHECK_BLACKHOLEDB
+dnl Sets HAVE_BLACKHOLE_DB if --with-blackhole-storage-engine is used
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MYSQL_CHECK_BLACKHOLEDB], [
+ AC_ARG_WITH([blackhole-storage-engine],
+ [
+ --with-blackhole-storage-engine
+ Enable the Blackhole Storage Engine],
+ [blackholedb="$withval"],
+ [blackholedb=no])
+ AC_MSG_CHECKING([for blackhole storage engine])
+
+ case "$blackholedb" in
+ yes )
+ AC_DEFINE([HAVE_BLACKHOLE_DB], [1], [Builds Blackhole Storage Engine])
+ AC_MSG_RESULT([yes])
+ [blackholedb=yes]
+ ;;
+ * )
+ AC_MSG_RESULT([no])
+ [blackholedb=no]
+ ;;
+ esac
+
+])
+dnl ---------------------------------------------------------------------------
+dnl END OF MYSQL_CHECK_BLACKHOLE SECTION
+dnl ---------------------------------------------------------------------------
diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4
index 556cc7625cc..186a069ac61 100644
--- a/config/ac-macros/misc.m4
+++ b/config/ac-macros/misc.m4
@@ -636,3 +636,31 @@ fi
dnl ---------------------------------------------------------------------------
+
+dnl ---------------------------------------------------------------------------
+dnl Macro: MYSQL_CHECK_BIG_TABLES
+dnl Sets BIG_TABLES if --with-big-tables is used
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MYSQL_CHECK_BIG_TABLES], [
+ AC_ARG_WITH([big-tables],
+ [
+ --with-big-tables Support tables with more than 4 G rows even on 32 bit platforms],
+ [bigtables="$withval"],
+ [bigtables=no])
+ AC_MSG_CHECKING([for big tables support])
+
+ case "$bigtables" in
+ yes )
+ AC_DEFINE([BIG_TABLES], [1], [Support big tables])
+ AC_MSG_RESULT([yes])
+ ;;
+ * )
+ AC_MSG_RESULT([no])
+ ;;
+ esac
+
+])
+dnl ---------------------------------------------------------------------------
+dnl END OF MYSQL_CHECK_BIG_TABLES SECTION
+dnl ---------------------------------------------------------------------------
+
diff --git a/configure.in b/configure.in
index 538379985be..11bd87651da 100644
--- a/configure.in
+++ b/configure.in
@@ -19,7 +19,6 @@ SHARED_LIB_VERSION=14:0:0
NDB_VERSION_MAJOR=5
NDB_VERSION_MINOR=1
NDB_VERSION_BUILD=0
-NDB_VERSION_STATUS="alpha"
# Set all version vars based on $VERSION. How do we do this more elegant ?
# Remember that regexps needs to quote [ and ] since this is run through m4
@@ -38,6 +37,7 @@ sinclude(config/ac-macros/character_sets.m4)
sinclude(config/ac-macros/compiler_flag.m4)
sinclude(config/ac-macros/ha_archive.m4)
sinclude(config/ac-macros/ha_berkeley.m4)
+sinclude(config/ac-macros/ha_blackhole.m4)
sinclude(config/ac-macros/ha_example.m4)
sinclude(config/ac-macros/ha_federated.m4)
sinclude(config/ac-macros/ha_innodb.m4)
@@ -353,7 +353,8 @@ then
then
if $CXX -v 2>&1 | grep 'version 3' > /dev/null 2>&1
then
- CXXFLAGS="$CXXFLAGS -DUSE_MYSYS_NEW -DDEFINE_CXA_PURE_VIRTUAL"
+ # Statically link the language support function's found in libsupc++.a
+ LIBS="$LIBS -lsupc++"
fi
fi
fi
@@ -2373,11 +2374,13 @@ AC_SUBST(readline_basedir)
AC_SUBST(readline_link)
AC_SUBST(readline_h_ln_cmd)
+MYSQL_CHECK_BIG_TABLES
MYSQL_CHECK_BDB
MYSQL_CHECK_INNODB
MYSQL_CHECK_EXAMPLEDB
MYSQL_CHECK_ARCHIVEDB
MYSQL_CHECK_CSVDB
+MYSQL_CHECK_BLACKHOLEDB
MYSQL_CHECK_NDBCLUSTER
MYSQL_CHECK_FEDERATED
diff --git a/include/config-netware.h b/include/config-netware.h
index e84fd6ae472..4a6dc3b1bb9 100644
--- a/include/config-netware.h
+++ b/include/config-netware.h
@@ -80,6 +80,9 @@ extern "C" {
/* On NetWare, stack grows towards lower address*/
#define STACK_DIRECTION -1
+/* On NetWare, to fix the problem with the deletion of open files */
+#define CANT_DELETE_OPEN_FILES 1
+
/* default directory information */
#define DEFAULT_MYSQL_HOME "sys:/mysql"
#define PACKAGE "mysql"
diff --git a/include/decimal.h b/include/decimal.h
index 3f4a2122c57..7b49841ca88 100644
--- a/include/decimal.h
+++ b/include/decimal.h
@@ -20,47 +20,50 @@
typedef enum
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
decimal_round_mode;
-typedef int32 decimal_digit;
+typedef int32 decimal_digit_t;
-typedef struct st_decimal {
+typedef struct st_decimal_t {
int intg, frac, len;
my_bool sign;
- decimal_digit *buf;
-} decimal;
+ decimal_digit_t *buf;
+} decimal_t;
-int internal_str2dec(const char *from, decimal *to, char **end, my_bool fixed);
-int decimal2string(decimal *from, char *to, int *to_len,
+int internal_str2dec(const char *from, decimal_t *to, char **end,
+ my_bool fixed);
+int decimal2string(decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler);
-int decimal2ulonglong(decimal *from, ulonglong *to);
-int ulonglong2decimal(ulonglong from, decimal *to);
-int decimal2longlong(decimal *from, longlong *to);
-int longlong2decimal(longlong from, decimal *to);
-int decimal2double(decimal *from, double *to);
-int double2decimal(double from, decimal *to);
-void decimal_optimize_fraction(decimal *from);
-int decimal2bin(decimal *from, char *to, int precision, int scale);
-int bin2decimal(char *from, decimal *to, int precision, int scale);
+int decimal2ulonglong(decimal_t *from, ulonglong *to);
+int ulonglong2decimal(ulonglong from, decimal_t *to);
+int decimal2longlong(decimal_t *from, longlong *to);
+int longlong2decimal(longlong from, decimal_t *to);
+int decimal2double(decimal_t *from, double *to);
+int double2decimal(double from, decimal_t *to);
+void decimal_optimize_fraction(decimal_t *from);
+int decimal2bin(decimal_t *from, char *to, int precision, int scale);
+int bin2decimal(char *from, decimal_t *to, int precision, int scale);
int decimal_size(int precision, int scale);
int decimal_bin_size(int precision, int scale);
-int decimal_result_size(decimal *from1, decimal *from2, char op, int param);
-
-int decimal_add(decimal *from1, decimal *from2, decimal *to);
-int decimal_sub(decimal *from1, decimal *from2, decimal *to);
-int decimal_cmp(decimal *from1, decimal *from2);
-int decimal_mul(decimal *from1, decimal *from2, decimal *to);
-int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr);
-int decimal_mod(decimal *from1, decimal *from2, decimal *to);
-int decimal_round(decimal *from, decimal *to, int new_scale,
+int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
+ int param);
+
+int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_cmp(decimal_t *from1, decimal_t *from2);
+int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to,
+ int scale_incr);
+int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_round(decimal_t *from, decimal_t *to, int new_scale,
decimal_round_mode mode);
-int decimal_is_zero(decimal *from);
-void max_decimal(int precision, int frac, decimal *to);
+int decimal_is_zero(decimal_t *from);
+void max_decimal(int precision, int frac, decimal_t *to);
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
#define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1)
-/* set a decimal to zero */
+/* set a decimal_t to zero */
#define decimal_make_zero(dec) do { \
(dec)->buf[0]=0; \
diff --git a/include/my_global.h b/include/my_global.h
index 2601c53bb92..7ec04377864 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -121,19 +121,36 @@
#endif
/*
- Solaris include file <sys/feature_tests.h> refers to X/Open document
+ Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
System Interfaces and Headers, Issue 5
- saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes
+ saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
but apparently other systems (namely FreeBSD) don't agree.
- Furthermore X/Open has since 2004 "System Interfaces, Issue 6"
- that dictates _XOPEN_SOURCE=600, but Solaris checks for 500.
- So, let's define 500 for solaris only.
+
+ On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
+ Furthermore, it tests that if a program requires older standard
+ (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
+ run on a new compiler (that defines _STDC_C99) and issues an #error.
+ It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
+ or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
+
+ To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
+ C++ compiler does not!
+
+ So, in a desperate attempt to get correct prototypes for both
+ C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
+ depending on the compiler's announced C standard support.
+
+ Cleaner solutions are welcome.
*/
#ifdef __sun
+#if __STDC_VERSION__ - 0 >= 199901L
+#define _XOPEN_SOURCE 600
+#else
#define _XOPEN_SOURCE 500
#endif
+#endif
#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
#ifndef _POSIX_PTHREAD_SEMANTICS
diff --git a/include/my_sys.h b/include/my_sys.h
index afd2803b75d..523c0570de7 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -845,7 +845,8 @@ extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(CHARSET_INFO *cs);
-extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
+extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
+ char *to, ulong to_length,
const char *from, ulong length);
extern void thd_increment_bytes_sent(ulong length);
@@ -854,6 +855,14 @@ extern void thd_increment_net_big_packet_count(ulong length);
#ifdef __WIN__
extern my_bool have_tcpip; /* Is set if tcpip is used */
+
+/* implemented in my_windac.c */
+
+int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
+ DWORD owner_rights, DWORD everybody_rights);
+
+void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
+
#endif
#ifdef __NETWARE__
void netware_reg_user(const char *ip, const char *user,
diff --git a/include/violite.h b/include/violite.h
index a62fe37f45d..97784694e79 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -144,8 +144,8 @@ int vio_close_shared_memory(Vio * vio);
#if !defined(DONT_MAP_VIO)
#define vio_delete(vio) (vio)->viodelete(vio)
#define vio_errno(vio) (vio)->vioerrno(vio)
-#define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
-#define vio_write(vio, buf, size) (vio)->write(vio, buf, size)
+#define vio_read(vio, buf, size) ((vio)->read)(vio,buf,size)
+#define vio_write(vio, buf, size) ((vio)->write)(vio, buf, size)
#define vio_blocking(vio, set_blocking_mode, old_mode)\
(vio)->vioblocking(vio, set_blocking_mode, old_mode)
#define vio_is_blocking(vio) (vio)->is_blocking(vio)
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index 9db69261468..d46613c3a68 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -381,6 +381,12 @@ struct trx_struct{
in MySQL's binlog write, we will
flush the log to disk later in
a separate call */
+ ibool must_flush_log_later;/* this flag is set to TRUE in
+ trx_commit_off_kernel() if
+ flush_log_later was TRUE, and there
+ were modifications by the transaction;
+ in that case we must flush the log
+ in trx_commit_complete_for_mysql() */
dulint commit_lsn; /* lsn at the time of the commit */
ibool dict_operation; /* TRUE if the trx is used to create
a table, create an index, or drop a
@@ -390,8 +396,9 @@ struct trx_struct{
dulint table_id; /* table id if the preceding field is
TRUE */
/*------------------------------*/
- int active_trans; /* whether a transaction in MySQL
- is active */
+ int active_trans; /* 1 - if a transaction in MySQL
+ is active. 2 - if prepare_commit_mutex
+ was taken */
void* mysql_thd; /* MySQL thread handle corresponding
to this trx, or NULL */
char** mysql_query_str;/* pointer to the field in mysqld_thd
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 643f7e164e5..cdda1dd4dee 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -99,6 +99,7 @@ trx_create(
trx->check_unique_secondary = TRUE;
trx->flush_log_later = FALSE;
+ trx->must_flush_log_later = FALSE;
trx->dict_operation = FALSE;
@@ -710,6 +711,8 @@ trx_commit_off_kernel(
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
+ trx->must_flush_log_later = FALSE;
+
rseg = trx->rseg;
if (trx->insert_undo != NULL || trx->update_undo != NULL) {
@@ -875,6 +878,7 @@ trx_commit_off_kernel(
if (trx->flush_log_later) {
/* Do nothing yet */
+ trx->must_flush_log_later = TRUE;
} else if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
} else if (srv_flush_log_at_trx_commit == 1) {
@@ -1594,7 +1598,9 @@ trx_commit_complete_for_mysql(
trx->op_info = "flushing log";
- if (srv_flush_log_at_trx_commit == 0) {
+ if (!trx->must_flush_log_later) {
+ /* Do nothing */
+ } else if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
} else if (srv_flush_log_at_trx_commit == 1) {
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
@@ -1615,6 +1621,8 @@ trx_commit_complete_for_mysql(
} else {
ut_error;
}
+
+ trx->must_flush_log_later = FALSE;
trx->op_info = "";
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 50dedebe119..204c833dd21 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -96,7 +96,8 @@ clean-local:
`echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \
$(CHARSET_SRCS) $(CHARSET_OBJS) \
$(mystringsextra) $(mysysheaders) $(vioheaders)\
- ../linked_client_sources net.c
+ ../linked_libmysql_sources ../linked_libmysql_r_sources \
+ net.c
conf_to_src_SOURCES = conf_to_src.c
conf_to_src_LDADD=
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 9746cb222fa..f09b09314d0 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1575,14 +1575,14 @@ mysql_hex_string(char *to, const char *from, ulong length)
ulong STDCALL
mysql_escape_string(char *to,const char *from,ulong length)
{
- return escape_string_for_mysql(default_charset_info, to, from, length);
+ return escape_string_for_mysql(default_charset_info, to, 0, from, length);
}
ulong STDCALL
mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
ulong length)
{
- return escape_string_for_mysql(mysql->charset, to, from, length);
+ return escape_string_for_mysql(mysql->charset, to, 0, from, length);
}
@@ -2862,6 +2862,17 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
mysql->status= MYSQL_STATUS_READY;
stmt->read_row_func= stmt_read_row_from_cursor;
}
+ else if (stmt->flags & CURSOR_TYPE_READ_ONLY)
+ {
+ /*
+ This is a single-row result set, a result set with no rows, EXPLAIN,
+ SHOW VARIABLES, or some other command which either a) bypasses the
+ cursors framework in the server and writes rows directly to the
+ network or b) is more efficient if all (few) result set rows are
+ precached on client and server's resources are freed.
+ */
+ DBUG_RETURN(mysql_stmt_store_result(stmt));
+ }
else
{
stmt->mysql->unbuffered_fetch_owner= &stmt->unbuffered_fetch_cancelled;
@@ -3608,7 +3619,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
if (is_unsigned)
data= ulonglong2double(value);
else
- data= value;
+ data= (double)value;
doublestore(buffer, data);
*param->error= is_unsigned ?
((ulonglong) value) != ((ulonglong) (*(double*) buffer)) :
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index c5579e9ec2b..5d88497e561 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -146,4 +146,6 @@ EXPORTS
mysql_rpl_query_type
mysql_slave_query
mysql_embedded
+ mysql_server_init
+ mysql_server_end
get_defaults_files
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index c77d9459ff3..ab52e8245a2 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -62,7 +62,8 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \
spatial.cc gstream.cc sql_help.cc tztime.cc protocol_cursor.cc \
sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
- parse_file.cc rpl_filter.cc sql_view.cc sql_trigger.cc my_decimal.cc
+ parse_file.cc rpl_filter.cc sql_view.cc sql_trigger.cc my_decimal.cc \
+ ha_blackhole.cc
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
libmysqld_a_SOURCES=
diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def
index ea3133594f5..0612141a60d 100644
--- a/libmysqld/libmysqld.def
+++ b/libmysqld/libmysqld.def
@@ -1,6 +1,6 @@
LIBRARY LIBMYSQLD
-DESCRIPTION 'MySQL 4.1 Embedded Server Library'
-VERSION 4.1
+DESCRIPTION 'MySQL 5.0 Embedded Server Library'
+VERSION 5.0
EXPORTS
_dig_vec_upper
_dig_vec_lower
@@ -158,3 +158,5 @@ EXPORTS
mysql_stmt_attr_set
mysql_stmt_field_count
get_defaults_files
+ my_charset_bin
+ my_charset_same
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 504bc33ecc1..d65a46a92fb 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -1090,10 +1090,10 @@ char *mi_keyseg_read(char *ptr, HA_KEYSEG *keyseg)
keyseg->null_pos = mi_uint4korr(ptr); ptr +=4;
keyseg->charset=0; /* Will be filled in later */
if (keyseg->null_bit)
- keyseg->bit_pos= keyseg->null_pos + (keyseg->null_bit == 7);
+ keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7));
else
{
- keyseg->bit_pos= keyseg->null_pos;
+ keyseg->bit_pos= (uint16)keyseg->null_pos;
keyseg->null_pos= 0;
}
return ptr;
diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c
index cc62614cb07..4b512dd89dd 100644
--- a/myisam/mi_packrec.c
+++ b/myisam/mi_packrec.c
@@ -1212,7 +1212,7 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_RETURN(0);
}
file_map=(byte*)
- my_mmap(0,share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN,PROT_READ,
+ my_mmap(0,(size_t)(share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN),PROT_READ,
MAP_SHARED | MAP_NORESERVE,info->dfile,0L);
if (file_map == (byte*) MAP_FAILED)
{
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index 09e2914bbaa..519e123e9da 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -427,8 +427,8 @@ static void usage(void)
can't fix the data file.\n\
--character-sets-dir=...\n\
Directory where character sets are.\n\
- --set-character-set=name\n\
- Change the character set used by the index.\n\
+ --set-collation=name\n\
+ Change the collation used by the index.\n\
-q, --quick Faster repair by not modifying the data file.\n\
One can give a second '-q' to force myisamchk to\n\
modify the original datafile in case of duplicate keys.\n\
diff --git a/mysql-test/README b/mysql-test/README
index bccb05c555c..65e6186613a 100644
--- a/mysql-test/README
+++ b/mysql-test/README
@@ -17,7 +17,7 @@ http://dev.mysql.com/doc/mysql/en/MySQL_test_suite.html
You can create your own test cases. To create a test case:
- xeamacs t/test_case_name.test
+ xemacs t/test_case_name.test
in the file, put a set of SQL commands that will create some tables,
load test data, run some queries to manipulate it.
diff --git a/mysql-test/include/have_blackhole.inc b/mysql-test/include/have_blackhole.inc
new file mode 100644
index 00000000000..c2b6ea18830
--- /dev/null
+++ b/mysql-test/include/have_blackhole.inc
@@ -0,0 +1,4 @@
+-- require r/have_blackhole.require
+disable_query_log;
+show variables like "have_blackhole_engine";
+enable_query_log;
diff --git a/mysql-test/include/ps_query.inc b/mysql-test/include/ps_query.inc
index e6f19c67138..9a413bff2f3 100644
--- a/mysql-test/include/ps_query.inc
+++ b/mysql-test/include/ps_query.inc
@@ -421,6 +421,11 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
b=? and a = (select ? from t1 where b = ? ) ' ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
+# Bug#8807
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+
######## correlated subquery
# no parameter
prepare stmt1 from ' select a, b FROM t1 outer_table where
diff --git a/mysql-test/lib/init_db.sql b/mysql-test/lib/init_db.sql
index 902af0b0842..97fa6fb955c 100644
--- a/mysql-test/lib/init_db.sql
+++ b/mysql-test/lib/init_db.sql
@@ -16,6 +16,11 @@ CREATE TABLE db (
Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
PRIMARY KEY Host (Host,Db,User),
KEY User (User)
) engine=MyISAM
@@ -23,8 +28,8 @@ CHARACTER SET utf8 COLLATE utf8_bin
comment='Database privileges';
-INSERT INTO db VALUES ('%','test' ,'','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
-INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
+INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
+INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
CREATE TABLE host (
@@ -42,6 +47,8 @@ CREATE TABLE host (
Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
PRIMARY KEY Host (Host,Db)
) engine=MyISAM
CHARACTER SET utf8 COLLATE utf8_bin
@@ -73,6 +80,11 @@ CREATE TABLE user (
Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
ssl_cipher BLOB NOT NULL,
x509_issuer BLOB NOT NULL,
@@ -80,15 +92,16 @@ CREATE TABLE user (
max_questions int(11) unsigned DEFAULT 0 NOT NULL,
max_updates int(11) unsigned DEFAULT 0 NOT NULL,
max_connections int(11) unsigned DEFAULT 0 NOT NULL,
+ max_user_connections int(11) unsigned DEFAULT 0 NOT NULL,
PRIMARY KEY Host (Host,User)
) engine=MyISAM
CHARACTER SET utf8 COLLATE utf8_bin
comment='Users and global privileges';
-INSERT INTO user VALUES ('localhost' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
-INSERT INTO user VALUES ('@HOSTNAME@%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
-REPLACE INTO user VALUES ('127.0.0.1' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
+INSERT INTO user VALUES ('localhost' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+INSERT INTO user VALUES ('@HOSTNAME@%' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+REPLACE INTO user VALUES ('127.0.0.1' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
INSERT INTO user (host,user) VALUES ('localhost','');
INSERT INTO user (host,user) VALUES ('@HOSTNAME@%','');
@@ -135,11 +148,11 @@ comment='Column privileges';
CREATE TABLE help_topic (
help_topic_id int unsigned not null,
- name varchar(64) not null,
+ name char(64) not null,
help_category_id smallint unsigned not null,
description text not null,
example text not null,
- url varchar(128) not null,
+ url char(128) not null,
primary key (help_topic_id),
unique index (name)
) engine=MyISAM
@@ -149,9 +162,9 @@ comment='help topics';
CREATE TABLE help_category (
help_category_id smallint unsigned not null,
- name varchar(64) not null,
+ name char(64) not null,
parent_category_id smallint unsigned null,
- url varchar(128) not null,
+ url char(128) not null,
primary key (help_category_id),unique index (name)
) engine=MyISAM
CHARACTER SET utf8
@@ -160,7 +173,7 @@ comment='help categories';
CREATE TABLE help_keyword (
help_keyword_id int unsigned not null,
- name varchar(64) not null,
+ name char(64) not null,
primary key (help_keyword_id),unique index (name)
) engine=MyISAM
CHARACTER SET utf8
@@ -468,3 +481,74 @@ INSERT INTO time_zone_leap_second (
,(662688015, 16) ,(709948816, 17) ,(741484817, 18)
,(773020818, 19) ,(820454419, 20) ,(867715220, 21)
,(915148821, 22);
+
+
+CREATE TABLE procs_priv (
+ Host char(60) binary DEFAULT '' NOT NULL,
+ Db char(64) binary DEFAULT '' NOT NULL,
+ User char(16) binary DEFAULT '' NOT NULL,
+ Routine_name char(64) binary DEFAULT '' NOT NULL,
+ Grantor char(77) DEFAULT '' NOT NULL,
+ Timestamp timestamp(14),
+ Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
+ PRIMARY KEY (Host,Db,User,Routine_name),
+ KEY Grantor (Grantor)
+) engine=MyISAM
+CHARACTER SET utf8 COLLATE utf8_bin
+comment='Procedure privileges';
+
+
+CREATE TABLE proc (
+ db char(64) binary DEFAULT '' NOT NULL,
+ name char(64) DEFAULT '' NOT NULL,
+ type enum('FUNCTION','PROCEDURE') NOT NULL,
+ specific_name char(64) DEFAULT '' NOT NULL,
+ language enum('SQL') DEFAULT 'SQL' NOT NULL,
+ sql_data_access enum('CONTAINS_SQL',
+ 'NO_SQL',
+ 'READS_SQL_DATA',
+ 'MODIFIES_SQL_DATA'
+ ) DEFAULT 'CONTAINS_SQL' NOT NULL,
+ is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL,
+ security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL,
+ param_list blob DEFAULT '' NOT NULL,
+ returns char(64) DEFAULT '' NOT NULL,
+ body blob DEFAULT '' NOT NULL,
+ definer char(77) binary DEFAULT '' NOT NULL,
+ created timestamp,
+ modified timestamp,
+ sql_mode set(
+ 'REAL_AS_FLOAT',
+ 'PIPES_AS_CONCAT',
+ 'ANSI_QUOTES',
+ 'IGNORE_SPACE',
+ 'NOT_USED',
+ 'ONLY_FULL_GROUP_BY',
+ 'NO_UNSIGNED_SUBTRACTION',
+ 'NO_DIR_IN_CREATE',
+ 'POSTGRESQL',
+ 'ORACLE',
+ 'MSSQL',
+ 'DB2',
+ 'MAXDB',
+ 'NO_KEY_OPTIONS',
+ 'NO_TABLE_OPTIONS',
+ 'NO_FIELD_OPTIONS',
+ 'MYSQL323',
+ 'MYSQL40',
+ 'ANSI',
+ 'NO_AUTO_VALUE_ON_ZERO',
+ 'NO_BACKSLASH_ESCAPES',
+ 'STRICT_TRANS_TABLES',
+ 'STRICT_ALL_TABLES',
+ 'NO_ZERO_IN_DATE',
+ 'NO_ZERO_DATE',
+ 'INVALID_DATES',
+ 'ERROR_FOR_DIVISION_BY_ZERO',
+ 'TRADITIONAL',
+ 'NO_AUTO_CREATE_USER',
+ 'HIGH_NOT_PRECEDENCE'
+ ) DEFAULT 0 NOT NULL,
+ comment char(64) binary DEFAULT '' NOT NULL,
+ PRIMARY KEY (db,name,type)
+) comment='Stored Procedures';
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index 5977bb380cf..878afe95f2c 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -63,21 +63,24 @@ sub collect_test_cases ($) {
# To speed things up, we sort first in if the test require a restart
# or not, second in alphanumeric order.
-# @$cases = sort {
-# if ( $a->{'master_restart'} and $b->{'master_restart'} or
-# ! $a->{'master_restart'} and ! $b->{'master_restart'} )
-# {
-# return $a->{'name'} cmp $b->{'name'};
-# }
-# if ( $a->{'master_restart'} )
-# {
-# return 1; # Is greater
-# }
-# else
-# {
-# return -1; # Is less
-# }
-# } @$cases;
+ if ( $::opt_reorder )
+ {
+ @$cases = sort {
+ if ( $a->{'master_restart'} and $b->{'master_restart'} or
+ ! $a->{'master_restart'} and ! $b->{'master_restart'} )
+ {
+ return $a->{'name'} cmp $b->{'name'};
+ }
+ if ( $a->{'master_restart'} )
+ {
+ return 1; # Is greater
+ }
+ else
+ {
+ return -1; # Is less
+ }
+ } @$cases;
+ }
return $cases;
}
diff --git a/mysql-test/lib/mtr_diff.pl b/mysql-test/lib/mtr_diff.pl
new file mode 100644
index 00000000000..4e927ff4e37
--- /dev/null
+++ b/mysql-test/lib/mtr_diff.pl
@@ -0,0 +1,283 @@
+# -*- cperl -*-
+
+# This is a library file used by the Perl version of mysql-test-run,
+# and is part of the translation of the Bourne shell script with the
+# same name.
+
+#use Data::Dumper;
+use strict;
+
+# $Data::Dumper::Indent= 1;
+
+sub mtr_diff($$);
+
+##############################################################################
+#
+# This is a simplified unified diff, with some special handling
+# of unsorted result sets
+#
+##############################################################################
+
+# FIXME replace die with mtr_error
+
+#require "mtr_report.pl";
+#mtr_diff("a.txt","b.txt");
+
+sub mtr_diff ($$) {
+ my $file1 = shift;
+ my $file2 = shift;
+
+ # ----------------------------------------------------------------------
+ # We read in all of the files at once
+ # ----------------------------------------------------------------------
+
+ unless ( open(FILE1, $file1) )
+ {
+ mtr_warning("can't open \"$file1\": $!");
+ return;
+ }
+
+ unless ( open(FILE2, $file2) )
+ {
+ mtr_warning("can't open \"$file2\": $!");
+ return;
+ }
+
+ my $lines1= collect_lines(<FILE1>);
+ my $lines2= collect_lines(<FILE2>);
+ close FILE1;
+ close FILE2;
+
+# print Dumper($lines1);
+# print Dumper($lines2);
+
+ # ----------------------------------------------------------------------
+ # We compare line by line, but don't shift off elements until we know
+ # what to do. This way we use the "restart" method, do simple change
+ # and restart by entering the diff loop from the beginning again.
+ # ----------------------------------------------------------------------
+
+ my @context;
+ my @info; # Collect information, and output later
+ my $lno1= 1;
+ my $lno2= 1;
+
+ while ( @$lines1 or @$lines2 )
+ {
+ unless ( @$lines1 )
+ {
+ push(@info, map {['+',$lno1,$lno2++,$_]} @$lines2);
+ last;
+ }
+ unless ( @$lines2 )
+ {
+ push(@info, map {['-',$lno1++,$lno2,$_]} @$lines1);
+ last;
+ }
+
+ # ----------------------------------------------------------------------
+ # We know both have lines
+ # ----------------------------------------------------------------------
+
+ if ( $lines1->[0] eq $lines2->[0] )
+ {
+ # Simple case, first line match and all is well
+ push(@info, ['',$lno1++,$lno2++,$lines1->[0]]);
+ shift @$lines1;
+ shift @$lines2;
+ next;
+ }
+
+ # ----------------------------------------------------------------------
+ # Now, we know they differ
+ # ----------------------------------------------------------------------
+
+ # How far in the other one, is there a match?
+
+ my $idx2= find_next_match($lines1->[0], $lines2);
+ my $idx1= find_next_match($lines2->[0], $lines1);
+
+ # Here we could test "if ( !defined $idx2 or !defined $idx1 )" and
+ # use a more complicated diff algorithm in the case both contains
+ # each others lines, just dislocated. But for this application, there
+ # should be no need.
+
+ if ( !defined $idx2 )
+ {
+ push(@info, ['-',$lno1++,$lno2,$lines1->[0]]);
+ shift @$lines1;
+ }
+ else
+ {
+ push(@info, ['+',$lno1,$lno2++,$lines2->[0]]);
+ shift @$lines2;
+ }
+ }
+
+ # ----------------------------------------------------------------------
+ # Try to output nicely
+ # ----------------------------------------------------------------------
+
+# print Dumper(\@info);
+
+ # We divide into "chunks" to output
+ # We want at least three lines of context
+
+ my @chunks;
+ my @chunk;
+ my $state= 'pre'; # 'pre', 'in' and 'post' difference
+ my $post_count= 0;
+
+ foreach my $info ( @info )
+ {
+ if ( $info->[0] eq '' and $state eq 'pre' )
+ {
+ # Collect no more than three lines of context before diff
+ push(@chunk, $info);
+ shift(@chunk) if @chunk > 3;
+ next;
+ }
+
+ if ( $info->[0] =~ /(\+|\-)/ and $state =~ /(pre|in)/ )
+ {
+ # Start/continue collecting diff
+ $state= 'in';
+ push(@chunk, $info);
+ next;
+ }
+
+ if ( $info->[0] eq '' and $state eq 'in' )
+ {
+ # Stop collecting diff, and collect context after diff
+ $state= 'post';
+ $post_count= 1;
+ push(@chunk, $info);
+ next;
+ }
+
+ if ( $info->[0] eq '' and $state eq 'post' and $post_count < 6 )
+ {
+ # We might find a new diff sequence soon, continue to collect
+ # non diffs but five up on 6.
+ $post_count++;
+ push(@chunk, $info);
+ next;
+ }
+
+ if ( $info->[0] eq '' and $state eq 'post' )
+ {
+ # We put an end to this, giving three non diff lines to
+ # the old chunk, and three to the new one.
+ my @left= splice(@chunk, -3, 3);
+ push(@chunks, [@chunk]);
+ $state= 'pre';
+ $post_count= 0;
+ @chunk= @left;
+ next;
+ }
+
+ if ( $info->[0] =~ /(\+|\-)/ and $state eq 'post' )
+ {
+ # We didn't split, continue collect diff
+ $state= 'in';
+ push(@chunk, $info);
+ next;
+ }
+
+ }
+
+ if ( $post_count > 3 )
+ {
+ $post_count -= 3;
+ splice(@chunk, -$post_count, $post_count);
+ }
+ push(@chunks, [@chunk]) if @chunk and $state ne 'pre';
+
+ foreach my $chunk ( @chunks )
+ {
+ my $from_file_start= $chunk->[0]->[1];
+ my $to_file_start= $chunk->[0]->[2];
+ my $from_file_offset= $chunk->[$#$chunk]->[1] - $from_file_start;
+ my $to_file_offset= $chunk->[$#$chunk]->[2] - $to_file_start;
+ print "\@\@ -$from_file_start,$from_file_offset ",
+ "+$to_file_start,$to_file_offset \@\@\n";
+
+ foreach my $info ( @$chunk )
+ {
+ if ( $info->[0] eq '' )
+ {
+ print " $info->[3]\n";
+ }
+ elsif ( $info->[0] eq '-' )
+ {
+ print "- $info->[3]\n";
+ }
+ elsif ( $info->[0] eq '+' )
+ {
+ print "+ $info->[3]\n";
+ }
+ }
+ }
+
+# print Dumper(\@chunks);
+
+}
+
+
+##############################################################################
+# Find if the string is found in the array, return the index if found,
+# if not found, return "undef"
+##############################################################################
+
+sub find_next_match {
+ my $line= shift;
+ my $lines= shift;
+
+ for ( my $idx= 0; $idx < @$lines; $idx++ )
+ {
+ return $idx if $lines->[$idx] eq $line;
+ }
+
+ return undef; # No match found
+}
+
+
+##############################################################################
+# Just read the lines, but handle "sets" of lines that are unordered
+##############################################################################
+
+sub collect_lines {
+
+ my @recordset;
+ my @lines;
+
+ while (@_)
+ {
+ my $line= shift @_;
+ chomp($line);
+
+ if ( $line =~ /^\Q%unordered%\E\t/ )
+ {
+ push(@recordset, $line);
+ }
+ elsif ( @recordset )
+ {
+ push(@lines, sort @recordset);
+ @recordset= (); # Clear it
+ }
+ else
+ {
+ push(@lines, $line);
+ }
+ }
+
+ if ( @recordset )
+ {
+ push(@lines, sort @recordset);
+ @recordset= (); # Clear it
+ }
+
+ return \@lines;
+}
+
+1;
diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl
index 9947fed9d27..fd665b154b8 100644
--- a/mysql-test/lib/mtr_report.pl
+++ b/mysql-test/lib/mtr_report.pl
@@ -89,12 +89,11 @@ sub mtr_report_test_passed ($) {
my $tinfo= shift;
my $timer= "";
-# FIXME
-# if ( $::opt_timer and -f "$::glob_mysql_test_dir/var/log/timer" )
-# {
-# $timer= `cat var/log/timer`;
-# $timer= sprintf "%13s", $timer;
-# }
+ if ( $::opt_timer and -f "$::glob_mysql_test_dir/var/log/timer" )
+ {
+ $timer= mtr_fromfile("$::glob_mysql_test_dir/var/log/timer");
+ $timer= sprintf "%12s", $timer;
+ }
$tinfo->{'result'}= 'MTR_RES_PASSED';
print "[ pass ] $timer\n";
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index ce419540bf2..90fc97b537b 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -94,6 +94,7 @@ require "lib/mtr_io.pl";
require "lib/mtr_gcov.pl";
require "lib/mtr_gprof.pl";
require "lib/mtr_report.pl";
+require "lib/mtr_diff.pl";
require "lib/mtr_match.pl";
require "lib/mtr_misc.pl";
@@ -214,6 +215,7 @@ our $opt_embedded_server;
our $opt_extern;
our $opt_fast;
our $opt_force;
+our $opt_reorder;
our $opt_gcov;
our $opt_gcov_err;
@@ -525,6 +527,7 @@ sub command_line_setup () {
'local-master' => \$opt_local_master,
'netware' => \$opt_netware,
'old-master' => \$opt_old_master,
+ 'reorder' => \$opt_reorder,
'script-debug' => \$opt_script_debug,
'sleep=i' => \$opt_sleep,
'socket=s' => \$opt_socket,
@@ -576,7 +579,7 @@ sub command_line_setup () {
$slave->[0]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/slave.pid";
$slave->[0]->{'path_mysock'}= "$opt_tmpdir/slave.sock";
$slave->[0]->{'path_myport'}= $opt_slave_myport;
- $slave->[0]->{'start_timeout'}= 400;
+ $slave->[0]->{'start_timeout'}= 400;
$slave->[1]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave1-data";
$slave->[1]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave1.err";
@@ -584,7 +587,7 @@ sub command_line_setup () {
$slave->[1]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/slave1.pid";
$slave->[1]->{'path_mysock'}= "$opt_tmpdir/slave1.sock";
$slave->[1]->{'path_myport'}= $opt_slave_myport + 1;
- $slave->[1]->{'start_timeout'}= 30;
+ $slave->[1]->{'start_timeout'}= 300;
$slave->[2]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave2-data";
$slave->[2]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave2.err";
@@ -592,7 +595,7 @@ sub command_line_setup () {
$slave->[2]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/slave2.pid";
$slave->[2]->{'path_mysock'}= "$opt_tmpdir/slave2.sock";
$slave->[2]->{'path_myport'}= $opt_slave_myport + 2;
- $slave->[2]->{'start_timeout'}= 30;
+ $slave->[2]->{'start_timeout'}= 300;
# Do sanity checks of command line arguments
@@ -1365,7 +1368,10 @@ sub run_testcase ($) {
mtr_report_test_name($tinfo);
mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n");
- do_before_start_master($tname,$tinfo->{'master_sh'});
+
+# FIXME test cases that depend on each other, prevent this from
+# being at this location.
+# do_before_start_master($tname,$tinfo->{'master_sh'});
# ----------------------------------------------------------------------
# If any mysqld servers running died, we have to know
@@ -1397,6 +1403,8 @@ sub run_testcase ($) {
}
if ( ! $master->[0]->{'pid'} )
{
+ # FIXME not correct location for do_before_start_master()
+ do_before_start_master($tname,$tinfo->{'master_sh'});
$master->[0]->{'pid'}=
mysqld_start('master',0,$tinfo->{'master_opt'},[]);
if ( ! $master->[0]->{'pid'} )
@@ -1532,9 +1540,10 @@ sub do_before_start_master ($$) {
$tname ne "rpl_crash_binlog_ib_3b")
{
# FIXME we really want separate dir for binlogs
- # FIXME replace 'rm' in backticks with portable Perl function
- `rm -f $glob_mysql_test_dir/var/log/master-bin*`;
-# unlink("$glob_mysql_test_dir/var/log/master-bin*");
+ foreach my $bin ( glob("$glob_mysql_test_dir/var/log/master*-bin.*") )
+ {
+ unlink($bin);
+ }
}
# Remove old master.info and relay-log.info files
@@ -1568,9 +1577,10 @@ sub do_before_start_slave ($$) {
$tname ne "rpl_crash_binlog_ib_3b" )
{
# FIXME we really want separate dir for binlogs
- # FIXME replace 'rm' in backticks with portable Perl function
- `rm -fr $glob_mysql_test_dir/var/log/slave*-bin.*`;
-# unlink("$glob_mysql_test_dir/var/log/slave*-bin.*"); # FIXME idx???
+ foreach my $bin ( glob("$glob_mysql_test_dir/var/log/slave*-bin.*") )
+ {
+ unlink($bin);
+ }
# FIXME really master?!
unlink("$glob_mysql_test_dir/var/slave-data/master.info");
unlink("$glob_mysql_test_dir/var/slave-data/relay-log.info");
@@ -1656,13 +1666,15 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--datadir=%s", $prefix,
$slave->[$idx]->{'path_myddir'});
+ # FIXME slave get this option twice?!
mtr_add_arg($args, "%s--exit-info=256", $prefix);
mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
mtr_add_arg($args, "%s--log-bin=%s/var/log/slave%s-bin", $prefix,
$glob_mysql_test_dir, $sidx); # FIXME use own dir for binlogs
mtr_add_arg($args, "%s--log-slave-updates", $prefix);
+ # FIXME option duplicated for slave
mtr_add_arg($args, "%s--log=%s", $prefix,
- $slave->[$idx]->{'path_myerr'});
+ $slave->[$idx]->{'path_mylog'});
mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
$slave->[$idx]->{'path_mypid'});
@@ -2043,7 +2055,7 @@ sub run_mysqltest ($$) {
if ( $opt_timer )
{
- mtr_add_arg($args, "--timer-file=var/log/timer");
+ mtr_add_arg($args, "--timer-file=%s/var/log/timer", $glob_mysql_test_dir);
}
if ( $opt_big_test )
@@ -2172,6 +2184,7 @@ Misc options
timer Show test case execution time
start-and-exit Only initiate and start the "mysqld" servers
fast Don't try to cleanup from earlier runs
+ reorder Reorder tests to get less server restarts
help Get this help text
unified-diff | udiff When presenting differences, use unified diff
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index e4343807124..ac1755cab9c 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -222,6 +222,7 @@ FAILED_CASES=
EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
EXTRA_MYSQLDUMP_OPT=""
+EXTRA_MYSQLSHOW_OPT=""
EXTRA_MYSQLBINLOG_OPT=""
USE_RUNNING_SERVER=0
USE_NDBCLUSTER=@USE_NDBCLUSTER@
@@ -238,7 +239,7 @@ SLEEP_TIME_FOR_DELETE=10
SLEEP_TIME_FOR_FIRST_MASTER=400 # Enough time to create innodb tables
SLEEP_TIME_FOR_SECOND_MASTER=400
SLEEP_TIME_FOR_FIRST_SLAVE=400
-SLEEP_TIME_FOR_SECOND_SLAVE=30
+SLEEP_TIME_FOR_SECOND_SLAVE=300
CHARACTER_SET=latin1
DBUSER=""
START_WAIT_TIMEOUT=10
@@ -453,6 +454,8 @@ while test $# -gt 0; do
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqltest.trace"
EXTRA_MYSQLDUMP_OPT="$EXTRA_MYSQLDUMP_OPT \
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqldump.trace"
+ EXTRA_MYSQLSHOW_OPT="$EXTRA_MYSQLSHOW_OPT \
+ --debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqlshow.trace"
EXTRA_MYSQLBINLOG_OPT="$EXTRA_MYSQLBINLOG_OPT \
--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysqlbinlog.trace"
EXTRA_MYSQL_CLIENT_TEST_OPT="--debug=d:t:A,$MYSQL_TEST_DIR/var/log/mysql_client_test.trace"
@@ -556,6 +559,11 @@ if [ x$SOURCE_DIST = x1 ] ; then
else
MYSQL_DUMP="$BASEDIR/client/mysqldump"
fi
+ if [ -f "$BASEDIR/client/.libs/mysqlshow" ] ; then
+ MYSQL_SHOW="$BASEDIR/client/.libs/mysqlshow"
+ else
+ MYSQL_SHOW="$BASEDIR/client/mysqlshow"
+ fi
if [ -f "$BASEDIR/client/.libs/mysqlbinlog" ] ; then
MYSQL_BINLOG="$BASEDIR/client/.libs/mysqlbinlog"
else
@@ -627,6 +635,7 @@ else
fi
MYSQL_TEST="$CLIENT_BINDIR/mysqltest"
MYSQL_DUMP="$CLIENT_BINDIR/mysqldump"
+ MYSQL_SHOW="$CLIENT_BINDIR/mysqlshow"
MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog"
MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
WAIT_PID="$CLIENT_BINDIR/mysql_waitpid"
@@ -697,10 +706,11 @@ fi
MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent $EXTRA_MYSQL_CLIENT_TEST_OPT"
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
+MYSQL_SHOW="$MYSQL_SHOW -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSHOW_OPT"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT"
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
-export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
+export MYSQL MYSQL_DUMP MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR
export NDB_TOOLS_DIR
export NDB_MGM
@@ -731,7 +741,7 @@ if [ -n "$DO_CLIENT_GDB" -o -n "$DO_GDB" ] ; then
XTERM=`which xterm`
fi
-export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR MASTER_MYSOCK
+export MYSQL MYSQL_DUMP MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR MASTER_MYSOCK
#++
# Function Definitions
diff --git a/mysql-test/r/blackhole.result b/mysql-test/r/blackhole.result
new file mode 100644
index 00000000000..a3053075de5
--- /dev/null
+++ b/mysql-test/r/blackhole.result
@@ -0,0 +1,86 @@
+drop table if exists t1,t2;
+CREATE TABLE t1 (
+Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
+) ENGINE=blackhole;
+INSERT INTO t1 VALUES (9410,9412);
+select period from t1;
+period
+select * from t1;
+Period Varor_period
+select t1.* from t1;
+Period Varor_period
+CREATE TABLE t2 (
+auto int NOT NULL auto_increment,
+fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
+companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
+fld3 char(30) DEFAULT '' NOT NULL,
+fld4 char(35) DEFAULT '' NOT NULL,
+fld5 char(35) DEFAULT '' NOT NULL,
+fld6 char(4) DEFAULT '' NOT NULL,
+primary key (auto)
+) ENGINE=blackhole;
+INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
+INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
+select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
+fld3
+select fld3 from t2 where fld3 like "%cultivation" ;
+fld3
+select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
+fld3 companynr
+select fld3,companynr from t2 where companynr = 58 order by fld3;
+fld3 companynr
+select fld3 from t2 order by fld3 desc limit 10;
+fld3
+select fld3 from t2 order by fld3 desc limit 5;
+fld3
+select fld3 from t2 order by fld3 desc limit 5,5;
+fld3
+select t2.fld3 from t2 where fld3 = 'honeysuckle';
+fld3
+select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
+fld3
+select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
+fld3
+select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
+fld3
+select t2.fld3 from t2 where fld3 LIKE 'h%le';
+fld3
+select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
+fld3
+select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
+fld3
+select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
+fld3
+select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
+fld1 fld3
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
+INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
+('Full-text indexes', 'are called collections'),
+('Only MyISAM tables','support collections'),
+('Function MATCH ... AGAINST()','is used to do a search'),
+('Full-text search in MySQL', 'implements vector space model');
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT
+t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT
+select * from t1 where MATCH(a,b) AGAINST ("collections");
+a b
+Only MyISAM tables support collections
+Full-text indexes are called collections
+explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against (_latin1'collections'))
+select * from t1 where MATCH(a,b) AGAINST ("indexes");
+a b
+Full-text indexes are called collections
+select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
+a b
+Full-text indexes are called collections
+Only MyISAM tables support collections
+select * from t1 where MATCH(a,b) AGAINST ("only");
+a b
+drop table if exists t1,t2;
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index 8f4ee3d0558..c63704f6d9d 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -77,3 +77,10 @@ big5_bin 6109
big5_bin 61
big5_bin 6120
drop table t1;
+SET NAMES big5;
+CREATE TABLE t1 (a text) character set big5;
+INSERT INTO t1 VALUES ('ùØ');
+SELECT * FROM t1;
+a
+ùØ
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result
index 647f8c6236c..c65055e726d 100644
--- a/mysql-test/r/ctype_cp1251.result
+++ b/mysql-test/r/ctype_cp1251.result
@@ -1,6 +1,6 @@
drop table if exists t1;
SET NAMES cp1251;
-create table t1 (a varchar(10) not null);
+create table t1 (a varchar(10) not null) character set cp1251;
insert into t1 values ("a"),("ab"),("abc");
select * from t1;
a
@@ -23,7 +23,7 @@ a
b
c
drop table t1;
-create table t1 (a char(15) binary, b binary(15));
+create table t1 (a char(15) binary, b binary(15)) character set cp1251;
insert into t1 values ('aaa','bbb'),('AAA','BBB');
select upper(a),upper(b) from t1;
upper(a) upper(b)
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index a734ad78e04..868bdd90051 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -642,3 +642,11 @@ Warnings:
Warning 1264 Out of range value adjusted for column 'Field1' at row 1
DROP TABLE t1;
SET NAMES latin1;
+CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
+INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
+update t1 set b=a;
+SELECT * FROM t1;
+a b
+1.1 1.100
+2.1 2.100
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 7fe8e76cb5b..490cde82ca3 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -871,3 +871,17 @@ drop table t1;
select convert(_koi8r'É' using utf8) < convert(_koi8r'Ê' using utf8);
convert(_koi8r'É' using utf8) < convert(_koi8r'Ê' using utf8)
1
+set names latin1;
+create table t1 (a varchar(10)) character set utf8;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+ifnull(a,'')
+test
+drop table t1;
+select repeat(_utf8'+',3) as h union select NULL;
+h
++++
+NULL
+select ifnull(NULL, _utf8'string');
+ifnull(NULL, _utf8'string')
+string
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result
index 2db014c4a52..8217a0e7ba6 100644
--- a/mysql-test/r/date_formats.result
+++ b/mysql-test/r/date_formats.result
@@ -79,6 +79,11 @@ concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
str_to_date(concat('15-01-2001',' 2:59:58.999'),
concat('%d-%m-%Y',' ','%H:%i:%s.%f'))
2001-01-15 02:59:58.999000
+select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
+STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T')
+NULL
+Warnings:
+Error 1411 Incorrect time value: '22.30.61' for function str_to_time
create table t1 (date char(30), format char(30) not null);
insert into t1 values
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
@@ -335,6 +340,22 @@ Tuesday 52 2001 %W %V %Y NULL
Tuesday 52 2001 %W %u %x NULL
7 53 1998 %w %u %Y NULL
NULL %m.%d.%Y NULL
+Warnings:
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_time
+Error 1411 Incorrect datetime value: '10:20:10AM' for function str_to_time
+Error 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_time
+Error 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_time
+Error 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_time
+Error 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_time
+Error 1411 Incorrect datetime value: '7 53 1998' for function str_to_time
select date,format,concat(str_to_date(date, format),'') as con from t1;
date format con
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
@@ -353,6 +374,22 @@ Tuesday 52 2001 %W %V %Y NULL
Tuesday 52 2001 %W %u %x NULL
7 53 1998 %w %u %Y NULL
NULL %m.%d.%Y NULL
+Warnings:
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_time
+Error 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_time
+Error 1411 Incorrect datetime value: '10:20:10AM' for function str_to_time
+Error 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_time
+Error 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_time
+Error 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_time
+Error 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_time
+Error 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_time
+Error 1411 Incorrect datetime value: '7 53 1998' for function str_to_time
truncate table t1;
insert into t1 values
('10:20:10AM', '%h:%i:%s'),
@@ -391,6 +428,8 @@ NULL
select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'))
NULL
+Warnings:
+Error 1411 Incorrect datetime value: '15-01-2001 12:59:59' for function str_to_time
explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result
index a012550ef5f..6c815e94b7c 100644
--- a/mysql-test/r/federated.result
+++ b/mysql-test/r/federated.result
@@ -106,7 +106,7 @@ CREATE TABLE federated.`t1%` (
`name` varchar(32) NOT NULL default ''
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
-COMMENT='mysql://root@127.0.0.1:9308/federated/t1%';
+COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1%';
INSERT INTO federated.`t1%` (id, name) VALUES (1, 'foo');
INSERT INTO federated.`t1%` (id, name) VALUES (2, 'fee');
SELECT * FROM federated.`t1%`;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 3e06018226d..1cf1a19056b 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -783,7 +783,7 @@ insert into t1 values (now());
create table t2 select f2 from (select max(now()) f2 from t1) a;
show columns from t2;
Field Type Null Key Default Extra
-f2 datetime NO 0000-00-00 00:00:00
+f2 datetime YES NULL
drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 15a650eccfa..1c2cfeca01e 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -639,6 +639,26 @@ drop table t1;
select charset(null), collation(null), coercibility(null);
charset(null) collation(null) coercibility(null)
binary binary 5
+CREATE TABLE t1 (a int, b int);
+CREATE TABLE t2 (a int, b int);
+INSERT INTO t1 VALUES (1,1),(2,2);
+INSERT INTO t2 VALUES (2,2),(3,3);
+select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
+where collation(t2.a) = _utf8'binary' order by t1.a,t2.a;
+a b a b
+1 1 NULL NULL
+2 2 2 2
+select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
+where charset(t2.a) = _utf8'binary' order by t1.a,t2.a;
+a b a b
+1 1 NULL NULL
+2 2 2 2
+select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
+where coercibility(t2.a) = 2 order by t1.a,t2.a;
+a b a b
+1 1 NULL NULL
+2 2 2 2
+DROP TABLE t1, t2;
select SUBSTR('abcdefg',3,2);
SUBSTR('abcdefg',3,2)
cd
diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result
index 9aa936f1c78..5ec5d7d724e 100644
--- a/mysql-test/r/func_system.result
+++ b/mysql-test/r/func_system.result
@@ -75,4 +75,8 @@ select * from t1 where a=database();
a
select * from t1 where a=user();
a
+insert into t1 values ('a');
+select left(concat(a,version()),1) from t1;
+left(concat(a,version()),1)
+a
drop table t1;
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index e5f7f535ae2..ecd2758fd1c 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -10,8 +10,8 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
grant delete on mysqltest.* to mysqltest_1@localhost;
select * from mysql.user where user="mysqltest_1";
-Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections
-localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED EDH-RSA-DES-CBC3-SHA 0 0 0 0
+Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections
+localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED EDH-RSA-DES-CBC3-SHA 0 0 0 0
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
@@ -41,15 +41,15 @@ delete from mysql.user where user='mysqltest_1';
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10;
select * from mysql.user where user="mysqltest_1";
-Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections
-localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N 10 0 0 0
+Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections
+localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N 10 0 0 0
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30;
select * from mysql.user where user="mysqltest_1";
-Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections
-localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 0
+Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections
+localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 0
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30
@@ -440,6 +440,7 @@ Create Databases,Tables,Indexes To create new databases and tables
Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
Create temporary tables Databases To use CREATE TEMPORARY TABLE
Create view Tables To create new views
+Create user Server Admin To create new users
Delete Tables To delete existing rows
Drop Databases,Tables To drop databases, tables, and views
Execute Functions,Procedures To execute stored routines
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
index e6db7bd682f..b7639d49c7d 100644
--- a/mysql-test/r/grant2.result
+++ b/mysql-test/r/grant2.result
@@ -1,11 +1,13 @@
SET NAMES binary;
drop database if exists mysqltest;
+drop database if exists mysqltest_1;
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
grant all privileges on `my\_1`.* to mysqltest_1@localhost with grant option;
+grant create user on *.* to mysqltest_1@localhost;
create user mysqltest_2@localhost;
grant select on `my\_1`.* to mysqltest_2@localhost;
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
@@ -13,7 +15,6 @@ ERROR 42000: You must have privileges to update tables in the mysql database to
grant update on mysql.* to mysqltest_1@localhost;
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
grant select on `my\_1`.* to mysqltest_3@localhost;
-ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
grant insert on mysql.* to mysqltest_1@localhost;
grant select on `my\_1`.* to mysqltest_3@localhost;
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'pass';
@@ -23,14 +24,11 @@ delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
+grant create user on *.* to mysqltest_1@localhost;
select current_user();
current_user()
mysqltest_1@localhost
-select current_user;
-current_user
-mysqltest_1@localhost
grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
-ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
set @@sql_mode='NO_AUTO_CREATE_USER';
@@ -38,21 +36,42 @@ select @@sql_mode;
@@sql_mode
NO_AUTO_CREATE_USER
grant select on `my\_1`.* to mysqltest_4@localhost with grant option;
-ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
+ERROR 42000: Can't find any matching row in the user table
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'
with grant option;
-ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
-GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
+GRANT CREATE USER ON *.* TO 'mysqltest_1'@'localhost'
GRANT ALL PRIVILEGES ON `my\_%`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
show grants for mysqltest_2@localhost;
-ERROR 42000: There is no such grant defined for user 'mysqltest_2' on host 'localhost'
+Grants for mysqltest_2@localhost
+GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'
+GRANT ALL PRIVILEGES ON `my\_1`.* TO 'mysqltest_2'@'localhost' WITH GRANT OPTION
show grants for mysqltest_3@localhost;
ERROR 42000: There is no such grant defined for user 'mysqltest_3' on host 'localhost'
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
+create database mysqltest_1;
+grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option;
+select current_user();
+current_user()
+mysqltest_1@localhost
+show databases;
+Database
+information_schema
+mysqltest_1
+test
+grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;
+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_1'
+show grants for mysqltest_1@localhost;
+Grants for mysqltest_1@localhost
+GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
+GRANT ALL PRIVILEGES ON `mysqltest\_1`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+drop database mysqltest_1;
+flush privileges;
create database mysqltest;
grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
flush privileges;
@@ -77,9 +96,9 @@ flush privileges;
create table t1 (a int, b int);
grant select (a) on t1 to mysqltest_1@localhost with grant option;
grant select (a,b) on t1 to mysqltest_2@localhost;
-ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't1'
grant select on t1 to mysqltest_3@localhost;
-ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
drop table t1;
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
@@ -164,8 +183,6 @@ GRANT INSERT ON "test".* TO 'mysqltest_1'@'%'
GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_1'@'%'
GRANT UPDATE ON "test"."t1" TO 'mysqltest_1'@'%'
drop user 'mysqltest_1', 'mysqltest_3';
-grant all on test.t1 to 'mysqltest_1';
-ERROR 42000: 'root'@'localhost' is not allowed to create new users
drop user 'mysqltest_1';
ERROR HY000: Operation DROP USER failed for 'mysqltest_1'@'%'
drop table t1, t2;
@@ -228,7 +245,7 @@ GRANT USAGE ON *.* TO '%@a'@'a'
GRANT SELECT ON "mysql".* TO '%@a'@'a'
drop user '%@a'@'a';
create user mysqltest_2@localhost;
-grant usage on *.* to mysqltest_2@localhost with grant option;
+grant create user on *.* to mysqltest_2@localhost;
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 'user'
create user mysqltest_A@'%';
@@ -236,19 +253,17 @@ rename user mysqltest_A@'%' to mysqltest_B@'%';
drop user mysqltest_B@'%';
drop user mysqltest_2@localhost;
create user mysqltest_3@localhost;
-grant all privileges on mysql.* to mysqltest_3@localhost;
+grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost;
+show grants;
+Grants for mysqltest_3@localhost
+GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost'
+GRANT INSERT, UPDATE, DELETE ON `mysql`.* TO 'mysqltest_3'@'localhost'
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-host user password
-% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
-localhost mysqltest_3
+ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 'user'
insert into mysql.user set host='%', user='mysqltest_B';
create user mysqltest_A@'%';
-ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
rename user mysqltest_B@'%' to mysqltest_C@'%';
-ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
-drop user mysqltest_B@'%';
-ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
-drop user mysqltest_B@'%';
+drop user mysqltest_C@'%';
drop user mysqltest_3@localhost;
set @@sql_mode='';
create database mysqltest_1;
diff --git a/mysql-test/r/grant3.result b/mysql-test/r/grant3.result
new file mode 100644
index 00000000000..6193c4fd49d
--- /dev/null
+++ b/mysql-test/r/grant3.result
@@ -0,0 +1,18 @@
+SET NAMES binary;
+drop table if exists t1;
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+delete from mysql.tables_priv where user like 'mysqltest\_%';
+delete from mysql.columns_priv where user like 'mysqltest\_%';
+flush privileges;
+create user mysqltest_1@localhost;
+grant create user on *.* to mysqltest_1@localhost;
+grant select on `my\_1`.* to mysqltest_1@localhost with grant option;
+grant select on `my\_1`.* to mysqltest_2@localhost;
+ERROR 42000: You are not allowed to create a user with GRANT
+create user mysqltest_2@localhost;
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+delete from mysql.tables_priv where user like 'mysqltest\_%';
+delete from mysql.columns_priv where user like 'mysqltest\_%';
+flush privileges;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index a43e67d57e6..af69cc83e83 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -677,3 +677,28 @@ select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0;
d
10
drop table t1;
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9);
+create table t2 (
+a int,
+b varchar(200) NOT NULL,
+c varchar(50) NOT NULL,
+d varchar(100) NOT NULL,
+primary key (a,b(132),c,d),
+key a (a,b)
+) charset=utf8;
+insert into t2 select
+x3.a, -- 3
+concat('val-', x3.a + 3*x4.a), -- 12
+concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120
+concat('val-', @a + 120*D.a)
+from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4;
+delete from t2 where a = 2 and b = 'val-2' order by a,b,c,d limit 30;
+explain select c from t2 where a = 2 and b = 'val-2' group by c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref PRIMARY,a PRIMARY 402 const,const 6 Using where
+select c from t2 where a = 2 and b = 'val-2' group by c;
+c
+val-74
+val-98
+drop table t1,t2;
diff --git a/mysql-test/r/have_blackhole.require b/mysql-test/r/have_blackhole.require
new file mode 100644
index 00000000000..15029a460f6
--- /dev/null
+++ b/mysql-test/r/have_blackhole.require
@@ -0,0 +1,2 @@
+Variable_name Value
+have_blackhole_engine YES
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index dc456e80e63..03c2cd8817c 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -118,8 +118,8 @@ t2
t3
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t2 MyISAM 9 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
-t3 MyISAM 9 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
+t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
+t3 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL # NULL NULL NULL # # NULL NULL NULL NULL view
show full columns from t3 like "a%";
Field Type Collation Null Key Default Extra Privileges Comment
@@ -432,7 +432,6 @@ information_schema.tables) union select version from
information_schema.tables;
s1
0
-9
10
drop table t1;
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
@@ -442,7 +441,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` (
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
`DESCRIPTION` varchar(60) NOT NULL default '',
`MAXLEN` bigint(3) NOT NULL default '0'
-) ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS=1818
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
set names latin2;
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table
@@ -451,7 +450,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` (
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
`DESCRIPTION` varchar(60) NOT NULL default '',
`MAXLEN` bigint(3) NOT NULL default '0'
-) ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS=1818
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1";
@@ -652,6 +651,8 @@ drop table t1, t2;
CREATE TABLE t_crashme ( f1 BIGINT);
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
+count(*)
+100
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result
index f57c134b6d0..2413834be4f 100644
--- a/mysql-test/r/kill.result
+++ b/mysql-test/r/kill.result
@@ -5,6 +5,12 @@ select ((@id := kill_id) - kill_id) from t1;
((@id := kill_id) - kill_id)
0
kill @id;
+select ((@id := kill_id) - kill_id) from t1;
+((@id := kill_id) - kill_id)
+0
+select @id != connection_id();
+@id != connection_id()
+1
select 4;
4
4
diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result
index 6a2cf466cfa..b5d5785f0f1 100644
--- a/mysql-test/r/metadata.result
+++ b/mysql-test/r/metadata.result
@@ -1,6 +1,6 @@
drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def 1 8 1 1 N 32897 0 63
def 1.0 246 4 3 N 161 1 63
def -1 8 2 2 N 32897 0 63
@@ -10,7 +10,7 @@ def NULL 6 0 0 Y 32896 0 63
1 1.0 -1 hello NULL
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp, l datetime, m enum('a','b'), n set('a','b'), o char(10));
select * from t1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 1 4 0 Y 32768 0 63
def test t1 t1 b b 2 6 0 Y 32768 0 63
def test t1 t1 c c 9 9 0 Y 32768 0 63
@@ -28,7 +28,7 @@ def test t1 t1 n n 254 3 0 Y 2048 0 8
def test t1 t1 o o 254 10 0 Y 0 0 8
a b c d e f g h i j k l m n o
select a b, b c from t1 as t2;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t2 a b 1 4 0 Y 32768 0 63
def test t1 t2 b c 2 6 0 Y 32768 0 63
b c
@@ -38,7 +38,7 @@ INSERT INTO t1 VALUES (1,'male'),(2,'female');
CREATE TABLE t2 (id tinyint(3) unsigned default NULL, data char(3) default '0');
INSERT INTO t2 VALUES (1,'yes'),(2,'no');
select t1.id, t1.data, t2.data from t1, t2 where t1.id = t2.id;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 id id 1 3 1 Y 32768 0 63
def test t1 t1 data data 253 255 6 Y 0 0 8
def test t2 t2 data data 254 3 3 Y 0 0 8
@@ -46,7 +46,7 @@ id data data
1 male yes
2 female no
select t1.id, t1.data, t2.data from t1, t2 where t1.id = t2.id order by t1.id;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 id id 1 3 1 Y 32768 0 63
def test t1 t1 data data 253 255 6 Y 0 0 8
def test t2 t2 data data 254 3 3 Y 0 0 8
@@ -54,9 +54,34 @@ id data data
1 male yes
2 female no
select t1.id from t1 union select t2.id from t2;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
-def test t1 t1 id id 1 3 1 Y 32768 0 63
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def id id 1 4 1 Y 32768 0 63
id
1
2
drop table t1,t2;
+create table t1 ( a int, b varchar(30), primary key(a));
+insert into t1 values (1,'one');
+insert into t1 values (2,'two');
+set @arg00=1 ;
+select @arg00 FROM t1 where a=1 union distinct select 1 FROM t1 where a=1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @arg00 @arg00 8 20 1 Y 32768 0 63
+@arg00
+1
+select * from (select @arg00) aaa;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def aaa @arg00 @arg00 8 20 1 Y 32768 0 63
+@arg00
+1
+select 1 union select 1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def 1 1 8 20 1 N 32769 0 63
+1
+1
+select * from (select 1 union select 1) aaa;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def aaa 1 1 8 20 1 N 32769 0 63
+1
+1
+drop table t1;
diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result
index a5f4915384d..7821c074202 100644
--- a/mysql-test/r/mix_innodb_myisam_binlog.result
+++ b/mysql-test/r/mix_innodb_myisam_binlog.result
@@ -9,9 +9,9 @@ commit;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(1)
-master-bin.000001 255 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 350 Xid 1 # COMMIT /* xid=7 */
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(1)
+master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 347 Xid 1 # COMMIT /* xid=7 */
delete from t1;
delete from t2;
reset master;
@@ -24,9 +24,9 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(2)
-master-bin.000001 255 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 350 Query 1 # use `test`; ROLLBACK
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(2)
+master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 347 Query 1 # use `test`; ROLLBACK
delete from t1;
delete from t2;
reset master;
@@ -42,12 +42,12 @@ commit;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(3)
-master-bin.000001 255 Query 1 # use `test`; savepoint my_savepoint
-master-bin.000001 341 Query 1 # use `test`; insert into t1 values(4)
-master-bin.000001 429 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 524 Query 1 # use `test`; rollback to savepoint my_savepoint
-master-bin.000001 622 Xid 1 # COMMIT /* xid=24 */
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(3)
+master-bin.000001 253 Query 1 # use `test`; savepoint my_savepoint
+master-bin.000001 338 Query 1 # use `test`; insert into t1 values(4)
+master-bin.000001 425 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 519 Query 1 # use `test`; rollback to savepoint my_savepoint
+master-bin.000001 616 Xid 1 # COMMIT /* xid=24 */
delete from t1;
delete from t2;
reset master;
@@ -68,13 +68,13 @@ a
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(5)
-master-bin.000001 255 Query 1 # use `test`; savepoint my_savepoint
-master-bin.000001 341 Query 1 # use `test`; insert into t1 values(6)
-master-bin.000001 429 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 524 Query 1 # use `test`; rollback to savepoint my_savepoint
-master-bin.000001 622 Query 1 # use `test`; insert into t1 values(7)
-master-bin.000001 710 Xid 1 # COMMIT /* xid=36 */
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(5)
+master-bin.000001 253 Query 1 # use `test`; savepoint my_savepoint
+master-bin.000001 338 Query 1 # use `test`; insert into t1 values(6)
+master-bin.000001 425 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 519 Query 1 # use `test`; rollback to savepoint my_savepoint
+master-bin.000001 616 Query 1 # use `test`; insert into t1 values(7)
+master-bin.000001 703 Xid 1 # COMMIT /* xid=36 */
delete from t1;
delete from t2;
reset master;
@@ -90,9 +90,9 @@ get_lock("a",10)
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(8)
-master-bin.000001 255 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 350 Query 1 # use `test`; ROLLBACK
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(8)
+master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 347 Query 1 # use `test`; ROLLBACK
delete from t1;
delete from t2;
reset master;
@@ -101,8 +101,8 @@ insert into t2 select * from t1;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(9)
-master-bin.000001 186 Xid 1 # COMMIT /* xid=59 */
-master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 185 Xid 1 # COMMIT /* xid=59 */
+master-bin.000001 212 Query 1 # use `test`; insert into t2 select * from t1
delete from t1;
delete from t2;
reset master;
@@ -112,18 +112,18 @@ insert into t2 select * from t1;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10)
-master-bin.000001 187 Xid 1 # COMMIT /* xid=65 */
-master-bin.000001 214 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 186 Xid 1 # COMMIT /* xid=65 */
+master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1
insert into t1 values(11);
commit;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10)
-master-bin.000001 187 Xid 1 # COMMIT /* xid=65 */
-master-bin.000001 214 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 309 Query 1 # use `test`; BEGIN
-master-bin.000001 378 Query 1 # use `test`; insert into t1 values(11)
-master-bin.000001 467 Xid 1 # COMMIT /* xid=67 */
+master-bin.000001 186 Xid 1 # COMMIT /* xid=65 */
+master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 307 Query 1 # use `test`; BEGIN
+master-bin.000001 375 Query 1 # use `test`; insert into t1 values(11)
+master-bin.000001 463 Xid 1 # COMMIT /* xid=67 */
alter table t2 engine=INNODB;
delete from t1;
delete from t2;
@@ -135,9 +135,9 @@ commit;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(12)
-master-bin.000001 256 Query 1 # use `test`; insert into t2 select * from t1
-master-bin.000001 351 Xid 1 # COMMIT /* xid=77 */
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(12)
+master-bin.000001 254 Query 1 # use `test`; insert into t2 select * from t1
+master-bin.000001 348 Xid 1 # COMMIT /* xid=77 */
delete from t1;
delete from t2;
reset master;
@@ -160,8 +160,8 @@ commit;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(14)
-master-bin.000001 256 Xid 1 # COMMIT /* xid=93 */
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(14)
+master-bin.000001 254 Xid 1 # COMMIT /* xid=93 */
delete from t1;
delete from t2;
reset master;
@@ -180,9 +180,9 @@ a
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; BEGIN
-master-bin.000001 167 Query 1 # use `test`; insert into t1 values(16)
-master-bin.000001 256 Query 1 # use `test`; insert into t1 values(18)
-master-bin.000001 345 Xid 1 # COMMIT /* xid=104 */
+master-bin.000001 166 Query 1 # use `test`; insert into t1 values(16)
+master-bin.000001 254 Query 1 # use `test`; insert into t1 values(18)
+master-bin.000001 342 Xid 1 # COMMIT /* xid=104 */
delete from t1;
delete from t2;
alter table t2 type=MyISAM;
diff --git a/mysql-test/r/mysqlshow.result b/mysql-test/r/mysqlshow.result
new file mode 100644
index 00000000000..a04a7081b34
--- /dev/null
+++ b/mysql-test/r/mysqlshow.result
@@ -0,0 +1,76 @@
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1),(2),(3);
+CREATE TABLE t2 (a int, b int);
+show tables;
+Tables_in_test
+t1
+t2
+select "--------------------" as "";
+
+--------------------
+Database: test
++--------+
+| Tables |
++--------+
+| t1 |
+| t2 |
++--------+
+select "---- -v ------------" as "";
+
+---- -v ------------
+Database: test
++--------+----------+
+| Tables | Columns |
++--------+----------+
+| t1 | 1 |
+| t2 | 2 |
++--------+----------+
+2 rows in set.
+
+select "---- -v -v ---------" as "";
+
+---- -v -v ---------
+Database: test
++--------+----------+------------+
+| Tables | Columns | Total Rows |
++--------+----------+------------+
+| t1 | 1 | 3 |
+| t2 | 2 | 0 |
++--------+----------+------------+
+2 rows in set.
+
+select "----- -t -----------" as "";
+
+----- -t -----------
+Database: test
++--------+------------+
+| Tables | table_type |
++--------+------------+
+| t1 | BASE TABLE |
+| t2 | BASE TABLE |
++--------+------------+
+select "---- -v -t ---------" as "";
+
+---- -v -t ---------
+Database: test
++--------+------------+----------+
+| Tables | table_type | Columns |
++--------+------------+----------+
+| t1 | BASE TABLE | 1 |
+| t2 | BASE TABLE | 2 |
++--------+------------+----------+
+2 rows in set.
+
+select "---- -v -v -t ------" as "";
+
+---- -v -v -t ------
+Database: test
++--------+------------+----------+------------+
+| Tables | table_type | Columns | Total Rows |
++--------+------------+----------+------------+
+| t1 | BASE TABLE | 1 | 3 |
+| t2 | BASE TABLE | 2 | 0 |
++--------+------------+----------+------------+
+2 rows in set.
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result
index 38b34579f03..27ebda36669 100644
--- a/mysql-test/r/ndb_autodiscover.result
+++ b/mysql-test/r/ndb_autodiscover.result
@@ -144,8 +144,8 @@ Handler_discover 1
flush tables;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL #
-t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL #
+t6 MyISAM 10 Fixed 1 260 # # # 0 NULL # # NULL # NULL #
+t7 ndbcluster 10 Fixed 1 276 # # # 0 NULL # # NULL # NULL #
show status like 'handler_discover%';
Variable_name Value
Handler_discover 2
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index 4863cb5b75e..91e52841c3b 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -378,6 +378,51 @@ a sum(b)
2 6
4 4
NULL 14
+SELECT b, a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
+b a sum(b)
+4 1 4
+NULL 1 4
+1 2 2
+2 2 4
+NULL 2 6
+1 4 4
+NULL 4 4
+NULL NULL 14
+SELECT DISTINCT b,a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
+b a sum(b)
+4 1 4
+NULL 1 4
+1 2 2
+2 2 4
+NULL 2 6
+1 4 4
+NULL 4 4
+NULL NULL 14
+ALTER TABLE t1 ADD COLUMN c INT;
+SELECT a,b,sum(c) FROM t1 GROUP BY a,b,c WITH ROLLUP;
+a b sum(c)
+1 4 NULL
+1 4 NULL
+1 NULL NULL
+2 1 NULL
+2 1 NULL
+2 2 NULL
+2 2 NULL
+2 NULL NULL
+4 1 NULL
+4 1 NULL
+4 NULL NULL
+NULL NULL NULL
+SELECT distinct a,b,sum(c) FROM t1 GROUP BY a,b,c WITH ROLLUP;
+a b sum(c)
+1 4 NULL
+1 NULL NULL
+2 1 NULL
+2 2 NULL
+2 NULL NULL
+4 1 NULL
+4 NULL NULL
+NULL NULL NULL
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES
diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result
index f7cb17a1a74..035c84431f8 100644
--- a/mysql-test/r/openssl_1.result
+++ b/mysql-test/r/openssl_1.result
@@ -10,22 +10,22 @@ select * from t1;
f1
5
delete from t1;
-ERROR 42000: Access denied for user 'ssl_user1'@'localhost' to database 'test'
+ERROR 42000: DELETE command denied to user 'ssl_user1'@'localhost' for table 't1'
select * from t1;
f1
5
delete from t1;
-ERROR 42000: Access denied for user 'ssl_user2'@'localhost' to database 'test'
+ERROR 42000: DELETE command denied to user 'ssl_user2'@'localhost' for table 't1'
select * from t1;
f1
5
delete from t1;
-ERROR 42000: Access denied for user 'ssl_user3'@'localhost' to database 'test'
+ERROR 42000: DELETE command denied to user 'ssl_user3'@'localhost' for table 't1'
select * from t1;
f1
5
delete from t1;
-ERROR 42000: Access denied for user 'ssl_user4'@'localhost' to database 'test'
+ERROR 42000: DELETE command denied to user 'ssl_user4'@'localhost' for table 't1'
delete from mysql.user where user='ssl_user%';
delete from mysql.db where user='ssl_user%';
flush privileges;
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index cd3c8e162f7..06acb72f49b 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -290,7 +290,7 @@ t2 1 t2_idx 1 b A NULL NULL NULL YES BTREE
prepare stmt4 from ' show table status from test like ''t2%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t2 MyISAM 9 Fixed 0 0 0 64424509439 1024 0 NULL # # # latin1_swedish_ci NULL
+t2 MyISAM 10 Fixed 0 0 0 64424509439 1024 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show table status from test like ''t9%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
@@ -342,6 +342,7 @@ EXAMPLE YES/NO Example storage engine
ARCHIVE YES/NO Archive storage engine
CSV YES/NO CSV storage engine
FEDERATED YES/NO Federated MySQL storage engine
+BLACKHOLE YES/NO /dev/null storage engine (anything you write to it disappears)
drop table if exists t5;
prepare stmt1 from ' drop table if exists t5 ' ;
execute stmt1 ;
@@ -483,7 +484,7 @@ prepare stmt1 from ' KILL 0 ';
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' explain select a from t1 order by b ';
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -499,7 +500,7 @@ id select_type table type possible_keys key key_len ref rows Extra
SET @arg00=1 ;
prepare stmt1 from ' explain select a from t1 where a > ? order by b ';
execute stmt1 using @arg00;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index 14b7e8a7069..37c3682cacd 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -48,7 +48,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -768,6 +768,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -1144,7 +1148,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -1799,7 +1803,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -1911,7 +1915,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1958,7 +1962,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2008,7 +2012,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2048,7 +2052,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2096,7 +2100,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2140,7 +2144,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2186,7 +2190,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2224,7 +2228,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 9a0927a9a5c..d56fcb96726 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -48,7 +48,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -768,6 +768,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -1144,7 +1148,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -1782,7 +1786,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -1894,7 +1898,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1941,7 +1945,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -1991,7 +1995,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2031,7 +2035,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2079,7 +2083,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2123,7 +2127,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2169,7 +2173,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2207,7 +2211,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 37dd8cb263e..899299fa36c 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -49,7 +49,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -769,6 +769,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -1145,7 +1149,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -1783,7 +1787,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -1895,7 +1899,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1942,7 +1946,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -1992,7 +1996,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2032,7 +2036,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2080,7 +2084,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2124,7 +2128,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2170,7 +2174,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2208,7 +2212,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 867d410ebf1..4a53fe47f3f 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -91,7 +91,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -811,6 +811,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -1187,7 +1191,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -1719,7 +1723,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -1831,7 +1835,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1878,7 +1882,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -1928,7 +1932,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1968,7 +1972,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2016,7 +2020,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2060,7 +2064,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2106,7 +2110,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2144,7 +2148,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -3100,7 +3104,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -3820,6 +3824,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -4196,7 +4204,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -4728,7 +4736,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -4840,7 +4848,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -4887,7 +4895,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -4937,7 +4945,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -4977,7 +4985,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -5025,7 +5033,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -5069,7 +5077,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -5115,7 +5123,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -5153,7 +5161,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result
index c02215ad750..8ea5b092b5e 100644
--- a/mysql-test/r/ps_6bdb.result
+++ b/mysql-test/r/ps_6bdb.result
@@ -48,7 +48,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -768,6 +768,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -1144,7 +1148,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -1782,7 +1786,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -1894,7 +1898,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1941,7 +1945,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -1991,7 +1995,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2031,7 +2035,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2079,7 +2083,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2123,7 +2127,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2169,7 +2173,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2207,7 +2211,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index f544dda798b..ec8c47031c1 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -48,7 +48,7 @@ test_sequence
------ simple select tests ------
prepare stmt1 from ' select * from t9 order by c1 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t9 t9 c1 c1 1 4 1 N 49155 0 63
def test t9 t9 c2 c2 2 6 1 Y 32768 0 63
def test t9 t9 c3 c3 9 9 1 Y 32768 0 63
@@ -768,6 +768,10 @@ prepare stmt1 from ' select a, ?, b FROM t1 outer_table where
execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;
a ? b
2 1 two
+prepare stmt1 from 'select c4 FROM t9 where
+ c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ;
+execute stmt1 using @arg01, @arg02;
+c4
prepare stmt1 from ' select a, b FROM t1 outer_table where
a = (select a from t1 where b = outer_table.b ) order by a ';
execute stmt1 ;
@@ -1144,7 +1148,7 @@ test_sequence
------ explain select tests ------
prepare stmt1 from ' explain select * from t9 ' ;
execute stmt1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32929 0 63
def select_type 253 19 6 N 1 31 8
def table 253 64 2 N 1 31 8
@@ -1782,7 +1786,7 @@ t5 CREATE TABLE `t5` (
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 3 3 N 1 1 63
@@ -1894,7 +1898,7 @@ from t9 where c1= 1 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -1941,7 +1945,7 @@ from t9 where c1= 0 ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -1991,7 +1995,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2031,7 +2035,7 @@ execute stmt1 using @my_key ;
@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2079,7 +2083,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 1 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2123,7 +2127,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08,
@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32
from t9 where c1= 0 ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
@@ -2169,7 +2173,7 @@ from t9 where c1= ?" ;
set @my_key= 1 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 1 Y 128 31 63
def @arg03 253 20 1 Y 128 31 63
@@ -2207,7 +2211,7 @@ def @arg32 253 8192 6 Y 0 31 8
set @my_key= 0 ;
execute stmt1 using @my_key ;
execute full_info ;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg01 253 20 1 Y 128 31 63
def @arg02 253 20 0 Y 128 31 63
def @arg03 253 20 0 Y 128 31 63
diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result
index 6366a2d0f8f..7f2ba568fb3 100644
--- a/mysql-test/r/rpl_change_master.result
+++ b/mysql-test/r/rpl_change_master.result
@@ -13,11 +13,11 @@ insert into t1 values(2);
stop slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 360 # # master-bin.000001 No No 0 0 184 # None 0 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 357 # # master-bin.000001 No No 0 0 183 # None 0 No #
change master to master_user='root';
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 184 # # master-bin.000001 No No 0 0 184 # None 0 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 183 # # master-bin.000001 No No 0 0 183 # None 0 No #
start slave;
select * from t1;
n
diff --git a/mysql-test/r/rpl_deadlock.result b/mysql-test/r/rpl_deadlock.result
index 809b7950add..866edb45cbb 100644
--- a/mysql-test/r/rpl_deadlock.result
+++ b/mysql-test/r/rpl_deadlock.result
@@ -8,6 +8,9 @@ create table t1 (a int not null, key(a)) engine=innodb;
create table t2 (a int not null, key(a)) engine=innodb;
create table t3 (a int) engine=innodb;
create table t4 (a int) engine=innodb;
+show variables like 'slave_transaction_retries';
+Variable_name Value
+slave_transaction_retries 10
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -20,6 +23,9 @@ t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show variables like 'slave_transaction_retries';
+Variable_name Value
+slave_transaction_retries 2
stop slave;
begin;
insert into t3 select * from t2 for update;
@@ -39,9 +45,9 @@ a
22
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 19118 # # master-bin.000001 Yes Yes 0 0 19118 # None 0 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 18911 # # master-bin.000001 Yes Yes 0 0 18911 # None 0 No #
stop slave;
-change master to master_log_pos=536;
+change master to master_log_pos=532;
begin;
select * from t2 for update;
a
@@ -57,10 +63,10 @@ a
22
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 19118 # # master-bin.000001 Yes Yes 0 0 19118 # None 0 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 18911 # # master-bin.000001 Yes Yes 0 0 18911 # None 0 No #
set global max_relay_log_size=0;
stop slave;
-change master to master_log_pos=536;
+change master to master_log_pos=532;
begin;
select * from t2 for update;
a
@@ -77,5 +83,5 @@ a
22
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 19118 # # master-bin.000001 Yes Yes 0 0 19118 # None 0 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 18911 # # master-bin.000001 Yes Yes 0 0 18911 # None 0 No #
drop table t1,t2;
diff --git a/mysql-test/r/rpl_drop_temp.result b/mysql-test/r/rpl_drop_temp.result
index e00309cac8f..04fe094ea26 100644
--- a/mysql-test/r/rpl_drop_temp.result
+++ b/mysql-test/r/rpl_drop_temp.result
@@ -10,3 +10,4 @@ create temporary table mysqltest.t2 (n int);
show status like 'Slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
+drop database mysqltest;
diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result
index a5e025078b9..a0a808ce9a8 100644
--- a/mysql-test/r/rpl_error_ignored_table.result
+++ b/mysql-test/r/rpl_error_ignored_table.result
@@ -9,7 +9,7 @@ insert into t1 values (1),(1);
ERROR 23000: Duplicate entry '1' for key 1
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 290 # # master-bin.000001 Yes Yes test.t3,test.t1,test.t2 0 0 290 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 288 # # master-bin.000001 Yes Yes test.t3,test.t1,test.t2 0 0 288 # None 0 No #
show tables like 't1';
Tables_in_test (t1)
drop table t1;
diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result
index 083db5f440d..b4e840ba271 100644
--- a/mysql-test/r/rpl_flush_log_loop.result
+++ b/mysql-test/r/rpl_flush_log_loop.result
@@ -14,4 +14,4 @@ start slave;
flush logs;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 209 # # slave-bin.000001 Yes Yes 0 0 209 # None 0 No #
+# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 208 # # slave-bin.000001 Yes Yes 0 0 208 # None 0 No #
diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result
index 4060910c079..dc11d10fab8 100644
--- a/mysql-test/r/rpl_loaddata.result
+++ b/mysql-test/r/rpl_loaddata.result
@@ -22,7 +22,7 @@ day id category name
2003-03-22 2416 a bbbbb
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
-slave-bin.000001 1292
+slave-bin.000001 1286
drop table t1;
drop table t2;
drop table t3;
@@ -33,7 +33,7 @@ set global sql_slave_skip_counter=1;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1800 # # master-bin.000001 Yes Yes 0 0 1800 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1789 # # master-bin.000001 Yes Yes 0 0 1789 # None 0 No #
set sql_log_bin=0;
delete from t1;
set sql_log_bin=1;
@@ -43,7 +43,7 @@ change master to master_user='test';
change master to master_user='root';
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1835 # # master-bin.000001 No No 0 0 1835 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1824 # # master-bin.000001 No No 0 0 1824 # None 0 No #
set global sql_slave_skip_counter=1;
start slave;
set sql_log_bin=0;
@@ -57,12 +57,25 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File
# 127.0.0.1 root MASTER_PORT 1 4 # # No No 0 0 0 # None 0 No #
reset master;
create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
-unique(day));
+unique(day)) engine=MyISAM;
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
ERROR 23000: Duplicate entry '2003-03-22' for key 1
-show master status;
-File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000001 441
+select * from t2;
+day id category name
+2003-02-22 2461 b a a a @ %  ' " a
+2003-03-22 2161 c asdf
+start slave;
+select * from t2;
+day id category name
+2003-02-22 2461 b a a a @ %  ' " a
+2003-03-22 2161 c asdf
+alter table t2 drop key day;
+delete from t2;
+load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
+terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
+'\n##\n' starting by '>' ignore 1 lines;
+ERROR 23000: Duplicate entry '2003-03-22' for key 1
+drop table t2;
drop table t2;
diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result
index 85b27dcad34..5d61746b984 100644
--- a/mysql-test/r/rpl_log.result
+++ b/mysql-test/r/rpl_log.result
@@ -20,24 +20,24 @@ drop table t1;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4
-master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001 220 Intvar 1 248 INSERT_ID=1
-master-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL)
-master-bin.000001 340 Query 1 417 use `test`; drop table t1
-master-bin.000001 417 Query 1 521 use `test`; create table t1 (word char(20) not null)
-master-bin.000001 521 Begin_load_query 1 1125 ;file_id=1;block_len=581
-master-bin.000001 1125 Execute_load_query 1 1274 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
-master-bin.000001 1274 Query 1 1351 use `test`; drop table t1
+master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 219 Intvar 1 247 INSERT_ID=1
+master-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL)
+master-bin.000001 338 Query 1 414 use `test`; drop table t1
+master-bin.000001 414 Query 1 517 use `test`; create table t1 (word char(20) not null)
+master-bin.000001 517 Begin_load_query 1 1121 ;file_id=1;block_len=581
+master-bin.000001 1121 Execute_load_query 1 1269 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
+master-bin.000001 1269 Query 1 1345 use `test`; drop table t1
show binlog events from 98 limit 1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key)
show binlog events from 98 limit 2;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001 220 Intvar 1 248 INSERT_ID=1
+master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 219 Intvar 1 247 INSERT_ID=1
show binlog events from 98 limit 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL)
+master-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL)
flush logs;
create table t5 (a int);
drop table t5;
@@ -50,23 +50,23 @@ drop table t1;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4
-master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001 220 Intvar 1 248 INSERT_ID=1
-master-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL)
-master-bin.000001 340 Query 1 417 use `test`; drop table t1
-master-bin.000001 417 Query 1 521 use `test`; create table t1 (word char(20) not null)
-master-bin.000001 521 Begin_load_query 1 1125 ;file_id=1;block_len=581
-master-bin.000001 1125 Execute_load_query 1 1274 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
-master-bin.000001 1274 Query 1 1351 use `test`; drop table t1
-master-bin.000001 1351 Rotate 1 1395 master-bin.000002;pos=4
+master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 219 Intvar 1 247 INSERT_ID=1
+master-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL)
+master-bin.000001 338 Query 1 414 use `test`; drop table t1
+master-bin.000001 414 Query 1 517 use `test`; create table t1 (word char(20) not null)
+master-bin.000001 517 Begin_load_query 1 1121 ;file_id=1;block_len=581
+master-bin.000001 1121 Execute_load_query 1 1269 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
+master-bin.000001 1269 Query 1 1345 use `test`; drop table t1
+master-bin.000001 1345 Rotate 1 1389 master-bin.000002;pos=4
show binlog events in 'master-bin.000002';
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4
-master-bin.000002 98 Query 1 185 use `test`; create table t5 (a int)
-master-bin.000002 185 Query 1 262 use `test`; drop table t5
-master-bin.000002 262 Query 1 349 use `test`; create table t1 (n int)
-master-bin.000002 349 Query 1 438 use `test`; insert into t1 values (1)
-master-bin.000002 438 Query 1 515 use `test`; drop table t1
+master-bin.000002 98 Query 1 184 use `test`; create table t5 (a int)
+master-bin.000002 184 Query 1 260 use `test`; drop table t5
+master-bin.000002 260 Query 1 346 use `test`; create table t1 (n int)
+master-bin.000002 346 Query 1 434 use `test`; insert into t1 values (1)
+master-bin.000002 434 Query 1 510 use `test`; drop table t1
show binary logs;
Log_name
master-bin.000001
@@ -79,25 +79,25 @@ slave-bin.000002
show binlog events in 'slave-bin.000001' from 4;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4
-slave-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key)
-slave-bin.000001 220 Intvar 1 248 INSERT_ID=1
-slave-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL)
-slave-bin.000001 340 Query 1 417 use `test`; drop table t1
-slave-bin.000001 417 Query 1 521 use `test`; create table t1 (word char(20) not null)
-slave-bin.000001 521 Begin_load_query 1 1125 ;file_id=1;block_len=581
-slave-bin.000001 1125 Execute_load_query 1 1283 use `test`; load data INFILE '../../var/tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1
-slave-bin.000001 1283 Query 1 1360 use `test`; drop table t1
-slave-bin.000001 1360 Query 1 1447 use `test`; create table t5 (a int)
-slave-bin.000001 1447 Query 1 1524 use `test`; drop table t5
-slave-bin.000001 1524 Rotate 2 1567 slave-bin.000002;pos=4
+slave-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key)
+slave-bin.000001 219 Intvar 1 247 INSERT_ID=1
+slave-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL)
+slave-bin.000001 338 Query 1 414 use `test`; drop table t1
+slave-bin.000001 414 Query 1 517 use `test`; create table t1 (word char(20) not null)
+slave-bin.000001 517 Begin_load_query 1 1121 ;file_id=1;block_len=581
+slave-bin.000001 1121 Execute_load_query 1 1278 use `test`; load data INFILE '../../var/tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1
+slave-bin.000001 1278 Query 1 1354 use `test`; drop table t1
+slave-bin.000001 1354 Query 1 1440 use `test`; create table t5 (a int)
+slave-bin.000001 1440 Query 1 1516 use `test`; drop table t5
+slave-bin.000001 1516 Rotate 2 1559 slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4
-slave-bin.000002 98 Query 1 185 use `test`; create table t1 (n int)
-slave-bin.000002 185 Query 1 274 use `test`; insert into t1 values (1)
-slave-bin.000002 274 Query 1 351 use `test`; drop table t1
+slave-bin.000002 98 Query 1 184 use `test`; create table t1 (n int)
+slave-bin.000002 184 Query 1 272 use `test`; insert into t1 values (1)
+slave-bin.000002 272 Query 1 348 use `test`; drop table t1
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 515 # # master-bin.000002 Yes Yes 0 0 515 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 510 # # master-bin.000002 Yes Yes 0 0 510 # None 0 No #
show binlog events in 'slave-bin.000005' from 4;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result
index 56cbe4d5ac8..fbe3b89828a 100644
--- a/mysql-test/r/rpl_max_relay_size.result
+++ b/mysql-test/r/rpl_max_relay_size.result
@@ -16,7 +16,7 @@ select @@global.max_relay_log_size;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73754 # # master-bin.000001 Yes Yes 0 0 73754 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No #
stop slave;
reset slave;
set global max_relay_log_size=(5*4096);
@@ -26,7 +26,7 @@ select @@global.max_relay_log_size;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73754 # # master-bin.000001 Yes Yes 0 0 73754 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No #
stop slave;
reset slave;
set global max_relay_log_size=0;
@@ -36,7 +36,7 @@ select @@global.max_relay_log_size;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73754 # # master-bin.000001 Yes Yes 0 0 73754 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No #
stop slave;
reset slave;
flush logs;
@@ -49,12 +49,12 @@ flush logs;
create table t1 (a int);
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73841 # # master-bin.000001 Yes Yes 0 0 73841 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73038 # # master-bin.000001 Yes Yes 0 0 73038 # None 0 No #
flush logs;
drop table t1;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73918 # # master-bin.000001 Yes Yes 0 0 73918 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73114 # # master-bin.000001 Yes Yes 0 0 73114 # None 0 No #
flush logs;
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
diff --git a/mysql-test/r/rpl_openssl.result b/mysql-test/r/rpl_openssl.result
index ad7251fd631..a4ed922d9d4 100644
--- a/mysql-test/r/rpl_openssl.result
+++ b/mysql-test/r/rpl_openssl.result
@@ -20,11 +20,11 @@ t
1
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 replssl MASTER_MYPORT 1 master-bin.000001 289 slave-relay-bin.000001 108 master-bin.000001 Yes Yes 0 0 289 108 None 0 Yes MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem #
+# 127.0.0.1 replssl MASTER_MYPORT 1 master-bin.000001 392 # # master-bin.000001 Yes Yes 0 0 392 # None 0 Yes MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem #
stop slave;
change master to master_user='root',master_password='', master_ssl=0;
start slave;
drop table t1;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 337 slave-relay-bin.000001 96 master-bin.000001 Yes Yes 0 0 337 96 None 0 No MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 468 # # master-bin.000001 Yes Yes 0 0 468 # None 0 No MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem #
diff --git a/mysql-test/r/rpl_relayrotate.result b/mysql-test/r/rpl_relayrotate.result
index 0135e90dce9..c79187e12d0 100644
--- a/mysql-test/r/rpl_relayrotate.result
+++ b/mysql-test/r/rpl_relayrotate.result
@@ -18,5 +18,5 @@ max(a)
8000
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 743188 # # master-bin.000001 Yes Yes 0 0 743188 # None 0 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 735186 # # master-bin.000001 Yes Yes 0 0 735186 # None 0 No #
drop table t1;
diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result
index 469504d06b4..8bcae3d25ad 100644
--- a/mysql-test/r/rpl_replicate_do.result
+++ b/mysql-test/r/rpl_replicate_do.result
@@ -28,4 +28,4 @@ ERROR 42S02: Table 'test.t11' doesn't exist
drop table if exists t1,t2,t11;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1668 # # master-bin.000001 Yes Yes test.t1 0 0 1668 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1658 # # master-bin.000001 Yes Yes test.t1 0 0 1658 # None 0 No #
diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result
index bd2e6dd685f..de177d12196 100644
--- a/mysql-test/r/rpl_rotate_logs.result
+++ b/mysql-test/r/rpl_rotate_logs.result
@@ -16,7 +16,7 @@ create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 60 master-bin.000001 552 # # master-bin.000001 Yes Yes 0 0 552 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 60 master-bin.000001 548 # # master-bin.000001 Yes Yes 0 0 548 # None 0 No #
select * from t1;
s
Could not break slave
@@ -57,7 +57,7 @@ master-bin.000003
insert into t2 values (65);
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 60 master-bin.000003 500 # # master-bin.000003 Yes Yes 0 0 500 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 60 master-bin.000003 496 # # master-bin.000003 Yes Yes 0 0 496 # None 0 No #
select * from t2;
m
34
@@ -79,13 +79,13 @@ master-bin.000004
master-bin.000005
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000005 2146
+master-bin.000005 2032
select * from t4;
a
testing temporary tables part 2
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_PORT 60 master-bin.000005 2146 # # master-bin.000005 Yes Yes 0 0 2146 # None 0 No #
+# 127.0.0.1 root MASTER_PORT 60 master-bin.000005 2032 # # master-bin.000005 Yes Yes 0 0 2032 # None 0 No #
lock tables t3 read;
select count(*) from t3 where n >= 4;
count(*)
diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result
index 445a330f196..a76fb87a52b 100644
--- a/mysql-test/r/rpl_temporary.result
+++ b/mysql-test/r/rpl_temporary.result
@@ -7,12 +7,12 @@ start slave;
reset master;
SET @save_select_limit=@@session.sql_select_limit;
SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100;
-ERROR HY000: Access denied; you need the SUPER privilege for this operation
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
SELECT @@session.sql_select_limit = @save_select_limit;
@@session.sql_select_limit = @save_select_limit
1
SET @@session.sql_select_limit=10, @@session.sql_log_bin=0;
-ERROR HY000: Access denied; you need the SUPER privilege for this operation
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
SELECT @@session.sql_select_limit = @save_select_limit;
@@session.sql_select_limit = @save_select_limit
1
diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result
index cd2c4d099be..85637638f99 100644
--- a/mysql-test/r/rpl_timezone.result
+++ b/mysql-test/r/rpl_timezone.result
@@ -4,21 +4,31 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
+set timestamp=100000000;
create table t1 (t timestamp);
create table t2 (t char(32));
select @@time_zone;
@@time_zone
+Japan
+select @@time_zone;
+@@time_zone
Europe/Moscow
+insert into t1 values ('20050101000000'), ('20050611093902');
set time_zone='UTC';
insert into t1 values ('20040101000000'), ('20040611093902');
select * from t1;
t
+2004-12-31 21:00:00
+2005-06-11 05:39:02
2004-01-01 00:00:00
2004-06-11 09:39:02
+set time_zone='UTC';
select * from t1;
t
-2004-01-01 03:00:00
-2004-06-11 13:39:02
+2004-12-31 21:00:00
+2005-06-11 05:39:02
+2004-01-01 00:00:00
+2004-06-11 09:39:02
delete from t1;
set time_zone='Europe/Moscow';
insert into t1 values ('20040101000000'), ('20040611093902');
@@ -26,19 +36,51 @@ select * from t1;
t
2004-01-01 00:00:00
2004-06-11 09:39:02
+set time_zone='Europe/Moscow';
+select * from t1;
+t
+2004-01-01 00:00:00
+2004-06-11 09:39:02
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+ROLLBACK;
+use test;
+SET TIMESTAMP=100000000;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
+SET @@session.sql_mode=0;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
+create table t1 (t timestamp);
+SET TIMESTAMP=100000000;
+create table t2 (t char(32));
+SET TIMESTAMP=100000000;
+SET @@session.time_zone='Europe/Moscow';
+insert into t1 values ('20050101000000'), ('20050611093902');
+SET TIMESTAMP=100000000;
+SET @@session.time_zone='UTC';
+insert into t1 values ('20040101000000'), ('20040611093902');
+SET TIMESTAMP=100000000;
+delete from t1;
+SET TIMESTAMP=100000000;
+SET @@session.time_zone='Europe/Moscow';
+insert into t1 values ('20040101000000'), ('20040611093902');
+ROLLBACK;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+delete from t1;
+set time_zone='UTC';
+load data infile '../../std_data/rpl_timezone.dat' into table t1;
select * from t1;
t
2004-01-01 00:00:00
2004-06-11 09:39:02
-show binlog events;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
-master-bin.000001 # Query 1 # use `test`; create table t1 (t timestamp)
-master-bin.000001 # Query 1 # use `test`; create table t2 (t char(32))
-master-bin.000001 # Query 1 # use `test`; SET ONE_SHOT TIME_ZONE='UTC'
-master-bin.000001 # Query 1 # use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
-master-bin.000001 # Query 1 # use `test`; delete from t1
-master-bin.000001 # Query 1 # use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
+set time_zone='UTC';
+select * from t1;
+t
+2004-01-01 00:00:00
+2004-06-11 09:39:02
+set time_zone='Europe/Moscow';
+set time_zone='Europe/Moscow';
+delete from t1;
+insert into t1 values ('20040101000000'), ('20040611093902');
set time_zone='MET';
insert into t2 (select t from t1);
select * from t1;
@@ -52,10 +94,6 @@ t
delete from t2;
set timestamp=1000072000;
insert into t2 values (current_timestamp), (current_date), (current_time);
-set timestamp=1000072000;
-select current_timestamp, current_date, current_time;
-current_timestamp current_date current_time
-2001-09-10 01:46:40 2001-09-10 01:46:40
select * from t2;
t
2001-09-09 23:46:40
@@ -73,5 +111,16 @@ t
2001-09-09 03:46:40
1000000000
set global time_zone='MET';
-ERROR HY000: Binary logging and replication forbid changing the global server time zone
+delete from t2;
+set time_zone='UTC';
+insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone));
+insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'));
+select * from t2;
+t
+2003-12-31 23:00:00
+2005-01-01 08:00:00
+select * from t2;
+t
+2003-12-31 23:00:00
+2005-01-01 08:00:00
drop table t1, t2;
diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result
index c9f9aa7b029..64efeab0145 100644
--- a/mysql-test/r/rpl_until.result
+++ b/mysql-test/r/rpl_until.result
@@ -15,14 +15,14 @@ drop table t2;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4
-master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001 220 Query 1 321 use `test`; insert into t1 values (1),(2),(3),(4)
-master-bin.000001 321 Query 1 398 use `test`; drop table t1
-master-bin.000001 398 Query 1 520 use `test`; create table t2(n int not null auto_increment primary key)
-master-bin.000001 520 Query 1 613 use `test`; insert into t2 values (1),(2)
-master-bin.000001 613 Query 1 706 use `test`; insert into t2 values (3),(4)
-master-bin.000001 706 Query 1 783 use `test`; drop table t2
-start slave until master_log_file='master-bin.000001', master_log_pos=321;
+master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 219 Query 1 319 use `test`; insert into t1 values (1),(2),(3),(4)
+master-bin.000001 319 Query 1 395 use `test`; drop table t1
+master-bin.000001 395 Query 1 516 use `test`; create table t2(n int not null auto_increment primary key)
+master-bin.000001 516 Query 1 608 use `test`; insert into t2 values (1),(2)
+master-bin.000001 608 Query 1 700 use `test`; insert into t2 values (3),(4)
+master-bin.000001 700 Query 1 776 use `test`; drop table t2
+start slave until master_log_file='master-bin.000001', master_log_pos=319;
select * from t1;
n
1
@@ -31,7 +31,7 @@ n
4
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 321 # Master master-bin.000001 321 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 319 # Master master-bin.000001 319 No #
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
select * from t1;
n
@@ -41,21 +41,21 @@ n
4
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 321 # Master master-no-such-bin.000001 291 No #
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=751;
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 319 # Master master-no-such-bin.000001 291 No #
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746;
select * from t2;
n
1
2
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 613 # Relay slave-relay-bin.000004 751 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 608 # Relay slave-relay-bin.000004 746 No #
start slave;
stop slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=783;
+start slave until master_log_file='master-bin.000001', master_log_pos=776;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 783 # Master master-bin.000001 783 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 776 # Master master-bin.000001 776 No #
start slave until master_log_file='master-bin', master_log_pos=561;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
@@ -67,6 +67,6 @@ ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UN
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave sql_thread;
-start slave until master_log_file='master-bin.000001', master_log_pos=783;
+start slave until master_log_file='master-bin.000001', master_log_pos=776;
Warnings:
Note 1254 Slave is already running
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 15cae7646f9..7c34481b519 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -315,57 +315,57 @@ insert into t2 values (1),(2);
insert into t3 values (1,1),(2,2);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values (3),(4);
insert into t2 values (3),(4);
insert into t3 values (3,3),(4,4);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values (5);
insert into t2 values (5);
insert into t3 values (5,5);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1 where a=3;
delete from t2 where b=3;
delete from t3 where a=3;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1;
delete from t2;
delete from t3;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
insert into t1 values (5);
insert into t2 values (5);
insert into t3 values (5,5);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL
delete from t1 where a=5;
delete from t2 where b=5;
delete from t3 where a=5;
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MEMORY 9 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
-t2 MEMORY 9 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
-t3 MEMORY 9 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
+t1 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
+t2 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
+t3 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL
drop table t1, t2, t3;
create database mysqltest;
show create database mysqltest;
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 1182c3d3569..c979ee34df0 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -494,4 +494,13 @@ declare continue handler for sqlstate '42x00' begin end;
begin end;
end|
ERROR 42000: Bad SQLSTATE: '42x00'
+create procedure bug6600()
+check table t1|
+ERROR 0A000: CHECK is not allowed in stored procedures
+create procedure bug6600()
+lock table t1 read|
+ERROR 0A000: LOCK is not allowed in stored procedures
+create procedure bug6600()
+unlock table t1|
+ERROR 0A000: UNLOCK is not allowed in stored procedures
drop table t1|
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index b2a1af03c9f..93884bf4cf4 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -2185,6 +2185,7 @@ Create Databases,Tables,Indexes To create new databases and tables
Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
Create temporary tables Databases To use CREATE TEMPORARY TABLE
Create view Tables To create new views
+Create user Server Admin To create new users
Delete Tables To delete existing rows
Drop Databases,Tables To drop databases, tables, and views
Execute Functions,Procedures To execute stored routines
@@ -2238,6 +2239,7 @@ Create Databases,Tables,Indexes To create new databases and tables
Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
Create temporary tables Databases To use CREATE TEMPORARY TABLE
Create view Tables To create new views
+Create user Server Admin To create new users
Delete Tables To delete existing rows
Drop Databases,Tables To drop databases, tables, and views
Execute Functions,Procedures To execute stored routines
@@ -2777,23 +2779,4 @@ a
3.2000
drop procedure bug8937|
delete from t1|
-drop procedure if exists bug6600|
-drop table if exists t3|
-drop view if exists v1|
-create table t3 (s1 decimal(31,30))|
-create view v1 as select * from t3|
-create procedure bug6600()
-check table v1|
-call bug6600()|
-Table Op Msg_type Msg_text
-test.v1 check status OK
-call bug6600()|
-Table Op Msg_type Msg_text
-test.v1 check status OK
-call bug6600()|
-Table Op Msg_type Msg_text
-test.v1 check status OK
-drop procedure bug6600|
-drop view v1|
-drop table t3|
drop table t1,t2;
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index c3d2533a2e3..47dbb87b990 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -1,3 +1,4 @@
+set @org_mode=@@sql_mode;
set @@sql_mode='ansi,traditional';
select @@sql_mode;
@@sql_mode
@@ -209,8 +210,12 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2004-10-00 15:30:00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2004-09-31 15:30:00' for column 'col1' at row 1
+INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '32.10.2004 15.30' for function str_to_time
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2003-02-29 15:30:00' for column 'col1' at row 1
+INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_time
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
@@ -220,8 +225,14 @@ INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col2' at row 1
+INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '32.10.2004 15.30' for function str_to_time
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2003-02-29 15:30:00' for column 'col2' at row 1
+INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_time
+INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
+ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col2' at row 1
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
@@ -230,8 +241,12 @@ INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col3' at row 1
+INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '32.10.2004 15.30' for function str_to_time
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2003-02-29 15:30:00' for column 'col3' at row 1
+INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_time
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col3' at row 1
drop table t1;
@@ -1030,3 +1045,48 @@ ERROR 22001: Data too long for column 'tinyblobcol' at row 1
select * from t1;
charcol varcharcol binarycol varbinarycol tinytextcol tinyblobcol
drop table t1;
+set sql_mode='traditional';
+create table t1 (col1 datetime);
+insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
+ERROR 22007: Truncated incorrect datetime value: '31.10.2004 15.30 abc'
+insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '32.10.2004 15.30' for function str_to_time
+insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
+ERROR HY000: Incorrect time value: '22:22:33 AM' for function str_to_time
+insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
+ERROR HY000: Incorrect time value: 'abc' for function str_to_time
+set sql_mode='';
+insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '31.10.2004 15.30 abc'
+insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+Warnings:
+Error 1411 Incorrect datetime value: '32.10.2004 15.30' for function str_to_time
+insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
+Warnings:
+Error 1411 Incorrect time value: '22:22:33 AM' for function str_to_time
+insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
+Warnings:
+Error 1411 Incorrect time value: 'abc' for function str_to_time
+insert into t1 values(STR_TO_DATE('31.10.2004 15.30','%d.%m.%Y %H.%i'));
+insert into t1 values(STR_TO_DATE('2004.12.12 11:22:33 AM','%Y.%m.%d %r'));
+insert into t1 values(STR_TO_DATE('2004.12.12 10:22:59','%Y.%m.%d %T'));
+select * from t1;
+col1
+2004-10-31 15:30:00
+NULL
+NULL
+NULL
+2004-10-31 15:30:00
+2004-12-12 11:22:33
+2004-12-12 10:22:59
+set sql_mode='traditional';
+select count(*) from t1 where STR_TO_DATE('2004.12.12 10:22:61','%Y.%m.%d %T') IS NULL;
+count(*)
+7
+Warnings:
+Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time
+Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time
+Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time
+drop table t1;
+set sql_mode=@org_mode;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 738c011012d..036d1631592 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1883,6 +1883,380 @@ SELECT a FROM t1 WHERE a <> ALL ( SELECT a FROM t1 WHERE b = 2 );
a
1
3
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 HAVING a = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 HAVING a = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 HAVING a = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 HAVING a = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 HAVING a = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 HAVING a = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 HAVING a = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 HAVING a = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) = ALL (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) <> ANY (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) = ANY (SELECT a FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 2 column(s)
+SELECT a FROM t1 WHERE a = ANY (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) = ANY (SELECT a,2 FROM t1 WHERE b = 2);
+a
+SELECT a FROM t1 WHERE (1,2) <> ALL (SELECT a FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 2 column(s)
+SELECT a FROM t1 WHERE a <> ALL (SELECT a,2 FROM t1 WHERE b = 2);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT a FROM t1 WHERE (1,2) <> ALL (SELECT a,2 FROM t1 WHERE b = 2);
+a
+1
+2
+3
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 WHERE b = 2);
+a
+2
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 WHERE b = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 WHERE b = 2 UNION SELECT a,1 FROM t1 WHERE b = 2);
+a
+2
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 WHERE b = 2 UNION SELECT a,1 FROM t1 WHERE b = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 HAVING a = 2 UNION SELECT a,1 FROM t1 HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 HAVING a = 2 UNION SELECT a,1 FROM t1 HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 group by a HAVING a = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 group by a HAVING a = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 group by a HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 group by a HAVING a = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 group by a HAVING a = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 group by a HAVING a = 2);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 group by a HAVING a = 2);
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 group by a HAVING a = 2);
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 group by a HAVING a = 2);
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 group by a HAVING a = 2);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 group by a HAVING a = 2);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 group by a HAVING a = 2);
+a
+1
+3
+SELECT concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a > t1.a), '-') from t1 a;
+concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a > t1.a), '-')
+0-
+0-
+1-
+SELECT concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a < t1.a), '-') from t1 a;
+concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a < t1.a), '-')
+1-
+0-
+0-
+SELECT concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a = t1.a), '-') from t1 a;
+concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a = t1.a), '-')
+0-
+1-
+0-
+DROP TABLE t1;
+CREATE TABLE t1 ( a double, b double );
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = 2e0);
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = 2e0);
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = 2e0);
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = 2e0);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = 2e0);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = 2e0);
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = 2e0);
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = 2e0);
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = 2e0);
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = 2e0);
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = 2e0);
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = 2e0);
+a
+1
+3
+DROP TABLE t1;
+CREATE TABLE t1 ( a char(1), b char(1));
+INSERT INTO t1 VALUES ('1','1'),('2','2'),('3','3');
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = '2');
+a
+3
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = '2');
+a
+1
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = '2');
+a
+2
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = '2');
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = '2');
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = '2');
+a
+1
+3
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = '2');
+a
+3
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = '2');
+a
+1
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = '2');
+a
+2
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = '2');
+a
+2
+3
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = '2');
+a
+1
+2
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = '2');
+a
+1
+3
DROP TABLE t1;
create table t1 (a int, b int);
insert into t1 values (1,2),(3,4);
@@ -2138,7 +2512,7 @@ drop table t1;
create table t1 (a1 int);
create table t2 (b1 int);
select * from t1 where a2 > any(select b1 from t2);
-ERROR 42S22: Unknown column 'a2' in 'scalar IN/ALL/ANY subquery'
+ERROR 42S22: Unknown column 'a2' in 'IN/ALL/ANY subquery'
select * from t1 where a1 > any(select b1 from t2);
a1
drop table t1,t2;
@@ -2277,7 +2651,63 @@ pass userid parentid parentgroup childid groupname grouptypeid crse categoryid c
1 5141 12 group2 12 group2 5 1 1 87 Oct04
1 5141 12 group2 12 group2 5 1 2 88 Oct04
1 5141 12 group2 12 group2 5 1 2 89 Oct04
-drop table if exists t1, t2, t3, t4, t5;
+drop table t1, t2, t3, t4, t5;
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+SELECT 1 FROM t1 WHERE (SELECT 1) in (SELECT 1);
+1
+1
+1
+1
+drop table t1;
+create table t1 (a int);
+create table t2 (a int);
+insert into t1 values (1),(2);
+insert into t2 values (0),(1),(2),(3);
+select a from t2 where a in (select a from t1);
+a
+1
+2
+select a from t2 having a in (select a from t1);
+a
+1
+2
+prepare stmt1 from "select a from t2 where a in (select a from t1)";
+execute stmt1;
+a
+1
+2
+execute stmt1;
+a
+1
+2
+deallocate prepare stmt1;
+prepare stmt1 from "select a from t2 having a in (select a from t1)";
+execute stmt1;
+a
+1
+2
+execute stmt1;
+a
+1
+2
+deallocate prepare stmt1;
+drop table t1, t2;
+create table t1 (a int, b int);
+insert into t1 values (1,2);
+select 1 = (select * from t1);
+ERROR 21000: Operand should contain 1 column(s)
+select (select * from t1) = 1;
+ERROR 21000: Operand should contain 2 column(s)
+select (1,2) = (select a from t1);
+ERROR 21000: Operand should contain 2 column(s)
+select (select a from t1) = (1,2);
+ERROR 21000: Operand should contain 1 column(s)
+select (1,2,3) = (select * from t1);
+ERROR 21000: Operand should contain 3 column(s)
+select (select * from t1) = (1,2,3);
+ERROR 21000: Operand should contain 2 column(s)
+drop table t1;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index 532f0eca014..40a9c3b9af5 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -96,6 +96,7 @@ user CREATE TABLE `user` (
`Show_view_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
`Create_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
`Alter_routine_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_user_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
`ssl_type` enum('','ANY','X509','SPECIFIED') character set utf8 NOT NULL default '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index dde50a1ee00..c926ebb6878 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -36,7 +36,7 @@ select 0 + b'1000000000000001';
32769
drop table if exists t1;
create table t1 (a bit(65));
-ERROR 42000: Column length too big for column 'a' (max = 64); use BLOB instead
+ERROR 42000: Column length too big for column 'a' (max = 64); use BLOB or TEXT instead
create table t1 (a bit(0));
show create table t1;
Table Create Table
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index a9b90617bcc..3316f9bb6db 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -33,11 +33,11 @@ t4 CREATE TABLE `t4` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2,t3,t4;
CREATE TABLE t1 (a char(257) default "hello");
-ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB instead
+ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t2 (a char(256));
-ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB instead
+ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t1 (a varchar(70000) default "hello");
-ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB instead
+ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
CREATE TABLE t2 (a blob default "hello");
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
drop table if exists t1,t2;
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index 2d5c2d2ac97..6a0c0090e79 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -693,3 +693,58 @@ SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1);
EMPNUM
E1
DROP TABLE t1,t2;
+create table t1 (d decimal(64,0));
+insert into t1 values (1);
+select * from t1;
+d
+1
+drop table t1;
+create table t1 (d decimal(64,99));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `d` decimal(64,30) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values (1);
+select * from t1;
+d
+1.000000000000000000000000000000
+drop table t1;
+create table t1 (d decimal(10,12));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `d` decimal(13,12) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (d decimal(5));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `d` decimal(5,0) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (d decimal);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `d` decimal(10,0) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (d decimal(65,0));
+ERROR 42000: Incorrect column specifier for column 'd'
+CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
+INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
+(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
+(2, 30.40, 30.40), (3, 37.00, 7.40), (3, -29.60, 0.00),
+(4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00),
+(5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20),
+(6, 0.00, 0.00), (6, -51.40, 0.00);
+SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b;
+i a b
+6 -51.40 0.00
+SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i
+HAVING a <> b;
+i a b
+6 -51.40 0.00
+drop table t1;
diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result
index d4496f454a0..f6cfa7f2733 100644
--- a/mysql-test/r/type_enum.result
+++ b/mysql-test/r/type_enum.result
@@ -1730,7 +1730,7 @@ insert into t1 values ('Y');
alter table t1 add b set ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin;
alter table t1 add c enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin;
select * from t1;
-Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 254 1 1 Y 384 0 8
def test t1 t1 b b 254 3 0 Y 2176 0 8
def test t1 t1 c c 254 1 0 Y 384 0 8
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index bb5f9e7f3b0..330caf68293 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -180,14 +180,6 @@ t1 CREATE TABLE `t1` (
`-(-1.1)` decimal(7,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
-CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
-INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
-update t1 set b=a;
-SELECT * FROM t1;
-a b
-1.1 1.100
-2.1 2.100
-DROP TABLE t1;
set session sql_mode='traditional';
select 1e10/0e0;
1e10/0e0
@@ -847,3 +839,6 @@ Error 1365 Division by 0
INSERT INTO Sow6_2f VALUES ('a59b');
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f;
+select 10.3330000000000/12.34500000;
+10.3330000000000/12.34500000
+0.8370190360469825840421223160000
diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result
index 1c2653bd225..d2fe843a68b 100644
--- a/mysql-test/r/type_varchar.result
+++ b/mysql-test/r/type_varchar.result
@@ -376,3 +376,10 @@ explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL 2 Using where; Using filesort
drop table t1;
+create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol));
+insert into t1 values ('test', 'something');
+update t1 set othercol='somethingelse' where pkcol='test';
+select * from t1;
+pkcol othercol
+test somethingelse
+drop table t1;
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 663793e0b5e..8c8e12d8838 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -565,7 +565,7 @@ a
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `a` decimal(20,1) NOT NULL default '0.0'
+ `a` decimal(19,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text);
@@ -732,7 +732,7 @@ tetetetetest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `dt` blob
+ `dt` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT sv from t2 UNION select b from t2;
@@ -755,7 +755,7 @@ tetetetetest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `i` blob
+ `i` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT sv from t2 UNION select tx from t2;
@@ -766,7 +766,7 @@ teeeeeeeeeeeest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `sv` text
+ `sv` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT b from t2 UNION select tx from t2;
@@ -1195,3 +1195,43 @@ a b
2 b
3 c
drop table t1;
+set @val:=6;
+select concat('value is: ', @val) union select 'some text';
+concat('value is: ', @val)
+value is: 6
+some text
+CREATE TABLE t1 (
+a ENUM('ä','ö','ü') character set utf8 not null default 'ü',
+b ENUM("one", "two") character set utf8,
+c ENUM("one", "two")
+);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` enum('ä','ö','ü') character set utf8 NOT NULL default 'ü',
+ `b` enum('one','two') character set utf8 default NULL,
+ `c` enum('one','two') default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('ä', 'one', 'one'), ('ö', 'two', 'one'), ('ü', NULL, NULL);
+create table t2 select NULL union select a from t1;
+show columns from t2;
+Field Type Null Key Default Extra
+NULL enum('ä','ö','ü') YES NULL
+drop table t2;
+create table t2 select a from t1 union select NULL;
+show columns from t2;
+Field Type Null Key Default Extra
+a enum('ä','ö','ü') YES NULL
+drop table t2;
+create table t2 select a from t1 union select a from t1;
+show columns from t2;
+Field Type Null Key Default Extra
+a varchar(1) NO
+drop table t2;
+create table t2 select a from t1 union select c from t1;
+ERROR HY000: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation 'UNION'
+create table t2 select a from t1 union select b from t1;
+show columns from t2;
+Field Type Null Key Default Extra
+a varchar(3) YES NULL
+drop table t2, t1;
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 4b2eef20a6b..bd261751938 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -204,3 +204,10 @@ set @var= NULL ;
select FIELD( @var,'1it','Hit') as my_column;
my_column
0
+select @v, coercibility(@v);
+@v coercibility(@v)
+NULL 2
+set @v1=null, @v2=1, @v3=1.1, @v4=now();
+select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
+coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4)
+2 2 2 2
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 908709efba3..e3b6c2c5917 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -520,3 +520,11 @@ SHOW VARIABLES LIKE 'table_cache';
Variable_name Value
table_cache 1
SET GLOBAL table_cache=DEFAULT;
+create table t1 (a int);
+select a into @x from t1;
+Warnings:
+Warning 1329 No data to FETCH
+show warnings;
+Level Code Message
+Warning 1329 No data to FETCH
+drop table t1;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 75459bd960b..c5fe4bf8565 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -149,7 +149,7 @@ v5 VIEW
v6 VIEW
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MyISAM 9 Fixed 5 9 45 38654705663 1024 0 NULL # # NULL latin1_swedish_ci NULL
+t1 MyISAM 10 Fixed 5 9 45 38654705663 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
v2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
v3 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
@@ -874,7 +874,7 @@ select * from v1;
col1
describe v1;
Field Type Null Key Default Extra
-col1 char(2) YES NULL
+col1 varchar(2) YES NULL
drop view v1;
drop table `t1a``b`;
create table t1 (col1 char(5),col2 char(5));
@@ -1115,7 +1115,7 @@ select * from v1;
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s)
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MyISAM 9 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
+t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL # NULL NULL NULL # # NULL NULL NULL NULL View 'test.v1' references invalid table(s) or column(s) or function(s)
drop view v1;
drop table t1;
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 222638f64bb..d143b66ae94 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -142,6 +142,25 @@ Warning 1265 Data truncated for column 'b' at row 10
select @@warning_count;
@@warning_count
50
+set max_error_count=0;
+show variables like 'max_error_count';
+Variable_name Value
+max_error_count 0
+update t1 set b='hi';
+Warnings:
+select @@warning_count;
+@@warning_count
+50
+show warnings;
+Level Code Message
+set max_error_count=65535;
+show variables like 'max_error_count';
+Variable_name Value
+max_error_count 65535
+set max_error_count=10;
+show variables like 'max_error_count';
+Variable_name Value
+max_error_count 10
drop table t1;
create table t1 (id int) engine=isam;
Warnings:
diff --git a/mysql-test/std_data/rpl_timezone.dat b/mysql-test/std_data/rpl_timezone.dat
new file mode 100644
index 00000000000..2df8a39f1e3
--- /dev/null
+++ b/mysql-test/std_data/rpl_timezone.dat
@@ -0,0 +1,2 @@
+20040101000000
+20040611093902
diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test
new file mode 100644
index 00000000000..052574d6921
--- /dev/null
+++ b/mysql-test/t/blackhole.test
@@ -0,0 +1,99 @@
+#
+# Simple test for blackhole example
+# Taken from the select test
+#
+-- source include/have_blackhole.inc
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (
+ Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
+) ENGINE=blackhole;
+
+INSERT INTO t1 VALUES (9410,9412);
+
+select period from t1;
+select * from t1;
+select t1.* from t1;
+
+#
+# Create test table
+#
+
+CREATE TABLE t2 (
+ auto int NOT NULL auto_increment,
+ fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
+ companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
+ fld3 char(30) DEFAULT '' NOT NULL,
+ fld4 char(35) DEFAULT '' NOT NULL,
+ fld5 char(35) DEFAULT '' NOT NULL,
+ fld6 char(4) DEFAULT '' NOT NULL,
+ primary key (auto)
+) ENGINE=blackhole;
+
+INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
+INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
+--enable_query_log
+
+#
+# Search with a key
+#
+
+select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
+select fld3 from t2 where fld3 like "%cultivation" ;
+
+#
+# Search with a key using sorting and limit the same time
+#
+
+select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
+select fld3,companynr from t2 where companynr = 58 order by fld3;
+
+select fld3 from t2 order by fld3 desc limit 10;
+select fld3 from t2 order by fld3 desc limit 5;
+select fld3 from t2 order by fld3 desc limit 5,5;
+
+#
+# Search with a key having a constant with each unique key.
+# The table is read directly with read-next on fld3
+#
+
+select t2.fld3 from t2 where fld3 = 'honeysuckle';
+select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
+select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
+select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
+select t2.fld3 from t2 where fld3 LIKE 'h%le';
+
+select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
+select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
+
+#
+# Test sorting with a used key (there is no need for sorting)
+#
+
+select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
+select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
+
+
+# Test for fulltext
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
+INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
+ ('Full-text indexes', 'are called collections'),
+ ('Only MyISAM tables','support collections'),
+ ('Function MATCH ... AGAINST()','is used to do a search'),
+ ('Full-text search in MySQL', 'implements vector space model');
+SHOW INDEX FROM t1;
+
+# nl search
+
+select * from t1 where MATCH(a,b) AGAINST ("collections");
+explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
+select * from t1 where MATCH(a,b) AGAINST ("indexes");
+select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
+select * from t1 where MATCH(a,b) AGAINST ("only");
+
+drop table if exists t1,t2;
diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test
index 8b75123ca32..b5cf610d941 100644
--- a/mysql-test/t/ctype_big5.test
+++ b/mysql-test/t/ctype_big5.test
@@ -16,3 +16,12 @@ SET collation_connection='big5_chinese_ci';
-- source include/ctype_filesort.inc
SET collation_connection='big5_bin';
-- source include/ctype_filesort.inc
+
+#
+# Bugs#9357: TEXT columns break string with special word in BIG5 charset.
+#
+SET NAMES big5;
+CREATE TABLE t1 (a text) character set big5;
+INSERT INTO t1 VALUES ('ùØ');
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_cp1251-master.opt b/mysql-test/t/ctype_cp1251-master.opt
deleted file mode 100644
index af089d9f176..00000000000
--- a/mysql-test/t/ctype_cp1251-master.opt
+++ /dev/null
@@ -1,2 +0,0 @@
---default-character-set=cp1251 --new
-
diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test
index 2d670ec3607..76873e6fa0e 100644
--- a/mysql-test/t/ctype_cp1251.test
+++ b/mysql-test/t/ctype_cp1251.test
@@ -10,7 +10,7 @@ SET NAMES cp1251;
# Test problem with LEFT() (Bug #514)
#
-create table t1 (a varchar(10) not null);
+create table t1 (a varchar(10) not null) character set cp1251;
insert into t1 values ("a"),("ab"),("abc");
select * from t1;
select a, left(a,1) as b from t1;
@@ -21,7 +21,7 @@ drop table t1;
#
# Test of binary and upper/lower
#
-create table t1 (a char(15) binary, b binary(15));
+create table t1 (a char(15) binary, b binary(15)) character set cp1251;
insert into t1 values ('aaa','bbb'),('AAA','BBB');
select upper(a),upper(b) from t1;
select lower(a),lower(b) from t1;
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 151e2cf5464..7ca2685a6e7 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -414,3 +414,12 @@ CREATE TABLE t1 (Field1 int(10) unsigned default '0');
INSERT INTO t1 VALUES ('-1');
DROP TABLE t1;
SET NAMES latin1;
+
+#
+# Conversion from an UCS2 string to a decimal column
+#
+CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
+INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
+update t1 set b=a;
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 2c498cd1922..194354f8718 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -707,3 +707,14 @@ drop table t1;
# Bug#8385: utf8_general_ci treats Cyrillic letters I and SHORT I as the same
#
select convert(_koi8r'É' using utf8) < convert(_koi8r'Ê' using utf8);
+
+#
+# Bugs#5980: NULL requires a characterset in a union
+#
+set names latin1;
+create table t1 (a varchar(10)) character set utf8;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+drop table t1;
+select repeat(_utf8'+',3) as h union select NULL;
+select ifnull(NULL, _utf8'string');
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index 800e5880b09..e8bd8965b96 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -122,6 +122,7 @@ SET datetime_format=default;
--disable_ps_protocol
select str_to_date(concat('15-01-2001',' 2:59:58.999'),
concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
+select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
--enable_ps_protocol
create table t1 (date char(30), format char(30) not null);
diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test
index db7e712bd5f..6a0e0bdac79 100644
--- a/mysql-test/t/federated.test
+++ b/mysql-test/t/federated.test
@@ -125,6 +125,7 @@ SELECT * FROM federated.t1;
DELETE FROM federated.t1;
DROP TABLE IF EXISTS federated.t1;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.`t1%` (
`id` int(20) NOT NULL,
`name` varchar(32) NOT NULL default ''
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 2041c776423..8bf36431587 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -377,6 +377,20 @@ insert into t1 values (null);
select charset(a), collation(a), coercibility(a) from t1;
drop table t1;
select charset(null), collation(null), coercibility(null);
+#
+# Make sure OUTER JOIN is not replaced with a regular joun
+#
+CREATE TABLE t1 (a int, b int);
+CREATE TABLE t2 (a int, b int);
+INSERT INTO t1 VALUES (1,1),(2,2);
+INSERT INTO t2 VALUES (2,2),(3,3);
+select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
+where collation(t2.a) = _utf8'binary' order by t1.a,t2.a;
+select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
+where charset(t2.a) = _utf8'binary' order by t1.a,t2.a;
+select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
+where coercibility(t2.a) = 2 order by t1.a,t2.a;
+DROP TABLE t1, t2;
#
# test for SUBSTR
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 7fff165e057..bbfef25bcfe 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -38,4 +38,6 @@ create table t1 (a char(10)) character set latin1;
select * from t1 where a=version();
select * from t1 where a=database();
select * from t1 where a=user();
+insert into t1 values ('a');
+select left(concat(a,version()),1) from t1;
drop table t1;
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index f86cf2a1db7..3bda5716d26 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -9,6 +9,7 @@ SET NAMES binary;
# prepare playground before tests
--disable_warnings
drop database if exists mysqltest;
+drop database if exists mysqltest_1;
--enable_warnings
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
@@ -18,6 +19,7 @@ flush privileges;
grant all privileges on `my\_1`.* to mysqltest_1@localhost with grant option;
+grant create user on *.* to mysqltest_1@localhost;
create user mysqltest_2@localhost;
connect (user_a,localhost,mysqltest_1,,);
connection user_a;
@@ -30,7 +32,6 @@ grant update on mysql.* to mysqltest_1@localhost;
connect (user_b,localhost,mysqltest_1,,);
connection user_b;
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
---error 1211
grant select on `my\_1`.* to mysqltest_3@localhost;
disconnect user_b;
connection default;
@@ -52,11 +53,10 @@ flush privileges;
#
grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
+grant create user on *.* to mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,);
connection user1;
select current_user();
-select current_user;
---error 1211
grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
--error 1044
grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
@@ -66,15 +66,16 @@ grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
#
set @@sql_mode='NO_AUTO_CREATE_USER';
select @@sql_mode;
---error 1211
+#
+# GRANT without IDENTIFIED BY does not create new users
+#
+--error 1133
grant select on `my\_1`.* to mysqltest_4@localhost with grant option;
---error 1211
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'
with grant option;
disconnect user1;
connection default;
show grants for mysqltest_1@localhost;
---error 1141
show grants for mysqltest_2@localhost;
--error 1141
show grants for mysqltest_3@localhost;
@@ -82,6 +83,24 @@ delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
+#
+# wild_compare part two - acl_cache
+#
+create database mysqltest_1;
+grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option;
+connect (user2,localhost,mysqltest_1,,);
+connection user2;
+select current_user();
+show databases;
+--error 1044
+grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;
+disconnect user2;
+connection default;
+show grants for mysqltest_1@localhost;
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+drop database mysqltest_1;
+flush privileges;
#
# Bug #6173: One can circumvent missing UPDATE privilege if he has SELECT
@@ -116,9 +135,9 @@ create table t1 (a int, b int);
grant select (a) on t1 to mysqltest_1@localhost with grant option;
connect (mrugly, localhost, mysqltest_1,,mysqltest);
connection mrugly;
---error 1211
+--error 1143
grant select (a,b) on t1 to mysqltest_2@localhost;
---error 1211
+--error 1142
grant select on t1 to mysqltest_3@localhost;
disconnect mrugly;
@@ -177,10 +196,6 @@ select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
show grants for 'mysqltest_1';
drop user 'mysqltest_1', 'mysqltest_3';
-#
-# Grant must not create user
---error 1211
-grant all on test.t1 to 'mysqltest_1';
--error 1396
drop user 'mysqltest_1';
#
@@ -248,36 +263,35 @@ show grants for '%@b'@'b';
show grants for '%@a'@'a';
drop user '%@a'@'a';
#
-# USAGE WITH GRANT OPTION is sufficient.
+# CREATE USER privilege is enough
+#
create user mysqltest_2@localhost;
-grant usage on *.* to mysqltest_2@localhost with grant option;
-connect (user2,localhost,mysqltest_2,,);
-connection user2;
+grant create user on *.* to mysqltest_2@localhost;
+connect (user3,localhost,mysqltest_2,,);
+connection user3;
--error 1142
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
drop user mysqltest_B@'%';
-disconnect user2;
+disconnect user3;
connection default;
drop user mysqltest_2@localhost;
#
-# ALL PRIVILEGES without GRANT OPTION is not sufficient.
+# INSERT/UPDATE/DELETE is ok too
create user mysqltest_3@localhost;
-grant all privileges on mysql.* to mysqltest_3@localhost;
-connect (user3,localhost,mysqltest_3,,);
-connection user3;
+grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost;
+connect (user4,localhost,mysqltest_3,,);
+connection user4;
+show grants;
+--error 1142
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
insert into mysql.user set host='%', user='mysqltest_B';
---error 1044
create user mysqltest_A@'%';
---error 1044
rename user mysqltest_B@'%' to mysqltest_C@'%';
---error 1044
-drop user mysqltest_B@'%';
-disconnect user3;
+drop user mysqltest_C@'%';
+disconnect user4;
connection default;
-drop user mysqltest_B@'%';
drop user mysqltest_3@localhost;
#
# Bug #3309: Test IP addresses with netmask
diff --git a/mysql-test/t/grant3-master.opt b/mysql-test/t/grant3-master.opt
new file mode 100644
index 00000000000..4b11f5902c1
--- /dev/null
+++ b/mysql-test/t/grant3-master.opt
@@ -0,0 +1 @@
+--safe-user-create
diff --git a/mysql-test/t/grant3.test b/mysql-test/t/grant3.test
new file mode 100644
index 00000000000..1488f910bc8
--- /dev/null
+++ b/mysql-test/t/grant3.test
@@ -0,0 +1,33 @@
+# Test of GRANT commands
+
+SET NAMES binary;
+connect (master,localhost,root,,);
+connection master;
+
+# Cleanup
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+delete from mysql.tables_priv where user like 'mysqltest\_%';
+delete from mysql.columns_priv where user like 'mysqltest\_%';
+flush privileges;
+
+create user mysqltest_1@localhost;
+grant create user on *.* to mysqltest_1@localhost;
+grant select on `my\_1`.* to mysqltest_1@localhost with grant option;
+connect (user_a,localhost,mysqltest_1,,);
+connection user_a;
+--error 1410
+grant select on `my\_1`.* to mysqltest_2@localhost;
+create user mysqltest_2@localhost;
+disconnect user_a;
+connection default;
+
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+delete from mysql.tables_priv where user like 'mysqltest\_%';
+delete from mysql.columns_priv where user like 'mysqltest\_%';
+flush privileges;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index afd479c520e..46e58cd00fd 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -489,3 +489,29 @@ select a,sum(b) from t1 where a=1 group by c having a=1;
select a as d,sum(b) from t1 where a=1 group by c having d=1;
select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0;
drop table t1;
+
+# Test for BUG#9213 GROUP BY query on utf-8 key returns wrong results
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9);
+create table t2 (
+ a int,
+ b varchar(200) NOT NULL,
+ c varchar(50) NOT NULL,
+ d varchar(100) NOT NULL,
+ primary key (a,b(132),c,d),
+ key a (a,b)
+) charset=utf8;
+
+insert into t2 select
+ x3.a, -- 3
+ concat('val-', x3.a + 3*x4.a), -- 12
+ concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120
+ concat('val-', @a + 120*D.a)
+from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4;
+
+delete from t2 where a = 2 and b = 'val-2' order by a,b,c,d limit 30;
+
+explain select c from t2 where a = 2 and b = 'val-2' group by c;
+select c from t2 where a = 2 and b = 'val-2' group by c;
+drop table t1,t2;
+
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 209755a0dcc..f4d47fa68aa 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -403,6 +403,7 @@ while ($tab_count)
--disable_result_log
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log
+SELECT count(*) FROM INFORMATION_SCHEMA.TABLES;
let $tab_count= 65;
while ($tab_count)
{
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index 8a9d96d4946..8492a2a2f8e 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -27,8 +27,9 @@ kill @id;
--sleep 5
# verify that con1 is doning a reconnect
connection con1;
-ping
-ping
+--ping
+--ping
+select ((@id := kill_id) - kill_id) from t1;
select @id != connection_id();
#make sure the server is still alive
diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test
index d11cb62b04e..ebd58ef4ebb 100644
--- a/mysql-test/t/metadata.test
+++ b/mysql-test/t/metadata.test
@@ -34,4 +34,17 @@ select t1.id, t1.data, t2.data from t1, t2 where t1.id = t2.id order by t1.id;
select t1.id from t1 union select t2.id from t2;
drop table t1,t2;
+#
+# variables union and derived tables metadata test
+#
+create table t1 ( a int, b varchar(30), primary key(a));
+insert into t1 values (1,'one');
+insert into t1 values (2,'two');
+set @arg00=1 ;
+select @arg00 FROM t1 where a=1 union distinct select 1 FROM t1 where a=1;
+select * from (select @arg00) aaa;
+select 1 union select 1;
+select * from (select 1 union select 1) aaa;
+drop table t1;
+
--disable_metadata
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index df3b0acaa11..0988416942c 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -60,7 +60,7 @@ select "--- --database --" as "";
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=232 $MYSQL_TEST_DIR/var/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=231 $MYSQL_TEST_DIR/var/log/master-bin.000002
# These are tests for remote binlog.
# They should return the same as previous test.
@@ -92,7 +92,7 @@ select "--- --database --" as "";
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=232 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=231 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# Bug#7853 (mysqlbinlog does not accept input from stdin)
--disable_query_log
diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test
index 74ddf4e2be4..cbde6c93210 100644
--- a/mysql-test/t/mysqlbinlog2.test
+++ b/mysql-test/t/mysqlbinlog2.test
@@ -46,11 +46,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQL_TEST_DIR/var/log/master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=600 $MYSQL_TEST_DIR/var/log/master-bin.000001
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -75,7 +75,7 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
@@ -102,11 +102,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -129,7 +129,7 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
diff --git a/mysql-test/t/mysqlshow.test b/mysql-test/t/mysqlshow.test
new file mode 100644
index 00000000000..8da29b91819
--- /dev/null
+++ b/mysql-test/t/mysqlshow.test
@@ -0,0 +1,20 @@
+#
+## Bug #5036 mysqlshow is missing a column
+#
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1),(2),(3);
+CREATE TABLE t2 (a int, b int);
+show tables;
+select "--------------------" as "";
+--exec $MYSQL_SHOW test
+select "---- -v ------------" as "";
+--exec $MYSQL_SHOW test -v
+select "---- -v -v ---------" as "";
+--exec $MYSQL_SHOW test -v -v
+select "----- -t -----------" as "";
+--exec $MYSQL_SHOW test -t
+select "---- -v -t ---------" as "";
+--exec $MYSQL_SHOW test -v -t
+select "---- -v -v -t ------" as "";
+--exec $MYSQL_SHOW test -v -v -t
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test
index 3aac0f45ead..6e83968a506 100644
--- a/mysql-test/t/olap.test
+++ b/mysql-test/t/olap.test
@@ -153,6 +153,13 @@ SELECT DISTINCT SUM(b), COUNT(DISTINCT b), COUNT(*) FROM t1
SELECT a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
SELECT DISTINCT a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
+SELECT b, a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
+SELECT DISTINCT b,a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;
+
+ALTER TABLE t1 ADD COLUMN c INT;
+SELECT a,b,sum(c) FROM t1 GROUP BY a,b,c WITH ROLLUP;
+SELECT distinct a,b,sum(c) FROM t1 GROUP BY a,b,c WITH ROLLUP;
+
DROP TABLE t1;
#
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 912c9fb9bec..2262395d586 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -20,22 +20,22 @@ connect (con4,localhost,ssl_user4,,);
connection con1;
select * from t1;
---error 1044;
+--error 1142;
delete from t1;
connection con2;
select * from t1;
---error 1044;
+--error 1142;
delete from t1;
connection con3;
select * from t1;
---error 1044;
+--error 1142;
delete from t1;
connection con4;
select * from t1;
---error 1044;
+--error 1142;
delete from t1;
connection default;
diff --git a/mysql-test/t/rpl_deadlock.test b/mysql-test/t/rpl_deadlock.test
index a196495e834..3bcbb1d4567 100644
--- a/mysql-test/t/rpl_deadlock.test
+++ b/mysql-test/t/rpl_deadlock.test
@@ -7,6 +7,8 @@
# (Guilhem) have seen the test manage to provoke lock wait timeout
# error but not deadlock error; that is ok as code deals with the two
# errors in exactly the same way.
+# We don't 'show status like 'slave_retried_transactions'' because this
+# is not repeatable (depends on sleeps).
source include/have_innodb.inc;
source include/master-slave.inc;
@@ -16,10 +18,12 @@ create table t1 (a int not null, key(a)) engine=innodb;
create table t2 (a int not null, key(a)) engine=innodb;
create table t3 (a int) engine=innodb;
create table t4 (a int) engine=innodb;
+show variables like 'slave_transaction_retries';
sync_slave_with_master;
show create table t1;
show create table t2;
+show variables like 'slave_transaction_retries';
stop slave;
# 1) Test deadlock
@@ -68,7 +72,7 @@ show slave status;
# 2) Test lock wait timeout
stop slave;
-change master to master_log_pos=536; # the BEGIN log event
+change master to master_log_pos=532; # the BEGIN log event
begin;
select * from t2 for update; # hold lock
start slave;
@@ -89,7 +93,7 @@ set global max_relay_log_size=0;
# This is really copy-paste of 2) of above
stop slave;
-change master to master_log_pos=536;
+change master to master_log_pos=532;
begin;
select * from t2 for update;
start slave;
diff --git a/mysql-test/t/rpl_drop_temp.test b/mysql-test/t/rpl_drop_temp.test
index 73d691d9d90..cf663367b78 100644
--- a/mysql-test/t/rpl_drop_temp.test
+++ b/mysql-test/t/rpl_drop_temp.test
@@ -11,3 +11,6 @@ disconnect master;
connection slave;
--real_sleep 3; # time for DROP to be written
show status like 'Slave_open_temp_tables';
+connection default;
+drop database mysqltest;
+
diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test
index d1404dea211..3d54897adda 100644
--- a/mysql-test/t/rpl_loaddata.test
+++ b/mysql-test/t/rpl_loaddata.test
@@ -123,12 +123,29 @@ show slave status;
connection master;
reset master;
create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
-unique(day));
+unique(day)) engine=MyISAM; # no transactions
--error 1062;
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
-# To test that there is Create_file & Delete_file, we test if the binlog is as
-# long as expected (can't do SHOW BINLOG EVENTS because of varying file_id).
-show master status;
+select * from t2;
+save_master_pos;
+connection slave;
+start slave;
+sync_with_master;
+select * from t2;
+
+# verify that if no error on slave, this is an error
+
+alter table t2 drop key day;
+connection master;
+delete from t2;
+--error 1062;
+load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
+terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
+'\n##\n' starting by '>' ignore 1 lines;
+connection slave;
+wait_for_slave_to_stop;
+drop table t2;
+connection master;
drop table t2;
diff --git a/mysql-test/t/rpl_timezone-slave.opt b/mysql-test/t/rpl_timezone-slave.opt
index 8e43bfbbb7e..191182c329c 100644
--- a/mysql-test/t/rpl_timezone-slave.opt
+++ b/mysql-test/t/rpl_timezone-slave.opt
@@ -1 +1 @@
---default-time-zone=Europe/Moscow
+--default-time-zone=Japan
diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test
index 3c180ca8849..a7547f7afc6 100644
--- a/mysql-test/t/rpl_timezone.test
+++ b/mysql-test/t/rpl_timezone.test
@@ -1,23 +1,38 @@
# Test of replication of time zones.
+
+# There is currently some bug possibly in prepared statements (this
+# test fails with --ps-protocol): sys_var_thd_time_zone::value_ptr()
+# is called only at prepare time, not at execution time. So,
+# thd->time_zone_used is not equal to 1 (it is back to 0, because of
+# reset_thd_for_next_command called at execution time), so the
+# timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem
+# and possibly Konstantin).
+
+--disable_ps_protocol
+
source include/master-slave.inc;
# Some preparations
let $VERSION=`select version()`;
+set timestamp=100000000; # for fixed output of mysqlbinlog
create table t1 (t timestamp);
create table t2 (t char(32));
+connection slave;
+select @@time_zone;
+
#
# Let us check how well replication works when we are saving datetime
# value in TIMESTAMP field.
#
connection master;
select @@time_zone;
+insert into t1 values ('20050101000000'), ('20050611093902');
set time_zone='UTC';
insert into t1 values ('20040101000000'), ('20040611093902');
select * from t1;
-# On slave we still in 'Europe/Moscow' so we should see equivalent but
-# textually different values.
sync_slave_with_master;
+set time_zone='UTC';
select * from t1;
# Let us check also that setting of time_zone back to default also works
@@ -28,12 +43,29 @@ set time_zone='Europe/Moscow';
insert into t1 values ('20040101000000'), ('20040611093902');
select * from t1;
sync_slave_with_master;
+set time_zone='Europe/Moscow';
select * from t1;
connection master;
-# We should not see SET ONE_SHOT time_zone before second insert
---replace_result $VERSION VERSION
---replace_column 2 # 5 #
-show binlog events;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001
+
+# Let us check with LOAD DATA INFILE
+# (we do it after mysqlbinlog because the temp files names are not constant)
+connection master;
+delete from t1;
+set time_zone='UTC';
+load data infile '../../std_data/rpl_timezone.dat' into table t1;
+select * from t1;
+sync_slave_with_master;
+set time_zone='UTC';
+select * from t1;
+set time_zone='Europe/Moscow';
+
+# Put back values of before the LOAD
+connection master;
+set time_zone='Europe/Moscow';
+delete from t1;
+insert into t1 values ('20040101000000'), ('20040611093902');
#
# Now let us check how well we replicate statments reading TIMESTAMP fields
@@ -54,10 +86,6 @@ delete from t2;
set timestamp=1000072000;
insert into t2 values (current_timestamp), (current_date), (current_time);
sync_slave_with_master;
-# Values in ouput of these to queries should differ because we are in
-# in 'MET' on master and in 'Europe/Moscow on slave...
-set timestamp=1000072000;
-select current_timestamp, current_date, current_time;
select * from t2;
#
@@ -73,13 +101,24 @@ sync_slave_with_master;
select * from t2;
#
-# Let us check that we are not allowing to set global time_zone with
+# Let us check that we are allowing to set global time_zone with
# replication
#
connection master;
---error 1387
set global time_zone='MET';
+#
+# Let us see if CONVERT_TZ(@@time_zone) replicates
+#
+delete from t2;
+set time_zone='UTC';
+insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone));
+insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'));
+select * from t2;
+sync_slave_with_master;
+select * from t2;
+
# Clean up
+connection master;
drop table t1, t2;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test
index 9ee1dca9c11..714719f5441 100644
--- a/mysql-test/t/rpl_until.test
+++ b/mysql-test/t/rpl_until.test
@@ -24,7 +24,7 @@ show binlog events;
# try to replicate all queries until drop of t1
connection slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=321;
+start slave until master_log_file='master-bin.000001', master_log_pos=319;
sleep 2;
# here table should be still not deleted
select * from t1;
@@ -42,7 +42,7 @@ sleep 2;
show slave status;
# try replicate all until second insert to t2;
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=751;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746;
sleep 4;
select * from t2;
--replace_result $MASTER_MYPORT MASTER_MYPORT
@@ -58,7 +58,7 @@ sync_with_master;
stop slave;
# this should stop immediately as we are already there
-start slave until master_log_file='master-bin.000001', master_log_pos=783;
+start slave until master_log_file='master-bin.000001', master_log_pos=776;
# 2 is not enough when running with valgrind
real_sleep 4
# here the sql slave thread should be stopped
@@ -79,4 +79,4 @@ start slave until relay_log_file='slave-relay-bin.000002';
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
# Warning should be given for second command
start slave sql_thread;
-start slave until master_log_file='master-bin.000001', master_log_pos=783;
+start slave until master_log_file='master-bin.000001', master_log_pos=776;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 53783e7c9bf..621700b732a 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -681,6 +681,23 @@ end|
#
+# BUG#6600: Stored procedure crash after repeated calls with check table
+#
+--error ER_SP_BADSTATEMENT
+create procedure bug6600()
+ check table t1|
+
+# Check these two as well, while we're at it. (Although it isn't really
+# related to the bug report, but to the fix.)
+--error ER_SP_BADSTATEMENT
+create procedure bug6600()
+ lock table t1 read|
+--error ER_SP_BADSTATEMENT
+create procedure bug6600()
+ unlock table t1|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 5c2e02045c5..b8eb371931f 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -3399,28 +3399,6 @@ delete from t1|
#
-# BUG#6600: Stored procedure crash after repeated calls with check table
-#
---disable_warnings
-drop procedure if exists bug6600|
-drop table if exists t3|
-drop view if exists v1|
---enable_warnings
-create table t3 (s1 decimal(31,30))|
-create view v1 as select * from t3|
-
-create procedure bug6600()
- check table v1|
-
-call bug6600()|
-call bug6600()|
-call bug6600()|
-drop procedure bug6600|
-drop view v1|
-drop table t3|
-
-
-#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 8af0d632f7c..96ba9993c49 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -2,6 +2,7 @@
-- source include/have_innodb.inc
+set @org_mode=@@sql_mode;
set @@sql_mode='ansi,traditional';
select @@sql_mode;
@@ -197,20 +198,12 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
-
-# deactivated because of Bug#5902
-# Bug#5902: Traditional mode: STR_TO_DATE changes invalid value rather than rejecting
-#--error 1292
-#INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
-
+--error 1411
+INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
-
-# deactivated because of Bug#5902
-# Bug#5902: Traditional mode: STR_TO_DATE changes invalid value rather than rejecting
-#--error 1292
-#INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
-
+--error 1411
+INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
@@ -226,21 +219,14 @@ INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
-
-# deactivated because of Bug#5902
-# Bug#5902: Traditional mode: STR_TO_DATE changes invalid value rather than rejecting
-#--error 1292
-#INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
-
+--error 1411
+INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
-
-# deactivated because of Bug#5902
-# Bug#5902: Traditional mode: STR_TO_DATE changes invalid value rather than rejecting
-#--error 1292
-#INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
-#--error 1292
-#INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
+--error 1411
+INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
+--error 1292
+INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
## Test INSERT with STR_TO_DATE into TIMESTAMP
# All test cases expected to fail should return
@@ -254,20 +240,12 @@ INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
-
-# deactivated because of Bug#5902
-# Bug#5902: Traditional mode: STR_TO_DATE changes invalid value rather than rejecting
-#--error 1292
-#INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
-
+--error 1411
+INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
-
-# deactivated because of Bug#5902
-# Bug#5902: Traditional mode: STR_TO_DATE changes invalid value rather than rejecting
-#--error 1292
-#INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
-
+--error 1411
+INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
@@ -962,3 +940,44 @@ insert into t1 (tinytextcol) values (repeat('x',256));
insert into t1 (tinyblobcol) values (repeat('x',256));
select * from t1;
drop table t1;
+
+#
+# Bug #5902: STR_TO_DATE() didn't give errors in traditional mode
+#
+
+set sql_mode='traditional';
+create table t1 (col1 datetime);
+--error 1292
+insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
+--error 1411
+insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+--error 1411
+insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
+--error 1411
+insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
+set sql_mode='';
+insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
+insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
+insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
+insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
+
+# Some correct values, just to test the functions
+insert into t1 values(STR_TO_DATE('31.10.2004 15.30','%d.%m.%Y %H.%i'));
+insert into t1 values(STR_TO_DATE('2004.12.12 11:22:33 AM','%Y.%m.%d %r'));
+insert into t1 values(STR_TO_DATE('2004.12.12 10:22:59','%Y.%m.%d %T'));
+
+select * from t1;
+
+# Check that select don't abort even in strict mode (for now)
+set sql_mode='traditional';
+
+--disable_ps_warnings
+select count(*) from t1 where STR_TO_DATE('2004.12.12 10:22:61','%Y.%m.%d %T') IS NULL;
+--enable_ps_warnings
+
+drop table t1;
+
+#
+# Restore mode
+#
+set sql_mode=@org_mode;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index cfcb32f37c8..55278ad40f8 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1153,6 +1153,7 @@ SELECT a FROM t1 WHERE a = ALL ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a >= ALL ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a <= ALL ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a <> ALL ( SELECT a FROM t1 WHERE b = 2 );
+# with index
ALTER TABLE t1 ADD INDEX (a);
SELECT a FROM t1 WHERE a > ANY ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a < ANY ( SELECT a FROM t1 WHERE b = 2 );
@@ -1166,7 +1167,144 @@ SELECT a FROM t1 WHERE a = ALL ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a >= ALL ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a <= ALL ( SELECT a FROM t1 WHERE b = 2 );
SELECT a FROM t1 WHERE a <> ALL ( SELECT a FROM t1 WHERE b = 2 );
+# having clause test
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 HAVING a = 2);
+# union test
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = 2 UNION SELECT a FROM t1 WHERE b = 2);
+# union + having test
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 HAVING a = 2 UNION SELECT a FROM t1 HAVING a = 2);
+# row tests
+# < > >= <= and = ALL/ <> ANY do not support row operation
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) = ALL (SELECT a,2 FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) <> ANY (SELECT a,2 FROM t1 WHERE b = 2);
+# following should be converted to IN
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) = ANY (SELECT a FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE a = ANY (SELECT a,2 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (1,2) = ANY (SELECT a,2 FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE (1,2) <> ALL (SELECT a FROM t1 WHERE b = 2);
+-- error 1241
+SELECT a FROM t1 WHERE a <> ALL (SELECT a,2 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (1,2) <> ALL (SELECT a,2 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 WHERE b = 2 UNION SELECT a,1 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 WHERE b = 2 UNION SELECT a,1 FROM t1 WHERE b = 2);
+SELECT a FROM t1 WHERE (a,1) = ANY (SELECT a,1 FROM t1 HAVING a = 2 UNION SELECT a,1 FROM t1 HAVING a = 2);
+SELECT a FROM t1 WHERE (a,1) <> ALL (SELECT a,1 FROM t1 HAVING a = 2 UNION SELECT a,1 FROM t1 HAVING a = 2);
+# without optimisation
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = 2 group by a);
+# without optimisation + having
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 group by a HAVING a = 2);
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 group by a HAVING a = 2);
+# EXISTS in string contence
+SELECT concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a > t1.a), '-') from t1 a;
+SELECT concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a < t1.a), '-') from t1 a;
+SELECT concat(EXISTS(SELECT a FROM t1 WHERE b = 2 and a.a = t1.a), '-') from t1 a;
DROP TABLE t1;
+CREATE TABLE t1 ( a double, b double );
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = 2e0);
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = 2e0);
+DROP TABLE t1;
+CREATE TABLE t1 ( a char(1), b char(1));
+INSERT INTO t1 VALUES ('1','1'),('2','2'),('3','3');
+SELECT a FROM t1 WHERE a > ANY (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a < ANY (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a = ANY (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a >= ANY (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a <= ANY (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a <> ANY (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a > ALL (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a < ALL (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a = ALL (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a >= ALL (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a <= ALL (SELECT a FROM t1 WHERE b = '2');
+SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = '2');
+DROP TABLE t1;
+
#
# SELECT(EXISTS * ...)optimisation
@@ -1443,8 +1581,9 @@ select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL;
drop table t1;
+#
# Test for BUG#8218
-
+#
CREATE TABLE t1 (
categoryId int(11) NOT NULL,
courseId int(11) NOT NULL,
@@ -1541,10 +1680,57 @@ join
group by
groupstuff.groupname, colhead , t2.courseid;
-drop table if exists t1, t2, t3, t4, t5;
+drop table t1, t2, t3, t4, t5;
+
+#
+# Transformation in left expression of subquery (BUG#8888)
+#
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+SELECT 1 FROM t1 WHERE (SELECT 1) in (SELECT 1);
+drop table t1;
+
+#
+# subselect into HAVING clause (code covarage improvement)
+#
+create table t1 (a int);
+create table t2 (a int);
+insert into t1 values (1),(2);
+insert into t2 values (0),(1),(2),(3);
+select a from t2 where a in (select a from t1);
+select a from t2 having a in (select a from t1);
+prepare stmt1 from "select a from t2 where a in (select a from t1)";
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+prepare stmt1 from "select a from t2 having a in (select a from t1)";
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+drop table t1, t2;
+#
+# single row subqueries and row operations (code covarage improvement)
+#
+create table t1 (a int, b int);
+insert into t1 values (1,2);
+-- error 1241
+select 1 = (select * from t1);
+-- error 1241
+select (select * from t1) = 1;
+-- error 1241
+select (1,2) = (select a from t1);
+-- error 1241
+select (select a from t1) = (1,2);
+-- error 1241
+select (1,2,3) = (select * from t1);
+-- error 1241
+select (select * from t1) = (1,2,3);
+drop table t1;
+#
#decimal-related tests
+#
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 18ac5d1e467..3205eabe01a 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -285,3 +285,44 @@ SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t2);
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1);
DROP TABLE t1,t2;
+
+#
+# Test limits of decimal
+#
+create table t1 (d decimal(64,0));
+insert into t1 values (1);
+select * from t1;
+drop table t1;
+create table t1 (d decimal(64,99));
+show create table t1;
+insert into t1 values (1);
+select * from t1;
+drop table t1;
+create table t1 (d decimal(10,12));
+show create table t1;
+drop table t1;
+create table t1 (d decimal(5));
+show create table t1;
+drop table t1;
+create table t1 (d decimal);
+show create table t1;
+drop table t1;
+--error 1063
+create table t1 (d decimal(65,0));
+
+#
+# Test example from manual
+#
+
+CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
+INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
+(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
+(2, 30.40, 30.40), (3, 37.00, 7.40), (3, -29.60, 0.00),
+(4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00),
+(5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20),
+(6, 0.00, 0.00), (6, -51.40, 0.00);
+
+SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b;
+SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i
+HAVING a <> b;
+drop table t1;
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index d116d56fa48..e85cc3d55c6 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -91,15 +91,6 @@ show create table t1;
drop table t1;
#
-# conversion from ucs2
-#
-CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
-INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
-update t1 set b=a;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
# Trydy's tests
#
set session sql_mode='traditional';
@@ -757,7 +748,7 @@ select 1 / 0;
#+-------+
#| 1 / 0 |
#+-------+
-#| NULL |
+#| NULL |
#+-------+
#1 row in set, 1 warning (0.00 sec)
#
@@ -873,3 +864,8 @@ SELECT MOD(col1,0) FROM Sow6_2f;
INSERT INTO Sow6_2f VALUES ('a59b');
#-- should return SQLSTATE 22018 invalid character value for cast
drop table Sow6_2f;
+
+#
+# bug#9501
+#
+select 10.3330000000000/12.34500000;
diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test
index 0168128d513..9867cf4c057 100644
--- a/mysql-test/t/type_varchar.test
+++ b/mysql-test/t/type_varchar.test
@@ -97,3 +97,12 @@ explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
drop table t1;
+
+#
+# bug#9339 - meaningless Field_varstring::get_key_image
+#
+create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol));
+insert into t1 values ('test', 'something');
+update t1 set othercol='somethingelse' where pkcol='test';
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 5ff22f1d6b6..95b5d4c6aaf 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -729,3 +729,34 @@ select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a;
drop table t1;
+
+#
+# Bugs#6519 UNION with collation binary and latin1_swedish_ci fails
+#
+set @val:=6;
+select concat('value is: ', @val) union select 'some text';
+
+#
+# Enum merging test
+#
+CREATE TABLE t1 (
+ a ENUM('ä','ö','ü') character set utf8 not null default 'ü',
+ b ENUM("one", "two") character set utf8,
+ c ENUM("one", "two")
+);
+show create table t1;
+insert into t1 values ('ä', 'one', 'one'), ('ö', 'two', 'one'), ('ü', NULL, NULL);
+create table t2 select NULL union select a from t1;
+show columns from t2;
+drop table t2;
+create table t2 select a from t1 union select NULL;
+show columns from t2;
+drop table t2;
+create table t2 select a from t1 union select a from t1;
+show columns from t2;
+drop table t2;
+-- error 1267
+create table t2 select a from t1 union select c from t1;
+create table t2 select a from t1 union select b from t1;
+show columns from t2;
+drop table t2, t1;
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index d8dfc10bfe4..49d8e167368 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -124,3 +124,10 @@ drop table t1;
#
set @var= NULL ;
select FIELD( @var,'1it','Hit') as my_column;
+
+#
+# Bug#9425 A user variable doesn't always have implicit coercibility
+#
+select @v, coercibility(@v);
+set @v1=null, @v2=1, @v3=1.1, @v4=now();
+select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 5310d50b7cb..ebd6edf4045 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -388,3 +388,12 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache';
SET GLOBAL table_cache=DEFAULT;
+
+#
+# Bug#6282 Packet error with SELECT INTO
+#
+create table t1 (a int);
+select a into @x from t1;
+show warnings;
+drop table t1;
+
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index c71365c3da6..69284b4c6e4 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -96,6 +96,19 @@ update t1 set b=a;
select @@warning_count;
--enable_ps_protocol
+# Bug#9072
+set max_error_count=0;
+show variables like 'max_error_count';
+update t1 set b='hi';
+--disable_ps_protocol
+select @@warning_count;
+--enable_ps_protocol
+show warnings;
+set max_error_count=65535;
+show variables like 'max_error_count';
+set max_error_count=10;
+show variables like 'max_error_count';
+
#
# Test for handler type
#
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 89d65624976..db8aa10bf1a 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -52,7 +52,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_net.c my_semaphore.c my_port.c my_sleep.c \
charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c
+ my_handler.c my_netware.c my_largepage.c \
+ my_windac.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c
libmysys_a_LIBADD = @THREAD_LOBJECTS@
diff --git a/mysys/charset-def.c b/mysys/charset-def.c
index f168556e3f7..92453aa0f59 100644
--- a/mysys/charset-def.c
+++ b/mysys/charset-def.c
@@ -62,6 +62,9 @@ extern CHARSET_INFO my_charset_utf8_slovak_uca_ci;
extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci;
extern CHARSET_INFO my_charset_utf8_roman_uca_ci;
extern CHARSET_INFO my_charset_utf8_persian_uca_ci;
+#ifdef HAVE_CYBOZU_COLLATION
+extern CHARSET_INFO my_charset_utf8_general_cs;
+#endif
#endif
#endif /* HAVE_UCA_COLLATIONS */
@@ -156,6 +159,9 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
#ifdef HAVE_CHARSET_utf8
add_compiled_collation(&my_charset_utf8_general_ci);
add_compiled_collation(&my_charset_utf8_bin);
+#ifdef HAVE_CYBOZU_COLLATION
+ add_compiled_collation(&my_charset_utf8_general_cs);
+#endif
#ifdef HAVE_UCA_COLLATIONS
add_compiled_collation(&my_charset_utf8_general_uca_ci);
add_compiled_collation(&my_charset_utf8_icelandic_uca_ci);
diff --git a/mysys/charset.c b/mysys/charset.c
index 4b7ad3e59f4..a4a8205a3f9 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -547,10 +547,10 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
DBUG_PRINT("enter",("name: '%s'", cs_name));
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
-
+
cs_number= get_charset_number(cs_name, cs_flags);
cs= cs_number ? get_internal_charset(cs_number, flags) : NULL;
-
+
if (!cs && (flags & MY_WME))
{
char index_file[FN_REFLEN];
@@ -561,21 +561,34 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
DBUG_RETURN(cs);
}
-
-ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
+/*
+ NOTE
+ to keep old C API, to_length may be 0 to mean "big enough"
+ RETURN
+ the length of the escaped string or ~0 if it did not fit.
+*/
+ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
+ char *to, ulong to_length,
const char *from, ulong length)
{
const char *to_start= to;
- const char *end;
+ const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length);
+ my_bool overflow=0;
#ifdef USE_MB
my_bool use_mb_flag= use_mb(charset_info);
#endif
- for (end= from + length; from != end; from++)
+ for (end= from + length; from < end; from++)
{
+ char escape=0;
#ifdef USE_MB
int l;
if (use_mb_flag && (l= my_ismbchar(charset_info, from, end)))
{
+ if (to + l >= to_end)
+ {
+ overflow=1;
+ break;
+ }
while (l--)
*to++= *from++;
from--;
@@ -593,45 +606,53 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
a valid GBK character, but 0xbf5c is. (0x27 = ', 0x5c = \)
*/
if (use_mb_flag && (l= my_mbcharlen(charset_info, *from)) > 1)
- {
- *to++= '\\';
- *to++= *from;
- continue;
- }
+ escape= *from;
+ else
#endif
switch (*from) {
case 0: /* Must be escaped for 'mysql' */
- *to++= '\\';
- *to++= '0';
+ escape= '0';
break;
case '\n': /* Must be escaped for logs */
- *to++= '\\';
- *to++= 'n';
+ escape= 'n';
break;
case '\r':
- *to++= '\\';
- *to++= 'r';
+ escape= 'r';
break;
case '\\':
- *to++= '\\';
- *to++= '\\';
+ escape= '\\';
break;
case '\'':
- *to++= '\\';
- *to++= '\'';
+ escape= '\'';
break;
case '"': /* Better safe than sorry */
- *to++= '\\';
- *to++= '"';
+ escape= '"';
break;
case '\032': /* This gives problems on Win32 */
- *to++= '\\';
- *to++= 'Z';
+ escape= 'Z';
break;
- default:
+ }
+ if (escape)
+ {
+ if (to + 2 >= to_end)
+ {
+ overflow=1;
+ break;
+ }
+ *to++= '\\';
+ *to++= escape;
+ }
+ else
+ {
+ if (to + 1 >= to_end)
+ {
+ overflow=1;
+ break;
+ }
*to++= *from;
}
}
*to= 0;
- return (ulong) (to - to_start);
+ return overflow ? (ulong)~0 : (ulong) (to - to_start);
}
+
diff --git a/mysys/default.c b/mysys/default.c
index 1c06feec634..ddff4e26be5 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -73,7 +73,7 @@ static int search_default_file(Process_option_func func, void *func_ctx,
static int search_default_file_with_ext(Process_option_func func,
void *func_ctx,
const char *dir, const char *ext,
- const char *config_file);
+ const char *config_file, int recursion_level);
static void init_default_directories();
static char *remove_end_comment(char *ptr);
@@ -124,7 +124,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
if (forced_default_file)
{
if ((error= search_default_file_with_ext(func, func_ctx, "", "",
- forced_default_file)) < 0)
+ forced_default_file, 0)) < 0)
goto err;
if (error > 0)
{
@@ -328,7 +328,7 @@ int load_defaults(const char *conf_file, const char **groups,
ctx.alloc= &alloc;
ctx.args= &args;
ctx.group= &group;
-
+
error= my_search_option_files(conf_file, argc, argv, &args_used,
handle_default_option, (void *) &ctx);
/*
@@ -402,7 +402,7 @@ static int search_default_file(Process_option_func opt_handler,
int error;
if ((error= search_default_file_with_ext(opt_handler, handler_ctx,
dir, *ext,
- config_file)) < 0)
+ config_file, 0)) < 0)
return error;
}
return 0;
@@ -411,7 +411,7 @@ static int search_default_file(Process_option_func opt_handler,
/*
Open a configuration file (if exists) and read given options from it
-
+
SYNOPSIS
search_default_file_with_ext()
opt_handler Option handler function. It is used to process
@@ -420,8 +420,10 @@ static int search_default_file(Process_option_func opt_handler,
parameters of the function.
dir directory to read
ext Extension for configuration file
- config_file Name of configuration file
+ config_file Name of configuration file
group groups to read
+ recursion_level the level of recursion, got while processing
+ "!include" or "!includedir"
RETURN
0 Success
@@ -433,13 +435,20 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
void *handler_ctx,
const char *dir,
const char *ext,
- const char *config_file)
+ const char *config_file,
+ int recursion_level)
{
- char name[FN_REFLEN+10], buff[4096], curr_gr[4096], *ptr, *end;
- char *value, option[4096];
+ char name[FN_REFLEN + 10], buff[4096], curr_gr[4096], *ptr, *end, **tmp_ext;
+ char *value, option[4096], tmp[FN_REFLEN];
+ static const char includedir_keyword[]= "includedir";
+ static const char include_keyword[]= "include";
+ const int max_recursion_level= 10;
FILE *fp;
uint line=0;
my_bool found_group=0;
+ uint i;
+ MY_DIR *search_dir;
+ FILEINFO *search_file;
if ((dir ? strlen(dir) : 0 )+strlen(config_file) >= FN_REFLEN-3)
return 0; /* Ignore wrong paths */
@@ -468,22 +477,117 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
if ((stat_info.st_mode & S_IWOTH) &&
(stat_info.st_mode & S_IFMT) == S_IFREG)
{
- fprintf(stderr, "warning: World-writeable config file %s is ignored\n",
+ fprintf(stderr, "warning: World-writable config file %s is ignored\n",
name);
return 0;
}
}
#endif
- if (!(fp = my_fopen(fn_format(name,name,"","",4),O_RDONLY,MYF(0))))
+ if (!(fp= my_fopen(fn_format(name, name, "", "", 4), O_RDONLY, MYF(0))))
return 0; /* Ignore wrong files */
- while (fgets(buff,sizeof(buff)-1,fp))
+ while (fgets(buff, sizeof(buff) - 1, fp))
{
line++;
/* Ignore comment and empty lines */
- for (ptr=buff ; my_isspace(&my_charset_latin1,*ptr) ; ptr++ ) ;
+ for (ptr= buff; my_isspace(&my_charset_latin1, *ptr); ptr++)
+ {}
+
if (*ptr == '#' || *ptr == ';' || !*ptr)
continue;
+
+ /* Configuration File Directives */
+ if ((*ptr == '!') && (recursion_level < max_recursion_level))
+ {
+ /* skip over `!' and following whitespace */
+ for (++ptr; my_isspace(&my_charset_latin1, ptr[0]); ptr++)
+ {}
+
+ if ((!strncmp(ptr, includedir_keyword, sizeof(includedir_keyword) - 1))
+ && my_isspace(&my_charset_latin1, ptr[sizeof(includedir_keyword) - 1]))
+ {
+ /* skip over "includedir" and following whitespace */
+ for (ptr+= sizeof(includedir_keyword) - 1;
+ my_isspace(&my_charset_latin1, ptr[0]); ptr++)
+ {}
+
+ /* trim trailing whitespace from directory name */
+ end= ptr + strlen(ptr) - 1;
+ /*
+ This would work fine even if no whitespaces are met
+ since fgets() stores the newline character in the buffer
+ */
+ for (; my_isspace(&my_charset_latin1, *(end - 1)); end--)
+ {}
+ end[0]= 0;
+
+ /* print error msg if there is nothing after !inludedir directive */
+ if (end == ptr)
+ {
+ fprintf(stderr,
+ "error: Wrong !includedir directive in config "
+ "file: %s at line %d\n",
+ name,line);
+ goto err;
+ }
+
+ if (!(search_dir= my_dir(ptr, MYF(MY_WME))))
+ goto err;
+
+ for (i= 0; i < (uint) search_dir->number_off_files; i++)
+ {
+ search_file= search_dir->dir_entry + i;
+ ext= fn_ext(search_file->name);
+
+ /* check extenstion */
+ for (tmp_ext= (char**) f_extensions; *tmp_ext; *tmp_ext++)
+ {
+ if (!strcmp(ext, *tmp_ext))
+ break;
+ }
+
+ if (*tmp_ext)
+ {
+ fn_format(tmp, search_file->name, ptr, "",
+ MY_UNPACK_FILENAME | MY_SAFE_PATH);
+
+ search_default_file_with_ext(opt_handler, handler_ctx, "", "", tmp,
+ recursion_level + 1);
+ }
+ }
+
+ my_dirend(search_dir);
+ }
+ else if ((!strncmp(ptr, include_keyword, sizeof(include_keyword) - 1))
+ && my_isspace(&my_charset_latin1, ptr[sizeof(include_keyword) - 1]))
+ {
+ /* skip over `include' and following whitespace */
+ for (ptr+= sizeof(include_keyword) - 1;
+ my_isspace(&my_charset_latin1, ptr[0]); ptr++)
+ {}
+
+ /* trim trailing whitespace from filename */
+ end= ptr + strlen(ptr) - 1;
+ for (; my_isspace(&my_charset_latin1, *(end - 1)) ; end--)
+ {}
+ end[0]= 0;
+
+ if (end == ptr)
+ {
+ fprintf(stderr,
+ "error: Wrong !include directive in config "
+ "file: %s at line %d\n",
+ name,line);
+ goto err;
+ }
+
+ search_default_file_with_ext(opt_handler, handler_ctx, "", "", ptr,
+ recursion_level + 1);
+ }
+
+ continue;
+ }
+
if (*ptr == '[') /* Group name */
{
found_group=1;
diff --git a/mysys/my_mmap.c b/mysys/my_mmap.c
index a111c3dc571..cd84630a761 100644
--- a/mysys/my_mmap.c
+++ b/mysys/my_mmap.c
@@ -46,11 +46,14 @@ void *my_mmap(void *addr, size_t len, int prot,
DWORD flProtect=0;
HANDLE hFileMap;
LPVOID ptr;
+ HANDLE hFile= (HANDLE)_get_osfhandle(fd);
+ if (hFile == INVALID_HANDLE_VALUE)
+ return MAP_FAILED;
flProtect|=SEC_COMMIT;
- hFileMap=CreateFileMapping(fd, NULL, &mmap_security_attributes,
- PAGE_READWRITE, 0, len, 0);
+ hFileMap=CreateFileMapping(hFile, &mmap_security_attributes,
+ PAGE_READWRITE, 0, len, NULL);
if (hFileMap == 0)
return MAP_FAILED;
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
new file mode 100644
index 00000000000..2c1027e4aa6
--- /dev/null
+++ b/mysys/my_windac.c
@@ -0,0 +1,224 @@
+/* Copyright (C) 2000-2005 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "mysys_priv.h"
+#include "m_string.h"
+#ifdef __WIN__
+
+/* Windows NT/2000 discretionary access control utility functions. */
+
+/*
+ Check if the operating system is built on NT technology.
+
+ RETURN
+ 0 Windows 95/98/Me
+ 1 otherwise
+*/
+
+static my_bool is_nt()
+{
+ return GetVersion() < 0x80000000;
+}
+
+/*
+ Auxilary structure to store pointers to the data which we need to keep
+ around while SECURITY_ATTRIBUTES is in use.
+*/
+
+typedef struct st_my_security_attr
+{
+ PSID everyone_sid;
+ PACL dacl;
+} My_security_attr;
+
+
+/*
+ Allocate and initialize SECURITY_ATTRIBUTES setting up access
+ rights for the owner and group `Everybody'.
+
+ SYNOPSIS
+ my_security_attr_create()
+ psa [OUT] pointer to store the pointer to SA in
+ perror [OUT] pointer to store error message if there was an
+ error
+ owner_rights [IN] access rights for the owner
+ everyone_rights [IN] access rights for group Everybody
+
+ DESCRIPTION
+ Set up the security attributes to provide clients with sufficient
+ access rights to a kernel object. We need this function
+ because if we simply grant all access to everybody (by installing
+ a NULL DACL) a mailicious user can attempt a denial of service
+ attack by taking ownership over the kernel object. Upon successful
+ return `psa' contains a pointer to SECUIRITY_ATTRIBUTES that can be used
+ to create kernel objects with proper access rights.
+
+ RETURN
+ 0 success, psa is 0 or points to a valid SA structure,
+ perror is left intact
+ !0 error, SA is set to 0, error message is stored in perror
+*/
+
+int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
+ DWORD owner_rights, DWORD everyone_rights)
+{
+ /* Top-level SID authority */
+ SID_IDENTIFIER_AUTHORITY world_auth= SECURITY_WORLD_SID_AUTHORITY;
+ PSID everyone_sid= 0;
+ HANDLE htoken= 0;
+ SECURITY_ATTRIBUTES *sa= 0;
+ PACL dacl= 0;
+ DWORD owner_token_length, dacl_length;
+ SECURITY_DESCRIPTOR *sd;
+ PTOKEN_USER owner_token;
+ PSID owner_sid;
+ My_security_attr *attr;
+
+ if (! is_nt())
+ {
+ *psa= 0;
+ return 0;
+ }
+
+ /*
+ Get SID of Everyone group. Easier to retrieve all SIDs each time
+ this function is called than worry about thread safety.
+ */
+ if (! AllocateAndInitializeSid(&world_auth, 1, SECURITY_WORLD_RID,
+ 0, 0, 0, 0, 0, 0, 0, &everyone_sid))
+ {
+ *perror= "Failed to retrieve the SID of Everyone group";
+ goto error;
+ }
+
+ /*
+ Get SID of the owner. Using GetSecurityInfo this task can be done
+ in just one call instead of five, but GetSecurityInfo declared in
+ aclapi.h, so I hesitate to use it.
+ SIC: OpenThreadToken works only if there is an active impersonation
+ token, hence OpenProcessToken is used.
+ */
+ if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &htoken))
+ {
+ *perror= "Failed to retrieve thread access token";
+ goto error;
+ }
+ GetTokenInformation(htoken, TokenUser, 0, 0, &owner_token_length);
+
+ if (! my_multi_malloc(MYF(MY_WME),
+ &sa, ALIGN_SIZE(sizeof(SECURITY_ATTRIBUTES)) +
+ sizeof(My_security_attr),
+ &sd, sizeof(SECURITY_DESCRIPTOR),
+ &owner_token, owner_token_length,
+ 0))
+ {
+ *perror= "Failed to allocate memory for SECURITY_ATTRIBUTES";
+ goto error;
+ }
+ bzero(owner_token, owner_token_length);
+ if (! GetTokenInformation(htoken, TokenUser, owner_token,
+ owner_token_length, &owner_token_length))
+ {
+ *perror= "GetTokenInformation failed";
+ goto error;
+ }
+ owner_sid= owner_token->User.Sid;
+
+ if (! IsValidSid(owner_sid))
+ {
+ *perror= "IsValidSid failed";
+ goto error;
+ }
+
+ /* Calculate the amount of memory that must be allocated for the DACL */
+ dacl_length= sizeof(ACL) + (sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD)) * 2 +
+ GetLengthSid(everyone_sid) + GetLengthSid(owner_sid);
+
+ /* Create an ACL */
+ if (! (dacl= (PACL) my_malloc(dacl_length, MYF(MY_ZEROFILL|MY_WME))))
+ {
+ *perror= "Failed to allocate memory for DACL";
+ goto error;
+ }
+ if (! InitializeAcl(dacl, dacl_length, ACL_REVISION))
+ {
+ *perror= "Failed to initialize DACL";
+ goto error;
+ }
+ if (! AddAccessAllowedAce(dacl, ACL_REVISION, everyone_rights, everyone_sid))
+ {
+ *perror= "Failed to set up DACL";
+ goto error;
+ }
+ if (! AddAccessAllowedAce(dacl, ACL_REVISION, owner_rights, owner_sid))
+ {
+ *perror= "Failed to set up DACL";
+ goto error;
+ }
+ if (! InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
+ {
+ *perror= "Could not initialize security descriptor";
+ goto error;
+ }
+ if (! SetSecurityDescriptorDacl(sd, TRUE, dacl, FALSE))
+ {
+ *perror= "Failed to install DACL";
+ goto error;
+ }
+
+ sa->nLength= sizeof(*sa);
+ sa->bInheritHandle= TRUE;
+ sa->lpSecurityDescriptor= sd;
+ /* Save pointers to everyone_sid and dacl to be able to clean them up */
+ attr= (My_security_attr*) (((char*) sa) + ALIGN_SIZE(sizeof(*sa)));
+ attr->everyone_sid= everyone_sid;
+ attr->dacl= dacl;
+ *psa= sa;
+
+ CloseHandle(htoken);
+ return 0;
+error:
+ if (everyone_sid)
+ FreeSid(everyone_sid);
+ if (htoken)
+ CloseHandle(htoken);
+ my_free((gptr) sa, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((gptr) dacl, MYF(MY_ALLOW_ZERO_PTR));
+ *psa= 0;
+ return 1;
+}
+
+/*
+ Cleanup security attributes freeing used memory.
+
+ SYNOPSIS
+ my_security_attr_free()
+ sa security attributes
+*/
+
+void my_security_attr_free(SECURITY_ATTRIBUTES *sa)
+{
+ if (sa)
+ {
+ My_security_attr *attr= (My_security_attr*)
+ (((char*)sa) + ALIGN_SIZE(sizeof(*sa)));
+ FreeSid(attr->everyone_sid);
+ my_free((gptr) attr->dacl, MYF(0));
+ my_free((gptr) sa, MYF(0));
+ }
+}
+
+#endif /* __WIN__ */
diff --git a/ndb/include/util/Vector.hpp b/ndb/include/util/Vector.hpp
index f60817dab67..480dddf8243 100644
--- a/ndb/include/util/Vector.hpp
+++ b/ndb/include/util/Vector.hpp
@@ -61,6 +61,10 @@ Vector<T>::Vector(int i){
template<class T>
Vector<T>::~Vector(){
delete[] m_items;
+ // safety for placement new usage
+ m_items = 0;
+ m_size = 0;
+ m_arraySize = 0;
}
template<class T>
@@ -174,6 +178,10 @@ MutexVector<T>::MutexVector(int i){
template<class T>
MutexVector<T>::~MutexVector(){
delete[] m_items;
+ // safety for placement new usage
+ m_items = 0;
+ m_size = 0;
+ m_arraySize = 0;
}
template<class T>
diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
index 78209c3affa..4bc5b127a8f 100644
--- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
+++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
@@ -2470,7 +2470,9 @@ Dbdict::restartCreateTab_writeTableConf(Signal* signal,
callback.m_callbackFunction =
safe_cast(&Dbdict::restartCreateTab_dihComplete);
- SegmentedSectionPtr fragDataPtr; fragDataPtr.setNull();
+ SegmentedSectionPtr fragDataPtr;
+ fragDataPtr.sz = 0;
+ fragDataPtr.setNull();
createTab_dih(signal, createTabPtr, fragDataPtr, &callback);
}
diff --git a/ndb/src/kernel/blocks/dbdict/printSchemafile/printSchemafile.cpp b/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp
index bf721a0b30a..0ba52878b7c 100644
--- a/ndb/src/kernel/blocks/dbdict/printSchemafile/printSchemafile.cpp
+++ b/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp
@@ -1,3 +1,11 @@
+#if 0
+make -f Makefile -f - printSchemaFile <<'_eof_'
+printSchemaFile: printSchemaFile.cpp
+ $(CXXCOMPILE) -o $@ $@.cpp -L../../../common/util/.libs -lgeneral
+_eof_
+exit $?
+#endif
+
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -92,6 +100,13 @@ NDB_COMMAND(printSchemafile,
}
print(filename, (SchemaFile *)&buf[0]);
+
+ Uint32 chk = 0, i;
+ for (i = 0; i < bytes/4; i++)
+ chk ^= buf[i];
+ if (chk != 0)
+ ndbout << "Invalid checksum!" << endl;
+
delete [] buf;
return 0;
}
diff --git a/ndb/src/kernel/blocks/dbdict/printSchemafile/Makefile b/ndb/src/kernel/blocks/dbdict/printSchemafile/Makefile
deleted file mode 100644
index 1b097e2ce37..00000000000
--- a/ndb/src/kernel/blocks/dbdict/printSchemafile/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-include .defs.mk
-
-TYPE := ndbapi
-
-BIN_TARGET := printSchemafile
-BIN_TARGET_ARCHIVES := portlib general
-
-CCFLAGS_LOC += -I..
-
-SOURCES := printSchemafile.cpp
-
-include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/src/kernel/vm/VMSignal.cpp b/ndb/src/kernel/vm/VMSignal.cpp
index bffca6f6541..e4eafb47ff7 100644
--- a/ndb/src/kernel/vm/VMSignal.cpp
+++ b/ndb/src/kernel/vm/VMSignal.cpp
@@ -18,8 +18,8 @@
#include <string.h>
Signal::Signal(){
- memset(&header, sizeof(header), 0);
- memset(theData, sizeof(theData), 0);
+ memset(&header, 0, sizeof(header));
+ memset(theData, 0, sizeof(theData));
}
void
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index 67ee307bb68..fe7909ba5a1 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -144,6 +144,7 @@ extern "C"
NdbMgmHandle
ndb_mgm_create_handle()
{
+ DBUG_ENTER("ndb_mgm_create_handle");
NdbMgmHandle h =
(NdbMgmHandle)my_malloc(sizeof(ndb_mgm_handle),MYF(MY_WME));
h->connected = 0;
@@ -163,7 +164,8 @@ ndb_mgm_create_handle()
h->logfile = 0;
#endif
- return h;
+ DBUG_PRINT("info", ("handle=0x%x", (UintPtr)h));
+ DBUG_RETURN(h);
}
extern "C"
@@ -171,10 +173,13 @@ int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
{
DBUG_ENTER("ndb_mgm_set_connectstring");
+ DBUG_PRINT("info", ("handle=0x%x", (UintPtr)handle));
+ handle->cfg.~LocalConfig();
new (&(handle->cfg)) LocalConfig;
if (!handle->cfg.init(mgmsrv, 0) ||
handle->cfg.ids.size() == 0)
{
+ handle->cfg.~LocalConfig();
new (&(handle->cfg)) LocalConfig;
handle->cfg.init(0, 0); /* reset the LocalConfig */
SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
@@ -191,8 +196,10 @@ extern "C"
void
ndb_mgm_destroy_handle(NdbMgmHandle * handle)
{
+ DBUG_ENTER("ndb_mgm_destroy_handle");
if(!handle)
- return;
+ DBUG_VOID_RETURN;
+ DBUG_PRINT("info", ("handle=0x%x", (UintPtr)(* handle)));
/**
* important! only disconnect if connected
* other code relies on this
@@ -209,6 +216,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
(*handle)->cfg.~LocalConfig();
my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
* handle = 0;
+ DBUG_VOID_RETURN;
}
/*****************************************************************************
diff --git a/ndb/src/ndbapi/DictCache.cpp b/ndb/src/ndbapi/DictCache.cpp
index afdb37aa53f..da9d5b70d47 100644
--- a/ndb/src/ndbapi/DictCache.cpp
+++ b/ndb/src/ndbapi/DictCache.cpp
@@ -24,12 +24,11 @@
Ndb_local_table_info *
Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz)
{
- if (sz % 8 != 0) // round to Uint64
- sz += 8 - sz % 8;
- void *data= malloc(sizeof(NdbTableImpl)+sz-8);
+ Uint32 tot_size= sizeof(NdbTableImpl *) + ((sz+7) & ~7); // round to Uint64
+ void *data= malloc(tot_size);
if (data == 0)
return 0;
- memset(data,0,sizeof(NdbTableImpl)+sz-8);
+ memset(data, 0, tot_size);
new (data) Ndb_local_table_info(table_impl);
return (Ndb_local_table_info *) data;
}
diff --git a/scripts/fill_func_tables.sh b/scripts/fill_func_tables.sh
index 459afee2fe1..203c730dd9a 100644
--- a/scripts/fill_func_tables.sh
+++ b/scripts/fill_func_tables.sh
@@ -131,8 +131,8 @@ print "USE mysql_help;\n";
print "DROP TABLE IF EXISTS function;\n";
print "CREATE TABLE function (";
print " func_id int unsigned not null auto_increment,";
-print " name varchar(64) not null,";
-print " url varchar(128) not null,";
+print " name char(64) not null,";
+print " url char(128) not null,";
print " description text not null,";
print " example text not null,";
print " min_args tinyint not null,";
@@ -145,8 +145,8 @@ print ") type=myisam;\n\n";
print "DROP TABLE IF EXISTS function_category_name;\n";
print "CREATE TABLE function_category_name (";
print " cat_id smallint unsigned not null auto_increment,";
-print " name varchar(64) not null,";
-print " url varchar(128) not null,";
+print " name char(64) not null,";
+print " url char(128) not null,";
print " date_created datetime not null,";
print " last_modified timestamp not null,";
print " primary key (cat_id)";
diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh
index efcbeffeb11..25f5726c35a 100644
--- a/scripts/make_win_src_distribution.sh
+++ b/scripts/make_win_src_distribution.sh
@@ -251,7 +251,7 @@ copy_dir_dirs() {
for i in client dbug extra heap include \
libmysql libmysqld myisam \
- myisammrg mysys regex sql strings sql-common \
+ myisammrg mysys regex sql strings sql-common sql/examples \
tools vio zlib
do
copy_dir_files $i
diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh
index d87113d3656..bb4c2f08193 100644
--- a/scripts/mysql_create_system_tables.sh
+++ b/scripts/mysql_create_system_tables.sh
@@ -146,6 +146,7 @@ then
c_u="$c_u Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
c_u="$c_u Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
c_u="$c_u Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
c_u="$c_u ssl_cipher BLOB NOT NULL,"
c_u="$c_u x509_issuer BLOB NOT NULL,"
@@ -161,22 +162,22 @@ then
if test "$1" = "test"
then
- i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
- INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
- REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+ i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+ INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+ REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
INSERT INTO user (host,user) values ('localhost','');
INSERT INTO user (host,user) values ('$hostname','');"
else
- i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);"
+ i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);"
if test "$windows" = "0"
then
i_u="$i_u
- INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
+ INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
INSERT INTO user (host,user) values ('$hostname','');
INSERT INTO user (host,user) values ('localhost','');"
else
i_u="$i_u
- INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
+ INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
fi
fi
fi
@@ -269,11 +270,11 @@ then
c_ht="$c_ht CREATE TABLE help_topic ("
c_ht="$c_ht help_topic_id int unsigned not null,"
- c_ht="$c_ht name varchar(64) not null,"
+ c_ht="$c_ht name char(64) not null,"
c_ht="$c_ht help_category_id smallint unsigned not null,"
c_ht="$c_ht description text not null,"
c_ht="$c_ht example text not null,"
- c_ht="$c_ht url varchar(128) not null,"
+ c_ht="$c_ht url char(128) not null,"
c_ht="$c_ht primary key (help_topic_id),"
c_ht="$c_ht unique index (name)"
c_ht="$c_ht ) engine=MyISAM"
@@ -291,9 +292,9 @@ then
c_hc="$c_hc CREATE TABLE help_category ("
c_hc="$c_hc help_category_id smallint unsigned not null,"
- c_hc="$c_hc name varchar(64) not null,"
+ c_hc="$c_hc name char(64) not null,"
c_hc="$c_hc parent_category_id smallint unsigned null,"
- c_hc="$c_hc url varchar(128) not null,"
+ c_hc="$c_hc url char(128) not null,"
c_hc="$c_hc primary key (help_category_id),"
c_hc="$c_hc unique index (name)"
c_hc="$c_hc ) engine=MyISAM"
@@ -309,7 +310,7 @@ then
c_hk="$c_hk CREATE TABLE help_keyword ("
c_hk="$c_hk help_keyword_id int unsigned not null,"
- c_hk="$c_hk name varchar(64) not null,"
+ c_hk="$c_hk name char(64) not null,"
c_hk="$c_hk primary key (help_keyword_id),"
c_hk="$c_hk unique index (name)"
c_hk="$c_hk ) engine=MyISAM"
diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh
index d5c96532782..d080b68b268 100644
--- a/scripts/mysql_fix_privilege_tables.sh
+++ b/scripts/mysql_fix_privilege_tables.sh
@@ -13,7 +13,7 @@ args=""
port=""
socket=""
database="mysql"
-bindir="."
+bindir=""
pkgdatadir="@pkgdatadir@"
print_defaults_bindir="."
diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql
index ecf437ebdc6..c81f4b37fca 100644
--- a/scripts/mysql_fix_privilege_tables.sql
+++ b/scripts/mysql_fix_privilege_tables.sql
@@ -290,6 +290,18 @@ UPDATE db SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Ex
ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections;
#
+# user.Create_user_priv
+#
+
+SET @hadCreateUserPriv:=0;
+SELECT @hadCreateUserPriv:=1 FROM user WHERE Create_user_priv LIKE '%';
+
+ALTER TABLE user ADD Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
+UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y'
+ WHERE @hadCreateUserPriv = 0 AND
+ (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
+
+#
# Create some possible missing tables
#
CREATE TABLE IF NOT EXISTS procs_priv (
@@ -306,19 +318,19 @@ KEY Grantor (Grantor)
CREATE TABLE IF NOT EXISTS help_topic (
help_topic_id int unsigned not null,
-name varchar(64) not null,
+name char(64) not null,
help_category_id smallint unsigned not null,
description text not null,
example text not null,
-url varchar(128) not null,
+url char(128) not null,
primary key (help_topic_id), unique index (name)
) CHARACTER SET utf8 comment='help topics';
CREATE TABLE IF NOT EXISTS help_category (
help_category_id smallint unsigned not null,
-name varchar(64) not null,
+name char(64) not null,
parent_category_id smallint unsigned null,
-url varchar(128) not null,
+url char(128) not null,
primary key (help_category_id),
unique index (name)
) CHARACTER SET utf8 comment='help categories';
@@ -331,7 +343,7 @@ primary key (help_keyword_id, help_topic_id)
CREATE TABLE IF NOT EXISTS help_keyword (
help_keyword_id int unsigned not null,
-name varchar(64) not null,
+name char(64) not null,
primary key (help_keyword_id),
unique index (name)
) CHARACTER SET utf8 comment='help keywords';
@@ -478,3 +490,35 @@ ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
'NO_AUTO_CREATE_USER',
'HIGH_NOT_PRECEDENCE'
) DEFAULT 0 NOT NULL;
+
+#
+# Change all varchar fields in privilege tables to CHAR, to ensure that
+# we can use the privilege tables in MySQL 4.1
+# Note that for this hack to work, we must change all CHAR() columns at
+# the same time
+#
+
+ALTER TABLE mysql.user
+modify Host char(60) binary DEFAULT '' NOT NULL,
+modify User char(16) binary DEFAULT '' NOT NULL,
+modify Password char(41) binary DEFAULT '' NOT NULL;
+
+ALTER TABLE mysql.db
+modify Host char(60) binary DEFAULT '' NOT NULL,
+modify Db char(64) binary DEFAULT '' NOT NULL,
+modify User char(16) binary DEFAULT '' NOT NULL;
+
+ALTER TABLE mysql.host
+modify Host char(60) binary DEFAULT '' NOT NULL,
+modify Db char(64) binary DEFAULT '' NOT NULL;
+
+ALTER TABLE help_topic
+modify name char(64) not null,
+modify url char(128) not null;
+
+ALTER TABLE help_category
+modify name char(64) not null,
+modify url char(128) not null;
+
+ALTER TABLE help_keyword
+modify name char(64) not null;
diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc
index 9831ad3a891..426f0cc40b2 100644
--- a/server-tools/instance-manager/commands.cc
+++ b/server-tools/instance-manager/commands.cc
@@ -14,14 +14,17 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include "command.h"
#include "commands.h"
-#include "instance.h"
+
#include "instance_map.h"
#include "messages.h"
+#include "mysqld_error.h"
+#include "mysql_manager_error.h"
#include "protocol.h"
#include "buffer.h"
+
#include <m_string.h>
+#include <mysql.h>
/* implementation for Show_instances: */
diff --git a/server-tools/instance-manager/commands.h b/server-tools/instance-manager/commands.h
index cd13bf09549..bab67f9c6b4 100644
--- a/server-tools/instance-manager/commands.h
+++ b/server-tools/instance-manager/commands.h
@@ -16,8 +16,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include "command.h"
#include "instance.h"
-#include "my_global.h"
/*
Print all instances of this instance manager.
diff --git a/server-tools/instance-manager/factory.cc b/server-tools/instance-manager/factory.cc
index cde5d0564aa..538d9353983 100644
--- a/server-tools/instance-manager/factory.cc
+++ b/server-tools/instance-manager/factory.cc
@@ -15,11 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "factory.h"
-#include "my_global.h"
-
-#include <stdio.h>
-#include <ctype.h>
-
Show_instances *Command_factory::new_Show_instances()
{
diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc
index 4fbfaf2672d..5d89f167f2f 100644
--- a/server-tools/instance-manager/guardian.cc
+++ b/server-tools/instance-manager/guardian.cc
@@ -20,10 +20,12 @@
#endif
#include "guardian.h"
+
#include "instance_map.h"
#include "instance.h"
#include "mysql_manager_error.h"
#include "log.h"
+
#include <string.h>
#include <sys/types.h>
#include <signal.h>
diff --git a/server-tools/instance-manager/guardian.h b/server-tools/instance-manager/guardian.h
index e43b5d565d7..502dc86b2ae 100644
--- a/server-tools/instance-manager/guardian.h
+++ b/server-tools/instance-manager/guardian.h
@@ -17,9 +17,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_global.h>
+#include "thread_registry.h"
+
#include <my_sys.h>
#include <my_list.h>
-#include "thread_registry.h"
#ifdef __GNUC__
#pragma interface
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 97282f3f800..00fcf6c3a98 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -19,16 +19,17 @@
#endif
#include "instance.h"
+
#include "mysql_manager_error.h"
#include "log.h"
#include "instance_map.h"
#include "priv.h"
+#include <sys/wait.h>
#include <my_sys.h>
#include <signal.h>
#include <m_string.h>
-#include <sys/wait.h>
-
+#include <mysql.h>
C_MODE_START
diff --git a/server-tools/instance-manager/instance.h b/server-tools/instance-manager/instance.h
index c141ff7b30d..14ef5cfcfb9 100644
--- a/server-tools/instance-manager/instance.h
+++ b/server-tools/instance-manager/instance.h
@@ -17,8 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_global.h>
-#include <my_sys.h>
-#include <mysql.h>
#include "instance_options.h"
#ifdef __GNUC__
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index d19d42662e5..3e76c24a9a1 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -19,10 +19,11 @@
#endif
#include "instance_map.h"
+
#include "buffer.h"
#include "instance.h"
+
#include <m_ctype.h>
-#include <my_sys.h>
#include <mysql_com.h>
#include <m_string.h>
diff --git a/server-tools/instance-manager/instance_map.h b/server-tools/instance-manager/instance_map.h
index 8d8ea33cf5d..46247c82a16 100644
--- a/server-tools/instance-manager/instance_map.h
+++ b/server-tools/instance-manager/instance_map.h
@@ -17,6 +17,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_global.h>
+
+#include "protocol.h"
+#include "guardian.h"
+
#include <my_sys.h>
#include <hash.h>
@@ -24,9 +28,6 @@
#pragma interface
#endif
-#include "protocol.h"
-#include "guardian.h"
-
class Instance;
extern int load_all_groups(char ***groups, const char *filename);
extern void free_groups(char **groups);
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index e1b81bc93b1..0d602f88ad2 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -19,8 +19,10 @@
#endif
#include "instance_options.h"
+
#include "parse_output.h"
#include "buffer.h"
+
#include <my_sys.h>
#include <mysql.h>
#include <signal.h>
diff --git a/server-tools/instance-manager/log.cc b/server-tools/instance-manager/log.cc
index dbcea3f9c3d..5491b4e70e9 100644
--- a/server-tools/instance-manager/log.cc
+++ b/server-tools/instance-manager/log.cc
@@ -14,8 +14,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include "log.h"
#include <my_global.h>
+
+#include "log.h"
+
#include <stdarg.h>
#include <m_string.h>
#include <my_sys.h>
diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc
index 8629c5e9d9c..fd8673c4d66 100644
--- a/server-tools/instance-manager/manager.cc
+++ b/server-tools/instance-manager/manager.cc
@@ -14,6 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
#include "manager.h"
#include "priv.h"
@@ -25,7 +26,6 @@
#include "log.h"
#include "guardian.h"
-#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <signal.h>
diff --git a/server-tools/instance-manager/messages.cc b/server-tools/instance-manager/messages.cc
index e3c2423a47e..d044c0f65db 100644
--- a/server-tools/instance-manager/messages.cc
+++ b/server-tools/instance-manager/messages.cc
@@ -13,11 +13,14 @@
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 */
-#include "messages.h"
#include <my_global.h>
-#include <mysql_com.h>
+#include "messages.h"
+#include "mysqld_error.h"
+#include "mysql_manager_error.h"
+
+#include <mysql_com.h>
#include <assert.h>
diff --git a/server-tools/instance-manager/messages.h b/server-tools/instance-manager/messages.h
index 4cc15b5efe4..b771efe5e13 100644
--- a/server-tools/instance-manager/messages.h
+++ b/server-tools/instance-manager/messages.h
@@ -16,9 +16,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include "mysqld_error.h"
-#include "mysql_manager_error.h"
-
const char *message(unsigned sql_errno);
const char *errno_to_sqlstate(unsigned sql_errno);
diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc
index 7947de70459..215dbe51b58 100644
--- a/server-tools/instance-manager/mysql_connection.cc
+++ b/server-tools/instance-manager/mysql_connection.cc
@@ -19,14 +19,10 @@
#endif
#include "mysql_connection.h"
-#include "priv.h"
-
-#include <mysql.h>
-#include <violite.h>
-#include <mysql_com.h>
-#include <m_string.h>
-#include <my_sys.h>
+#include "priv.h"
+#include "mysql_manager_error.h"
+#include "mysqld_error.h"
#include "thread_registry.h"
#include "log.h"
#include "user_map.h"
@@ -36,6 +32,13 @@
#include "factory.h"
#include "parse.h"
+#include <mysql.h>
+#include <violite.h>
+#include <mysql_com.h>
+#include <m_string.h>
+#include <my_sys.h>
+
+
Command *parse_command(Command_factory * factory, const char *text);
Mysql_connection_thread_args::Mysql_connection_thread_args(
diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc
index e1d267b492e..262686c3fab 100644
--- a/server-tools/instance-manager/mysqlmanager.cc
+++ b/server-tools/instance-manager/mysqlmanager.cc
@@ -14,11 +14,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
#include "manager.h"
+
#include "options.h"
#include "log.h"
-#include <my_global.h>
#include <my_sys.h>
#include <string.h>
#include <signal.h>
diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc
index 9e4205b1407..4b5ec27f302 100644
--- a/server-tools/instance-manager/options.cc
+++ b/server-tools/instance-manager/options.cc
@@ -20,14 +20,13 @@
#include "options.h"
-#include <my_global.h>
+#include "priv.h"
+
#include <my_sys.h>
#include <my_getopt.h>
#include <m_string.h>
#include <mysql_com.h>
-#include "priv.h"
-
#define QUOTE2(x) #x
#define QUOTE(x) QUOTE2(x)
diff --git a/server-tools/instance-manager/parse.cc b/server-tools/instance-manager/parse.cc
index 4c897ddf933..d3fb10b7c94 100644
--- a/server-tools/instance-manager/parse.cc
+++ b/server-tools/instance-manager/parse.cc
@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "parse.h"
+
#include <string.h>
enum Token
diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc
index 6fee0797395..77fa40ca352 100644
--- a/server-tools/instance-manager/parse_output.cc
+++ b/server-tools/instance-manager/parse_output.cc
@@ -14,10 +14,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
#include "parse.h"
#include <stdio.h>
-#include <my_global.h>
#include <my_sys.h>
#include <string.h>
diff --git a/server-tools/instance-manager/protocol.cc b/server-tools/instance-manager/protocol.cc
index 60cd0e8714f..9c8975a78be 100644
--- a/server-tools/instance-manager/protocol.cc
+++ b/server-tools/instance-manager/protocol.cc
@@ -14,13 +14,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-#include <my_sys.h>
+#include "protocol.h"
+
+#include "messages.h"
+
#include <mysql_com.h>
#include <m_string.h>
-#include "messages.h"
-#include "protocol.h"
static char eof_buff[1]= { (char) 254 }; /* Marker for end of fields */
diff --git a/server-tools/instance-manager/protocol.h b/server-tools/instance-manager/protocol.h
index 1102f95ff8f..b7b18b4b76c 100644
--- a/server-tools/instance-manager/protocol.h
+++ b/server-tools/instance-manager/protocol.h
@@ -17,6 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "buffer.h"
+
#include <my_list.h>
typedef struct field {
diff --git a/server-tools/instance-manager/thread_registry.cc b/server-tools/instance-manager/thread_registry.cc
index bf01aa6d7b2..16821df4146 100644
--- a/server-tools/instance-manager/thread_registry.cc
+++ b/server-tools/instance-manager/thread_registry.cc
@@ -20,10 +20,11 @@
#include "thread_registry.h"
+#include "log.h"
+
#include <assert.h>
#include <signal.h>
#include <thr_alarm.h>
-#include "log.h"
/* Kick-off signal handler */
diff --git a/server-tools/instance-manager/user_map.h b/server-tools/instance-manager/user_map.h
index dcd2fd1494d..4c86edd93d9 100644
--- a/server-tools/instance-manager/user_map.h
+++ b/server-tools/instance-manager/user_map.h
@@ -17,10 +17,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef __GNUC__
-#pragma interface
+#pragma interface
#endif
#include <my_global.h>
+
#include <my_sys.h>
#include <hash.h>
diff --git a/sql-common/client.c b/sql-common/client.c
index 2c73cb4d07c..f28ea65fabf 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -405,6 +405,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
char *suffix_pos;
DWORD error_allow = 0;
DWORD error_code = 0;
+ DWORD event_access_rights= SYNCHRONIZE | EVENT_MODIFY_STATE;
char *shared_memory_base_name = mysql->options.shared_memory_base_name;
/*
@@ -416,13 +417,13 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
*/
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
strmov(suffix_pos, "CONNECT_REQUEST");
- if (!(event_connect_request= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
+ if (!(event_connect_request= OpenEvent(event_access_rights, FALSE, tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR;
goto err;
}
strmov(suffix_pos, "CONNECT_ANSWER");
- if (!(event_connect_answer= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
+ if (!(event_connect_answer= OpenEvent(event_access_rights,FALSE,tmp)))
{
error_allow = CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR;
goto err;
@@ -484,35 +485,35 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
}
strmov(suffix_pos, "SERVER_WROTE");
- if ((event_server_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+ if ((event_server_wrote = OpenEvent(event_access_rights,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "SERVER_READ");
- if ((event_server_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+ if ((event_server_read = OpenEvent(event_access_rights,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CLIENT_WROTE");
- if ((event_client_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+ if ((event_client_wrote = OpenEvent(event_access_rights,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CLIENT_READ");
- if ((event_client_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+ if ((event_client_read = OpenEvent(event_access_rights,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
strmov(suffix_pos, "CONNECTION_CLOSED");
- if ((event_conn_closed = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+ if ((event_conn_closed = OpenEvent(event_access_rights,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 1f766564f56..783ea7dfda6 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -62,9 +62,8 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
parse_file.h sql_view.h sql_trigger.h \
examples/ha_example.h examples/ha_archive.h \
- examples/ha_tina.h \
+ examples/ha_tina.h ha_blackhole.h \
ha_federated.h
-
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
item.cc item_sum.cc item_buff.cc item_func.cc \
item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
@@ -100,7 +99,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
sp_cache.cc parse_file.cc sql_trigger.cc \
examples/ha_example.cc examples/ha_archive.cc \
- examples/ha_tina.cc \
+ examples/ha_tina.cc ha_blackhole.cc \
ha_federated.cc
gen_lex_hash_SOURCES = gen_lex_hash.cc
diff --git a/sql/field.cc b/sql/field.cc
index b6dd00d62a7..f3666f862af 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -48,6 +48,936 @@ const char field_separator=',';
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320
+/*
+ Rules for merging different types of fields in UNION
+
+ NOTE: to avoid 256*256 table, gap in table types numeration is skiped
+ following #defines describe that gap and how to canculate number of fields
+ and index of field in thia array.
+*/
+#define FIELDTYPE_TEAR_FROM (MYSQL_TYPE_BIT + 1)
+#define FIELDTYPE_TEAR_TO (MYSQL_TYPE_NEWDECIMAL - 1)
+#define FIELDTYPE_NUM (FIELDTYPE_TEAR_FROM + (255 - FIELDTYPE_TEAR_TO))
+inline int field_type2index (enum_field_types field_type)
+{
+ return (field_type < FIELDTYPE_TEAR_FROM ?
+ field_type :
+ ((int)FIELDTYPE_TEAR_FROM) + (field_type - FIELDTYPE_TEAR_TO) - 1);
+}
+
+static enum_field_types field_types_merge_rules [FIELDTYPE_NUM][FIELDTYPE_NUM]=
+{
+ /* MYSQL_TYPE_DECIMAL -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NEWDECIMAL,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NEWDECIMAL,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_DECIMAL, MYSQL_TYPE_DECIMAL,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_TINY -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_TINY,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_TINY, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_SHORT -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_SHORT,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_SHORT,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_LONG -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_LONG, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_LONG, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_FLOAT -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_FLOAT,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_DOUBLE -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_NULL -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_TINY,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_TIME,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_BIT,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_ENUM,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_SET, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_GEOMETRY
+ },
+ /* MYSQL_TYPE_TIMESTAMP -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TIMESTAMP,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_LONGLONG -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_LONGLONG,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_LONGLONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_LONGLONG,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_INT24 -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_INT24, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_INT24, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_DATE -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_TIME -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_TIME,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_DATETIME -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_YEAR -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_YEAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_YEAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_NEWDATE -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_DATETIME,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_VARCHAR -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_BIT -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_BIT, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_BIT,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_NEWDECIMAL -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NEWDECIMAL,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NEWDECIMAL,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_DOUBLE, MYSQL_TYPE_DOUBLE,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NEWDECIMAL,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_NEWDECIMAL,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_ENUM -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_ENUM, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_SET -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_SET, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_TINY_BLOB -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_TINY_BLOB
+ },
+ /* MYSQL_TYPE_MEDIUM_BLOB -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_MEDIUM_BLOB
+ },
+ /* MYSQL_TYPE_LONG_BLOB -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONG_BLOB
+ },
+ /* MYSQL_TYPE_BLOB -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_BLOB
+ },
+ /* MYSQL_TYPE_VAR_STRING -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR
+ },
+ /* MYSQL_TYPE_STRING -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_STRING, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_STRING
+ },
+ /* MYSQL_TYPE_GEOMETRY -> */
+ {
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ MYSQL_TYPE_GEOMETRY, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_BIT <16>-<245>
+ MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ MYSQL_TYPE_VARCHAR, MYSQL_TYPE_TINY_BLOB,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ MYSQL_TYPE_BLOB, MYSQL_TYPE_VARCHAR,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ MYSQL_TYPE_STRING, MYSQL_TYPE_GEOMETRY
+ }
+};
+
+/*
+ Return type of which can carry value of both given types in UNION result
+
+ SYNOPSIS
+ Field::field_type_merge()
+ a, b types for merging
+
+ RETURN
+ type of field
+*/
+
+enum_field_types Field::field_type_merge(enum_field_types a,
+ enum_field_types b)
+{
+ DBUG_ASSERT(a < FIELDTYPE_TEAR_FROM || a > FIELDTYPE_TEAR_TO);
+ DBUG_ASSERT(b < FIELDTYPE_TEAR_FROM || b > FIELDTYPE_TEAR_TO);
+ return field_types_merge_rules[field_type2index(a)]
+ [field_type2index(b)];
+}
+
+
+static Item_result field_types_result_type [FIELDTYPE_NUM]=
+{
+ //MYSQL_TYPE_DECIMAL MYSQL_TYPE_TINY
+ DECIMAL_RESULT, INT_RESULT,
+ //MYSQL_TYPE_SHORT MYSQL_TYPE_LONG
+ INT_RESULT, INT_RESULT,
+ //MYSQL_TYPE_FLOAT MYSQL_TYPE_DOUBLE
+ REAL_RESULT, REAL_RESULT,
+ //MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
+ STRING_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
+ INT_RESULT, INT_RESULT,
+ //MYSQL_TYPE_DATE MYSQL_TYPE_TIME
+ STRING_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR
+ STRING_RESULT, INT_RESULT,
+ //MYSQL_TYPE_NEWDATE MYSQL_TYPE_VARCHAR
+ STRING_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_BIT <16>-<245>
+ STRING_RESULT,
+ //MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_ENUM
+ DECIMAL_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_SET MYSQL_TYPE_TINY_BLOB
+ STRING_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_MEDIUM_BLOB MYSQL_TYPE_LONG_BLOB
+ STRING_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_BLOB MYSQL_TYPE_VAR_STRING
+ STRING_RESULT, STRING_RESULT,
+ //MYSQL_TYPE_STRING MYSQL_TYPE_GEOMETRY
+ STRING_RESULT, STRING_RESULT
+};
+
+
+/*
+ Detect Item_result by given field type of UNION merge result
+
+ SYNOPSIS
+ Field::result_merge_type()
+ field_type given field type
+
+ RETURN
+ Item_result (type of internal MySQL expression result)
+*/
+
+Item_result Field::result_merge_type(enum_field_types field_type)
+{
+ DBUG_ASSERT(field_type < FIELDTYPE_TEAR_FROM || field_type
+ > FIELDTYPE_TEAR_TO);
+ return field_types_result_type[field_type2index(field_type)];
+}
+
/*****************************************************************************
Static help functions
*****************************************************************************/
@@ -229,164 +1159,6 @@ static bool test_if_real(const char *str,int length, CHARSET_INFO *cs)
/*
- Tables of filed type compatibility.
-
- There are tables for every type, table consist of list of types in which
- given type can be converted without data lost, list should be ended with
- FIELD_CAST_STOP
-*/
-static Field::field_cast_enum field_cast_decimal[]=
-{Field::FIELD_CAST_DECIMAL,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_new_decimal[]=
-{Field::FIELD_CAST_NEWDECIMAL,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_tiny[]=
-{Field::FIELD_CAST_TINY,
- Field::FIELD_CAST_SHORT, Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG,
- Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_short[]=
-{Field::FIELD_CAST_SHORT,
- Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_medium[]=
-{Field::FIELD_CAST_MEDIUM,
- Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_long[]=
-{Field::FIELD_CAST_LONG,
- Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_longlong[]=
-{Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_float[]=
-{Field::FIELD_CAST_FLOAT,
- Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_double[]=
-{Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_null[]=
-{Field::FIELD_CAST_NULL,
- Field::FIELD_CAST_DECIMAL, Field::FIELD_CAST_TINY, Field::FIELD_CAST_SHORT,
- Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG, Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_TIMESTAMP, Field::FIELD_CAST_YEAR,
- Field::FIELD_CAST_DATE, Field::FIELD_CAST_NEWDATE,
- Field::FIELD_CAST_TIME, Field::FIELD_CAST_DATETIME,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB,
- Field::FIELD_CAST_GEOM, Field::FIELD_CAST_ENUM, Field::FIELD_CAST_SET,
- Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_timestamp[]=
-{Field::FIELD_CAST_TIMESTAMP,
- Field::FIELD_CAST_DATETIME,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_year[]=
-{Field::FIELD_CAST_YEAR,
- Field::FIELD_CAST_SHORT, Field::FIELD_CAST_MEDIUM, Field::FIELD_CAST_LONG,
- Field::FIELD_CAST_LONGLONG,
- Field::FIELD_CAST_FLOAT, Field::FIELD_CAST_DOUBLE,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_date[]=
-{Field::FIELD_CAST_DATE,
- Field::FIELD_CAST_DATETIME,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_newdate[]=
-{Field::FIELD_CAST_NEWDATE,
- Field::FIELD_CAST_DATE,
- Field::FIELD_CAST_DATETIME,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_time[]=
-{Field::FIELD_CAST_TIME,
- Field::FIELD_CAST_DATETIME,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_datetime[]=
-{Field::FIELD_CAST_DATETIME,
- Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_string[]=
-{Field::FIELD_CAST_STRING,
- Field::FIELD_CAST_VARSTRING, Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_varstring[]=
-{Field::FIELD_CAST_VARSTRING,
- Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_blob[]=
-{Field::FIELD_CAST_BLOB,
- Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_bit[]=
-{Field::FIELD_CAST_BIT,
- Field::FIELD_CAST_STOP};
-/*
- Geometrical, enum and set fields can be casted only to expressions
-*/
-static Field::field_cast_enum field_cast_geom[]=
-{Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_enum[]=
-{Field::FIELD_CAST_STOP};
-static Field::field_cast_enum field_cast_set[]=
-{Field::FIELD_CAST_STOP};
-// Array of pointers on conversion table for all fields types casting
-static Field::field_cast_enum *field_cast_array[]=
-{0, //FIELD_CAST_STOP
- field_cast_decimal, field_cast_tiny, field_cast_short,
- field_cast_medium, field_cast_long, field_cast_longlong,
- field_cast_float, field_cast_double,
- field_cast_null,
- field_cast_timestamp, field_cast_year, field_cast_date, field_cast_newdate,
- field_cast_time, field_cast_datetime,
- field_cast_string, field_cast_varstring, field_cast_blob,
- field_cast_geom, field_cast_enum, field_cast_set, field_cast_bit,
- field_cast_new_decimal
-};
-
-
-/*
- Check if field of given type can store a value of this field.
-
- SYNOPSIS
- type type for test
-
- RETURN
- 1 can
- 0 can not
-*/
-
-bool Field::field_cast_compatible(Field::field_cast_enum type)
-{
- DBUG_ASSERT(type != FIELD_CAST_STOP);
- Field::field_cast_enum *array= field_cast_array[field_cast_type()];
- while (*array != FIELD_CAST_STOP)
- {
- if (*(array++) == type)
- return 1;
- }
- return 0;
-}
-
-
-/*
Interpret field value as an integer but return the result as a string.
This is used for printing bit_fields as numbers while debugging
@@ -473,8 +1245,13 @@ void Field_num::add_zerofill_and_unsigned(String &res) const
void Field::make_field(Send_field *field)
{
- field->db_name= orig_table->s->table_cache_key;
- field->org_table_name= orig_table->s->table_name;
+ if (orig_table->s->table_cache_key && *(orig_table->s->table_cache_key))
+ {
+ field->org_table_name= orig_table->s->table_name;
+ field->db_name= orig_table->s->table_cache_key;
+ }
+ else
+ field->org_table_name= field->db_name= "";
field->table_name= orig_table->alias;
field->col_name= field->org_col_name= field_name;
field->charsetnr= charset()->number;
@@ -752,25 +1529,22 @@ bool Field::quote_data(String *unquoted_string)
{
char escaped_string[IO_SIZE];
char *unquoted_string_buffer= (char *)(unquoted_string->ptr());
- uint need_quotes;
DBUG_ENTER("Field::quote_data");
- // this is the same call that mysql_real_escape_string() calls
- escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
- unquoted_string->ptr(), unquoted_string->length());
-
- need_quotes= needs_quotes();
-
- if (need_quotes == 0)
+ if (!needs_quotes())
DBUG_RETURN(0);
+ // this is the same call that mysql_real_escape_string() calls
+ if (escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
+ sizeof(escaped_string), unquoted_string->ptr(),
+ unquoted_string->length()) == (ulong)~0)
+ DBUG_RETURN(1);
+
// reset string, then re-append with quotes and escaped values
unquoted_string->length(0);
- if (unquoted_string->append('\''))
- DBUG_RETURN(1);
- if (unquoted_string->append((char *)escaped_string))
- DBUG_RETURN(1);
- if (unquoted_string->append('\''))
+ if (unquoted_string->append('\'') ||
+ unquoted_string->append((char *)escaped_string) ||
+ unquoted_string->append('\''))
DBUG_RETURN(1);
DBUG_RETURN(0);
}
@@ -2451,14 +3225,15 @@ static bool test_if_minus(CHARSET_INFO *cs,
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
+ ulong tmp_scan;
longlong tmp;
long store_tmp;
int error;
char *end;
- tmp= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES);
- len-= tmp;
- from+= tmp;
+ tmp_scan= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES);
+ len-= tmp_scan;
+ from+= tmp_scan;
end= (char*) from+len;
tmp= cs->cset->my_strtoll10(cs, from, &end, &error);
@@ -4701,15 +5476,19 @@ int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
TIME time_tmp;
int error;
ulonglong tmp= 0;
+ enum enum_mysql_timestamp_type func_res;
- if (str_to_datetime(from, len, &time_tmp,
- (TIME_FUZZY_DATE |
- (table->in_use->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))),
- &error) > MYSQL_TIMESTAMP_ERROR)
+ func_res= str_to_datetime(from, len, &time_tmp,
+ (TIME_FUZZY_DATE |
+ (table->in_use->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))),
+ &error);
+ if ((int) func_res > (int) MYSQL_TIMESTAMP_ERROR)
tmp= TIME_to_ulonglong_datetime(&time_tmp);
-
+ else
+ error= 1; // Fix if invalid zero date
+
if (error)
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
@@ -5724,12 +6503,12 @@ void Field_varstring::get_key_image(char *buff, uint length, imagetype type)
{
uint f_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr);
uint char_length= length / field_charset->mbmaxlen;
- char_length= my_charpos(field_charset, ptr, ptr + length_bytes,
- char_length);
+ char *pos= ptr+length_bytes;
+ char_length= my_charpos(field_charset, pos, pos + f_length, char_length);
set_if_smaller(f_length, char_length);
/* Key is always stored with 2 bytes */
int2store(buff,f_length);
- memcpy(buff+HA_KEY_BLOB_LENGTH, ptr+length_bytes, f_length);
+ memcpy(buff+HA_KEY_BLOB_LENGTH, pos, f_length);
if (f_length < length)
{
/*
@@ -7002,8 +7781,10 @@ longlong Field_bit::val_int(void)
{
ulonglong bits= 0;
if (bit_len)
+ {
bits= get_rec_bits(bit_ptr, bit_ofs, bit_len);
- bits<<= (field_length * 8);
+ bits<<= (field_length * 8);
+ }
switch (field_length) {
case 0: return bits;
@@ -7419,40 +8200,6 @@ Field *make_field(char *ptr, uint32 field_length,
}
-/*
- Check if field_type is appropriate field type
- to create field for tmp table using
- item->tmp_table_field() method
-
- SYNOPSIS
- field_types_to_be_kept()
- field_type - field type
-
- NOTE
- it is used in function get_holder_example_field()
- from item.cc
-
- RETURN
- 1 - can use item->tmp_table_field() method
- 0 - can not use item->tmp_table_field() method
-
-*/
-
-bool field_types_to_be_kept(enum_field_types field_type)
-{
- switch (field_type)
- {
- case FIELD_TYPE_DATE:
- case FIELD_TYPE_NEWDATE:
- case FIELD_TYPE_TIME:
- case FIELD_TYPE_DATETIME:
- return 1;
- default:
- return 0;
- }
-}
-
-
/* Create a field suitable for create of table */
create_field::create_field(Field *old_field,Field *orig_field)
diff --git a/sql/field.h b/sql/field.h
index 5b13ba1042a..ce6753400bb 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -31,6 +31,17 @@ class Protocol;
struct st_cache_field;
void field_conv(Field *to,Field *from);
+inline uint get_enum_pack_length(int elements)
+{
+ return elements < 256 ? 1 : 2;
+}
+
+inline uint get_set_pack_length(int elements)
+{
+ uint len= (elements + 7) / 8;
+ return len > 4 ? 8 : len;
+}
+
class Field
{
Field(const Item &); /* Prevent use of these */
@@ -49,7 +60,7 @@ public:
struct st_table *orig_table; // Pointer to original table
const char **table_name, *field_name;
LEX_STRING comment;
- ulong query_id; // For quick test of used fields
+ query_id_t query_id; // For quick test of used fields
/* Field is part of the following keys */
key_map key_start,part_of_key,part_of_sortkey;
/*
@@ -71,18 +82,6 @@ public:
GEOM_GEOMETRYCOLLECTION = 7
};
enum imagetype { itRAW, itMBR};
- enum field_cast_enum
- {
- FIELD_CAST_STOP, FIELD_CAST_DECIMAL, FIELD_CAST_TINY, FIELD_CAST_SHORT,
- FIELD_CAST_MEDIUM, FIELD_CAST_LONG, FIELD_CAST_LONGLONG,
- FIELD_CAST_FLOAT, FIELD_CAST_DOUBLE,
- FIELD_CAST_NULL,
- FIELD_CAST_TIMESTAMP, FIELD_CAST_YEAR, FIELD_CAST_DATE, FIELD_CAST_NEWDATE,
- FIELD_CAST_TIME, FIELD_CAST_DATETIME,
- FIELD_CAST_STRING, FIELD_CAST_VARSTRING, FIELD_CAST_BLOB,
- FIELD_CAST_GEOM, FIELD_CAST_ENUM, FIELD_CAST_SET, FIELD_CAST_BIT,
- FIELD_CAST_NEWDECIMAL
- };
utype unireg_check;
uint32 field_length; // Length of field
@@ -119,6 +118,8 @@ public:
String *val_int_as_str(String *val_buffer, my_bool unsigned_flag);
virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); }
+ static enum_field_types field_type_merge(enum_field_types, enum_field_types);
+ static Item_result result_merge_type(enum_field_types);
bool eq(Field *field)
{
return (ptr == field->ptr && null_ptr == field->null_ptr &&
@@ -296,8 +297,6 @@ public:
return (op_result == E_DEC_OVERFLOW);
}
int warn_if_overflow(int op_result);
- virtual field_cast_enum field_cast_type()= 0;
- bool field_cast_compatible(field_cast_enum type);
/* maximum possible display length */
virtual uint32 max_length()= 0;
/* length of field value symbolic representation (in bytes) */
@@ -432,7 +431,6 @@ public:
bool zero_pack() const { return 0; }
void sql_type(String &str) const;
uint32 max_length() { return field_length; }
- field_cast_enum field_cast_type() { return FIELD_CAST_DECIMAL; }
};
@@ -470,7 +468,6 @@ public:
{ return field_length + 1 + (dec ? 1 : 0) + (field_length == dec ? 1 : 0); }
uint32 representation_length()
{ return field_length + 1 + (dec ? 1 : 0) + (field_length == dec ? 1 : 0); };
- field_cast_enum field_cast_type() { return FIELD_CAST_NEWDECIMAL; }
uint size_of() const { return sizeof(*this); }
uint32 pack_length() const { return (uint32) bin_size; }
};
@@ -504,7 +501,6 @@ public:
uint32 pack_length() const { return 1; }
void sql_type(String &str) const;
uint32 max_length() { return 4; }
- field_cast_enum field_cast_type() { return FIELD_CAST_TINY; }
};
@@ -541,7 +537,6 @@ public:
uint32 pack_length() const { return 2; }
void sql_type(String &str) const;
uint32 max_length() { return 6; }
- field_cast_enum field_cast_type() { return FIELD_CAST_SHORT; }
};
@@ -573,7 +568,6 @@ public:
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
uint32 max_length() { return 8; }
- field_cast_enum field_cast_type() { return FIELD_CAST_MEDIUM; }
};
@@ -610,7 +604,6 @@ public:
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
uint32 max_length() { return 11; }
- field_cast_enum field_cast_type() { return FIELD_CAST_LONG; }
};
@@ -650,7 +643,6 @@ public:
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
uint32 max_length() { return 20; }
- field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; }
};
#endif
@@ -686,7 +678,6 @@ public:
uint32 pack_length() const { return sizeof(float); }
void sql_type(String &str) const;
uint32 max_length() { return 24; }
- field_cast_enum field_cast_type() { return FIELD_CAST_FLOAT; }
};
@@ -721,7 +712,6 @@ public:
uint32 pack_length() const { return sizeof(double); }
void sql_type(String &str) const;
uint32 max_length() { return 53; }
- field_cast_enum field_cast_type() { return FIELD_CAST_DOUBLE; }
};
@@ -754,7 +744,6 @@ public:
void sql_type(String &str) const;
uint size_of() const { return sizeof(*this); }
uint32 max_length() { return 4; }
- field_cast_enum field_cast_type() { return FIELD_CAST_NULL; }
};
@@ -806,7 +795,6 @@ public:
}
bool get_date(TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime);
- field_cast_enum field_cast_type() { return FIELD_CAST_TIMESTAMP; }
timestamp_auto_set_type get_auto_set_type() const;
};
@@ -830,7 +818,6 @@ public:
bool send_binary(Protocol *protocol);
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
- field_cast_enum field_cast_type() { return FIELD_CAST_YEAR; }
};
@@ -863,7 +850,6 @@ public:
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
- field_cast_enum field_cast_type() { return FIELD_CAST_DATE; }
};
class Field_newdate :public Field_str {
@@ -895,7 +881,6 @@ public:
bool zero_pack() const { return 1; }
bool get_date(TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime);
- field_cast_enum field_cast_type() { return FIELD_CAST_NEWDATE; }
};
@@ -931,7 +916,6 @@ public:
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
- field_cast_enum field_cast_type() { return FIELD_CAST_TIME; }
};
@@ -969,7 +953,6 @@ public:
bool zero_pack() const { return 1; }
bool get_date(TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime);
- field_cast_enum field_cast_type() { return FIELD_CAST_DATETIME; }
};
@@ -1018,7 +1001,6 @@ public:
enum_field_types real_type() const { return FIELD_TYPE_STRING; }
bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
- field_cast_enum field_cast_type() { return FIELD_CAST_STRING; }
Field *new_field(MEM_ROOT *root, struct st_table *new_table);
};
@@ -1085,7 +1067,6 @@ public:
enum_field_types real_type() const { return MYSQL_TYPE_VARCHAR; }
bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
- field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; }
Field *new_field(MEM_ROOT *root, struct st_table *new_table);
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
char *new_ptr, uchar *new_null_ptr,
@@ -1183,7 +1164,6 @@ public:
uint size_of() const { return sizeof(*this); }
bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
- field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; }
uint32 max_length();
};
@@ -1213,7 +1193,6 @@ public:
int store(longlong nr) { return 1; }
int store_decimal(const my_decimal *) { return 1; }
void get_key_image(char *buff,uint length,imagetype type);
- field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; }
};
#endif /*HAVE_SPATIAL*/
@@ -1258,7 +1237,6 @@ public:
bool has_charset(void) const { return TRUE; }
/* enum and set are sorted as integers */
CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
- field_cast_enum field_cast_type() { return FIELD_CAST_ENUM; }
};
@@ -1284,7 +1262,6 @@ public:
void sql_type(String &str) const;
enum_field_types real_type() const { return FIELD_TYPE_SET; }
bool has_charset(void) const { return TRUE; }
- field_cast_enum field_cast_type() { return FIELD_CAST_SET; }
};
@@ -1327,7 +1304,6 @@ public:
{ return (uint32) field_length + (bit_len > 0); }
uint32 pack_length_in_rec() const { return field_length; }
void sql_type(String &str) const;
- field_cast_enum field_cast_type() { return FIELD_CAST_BIT; }
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
const char *unpack(char* to, const char *from);
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
@@ -1424,7 +1400,6 @@ enum_field_types get_blob_type_from_length(ulong length);
uint32 calc_pack_length(enum_field_types type,uint32 length);
int set_field_to_null(Field *field);
int set_field_to_null_with_conversions(Field *field, bool no_conversions);
-bool field_types_to_be_kept(enum_field_types field_type);
/*
The following are for the interface with the .frm file
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index a6cc05e1fdb..54d9865ddd5 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -372,9 +372,8 @@ void berkeley_cleanup_log_files(void)
** Berkeley DB tables
*****************************************************************************/
-static const char *ha_bdb_bas_exts[]= { ha_berkeley_ext, NullS };
const char **ha_berkeley::bas_ext() const
-{ return ha_bdb_bas_exts; }
+{ static const char *ext[]= { ha_berkeley_ext, NullS }; return ext; }
ulong ha_berkeley::index_flags(uint idx, uint part, bool all_parts) const
@@ -1548,7 +1547,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
do_prev= 1;
}
if (key_len == key_info->key_length &&
- !table->key_info[active_index].flags & HA_END_SPACE_KEY)
+ !(table->key_info[active_index].flags & HA_END_SPACE_KEY))
{
if (find_flag == HA_READ_AFTER_KEY)
key_info->handler.bdb_return_if_eq= 1;
@@ -1646,7 +1645,7 @@ int ha_berkeley::index_next_same(byte * buf, const byte *key, uint keylen)
&LOCK_status);
bzero((char*) &row,sizeof(row));
if (keylen == table->key_info[active_index].key_length &&
- !table->key_info[active_index].flags & HA_END_SPACE_KEY)
+ !(table->key_info[active_index].flags & HA_END_SPACE_KEY))
error=read_row(cursor->c_get(cursor, &last_key, &row, DB_NEXT_DUP),
(char*) buf, active_index, &row, &last_key, 1);
else
diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc
new file mode 100644
index 00000000000..e34d5d723a4
--- /dev/null
+++ b/sql/ha_blackhole.cc
@@ -0,0 +1,188 @@
+/* Copyright (C) 2005 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+
+#ifdef __GNUC__
+#pragma implementation // gcc: Class implementation
+#endif
+
+#include <mysql_priv.h>
+
+#ifdef HAVE_BLACKHOLE_DB
+#include "ha_blackhole.h"
+
+
+const char **ha_blackhole::bas_ext() const
+{
+ static const char *ext[]= { NullS };
+ return ext;
+}
+
+int ha_blackhole::open(const char *name, int mode, uint test_if_locked)
+{
+ DBUG_ENTER("ha_blackhole::open");
+ thr_lock_init(&thr_lock);
+ thr_lock_data_init(&thr_lock,&lock,NULL);
+ DBUG_RETURN(0);
+}
+
+int ha_blackhole::close(void)
+{
+ DBUG_ENTER("ha_blackhole::close");
+ thr_lock_delete(&thr_lock);
+ DBUG_RETURN(0);
+}
+
+int ha_blackhole::create(const char *name, TABLE *table_arg,
+ HA_CREATE_INFO *create_info)
+{
+ DBUG_ENTER("ha_blackhole::create");
+ DBUG_RETURN(0);
+}
+
+const char *ha_blackhole::index_type(uint key_number)
+{
+ DBUG_ENTER("ha_blackhole::index_type");
+ DBUG_RETURN((table->key_info[key_number].flags & HA_FULLTEXT) ?
+ "FULLTEXT" :
+ (table->key_info[key_number].flags & HA_SPATIAL) ?
+ "SPATIAL" :
+ (table->key_info[key_number].algorithm == HA_KEY_ALG_RTREE) ?
+ "RTREE" :
+ "BTREE");
+}
+
+int ha_blackhole::write_row(byte * buf)
+{
+ DBUG_ENTER("ha_blackhole::write_row");
+ DBUG_RETURN(0);
+}
+
+int ha_blackhole::rnd_init(bool scan)
+{
+ DBUG_ENTER("ha_blackhole::rnd_init");
+ DBUG_RETURN(0);
+}
+
+
+int ha_blackhole::rnd_next(byte *buf)
+{
+ DBUG_ENTER("ha_blackhole::rnd_next");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+
+int ha_blackhole::rnd_pos(byte * buf, byte *pos)
+{
+ DBUG_ENTER("ha_blackhole::rnd_pos");
+ DBUG_ASSERT(0);
+ DBUG_RETURN(0);
+}
+
+
+void ha_blackhole::position(const byte *record)
+{
+ DBUG_ENTER("ha_blackhole::position");
+ DBUG_ASSERT(0);
+ DBUG_VOID_RETURN;
+}
+
+
+void ha_blackhole::info(uint flag)
+{
+ DBUG_ENTER("ha_blackhole::info");
+
+ records= 0;
+ deleted= 0;
+ errkey= 0;
+ mean_rec_length= 0;
+ data_file_length= 0;
+ index_file_length= 0;
+ max_data_file_length= 0;
+ delete_length= 0;
+ if (flag & HA_STATUS_AUTO)
+ auto_increment_value= 1;
+ DBUG_VOID_RETURN;
+}
+
+int ha_blackhole::external_lock(THD *thd, int lock_type)
+{
+ DBUG_ENTER("ha_blackhole::external_lock");
+ DBUG_RETURN(0);
+}
+
+
+THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd,
+ THR_LOCK_DATA **to,
+ enum thr_lock_type lock_type)
+{
+ *to++= &lock;
+
+ return to;
+}
+
+
+int ha_blackhole::index_read(byte * buf, const byte * key,
+ uint key_len, enum ha_rkey_function find_flag)
+{
+ DBUG_ENTER("ha_blackhole::index_read");
+ DBUG_RETURN(0);
+}
+
+
+int ha_blackhole::index_read_idx(byte * buf, uint idx, const byte * key,
+ uint key_len, enum ha_rkey_function find_flag)
+{
+ DBUG_ENTER("ha_blackhole::index_read_idx");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+
+int ha_blackhole::index_read_last(byte * buf, const byte * key, uint key_len)
+{
+ DBUG_ENTER("ha_blackhole::index_read_last");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+
+int ha_blackhole::index_next(byte * buf)
+{
+ DBUG_ENTER("ha_blackhole::index_next");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+
+int ha_blackhole::index_prev(byte * buf)
+{
+ DBUG_ENTER("ha_blackhole::index_prev");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+
+int ha_blackhole::index_first(byte * buf)
+{
+ DBUG_ENTER("ha_blackhole::index_first");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+
+int ha_blackhole::index_last(byte * buf)
+{
+ DBUG_ENTER("ha_blackhole::index_last");
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+}
+
+#endif /* HAVE_BLACKHOLE_DB */
diff --git a/sql/ha_blackhole.h b/sql/ha_blackhole.h
new file mode 100644
index 00000000000..b6f924e94b9
--- /dev/null
+++ b/sql/ha_blackhole.h
@@ -0,0 +1,88 @@
+/* Copyright (C) 2005 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifdef __GNUC__
+#pragma interface /* gcc class implementation */
+#endif
+
+/*
+ Class definition for the blackhole storage engine
+ "Dumbest named feature ever"
+*/
+class ha_blackhole: public handler
+{
+ THR_LOCK_DATA lock; /* MySQL lock */
+ THR_LOCK thr_lock;
+
+public:
+ ha_blackhole(TABLE *table): handler(table)
+ {
+ }
+ ~ha_blackhole()
+ {
+ }
+ /* The name that will be used for display purposes */
+ const char *table_type() const { return "BLACKHOLE"; }
+ /*
+ The name of the index type that will be used for display
+ don't implement this method unless you really have indexes
+ */
+ const char *index_type(uint key_number);
+ const char **bas_ext() const;
+ ulong table_flags() const
+ {
+ return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
+ HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
+ HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME |
+ HA_CAN_INSERT_DELAYED);
+ }
+ ulong index_flags(uint inx, uint part, bool all_parts) const
+ {
+ return ((table->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ?
+ 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
+ HA_READ_ORDER | HA_KEYREAD_ONLY);
+ }
+ /* The following defines can be increased if necessary */
+#define BLACKHOLE_MAX_KEY 64 /* Max allowed keys */
+#define BLACKHOLE_MAX_KEY_SEG 16 /* Max segments for key */
+#define BLACKHOLE_MAX_KEY_LENGTH 1000
+ uint max_supported_keys() const { return BLACKHOLE_MAX_KEY; }
+ uint max_supported_key_length() const { return BLACKHOLE_MAX_KEY_LENGTH; }
+ uint max_supported_key_part_length() const { return BLACKHOLE_MAX_KEY_LENGTH; }
+ int open(const char *name, int mode, uint test_if_locked);
+ int close(void);
+ int write_row(byte * buf);
+ int rnd_init(bool scan);
+ int rnd_next(byte *buf);
+ int rnd_pos(byte * buf, byte *pos);
+ int index_read(byte * buf, const byte * key,
+ uint key_len, enum ha_rkey_function find_flag);
+ int index_read_idx(byte * buf, uint idx, const byte * key,
+ uint key_len, enum ha_rkey_function find_flag);
+ int index_read_last(byte * buf, const byte * key, uint key_len);
+ int index_next(byte * buf);
+ int index_prev(byte * buf);
+ int index_first(byte * buf);
+ int index_last(byte * buf);
+ void position(const byte *record);
+ void info(uint flag);
+ int external_lock(THD *thd, int lock_type);
+ int create(const char *name, TABLE *table_arg,
+ HA_CREATE_INFO *create_info);
+ THR_LOCK_DATA **store_lock(THD *thd,
+ THR_LOCK_DATA **to,
+ enum thr_lock_type lock_type);
+};
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index cddd0fd5927..8000aae180d 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -469,6 +469,7 @@ static int check_foreign_data_source(FEDERATED_SHARE *share)
*/
query.append("SHOW TABLES LIKE '");
escape_string_for_mysql(&my_charset_bin, (char *)escaped_table_base_name,
+ sizeof(escaped_table_base_name),
share->table_base_name,
share->table_base_name_length);
query.append(escaped_table_base_name);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 870ad1af52b..e29560f15a5 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -45,7 +45,8 @@ have disables the InnoDB inlining in this file. */
#include "ha_innodb.h"
-pthread_mutex_t innobase_mutex;
+pthread_mutex_t innobase_share_mutex, // to protect innobase_open_files
+ prepare_commit_mutex; // to force correct commit order in binlog
bool innodb_inited= 0;
/* Store MySQL definition of 'byte': in Linux it is char while InnoDB
@@ -1268,7 +1269,8 @@ innobase_init(void)
(void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
(hash_get_key) innobase_get_key, 0, 0);
- pthread_mutex_init(&innobase_mutex, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
innodb_inited= 1;
/* If this is a replication slave and we needed to do a crash recovery,
@@ -1307,6 +1309,9 @@ innobase_end(void)
}
#endif
if (innodb_inited) {
+
+#ifndef __NETWARE__ /* NetWare can't close unclosed files, kill remaining
+ threads, etc, so we disable the very fast shutdown */
if (innobase_very_fast_shutdown) {
srv_very_fast_shutdown = TRUE;
fprintf(stderr,
@@ -1314,6 +1319,7 @@ innobase_end(void)
"InnoDB: the InnoDB buffer pool to data files. At the next mysqld startup\n"
"InnoDB: InnoDB will do a crash recovery!\n");
}
+#endif
innodb_inited = 0;
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
@@ -1322,7 +1328,8 @@ innobase_end(void)
hash_free(&innobase_open_tables);
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_destroy(&innobase_mutex);
+ pthread_mutex_destroy(&innobase_share_mutex);
+ pthread_mutex_destroy(&prepare_commit_mutex);
}
DBUG_RETURN(err);
@@ -1480,9 +1487,20 @@ innobase_commit(
/* We were instructed to commit the whole transaction, or
this is an SQL statement end and autocommit is on */
+ /* We need current binlog position for ibbackup to work.
+ Note, the position is current because of prepare_commit_mutex */
+ trx->mysql_log_file_name = mysql_bin_log.get_log_fname();
+ trx->mysql_log_offset =
+ (ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;
+
innobase_commit_low(trx);
+ if (trx->active_trans == 2) {
+
+ pthread_mutex_unlock(&prepare_commit_mutex);
+ }
trx->active_trans = 0;
+
} else {
/* We just mark the SQL statement ended and do not do a
transaction commit */
@@ -2435,7 +2453,14 @@ ha_innobase::store_key_val_for_row(
(byte*) (record
+ (ulint)get_field_offset(table, field)),
lenlen);
+
+ /* In a column prefix index, we may need to truncate
+ the stored value: */
+ if (len > key_part->length) {
+ len = key_part->length;
+ }
+
/* The length in a key value is always stored in 2
bytes */
@@ -2472,6 +2497,11 @@ ha_innobase::store_key_val_for_row(
ut_a(get_field_offset(table, field)
== key_part->offset);
+
+ /* All indexes on BLOB and TEXT are column prefix
+ indexes, and we may need to truncate the data to be
+ stored in the kay value: */
+
if (blob_len > key_part->length) {
blob_len = key_part->length;
}
@@ -2490,11 +2520,17 @@ ha_innobase::store_key_val_for_row(
buff += key_part->length;
} else {
+ /* Here we handle all other data types except the
+ true VARCHAR, BLOB and TEXT. Note that the column
+ value we store may be also in a column prefix
+ index. */
+
if (is_null) {
buff += key_part->length;
continue;
}
+
memcpy(buff, record + key_part->offset,
key_part->length);
buff += key_part->length;
@@ -5953,7 +5989,7 @@ static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
static INNOBASE_SHARE *get_share(const char *table_name)
{
INNOBASE_SHARE *share;
- pthread_mutex_lock(&innobase_mutex);
+ pthread_mutex_lock(&innobase_share_mutex);
uint length=(uint) strlen(table_name);
if (!(share=(INNOBASE_SHARE*) hash_search(&innobase_open_tables,
(mysql_byte*) table_name,
@@ -5967,7 +6003,7 @@ static INNOBASE_SHARE *get_share(const char *table_name)
strmov(share->table_name,table_name);
if (my_hash_insert(&innobase_open_tables, (mysql_byte*) share))
{
- pthread_mutex_unlock(&innobase_mutex);
+ pthread_mutex_unlock(&innobase_share_mutex);
my_free((gptr) share,0);
return 0;
}
@@ -5976,13 +6012,13 @@ static INNOBASE_SHARE *get_share(const char *table_name)
}
}
share->use_count++;
- pthread_mutex_unlock(&innobase_mutex);
+ pthread_mutex_unlock(&innobase_share_mutex);
return share;
}
static void free_share(INNOBASE_SHARE *share)
{
- pthread_mutex_lock(&innobase_mutex);
+ pthread_mutex_lock(&innobase_share_mutex);
if (!--share->use_count)
{
hash_delete(&innobase_open_tables, (mysql_byte*) share);
@@ -5990,7 +6026,7 @@ static void free_share(INNOBASE_SHARE *share)
pthread_mutex_destroy(&share->mutex);
my_free((gptr) share, MYF(0));
}
- pthread_mutex_unlock(&innobase_mutex);
+ pthread_mutex_unlock(&innobase_share_mutex);
}
/*********************************************************************
@@ -6454,15 +6490,38 @@ innobase_xa_prepare(
FALSE - the current SQL statement ended */
{
int error = 0;
- trx_t* trx;
+ trx_t* trx = check_trx_exists(thd);
+
+ if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
+
+ /* For ibbackup to work the order of transactions in binlog
+ and InnoDB must be the same. Consider the situation
+
+ thread1> prepare; write to binlog; ...
+ <context switch>
+ thread2> prepare; write to binlog; commit
+ thread1> ... commit
+
+ To ensure this will not happen we're taking the mutex on
+ prepare, and releasing it on commit.
+
+ Note: only do it for normal commits, done via ha_commit_trans.
+ If 2pc protocol is executed by external transaction
+ coordinator, it will be just a regular MySQL client
+ executing XA PREPARE and XA COMMIT commands.
+ In this case we cannot know how many minutes or hours
+ will be between XA PREPARE and XA COMMIT, and we don't want
+ to block for undefined period of time.
+ */
+ pthread_mutex_lock(&prepare_commit_mutex);
+ trx->active_trans = 2;
+ }
if (!thd->variables.innodb_support_xa) {
return(0);
}
- trx = check_trx_exists(thd);
-
trx->xid=thd->transaction.xid;
/* Release a possible FIFO ticket and search latch. Since we will
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index e1ed3a486cf..6ad385ae848 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -47,7 +47,7 @@ class ha_innobase: public handler
THD* user_thd; /* the thread handle of the user
currently using the handle; this is
set in external_lock function */
- ulong last_query_id; /* the latest query id where the
+ query_id_t last_query_id; /* the latest query id where the
handle was used */
THR_LOCK_DATA lock;
INNOBASE_SHARE *share;
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 68523bfb41f..dd7a719eda4 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -308,7 +308,7 @@ Ndb *ha_ndbcluster::get_ndb()
* manage uncommitted insert/deletes during transactio to get records correct
*/
-struct Ndb_table_local_info {
+struct Ndb_local_table_statistics {
int no_uncommitted_rows_count;
ulong last_count;
ha_rows records;
@@ -329,7 +329,8 @@ void ha_ndbcluster::records_update()
if (m_ha_not_exact_count)
return;
DBUG_ENTER("ha_ndbcluster::records_update");
- struct Ndb_table_local_info *info= (struct Ndb_table_local_info *)m_table_info;
+ struct Ndb_local_table_statistics *info=
+ (struct Ndb_local_table_statistics *)m_table_info;
DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
((const NDBTAB *)m_table)->getTableId(),
info->no_uncommitted_rows_count));
@@ -366,7 +367,8 @@ void ha_ndbcluster::no_uncommitted_rows_init(THD *thd)
if (m_ha_not_exact_count)
return;
DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_init");
- struct Ndb_table_local_info *info= (struct Ndb_table_local_info *)m_table_info;
+ struct Ndb_local_table_statistics *info=
+ (struct Ndb_local_table_statistics *)m_table_info;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
if (info->last_count != thd_ndb->count)
{
@@ -385,8 +387,8 @@ void ha_ndbcluster::no_uncommitted_rows_update(int c)
if (m_ha_not_exact_count)
return;
DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_update");
- struct Ndb_table_local_info *info=
- (struct Ndb_table_local_info *)m_table_info;
+ struct Ndb_local_table_statistics *info=
+ (struct Ndb_local_table_statistics *)m_table_info;
info->no_uncommitted_rows_count+= c;
DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
((const NDBTAB *)m_table)->getTableId(),
@@ -838,10 +840,8 @@ bool ha_ndbcluster::uses_blob_value(bool all_fields)
Get metadata for this table from NDB
IMPLEMENTATION
- - save the NdbDictionary::Table for easy access
- check that frm-file on disk is equal to frm-file
of table accessed in NDB
- - build a list of the indexes for the table
*/
int ha_ndbcluster::get_metadata(const char *path)
@@ -905,11 +905,12 @@ int ha_ndbcluster::get_metadata(const char *path)
if (error)
DBUG_RETURN(error);
-
- m_table= NULL;
- m_table_info= NULL;
- DBUG_RETURN(build_index_list(table, ILBP_OPEN));
+ m_tableVersion= tab->getObjectVersion();
+ m_table= (void *)tab;
+ m_table_info= NULL; // Set in external lock
+
+ DBUG_RETURN(build_index_list(ndb, table, ILBP_OPEN));
}
static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
@@ -937,7 +938,7 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
#endif
for (unsigned j= 0; j < sz; j++)
{
- const NdbDictionary::Column *c= index->getColumn(j);
+ const NDBCOL *c= index->getColumn(j);
if (strncmp(field_name, c->getName(), name_sz) == 0)
{
data.unique_index_attrid_map[i]= j;
@@ -949,7 +950,7 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
DBUG_RETURN(0);
}
-int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
+int ha_ndbcluster::build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase)
{
uint i;
int error= 0;
@@ -958,8 +959,7 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
static const char* unique_suffix= "$unique";
KEY* key_info= tab->key_info;
const char **key_name= tab->s->keynames.type_names;
- Ndb *ndb= get_ndb();
- NdbDictionary::Dictionary *dict= ndb->getDictionary();
+ NDBDICT *dict= ndb->getDictionary();
DBUG_ENTER("ha_ndbcluster::build_index_list");
// Save information about all known indexes
@@ -2171,6 +2171,7 @@ int ha_ndbcluster::delete_row(const byte *record)
DBUG_ENTER("delete_row");
statistic_increment(thd->status_var.ha_delete_count,&LOCK_status);
+ m_rows_changed++;
if (cursor)
{
@@ -2221,8 +2222,6 @@ int ha_ndbcluster::delete_row(const byte *record)
}
}
- m_rows_changed++;
-
// Execute delete operation
if (execute_no_commit(this,trans) != 0) {
no_uncommitted_rows_execute_failure();
@@ -3023,12 +3022,8 @@ int ha_ndbcluster::extra_opt(enum ha_extra_function operation, ulong cache_size)
}
-static const char *ha_ndb_bas_ext[]= { ha_ndb_ext, NullS };
-const char**
-ha_ndbcluster::bas_ext() const
-{
- return ha_ndb_bas_ext;
-}
+const char** ha_ndbcluster::bas_ext() const
+{ static const char *ext[]= { ha_ndb_ext, NullS }; return ext; }
/*
@@ -3107,6 +3102,10 @@ THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd,
When a table lock is held one transaction will be started which holds
the table lock and for each statement a hupp transaction will be started
+ If we are locking the table then:
+ - save the NdbDictionary::Table for easy access
+ - save reference to table statistics
+ - refresh list of the indexes for the table if needed (if altered)
*/
int ha_ndbcluster::external_lock(THD *thd, int lock_type)
@@ -3212,7 +3211,15 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
if (!(tab= dict->getTable(m_tabname, &tab_info)))
ERR_RETURN(dict->getNdbError());
DBUG_PRINT("info", ("Table schema version: %d", tab->getObjectVersion()));
- m_table= (void *)tab;
+ if (m_table != (void *)tab || m_tableVersion != tab->getObjectVersion())
+ {
+ /*
+ The table has been altered, refresh the index list
+ */
+ build_index_list(ndb, table, ILBP_OPEN);
+ m_table= (void *)tab;
+ m_tableVersion = tab->getObjectVersion();
+ }
m_table_info= tab_info;
}
no_uncommitted_rows_init(thd);
@@ -3873,7 +3880,7 @@ int ha_ndbcluster::create(const char *name,
m_dbname, m_tabname));
// Create secondary indexes
- my_errno= build_index_list(form, ILBP_CREATE);
+ my_errno= build_index_list(ndb, form, ILBP_CREATE);
if (!my_errno)
my_errno= write_ndb_file();
@@ -4092,6 +4099,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
m_active_trans(NULL),
m_active_cursor(NULL),
m_table(NULL),
+ m_tableVersion(-1),
m_table_info(NULL),
m_table_flags(HA_REC_NOT_IN_SEQ |
HA_NULL_IN_KEY |
@@ -4240,9 +4248,9 @@ Thd_ndb* ha_ndbcluster::seize_thd_ndb()
DBUG_ENTER("seize_thd_ndb");
thd_ndb= new Thd_ndb();
- thd_ndb->ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_table_local_info));
-
-
+ thd_ndb->ndb->getDictionary()->set_local_table_data_size(
+ sizeof(Ndb_local_table_statistics)
+ );
if (thd_ndb->ndb->init(max_transactions) != 0)
{
ERR_PRINT(thd_ndb->ndb->getNdbError());
@@ -4332,7 +4340,7 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name,
ndb->setDatabaseName(db);
NDBDICT* dict= ndb->getDictionary();
- dict->set_local_table_data_size(sizeof(Ndb_table_local_info));
+ dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
dict->invalidateTable(name);
if (!(tab= dict->getTable(name)))
{
@@ -4378,7 +4386,7 @@ int ndbcluster_table_exists(THD* thd, const char *db, const char *name)
ndb->setDatabaseName(db);
NDBDICT* dict= ndb->getDictionary();
- dict->set_local_table_data_size(sizeof(Ndb_table_local_info));
+ dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
dict->invalidateTable(name);
if (!(tab= dict->getTable(name)))
{
@@ -4597,7 +4605,7 @@ ndbcluster_init()
DBUG_PRINT("error", ("failed to create global ndb object"));
goto ndbcluster_init_error;
}
- g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_table_local_info));
+ g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
if (g_ndb->init() != 0)
{
ERR_PRINT (g_ndb->getNdbError());
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index 82925ad5d69..4574ddc3562 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -509,7 +509,7 @@ private:
int create_unique_index(const char *name, KEY *key_info);
int initialize_autoincrement(const void *table);
enum ILBP {ILBP_CREATE = 0, ILBP_OPEN = 1}; // Index List Build Phase
- int build_index_list(TABLE *tab, enum ILBP phase);
+ int build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase);
int get_metadata(const char* path);
void release_metadata();
NDB_INDEX_TYPE get_index_type(uint idx_no) const;
@@ -594,6 +594,7 @@ private:
NdbTransaction *m_active_trans;
NdbScanOperation *m_active_cursor;
void *m_table;
+ int m_tableVersion;
void *m_table_info;
char m_dbname[FN_HEADLEN];
//char m_schemaname[FN_HEADLEN];
diff --git a/sql/handler.cc b/sql/handler.cc
index df0d7704163..143e56fdc7c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -32,6 +32,9 @@
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
#endif
+#ifdef HAVE_BLACKHOLE_DB
+#include "ha_blackhole.h"
+#endif
#ifdef HAVE_EXAMPLE_DB
#include "examples/ha_example.h"
#endif
@@ -103,6 +106,9 @@ struct show_table_type_st sys_table_types[]=
"CSV storage engine", DB_TYPE_CSV_DB},
{"FEDERATED",&have_federated_db,
"Federated MySQL storage engine", DB_TYPE_FEDERATED_DB},
+ {"BLACKHOLE",&have_blackhole_db,
+ "/dev/null storage engine (anything you write to it disappears)",
+ DB_TYPE_BLACKHOLE_DB},
{NullS, NULL, NullS, DB_TYPE_UNKNOWN}
};
@@ -211,6 +217,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
case DB_TYPE_ARCHIVE_DB:
return new ha_archive(table);
#endif
+#ifdef HAVE_BLACKHOLE_DB
+ case DB_TYPE_BLACKHOLE_DB:
+ return new ha_blackhole(table);
+#endif
#ifdef HAVE_FEDERATED_DB
case DB_TYPE_FEDERATED_DB:
return new ha_federated(table);
@@ -416,7 +426,12 @@ int ha_init()
}
#endif
DBUG_ASSERT(total_ha < MAX_HA);
- opt_using_transactions= total_ha>opt_bin_log;
+ /*
+ Check if there is a transaction-capable storage engine besides the
+ binary log (which is considered a transaction-capable storage engine in
+ counting total_ha)
+ */
+ opt_using_transactions= total_ha>(ulong)opt_bin_log;
savepoint_alloc_size+= sizeof(SAVEPOINT);
return error;
}
@@ -526,7 +541,6 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
/*
RETURN
- -1 - cannot prepare
0 - ok
1 - error, transaction was rolled back
*/
@@ -539,8 +553,6 @@ int ha_prepare(THD *thd)
#ifdef USING_TRANSACTIONS
if (trans->nht)
{
- if (trans->no_2pc)
- DBUG_RETURN(-1);
for (; *ht; ht++)
{
int err;
@@ -762,14 +774,13 @@ static char* xid_to_str(char *buf, XID *xid)
for (i=0; i < xid->gtrid_length+xid->bqual_length; i++)
{
uchar c=(uchar)xid->data[i];
- bool is_next_dig;
+ /* is_next_dig is set if next character is a number */
+ bool is_next_dig= FALSE;
if (i < XIDDATASIZE)
{
- char ch=xid->data[i+1];
- is_next_dig=(c >= '0' && c <='9');
+ char ch= xid->data[i+1];
+ is_next_dig= (ch >= '0' && ch <='9');
}
- else
- is_next_dig=FALSE;
if (i == xid->gtrid_length)
{
*s++='\'';
@@ -782,6 +793,11 @@ static char* xid_to_str(char *buf, XID *xid)
if (c < 32 || c > 126)
{
*s++='\\';
+ /*
+ If next character is a number, write current character with
+ 3 octal numbers to ensure that the next number is not seen
+ as part of the octal number
+ */
if (c > 077 || is_next_dig)
*s++=_dig_vec_lower[c >> 6];
if (c > 007 || is_next_dig)
@@ -831,9 +847,9 @@ int ha_recover(HASH *commit_list)
/* commit_list and tc_heuristic_recover cannot be set both */
DBUG_ASSERT(commit_list==0 || tc_heuristic_recover==0);
/* if either is set, total_ha_2pc must be set too */
- DBUG_ASSERT(dry_run || total_ha_2pc>opt_bin_log);
+ DBUG_ASSERT(dry_run || total_ha_2pc>(ulong)opt_bin_log);
- if (total_ha_2pc <= opt_bin_log)
+ if (total_ha_2pc <= (ulong)opt_bin_log)
DBUG_RETURN(0);
if (commit_list)
diff --git a/sql/handler.h b/sql/handler.h
index c8e1d75f2f7..e5b63c7f25c 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -160,7 +160,7 @@ enum db_type
DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER,
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB,
DB_TYPE_FEDERATED_DB,
-
+ DB_TYPE_BLACKHOLE_DB,
DB_TYPE_DEFAULT // Must be last
};
@@ -379,7 +379,7 @@ typedef struct st_savepoint SAVEPOINT;
extern ulong savepoint_alloc_size;
/* Forward declaration for condition pushdown to storage engine */
-typedef struct Item COND;
+typedef class Item COND;
typedef struct st_ha_check_opt
{
diff --git a/sql/item.cc b/sql/item.cc
index 64fc2696f1f..48faa3509f4 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -178,7 +178,7 @@ bool Item::val_bool()
{
switch(result_type()) {
case INT_RESULT:
- return val_int();
+ return val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;
@@ -586,18 +586,8 @@ Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs)
return NULL;
}
conv->str_value.copy();
- /*
- The above line executes str_value.realloc() internally,
- which alligns Alloced_length using ALLIGN_SIZE.
- In the case of Item_string::str_value we don't want
- Alloced_length to be longer than str_length.
- Otherwise, some functions like Item_func_concat::val_str()
- try to reuse str_value as a buffer for concatenation result
- for optimization purposes, so our string constant become
- corrupted. See bug#8785 for more details.
- Let's shrink Alloced_length to str_length to avoid this problem.
- */
- conv->str_value.shrink_to_length();
+ /* Ensure that no one is going to change the result string */
+ conv->str_value.mark_as_const();
return conv;
}
@@ -1217,7 +1207,7 @@ bool Item_field::val_bool_result()
return FALSE;
switch (result_field->result_type()) {
case INT_RESULT:
- return result_field->val_int();
+ return result_field->val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;
@@ -2050,7 +2040,7 @@ const String *Item_param::query_val_str(String* str) const
buf= str->c_ptr_quick();
ptr= buf;
*ptr++= '\'';
- ptr+= escape_string_for_mysql(str_value.charset(), ptr,
+ ptr+= escape_string_for_mysql(str_value.charset(), ptr, 0,
str_value.ptr(), str_value.length());
*ptr++= '\'';
str->length(ptr - buf);
@@ -2104,6 +2094,34 @@ bool Item_param::convert_str_value(THD *thd)
return rc;
}
+bool Item_param::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
+{
+ DBUG_ASSERT(fixed == 0);
+ SELECT_LEX *cursel= (SELECT_LEX *) thd->lex->current_select;
+
+ /*
+ Parameters in a subselect should mark the subselect as not constant
+ during prepare
+ */
+ if (state == NO_VALUE)
+ {
+ /*
+ SELECT_LEX_UNIT::item set only for subqueries, so test of it presence
+ can be barrier to stop before derived table SELECT or very outer SELECT
+ */
+ for(;
+ cursel->master_unit()->item;
+ cursel= cursel->outer_select())
+ {
+ Item_subselect *subselect_item= cursel->master_unit()->item;
+ subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT;
+ subselect_item->const_item_cache= 0;
+ }
+ }
+ fixed= 1;
+ return 0;
+}
+
void Item_param::print(String *str)
{
@@ -3051,10 +3069,10 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
case MYSQL_TYPE_NULL:
return new Field_null((char*) 0, max_length, Field::NONE,
name, table, &my_charset_bin);
- case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_INT24:
return new Field_medium((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table, 0, unsigned_flag);
+ case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_DATE:
return new Field_date(maybe_null, name, table, &my_charset_bin);
case MYSQL_TYPE_TIME:
@@ -3946,7 +3964,7 @@ bool Item_ref::val_bool_result()
return 0;
switch (result_field->result_type()) {
case INT_RESULT:
- return result_field->val_int();
+ return result_field->val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;
@@ -4691,225 +4709,309 @@ void Item_cache_row::bring_value()
}
+Item_type_holder::Item_type_holder(THD *thd, Item *item)
+ :Item(thd, item), enum_set_typelib(0), fld_type(get_real_type(item))
+{
+ DBUG_ASSERT(item->fixed);
+
+ max_length= display_length(item);
+ maybe_null= item->maybe_null;
+ collation.set(item->collation);
+ get_full_info(item);
+ /* fix variable decimals which always is NOT_FIXED_DEC */
+ if (Field::result_merge_type(fld_type) == INT_RESULT)
+ decimals= 0;
+}
+
+
/*
- Returns field for temporary table dependind on item type
+ Return expression type of Item_type_holder
SYNOPSIS
- get_holder_example_field()
- thd - thread handler
- item - pointer to item
- table - empty table object
-
- NOTE
- It is possible to return field for Item_func
- items only if field type of this item is
- date or time or datetime type.
- also see function field_types_to_be_kept() from
- field.cc
+ Item_type_holder::result_type()
RETURN
- # - field
- 0 - no field
+ Item_result (type of internal MySQL expression result)
*/
-Field *get_holder_example_field(THD *thd, Item *item, TABLE *table)
+Item_result Item_type_holder::result_type() const
{
- DBUG_ASSERT(table != 0);
+ return Field::result_merge_type(fld_type);
+}
- Item_func *tmp_item= 0;
- if (item->type() == Item::FIELD_ITEM)
- return (((Item_field*) item)->field);
- if (item->type() == Item::FUNC_ITEM)
- tmp_item= (Item_func *) item;
- else if (item->type() == Item::SUM_FUNC_ITEM)
+
+/*
+ Find real field type of item
+
+ SYNOPSIS
+ Item_type_holder::get_real_type()
+
+ RETURN
+ type of field which should be created to store item value
+*/
+
+enum_field_types Item_type_holder::get_real_type(Item *item)
+{
+ switch(item->type())
+ {
+ case FIELD_ITEM:
{
+ /*
+ Item_fields::field_type ask Field_type() but sometimes field return
+ a different type, like for enum/set, so we need to ask real type.
+ */
+ Field *field= ((Item_field *) item)->field;
+ enum_field_types type= field->real_type();
+ /* work around about varchar type field detection */
+ if (type == MYSQL_TYPE_STRING && field->type() == MYSQL_TYPE_VAR_STRING)
+ return MYSQL_TYPE_VAR_STRING;
+ return type;
+ }
+ case SUM_FUNC_ITEM:
+ {
+ /*
+ Argument of aggregate function sometimes should be asked about field
+ type
+ */
Item_sum *item_sum= (Item_sum *) item;
if (item_sum->keep_field_type())
+ return get_real_type(item_sum->args[0]);
+ break;
+ }
+ case FUNC_ITEM:
+ if (((Item_func *) item)->functype() == Item_func::GUSERVAR_FUNC)
{
- if (item_sum->args[0]->type() == Item::FIELD_ITEM)
- return (((Item_field*) item_sum->args[0])->field);
- if (item_sum->args[0]->type() == Item::FUNC_ITEM)
- tmp_item= (Item_func *) item_sum->args[0];
+ /*
+ There are work around of problem with changing variable type on the
+ fly and variable always report "string" as field type to get
+ acceptable information for client in send_field, so we make field
+ type from expression type.
+ */
+ switch (item->result_type())
+ {
+ case STRING_RESULT:
+ return MYSQL_TYPE_VAR_STRING;
+ case INT_RESULT:
+ return MYSQL_TYPE_LONGLONG;
+ case REAL_RESULT:
+ return MYSQL_TYPE_DOUBLE;
+ case DECIMAL_RESULT:
+ return MYSQL_TYPE_NEWDECIMAL;
+ case ROW_RESULT:
+ default:
+ DBUG_ASSERT(0);
+ return MYSQL_TYPE_VAR_STRING;
+ }
}
+ break;
+ default:
+ break;
}
- return (tmp_item && field_types_to_be_kept(tmp_item->field_type()) ?
- tmp_item->tmp_table_field(table) : 0);
-}
-
-
-Item_type_holder::Item_type_holder(THD *thd, Item *item, TABLE *table)
- :Item(thd, item), item_type(item->result_type()),
- orig_type(item_type)
-{
- DBUG_ASSERT(item->fixed);
-
- /*
- It is safe assign pointer on field, because it will be used just after
- all JOIN::prepare calls and before any SELECT execution
- */
- field_example= get_holder_example_field(thd, item, table);
- max_length= real_length(item);
- maybe_null= item->maybe_null;
- collation.set(item->collation);
+ return item->field_type();
}
-
/*
- STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT DECIMAL_RESULT
-
- ROW_RESULT should never appear in Item_type_holder::join_types,
- but it is included in following table just to make table full
- (there DBUG_ASSERT in function to catch ROW_RESULT)
-*/
-static Item_result type_convertor[5][5]=
-{{STRING_RESULT, STRING_RESULT, STRING_RESULT, ROW_RESULT, STRING_RESULT},
- {STRING_RESULT, REAL_RESULT, REAL_RESULT, ROW_RESULT, REAL_RESULT},
- {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT},
- {ROW_RESULT, ROW_RESULT, ROW_RESULT, ROW_RESULT, ROW_RESULT},
- {STRING_RESULT, REAL_RESULT, DECIMAL_RESULT, ROW_RESULT, DECIMAL_RESULT}};
-
-/*
- Values of 'from' field can be stored in 'to' field.
+ Find field type which can carry current Item_type_holder type and
+ type of given Item.
SYNOPSIS
- is_attr_compatible()
- from Item which values should be saved
- to Item where values should be saved
+ Item_type_holder::join_types()
+ thd thread handler
+ item given item to join its parameters with this item ones
RETURN
- 1 can be saved
- 0 can not be saved
+ TRUE error - types are incompatible
+ FALSE OK
*/
-inline bool is_attr_compatible(Item *from, Item *to)
-{
- return ((to->max_length >= from->max_length) &&
- ((to->result_type() != DECIMAL_RESULT &&
- to->result_type() != REAL_RESULT &&
- to->result_type() != INT_RESULT) ||
- (to->decimals >= from->decimals) &&
- ((to->max_length - to->decimals) >=
- (from->max_length - from->decimals))) &&
- (to->maybe_null || !from->maybe_null) &&
- (to->result_type() != STRING_RESULT ||
- from->result_type() != STRING_RESULT ||
- (from->collation.collation == to->collation.collation)));
-}
-
-
-bool Item_type_holder::join_types(THD *thd, Item *item, TABLE *table)
+bool Item_type_holder::join_types(THD *thd, Item *item)
{
- uint32 new_length= real_length(item);
- bool use_new_field= 0, use_expression_type= 0;
- Item_result new_result_type= type_convertor[item_type][item->result_type()];
- Field *field= get_holder_example_field(thd, item, table);
- bool item_is_a_field= (field != NULL);
- /*
- Check if both items point to fields: in this case we
- can adjust column types of result table in the union smartly.
- */
- if (field_example && item_is_a_field)
+ DBUG_ENTER("Item_type_holder::join_types");
+ DBUG_PRINT("info:", ("was type %d len %d, dec %d name %s",
+ fld_type, max_length, decimals,
+ (name ? name : "<NULL>")));
+ DBUG_PRINT("info:", ("in type %d len %d, dec %d",
+ get_real_type(item),
+ item->max_length, item->decimals));
+ fld_type= Field::field_type_merge(fld_type, get_real_type(item));
{
- /* Can 'field_example' field store data of the column? */
- if ((use_new_field=
- (!field->field_cast_compatible(field_example->field_cast_type()) ||
- !is_attr_compatible(item, this))))
- {
- /*
- The old field can't store value of the new field.
- Check if the new field can store value of the old one.
- */
- use_expression_type|=
- (!field_example->field_cast_compatible(field->field_cast_type()) ||
- !is_attr_compatible(this, item));
- }
+ int item_decimals= item->decimals;
+ /* fix variable decimals which always is NOT_FIXED_DEC */
+ if (Field::result_merge_type(fld_type) == INT_RESULT)
+ item_decimals= 0;
+ decimals= max(decimals, item_decimals);
}
- else if (field_example || item_is_a_field)
+ if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
{
+ int item_length= display_length(item);
+ int intp1= item_length - min(item->decimals, NOT_FIXED_DEC - 1);
+ int intp2= max_length - min(decimals, NOT_FIXED_DEC - 1);
+ /* can't be overflow because it work only for decimals (no strings) */
+ int dec_length= max(intp1, intp2) + decimals;
+ max_length= max(max_length, max(item_length, dec_length));
/*
- Expression types can't be mixed with field types, we have to use
- expression types.
+ we can't allow decimals to be NOT_FIXED_DEC, to prevent creation
+ decimal with max precision (see Field_new_decimal constcuctor)
*/
- use_new_field= 1; // make next if test easier
- use_expression_type= 1;
+ if (decimals >= NOT_FIXED_DEC)
+ decimals= NOT_FIXED_DEC - 1;
}
-
- /* Check whether size/type of the result item should be changed */
- if (use_new_field ||
- (new_result_type != item_type) || (new_length > max_length) ||
- (!maybe_null && item->maybe_null) ||
- ((new_result_type == REAL_RESULT || new_result_type == DECIMAL_RESULT) &&
- (decimals < item->decimals ||
- (max_length - decimals) < (new_length - item->decimals))) ||
- (item_type == STRING_RESULT &&
- collation.collation != item->collation.collation))
+ else
+ max_length= max(max_length, display_length(item));
+ if (Field::result_merge_type(fld_type) == STRING_RESULT)
{
- const char *old_cs,*old_derivation;
- if (use_expression_type || !item_is_a_field)
- field_example= 0;
- else
- {
- /*
- It is safe to assign a pointer to field here, because it will be used
- before any table is closed.
- */
- field_example= field;
- }
-
+ const char *old_cs, *old_derivation;
old_cs= collation.collation->name;
old_derivation= collation.derivation_name();
- if (item_type == STRING_RESULT && collation.aggregate(item->collation))
+ if (collation.aggregate(item->collation))
{
my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0),
- old_cs, old_derivation,
- item->collation.collation->name,
- item->collation.derivation_name(),
- "UNION");
- return 1;
- }
-
- if (new_result_type == DECIMAL_RESULT)
- {
- int intp1= new_length - item->decimals;
- int intp2= max_length - decimals;
- max_length= max(intp1, intp2);
- decimals= max(decimals, item->decimals);
- /* can't be overflow because it work only for decimals (no strings) */
- max_length+= decimals;
- }
- else
- {
- max_length= max(max_length, new_length);
- decimals= max(decimals, item->decimals);
+ old_cs, old_derivation,
+ item->collation.collation->name,
+ item->collation.derivation_name(),
+ "UNION");
+ DBUG_RETURN(TRUE);
}
- maybe_null|= item->maybe_null;
- item_type= new_result_type;
}
- DBUG_ASSERT(item_type != ROW_RESULT);
- return 0;
+ maybe_null|= item->maybe_null;
+ get_full_info(item);
+ DBUG_PRINT("info:", ("become type %d len %d, dec %d",
+ fld_type, max_length, decimals));
+ DBUG_RETURN(FALSE);
}
+/*
+ Calculate lenth for merging result for given Item type
+
+ SYNOPSIS
+ Item_type_holder::real_length()
+ item Item for lrngth detection
-uint32 Item_type_holder::real_length(Item *item)
+ RETURN
+ length
+*/
+
+uint32 Item_type_holder::display_length(Item *item)
{
if (item->type() == Item::FIELD_ITEM)
return ((Item_field *)item)->max_disp_length();
- switch (item->result_type()) {
- case STRING_RESULT:
- case DECIMAL_RESULT:
+ switch (item->field_type())
+ {
+ case MYSQL_TYPE_DECIMAL:
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_TIME:
+ case MYSQL_TYPE_DATETIME:
+ case MYSQL_TYPE_YEAR:
+ case MYSQL_TYPE_NEWDATE:
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_BIT:
+ case MYSQL_TYPE_NEWDECIMAL:
+ case MYSQL_TYPE_ENUM:
+ case MYSQL_TYPE_SET:
+ case MYSQL_TYPE_TINY_BLOB:
+ case MYSQL_TYPE_MEDIUM_BLOB:
+ case MYSQL_TYPE_LONG_BLOB:
+ case MYSQL_TYPE_BLOB:
+ case MYSQL_TYPE_VAR_STRING:
+ case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_GEOMETRY:
return item->max_length;
- case REAL_RESULT:
+ case MYSQL_TYPE_TINY:
+ return 4;
+ case MYSQL_TYPE_SHORT:
+ return 6;
+ case MYSQL_TYPE_LONG:
+ return 11;
+ case MYSQL_TYPE_FLOAT:
+ return 25;
+ case MYSQL_TYPE_DOUBLE:
return 53;
- case INT_RESULT:
+ case MYSQL_TYPE_NULL:
+ return 4;
+ case MYSQL_TYPE_LONGLONG:
return 20;
- case ROW_RESULT:
+ case MYSQL_TYPE_INT24:
+ return 8;
default:
DBUG_ASSERT(0); // we should never go there
return 0;
}
}
+
+/*
+ Make temporary table field according collected information about type
+ of UNION result
+
+ SYNOPSIS
+ Item_type_holder::make_field_by_type()
+ table temporary table for which we create fields
+
+ RETURN
+ created field
+*/
+
+Field *Item_type_holder::make_field_by_type(TABLE *table)
+{
+ /*
+ The field functions defines a field to be not null if null_ptr is not 0
+ */
+ uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
+ switch (fld_type)
+ {
+ case MYSQL_TYPE_ENUM:
+ DBUG_ASSERT(enum_set_typelib);
+ return new Field_enum((char *) 0, max_length, null_ptr, 0,
+ Field::NONE, name,
+ table, get_enum_pack_length(enum_set_typelib->count),
+ enum_set_typelib, collation.collation);
+ case MYSQL_TYPE_SET:
+ DBUG_ASSERT(enum_set_typelib);
+ return new Field_set((char *) 0, max_length, null_ptr, 0,
+ Field::NONE, name,
+ table, get_set_pack_length(enum_set_typelib->count),
+ enum_set_typelib, collation.collation);
+ default:
+ break;
+ }
+ return tmp_table_field_from_field_type(table);
+}
+
+
+/*
+ Get full information from Item about enum/set fields to be able to create
+ them later
+
+ SYNOPSIS
+ Item_type_holder::get_full_info
+ item Item for information collection
+*/
+void Item_type_holder::get_full_info(Item *item)
+{
+ if (fld_type == MYSQL_TYPE_ENUM ||
+ fld_type == MYSQL_TYPE_SET)
+ {
+ /*
+ We can have enum/set type after merging only if we have one enum/set
+ field and number of NULL fields
+ */
+ DBUG_ASSERT((enum_set_typelib &&
+ get_real_type(item) == MYSQL_TYPE_NULL) ||
+ (!enum_set_typelib &&
+ item->type() == Item::FIELD_ITEM &&
+ (get_real_type(item) == MYSQL_TYPE_ENUM ||
+ get_real_type(item) == MYSQL_TYPE_SET) &&
+ ((Field_enum*)((Item_field *) item)->field)->typelib));
+ if (!enum_set_typelib)
+ {
+ enum_set_typelib= ((Field_enum*)((Item_field *) item)->field)->typelib;
+ }
+ }
+}
+
+
double Item_type_holder::val_real()
{
DBUG_ASSERT(0); // should never be called
diff --git a/sql/item.h b/sql/item.h
index 55c9af356a8..0a2be74c76c 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -389,7 +389,7 @@ public:
FALSE value is false or NULL
TRUE value is true (not equal to 0)
*/
- bool val_bool();
+ virtual bool val_bool();
/* Helper functions, see item_sum.cc */
String *val_string_from_real(String *str);
String *val_string_from_int(String *str);
@@ -882,6 +882,7 @@ public:
bool get_time(TIME *tm);
bool get_date(TIME *tm, uint fuzzydate);
int save_in_field(Field *field, bool no_conversions);
+ bool fix_fields(THD *, struct st_table_list *, Item **);
void set_null();
void set_int(longlong i, uint32 max_length_arg);
@@ -1782,33 +1783,33 @@ public:
/*
- Used to store type. name, length of Item for UNIONS & derived table
+ Item_type_holder used to store type. name, length of Item for UNIONS &
+ derived tables.
+
+ Item_type_holder do not need cleanup() because its time of live limited by
+ single SP/PS execution.
*/
class Item_type_holder: public Item
{
protected:
- Item_result item_type;
- Item_result orig_type;
- Field *field_example;
+ TYPELIB *enum_set_typelib;
+ enum_field_types fld_type;
+
+ void get_full_info(Item *item);
public:
- Item_type_holder(THD*, Item*, TABLE *);
+ Item_type_holder(THD*, Item*);
- Item_result result_type () const { return item_type; }
+ Item_result result_type() const;
+ virtual enum_field_types field_type() const { return fld_type; };
enum Type type() const { return TYPE_HOLDER; }
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal *);
String *val_str(String*);
- bool join_types(THD *thd, Item *, TABLE *);
- Field *example() { return field_example; }
- static uint32 real_length(Item *item);
- void cleanup()
- {
- DBUG_ENTER("Item_type_holder::cleanup");
- Item::cleanup();
- item_type= orig_type;
- DBUG_VOID_RETURN;
- }
+ bool join_types(THD *thd, Item *);
+ Field *make_field_by_type(TABLE *table);
+ static uint32 display_length(Item *item);
+ static enum_field_types get_real_type(Item *);
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index c0cb0704852..66354560756 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -432,10 +432,16 @@ int Arg_comparator::compare_e_binary_string()
int Arg_comparator::compare_real()
{
- double val1= (*a)->val_real();
+ /*
+ Fix yet another manifestation of Bug#2338. 'Volatile' will instruct
+ gcc to flush double values out of 80-bit Intel FPU registers before
+ performing the comparison.
+ */
+ volatile double val1, val2;
+ val1= (*a)->val_real();
if (!(*a)->null_value)
{
- double val2= (*b)->val_real();
+ val2= (*b)->val_real();
if (!(*b)->null_value)
{
owner->null_value= 0;
@@ -708,7 +714,7 @@ longlong Item_in_optimizer::val_int()
null_value= 1;
return 0;
}
- longlong tmp= args[1]->val_int_result();
+ bool tmp= args[1]->val_bool_result();
null_value= args[1]->null_value;
return tmp;
}
@@ -1720,7 +1726,7 @@ void Item_func_coalesce::fix_length_and_dec()
decimals= 0;
break;
case ROW_RESULT:
- defaullt:
+ default:
DBUG_ASSERT(0);
}
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 5eb87c2e92b..c607efa0797 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -882,7 +882,7 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
}
case REAL_RESULT:
{
- double result= int_op();
+ double result= (double)int_op();
double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
break;
}
@@ -2772,8 +2772,8 @@ String *Item_func_udf_str::val_str(String *str)
/*
- This has to come last in the udf_handler methods, or the compiler for IBM
- AIX fails to compile with debugging enabled. (Yes, really.)
+ This has to come last in the udf_handler methods, or C for AIX
+ version 6.0.0.0 fails to compile with debugging enabled. (Yes, really.)
*/
udf_handler::~udf_handler()
@@ -3569,20 +3569,20 @@ Item_func_set_user_var::update()
case REAL_RESULT:
{
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
- REAL_RESULT, &my_charset_bin, DERIVATION_NONE);
+ REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT);
break;
}
case INT_RESULT:
{
res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
- INT_RESULT, &my_charset_bin, DERIVATION_NONE);
+ INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT);
break;
}
case STRING_RESULT:
{
if (!save_result.vstr) // Null value
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
- DERIVATION_NONE);
+ DERIVATION_IMPLICIT);
else
res= update_hash((void*) save_result.vstr->ptr(),
save_result.vstr->length(), STRING_RESULT,
@@ -3594,11 +3594,11 @@ Item_func_set_user_var::update()
{
if (!save_result.vdec) // Null value
res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
- DERIVATION_NONE);
+ DERIVATION_IMPLICIT);
else
res= update_hash((void*) save_result.vdec,
sizeof(my_decimal), DECIMAL_RESULT,
- &my_charset_bin, DERIVATION_NONE);
+ &my_charset_bin, DERIVATION_IMPLICIT);
break;
}
case ROW_RESULT:
@@ -3850,7 +3850,10 @@ void Item_func_get_user_var::fix_length_and_dec()
}
}
else
+ {
+ collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
null_value= 1;
+ }
if (error)
thd->fatal_error();
@@ -4683,7 +4686,6 @@ Field *
Item_func_sp::tmp_table_field(TABLE *t_arg)
{
Field *res= 0;
- enum_field_types ftype;
DBUG_ENTER("Item_func_sp::tmp_table_field");
if (m_sp)
diff --git a/sql/item_func.h b/sql/item_func.h
index 93633e75619..9bf21fa1aa3 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -704,7 +704,8 @@ public:
Item_func_coercibility(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "coercibility"; }
- void fix_length_and_dec() { max_length=10; }
+ void fix_length_and_dec() { max_length=10; maybe_null= 0; }
+ table_map not_null_tables() const { return 0; }
};
class Item_func_locate :public Item_int_func
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 81120bbe3f7..3fe1b819f36 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2888,7 +2888,7 @@ String *Item_func_uuid::val_str(String *str)
with a clock_seq value (initialized random below), we use a separate
randominit() here
*/
- randominit(&uuid_rand, tmp + (ulong) thd, tmp + query_id);
+ randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)query_id);
for (i=0; i < (int)sizeof(mac); i++)
mac[i]=(uchar)(my_rnd(&uuid_rand)*255);
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index ea8a78c528a..eec81f953fb 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -653,7 +653,9 @@ public:
{
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
+ maybe_null= 0;
};
+ table_map not_null_tables() const { return 0; }
};
class Item_func_collation :public Item_str_func
@@ -666,7 +668,9 @@ public:
{
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
+ maybe_null= 0;
};
+ table_map not_null_tables() const { return 0; }
};
class Item_func_crc32 :public Item_int_func
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 46b2770a12a..0fbcf32a83c 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -379,20 +379,8 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
*/
substitution->walk(&Item::remove_dependence_processor,
(byte *) select_lex->outer_select());
- if (join->conds || join->having)
- {
- Item *cond;
- if (!join->having)
- cond= join->conds;
- else if (!join->conds)
- cond= join->having;
- else
- if (!(cond= new Item_cond_and(join->conds, join->having)))
- goto err;
- if (!(substitution= new Item_func_if(cond, substitution,
- new Item_null())))
- goto err;
- }
+ /* SELECT without FROM clause can't have WHERE or HAVING clause */
+ DBUG_ASSERT(join->conds == 0 && join->having == 0);
return RES_REDUCE;
}
return RES_OK;
@@ -579,7 +567,7 @@ bool Item_in_subselect::test_limit(SELECT_LEX_UNIT *unit)
Item_in_subselect::Item_in_subselect(Item * left_exp,
st_select_lex *select_lex):
- Item_exists_subselect(), transformed(0), upper_item(0)
+ Item_exists_subselect(), optimizer(0), transformed(0), upper_item(0)
{
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
left_expr= left_exp;
@@ -649,7 +637,7 @@ String *Item_exists_subselect::val_str(String *str)
reset();
return 0;
}
- str->set(value,&my_charset_bin);
+ str->set((ulonglong)value,&my_charset_bin);
return str;
}
@@ -675,12 +663,17 @@ bool Item_exists_subselect::val_bool()
reset();
return 0;
}
- return value;
+ return value != 0;
}
double Item_in_subselect::val_real()
{
+ /*
+ As far as Item_in_subselect called only from Item_in_optimizer this
+ method should not be used
+ */
+ DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
if (exec())
{
@@ -693,8 +686,14 @@ double Item_in_subselect::val_real()
return (double) value;
}
+
longlong Item_in_subselect::val_int()
{
+ /*
+ As far as Item_in_subselect called only from Item_in_optimizer this
+ method should not be used
+ */
+ DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
if (exec())
{
@@ -707,8 +706,14 @@ longlong Item_in_subselect::val_int()
return value;
}
+
String *Item_in_subselect::val_str(String *str)
{
+ /*
+ As far as Item_in_subselect called only from Item_in_optimizer this
+ method should not be used
+ */
+ DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
if (exec())
{
@@ -721,30 +726,56 @@ String *Item_in_subselect::val_str(String *str)
null_value= 1;
return 0;
}
- str->set(value, &my_charset_bin);
+ str->set((ulonglong)value, &my_charset_bin);
return str;
}
+bool Item_in_subselect::val_bool()
+{
+ DBUG_ASSERT(fixed == 1);
+ if (exec())
+ {
+ reset();
+ null_value= 1;
+ return 0;
+ }
+ if (was_null && !value)
+ null_value= 1;
+ return value;
+}
+
+my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value)
+{
+ /*
+ As far as Item_in_subselect called only from Item_in_optimizer this
+ method should not be used
+ */
+ DBUG_ASSERT(0);
+ DBUG_ASSERT(fixed == 1);
+ if (exec())
+ {
+ reset();
+ null_value= 1;
+ return 0;
+ }
+ if (was_null && !value)
+ null_value= 1;
+ int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
+ return decimal_value;
+}
+
+
/* Rewrite a single-column IN/ALL/ANY subselect. */
Item_subselect::trans_res
Item_in_subselect::single_value_transformer(JOIN *join,
Comp_creator *func)
{
- const char *save_where= thd->where;
Item_subselect::trans_res result= RES_ERROR;
DBUG_ENTER("Item_in_subselect::single_value_transformer");
- if (changed)
- {
- DBUG_RETURN(RES_OK);
- }
-
SELECT_LEX *select_lex= join->select_lex;
- Item_arena *arena, backup;
- arena= thd->change_arena_if_needed(&backup);
- thd->where= "scalar IN/ALL/ANY subquery";
/*
Check that the right part of the subselect contains no more than one
@@ -753,7 +784,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (select_lex->item_list.elements > 1)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
/*
@@ -773,11 +804,12 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (substitution)
{
// It is second (third, ...) SELECT of UNION => All is done
- goto ok;
+ DBUG_RETURN(RES_OK);
}
Item *subs;
if (!select_lex->group_list.elements &&
+ !select_lex->having &&
!select_lex->with_sum_func &&
!(select_lex->next_select()))
{
@@ -813,7 +845,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
we do not check item->fixed
*/
if (item->fix_fields(thd, join->tables_list, 0))
- goto err;
+ DBUG_RETURN(RES_ERROR);
/* we added aggregate function => we have to change statistic */
count_field_types(&join->tmp_table_param, join->all_fields, 0);
@@ -829,25 +861,16 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (upper_item)
upper_item->set_sub_test(item);
}
- // left expression belong to outer select
- SELECT_LEX *current= thd->lex->current_select, *up;
- thd->lex->current_select= up= current->return_after_parsing();
- if (!left_expr->fixed &&
- left_expr->fix_fields(thd, up->get_table_list(), &left_expr))
- {
- thd->lex->current_select= current;
- goto err;
- }
- thd->lex->current_select= current;
+ /* fix fields is already called for left expression */
substitution= func->create(left_expr, subs);
- goto ok;
+ DBUG_RETURN(RES_OK);
}
if (!substitution)
{
//first call for this unit
SELECT_LEX_UNIT *unit= select_lex->master_unit();
- substitution= optimizer= new Item_in_optimizer(left_expr, this);
+ substitution= optimizer;
SELECT_LEX *current= thd->lex->current_select, *up;
@@ -856,7 +879,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0))
{
thd->lex->current_select= current;
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
thd->lex->current_select= current;
@@ -907,7 +930,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
tmp= join->having->fix_fields(thd, join->tables_list, 0);
select_lex->having_fix_field= 0;
if (tmp)
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
else
{
@@ -943,7 +966,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
tmp= join->having->fix_fields(thd, join->tables_list, 0);
select_lex->having_fix_field= 0;
if (tmp)
- goto err;
+ DBUG_RETURN(RES_ERROR);
item= new Item_cond_or(item,
new Item_func_isnull(orig_item));
#ifdef CORRECT_BUT_TOO_SLOW_TO_BE_USABLE
@@ -963,7 +986,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
after creation
*/
if (join->conds->fix_fields(thd, join->tables_list, 0))
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
else
{
@@ -992,7 +1015,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
tmp= join->having->fix_fields(thd, join->tables_list, 0);
select_lex->having_fix_field= 0;
if (tmp)
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
else
{
@@ -1008,51 +1031,33 @@ Item_in_subselect::single_value_transformer(JOIN *join,
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_SELECT_REDUCED, warn_buff);
}
- result= RES_REDUCE;
- goto err;
+ DBUG_RETURN(RES_REDUCE);
}
}
}
-ok:
- thd->where= save_where;
- result= RES_OK;
-
-err:
- if (arena)
- thd->restore_backup_item_arena(arena, &backup);
- DBUG_RETURN(result);
+ DBUG_RETURN(RES_OK);
}
Item_subselect::trans_res
Item_in_subselect::row_value_transformer(JOIN *join)
{
- const char *save_where= thd->where;
Item *item= 0;
SELECT_LEX *select_lex= join->select_lex;
DBUG_ENTER("Item_in_subselect::row_value_transformer");
- if (changed)
- {
- DBUG_RETURN(RES_OK);
- }
- thd->where= "row IN/ALL/ANY subquery";
-
- Item_arena *arena, backup;
- arena= thd->change_arena_if_needed(&backup);
-
if (select_lex->item_list.elements != left_expr->cols())
{
my_error(ER_OPERAND_COLUMNS, MYF(0), left_expr->cols());
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
if (!substitution)
{
//first call for this unit
SELECT_LEX_UNIT *unit= select_lex->master_unit();
- substitution= optimizer= new Item_in_optimizer(left_expr, this);
+ substitution= optimizer;
SELECT_LEX *current= thd->lex->current_select, *up;
thd->lex->current_select= up= current->return_after_parsing();
@@ -1060,7 +1065,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0))
{
thd->lex->current_select= current;
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
// we will refer to upper level cache array => we have to save it in PS
@@ -1079,7 +1084,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->el(i)->cols()))
- goto err;
+ DBUG_RETURN(RES_ERROR);
Item *func= new Item_ref_null_helper(this,
select_lex->ref_pointer_array+i,
(char *) "<no matter>",
@@ -1111,7 +1116,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
if (join->having->fix_fields(thd, join->tables_list, 0))
{
select_lex->having_fix_field= 0;
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
select_lex->having_fix_field= 0;
}
@@ -1128,27 +1133,113 @@ Item_in_subselect::row_value_transformer(JOIN *join)
join->conds->fixed
*/
if (join->conds->fix_fields(thd, join->tables_list, 0))
- goto err;
+ DBUG_RETURN(RES_ERROR);
}
- thd->where= save_where;
- if (arena)
- thd->restore_backup_item_arena(arena, &backup);
- DBUG_RETURN(RES_OK);
-err:
- if (arena)
- thd->restore_backup_item_arena(arena, &backup);
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(RES_OK);
}
Item_subselect::trans_res
Item_in_subselect::select_transformer(JOIN *join)
{
+ return select_in_like_transformer(join, &eq_creator);
+}
+
+
+/*
+ Prepare IN/ALL/ANY/SOME subquery transformation and call appropriate
+ transformation function
+
+ SYNOPSIS
+ Item_in_subselect::select_in_like_transformer()
+ join JOIN object of transforming subquery
+ func creator of condition function of subquery
+
+ DESCRIPTION
+ To decide which transformation procedure (scalar or row) applicable here
+ we have to call fix_fields() for left expression to be able to call
+ cols() method on it. Also this method make arena management for
+ underlying transformation methods.
+
+ RETURN
+ RES_OK OK
+ RES_REDUCE OK, and current subquery was reduced during transformation
+ RES_ERROR Error
+*/
+
+Item_subselect::trans_res
+Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
+{
+ Item_arena *arena, backup;
+ SELECT_LEX *current= thd->lex->current_select, *up;
+ const char *save_where= thd->where;
+ Item_subselect::trans_res res= RES_ERROR;
+ bool result;
+
+ DBUG_ENTER("Item_in_subselect::select_in_like_transformer");
+
+ if (changed)
+ {
+ DBUG_RETURN(RES_OK);
+ }
+
+ thd->where= "IN/ALL/ANY subquery";
+
+ /*
+ In some optimisation cases we will not need this Item_in_optimizer
+ object, but we can't know it here, but here we need address correct
+ reference on left expresion.
+ */
+ if (!optimizer)
+ {
+ arena= thd->change_arena_if_needed(&backup);
+ result= (!(optimizer= new Item_in_optimizer(left_expr, this)));
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
+ if (result)
+ goto err;
+ }
+
+ thd->lex->current_select= up= current->return_after_parsing();
+ result= (!left_expr->fixed &&
+ left_expr->fix_fields(thd, up->get_table_list(),
+ optimizer->arguments()));
+ /* fix_fields can change reference to left_expr, we need reassign it */
+ left_expr= optimizer->arguments()[0];
+
+ thd->lex->current_select= current;
+ if (result)
+ goto err;
+
transformed= 1;
+ arena= thd->change_arena_if_needed(&backup);
+ /*
+ Both transformers call fix_fields() only for Items created inside them,
+ and all that items do not make permanent changes in current item arena
+ which allow to us call them with changed arena (if we do not know nature
+ of Item, we have to call fix_fields() for it only with original arena to
+ avoid memory leack)
+ */
if (left_expr->cols() == 1)
- return single_value_transformer(join, &eq_creator);
- return row_value_transformer(join);
+ res= single_value_transformer(join, func);
+ else
+ {
+ /* we do not support row operation for ALL/ANY/SOME */
+ if (func != &eq_creator)
+ {
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
+ my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
+ DBUG_RETURN(RES_ERROR);
+ }
+ res= row_value_transformer(join);
+ }
+ if (arena)
+ thd->restore_backup_item_arena(arena, &backup);
+err:
+ thd->where= save_where;
+ DBUG_RETURN(res);
}
@@ -1171,7 +1262,7 @@ Item_allany_subselect::select_transformer(JOIN *join)
transformed= 1;
if (upper_item)
upper_item->show= 1;
- return single_value_transformer(join, func);
+ return select_in_like_transformer(join, func);
}
@@ -1279,7 +1370,7 @@ int subselect_single_select_engine::prepare()
int subselect_union_engine::prepare()
{
- return unit->prepare(thd, result, SELECT_NO_UNLOCK);
+ return unit->prepare(thd, result, SELECT_NO_UNLOCK, "");
}
int subselect_uniquesubquery_engine::prepare()
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 4661fae81da..56864109a04 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -120,6 +120,7 @@ public:
friend class Item_in_optimizer;
friend bool Item_field::fix_fields(THD *, TABLE_LIST *, Item **);
friend bool Item_ref::fix_fields(THD *, TABLE_LIST *, Item **);
+ friend bool Item_param::fix_fields(THD *, TABLE_LIST *, Item **);
};
/* single value subselect */
@@ -179,7 +180,7 @@ public:
class Item_exists_subselect :public Item_subselect
{
protected:
- longlong value; /* value of this item (boolean: exists/not-exists) */
+ bool value; /* value of this item (boolean: exists/not-exists) */
public:
Item_exists_subselect(st_select_lex *select_lex);
@@ -225,7 +226,8 @@ public:
Item_in_subselect(Item * left_expr, st_select_lex *select_lex);
Item_in_subselect()
- :Item_exists_subselect(), abort_on_null(0), transformed(0), upper_item(0)
+ :Item_exists_subselect(), optimizer(0), abort_on_null(0), transformed(0),
+ upper_item(0)
{}
subs_type substype() { return IN_SUBS; }
@@ -236,12 +238,14 @@ public:
was_null= 0;
}
trans_res select_transformer(JOIN *join);
- trans_res single_value_transformer(JOIN *join,
- Comp_creator *func);
+ trans_res select_in_like_transformer(JOIN *join, Comp_creator *func);
+ trans_res single_value_transformer(JOIN *join, Comp_creator *func);
trans_res row_value_transformer(JOIN * join);
longlong val_int();
double val_real();
String *val_str(String*);
+ my_decimal *val_decimal(my_decimal *);
+ bool val_bool();
void top_level_item() { abort_on_null=1; }
bool test_limit(st_select_lex_unit *unit);
void print(String *str);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4b7415b6829..3dbc3833f9e 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -311,8 +311,8 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table,
{
Field *field= ((Item_field*) args[0])->field;
- if ((field= create_tmp_field_from_field(current_thd, field, this, table,
- 0, convert_blob_length)))
+ if ((field= create_tmp_field_from_field(current_thd, field, name, table,
+ NULL, convert_blob_length)))
field->flags&= ~NOT_NULL_FLAG;
return field;
}
@@ -2128,7 +2128,7 @@ my_decimal *Item_variance_field::val_decimal(my_decimal *dec_buf)
int simple_str_key_cmp(void* arg, byte* key1, byte* key2)
{
Field *f= (Field*) arg;
- return f->cmp(key1, key2);
+ return f->cmp((const char*)key1, (const char*)key2);
}
/*
@@ -2160,7 +2160,7 @@ int composite_key_cmp(void* arg, byte* key1, byte* key2)
C_MODE_START
-static int count_distinct_walk(void *elem, unsigned int count, void *arg)
+static int count_distinct_walk(void *elem, element_count count, void *arg)
{
(*((ulonglong*)arg))++;
return 0;
@@ -2665,17 +2665,17 @@ int group_concat_key_cmp_with_distinct_and_order(void* arg,byte* key1,
Append data from current leaf to item->result
*/
-int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
+int dump_leaf_key(byte* key, element_count count __attribute__((unused)),
Item_func_group_concat *item)
{
TABLE *table= item->table;
char *record= (char*) table->record[0] + table->s->null_bytes;
String tmp(table->record[1], table->s->reclength, default_charset_info), tmp2;
- String &result= item->result;
+ String *result= &item->result;
Item **arg= item->args, **arg_end= item->args + item->arg_count_field;
- if (result.length())
- result.append(*item->separator);
+ if (result->length())
+ result->append(*item->separator);
tmp.length(0);
@@ -2702,14 +2702,14 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
else
res= (*arg)->val_str(&tmp);
if (res)
- result.append(*res);
+ result->append(*res);
}
/* stop if length of result more than max_length */
- if (result.length() > item->max_length)
+ if (result->length() > item->max_length)
{
item->count_cut_values++;
- result.length(item->max_length);
+ result->length(item->max_length);
item->warning_for_row= TRUE;
return 1;
}
@@ -2910,8 +2910,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
MYF(0));
return TRUE;
}
- if (!args) /* allocation in constructor may fail */
- return TRUE;
thd->allow_sum_func= 0;
maybe_null= 0;
@@ -2972,12 +2970,10 @@ bool Item_func_group_concat::setup(THD *thd)
if (item->null_value)
{
always_null= 1;
- break;
+ DBUG_RETURN(FALSE);
}
}
}
- if (always_null)
- DBUG_RETURN(FALSE);
List<Item> all_fields(list);
/*
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 6a60ec0b234..d03ef94b9cd 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -862,7 +862,8 @@ class Item_func_group_concat : public Item_sum
friend int group_concat_key_cmp_with_distinct_and_order(void* arg,
byte* key1,
byte* key2);
- friend int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
+ friend int dump_leaf_key(byte* key,
+ element_count count __attribute__((unused)),
Item_func_group_concat *group_concat_item);
public:
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 3d1feee1f8c..c603d41fa2e 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -160,7 +160,8 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0,
static bool extract_date_time(DATE_TIME_FORMAT *format,
const char *val, uint length, TIME *l_time,
timestamp_type cached_timestamp_type,
- const char **sub_pattern_end)
+ const char **sub_pattern_end,
+ const char *date_time_type)
{
int weekday= 0, yearday= 0, daypart= 0;
int week_number= -1;
@@ -188,12 +189,12 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
for (; ptr != end && val != val_end; ptr++)
{
-
if (*ptr == '%' && ptr+1 != end)
{
int val_len;
char *tmp;
+ error= 0;
/* Skip pre-space between each argument */
while (val != val_end && my_isspace(cs, *val))
val++;
@@ -343,16 +344,22 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
/* Time in AM/PM notation */
case 'r':
- error= extract_date_time(&time_ampm_format, val,
- (uint)(val_end - val), l_time,
- cached_timestamp_type, &val);
+ /*
+ We can't just set error here, as we don't want to generate two
+ warnings in case of errors
+ */
+ if (extract_date_time(&time_ampm_format, val,
+ (uint)(val_end - val), l_time,
+ cached_timestamp_type, &val, "time"))
+ DBUG_RETURN(1);
break;
/* Time in 24-hour notation */
case 'T':
- error= extract_date_time(&time_24hrs_format, val,
- (uint)(val_end - val), l_time,
- cached_timestamp_type, &val);
+ if (extract_date_time(&time_24hrs_format, val,
+ (uint)(val_end - val), l_time,
+ cached_timestamp_type, &val, "time"))
+ DBUG_RETURN(1);
break;
/* Conversion specifiers that match classes of characters */
@@ -471,6 +478,13 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
DBUG_RETURN(0);
err:
+ {
+ char buff[128];
+ strmake(buff, val_begin, min(length, sizeof(buff)-1));
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+ date_time_type, buff, "str_to_time");
+ }
DBUG_RETURN(1);
}
@@ -2972,7 +2986,7 @@ bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date)
date_time_format.format.str= (char*) format->ptr();
date_time_format.format.length= format->length();
if (extract_date_time(&date_time_format, val->ptr(), val->length(),
- ltime, cached_timestamp_type, 0))
+ ltime, cached_timestamp_type, 0, "datetime"))
goto null_date;
if (cached_timestamp_type == MYSQL_TIMESTAMP_TIME && ltime->day)
{
diff --git a/sql/log.cc b/sql/log.cc
index f477faa4912..37f9c5a9122 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1640,57 +1640,6 @@ bool MYSQL_LOG::write(Log_event *event_info)
if (thd)
{
-#if MYSQL_VERSION_ID < 50003
- /*
- To make replication of charsets working in 4.1 we are writing values
- of charset related variables before every statement in the binlog,
- if values of those variables differ from global server-wide defaults.
- We are using SET ONE_SHOT command so that the charset vars get reset
- to default after the first non-SET statement.
- In the next 5.0 this won't be needed as we will use the new binlog
- format to store charset info.
- */
- if ((thd->variables.character_set_client->number !=
- global_system_variables.collation_server->number) ||
- (thd->variables.character_set_client->number !=
- thd->variables.collation_connection->number) ||
- (thd->variables.collation_server->number !=
- thd->variables.collation_connection->number))
- {
- char buf[200];
- int written= my_snprintf(buf, sizeof(buf)-1,
- "SET ONE_SHOT CHARACTER_SET_CLIENT=%u,\
-COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u",
- (uint) thd->variables.character_set_client->number,
- (uint) thd->variables.collation_connection->number,
- (uint) thd->variables.collation_database->number,
- (uint) thd->variables.collation_server->number);
- Query_log_event e(thd, buf, written, 0, FALSE);
- if (e.write(file))
- goto err;
- }
-#endif
- /*
- We use the same ONE_SHOT trick for making replication of time zones
- working in 4.1. Again in 5.0 we have better means for doing this.
-
- TODO: we should do like we now do with charsets (no more ONE_SHOT;
- logging in each event in a compact format). Dmitri says we can do:
- if (time_zone_used) write the timezone to binlog (in a format to be
- defined).
- */
- if (thd->time_zone_used &&
- thd->variables.time_zone != global_system_variables.time_zone)
- {
- char buf[MAX_TIME_ZONE_NAME_LENGTH + 26];
- char *buf_end= strxmov(buf, "SET ONE_SHOT TIME_ZONE='",
- thd->variables.time_zone->get_name()->ptr(),
- "'", NullS);
- Query_log_event e(thd, buf, buf_end - buf, 0, FALSE);
- if (e.write(file))
- goto err;
- }
-
if (thd->last_insert_id_used)
{
Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT,
@@ -2507,7 +2456,7 @@ int TC_LOG_MMAP::open(const char *opt_name)
goto err;
}
- data= (uchar *)my_mmap(0, file_length, PROT_READ|PROT_WRITE,
+ data= (uchar *)my_mmap(0, (size_t)file_length, PROT_READ|PROT_WRITE,
MAP_NOSYNC|MAP_SHARED, fd, 0);
if (data == MAP_FAILED)
{
@@ -2516,7 +2465,7 @@ int TC_LOG_MMAP::open(const char *opt_name)
}
inited=2;
- npages=file_length/tc_log_page_size;
+ npages=(uint)file_length/tc_log_page_size;
DBUG_ASSERT(npages >= 3); // to guarantee non-empty pool
if (!(pages=(PAGE *)my_malloc(npages*sizeof(PAGE), MYF(MY_WME|MY_ZEROFILL))))
goto err;
@@ -2542,7 +2491,7 @@ int TC_LOG_MMAP::open(const char *opt_name)
goto err;
memcpy(data, tc_log_magic, sizeof(tc_log_magic));
- data[sizeof(tc_log_magic)]= total_ha_2pc;
+ data[sizeof(tc_log_magic)]= (uchar)total_ha_2pc;
my_msync(fd, data, tc_log_page_size, MS_SYNC);
inited=5;
@@ -2796,7 +2745,7 @@ void TC_LOG_MMAP::close()
case 3:
my_free((gptr)pages, MYF(0));
case 2:
- my_munmap(data, file_length);
+ my_munmap(data, (size_t)file_length);
case 1:
my_close(fd, MYF(0));
}
@@ -2844,7 +2793,7 @@ int TC_LOG_MMAP::recover()
goto err2;
hash_free(&xids);
- bzero(data, file_length);
+ bzero(data, (size_t)file_length);
return 0;
err2:
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 7c05392a873..4189bf2a787 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -507,8 +507,6 @@ void Log_event::init_show_field_list(List<Item>* field_list)
field_list->push_back(new Item_empty_string("Info", 20));
}
-#endif /* !MYSQL_CLIENT */
-
/*
Log_event::write()
@@ -593,7 +591,6 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
*/
-#ifndef MYSQL_CLIENT
int Log_event::read_log_event(IO_CACHE* file, String* packet,
pthread_mutex_t* log_lock)
{
@@ -957,6 +954,7 @@ void Query_log_event::pack_info(Protocol *protocol)
}
#endif
+#ifndef MYSQL_CLIENT
/*
Query_log_event::write()
@@ -974,7 +972,8 @@ bool Query_log_event::write(IO_CACHE* file)
1+8+ // code of sql_mode and sql_mode
1+1+FN_REFLEN+ // code of catalog and catalog length and catalog
1+4+ // code of autoinc and the 2 autoinc variables
- 1+6 // code of charset and charset
+ 1+6+ // code of charset and charset
+ 1+1+MAX_TIME_ZONE_NAME_LENGTH // code of tz and tz length and tz name
], *start, *start_of_status;
ulong event_length;
@@ -1031,37 +1030,40 @@ bool Query_log_event::write(IO_CACHE* file)
start_of_status= start= buf+QUERY_HEADER_LEN;
if (flags2_inited)
{
- *(start++)= Q_FLAGS2_CODE;
+ *start++= Q_FLAGS2_CODE;
int4store(start, flags2);
start+= 4;
}
if (sql_mode_inited)
{
- *(start++)= Q_SQL_MODE_CODE;
+ *start++= Q_SQL_MODE_CODE;
int8store(start, (ulonglong)sql_mode);
start+= 8;
}
- if (catalog_len >= 0) // i.e. "catalog inited" (false for 4.0 events)
+ if (catalog_len) // i.e. "catalog inited" (false for 4.0 events)
{
- *(start++)= Q_CATALOG_CODE;
- *(start++)= (uchar) catalog_len;
+ *start++= Q_CATALOG_NZ_CODE;
+ *start++= (uchar) catalog_len;
bmove(start, catalog, catalog_len);
start+= catalog_len;
/*
- We write a \0 at the end. As we also have written the length, it's
- apparently useless; but in fact it enables us to just do
- catalog= a_pointer_to_the_buffer_of_the_read_event
- later in the slave SQL thread.
- If we didn't have the \0, we would need to memdup to build the catalog in
- the slave SQL thread.
- And still the interest of having the length too is that in the slave SQL
- thread we immediately know at which position the catalog ends (no need to
- search for '\0'. In other words: length saves search, \0 saves mem alloc,
- at the cost of 1 redundant byte on the disk.
- Note that this is only a fix until we change 'catalog' to LEX_STRING
- (then we won't need the \0).
+ In 5.0.x where x<4 masters we used to store the end zero here. This was
+ a waste of one byte so we don't do it in x>=4 masters. We change code to
+ Q_CATALOG_NZ_CODE, because re-using the old code would make x<4 slaves
+ of this x>=4 master segfault (expecting a zero when there is
+ none). Remaining compatibility problems are: the older slave will not
+ find the catalog; but it is will not crash, and it's not an issue
+ that it does not find the catalog as catalogs were not used in these
+ older MySQL versions (we store it in binlog and read it from relay log
+ but do nothing useful with it). What is an issue is that the older slave
+ will stop processing the Q_* blocks (and jumps to the db/query) as soon
+ as it sees unknown Q_CATALOG_NZ_CODE; so it will not be able to read
+ Q_AUTO_INCREMENT*, Q_CHARSET and so replication will fail silently in
+ various ways. Documented that you should not mix alpha/beta versions if
+ they are not exactly the same version, with example of 5.0.3->5.0.2 and
+ 5.0.4->5.0.3. If replication is from older to new, the new will
+ recognize Q_CATALOG_CODE and have no problem.
*/
- *(start++)= '\0';
}
if (auto_increment_increment != 1)
{
@@ -1072,15 +1074,24 @@ bool Query_log_event::write(IO_CACHE* file)
}
if (charset_inited)
{
- *(start++)= Q_CHARSET_CODE;
+ *start++= Q_CHARSET_CODE;
memcpy(start, charset, 6);
start+= 6;
}
+ if (time_zone_len)
+ {
+ /* In the TZ sys table, column Name is of length 64 so this should be ok */
+ DBUG_ASSERT(time_zone_len <= MAX_TIME_ZONE_NAME_LENGTH);
+ *start++= Q_TIME_ZONE_CODE;
+ *start++= time_zone_len;
+ memcpy(start, time_zone_str, time_zone_len);
+ start+= time_zone_len;
+ }
/*
Here there could be code like
if (command-line-option-which-says-"log_this_variable" && inited)
{
- *(start++)= Q_THIS_VARIABLE_CODE;
+ *start++= Q_THIS_VARIABLE_CODE;
int4store(start, this_variable);
start+= 4;
}
@@ -1109,8 +1120,6 @@ bool Query_log_event::write(IO_CACHE* file)
/*
Query_log_event::Query_log_event()
*/
-
-#ifndef MYSQL_CLIENT
Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
ulong query_length, bool using_trans,
bool suppress_use)
@@ -1151,6 +1160,18 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
int2store(charset, thd_arg->variables.character_set_client->number);
int2store(charset+2, thd_arg->variables.collation_connection->number);
int2store(charset+4, thd_arg->variables.collation_server->number);
+ if (thd_arg->time_zone_used)
+ {
+ /*
+ Note that our event becomes dependent on the Time_zone object
+ representing the time zone. Fortunately such objects are never deleted
+ or changed during mysqld's lifetime.
+ */
+ time_zone_len= thd_arg->variables.time_zone->get_name()->length();
+ time_zone_str= thd_arg->variables.time_zone->get_name()->ptr();
+ }
+ else
+ time_zone_len= 0;
DBUG_PRINT("info",("Query_log_event has flags2=%lu sql_mode=%lu",flags2,sql_mode));
}
#endif /* MYSQL_CLIENT */
@@ -1164,15 +1185,18 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
Query_log_event::Query_log_event(const char* buf, uint event_len,
const Format_description_log_event *description_event,
Log_event_type event_type)
- :Log_event(buf, description_event), data_buf(0), query(NullS), catalog(NullS),
+ :Log_event(buf, description_event), data_buf(0), query(NullS),
db(NullS), catalog_len(0), status_vars_len(0),
flags2_inited(0), sql_mode_inited(0), charset_inited(0),
- auto_increment_increment(1), auto_increment_offset(1)
+ auto_increment_increment(1), auto_increment_offset(1),
+ time_zone_len(0)
{
ulong data_len;
uint32 tmp;
uint8 common_header_len, post_header_len;
- const char *start, *end;
+ char *start;
+ const char *end;
+ bool catalog_nz= 1;
DBUG_ENTER("Query_log_event::Query_log_event(char*,...)");
common_header_len= description_event->common_header_len;
@@ -1192,7 +1216,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
slave_proxy_id= thread_id = uint4korr(buf + Q_THREAD_ID_OFFSET);
exec_time = uint4korr(buf + Q_EXEC_TIME_OFFSET);
- db_len = (uint)buf[Q_DB_LEN_OFFSET];
+ db_len = (uint)buf[Q_DB_LEN_OFFSET]; // TODO: add a check of all *_len vars
error_code = uint2korr(buf + Q_ERR_CODE_OFFSET);
/*
@@ -1218,7 +1242,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
/* variable-part: the status vars; only in MySQL 5.0 */
start= (char*) (buf+post_header_len);
- end= (char*) (start+status_vars_len);
+ end= (const char*) (start+status_vars_len);
for (const uchar* pos= (const uchar*) start; pos < (const uchar*) end;)
{
switch (*pos++) {
@@ -1240,11 +1264,10 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
pos+= 8;
break;
}
- case Q_CATALOG_CODE:
- catalog_len= *pos;
- if (catalog_len)
- catalog= (char*) pos+1; // Will be copied later
- pos+= catalog_len+2;
+ case Q_CATALOG_NZ_CODE:
+ if ((catalog_len= *pos))
+ catalog= (char*) pos+1; // Will be copied later
+ pos+= catalog_len+1;
break;
case Q_AUTO_INCREMENT:
auto_increment_increment= uint2korr(pos);
@@ -1258,32 +1281,60 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
pos+= 6;
break;
}
+ case Q_TIME_ZONE_CODE:
+ {
+ if ((time_zone_len= *pos))
+ time_zone_str= (char *)(pos+1);
+ pos+= time_zone_len+1;
+ break;
+ }
+ case Q_CATALOG_CODE: /* for 5.0.x where 0<=x<=3 masters */
+ if ((catalog_len= *pos))
+ catalog= (char*) pos+1; // Will be copied later
+ pos+= catalog_len+2; // leap over end 0
+ catalog_nz= 0; // catalog has end 0 in event
+ break;
default:
/* That's why you must write status vars in growing order of code */
DBUG_PRINT("info",("Query_log_event has unknown status vars (first has\
code: %u), skipping the rest of them", (uint) *(pos-1)));
- pos= (const uchar*) end; // Break look
+ pos= (const uchar*) end; // Break loop
}
}
- /* A 2nd variable part; this is common to all versions */
-
- if (!(start= data_buf = (char*) my_malloc(catalog_len + data_len +2, MYF(MY_WME))))
+ if (!(start= data_buf = (char*) my_malloc(catalog_len + 1 +
+ time_zone_len + 1 +
+ data_len + 1, MYF(MY_WME))))
DBUG_VOID_RETURN;
- if (catalog) // If catalog is given
+ if (catalog_len) // If catalog is given
+ {
+ if (likely(catalog_nz)) // true except if event comes from 5.0.0|1|2|3.
+ {
+ memcpy(start, catalog, catalog_len);
+ catalog= start;
+ start+= catalog_len;
+ *start++= 0;
+ }
+ else
+ {
+ memcpy(start, catalog, catalog_len+1); // copy end 0
+ catalog= start;
+ start+= catalog_len+1;
+ }
+ }
+ if (time_zone_len)
{
- memcpy((char*) start, catalog, catalog_len+1); // Copy name and end \0
- catalog= start;
- start+= catalog_len+1;
+ memcpy(start, time_zone_str, time_zone_len);
+ time_zone_str= start;
+ start+= time_zone_len;
+ *start++= 0;
}
+ /* A 2nd variable part; this is common to all versions */
memcpy((char*) start, end, data_len); // Copy db and query
- ((char*) start)[data_len]= '\0'; // End query with \0 (For safetly)
+ start[data_len]= '\0'; // End query with \0 (For safetly)
db= start;
query= start + db_len + 1;
q_len= data_len - db_len -1;
- /* This is used to detect wrong parsing. Could be removed in the future. */
- DBUG_PRINT("info", ("catalog: '%s' len: %u db: '%s' len: %u q_len: %lu",
- catalog, (uint) catalog_len, db, (uint) db_len,q_len));
DBUG_VOID_RETURN;
}
@@ -1391,6 +1442,8 @@ void Query_log_event::print_query_header(FILE* file, bool short_form,
last_event_info->auto_increment_offset= auto_increment_offset;
}
+ /* TODO: print the catalog when we feature SET CATALOG */
+
if (likely(charset_inited))
{
if (unlikely(!last_event_info->charset_inited)) /* first Query event */
@@ -1411,6 +1464,14 @@ void Query_log_event::print_query_header(FILE* file, bool short_form,
memcpy(last_event_info->charset, charset, 6);
}
}
+ if (time_zone_len)
+ {
+ if (bcmp(last_event_info->time_zone_str, time_zone_str, time_zone_len+1))
+ {
+ fprintf(file,"SET @@session.time_zone='%s';\n", time_zone_str);
+ memcpy(last_event_info->time_zone_str, time_zone_str, time_zone_len+1);
+ }
+ }
}
@@ -1444,7 +1505,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, const char *query
alloced block (see Query_log_event::exec_event()). Same for thd->db.
Thank you.
*/
- thd->catalog= (char*) catalog;
+ thd->catalog= catalog_len ? (char *) catalog : (char *)"";
thd->db_length= db_len;
thd->db= (char *) rpl_filter->get_rewrite_db(db, &thd->db_length);
thd->variables.auto_increment_increment= auto_increment_increment;
@@ -1514,20 +1575,28 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, const char *query
get_charset(uint2korr(charset+4), MYF(MY_WME))))
{
/*
- We updated the thd->variables with nonsensical values (0), and the
- thread is not guaranteed to terminate now (as it may be configured
- to ignore EE_UNKNOWN_CHARSET);if we're going to execute a next
- statement we'll have a new charset info with it, so no problem to
- have stored 0 in thd->variables. But we invalidate cached
- charset to force a check next time (otherwise if next time
- charset is unknown again we won't detect it).
+ We updated the thd->variables with nonsensical values (0). Let's
+ set them to something safe (i.e. which avoids crash), and we'll
+ stop with EE_UNKNOWN_CHARSET in compare_errors (unless set to
+ ignore this error).
*/
- rli->cached_charset_invalidate();
+ set_slave_thread_default_charset(thd, rli);
goto compare_errors;
}
thd->update_charset(); // for the charset change to take effect
}
}
+ if (time_zone_len)
+ {
+ String tmp(time_zone_str, time_zone_len, &my_charset_bin);
+ if (!(thd->variables.time_zone=
+ my_tz_find_with_opening_tz_tables(thd, &tmp)))
+ {
+ my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), tmp.c_ptr());
+ thd->variables.time_zone= global_system_variables.time_zone;
+ goto compare_errors;
+ }
+ }
/* Execute the query (note that we bypass dispatch_command()) */
mysql_parse(thd, thd->query, thd->query_length);
@@ -1752,6 +1821,7 @@ Start_log_event_v3::Start_log_event_v3(const char* buf,
Start_log_event_v3::write()
*/
+#ifndef MYSQL_CLIENT
bool Start_log_event_v3::write(IO_CACHE* file)
{
char buff[START_V3_HEADER_LEN];
@@ -1761,6 +1831,7 @@ bool Start_log_event_v3::write(IO_CACHE* file)
return (write_header(file, sizeof(buff)) ||
my_b_safe_write(file, (byte*) buff, sizeof(buff)));
}
+#endif
/*
@@ -1976,7 +2047,7 @@ Format_description_log_event(const char* buf,
DBUG_VOID_RETURN;
}
-
+#ifndef MYSQL_CLIENT
bool Format_description_log_event::write(IO_CACHE* file)
{
/*
@@ -1993,6 +2064,7 @@ bool Format_description_log_event::write(IO_CACHE* file)
return (write_header(file, sizeof(buff)) ||
my_b_safe_write(file, buff, sizeof(buff)));
}
+#endif
/*
SYNOPSIS
@@ -2013,6 +2085,7 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
delete rli->relay_log.description_event_for_exec;
rli->relay_log.description_event_for_exec= this;
+#ifdef USING_TRANSACTIONS
/*
As a transaction NEVER spans on 2 or more binlogs:
if we have an active transaction at this point, the master died
@@ -2034,6 +2107,7 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
"to its binary log.");
end_trans(thd, ROLLBACK);
}
+#endif
/*
If this event comes from ourselves, there is no cleaning task to perform,
we don't call Start_log_event_v3::exec_event() (this was just to update the
@@ -2209,6 +2283,8 @@ void Load_log_event::pack_info(Protocol *protocol)
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
+#ifndef MYSQL_CLIENT
+
/*
Load_log_event::write_data_header()
*/
@@ -2250,7 +2326,6 @@ bool Load_log_event::write_data_body(IO_CACHE* file)
Load_log_event::Load_log_event()
*/
-#ifndef MYSQL_CLIENT
Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
const char *db_arg, const char *table_name_arg,
List<Item> &fields_arg,
@@ -2864,6 +2939,7 @@ Rotate_log_event::Rotate_log_event(const char* buf, uint event_len,
Rotate_log_event::write()
*/
+#ifndef MYSQL_CLIENT
bool Rotate_log_event::write(IO_CACHE* file)
{
char buf[ROTATE_HEADER_LEN];
@@ -2872,7 +2948,7 @@ bool Rotate_log_event::write(IO_CACHE* file)
my_b_safe_write(file, (byte*)buf, ROTATE_HEADER_LEN) ||
my_b_safe_write(file, (byte*)new_log_ident, (uint) ident_len));
}
-
+#endif
/*
Rotate_log_event::exec_event()
@@ -2930,17 +3006,10 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
master is 4.0 then the events are in the slave's format (conversion).
*/
set_slave_thread_options(thd);
+ set_slave_thread_default_charset(thd, rli);
thd->variables.sql_mode= global_system_variables.sql_mode;
thd->variables.auto_increment_increment=
thd->variables.auto_increment_offset= 1;
- thd->variables.character_set_client=
- global_system_variables.character_set_client;
- thd->variables.collation_connection=
- global_system_variables.collation_connection;
- thd->variables.collation_server=
- global_system_variables.collation_server;
- thd->update_charset();
- rli->cached_charset_invalidate();
}
pthread_mutex_unlock(&rli->data_lock);
pthread_cond_broadcast(&rli->data_cond);
@@ -3002,6 +3071,7 @@ const char* Intvar_log_event::get_var_type_name()
Intvar_log_event::write()
*/
+#ifndef MYSQL_CLIENT
bool Intvar_log_event::write(IO_CACHE* file)
{
byte buf[9];
@@ -3010,6 +3080,7 @@ bool Intvar_log_event::write(IO_CACHE* file)
return (write_header(file, sizeof(buf)) ||
my_b_safe_write(file, buf, sizeof(buf)));
}
+#endif
/*
@@ -3094,6 +3165,7 @@ Rand_log_event::Rand_log_event(const char* buf,
}
+#ifndef MYSQL_CLIENT
bool Rand_log_event::write(IO_CACHE* file)
{
byte buf[16];
@@ -3102,6 +3174,7 @@ bool Rand_log_event::write(IO_CACHE* file)
return (write_header(file, sizeof(buf)) ||
my_b_safe_write(file, buf, sizeof(buf)));
}
+#endif
#ifdef MYSQL_CLIENT
@@ -3165,11 +3238,13 @@ Xid_log_event(const char* buf,
}
+#ifndef MYSQL_CLIENT
bool Xid_log_event::write(IO_CACHE* file)
{
return write_header(file, sizeof(xid)) ||
my_b_safe_write(file, (byte*) &xid, sizeof(xid));
}
+#endif
#ifdef MYSQL_CLIENT
@@ -3303,6 +3378,7 @@ User_var_log_event(const char* buf,
}
+#ifndef MYSQL_CLIENT
bool User_var_log_event::write(IO_CACHE* file)
{
char buf[UV_NAME_LEN_SIZE];
@@ -3337,7 +3413,7 @@ bool User_var_log_event::write(IO_CACHE* file)
dec->fix_buffer_pointer();
buf2[0]= (char)(dec->intg + dec->frac);
buf2[1]= (char)dec->frac;
- decimal2bin((decimal*)val, buf2+2, buf2[0], buf2[1]);
+ decimal2bin((decimal_t*)val, buf2+2, buf2[0], buf2[1]);
val_len= decimal_bin_size(buf2[0], buf2[1]) + 2;
break;
}
@@ -3362,6 +3438,7 @@ bool User_var_log_event::write(IO_CACHE* file)
my_b_safe_write(file, (byte*) buf1, buf1_length) ||
my_b_safe_write(file, (byte*) pos, val_len));
}
+#endif
/*
@@ -3404,8 +3481,8 @@ void User_var_log_event::print(FILE* file, bool short_form, LAST_EVENT_INFO* las
int str_len= sizeof(str_buf) - 1;
int precision= (int)val[0];
int scale= (int)val[1];
- decimal_digit dec_buf[10];
- decimal dec;
+ decimal_digit_t dec_buf[10];
+ decimal_t dec;
dec.len= 10;
dec.buf= dec_buf;
@@ -3635,6 +3712,7 @@ int Slave_log_event::get_data_size()
}
+#ifndef MYSQL_CLIENT
bool Slave_log_event::write(IO_CACHE* file)
{
ulong event_length= get_data_size();
@@ -3645,6 +3723,7 @@ bool Slave_log_event::write(IO_CACHE* file)
return (write_header(file, event_length) ||
my_b_safe_write(file, (byte*) mem_pool, event_length));
}
+#endif
void Slave_log_event::init_from_mem_pool(int data_size)
@@ -3771,7 +3850,6 @@ Create_file_log_event(THD* thd_arg, sql_exchange* ex,
sql_ex.force_new_format();
DBUG_VOID_RETURN;
}
-#endif /* !MYSQL_CLIENT */
/*
@@ -3816,6 +3894,7 @@ bool Create_file_log_event::write_base(IO_CACHE* file)
return res;
}
+#endif /* !MYSQL_CLIENT */
/*
Create_file_log_event ctor
@@ -3948,8 +4027,10 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
strmov(p, ".info"); // strmov takes less code than memcpy
strnmov(proc_info, "Making temp file ", 17); // no end 0
thd->proc_info= proc_info;
- if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC,
- MYF(MY_WME))) < 0 ||
+ my_delete(fname_buf, MYF(0)); // old copy may exist already
+ if ((fd= my_create(fname_buf, CREATE_MODE,
+ O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
+ MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0,
MYF(MY_WME|MY_NABP)))
{
@@ -3973,8 +4054,10 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
my_close(fd, MYF(0));
// fname_buf now already has .data, not .info, because we did our trick
- if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC,
- MYF(MY_WME))) < 0)
+ my_delete(fname_buf, MYF(0)); // old copy may exist already
+ if ((fd= my_create(fname_buf, CREATE_MODE,
+ O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
+ MYF(MY_WME))) < 0)
{
slave_print_error(rli,my_errno, "Error in Create_file event: could not open file '%s'", fname_buf);
goto err;
@@ -4043,6 +4126,7 @@ Append_block_log_event::Append_block_log_event(const char* buf, uint len,
Append_block_log_event::write()
*/
+#ifndef MYSQL_CLIENT
bool Append_block_log_event::write(IO_CACHE* file)
{
byte buf[APPEND_BLOCK_HEADER_LEN];
@@ -4051,6 +4135,7 @@ bool Append_block_log_event::write(IO_CACHE* file)
my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
my_b_safe_write(file, (byte*) block, block_len));
}
+#endif
/*
@@ -4088,12 +4173,12 @@ void Append_block_log_event::pack_info(Protocol *protocol)
/*
- Append_block_log_event::get_open_mode()
+ Append_block_log_event::get_create_or_append()
*/
-int Append_block_log_event::get_open_mode() const
+int Append_block_log_event::get_create_or_append() const
{
- return O_WRONLY | O_APPEND | O_BINARY;
+ return 0; /* append to the file, fail if not exists */
}
/*
@@ -4111,7 +4196,21 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
memcpy(p, ".data", 6);
strnmov(proc_info, "Making temp file ", 17); // no end 0
thd->proc_info= proc_info;
- if ((fd = my_open(fname, get_open_mode(), MYF(MY_WME))) < 0)
+ if (get_create_or_append())
+ {
+ my_delete(fname, MYF(0)); // old copy may exist already
+ if ((fd= my_create(fname, CREATE_MODE,
+ O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
+ MYF(MY_WME))) < 0)
+ {
+ slave_print_error(rli, my_errno,
+ "Error in %s event: could not create file '%s'",
+ get_type_str(), fname);
+ goto err;
+ }
+ }
+ else if ((fd = my_open(fname, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW,
+ MYF(MY_WME))) < 0)
{
slave_print_error(rli, my_errno,
"Error in %s event: could not open file '%s'",
@@ -4172,6 +4271,7 @@ Delete_file_log_event::Delete_file_log_event(const char* buf, uint len,
Delete_file_log_event::write()
*/
+#ifndef MYSQL_CLIENT
bool Delete_file_log_event::write(IO_CACHE* file)
{
byte buf[DELETE_FILE_HEADER_LEN];
@@ -4179,6 +4279,7 @@ bool Delete_file_log_event::write(IO_CACHE* file)
return (write_header(file, sizeof(buf)) ||
my_b_safe_write(file, buf, sizeof(buf)));
}
+#endif
/*
@@ -4266,6 +4367,7 @@ Execute_load_log_event::Execute_load_log_event(const char* buf, uint len,
Execute_load_log_event::write()
*/
+#ifndef MYSQL_CLIENT
bool Execute_load_log_event::write(IO_CACHE* file)
{
byte buf[EXEC_LOAD_HEADER_LEN];
@@ -4273,6 +4375,7 @@ bool Execute_load_log_event::write(IO_CACHE* file)
return (write_header(file, sizeof(buf)) ||
my_b_safe_write(file, buf, sizeof(buf)));
}
+#endif
/*
@@ -4320,7 +4423,8 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
Load_log_event* lev = 0;
memcpy(p, ".info", 6);
- if ((fd = my_open(fname, O_RDONLY|O_BINARY, MYF(MY_WME))) < 0 ||
+ if ((fd = my_open(fname, O_RDONLY | O_BINARY | O_NOFOLLOW,
+ MYF(MY_WME))) < 0 ||
init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0,
MYF(MY_WME|MY_NABP)))
{
@@ -4419,9 +4523,9 @@ Begin_load_query_log_event(const char* buf, uint len,
#if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Begin_load_query_log_event::get_open_mode() const
+int Begin_load_query_log_event::get_create_or_append() const
{
- return O_CREAT | O_WRONLY | O_BINARY | O_TRUNC;
+ return 1; /* create the file */
}
#endif /* defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -4476,6 +4580,7 @@ ulong Execute_load_query_log_event::get_post_header_size_for_derived()
}
+#ifndef MYSQL_CLIENT
bool
Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file)
{
@@ -4486,6 +4591,7 @@ Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file)
*(buf + 4 + 4 + 4)= (char)dup_handling;
return my_b_safe_write(file, (byte*) buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
}
+#endif
#ifdef MYSQL_CLIENT
@@ -4596,7 +4702,12 @@ Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
/* Forging file name for deletion in same buffer */
*fname_end= 0;
- (void) my_delete(fname, MYF(MY_WME));
+ /*
+ If there was an error the slave is going to stop, leave the
+ file so that we can re-execute this event at START SLAVE.
+ */
+ if (!error)
+ (void) my_delete(fname, MYF(MY_WME));
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
return error;
diff --git a/sql/log_event.h b/sql/log_event.h
index 43a801da851..2985fcabb50 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -234,9 +234,24 @@ struct sql_ex_info
/* these are codes, not offsets; not more than 256 values (1 byte). */
#define Q_FLAGS2_CODE 0
#define Q_SQL_MODE_CODE 1
+#ifndef TO_BE_DELETED
+/*
+ Q_CATALOG_CODE is catalog with end zero stored; it is used only by MySQL
+ 5.0.x where 0<=x<=3.
+*/
#define Q_CATALOG_CODE 2
+#endif
#define Q_AUTO_INCREMENT 3
#define Q_CHARSET_CODE 4
+#define Q_TIME_ZONE_CODE 5
+/*
+ Q_CATALOG_NZ_CODE is catalog withOUT end zero stored; it is used by MySQL
+ 5.0.x where x>=4. Saves one byte in every Query_log_event in binlog,
+ compared to Q_CATALOG_CODE. The reason we didn't simply re-use
+ Q_CATALOG_CODE is that then a 5.0.3 slave of this 5.0.x (x>=4) master would
+ crash (segfault etc) because it would expect a 0 when there is none.
+*/
+#define Q_CATALOG_NZ_CODE 6
/* Intvar event post-header */
@@ -448,6 +463,7 @@ typedef struct st_last_event_info
ulong auto_increment_increment, auto_increment_offset;
bool charset_inited;
char charset[6]; // 3 variables, each of them storable in 2 bytes
+ char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH];
st_last_event_info()
:flags2_inited(0), sql_mode_inited(0),
auto_increment_increment(1),auto_increment_offset(1), charset_inited(0)
@@ -459,6 +475,7 @@ typedef struct st_last_event_info
*/
bzero(db, sizeof(db));
bzero(charset, sizeof(charset));
+ bzero(time_zone_str, sizeof(time_zone_str));
}
} LAST_EVENT_INFO;
#endif
@@ -583,6 +600,7 @@ public:
my_free((gptr) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
}
+#ifndef MYSQL_CLIENT
bool write_header(IO_CACHE* file, ulong data_length);
virtual bool write(IO_CACHE* file)
{
@@ -590,13 +608,14 @@ public:
write_data_header(file) ||
write_data_body(file));
}
- virtual bool is_artificial_event() { return 0; }
virtual bool write_data_header(IO_CACHE* file)
{ return 0; }
virtual bool write_data_body(IO_CACHE* file __attribute__((unused)))
{ return 0; }
+#endif
virtual Log_event_type get_type_code() = 0;
virtual bool is_valid() const = 0;
+ virtual bool is_artificial_event() { return 0; }
inline bool get_cache_stmt() { return cache_stmt; }
Log_event(const char* buf, const Format_description_log_event* description_event);
virtual ~Log_event() { free_temp_buf();}
@@ -672,7 +691,7 @@ public:
concerned) from here.
*/
- int catalog_len; // <= 255 char; -1 means uninited
+ uint catalog_len; // <= 255 char; 0 means uninited
/*
We want to be able to store a variable number of N-bit status vars:
@@ -714,6 +733,8 @@ public:
ulong sql_mode;
ulong auto_increment_increment, auto_increment_offset;
char charset[6];
+ uint time_zone_len; /* 0 means uninited */
+ const char *time_zone_str;
#ifndef MYSQL_CLIENT
@@ -737,12 +758,13 @@ public:
~Query_log_event()
{
if (data_buf)
- {
my_free((gptr) data_buf, MYF(0));
- }
}
Log_event_type get_type_code() { return QUERY_EVENT; }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+ virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
+#endif
bool is_valid() const { return query != 0; }
/*
@@ -751,7 +773,6 @@ public:
*/
virtual ulong get_post_header_size_for_derived() { return 0; }
/* Writes derived event-specific part of post header. */
- virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
};
#ifdef HAVE_REPLICATION
@@ -790,7 +811,9 @@ public:
int get_data_size();
bool is_valid() const { return master_host != 0; }
Log_event_type get_type_code() { return SLAVE_EVENT; }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
};
#endif /* HAVE_REPLICATION */
@@ -885,8 +908,10 @@ public:
{
return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
}
+#ifndef MYSQL_CLIENT
bool write_data_header(IO_CACHE* file);
bool write_data_body(IO_CACHE* file);
+#endif
bool is_valid() const { return table_name != 0; }
int get_data_size()
{
@@ -962,7 +987,9 @@ public:
const Format_description_log_event* description_event);
~Start_log_event_v3() {}
Log_event_type get_type_code() { return START_EVENT_V3;}
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
bool is_valid() const { return 1; }
int get_data_size()
{
@@ -1004,7 +1031,9 @@ public:
const Format_description_log_event* description_event);
~Format_description_log_event() { my_free((gptr)post_header_len, MYF(0)); }
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
bool is_valid() const
{
return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
@@ -1054,7 +1083,9 @@ public:
Log_event_type get_type_code() { return INTVAR_EVENT;}
const char* get_var_type_name();
int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;}
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
bool is_valid() const { return 1; }
};
@@ -1092,7 +1123,9 @@ class Rand_log_event: public Log_event
~Rand_log_event() {}
Log_event_type get_type_code() { return RAND_EVENT;}
int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
bool is_valid() const { return 1; }
};
@@ -1127,7 +1160,9 @@ class Xid_log_event: public Log_event
~Xid_log_event() {}
Log_event_type get_type_code() { return XID_EVENT;}
int get_data_size() { return sizeof(xid); }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
bool is_valid() const { return 1; }
};
@@ -1169,7 +1204,9 @@ public:
User_var_log_event(const char* buf, const Format_description_log_event* description_event);
~User_var_log_event() {}
Log_event_type get_type_code() { return USER_VAR_EVENT;}
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
bool is_valid() const { return 1; }
};
@@ -1239,7 +1276,9 @@ public:
Log_event_type get_type_code() { return ROTATE_EVENT;}
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
bool is_valid() const { return new_log_ident != 0; }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
};
@@ -1299,6 +1338,7 @@ public:
4 + 1 + block_len);
}
bool is_valid() const { return inited_from_old || block != 0; }
+#ifndef MYSQL_CLIENT
bool write_data_header(IO_CACHE* file);
bool write_data_body(IO_CACHE* file);
/*
@@ -1306,6 +1346,7 @@ public:
write it as Load event - used on the slave
*/
bool write_base(IO_CACHE* file);
+#endif
};
@@ -1340,7 +1381,7 @@ public:
#ifdef HAVE_REPLICATION
int exec_event(struct st_relay_log_info* rli);
void pack_info(Protocol* protocol);
- virtual int get_open_mode() const;
+ virtual int get_create_or_append() const;
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
@@ -1352,7 +1393,9 @@ public:
Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;}
bool is_valid() const { return block != 0; }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
const char* get_db() { return db; }
};
@@ -1386,7 +1429,9 @@ public:
Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
bool is_valid() const { return file_id != 0; }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
const char* get_db() { return db; }
};
@@ -1419,7 +1464,9 @@ public:
Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
int get_data_size() { return EXEC_LOAD_HEADER_LEN ;}
bool is_valid() const { return file_id != 0; }
+#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
+#endif
const char* get_db() { return db; }
};
@@ -1442,7 +1489,7 @@ public:
bool using_trans);
#ifdef HAVE_REPLICATION
Begin_load_query_log_event(THD* thd);
- int get_open_mode() const;
+ int get_create_or_append() const;
#endif /* HAVE_REPLICATION */
#endif
Begin_load_query_log_event(const char* buf, uint event_len,
@@ -1507,7 +1554,9 @@ public:
bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
ulong get_post_header_size_for_derived();
+#ifndef MYSQL_CLIENT
bool write_post_header_for_derived(IO_CACHE* file);
+#endif
};
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 334c40c0f70..19b6abd7243 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -88,7 +88,7 @@ int my_decimal2string(uint mask, const my_decimal *d,
int result;
if (str->alloc(length))
return check_result(mask, E_DEC_OOM);
- result= decimal2string((decimal*) d, (char*) str->ptr(),
+ result= decimal2string((decimal_t*) d, (char*) str->ptr(),
&length, fixed_prec, fixed_dec,
filler);
str->length(length);
@@ -172,7 +172,7 @@ int str2my_decimal(uint mask, const char *from, uint length,
charset= &my_charset_bin;
}
from_end= end= (char*) from+length;
- err= string2decimal((char *)from, (decimal *)decimal_value, &end);
+ err= string2decimal((char *)from, (decimal_t*) decimal_value, &end);
if (end != from_end && !err)
{
/* Give warining if there is something other than end space */
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index a2cc61cf8d4..03801390d82 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -69,15 +69,15 @@ inline uint my_decimal_size(uint precision, uint scale)
/*
- my_decimal class limits 'decimal' type to what we need in MySQL
+ my_decimal class limits 'decimal_t' type to what we need in MySQL
It contains internally all necessary space needed by the instance so
no extra memory is needed. One should call fix_buffer_pointer() function
when he moves my_decimal objects in memory
*/
-class my_decimal :public decimal
+class my_decimal :public decimal_t
{
- decimal_digit buffer[DECIMAL_BUFF_LENGTH];
+ decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
public:
@@ -85,7 +85,7 @@ public:
{
len= DECIMAL_BUFF_LENGTH;
buf= buffer;
-#if !defined(DBUG_OFF)
+#if !defined (HAVE_purify) && !defined(DBUG_OFF)
/* Set buffer to 'random' value to find wrong buffer usage */
for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
buffer[i]= i;
@@ -97,8 +97,8 @@ public:
}
void fix_buffer_pointer() { buf= buffer; }
- bool sign() const { return decimal::sign; }
- void sign(bool s) { decimal::sign= s; }
+ bool sign() const { return decimal_t::sign; }
+ void sign(bool s) { decimal_t::sign= s; }
};
@@ -165,7 +165,7 @@ inline
int binary2my_decimal(uint mask, const char *bin, my_decimal *d, int prec,
int scale)
{
- return check_result(mask, bin2decimal((char *)bin, (decimal*) d, prec,
+ return check_result(mask, bin2decimal((char *)bin, (decimal_t*) d, prec,
scale));
}
@@ -173,7 +173,7 @@ int binary2my_decimal(uint mask, const char *bin, my_decimal *d, int prec,
inline
int my_decimal_set_zero(my_decimal *d)
{
- decimal_make_zero(((decimal*) d));
+ decimal_make_zero(((decimal_t*) d));
return 0;
}
@@ -181,7 +181,7 @@ int my_decimal_set_zero(my_decimal *d)
inline
bool my_decimal_is_zero(const my_decimal *decimal_value)
{
- return decimal_is_zero((decimal*) decimal_value);
+ return decimal_is_zero((decimal_t*) decimal_value);
}
@@ -189,7 +189,7 @@ inline
int my_decimal_round(uint mask, const my_decimal *from, int scale,
bool truncate, my_decimal *to)
{
- return check_result(mask, decimal_round((decimal*) from, to, scale,
+ return check_result(mask, decimal_round((decimal_t*) from, to, scale,
(truncate ? TRUNCATE : HALF_UP)));
}
@@ -197,14 +197,14 @@ int my_decimal_round(uint mask, const my_decimal *from, int scale,
inline
int my_decimal_floor(uint mask, const my_decimal *from, my_decimal *to)
{
- return check_result(mask, decimal_round((decimal*) from, to, 0, FLOOR));
+ return check_result(mask, decimal_round((decimal_t*) from, to, 0, FLOOR));
}
inline
int my_decimal_ceiling(uint mask, const my_decimal *from, my_decimal *to)
{
- return check_result(mask, decimal_round((decimal*) from, to, 0, CEILING));
+ return check_result(mask, decimal_round((decimal_t*) from, to, 0, CEILING));
}
@@ -219,7 +219,7 @@ int my_decimal2int(uint mask, const my_decimal *d, my_bool unsigned_flag,
{
my_decimal rounded;
/* decimal_round can return only E_DEC_TRUNCATED */
- decimal_round((decimal*)d, &rounded, 0, HALF_UP);
+ decimal_round((decimal_t*)d, &rounded, 0, HALF_UP);
return check_result(mask, (unsigned_flag ?
decimal2ulonglong(&rounded, (ulonglong *)l) :
decimal2longlong(&rounded, l)));
@@ -230,14 +230,14 @@ inline
int my_decimal2double(uint mask, const my_decimal *d, double *result)
{
/* No need to call check_result as this will always succeed */
- return decimal2double((decimal*) d, result);
+ return decimal2double((decimal_t*) d, result);
}
inline
int str2my_decimal(uint mask, const char *str, my_decimal *d, char **end)
{
- return check_result(mask, string2decimal(str, (decimal*) d, end));
+ return check_result(mask, string2decimal(str, (decimal_t*) d, end));
}
@@ -255,7 +255,7 @@ int string2my_decimal(uint mask, const String *str, my_decimal *d)
inline
int double2my_decimal(uint mask, double val, my_decimal *d)
{
- return check_result(mask, double2decimal(val, (decimal*) d));
+ return check_result(mask, double2decimal(val, (decimal_t*) d));
}
@@ -269,7 +269,7 @@ int int2my_decimal(uint mask, longlong i, my_bool unsigned_flag, my_decimal *d)
inline
-void my_decimal_neg(st_decimal *arg)
+void my_decimal_neg(decimal_t *arg)
{
decimal_neg(arg);
}
@@ -279,7 +279,7 @@ inline
int my_decimal_add(uint mask, my_decimal *res, const my_decimal *a,
const my_decimal *b)
{
- return check_result(mask, decimal_add((decimal*) a, (decimal*) b, res));
+ return check_result(mask, decimal_add((decimal_t*) a, (decimal_t*) b, res));
}
@@ -287,7 +287,7 @@ inline
int my_decimal_sub(uint mask, my_decimal *res, const my_decimal *a,
const my_decimal *b)
{
- return check_result(mask, decimal_sub((decimal*) a, (decimal*) b, res));
+ return check_result(mask, decimal_sub((decimal_t*) a, (decimal_t*) b, res));
}
@@ -295,7 +295,7 @@ inline
int my_decimal_mul(uint mask, my_decimal *res, const my_decimal *a,
const my_decimal *b)
{
- return check_result(mask, decimal_mul((decimal*) a, (decimal*) b, res));
+ return check_result(mask, decimal_mul((decimal_t*) a, (decimal_t*) b, res));
}
@@ -303,7 +303,7 @@ inline
int my_decimal_div(uint mask, my_decimal *res, const my_decimal *a,
const my_decimal *b, int div_scale_inc)
{
- return check_result(mask, decimal_div((decimal*) a, (decimal*) b, res,
+ return check_result(mask, decimal_div((decimal_t*) a, (decimal_t*) b, res,
div_scale_inc));
}
@@ -312,7 +312,7 @@ inline
int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
const my_decimal *b)
{
- return check_result(mask, decimal_mod((decimal*) a, (decimal*) b, res));
+ return check_result(mask, decimal_mod((decimal_t*) a, (decimal_t*) b, res));
}
@@ -320,14 +320,14 @@ int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
inline
int my_decimal_cmp(const my_decimal *a, const my_decimal *b)
{
- return decimal_cmp((decimal*) a, (decimal*) b);
+ return decimal_cmp((decimal_t*) a, (decimal_t*) b);
}
inline
void max_my_decimal(my_decimal *to, int precision, int frac)
{
DBUG_ASSERT(precision <= DECIMAL_MAX_LENGTH);
- max_decimal(precision, frac, (decimal*) to);
+ max_decimal(precision, frac, (decimal_t*) to);
}
#endif /*my_decimal_h*/
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 07bc235e2eb..950efc07efa 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -44,6 +44,13 @@ typedef ulonglong table_map; /* Used for table bits in join */
typedef Bitmap<64> key_map; /* Used for finding keys */
typedef ulong key_part_map; /* Used for finding key parts */
+/* query_id */
+typedef ulonglong query_id_t;
+extern query_id_t query_id;
+
+/* increment query_id and return it. */
+inline query_id_t next_query_id() { return query_id++; }
+
/* useful constants */
extern const key_map key_map_empty;
extern const key_map key_map_full;
@@ -257,6 +264,12 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
/* Flag set if setup_tables already done */
#define OPTION_SETUP_TABLES_DONE (1L << 30)
+/*
+ Maximum length of time zone name that we support
+ (Time zone name is char(64) in db). mysqlbinlog needs it.
+*/
+#define MAX_TIME_ZONE_NAME_LENGTH 72
+
/* The rest of the file is included in the server only */
#ifndef MYSQL_CLIENT
@@ -1141,6 +1154,7 @@ extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb;
extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
extern SHOW_COMP_OPTION have_crypt;
extern SHOW_COMP_OPTION have_compress;
+extern SHOW_COMP_OPTION have_blackhole_db;
#ifndef __WIN__
extern pthread_t signal_thread;
@@ -1299,14 +1313,6 @@ SQL_CRYPT *get_crypt_for_frm(void);
#include "sql_view.h"
-/* query_id */
-
-typedef ulonglong query_id_t;
-extern query_id_t query_id;
-
-/* increment query_id and return it. */
-inline query_id_t next_query_id() { return query_id++; }
-
/* Some inline functions for more speed */
inline bool add_item_to_list(THD *thd, Item *item)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 682fe8b9cac..bbef9ca6d26 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -419,6 +419,7 @@ SHOW_COMP_OPTION have_federated_db;
SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
SHOW_COMP_OPTION have_geometry, have_rtree_keys;
SHOW_COMP_OPTION have_crypt, have_compress;
+SHOW_COMP_OPTION have_blackhole_db;
/* Thread specific variables */
@@ -3137,8 +3138,17 @@ we force server id to 2, but this MySQL server will not act as a slave.");
#endif
if (opt_bootstrap) /* If running with bootstrap, do not start replication. */
opt_skip_slave_start= 1;
- /* init_slave() must be called after the thread keys are created */
- init_slave();
+ /*
+ init_slave() must be called after the thread keys are created.
+ Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other
+ places) assume that active_mi != 0, so let's fail if it's 0 (out of
+ memory); a message has already been printed.
+ */
+ if (init_slave() && !active_mi)
+ {
+ end_thr_alarm(1); // Don't allow alarms
+ unireg_abort(1);
+ }
if (opt_bootstrap)
{
@@ -3312,9 +3322,10 @@ default_service_handling(char **argv,
int main(int argc, char **argv)
{
- /* When several instances are running on the same machine, we
- need to have an unique named hEventShudown through the
- application PID e.g.: MySQLShutdown1890; MySQLShutdown2342
+ /*
+ When several instances are running on the same machine, we
+ need to have an unique named hEventShudown through the
+ application PID e.g.: MySQLShutdown1890; MySQLShutdown2342
*/
int10_to_str((int) GetCurrentProcessId(),strmov(shutdown_event_name,
"MySQLShutdown"), 10);
@@ -3893,10 +3904,19 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
char *suffix_pos;
char connect_number_char[22], *p;
const char *errmsg= 0;
+ SECURITY_ATTRIBUTES *sa_event= 0, *sa_mapping= 0;
my_thread_init();
DBUG_ENTER("handle_connections_shared_memorys");
DBUG_PRINT("general",("Waiting for allocated shared memory."));
+ if (my_security_attr_create(&sa_event, &errmsg,
+ GENERIC_ALL, SYNCHRONIZE | EVENT_MODIFY_STATE))
+ goto error;
+
+ if (my_security_attr_create(&sa_mapping, &errmsg,
+ GENERIC_ALL, FILE_MAP_READ | FILE_MAP_WRITE))
+ goto error;
+
/*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part
@@ -3906,22 +3926,22 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
*/
suffix_pos= strxmov(tmp,shared_memory_base_name,"_",NullS);
strmov(suffix_pos, "CONNECT_REQUEST");
- if ((smem_event_connect_request= CreateEvent(0,FALSE,FALSE,tmp)) == 0)
+ if ((smem_event_connect_request= CreateEvent(sa_event,
+ FALSE, FALSE, tmp)) == 0)
{
errmsg= "Could not create request event";
goto error;
}
strmov(suffix_pos, "CONNECT_ANSWER");
- if ((event_connect_answer= CreateEvent(0,FALSE,FALSE,tmp)) == 0)
+ if ((event_connect_answer= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0)
{
errmsg="Could not create answer event";
goto error;
}
strmov(suffix_pos, "CONNECT_DATA");
- if ((handle_connect_file_map= CreateFileMapping(INVALID_HANDLE_VALUE,0,
- PAGE_READWRITE,
- 0,sizeof(connect_number),
- tmp)) == 0)
+ if ((handle_connect_file_map=
+ CreateFileMapping(INVALID_HANDLE_VALUE, sa_mapping,
+ PAGE_READWRITE, 0, sizeof(connect_number), tmp)) == 0)
{
errmsg= "Could not create file mapping";
goto error;
@@ -3966,10 +3986,9 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
suffix_pos= strxmov(tmp,shared_memory_base_name,"_",connect_number_char,
"_",NullS);
strmov(suffix_pos, "DATA");
- if ((handle_client_file_map= CreateFileMapping(INVALID_HANDLE_VALUE,0,
- PAGE_READWRITE,0,
- smem_buffer_length,
- tmp)) == 0)
+ if ((handle_client_file_map=
+ CreateFileMapping(INVALID_HANDLE_VALUE, sa_mapping,
+ PAGE_READWRITE, 0, smem_buffer_length, tmp)) == 0)
{
errmsg= "Could not create file mapping";
goto errorconn;
@@ -3982,31 +4001,33 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
goto errorconn;
}
strmov(suffix_pos, "CLIENT_WROTE");
- if ((event_client_wrote= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
+ if ((event_client_wrote= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0)
{
errmsg= "Could not create client write event";
goto errorconn;
}
strmov(suffix_pos, "CLIENT_READ");
- if ((event_client_read= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
+ if ((event_client_read= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0)
{
errmsg= "Could not create client read event";
goto errorconn;
}
strmov(suffix_pos, "SERVER_READ");
- if ((event_server_read= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
+ if ((event_server_read= CreateEvent(sa_event, FALSE, FALSE, tmp)) == 0)
{
errmsg= "Could not create server read event";
goto errorconn;
}
strmov(suffix_pos, "SERVER_WROTE");
- if ((event_server_wrote= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
+ if ((event_server_wrote= CreateEvent(sa_event,
+ FALSE, FALSE, tmp)) == 0)
{
errmsg= "Could not create server write event";
goto errorconn;
}
strmov(suffix_pos, "CONNECTION_CLOSED");
- if ((event_conn_closed= CreateEvent(0, TRUE , FALSE, tmp)) == 0)
+ if ((event_conn_closed= CreateEvent(sa_event,
+ TRUE, FALSE, tmp)) == 0)
{
errmsg= "Could not create closed connection event";
goto errorconn;
@@ -4081,6 +4102,8 @@ error:
strxmov(buff, "Can't create shared memory service: ", errmsg, ".", NullS);
sql_perror(buff);
}
+ my_security_attr_free(sa_event);
+ my_security_attr_free(sa_mapping);
if (handle_connect_map) UnmapViewOfFile(handle_connect_map);
if (handle_connect_file_map) CloseHandle(handle_connect_file_map);
if (event_connect_answer) CloseHandle(event_connect_answer);
@@ -5226,7 +5249,7 @@ The minimum value for this variable is 4096.",
"Max number of errors/warnings to store for a statement.",
(gptr*) &global_system_variables.max_error_count,
(gptr*) &max_system_variables.max_error_count,
- 0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 1, 65535, 0, 1, 0},
+ 0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
"Don't allow creation of heap tables bigger than this.",
(gptr*) &global_system_variables.max_heap_table_size,
@@ -5690,7 +5713,8 @@ struct show_var_st status_vars[]= {
{"Select_range_check", (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
{"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
{"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG},
- {"Slave_running", (char*) 0, SHOW_SLAVE_RUNNING},
+ {"Slave_running", (char*) 0, SHOW_SLAVE_RUNNING},
+ {"Slave_retried_transactions",(char*) 0, SHOW_SLAVE_RETRIED_TRANS},
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
{"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
@@ -5948,6 +5972,11 @@ static void mysql_init_variables(void)
#else
have_archive_db= SHOW_OPTION_NO;
#endif
+#ifdef HAVE_BLACKHOLE_DB
+ have_blackhole_db= SHOW_OPTION_YES;
+#else
+ have_blackhole_db= SHOW_OPTION_NO;
+#endif
#ifdef HAVE_FEDERATED_DB
have_federated_db= SHOW_OPTION_YES;
#else
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index fe1780b92a7..44e2f5ee9f2 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1407,6 +1407,7 @@ public:
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); }
+ static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* Never called */ }
};
class TRP_ROR_INTERSECT;
@@ -3606,10 +3607,10 @@ static SEL_ARG *
get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
Item_func::Functype type,Item *value)
{
- uint maybe_null=(uint) field->real_maybe_null(), copies;
+ uint maybe_null=(uint) field->real_maybe_null();
bool optimize_range;
SEL_ARG *tree;
- char *str, *str2;
+ char *str;
DBUG_ENTER("get_mm_leaf");
if (!value) // IS NULL or IS NOT NULL
@@ -3744,39 +3745,13 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
/* This happens when we try to insert a NULL field in a not null column */
DBUG_RETURN(&null_element); // cmp with NULL is never TRUE
}
- /* Get local copy of key */
- copies= 1;
- if (field->key_type() == HA_KEYTYPE_VARTEXT1 ||
- field->key_type() == HA_KEYTYPE_VARTEXT2)
- copies= 2;
- str= str2= (char*) alloc_root(param->mem_root,
- (key_part->store_length)*copies+1);
+ str= (char*) alloc_root(param->mem_root, key_part->store_length+1);
if (!str)
DBUG_RETURN(0);
if (maybe_null)
*str= (char) field->is_real_null(); // Set to 1 if null
field->get_key_image(str+maybe_null, key_part->length, key_part->image_type);
- if (copies == 2)
- {
- /*
- The key is stored as 2 byte length + key
- key doesn't match end space. In other words, a key 'X ' should match
- all rows between 'X' and 'X ...'
- */
- uint length= uint2korr(str+maybe_null);
- str2= str+ key_part->store_length;
- /* remove end space */
- while (length > 0 && str[length+HA_KEY_BLOB_LENGTH+maybe_null-1] == ' ')
- length--;
- int2store(str+maybe_null, length);
- /* Create key that is space filled */
- memcpy(str2, str, length + HA_KEY_BLOB_LENGTH + maybe_null);
- my_fill_8bit(field->charset(),
- str2+ length+ HA_KEY_BLOB_LENGTH +maybe_null,
- key_part->length-length, ' ');
- int2store(str2+maybe_null, key_part->length);
- }
- if (!(tree=new SEL_ARG(field,str,str2)))
+ if (!(tree=new SEL_ARG(field,str,str)))
DBUG_RETURN(0); // out of memory
switch (type) {
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 23dbb22399b..457df3f2947 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -767,6 +767,7 @@ struct show_var_st init_vars[]= {
{sys_group_concat_max_len.name, (char*) &sys_group_concat_max_len, SHOW_SYS},
{"have_archive", (char*) &have_archive_db, SHOW_HAVE},
{"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE},
+ {"have_blackhole_engine", (char*) &have_blackhole_db, SHOW_HAVE},
{"have_compress", (char*) &have_compress, SHOW_HAVE},
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
@@ -2095,27 +2096,6 @@ void sys_var_character_set_server::set_default(THD *thd, enum_var_type type)
}
}
-#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50003)
-bool sys_var_character_set_server::check(THD *thd, set_var *var)
-{
- /*
- To be perfect we should fail even if we are a 5.0.3 slave, a 4.1 master,
- and user wants to change our global character set variables. Because
- replicating a 4.1 assumes those are not changed. But that's not easy to
- do.
- */
- if ((var->type == OPT_GLOBAL) &&
- (mysql_bin_log.is_open() ||
- active_mi->slave_running || active_mi->rli.slave_running))
- {
- my_error(ER_LOGGING_PROHIBIT_CHANGING_OF, MYF(0),
- "character set, collation");
- return 1;
- }
- return sys_var_character_set::check(thd,var);
-}
-#endif
-
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
enum_var_type type)
{
@@ -2208,20 +2188,6 @@ void sys_var_collation_database::set_default(THD *thd, enum_var_type type)
}
}
-#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50003)
-bool sys_var_collation_server::check(THD *thd, set_var *var)
-{
- if ((var->type == OPT_GLOBAL) &&
- (mysql_bin_log.is_open() ||
- active_mi->slave_running || active_mi->rli.slave_running))
- {
- my_error(ER_LOGGING_PROHIBIT_CHANGING_OF, MYF(0),
- "character set, collation");
- return 1;
- }
- return sys_var_collation::check(thd,var);
-}
-#endif
bool sys_var_collation_server::update(THD *thd, set_var *var)
{
@@ -2560,16 +2526,6 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
String str(buff, sizeof(buff), &my_charset_latin1);
String *res= var->value->val_str(&str);
-#if defined(HAVE_REPLICATION)
- if ((var->type == OPT_GLOBAL) &&
- (mysql_bin_log.is_open() ||
- active_mi->slave_running || active_mi->rli.slave_running))
- {
- my_error(ER_LOGGING_PROHIBIT_CHANGING_OF, MYF(0), "time zone");
- return 1;
- }
-#endif
-
if (!(var->save_result.time_zone=
my_tz_find(res, thd->lex->time_zone_tables_used)))
{
@@ -2605,7 +2561,18 @@ byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
if (type == OPT_GLOBAL)
return (byte *)(global_system_variables.time_zone->get_name()->ptr());
else
+ {
+ /*
+ This is an ugly fix for replication: we don't replicate properly queries
+ invoking system variables' values to update tables; but
+ CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
+ replicable (i.e. we tell the binlog code to store the session
+ timezone). If it's the global value which was used we can't replicate
+ (binlog code stores session value only).
+ */
+ thd->time_zone_used= 1;
return (byte *)(thd->variables.time_zone->get_name()->ptr());
+ }
}
@@ -2652,7 +2619,7 @@ bool sys_var_max_user_conn::update(THD *thd, set_var *var)
{
DBUG_ASSERT(var->type == OPT_GLOBAL);
pthread_mutex_lock(&LOCK_global_system_variables);
- max_user_connections= var->save_result.ulonglong_value;
+ max_user_connections= (uint)var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
return 0;
}
diff --git a/sql/set_var.h b/sql/set_var.h
index d78c228c142..585f6df3547 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -565,9 +565,6 @@ class sys_var_character_set_server :public sys_var_character_set
public:
sys_var_character_set_server(const char *name_arg) :
sys_var_character_set(name_arg) {}
-#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50003)
- bool check(THD *thd, set_var *var);
-#endif
void set_default(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
};
@@ -603,9 +600,6 @@ class sys_var_collation_server :public sys_var_collation
{
public:
sys_var_collation_server(const char *name_arg) :sys_var_collation(name_arg) {}
-#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50003)
- bool check(THD *thd, set_var *var);
-#endif
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index d4caeebb70c..71e4640e88b 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -1774,7 +1774,7 @@ ER_TOO_BIG_FIELDLENGTH 42000 S1009
cze "P-Bøíli¹ velká délka sloupce '%-.64s' (nejvíce %d). Pou¾ijte BLOB"
dan "For stor feltlængde for kolonne '%-.64s' (maks = %d). Brug BLOB i stedet"
nla "Te grote kolomlengte voor '%-.64s' (max = %d). Maak hiervoor gebruik van het type BLOB"
- eng "Column length too big for column '%-.64s' (max = %d); use BLOB instead"
+ eng "Column length too big for column '%-.64s' (max = %d); use BLOB or TEXT instead"
jps "column '%-.64s' ‚Í,Šm•Û‚·‚é column ‚Ì‘å‚«‚³‚ª‘½‚·‚¬‚Ü‚·. (Å‘å %d ‚Ü‚Å). BLOB ‚ð‚©‚í‚è‚ÉŽg—p‚µ‚Ä‚­‚¾‚³‚¢.",
est "Tulba '%-.64s' pikkus on liiga pikk (maksimaalne pikkus: %d). Kasuta BLOB väljatüüpi"
fre "Champ '%-.64s' trop long (max = %d). Utilisez un BLOB"
@@ -1789,7 +1789,7 @@ ER_TOO_BIG_FIELDLENGTH 42000 S1009
pol "Zbyt du¿a d³ugo?æ kolumny '%-.64s' (maks. = %d). W zamian u¿yj typu BLOB"
por "Comprimento da coluna '%-.64s' grande demais (max = %d); use BLOB em seu lugar"
rum "Lungimea coloanei '%-.64s' este prea lunga (maximum = %d). Foloseste BLOB mai bine"
- rus "óÌÉÛËÏÍ ÂÏÌØÛÁÑ ÄÌÉÎÁ ÓÔÏÌÂÃÁ '%-.64s' (ÍÁËÓÉÍÕÍ = %d). éÓÐÏÌØÚÕÊÔÅ ÔÉÐ BLOB ×ÍÅÓÔÏ ÔÅËÕÝÅÇÏ"
+ rus "óÌÉÛËÏÍ ÂÏÌØÛÁÑ ÄÌÉÎÁ ÓÔÏÌÂÃÁ '%-.64s' (ÍÁËÓÉÍÕÍ = %d). éÓÐÏÌØÚÕÊÔÅ ÔÉÐ BLOB ÉÌÉ TEXT ×ÍÅÓÔÏ ÔÅËÕÝÅÇÏ"
serbian "Previše podataka za kolonu '%-.64s' (maksimum je %d). Upotrebite BLOB polje"
slo "Príli¹ veµká då¾ka pre pole '%-.64s' (maximum = %d). Pou¾ite BLOB"
spa "Longitud de columna demasiado grande para la columna '%-.64s' (maximo = %d).Usar BLOB en su lugar"
@@ -4637,7 +4637,7 @@ ER_USER_LIMIT_REACHED 42000
rus "ðÏÌØÚÏ×ÁÔÅÌØ '%-.64s' ÐÒÅ×ÙÓÉÌ ÉÓÐÏÌØÚÏ×ÁÎÉÅ ÒÅÓÕÒÓÁ '%s' (ÔÅËÕÝÅÅ ÚÎÁÞÅÎÉÅ: %ld)"
spa "Usuario '%-.64s' ha excedido el recurso '%s' (actual valor: %ld)"
swe "Användare '%-.64s' har överskridit '%s' (nuvarande värde: %ld)"
-ER_SPECIFIC_ACCESS_DENIED_ERROR
+ER_SPECIFIC_ACCESS_DENIED_ERROR 42000
nla "Toegang geweigerd. U moet het %-.128s privilege hebben voor deze operatie"
eng "Access denied; you need the %-.128s privilege for this operation"
ger "Befehl nicht zulässig. Hierfür wird die Berechtigung %-.128s benötigt"
@@ -5094,7 +5094,7 @@ ER_SP_BADSELECT 0A000
ER_SP_BADRETURN 42000
eng "RETURN is only allowed in a FUNCTION"
ER_SP_BADSTATEMENT 0A000
- eng "LOCK and UNLOCK tables are not allowed in stored procedures"
+ eng "%s is not allowed in stored procedures"
ER_UPDATE_LOG_DEPRECATED_IGNORED 42000
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been ignored"
ER_UPDATE_LOG_DEPRECATED_TRANSLATED 42000
@@ -5332,3 +5332,7 @@ ER_STARTUP
eng "%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d %s"
ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR
eng "Can't load value from file with fixed size rows to variable"
+ER_CANT_CREATE_USER_WITH_GRANT 42000
+ eng "You are not allowed to create a user with GRANT"
+ER_WRONG_VALUE_FOR_TYPE
+ eng "Incorrect %-.32s value: '%-.128s' for function %-.32s"
diff --git a/sql/slave.cc b/sql/slave.cc
index 838efae6d11..28801d8ea6e 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -28,6 +28,7 @@
#include <my_dir.h>
#include <sql_common.h>
+#define MAX_SLAVE_RETRY_PAUSE 5
bool use_slave_mask = 0;
MY_BITMAP slave_error_mask;
@@ -1137,11 +1138,10 @@ be equal for replication to work";
such check will broke everything for them. (And now everything will
work for them because by default both their master and slave will have
'SYSTEM' time zone).
-
- TODO: when the new replication of timezones is sorted out with Dmitri,
- change >= '4' to == '4'.
+ This check is only necessary for 4.x masters (and < 5.0.4 masters but
+ those were alpha).
*/
- if ((*mysql->server_version >= '4') &&
+ if ((*mysql->server_version == '4') &&
!mysql_real_query(mysql, "SELECT @@GLOBAL.TIME_ZONE", 25) &&
(master_res= mysql_store_result(mysql)))
{
@@ -2163,7 +2163,7 @@ st_relay_log_info::st_relay_log_info()
ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0),
abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0),
inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
- until_log_pos(0)
+ until_log_pos(0), retried_trans(0)
{
group_relay_log_name[0]= event_relay_log_name[0]=
group_master_log_name[0]= 0;
@@ -2404,6 +2404,18 @@ void set_slave_thread_options(THD* thd)
thd->variables.completion_type= 0;
}
+void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli)
+{
+ thd->variables.character_set_client=
+ global_system_variables.character_set_client;
+ thd->variables.collation_connection=
+ global_system_variables.collation_connection;
+ thd->variables.collation_server=
+ global_system_variables.collation_server;
+ thd->update_charset();
+ rli->cached_charset_invalidate();
+}
+
/*
init_slave_thread()
*/
@@ -2884,9 +2896,8 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
init_master_info()).
b) init_relay_log_pos(), because the BEGIN may be an older relay log.
*/
- if (rli->trans_retries--)
+ if (rli->trans_retries < slave_trans_retries)
{
- sql_print_information("Slave SQL thread retries transaction");
if (init_master_info(rli->mi, 0, 0, 0, SLAVE_SQL))
sql_print_error("Failed to initialize the master info structure");
else if (init_relay_log_pos(rli,
@@ -2898,8 +2909,16 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
else
{
exec_res= 0;
- sleep(2); // chance for concurrent connection to get more locks
- }
+ /* chance for concurrent connection to get more locks */
+ safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
+ (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
+ pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
+ rli->trans_retries++;
+ rli->retried_trans++;
+ pthread_mutex_unlock(&rli->data_lock);
+ DBUG_PRINT("info", ("Slave retries transaction "
+ "rli->trans_retries: %lu", rli->trans_retries));
+ }
}
else
sql_print_error("Slave SQL thread retried transaction %lu time(s) "
@@ -2908,8 +2927,8 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
slave_trans_retries);
}
if (!((thd->options & OPTION_BEGIN) && opt_using_transactions))
- rli->trans_retries= slave_trans_retries; // restart from fresh
- }
+ rli->trans_retries= 0; // restart from fresh
+ }
return exec_res;
}
else
@@ -3324,7 +3343,7 @@ slave_begin:
pthread_mutex_lock(&rli->log_space_lock);
rli->ignore_log_space_limit= 0;
pthread_mutex_unlock(&rli->log_space_lock);
- rli->trans_retries= slave_trans_retries; // start from "no error"
+ rli->trans_retries= 0; // start from "no error"
if (init_relay_log_pos(rli,
rli->group_relay_log_name,
diff --git a/sql/slave.h b/sql/slave.h
index 61cd5490b90..ead1aa87ce6 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -295,7 +295,14 @@ typedef struct st_relay_log_info
} until_log_names_cmp_result;
char cached_charset[6];
- ulong trans_retries;
+ /*
+ trans_retries varies between 0 to slave_transaction_retries and counts how
+ many times the slave has retried the present transaction; gets reset to 0
+ when the transaction finally succeeds. retried_trans is a cumulative
+ counter: how many times the slave has retried a transaction (any) since
+ slave started.
+ */
+ ulong trans_retries, retried_trans;
st_relay_log_info();
~st_relay_log_info();
@@ -537,6 +544,7 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos,
int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
const char** errmsg);
void set_slave_thread_options(THD* thd);
+void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli);
void rotate_relay_log(MASTER_INFO* mi);
extern "C" pthread_handler_decl(handle_slave_io,arg);
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 037ef0b70ca..89c4b2dbaac 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -58,7 +58,6 @@ sp_multi_results_command(enum enum_sql_command cmd)
{
switch (cmd) {
case SQLCOM_ANALYZE:
- case SQLCOM_CHECK:
case SQLCOM_CHECKSUM:
case SQLCOM_HA_READ:
case SQLCOM_SHOW_BINLOGS:
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 3e6aba32feb..e72d78a6ac8 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -238,7 +238,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
DBUG_PRINT("info",("user table fields: %d, password length: %d",
table->s->fields, table->field[2]->field_length));
-
+
pthread_mutex_lock(&LOCK_global_system_variables);
if (table->field[2]->field_length < SCRAMBLED_PASSWORD_CHAR_LENGTH)
{
@@ -322,6 +322,12 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
if (table->s->fields <= 33 && (user.access & ALTER_ACL))
user.access|= ALTER_PROC_ACL;
+ /*
+ pre 5.0.3 did not have CREATE_USER_ACL
+ */
+ if (table->s->fields <= 36 && (user.access & GRANT_ACL))
+ user.access|= CREATE_USER_ACL;
+
user.sort= get_sort(2,user.host.hostname,user.user);
user.hostname_length= (user.host.hostname ?
(uint) strlen(user.host.hostname) : 0);
@@ -1090,6 +1096,9 @@ static void acl_insert_db(const char *user, const char *host, const char *db,
/*
Get privilege for a host, user and db combination
+
+ as db_is_pattern changes the semantics of comparison,
+ acl_cache is not used if db_is_pattern is set.
*/
ulong acl_get(const char *host, const char *ip,
@@ -1109,7 +1118,7 @@ ulong acl_get(const char *host, const char *ip,
db=tmp_db;
}
key_length=(uint) (end-key);
- if ((entry=(acl_entry*) acl_cache->search(key,key_length)))
+ if (!db_is_pattern && (entry=(acl_entry*) acl_cache->search(key,key_length)))
{
db_access=entry->access;
VOID(pthread_mutex_unlock(&acl_cache->lock));
@@ -1158,7 +1167,8 @@ ulong acl_get(const char *host, const char *ip,
}
exit:
/* Save entry in cache for quick retrieval */
- if ((entry= (acl_entry*) malloc(sizeof(acl_entry)+key_length)))
+ if (!db_is_pattern &&
+ (entry= (acl_entry*) malloc(sizeof(acl_entry)+key_length)))
{
entry->access=(db_access & host_access);
entry->length=key_length;
@@ -1540,18 +1550,26 @@ end:
}
-/* Return 1 if we are allowed to create new users */
+/*
+ Return 1 if we are allowed to create new users
+ the logic here is: INSERT_ACL is sufficient.
+ It's also a requirement in opt_safe_user_create,
+ otherwise CREATE_USER_ACL is enough.
+*/
static bool test_if_create_new_users(THD *thd)
{
- bool create_new_users=1; // Assume that we are allowed to create new users
- if (opt_safe_user_create && !(thd->master_access & INSERT_ACL))
+ bool create_new_users= test(thd->master_access & INSERT_ACL) ||
+ (!opt_safe_user_create &&
+ test(thd->master_access & CREATE_USER_ACL));
+ if (!create_new_users)
{
TABLE_LIST tl;
ulong db_access;
bzero((char*) &tl,sizeof(tl));
tl.db= (char*) "mysql";
tl.table_name= (char*) "user";
+ create_new_users= 1;
db_access=acl_get(thd->host, thd->ip,
thd->priv_user, tl.db, 0);
@@ -1571,7 +1589,7 @@ static bool test_if_create_new_users(THD *thd)
static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
ulong rights, bool revoke_grant,
- bool create_user)
+ bool can_create_user, bool no_auto_create)
{
int error = -1;
bool old_row_exists=0;
@@ -1613,8 +1631,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
goto end;
}
/*
- There are four options which affect the process of creation of
- a new user(mysqld option --safe-create-user, 'insert' privilege
+ There are four options which affect the process of creation of
+ a new user (mysqld option --safe-create-user, 'insert' privilege
on 'mysql.user' table, using 'GRANT' with 'IDENTIFIED BY' and
SQL_MODE flag NO_AUTO_CREATE_USER). Below is the simplified rule
how it should work.
@@ -1622,11 +1640,17 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
else if (identified_by) => create
else if (no_auto_create_user) => reject
else create
+
+ see also test_if_create_new_users()
*/
- else if (((thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER) &&
- !password_len) || !create_user)
+ else if (!password_len && no_auto_create)
+ {
+ my_error(ER_PASSWORD_NO_MATCH, MYF(0), combo.user.str, combo.host.str);
+ goto end;
+ }
+ else if (!can_create_user)
{
- my_error(ER_NO_PERMISSION_TO_CREATE_USER, MYF(0),
+ my_error(ER_CANT_CREATE_USER_WITH_GRANT, MYF(0),
thd->user, thd->host_or_ip);
goto end;
}
@@ -2707,7 +2731,9 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
/* Create user if needed */
pthread_mutex_lock(&acl_cache->lock);
error=replace_user_table(thd, tables[0].table, *Str,
- 0, revoke_grant, create_new_users);
+ 0, revoke_grant, create_new_users,
+ test(thd->variables.sql_mode &
+ MODE_NO_AUTO_CREATE_USER));
pthread_mutex_unlock(&acl_cache->lock);
if (error)
{
@@ -2912,7 +2938,9 @@ bool mysql_procedure_grant(THD *thd, TABLE_LIST *table_list,
/* Create user if needed */
pthread_mutex_lock(&acl_cache->lock);
error=replace_user_table(thd, tables[0].table, *Str,
- 0, revoke_grant, create_new_users);
+ 0, revoke_grant, create_new_users,
+ test(thd->variables.sql_mode &
+ MODE_NO_AUTO_CREATE_USER));
pthread_mutex_unlock(&acl_cache->lock);
if (error)
{
@@ -2924,7 +2952,7 @@ bool mysql_procedure_grant(THD *thd, TABLE_LIST *table_list,
table_name= table_list->table_name;
grant_name= proc_hash_search(Str->host.str, NullS, db_name,
- Str->user.str, table_name, 1);
+ Str->user.str, table_name, 1);
if (!grant_name)
{
if (revoke_grant)
@@ -2945,7 +2973,7 @@ bool mysql_procedure_grant(THD *thd, TABLE_LIST *table_list,
}
my_hash_insert(&proc_priv_hash,(byte*) grant_name);
}
-
+
if (replace_proc_table(thd, grant_name, tables[1].table, *Str,
db_name, table_name, rights, revoke_grant))
{
@@ -3036,11 +3064,10 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
result= -1;
continue;
}
- if ((replace_user_table(thd,
- tables[0].table,
- *Str,
- (!db ? rights : 0), revoke_grant,
- create_new_users)))
+ if (replace_user_table(thd, tables[0].table, *Str,
+ (!db ? rights : 0), revoke_grant, create_new_users,
+ test(thd->variables.sql_mode &
+ MODE_NO_AUTO_CREATE_USER)))
result= -1;
else if (db)
{
@@ -3687,11 +3714,13 @@ static const char *command_array[]=
"ALTER", "SHOW DATABASES", "SUPER", "CREATE TEMPORARY TABLES",
"LOCK TABLES", "EXECUTE", "REPLICATION SLAVE", "REPLICATION CLIENT",
"CREATE VIEW", "SHOW VIEW", "CREATE ROUTINE", "ALTER ROUTINE",
+ "CREATE USER"
};
static uint command_lengths[]=
{
- 6, 6, 6, 6, 6, 4, 6, 8, 7, 4, 5, 10, 5, 5, 14, 5, 23, 11, 7, 17, 18, 11, 9, 14, 13
+ 6, 6, 6, 6, 6, 4, 6, 8, 7, 4, 5, 10, 5, 5, 14, 5, 23, 11, 7, 17, 18, 11, 9,
+ 14, 13, 11
};
@@ -4807,13 +4836,11 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
}
sql_mode= thd->variables.sql_mode;
- thd->variables.sql_mode&= ~MODE_NO_AUTO_CREATE_USER;
- if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1))
+ if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
{
append_user(&wrong_users, user_name);
result= TRUE;
}
- thd->variables.sql_mode= sql_mode;
}
VOID(pthread_mutex_unlock(&acl_cache->lock));
@@ -4969,7 +4996,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
}
if (replace_user_table(thd, tables[0].table,
- *lex_user, ~0, 1, 0))
+ *lex_user, ~0, 1, 0, 0))
{
result= -1;
continue;
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index 7833e9ea9bb..2bc7c45907c 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -41,12 +41,17 @@
#define SHOW_VIEW_ACL (1L << 22)
#define CREATE_PROC_ACL (1L << 23)
#define ALTER_PROC_ACL (1L << 24)
+#define CREATE_USER_ACL (1L << 25)
/*
don't forget to update
- static struct show_privileges_st sys_privileges[]
- in sql_show.cc when adding new privileges!
+ 1. static struct show_privileges_st sys_privileges[]
+ 2. static const char *command_array[] and static uint command_lengths[]
+ 3. mysql_create_system_tables.sh, mysql_fix_privilege_tables.sql
+ 4. acl_init() or whatever - to define behaviour for old privilege tables
+ 5. sql_yacc.yy - for GRANT/REVOKE to work
*/
-
+#define EXTRA_ACL (1L << 29)
+#define NO_ACCESS (1L << 30)
#define DB_ACLS \
(UPDATE_ACL | SELECT_ACL | INSERT_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \
GRANT_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL | \
@@ -73,10 +78,7 @@
REFERENCES_ACL | INDEX_ACL | ALTER_ACL | SHOW_DB_ACL | SUPER_ACL | \
CREATE_TMP_ACL | LOCK_TABLES_ACL | REPL_SLAVE_ACL | REPL_CLIENT_ACL | \
EXECUTE_ACL | CREATE_VIEW_ACL | SHOW_VIEW_ACL | CREATE_PROC_ACL | \
- ALTER_PROC_ACL )
-
-#define EXTRA_ACL (1L << 29)
-#define NO_ACCESS (1L << 30)
+ ALTER_PROC_ACL | CREATE_USER_ACL)
#define DEFAULT_CREATE_PROC_ACLS \
(ALTER_PROC_ACL | EXECUTE_ACL)
@@ -86,25 +88,21 @@
This is needed as the 'host' and 'db' table is missing a few privileges
*/
-/* Continius bit-segments that needs to be shifted */
-#define DB_REL1 ((1L << 6) | (1L << 7) | (1L << 8) | (1L << 9))
-#define DB_REL2 ((1L << 10) | (1L << 11))
-#define DB_REL3 ((1L << 12) | (1L << 13) | (1L << 14) | (1L << 15))
-#define DB_REL4 ((1L << 16))
-
/* Privileges that needs to be reallocated (in continous chunks) */
+#define DB_CHUNK0 (SELECT_ACL | INSERT_ACL | UPDATE_ACL | DELETE_ACL | \
+ CREATE_ACL | DROP_ACL)
#define DB_CHUNK1 (GRANT_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL)
#define DB_CHUNK2 (CREATE_TMP_ACL | LOCK_TABLES_ACL)
#define DB_CHUNK3 (CREATE_VIEW_ACL | SHOW_VIEW_ACL | \
CREATE_PROC_ACL | ALTER_PROC_ACL )
#define DB_CHUNK4 (EXECUTE_ACL)
-#define fix_rights_for_db(A) (((A) & 63) | \
- (((A) & DB_REL1) << 4) | \
- (((A) & DB_REL2) << 6) | \
- (((A) & DB_REL3) << 9) | \
- (((A) & DB_REL4) << 2))
-#define get_rights_for_db(A) (((A) & 63) | \
+#define fix_rights_for_db(A) (((A) & DB_CHUNK0) | \
+ (((A) << 4) & DB_CHUNK1) | \
+ (((A) << 6) & DB_CHUNK2) | \
+ (((A) << 9) & DB_CHUNK3) | \
+ (((A) << 2) & DB_CHUNK4))
+#define get_rights_for_db(A) (((A) & DB_CHUNK0) | \
(((A) & DB_CHUNK1) >> 4) | \
(((A) & DB_CHUNK2) >> 6) | \
(((A) & DB_CHUNK3) >> 9) | \
@@ -191,8 +189,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
bool mysql_procedure_grant(THD *thd, TABLE_LIST *table,
List <LEX_USER> &user_list, ulong rights,
bool revoke, bool no_error);
-ACL_USER *check_acl_user(LEX_USER *user_name,
- uint *acl_acl_userdx);
+ACL_USER *check_acl_user(LEX_USER *user_name, uint *acl_acl_userdx);
my_bool grant_init(THD *thd);
void grant_free(void);
void grant_reload(THD *thd);
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 5fa161257c7..4a4f61f985c 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2225,7 +2225,6 @@ my_bool Query_cache::register_all_tables(Query_cache_block *block,
n= register_tables_from_list(tables_used, 0, block_table);
-err:
if (n)
{
DBUG_PRINT("qcache", ("failed at table %d", (int) n));
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 5fb91d9c1a4..cf7240e4dba 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -193,6 +193,7 @@ THD::THD()
variables.pseudo_thread_id= 0;
one_shot_set= 0;
file_id = 0;
+ query_id= 0;
warn_id= 0;
db_charset= global_system_variables.collation_database;
bzero(ha_data, sizeof(ha_data));
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 469eb86803a..c32c79e8108 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1169,8 +1169,8 @@ public:
from table are necessary for this select, to check if it's necessary to
update auto-updatable fields (like auto_increment and timestamp).
*/
- ulong query_id;
- ulong warn_id, version, options, thread_id, col_access;
+ query_id_t query_id, warn_id;
+ ulong version, options, thread_id, col_access;
/* Statement id is thread-wide. This counter is used to generate ids */
ulong statement_id_counter;
@@ -1798,7 +1798,8 @@ class user_var_entry
public:
LEX_STRING name;
char *value;
- ulong length, update_query_id, used_query_id;
+ ulong length;
+ query_id_t update_query_id, used_query_id;
Item_result type;
double val_real(my_bool *null_value);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 8a0ed1d5b87..1f345a28d2c 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -875,12 +875,13 @@ err:
static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error)
{
- char tmp_path[FN_REFLEN], tmp2_path[FN_REFLEN], *pos;
+ char tmp_path[FN_REFLEN], *pos;
char *path= tmp_path;
DBUG_ENTER("rm_dir_w_symlink");
unpack_filename(tmp_path, org_path);
#ifdef HAVE_READLINK
int error;
+ char tmp2_path[FN_REFLEN];
/* Remove end FN_LIBCHAR as this causes problem on Linux in readlink */
pos= strend(path);
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index eb7b3e8a319..45718e7c7da 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -115,7 +115,7 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
DBUG_RETURN(1); // out of memory
// st_select_lex_unit::prepare correctly work for single select
- if ((res= unit->prepare(thd, derived_result, 0)))
+ if ((res= unit->prepare(thd, derived_result, 0, orig_table_list->alias)))
goto exit;
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index fa3e2070a28..3c8e8e55c1f 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -763,7 +763,6 @@ bool mysqld_help(THD *thd, const char *mask)
}
send_eof(thd);
-end:
DBUG_RETURN(FALSE);
error:
DBUG_RETURN(TRUE);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e2ab7ea12c5..691c7c1a98b 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -31,7 +31,7 @@ static void end_delayed_insert(THD *thd);
extern "C" pthread_handler_decl(handle_delayed_insert,arg);
static void unlink_blobs(register TABLE *table);
#endif
-static bool check_view_insertability(TABLE_LIST *view, ulong query_id);
+static bool check_view_insertability(TABLE_LIST *view, query_id_t query_id);
/* Define to force use of my_malloc() if the allocated memory block is big */
@@ -538,7 +538,7 @@ abort:
TRUE - can't be used for insert
*/
-static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
+static bool check_view_insertability(TABLE_LIST *view, query_id_t query_id)
{
uint num= view->view->select_lex.item_list.elements;
TABLE *table= view->table;
@@ -546,7 +546,7 @@ static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
*trans_end= trans_start + num;
Field_translator *trans;
Field **field_ptr= table->field;
- ulong other_query_id= query_id - 1;
+ query_id_t other_query_id= query_id - 1;
DBUG_ENTER("check_key_in_view");
DBUG_ASSERT(view->table != 0 && view->field_translation != 0);
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index afd48943439..2391c0b7ef9 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -436,7 +436,8 @@ public:
void exclude_tree();
/* UNION methods */
- bool prepare(THD *thd, select_result *result, ulong additional_options);
+ bool prepare(THD *thd, select_result *result, ulong additional_options,
+ const char *tmp_table_alias);
bool exec();
bool cleanup();
inline void unclean() { cleaned= 0; }
@@ -892,6 +893,8 @@ struct st_lex_local: public st_lex
}
static void operator delete(void *ptr,size_t size)
{ TRASH(ptr, size); }
+ static void operator delete(void *ptr, MEM_ROOT *mem_root)
+ { /* Never called */ }
};
void lex_init(void);
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index e2f7c9d62c8..a0fed715405 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -81,6 +81,9 @@ static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &set_values, READ_INFO &read_info,
String &enclosed, ulong skip_lines,
bool ignore_check_option_errors);
+static bool write_execute_load_query_log_event(THD *thd,
+ bool duplicates, bool ignore,
+ bool transactional_table);
/*
@@ -413,8 +416,14 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
/* If the file was not empty, wrote_create_file is true */
if (lf_info.wrote_create_file)
{
- Delete_file_log_event d(thd, db, transactional_table);
- mysql_bin_log.write(&d);
+ if ((info.copied || info.deleted) && !transactional_table)
+ write_execute_load_query_log_event(thd, handle_duplicates,
+ ignore, transactional_table);
+ else
+ {
+ Delete_file_log_event d(thd, db, transactional_table);
+ mysql_bin_log.write(&d);
+ }
}
}
#endif /*!EMBEDDED_LIBRARY*/
@@ -437,16 +446,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
*/
read_info.end_io_cache();
if (lf_info.wrote_create_file)
- {
- Execute_load_query_log_event e(thd, thd->query, thd->query_length,
- (char*)thd->lex->fname_start - (char*)thd->query,
- (char*)thd->lex->fname_end - (char*)thd->query,
- (handle_duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
- (ignore ? LOAD_DUP_IGNORE :
- LOAD_DUP_ERROR),
- transactional_table, FALSE);
- mysql_bin_log.write(&e);
- }
+ write_execute_load_query_log_event(thd, handle_duplicates,
+ ignore, transactional_table);
}
#endif /*!EMBEDDED_LIBRARY*/
if (transactional_table)
@@ -462,6 +463,23 @@ err:
DBUG_RETURN(error);
}
+
+/* Not a very useful function; just to avoid duplication of code */
+static bool write_execute_load_query_log_event(THD *thd,
+ bool duplicates, bool ignore,
+ bool transactional_table)
+{
+ Execute_load_query_log_event
+ e(thd, thd->query, thd->query_length,
+ (char*)thd->lex->fname_start - (char*)thd->query,
+ (char*)thd->lex->fname_end - (char*)thd->query,
+ (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
+ (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
+ transactional_table, FALSE);
+ return mysql_bin_log.write(&e);
+}
+
+
/****************************************************************************
** Read of rows of fixed size + optional garage + optonal newline
****************************************************************************/
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 981013479df..606286bfbc0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -28,7 +28,6 @@
#include "sp_head.h"
#include "sp.h"
-#include "sp_cache.h"
#ifdef HAVE_OPENSSL
/*
@@ -3049,7 +3048,6 @@ unsent_create_error:
goto error; /* purecov: inspected */
thd->slow_command=TRUE;
res = mysql_check_table(thd, first_table, &lex->check_opt);
- sp_cache_invalidate();
break;
}
case SQLCOM_ANALYZE:
@@ -3564,7 +3562,8 @@ unsent_create_error:
#ifndef NO_EMBEDDED_ACCESS_CHECKS
case SQLCOM_CREATE_USER:
{
- if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
+ if (check_access(thd, INSERT_ACL, "mysql", 0, 1, 1) &&
+ check_global_access(thd,CREATE_USER_ACL))
break;
if (!(res= mysql_create_user(thd, lex->users_list)))
{
@@ -3579,7 +3578,8 @@ unsent_create_error:
}
case SQLCOM_DROP_USER:
{
- if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
+ if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 1) &&
+ check_global_access(thd,CREATE_USER_ACL))
break;
if (!(res= mysql_drop_user(thd, lex->users_list)))
{
@@ -3594,7 +3594,8 @@ unsent_create_error:
}
case SQLCOM_RENAME_USER:
{
- if (check_access(thd, GRANT_ACL,"mysql",0,1,0))
+ if (check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1) &&
+ check_global_access(thd,CREATE_USER_ACL))
break;
if (!(res= mysql_rename_user(thd, lex->users_list)))
{
@@ -3609,7 +3610,8 @@ unsent_create_error:
}
case SQLCOM_REVOKE_ALL:
{
- if (check_access(thd, GRANT_ACL ,"mysql",0,1,0))
+ if (check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1) &&
+ check_global_access(thd,CREATE_USER_ACL))
break;
if (!(res = mysql_revoke_all(thd, lex->users_list)))
{
@@ -3637,47 +3639,29 @@ unsent_create_error:
uint counter;
List_iterator <LEX_USER> user_list(lex->users_list);
- while ((user=user_list++))
+ while ((user= user_list++))
{
- if (strcmp(thd->user, user->user.str) ||
- user->host.str &&
- my_strcasecmp(system_charset_info,
- user->host.str, thd->host_or_ip))
- {
- // We are trying to update another user, or create a new user
-
- if (!check_access(thd, GRANT_ACL, "mysql", 0, 1, 1))
- break; // We can update any existing, or add new users
-
- if (!check_acl_user(user, &counter) &&
- check_access(thd, INSERT_ACL, "mysql", 0, 1, 1))
- {
- my_error(ER_NO_PERMISSION_TO_CREATE_USER, MYF(0),
- thd->user, thd->host_or_ip);
- goto error; // Can't create new user, user does not exists
- }
- if (check_acl_user(user, &counter) &&
- user->password.str &&
- check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1))
- {
- my_message(ER_PASSWORD_NOT_ALLOWED,
- ER(ER_PASSWORD_NOT_ALLOWED), MYF(0));
- goto error; // Can't update password, user already exists
- }
- }
- }
- }
- if (specialflag & SPECIAL_NO_RESOLVE)
- {
- LEX_USER *user;
- List_iterator <LEX_USER> user_list(lex->users_list);
- while ((user=user_list++))
- {
- if (hostname_requires_resolving(user->host.str))
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_HOSTNAME_WONT_WORK,
- ER(ER_WARN_HOSTNAME_WONT_WORK),
- user->host.str);
+ if (specialflag & SPECIAL_NO_RESOLVE &&
+ hostname_requires_resolving(user->host.str))
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_HOSTNAME_WONT_WORK,
+ ER(ER_WARN_HOSTNAME_WONT_WORK),
+ user->host.str);
+ // Are we trying to change a password of another user
+ DBUG_ASSERT(user->host.str != 0);
+ if (strcmp(thd->user, user->user.str) ||
+ my_strcasecmp(system_charset_info,
+ user->host.str, thd->host_or_ip))
+ {
+ // TODO: use check_change_password()
+ if (check_acl_user(user, &counter) && user->password.str &&
+ check_access(thd, UPDATE_ACL,"mysql",0,1,1))
+ {
+ my_message(ER_PASSWORD_NOT_ALLOWED,
+ ER(ER_PASSWORD_NOT_ALLOWED), MYF(0));
+ goto error;
+ }
+ }
}
}
if (first_table)
@@ -4596,6 +4580,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access;
+ bool db_is_pattern= test(want_access & GRANT_ACL);
#endif
ulong dummy;
DBUG_ENTER("check_access");
@@ -4627,9 +4612,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
*/
db_access= thd->db_access;
if (!(thd->master_access & SELECT_ACL) &&
- (db && (!thd->db || strcmp(db,thd->db))))
- db_access=acl_get(thd->host, thd->ip,
- thd->priv_user, db, test(want_access & GRANT_ACL));
+ (db && (!thd->db || db_is_pattern || strcmp(db,thd->db))))
+ db_access=acl_get(thd->host, thd->ip, thd->priv_user, db, db_is_pattern);
*save_priv=thd->master_access | db_access;
DBUG_RETURN(FALSE);
}
@@ -4650,9 +4634,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
if (db == any_db)
DBUG_RETURN(FALSE); // Allow select on anything
- if (db && (!thd->db || strcmp(db,thd->db)))
- db_access=acl_get(thd->host, thd->ip,
- thd->priv_user, db, test(want_access & GRANT_ACL));
+ if (db && (!thd->db || db_is_pattern || strcmp(db,thd->db)))
+ db_access=acl_get(thd->host, thd->ip, thd->priv_user, db, db_is_pattern);
else
db_access=thd->db_access;
DBUG_PRINT("info",("db_access: %lu", db_access));
@@ -5547,9 +5530,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
my_error(ER_TOO_BIG_SET, MYF(0), field_name); /* purecov: inspected */
DBUG_RETURN(NULL);
}
- new_field->pack_length= (interval_list->elements + 7) / 8;
- if (new_field->pack_length > 4)
- new_field->pack_length=8;
+ new_field->pack_length= get_set_pack_length(interval_list->elements);
List_iterator<String> it(*interval_list);
String *tmp;
@@ -5566,7 +5547,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
case FIELD_TYPE_ENUM:
{
// Should be safe
- new_field->pack_length= interval_list->elements < 256 ? 1 : 2;
+ new_field->pack_length= get_enum_pack_length(interval_list->elements);
List_iterator<String> it(*interval_list);
String *tmp;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 7862717bb18..ace2a9de420 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -865,7 +865,7 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt,
*ptr++= '\'';
ptr+=
escape_string_for_mysql(&my_charset_utf8_general_ci,
- ptr, entry->name.str, entry->name.length);
+ ptr, 0, entry->name.str, entry->name.length);
*ptr++= '\'';
str.length(ptr - buf);
@@ -1166,7 +1166,7 @@ static int mysql_test_select(Prepared_statement *stmt,
It is not SELECT COMMAND for sure, so setup_tables will be called as
usual, and we pass 0 as setup_tables_done_option
*/
- if (unit->prepare(thd, 0, 0))
+ if (unit->prepare(thd, 0, 0, ""))
{
goto err_prep;
}
@@ -1318,7 +1318,7 @@ static bool select_like_stmt_test(Prepared_statement *stmt,
thd->used_tables= 0; // Updated by setup_fields
// JOIN::prepare calls
- if (lex->unit.prepare(thd, 0, setup_tables_done_option))
+ if (lex->unit.prepare(thd, 0, setup_tables_done_option, ""))
{
res= TRUE;
}
@@ -1970,6 +1970,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
{
ulong stmt_id= uint4korr(packet);
ulong flags= (ulong) ((uchar) packet[4]);
+ Cursor *cursor= 0;
/*
Query text for binary log, or empty string if the query is not put into
binary log.
@@ -2007,15 +2008,17 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
statement: we can't open a cursor for it.
*/
flags= 0;
+ my_error(ER_SP_BAD_CURSOR_QUERY, MYF(0));
+ goto err;
}
else
{
DBUG_PRINT("info",("Using READ_ONLY cursor"));
if (!stmt->cursor &&
- !(stmt->cursor= new (&stmt->main_mem_root) Cursor()))
+ !(cursor= stmt->cursor= new (&stmt->main_mem_root) Cursor()))
DBUG_VOID_RETURN;
/* If lex->result is set, mysql_execute_command will use it */
- stmt->lex->result= &stmt->cursor->result;
+ stmt->lex->result= &cursor->result;
}
}
#ifndef EMBEDDED_LIBRARY
@@ -2061,11 +2064,10 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
my_pthread_setprio(pthread_self(), WAIT_PRIOR);
thd->protocol= &thd->protocol_simple; // Use normal protocol
- if (flags & (ulong) CURSOR_TYPE_READ_ONLY)
+ if (cursor && cursor->is_open())
{
- if (stmt->cursor->is_open())
- stmt->cursor->init_from_thd(thd);
- stmt->cursor->state= stmt->state;
+ cursor->init_from_thd(thd);
+ cursor->state= stmt->state;
}
else
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 1e05400e88e..0c00d947508 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6646,7 +6646,6 @@ static COND *build_equal_items(THD *thd, COND *cond,
{
if (table->on_expr)
{
- Item *expr;
List<TABLE_LIST> *join_list= table->nested_join ?
&table->nested_join->join_list : NULL;
/*
@@ -7592,14 +7591,13 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item)
create_tmp_field_from_field()
thd Thread handler
org_field field from which new field will be created
- item Item to create a field for
+ name New field name
table Temporary table
- modify_item 1 if item->result_field should point to new item.
- This is relevent for how fill_record() is going to
- work:
- If modify_item is 1 then fill_record() will update
+ item !=NULL if item->result_field should point to new field.
+ This is relevant for how fill_record() is going to work:
+ If item != NULL then fill_record() will update
the record in the original table.
- If modify_item is 0 then fill_record() will update
+ If item == NULL then fill_record() will update
the temporary table
convert_blob_length If >0 create a varstring(convert_blob_length) field
instead of blob.
@@ -7610,9 +7608,8 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item)
*/
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
- Item *item, TABLE *table,
- bool modify_item,
- uint convert_blob_length)
+ const char *name, TABLE *table,
+ Item_field *item, uint convert_blob_length)
{
Field *new_field;
@@ -7625,10 +7622,10 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field,
new_field= org_field->new_field(thd->mem_root, table);
if (new_field)
{
- if (modify_item)
- ((Item_field *)item)->result_field= new_field;
+ if (item)
+ item->result_field= new_field;
else
- new_field->field_name= item->name;
+ new_field->field_name= name;
if (org_field->maybe_null())
new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join
if (org_field->type() == MYSQL_TYPE_VAR_STRING ||
@@ -7783,8 +7780,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item::DEFAULT_VALUE_ITEM:
{
Item_field *field= (Item_field*) item;
- return create_tmp_field_from_field(thd, (*from_field= field->field), item,
- table, modify_item, convert_blob_length);
+ return create_tmp_field_from_field(thd, (*from_field= field->field),
+ item->name, table,
+ modify_item ? (Item_field*) item : NULL,
+ convert_blob_length);
}
case Item::FUNC_ITEM:
case Item::COND_ITEM:
@@ -7803,14 +7802,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
return create_tmp_field_from_item(thd, item, table, copy_func, modify_item,
convert_blob_length);
case Item::TYPE_HOLDER:
- {
- Field *example= ((Item_type_holder *)item)->example();
- if (example)
- return create_tmp_field_from_field(thd, example, item, table, 0,
- convert_blob_length);
- return create_tmp_field_from_item(thd, item, table, copy_func, 0,
- convert_blob_length);
- }
+ return ((Item_type_holder *)item)->make_field_by_type(table);
default: // Dosen't have to be stored
return 0;
}
@@ -8545,7 +8537,7 @@ static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
seg->type=
((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ?
HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2);
- seg->bit_start= field->pack_length() - table->s->blob_ptr_size;
+ seg->bit_start= (uint8)(field->pack_length() - table->s->blob_ptr_size);
seg->flag= HA_BLOB_PART;
seg->length=0; // Whole blob in unique constraint
}
@@ -8715,8 +8707,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
*table= new_table;
table->s= &table->share_not_to_be_used;
table->file->change_table_ptr(table);
- thd->proc_info= (!strcmp(save_proc_info,"Copying to tmp table") ?
- "Copying to tmp table on disk" : save_proc_info);
+ if (save_proc_info)
+ thd->proc_info= (!strcmp(save_proc_info,"Copying to tmp table") ?
+ "Copying to tmp table on disk" : save_proc_info);
DBUG_RETURN(0);
err:
@@ -10145,20 +10138,18 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
join->sum_funcs_end[send_group_parts]);
if (join->having && join->having->val_int() == 0)
error= -1;
- else if ((error=table->file->write_row(table->record[0])))
+ else if ((error= table->file->write_row(table->record[0])))
{
if (create_myisam_from_heap(join->thd, table,
&join->tmp_table_param,
error, 0))
DBUG_RETURN(-1);
}
- if (join->rollup.state != ROLLUP::STATE_NONE && error <= 0)
+ if (join->rollup.state != ROLLUP::STATE_NONE)
{
if (join->rollup_write_data((uint) (idx+1), table))
- error= 1;
+ DBUG_RETURN(-1);
}
- if (error > 0)
- DBUG_RETURN(-1);
if (end_of_records)
DBUG_RETURN(0);
}
@@ -10586,7 +10577,20 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
/* Found key that can be used to retrieve data in sorted order */
if (tab->ref.key >= 0)
{
- tab->ref.key= new_ref_key;
+ /*
+ We'll use ref access method on key new_ref_key. In general case
+ the index search tuple for new_ref_key will be different (e.g.
+ when one index is defined as (part1, part2, ...) and another as
+ (part1, part2(N), ...) and the WHERE clause contains
+ "part1 = const1 AND part2=const2".
+ So we build tab->ref from scratch here.
+ */
+ KEYUSE *keyuse= tab->keyuse;
+ while (keyuse->key != new_ref_key && keyuse->table == tab->table)
+ keyuse++;
+ if (create_ref_for_key(tab->join, tab, keyuse,
+ tab->join->const_table_map))
+ DBUG_RETURN(0);
}
else
{
@@ -12685,17 +12689,21 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
{
/* Check if this is something that is part of this group by */
ORDER *group_tmp;
- for (group_tmp= start_group, i-- ;
+ for (group_tmp= start_group, i= pos ;
group_tmp ; group_tmp= group_tmp->next, i++)
{
if (*group_tmp->item == item)
{
+ Item_null_result *null_item;
/*
This is an element that is used by the GROUP BY and should be
set to NULL in this level
*/
item->maybe_null= 1; // Value will be null sometimes
- Item_null_result *null_item= rollup.null_items[i];
+ null_item= rollup.null_items[i];
+ DBUG_ASSERT(null_item->result_field == 0 ||
+ null_item->result_field ==
+ ((Item_field *) item)->result_field);
null_item->result_field= ((Item_field *) item)->result_field;
item= null_item;
break;
@@ -13186,7 +13194,8 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
unit->fake_select_lex->select_number= UINT_MAX; // jost for initialization
unit->fake_select_lex->type= "UNION RESULT";
unit->fake_select_lex->options|= SELECT_DESCRIBE;
- if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE)))
+ if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE,
+ "")))
res= unit->exec();
res|= unit->cleanup();
}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 02e1dde8a7f..381ccbba4fd 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -351,7 +351,7 @@ class Cursor: public Sql_alloc, public Item_arena
MYSQL_LOCK *lock;
TABLE *derived_tables;
/* List of items created during execution */
- ulong query_id;
+ query_id_t query_id;
public:
select_send result;
@@ -370,7 +370,7 @@ public:
void close();
void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; }
- Cursor() :join(0), unit(0) {}
+ Cursor() :Item_arena(TRUE), join(0), unit(0) {}
~Cursor();
};
@@ -402,10 +402,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
int error, bool ignore_last_dupp_error);
uint find_shortest_key(TABLE *table, const key_map *usable_keys);
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
- Item *item, TABLE *table,
- bool modify_item,
- uint convert_blob_length);
-
+ const char *name, TABLE *table,
+ Item_field *item, uint convert_blob_length);
+
/* functions from opt_sum.cc */
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 124ce1805db..263f907f277 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -41,6 +41,7 @@ static int
store_create_info(THD *thd, TABLE_LIST *table_list, String *packet);
static int
view_store_create_info(THD *thd, TABLE_LIST *table, String *packet);
+static bool schema_table_store_record(THD *thd, TABLE *table);
/***************************************************************************
@@ -102,6 +103,7 @@ static struct show_privileges_st sys_privileges[]=
{"Create routine","Functions,Procedures","To use CREATE FUNCTION/PROCEDURE"},
{"Create temporary tables","Databases","To use CREATE TEMPORARY TABLE"},
{"Create view", "Tables", "To create new views"},
+ {"Create user", "Server Admin", "To create new users"},
{"Delete", "Tables", "To delete existing rows"},
{"Drop", "Databases,Tables", "To drop databases, tables, and views"},
{"Execute", "Functions,Procedures", "To execute stored routines"},
@@ -977,7 +979,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
packet->append(buff, (uint) (end- buff));
}
- if (share->max_rows)
+ if (share->max_rows && !table_list->schema_table)
{
packet->append(" MAX_ROWS=", 10);
end= longlong10_to_str(share->max_rows, buff, 10);
@@ -1330,6 +1332,19 @@ static bool show_status_array(THD *thd, const char *wild,
pthread_mutex_unlock(&LOCK_active_mi);
break;
}
+ case SHOW_SLAVE_RETRIED_TRANS:
+ {
+ /*
+ TODO: in 5.1 with multimaster, have one such counter per line in SHOW
+ SLAVE STATUS, and have the sum over all lines here.
+ */
+ pthread_mutex_lock(&LOCK_active_mi);
+ pthread_mutex_lock(&active_mi->rli.data_lock);
+ end= int10_to_str(active_mi->rli.retried_trans, buff, 10);
+ pthread_mutex_unlock(&active_mi->rli.data_lock);
+ pthread_mutex_unlock(&LOCK_active_mi);
+ break;
+ }
#endif /* HAVE_REPLICATION */
case SHOW_OPENTABLES:
end= int10_to_str((long) cached_tables(), buff, 10);
@@ -1536,7 +1551,8 @@ static bool show_status_array(THD *thd, const char *wild,
table->field[0]->store(name_buffer, strlen(name_buffer),
system_charset_info);
table->field[1]->store(pos, (uint32) (end - pos), system_charset_info);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(TRUE);
}
}
}
@@ -1592,6 +1608,34 @@ typedef struct st_index_field_values
} INDEX_FIELD_VALUES;
+/*
+ Store record to I_S table, convert HEAP table
+ to MyISAM if necessary
+
+ SYNOPSIS
+ schema_table_store_record()
+ thd thread handler
+ table Information schema table to be updated
+
+ RETURN
+ 0 success
+ 1 error
+*/
+
+static bool schema_table_store_record(THD *thd, TABLE *table)
+{
+ int error;
+ if ((error= table->file->write_row(table->record[0])))
+ {
+ if (create_myisam_from_heap(thd, table,
+ table->pos_in_table_list->schema_table_param,
+ error, 0))
+ return 1;
+ }
+ return 0;
+}
+
+
void get_index_field_values(LEX *lex, INDEX_FIELD_VALUES *index_field_values)
{
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
@@ -1915,7 +1959,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
}
}
}
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ goto err;
}
else
{
@@ -1952,13 +1997,13 @@ err:
}
-void store_schema_shemata(TABLE *table, const char *db_name,
+bool store_schema_shemata(THD* thd, TABLE *table, const char *db_name,
const char* cs_name)
{
restore_record(table, s->default_values);
table->field[1]->store(db_name, strlen(db_name), system_charset_info);
table->field[2]->store(cs_name, strlen(cs_name), system_charset_info);
- table->file->write_row(table->record[0]);
+ return schema_table_store_record(thd, table);
}
@@ -1987,7 +2032,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
{
if (with_i_schema) // information schema name is always first in list
{
- store_schema_shemata(table, file_name, system_charset_info->csname);
+ if (store_schema_shemata(thd, table, file_name,
+ system_charset_info->csname))
+ DBUG_RETURN(1);
with_i_schema= 0;
continue;
}
@@ -2010,8 +2057,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
path[length-1]= FN_LIBCHAR;
strmov(path+length, MY_DB_OPT_FILE);
load_db_opt(thd, path, &create);
- store_schema_shemata(table, file_name,
- create.default_table_charset->csname);
+ if (store_schema_shemata(thd, table, file_name,
+ create.default_table_charset->csname))
+ DBUG_RETURN(1);
}
}
DBUG_RETURN(0);
@@ -2196,8 +2244,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
}
}
}
- table->file->write_row(table->record[0]);
- DBUG_RETURN(0);
+ DBUG_RETURN(schema_table_store_record(thd, table));
}
@@ -2375,7 +2422,8 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
#endif
table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
table->field[18]->store(field->comment.str, field->comment.length, cs);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
}
}
DBUG_RETURN(0);
@@ -2404,7 +2452,8 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(tmp_cs->comment ? tmp_cs->comment : ""),
scs);
table->field[3]->store((longlong) tmp_cs->mbmaxlen);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ return 1;
}
}
return 0;
@@ -2443,7 +2492,8 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
table->field[5]->store((longlong) tmp_cl->strxfrm_multiply);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ return 1;
}
}
}
@@ -2472,14 +2522,15 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond)
restore_record(table, s->default_values);
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ return 1;
}
}
return 0;
}
-void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
+bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
const char *wild, bool full_access, const char *sp_user)
{
String tmp_string;
@@ -2493,7 +2544,7 @@ void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
if (!full_access)
full_access= !strcmp(sp_user, definer);
if (!full_access && check_some_routine_access(thd, sp_db, sp_name))
- return;
+ return 0;
if (lex->orig_sql_command == SQLCOM_SHOW_STATUS_PROC &&
proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE ||
@@ -2542,9 +2593,10 @@ void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
get_field(thd->mem_root, proc_table->field[15], &tmp_string);
table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[19]->store(definer, strlen(definer), cs);
- table->file->write_row(table->record[0]);
+ return schema_table_store_record(thd, table);
}
}
+ return 0;
}
@@ -2577,9 +2629,19 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
res= (res == HA_ERR_END_OF_FILE) ? 0 : 1;
goto err;
}
- store_schema_proc(thd, table, proc_table, wild, full_access, definer);
+ if (store_schema_proc(thd, table, proc_table, wild, full_access, definer))
+ {
+ res= 1;
+ goto err;
+ }
while (!proc_table->file->index_next(proc_table->record[0]))
- store_schema_proc(thd, table, proc_table, wild, full_access, definer);
+ {
+ if (store_schema_proc(thd, table, proc_table, wild, full_access, definer))
+ {
+ res= 1;
+ goto err;
+ }
+ }
err:
proc_table->file->ha_index_end();
@@ -2669,7 +2731,8 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
else
table->field[14]->store("", 0, cs);
table->field[14]->set_notnull();
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
}
}
}
@@ -2708,7 +2771,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
table->field[5]->store("YES", 3, cs);
else
table->field[5]->store("NO", 2, cs);
- table->file->write_row(table->record[0]);
+ DBUG_RETURN(schema_table_store_record(thd, table));
}
}
else
@@ -2722,9 +2785,9 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
}
-void store_constraints(TABLE *table, const char*db, const char *tname,
- const char *key_name, uint key_len,
- const char *con_type, uint con_len)
+bool store_constraints(THD *thd, TABLE *table, const char *db,
+ const char *tname, const char *key_name,
+ uint key_len, const char *con_type, uint con_len)
{
CHARSET_INFO *cs= system_charset_info;
restore_record(table, s->default_values);
@@ -2733,7 +2796,7 @@ void store_constraints(TABLE *table, const char*db, const char *tname,
table->field[3]->store(db, strlen(db), cs);
table->field[4]->store(tname, strlen(tname), cs);
table->field[5]->store(con_type, con_len, cs);
- table->file->write_row(table->record[0]);
+ return schema_table_store_record(thd, table);
}
@@ -2766,11 +2829,17 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
continue;
if (i == primary_key && !strcmp(key_info->name, primary_key_name))
- store_constraints(table, base_name, file_name, key_info->name,
- strlen(key_info->name), "PRIMARY KEY", 11);
+ {
+ if (store_constraints(thd, table, base_name, file_name, key_info->name,
+ strlen(key_info->name), "PRIMARY KEY", 11))
+ DBUG_RETURN(1);
+ }
else if (key_info->flags & HA_NOSAME)
- store_constraints(table, base_name, file_name, key_info->name,
- strlen(key_info->name), "UNIQUE", 6);
+ {
+ if (store_constraints(thd, table, base_name, file_name, key_info->name,
+ strlen(key_info->name), "UNIQUE", 6))
+ DBUG_RETURN(1);
+ }
}
show_table->file->get_foreign_key_list(thd, &f_key_list);
@@ -2778,8 +2847,11 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
while ((f_key_info=it++))
{
- store_constraints(table, base_name, file_name, f_key_info->forein_id->str,
- strlen(f_key_info->forein_id->str), "FOREIGN KEY", 11);
+ if (store_constraints(thd, table, base_name, file_name,
+ f_key_info->forein_id->str,
+ strlen(f_key_info->forein_id->str),
+ "FOREIGN KEY", 11))
+ DBUG_RETURN(1);
}
}
DBUG_RETURN(res);
@@ -2842,7 +2914,8 @@ static int get_schema_key_column_usage_record(THD *thd,
key_part->field->field_name,
strlen(key_part->field->field_name),
(longlong) f_idx);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
}
}
}
@@ -2868,7 +2941,8 @@ static int get_schema_key_column_usage_record(THD *thd,
(longlong) f_idx);
table->field[8]->store((longlong) f_idx);
table->field[8]->set_notnull();
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
}
}
}
@@ -2893,7 +2967,8 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
table->field[1]->store(open_list->table, strlen(open_list->table), cs);
table->field[2]->store((longlong) open_list->in_use);
table->field[3]->store((longlong) open_list->locked);
- table->file->write_row(table->record[0]);
+ if (schema_table_store_record(thd, table))
+ DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
@@ -3034,6 +3109,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
TMP_TABLE_ALL_COLUMNS),
HA_POS_ERROR, table_list->alias)))
DBUG_RETURN(0);
+ table_list->schema_table_param= tmp_table_param;
DBUG_RETURN(table);
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index fc1e9f171b6..7ece9885040 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -84,6 +84,7 @@ public:
inline char& operator [] (uint32 i) const { return Ptr[i]; }
inline void length(uint32 len) { str_length=len ; }
inline bool is_empty() { return (str_length == 0); }
+ inline void mark_as_const() { Alloced_length= 0;}
inline const char *ptr() const { return Ptr; }
inline char *c_ptr()
{
@@ -205,10 +206,6 @@ public:
}
}
}
- inline void shrink_to_length()
- {
- Alloced_length= str_length;
- }
bool is_alloced() { return alloced; }
inline String& operator = (const String &s)
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 8295e2f07ab..b125eeaf03a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -613,7 +613,7 @@ int prepare_create_field(create_field *sql_field,
Prepares the table and key structures for table creation.
NOTES
- sets create_info->varchar if the table has a varchar or blob.
+ sets create_info->varchar if the table has a varchar
RETURN VALUES
0 ok
@@ -862,12 +862,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
&timestamps, &timestamps_with_niladic,
file->table_flags()))
DBUG_RETURN(-1);
- if (sql_field->sql_type == FIELD_TYPE_BLOB ||
- sql_field->sql_type == FIELD_TYPE_MEDIUM_BLOB ||
- sql_field->sql_type == FIELD_TYPE_TINY_BLOB ||
- sql_field->sql_type == FIELD_TYPE_LONG_BLOB ||
- sql_field->sql_type == FIELD_TYPE_GEOMETRY ||
- sql_field->sql_type == MYSQL_TYPE_VARCHAR)
+ if (sql_field->sql_type == MYSQL_TYPE_VARCHAR)
create_info->varchar= 1;
sql_field->offset= pos;
if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
@@ -2052,7 +2047,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->no_warnings_for_error= 0;
table->next_global= next_global_table;
/* if view are unsupported */
- if (table->view && !view_operator_func)
+ if (table->view && view_operator_func == NULL)
{
result_code= HA_ADMIN_NOT_IMPLEMENTED;
goto send_result;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 13c7f0a40b7..00770ba02a2 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -30,7 +30,7 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result,
DBUG_ENTER("mysql_union");
bool res;
if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK |
- setup_tables_done_option)))
+ setup_tables_done_option, "")))
res= unit->exec();
if (!res && thd->cursor && thd->cursor->is_open())
{
@@ -140,7 +140,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd)
bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
- ulong additional_options)
+ ulong additional_options,
+ const char *tmp_table_alias)
{
SELECT_LEX *lex_select_save= thd_arg->lex->current_select;
SELECT_LEX *sl, *first_select;
@@ -255,7 +256,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
while ((item_tmp= it++))
{
/* Error's in 'new' will be detected after loop */
- types.push_back(new Item_type_holder(thd_arg, item_tmp, empty_table));
+ types.push_back(new Item_type_holder(thd_arg, item_tmp));
}
if (thd_arg->is_fatal_error)
@@ -274,8 +275,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
Item *type, *item_tmp;
while ((type= tp++, item_tmp= it++))
{
- if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp,
- empty_table))
+ if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp))
DBUG_RETURN(TRUE);
}
}
@@ -308,7 +308,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
(first_select_in_union()->options |
thd_arg->options |
TMP_TABLE_ALL_COLUMNS),
- HA_POS_ERROR, (char*) "")))
+ HA_POS_ERROR, (char *) tmp_table_alias)))
goto err;
table->file->extra(HA_EXTRA_WRITE_CACHE);
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
@@ -418,7 +418,7 @@ bool st_select_lex_unit::exec()
}
/* re-enabling indexes for next subselect iteration */
if (union_distinct && table->file->enable_indexes(HA_KEY_SWITCH_ALL))
- DBUG_ASSERT(TRUE);
+ DBUG_ASSERT(0);
}
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
{
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 3ee656b00ce..bb0ac31bdc7 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -29,7 +29,7 @@ static bool safe_update_on_fly(JOIN_TAB *join_tab, List<Item> *fields);
/* Return 0 if row hasn't changed */
-static bool compare_record(TABLE *table, ulong query_id)
+static bool compare_record(TABLE *table, query_id_t query_id)
{
if (table->s->blob_fields + table->s->varchar_fields == 0)
return cmp_record(table,record[1]);
@@ -125,7 +125,7 @@ int mysql_update(THD *thd,
uint want_privilege;
#endif
uint table_count= 0;
- ulong query_id=thd->query_id, timestamp_query_id;
+ query_id_t query_id=thd->query_id, timestamp_query_id;
ha_rows updated, found;
key_map old_used_keys;
TABLE *table;
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 31277452118..e4f30f72443 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -216,7 +216,7 @@ bool mysql_create_view(THD *thd,
/* prepare select to resolve all fields */
lex->view_prepare_mode= 1;
- if (unit->prepare(thd, 0, 0))
+ if (unit->prepare(thd, 0, 0, view->view_name.str))
{
/*
some errors from prepare are reported to user, if is not then
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index cc6eadf5fd5..4924f78dc0a 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1398,7 +1398,7 @@ create_function_tail:
uint unused1= 0;
int unused2= 0;
- if (!(new_field= new_create_field(YYTHD, "",
+ if (!(new_field= new_create_field(YYTHD, (char*) "",
(enum enum_field_types)$8,
lex->length, lex->dec, lex->type,
(Item *)0, (Item *) 0, &cmt, 0,
@@ -3670,9 +3670,15 @@ analyze:
check:
CHECK_SYM table_or_tables
{
- LEX *lex=Lex;
- lex->sql_command = SQLCOM_CHECK;
- lex->check_opt.init();
+ LEX *lex=Lex;
+
+ if (lex->sphead)
+ {
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK");
+ YYABORT;
+ }
+ lex->sql_command = SQLCOM_CHECK;
+ lex->check_opt.init();
}
table_list opt_mi_check_type
{}
@@ -7719,7 +7725,7 @@ lock:
if (lex->sphead)
{
- my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0));
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "LOCK");
YYABORT;
}
lex->sql_command= SQLCOM_LOCK_TABLES;
@@ -7758,7 +7764,7 @@ unlock:
if (lex->sphead)
{
- my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0));
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "UNLOCK");
YYABORT;
}
lex->sql_command= SQLCOM_UNLOCK_TABLES;
@@ -7903,6 +7909,7 @@ object_privilege:
| SHOW VIEW_SYM { Lex->grant |= SHOW_VIEW_ACL; }
| CREATE ROUTINE_SYM { Lex->grant |= CREATE_PROC_ACL; }
| ALTER ROUTINE_SYM { Lex->grant |= ALTER_PROC_ACL; }
+ | CREATE USER { Lex->grant |= CREATE_USER_ACL; }
;
diff --git a/sql/structs.h b/sql/structs.h
index cbc7161ee20..7a70bfc0f4f 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -182,7 +182,7 @@ enum SHOW_TYPE
SHOW_SSL_CTX_SESS_TIMEOUTS, SHOW_SSL_CTX_SESS_CACHE_FULL,
SHOW_SSL_GET_CIPHER_LIST,
#endif /* HAVE_OPENSSL */
- SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING,
+ SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING, SHOW_SLAVE_RETRIED_TRANS,
SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_CONST_LONG,
SHOW_LONG_STATUS, SHOW_LONG_CONST_STATUS
};
diff --git a/sql/table.cc b/sql/table.cc
index 939690395d4..9238d8aa68e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -149,6 +149,15 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
*fn_ext(index_file)='\0'; // Remove .frm extension
share->frm_version= head[2];
+ /*
+ Check if .frm file created by MySQL 5.0. In this case we want to
+ display CHAR fields as CHAR and not as VARCHAR.
+ We do it this way as we want to keep the old frm version to enable
+ MySQL 4.1 to read these files.
+ */
+ if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5)
+ share->frm_version= FRM_VER_TRUE_VARCHAR;
+
share->db_type= ha_checktype((enum db_type) (uint) *(head+3));
share->db_create_options= db_create_options=uint2korr(head+30);
share->db_options_in_use= share->db_create_options;
@@ -1317,6 +1326,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
create_info->table_options|=HA_OPTION_LONG_BLOB_PTR; // Use portable blob pointers
int2store(fileinfo+30,create_info->table_options);
fileinfo[32]=0; // No filename anymore
+ fileinfo[33]=5; // Mark for 5.0 frm file
int4store(fileinfo+34,create_info->avg_row_length);
fileinfo[38]= (create_info->default_table_charset ?
create_info->default_table_charset->number : 0);
diff --git a/sql/table.h b/sql/table.h
index 49ead2cb0b7..fd299759678 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -188,7 +188,7 @@ struct st_table {
ORDER *group;
const char *alias; /* alias or table name */
uchar *null_flags;
- ulong query_id;
+ query_id_t query_id;
ha_rows quick_rows[MAX_KEY];
key_part_map const_key_parts[MAX_KEY];
@@ -322,6 +322,7 @@ typedef struct st_schema_table
struct st_lex;
class select_union;
+class TMP_TABLE_PARAM;
struct Field_translator
{
@@ -370,6 +371,7 @@ typedef struct st_table_list
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex;
bool schema_table_reformed;
+ TMP_TABLE_PARAM *schema_table_param;
/* link to select_lex where this table was used */
st_select_lex *select_lex;
st_lex *view; /* link on VIEW lex for merging */
diff --git a/sql/tztime.cc b/sql/tztime.cc
index bd9d49f0ab0..983c630071e 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -2178,7 +2178,7 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables)
DBUG_PRINT("enter", ("time zone name='%s'",
name ? ((String *)name)->c_ptr() : "NULL"));
- DBUG_ASSERT(!time_zone_tables_exist || tz_tables);
+ DBUG_ASSERT(!time_zone_tables_exist || tz_tables || current_thd->slave_thread);
if (!name)
DBUG_RETURN(0);
@@ -2210,7 +2210,7 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables)
(const byte *)name->ptr(),
name->length())))
result_tz= tmp_tzname->tz;
- else if (time_zone_tables_exist)
+ else if (time_zone_tables_exist && tz_tables)
result_tz= tz_load_from_open_tables(name, tz_tables);
}
@@ -2219,6 +2219,58 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables)
DBUG_RETURN(result_tz);
}
+
+/*
+ A more standalone version of my_tz_find(): will open tz tables if needed.
+ This is so far only used by replication, where time zone setting does not
+ happen in the usual query context.
+
+ SYNOPSIS
+ my_tz_find_with_opening_tz_tables()
+ thd - pointer to thread's THD structure
+ name - time zone specification
+
+ DESCRIPTION
+ This function tries to find a time zone which matches the named passed in
+ argument. If it fails, it will open time zone tables and re-try the
+ search.
+ This function is needed for the slave SQL thread, which does not do the
+ addition of time zone tables which is usually done during query parsing
+ (as time zone setting by slave does not happen in mysql_parse() but
+ before). So it needs to open tz tables by itself if needed.
+ See notes of my_tz_find() as they also apply here.
+
+ RETURN VALUE
+ Pointer to corresponding Time_zone object. 0 - in case of bad time zone
+ specification or other error.
+
+*/
+Time_zone *my_tz_find_with_opening_tz_tables(THD *thd, const String *name)
+{
+ Time_zone *tz;
+ DBUG_ENTER("my_tz_find_with_opening_tables");
+ DBUG_ASSERT(thd);
+ DBUG_ASSERT(thd->slave_thread); // intended for use with slave thread only
+ if (!(tz= my_tz_find(name, 0)) && time_zone_tables_exist)
+ {
+ /*
+ Probably we have not loaded this time zone yet so let us look it up in
+ our time zone tables. Note that if we don't have tz tables on this
+ slave, we don't even try.
+ */
+ TABLE_LIST tables[4];
+ TABLE_LIST *dummy;
+ TABLE_LIST **dummyp= &dummy;
+ tz_init_table_list(tables, &dummyp);
+ if (simple_open_n_lock_tables(thd, tables))
+ DBUG_RETURN(0);
+ tz= my_tz_find(name, tables);
+ /* We need to close tables _now_ to not pollute coming query */
+ close_thread_tables(thd);
+ }
+ DBUG_RETURN(tz);
+}
+
#endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
diff --git a/sql/tztime.h b/sql/tztime.h
index caf663fc8cb..777e521d761 100644
--- a/sql/tztime.h
+++ b/sql/tztime.h
@@ -61,6 +61,7 @@ extern Time_zone * my_tz_UTC;
extern Time_zone * my_tz_SYSTEM;
extern TABLE_LIST * my_tz_get_table_list(THD *thd, TABLE_LIST ***global_next_ptr);
extern Time_zone * my_tz_find(const String *name, TABLE_LIST *tz_tables);
+extern Time_zone * my_tz_find_with_opening_tz_tables(THD *thd, const String *name);
extern my_bool my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap);
extern void my_tz_free();
@@ -96,10 +97,4 @@ inline bool my_tz_check_n_skip_implicit_tables(TABLE_LIST **table,
return FALSE;
}
-/*
- Maximum length of time zone name that we support
- (Time zone name is char(64) in db)
-*/
-#define MAX_TIME_ZONE_NAME_LENGTH 72
-
#endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 793c48bb988..336b5f0e832 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6287,6 +6287,39 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
return 2;
}
+
+/*
+ Returns a well formed length of a BIG5 string.
+ CP950 and HKSCS additional characters are also accepted.
+*/
+static
+uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
+ const char *b, const char *e, uint pos)
+{
+ const char *b0= b;
+ const char *emb= e - 1; /* Last possible end of an MB character */
+ while (pos && b < e)
+ {
+ if ((uchar) b[0] < 128)
+ {
+ /* Single byte ascii character */
+ b++;
+ }
+ else if ((b < emb) && isbig5code((uchar)*b, (uchar)b[1]))
+ {
+ /* Double byte character */
+ b+= 2;
+ }
+ else
+ {
+ /* Wrong byte sequence */
+ break;
+ }
+ }
+ return b - b0;
+}
+
+
static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler =
{
NULL, /* init */
@@ -6308,7 +6341,7 @@ static MY_CHARSET_HANDLER my_charset_big5_handler=
mbcharlen_big5,
my_numchars_mb,
my_charpos_mb,
- my_well_formed_len_mb,
+ my_well_formed_len_big5,
my_lengthsp_8bit,
my_numcells_8bit,
my_mb_wc_big5, /* mb_wc */
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 61e7cf1571b..91888771c80 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -894,7 +894,7 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)),
while (long_val != 0)
{
long quo= long_val/10;
- *--p = '0' + (long_val - quo*10);
+ *--p = '0' + (char)(long_val - quo*10);
long_val= quo;
}
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index b0e2d1fcb1a..9a54fe5595b 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -4591,12 +4591,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)),
const char *b0= b;
while (pos && b < e)
{
- /*
- Cast to int8 for extra safety.
- "char" can be unsigned by default
- on some platforms.
- */
- if (((int8)b[0]) >= 0)
+ if ((uchar) b[0] < 128)
{
/* Single byte ascii character */
b++;
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 797bc9f9047..72483ce5c4c 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1049,7 +1049,7 @@ int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)),
while (long_val != 0)
{
long quo= long_val/10;
- *--p = '0' + (long_val - quo*10);
+ *--p = '0' + (char)(long_val - quo*10);
long_val= quo;
}
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 187e5cb9e4a..e8b7a5e9e81 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2148,12 +2148,7 @@ int my_strcasecmp_utf8(CHARSET_INFO *cs, const char *s, const char *t)
{
my_wc_t s_wc,t_wc;
- /*
- Cast to int8 for extra safety.
- char can be unsigned by default
- on some platforms.
- */
- if (((int8)s[0]) >= 0)
+ if ((uchar) s[0] < 128)
{
/*
s[0] is between 0 and 127.
@@ -2200,7 +2195,7 @@ int my_strcasecmp_utf8(CHARSET_INFO *cs, const char *s, const char *t)
/* Do the same for the second string */
- if (((int8)t[0]) >= 0)
+ if ((uchar) t[0] < 128)
{
/* Convert single byte character into weight */
t_wc= plane00[(uchar) t[0]].tolower;
@@ -2264,8 +2259,8 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs,
plane=(wc>>8) & 0xFF;
wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc;
- *dst++= wc >> 8;
- *dst++= wc & 0xFF;
+ *dst++= (uchar)(wc >> 8);
+ *dst++= (uchar)(wc & 0xFF);
}
@@ -2276,7 +2271,7 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs,
}
if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */
- *de= 0x00;
+ *dst= 0x00;
return dstlen;
}
@@ -2410,6 +2405,172 @@ CHARSET_INFO my_charset_utf8_bin=
&my_collation_mb_bin_handler
};
+#ifdef HAVE_CYBOZU_COLLATION
+
+/*
+ * These functions bacically do the same as their original, except
+ * that they return 0 only when two comparing unicode strings are
+ * strictly the same in case-sensitive way. See "save_diff" local
+ * variable to what they actually do.
+ */
+
+static int my_strnncoll_utf8_cs(CHARSET_INFO *cs,
+ const uchar *s, uint slen,
+ const uchar *t, uint tlen,
+ my_bool t_is_prefix)
+{
+ int s_res,t_res;
+ my_wc_t s_wc,t_wc;
+ const uchar *se=s+slen;
+ const uchar *te=t+tlen;
+ int save_diff = 0;
+ int diff;
+
+ while ( s < se && t < te )
+ {
+ int plane;
+ s_res=my_utf8_uni(cs,&s_wc, s, se);
+ t_res=my_utf8_uni(cs,&t_wc, t, te);
+
+ if ( s_res <= 0 || t_res <= 0 )
+
+ {
+ /* Incorrect string, compare by char value */
+ return ((int)s[0]-(int)t[0]);
+ }
+
+ if ( save_diff == 0 )
+ {
+ save_diff = ((int)s_wc) - ((int)t_wc);
+ }
+ plane=(s_wc>>8) & 0xFF;
+ s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].sort : s_wc;
+ plane=(t_wc>>8) & 0xFF;
+ t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
+ if ( s_wc != t_wc )
+ {
+ return ((int) s_wc) - ((int) t_wc);
+ }
+
+ s+=s_res;
+ t+=t_res;
+ }
+ diff = ( (se-s) - (te-t) );
+ return t_is_prefix ? t-te : ((diff == 0) ? save_diff : diff);
+}
+
+static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs,
+ const uchar *s, uint slen,
+ const uchar *t, uint tlen)
+{
+ int s_res,t_res;
+ my_wc_t s_wc,t_wc;
+ const uchar *se= s+slen;
+ const uchar *te= t+tlen;
+ int save_diff = 0;
+
+ while ( s < se && t < te )
+ {
+ int plane;
+ s_res=my_utf8_uni(cs,&s_wc, s, se);
+ t_res=my_utf8_uni(cs,&t_wc, t, te);
+
+ if ( s_res <= 0 || t_res <= 0 )
+ {
+ /* Incorrect string, compare by char value */
+ return ((int)s[0]-(int)t[0]);
+ }
+
+ if ( save_diff == 0 )
+ {
+ save_diff = ((int)s_wc) - ((int)t_wc);
+ }
+ plane=(s_wc>>8) & 0xFF;
+ s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].sort : s_wc;
+ plane=(t_wc>>8) & 0xFF;
+ t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
+ if ( s_wc != t_wc )
+ {
+ return ((int) s_wc) - ((int) t_wc);
+ }
+
+ s+=s_res;
+ t+=t_res;
+ }
+
+ slen= se-s;
+ tlen= te-t;
+
+ if (slen != tlen)
+ {
+ int swap= 0;
+ if (slen < tlen)
+ {
+ slen= tlen;
+ s= t;
+ se= te;
+ swap= -1;
+ }
+ /*
+ This following loop uses the fact that in UTF-8
+ all multibyte characters are greater than space,
+ and all multibyte head characters are greater than
+ space. It means if we meet a character greater
+ than space, it always means that the longer string
+ is greater. So we can reuse the same loop from the
+ 8bit version, without having to process full multibute
+ sequences.
+ */
+ for ( ; s < se; s++)
+ {
+ if (*s != ' ')
+ return ((int)*s - (int) ' ') ^ swap;
+ }
+ }
+ return save_diff;
+}
+
+static MY_COLLATION_HANDLER my_collation_cs_handler =
+{
+ NULL, /* init */
+ my_strnncoll_utf8_cs,
+ my_strnncollsp_utf8_cs,
+ my_strnxfrm_utf8,
+ my_like_range_simple,
+ my_wildcmp_mb,
+ my_strcasecmp_utf8,
+ my_instr_mb,
+ my_hash_sort_utf8
+};
+
+CHARSET_INFO my_charset_utf8_general_cs=
+{
+ 254,0,0, /* number */
+ MY_CS_COMPILED|MY_CS_UNICODE, /* state */
+ "utf8", /* cs name */
+ "utf8_general_cs", /* name */
+ "", /* comment */
+ NULL, /* tailoring */
+ ctype_utf8, /* ctype */
+ to_lower_utf8, /* to_lower */
+ to_upper_utf8, /* to_upper */
+ to_upper_utf8, /* sort_order */
+ NULL, /* contractions */
+ NULL, /* sort_order_big*/
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 1, /* strxfrm_multiply */
+ 1, /* mbminlen */
+ 3, /* mbmaxlen */
+ 0, /* min_sort_char */
+ 255, /* max_sort_char */
+ &my_charset_utf8_handler,
+ &my_collation_cs_handler
+};
+#endif /* Cybozu Hack */
+
#ifdef MY_TEST_UTF8
#include <stdio.h>
diff --git a/strings/decimal.c b/strings/decimal.c
index 90e64ae892f..56dba61d887 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -109,20 +109,20 @@
/*
Internally decimal numbers are stored base 10^9 (see DIG_BASE below)
- So one "decimal_digit" is
+ So one variable of type decimal_digit_t is limited:
0 < decimal_digit <= DIG_MAX < DIG_BASE
- in the struct st_decimal:
+ in the struct st_decimal_t:
- intg is the number of *decimal* digits (NOT number of decimal_digit's !)
+ intg is the number of *decimal* digits (NOT number of decimal_digit_t's !)
before the point
frac - number of decimal digits after the point
- buf is an array of decimal_digit's
- len is the length of buf (length of allocated space) in decimal_digit's,
+ buf is an array of decimal_digit_t's
+ len is the length of buf (length of allocated space) in decimal_digit_t's,
not in bytes
*/
-typedef decimal_digit dec1;
+typedef decimal_digit_t dec1;
typedef longlong dec2;
#define DIG_PER_DEC1 9
@@ -139,8 +139,12 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={
999900000, 999990000, 999999000,
999999900, 999999990 };
+#ifdef HAVE_purify
+#define sanity(d) DBUG_ASSERT((d)->len > 0)
+#else
#define sanity(d) DBUG_ASSERT((d)->len >0 && ((d)->buf[0] | \
(d)->buf[(d)->len-1] | 1))
+#endif
#define FIX_INTG_FRAC_ERROR(len, intg1, frac1, error) \
do \
@@ -219,7 +223,7 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={
to->buf and to->len must be set.
*/
-void max_decimal(int precision, int frac, decimal *to)
+void max_decimal(int precision, int frac, decimal_t *to)
{
int intpart;
dec1 *buf= to->buf;
@@ -246,7 +250,7 @@ void max_decimal(int precision, int frac, decimal *to)
}
-static dec1 *remove_leading_zeroes(decimal *from, int *intg_result)
+static dec1 *remove_leading_zeroes(decimal_t *from, int *intg_result)
{
int intg= from->intg, i;
dec1 *buf0= from->buf;
@@ -277,7 +281,7 @@ static dec1 *remove_leading_zeroes(decimal *from, int *intg_result)
from number for processing
*/
-void decimal_optimize_fraction(decimal *from)
+void decimal_optimize_fraction(decimal_t *from)
{
int frac= from->frac, i;
dec1 *buf0= from->buf + ROUND_UP(from->intg) + ROUND_UP(frac) - 1;
@@ -324,7 +328,7 @@ void decimal_optimize_fraction(decimal *from)
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
*/
-int decimal2string(decimal *from, char *to, int *to_len,
+int decimal2string(decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler)
{
@@ -449,7 +453,7 @@ int decimal2string(decimal *from, char *to, int *to_len,
be written by this address
*/
-static void digits_bounds(decimal *from, int *start_result, int *end_result)
+static void digits_bounds(decimal_t *from, int *start_result, int *end_result)
{
int start, stop, i;
dec1 *buf_beg= from->buf;
@@ -516,7 +520,7 @@ static void digits_bounds(decimal *from, int *start_result, int *end_result)
'shift' have to be from 1 to DIG_PER_DEC1-1 (inclusive)
*/
-void do_mini_left_shift(decimal *dec, int shift, int beg, int last)
+void do_mini_left_shift(decimal_t *dec, int shift, int beg, int last)
{
dec1 *from= dec->buf + ROUND_UP(beg + 1) - 1;
dec1 *end= dec->buf + ROUND_UP(last) - 1;
@@ -546,7 +550,7 @@ void do_mini_left_shift(decimal *dec, int shift, int beg, int last)
'shift' have to be from 1 to DIG_PER_DEC1-1 (inclusive)
*/
-void do_mini_right_shift(decimal *dec, int shift, int beg, int last)
+void do_mini_right_shift(decimal_t *dec, int shift, int beg, int last)
{
dec1 *from= dec->buf + ROUND_UP(last) - 1;
dec1 *end= dec->buf + ROUND_UP(beg + 1) - 1;
@@ -579,7 +583,7 @@ void do_mini_right_shift(decimal *dec, int shift, int beg, int last)
E_DEC_TRUNCATED number was rounded to fit into buffer
*/
-int decimal_shift(decimal *dec, int shift)
+int decimal_shift(decimal_t *dec, int shift)
{
/* index of first non zero digit (all indexes from 0) */
int beg;
@@ -776,7 +780,8 @@ int decimal_shift(decimal *dec, int shift)
(to make error handling easier)
*/
-int internal_str2dec(const char *from, decimal *to, char **end, my_bool fixed)
+int
+internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed)
{
const char *s= from, *s1, *endp, *end_of_string= *end;
int i, intg, frac, error, intg1, frac1;
@@ -933,7 +938,7 @@ fatal_error:
E_DEC_OK
*/
-int decimal2double(decimal *from, double *to)
+int decimal2double(decimal_t *from, double *to)
{
double x=0, t=DIG_BASE;
int intg, frac;
@@ -959,7 +964,7 @@ int decimal2double(decimal *from, double *to)
E_DEC_OK/E_DEC_OVERFLOW/E_DEC_TRUNCATED
*/
-int double2decimal(double from, decimal *to)
+int double2decimal(double from, decimal_t *to)
{
/* TODO: fix it, when we'll have dtoa */
char s[400], *end;
@@ -968,7 +973,7 @@ int double2decimal(double from, decimal *to)
return string2decimal(s, to, &end);
}
-static int ull2dec(ulonglong from, decimal *to)
+static int ull2dec(ulonglong from, decimal_t *to)
{
int intg1, error=E_DEC_OK;
ulonglong x=from;
@@ -994,20 +999,20 @@ static int ull2dec(ulonglong from, decimal *to)
return error;
}
-int ulonglong2decimal(ulonglong from, decimal *to)
+int ulonglong2decimal(ulonglong from, decimal_t *to)
{
to->sign=0;
return ull2dec(from, to);
}
-int longlong2decimal(longlong from, decimal *to)
+int longlong2decimal(longlong from, decimal_t *to)
{
if ((to->sign= from < 0))
return ull2dec(-from, to);
return ull2dec(from, to);
}
-int decimal2ulonglong(decimal *from, ulonglong *to)
+int decimal2ulonglong(decimal_t *from, ulonglong *to)
{
dec1 *buf=from->buf;
ulonglong x=0;
@@ -1036,7 +1041,7 @@ int decimal2ulonglong(decimal *from, ulonglong *to)
return E_DEC_OK;
}
-int decimal2longlong(decimal *from, longlong *to)
+int decimal2longlong(decimal_t *from, longlong *to)
{
dec1 *buf=from->buf;
longlong x=0;
@@ -1108,7 +1113,7 @@ int decimal2longlong(decimal *from, longlong *to)
3. The first intg % DIG_PER_DEC1 digits are stored in the reduced
number of bytes (enough bytes to store this number of digits -
see dig2bytes)
- 4. same for frac - full decimal_digit's are stored as is,
+ 4. same for frac - full decimal_digit_t's are stored as is,
the last frac % DIG_PER_DEC1 digits - in the reduced number of bytes.
5. If the number is negative - every byte is inversed.
5. The very first bit of the resulting byte array is inverted (because
@@ -1118,7 +1123,7 @@ int decimal2longlong(decimal *from, longlong *to)
1234567890.1234
- internally is represented as 3 decimal_digit's
+ internally is represented as 3 decimal_digit_t's
1 234567890 123400000
@@ -1127,13 +1132,13 @@ int decimal2longlong(decimal *from, longlong *to)
00-00-00-01 0D-FB-38-D2 07-5A-EF-40
- now, middle decimal_digit is full - it stores 9 decimal digits. It goes
+ now, middle decimal_digit_t is full - it stores 9 decimal digits. It goes
into binary representation as is:
........... 0D-FB-38-D2 ............
- First decimal_digit has only one decimal digit. We can store one digit in
+ First decimal_digit_t has only one decimal digit. We can store one digit in
one byte, no need to waste four:
01 0D-FB-38-D2 ............
@@ -1151,7 +1156,7 @@ int decimal2longlong(decimal *from, longlong *to)
7E F2 04 37 2D FB 2D
*/
-int decimal2bin(decimal *from, char *to, int precision, int frac)
+int decimal2bin(decimal_t *from, char *to, int precision, int frac)
{
dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1;
int error=E_DEC_OK, intg=precision-frac,
@@ -1279,7 +1284,7 @@ int decimal2bin(decimal *from, char *to, int precision, int frac)
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
*/
-int bin2decimal(char *from, decimal *to, int precision, int scale)
+int bin2decimal(char *from, decimal_t *to, int precision, int scale)
{
int error=E_DEC_OK, intg=precision-scale,
intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
@@ -1420,7 +1425,9 @@ int decimal_bin_size(int precision, int scale)
E_DEC_OK/E_DEC_TRUNCATED
*/
-int decimal_round(decimal *from, decimal *to, int scale, decimal_round_mode mode)
+int
+decimal_round(decimal_t *from, decimal_t *to, int scale,
+ decimal_round_mode mode)
{
int frac0=scale>0 ? ROUND_UP(scale) : scale/DIG_PER_DEC1,
frac1=ROUND_UP(from->frac), round_digit,
@@ -1581,7 +1588,7 @@ done:
multiply by sizeof(dec1)
*/
-int decimal_result_size(decimal *from1, decimal *from2, char op, int param)
+int decimal_result_size(decimal_t *from1, decimal_t *from2, char op, int param)
{
switch (op) {
case '-':
@@ -1600,7 +1607,7 @@ int decimal_result_size(decimal *from1, decimal *from2, char op, int param)
return -1; /* shut up the warning */
}
-static int do_add(decimal *from1, decimal *from2, decimal *to)
+static int do_add(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
@@ -1676,7 +1683,7 @@ static int do_add(decimal *from1, decimal *from2, decimal *to)
/* to=from1-from2.
if to==0, return -1/0/+1 - the result of the comparison */
-static int do_sub(decimal *from1, decimal *from2, decimal *to)
+static int do_sub(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
@@ -1737,7 +1744,7 @@ static int do_sub(decimal *from1, decimal *from2, decimal *to)
/* ensure that always from1 > from2 (and intg1 >= intg2) */
if (carry)
{
- swap_variables(decimal *,from1,from1);
+ swap_variables(decimal_t *,from1,from1);
swap_variables(dec1 *,start1, start2);
swap_variables(int,intg1,intg2);
swap_variables(int,frac1,frac2);
@@ -1803,28 +1810,28 @@ static int do_sub(decimal *from1, decimal *from2, decimal *to)
return error;
}
-int decimal_add(decimal *from1, decimal *from2, decimal *to)
+int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
if (likely(from1->sign == from2->sign))
return do_add(from1, from2, to);
return do_sub(from1, from2, to);
}
-int decimal_sub(decimal *from1, decimal *from2, decimal *to)
+int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
if (likely(from1->sign == from2->sign))
return do_sub(from1, from2, to);
return do_add(from1, from2, to);
}
-int decimal_cmp(decimal *from1, decimal *from2)
+int decimal_cmp(decimal_t *from1, decimal_t *from2)
{
if (likely(from1->sign == from2->sign))
return do_sub(from1, from2, 0);
return from1->sign > from2->sign ? -1 : 1;
}
-int decimal_is_zero(decimal *from)
+int decimal_is_zero(decimal_t *from)
{
dec1 *buf1=from->buf,
*end=buf1+ROUND_UP(from->intg)+ROUND_UP(from->frac);
@@ -1855,7 +1862,7 @@ int decimal_is_zero(decimal *from)
XXX if this library is to be used with huge numbers of thousands of
digits, fast multiplication must be implemented.
*/
-int decimal_mul(decimal *from1, decimal *from2, decimal *to)
+int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
@@ -1926,16 +1933,16 @@ int decimal_mul(decimal *from1, decimal *from2, decimal *to)
XXX if this library is to be used with huge numbers of thousands of
digits, fast division must be implemented and alloca should be
changed to malloc (or at least fallback to malloc if alloca() fails)
- but then, decimal_mod() should be rewritten too :(
+ but then, decimal_mul() should be rewritten too :(
*/
-static int do_div_mod(decimal *from1, decimal *from2,
- decimal *to, decimal *mod, int scale_incr)
+static int do_div_mod(decimal_t *from1, decimal_t *from2,
+ decimal_t *to, decimal_t *mod, int scale_incr)
{
int frac1=ROUND_UP(from1->frac)*DIG_PER_DEC1, prec1=from1->intg+frac1,
frac2=ROUND_UP(from2->frac)*DIG_PER_DEC1, prec2=from2->intg+frac2,
- error, i, intg0, frac0, len1, len2, dlen1, dintg, div=(!mod);
+ error, i, intg0, frac0, len1, len2, dintg, div=(!mod);
dec1 *buf0, *buf1=from1->buf, *buf2=from2->buf, *tmp1,
- *start2, *stop2, *stop1, *stop0, norm2, carry, *start1;
+ *start2, *stop2, *stop1, *stop0, norm2, carry, *start1, dcarry;
dec2 norm_factor, x, guess, y;
LINT_INIT(error);
@@ -2036,7 +2043,7 @@ static int do_div_mod(decimal *from1, decimal *from2,
/* removing end zeroes */
while (*stop2 == 0 && stop2 >= start2)
stop2--;
- len2= ++stop2 - start2;
+ len2= stop2++ - start2;
/*
calculating norm2 (normalized *start2) - we need *start2 to be large
@@ -2048,87 +2055,70 @@ static int do_div_mod(decimal *from1, decimal *from2,
*/
norm_factor=DIG_BASE/(*start2+1);
norm2=(dec1)(norm_factor*start2[0]);
- if (likely(len2>1))
+ if (likely(len2>0))
norm2+=(dec1)(norm_factor*start2[1]/DIG_BASE);
+ if (*start1 < *start2)
+ dcarry=*start1++;
+ else
+ dcarry=0;
+
/* main loop */
- for ( ; buf0 < stop0; buf0++)
+ for (; buf0 < stop0; buf0++)
{
/* short-circuit, if possible */
- if (unlikely(*start1 == 0))
- {
- start1++;
- if (likely(div))
- *buf0=0;
- continue;
- }
-
- /* D3: make a guess */
- if (*start1 >= *start2)
- {
- x=start1[0];
- y=start1[1];
- dlen1=len2-1;
- }
+ if (unlikely(dcarry == 0 && *start1 < *start2))
+ guess=0;
else
{
- x=((dec2)start1[0])*DIG_BASE+start1[1];
- y=start1[2];
- dlen1=len2;
- }
- guess=(norm_factor*x+norm_factor*y/DIG_BASE)/norm2;
- if (unlikely(guess >= DIG_BASE))
- guess=DIG_BASE-1;
- if (likely(len2>1))
- {
- /* hmm, this is a suspicious trick - I removed normalization here */
- if (start2[1]*guess > (x-guess*start2[0])*DIG_BASE+y)
- guess--;
- if (unlikely(start2[1]*guess > (x-guess*start2[0])*DIG_BASE+y))
- guess--;
- DBUG_ASSERT(start2[1]*guess <= (x-guess*start2[0])*DIG_BASE+y);
- }
-
- /* D4: multiply and subtract */
- buf2=stop2;
- buf1=start1+dlen1;
- DBUG_ASSERT(buf1 < stop1);
- for (carry=0; buf2 > start2; buf1--)
- {
- dec1 hi, lo;
- x=guess * (*--buf2);
- hi=(dec1)(x/DIG_BASE);
- lo=(dec1)(x-((dec2)hi)*DIG_BASE);
- SUB2(*buf1, *buf1, lo, carry);
- carry+=hi;
- }
- for (; buf1 >= start1; buf1--)
- {
- SUB2(*buf1, *buf1, 0, carry);
- }
+ /* D3: make a guess */
+ x=start1[0]+((dec2)dcarry)*DIG_BASE;
+ y=start1[1];
+ guess=(norm_factor*x+norm_factor*y/DIG_BASE)/norm2;
+ if (unlikely(guess >= DIG_BASE))
+ guess=DIG_BASE-1;
+ if (likely(len2>0))
+ {
+ /* hmm, this is a suspicious trick - I removed normalization here */
+ if (start2[1]*guess > (x-guess*start2[0])*DIG_BASE+y)
+ guess--;
+ if (unlikely(start2[1]*guess > (x-guess*start2[0])*DIG_BASE+y))
+ guess--;
+ DBUG_ASSERT(start2[1]*guess <= (x-guess*start2[0])*DIG_BASE+y);
+ }
- /* D5: check the remainder */
- if (unlikely(carry))
- {
- DBUG_ASSERT(carry==1);
- /* D6: correct the guess */
- guess--;
+ /* D4: multiply and subtract */
buf2=stop2;
- buf1=start1+dlen1;
+ buf1=start1+len2;
+ DBUG_ASSERT(buf1 < stop1);
for (carry=0; buf2 > start2; buf1--)
{
- ADD(*buf1, *buf1, *--buf2, carry);
+ dec1 hi, lo;
+ x=guess * (*--buf2);
+ hi=(dec1)(x/DIG_BASE);
+ lo=(dec1)(x-((dec2)hi)*DIG_BASE);
+ SUB2(*buf1, *buf1, lo, carry);
+ carry+=hi;
}
- for (; buf1 >= start1; buf1--)
+ carry= dcarry < carry;
+
+ /* D5: check the remainder */
+ if (unlikely(carry))
{
- SUB2(*buf1, *buf1, 0, carry);
+ /* D6: correct the guess */
+ guess--;
+ buf2=stop2;
+ buf1=start1+len2;
+ for (carry=0; buf2 > start2; buf1--)
+ {
+ ADD(*buf1, *buf1, *--buf2, carry);
+ }
}
- DBUG_ASSERT(carry==1);
}
if (likely(div))
*buf0=(dec1)guess;
- if (*start1 == 0)
- start1++;
+ dcarry= *start1;
+ start1++;
}
if (mod)
{
@@ -2137,6 +2127,8 @@ static int do_div_mod(decimal *from1, decimal *from2,
intg=prec1-frac1
frac=max(frac1, frac2)=to->frac
*/
+ if (dcarry)
+ *--start1=dcarry;
buf0=to->buf;
intg0=ROUND_UP(prec1-frac1)-(start1-tmp1);
frac0=ROUND_UP(to->frac);
@@ -2204,7 +2196,8 @@ done:
see do_div_mod()
*/
-int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr)
+int
+decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to, int scale_incr)
{
return do_div_mod(from1, from2, to, 0, scale_incr);
}
@@ -2236,7 +2229,7 @@ int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr)
thus, there's no requirement for M or N to be integers
*/
-int decimal_mod(decimal *from1, decimal *from2, decimal *to)
+int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
return do_div_mod(from1, from2, 0, to, 0);
}
@@ -2244,10 +2237,10 @@ int decimal_mod(decimal *from1, decimal *from2, decimal *to)
#ifdef MAIN
int full= 0;
-decimal a, b, c;
+decimal_t a, b, c;
char buf1[100], buf2[100], buf3[100];
-void dump_decimal(decimal *d)
+void dump_decimal(decimal_t *d)
{
int i;
printf("/* intg=%d, frac=%d, sign=%d, buf[]={", d->intg, d->frac, d->sign);
@@ -2267,7 +2260,7 @@ void check_result_code(int actual, int want)
}
-void print_decimal(decimal *d, const char *orig, int actual, int want)
+void print_decimal(decimal_t *d, const char *orig, int actual, int want)
{
char s[100];
int slen=sizeof(s);
@@ -2745,6 +2738,8 @@ int main()
test_dv("1.000000000000", "3","0.333333333333333333", 0);
test_dv("1", "1","1.000000000", 0);
test_dv("0.0123456789012345678912345", "9999999999","0.000000000001234567890246913578148141", 0);
+ test_dv("10.333000000", "12.34500","0.837019036046982584042122316", 0);
+ test_dv("10.000000000060", "2","5.000000000030000000", 0);
printf("==== decimal_mod ====\n");
test_md("234","10","4", 0);
diff --git a/strings/my_strtoll10-x86.s b/strings/my_strtoll10-x86.s
index e89e7ff5989..c04384667a7 100644
--- a/strings/my_strtoll10-x86.s
+++ b/strings/my_strtoll10-x86.s
@@ -394,7 +394,7 @@ my_strtoll10:
popl %ebp
ret
-my_strtoll10_end:
+.my_strtoll10_end:
.size my_strtoll10,.my_strtoll10_end-my_strtoll10
.comm res,240,32
.comm end_ptr,120,32
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 9e5c7ea6983..2735ad91c6e 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -99,10 +99,23 @@ parse_manager_arguments() {
}
wait_for_pid () {
- for((i=0; i<35; i++)); do
+ i=0
+ while test $i -lt 35 ; do
sleep 1
- test -s $pid_file && i='' && break
+ case "$1" in
+ 'created')
+ test -s $pid_file && i='' && break
+ ;;
+ 'removed')
+ test ! -s $pid_file && i='' && break
+ ;;
+ *)
+ echo "wait_for_pid () usage: wait_for_pid created|removed"
+ exit 1
+ ;;
+ esac
echo $echo_n ".$echo_c"
+ i=`expr $i + 1`
done
if test -z "$i" ; then
@@ -196,7 +209,7 @@ case "$mode" in
# be overwritten at next upgrade.
echo $echo_n "Starting MySQL"
$sbindir/mysqlmanager $USER_OPTION --pid-file=$pid_file >/dev/null 2>&1 &
- wait_for_pid
+ wait_for_pid created
# Make lock for RedHat / SuSE
if test -w /var/lock/subsys
@@ -217,7 +230,7 @@ case "$mode" in
echo $echo_n "Shutting down MySQL"
kill $mysqlmanager_pid
# mysqlmanager should remove the pid_file when it exits, so wait for it.
- wait_for_pid
+ wait_for_pid removed
# delete lock for RedHat / SuSE
if test -f /var/lock/subsys/mysqlmanager
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 1231df6a1a5..bad340e9de1 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -694,8 +694,8 @@ fi
%changelog
* Fri Mar 18 2005 Lenz Grimmer <lenz@mysql.com>
-- Disabled RAID in the Max binares once and for all (it has finally been removed
- from the source tree)
+- Disabled RAID in the Max binaries once and for all (it has finally been
+ removed from the source tree)
* Sun Feb 20 2005 Petr Chardin <petr@mysql.com>
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 073c30b1e4d..0f117b640c3 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -12704,6 +12704,7 @@ from t2);");
static void test_bug8378()
{
+#ifdef HAVE_CHARSET_gbk
MYSQL *lmysql;
char out[9]; /* strlen(TEST_BUG8378)*2+1 */
int len;
@@ -12738,6 +12739,115 @@ static void test_bug8378()
DIE_UNLESS(memcmp(out, TEST_BUG8378_OUT, len) == 0);
mysql_close(lmysql);
+#endif
+}
+
+
+static void test_bug8722()
+{
+ MYSQL_STMT *stmt;
+ int rc;
+ const char *stmt_text;
+
+ myheader("test_bug8722");
+ /* Prepare test data */
+ stmt_text= "drop table if exists t1, v1";
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+ stmt_text= "CREATE TABLE t1 (c1 varchar(10), c2 varchar(10), c3 varchar(10),"
+ " c4 varchar(10), c5 varchar(10), c6 varchar(10),"
+ " c7 varchar(10), c8 varchar(10), c9 varchar(10),"
+ "c10 varchar(10))";
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+ stmt_text= "INSERT INTO t1 VALUES (1,2,3,4,5,6,7,8,9,10)";
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+ stmt_text= "CREATE VIEW v1 AS SELECT * FROM t1";
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+ /* Note: if you uncomment following block everything works fine */
+/*
+ rc= mysql_query(mysql, "sellect * from v1");
+ myquery(rc);
+ mysql_free_result(mysql_store_result(mysql));
+*/
+
+ stmt= mysql_stmt_init(mysql);
+ stmt_text= "select * from v1";
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ check_execute(stmt, rc);
+ mysql_stmt_close(stmt);
+ stmt_text= "drop table if exists t1, v1";
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+}
+
+
+MYSQL_STMT *open_cursor(char *query)
+{
+ int rc;
+ const ulong type= (ulong)CURSOR_TYPE_READ_ONLY;
+
+ MYSQL_STMT *stmt= mysql_stmt_init(mysql);
+ rc= mysql_stmt_prepare(stmt, query, strlen(query));
+ check_execute(stmt, rc);
+
+ mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type);
+ return stmt;
+}
+
+
+static void test_bug8880()
+{
+ MYSQL_STMT *stmt_list[2], **stmt;
+ MYSQL_STMT **stmt_list_end= (MYSQL_STMT**) stmt_list + 2;
+ int rc;
+
+ myheader("test_bug8880");
+
+ mysql_query(mysql, "drop table if exists t1");
+ mysql_query(mysql, "create table t1 (a int not null primary key, b int)");
+ rc= mysql_query(mysql, "insert into t1 values (1,1)");
+ myquery(rc); /* one check is enough */
+ /*
+ when inserting 2 rows everything works well
+ mysql_query(mysql, "INSERT INTO t1 VALUES (1,1),(2,2)");
+ */
+ for (stmt= stmt_list; stmt < stmt_list_end; stmt++)
+ *stmt= open_cursor("select a from t1");
+ for (stmt= stmt_list; stmt < stmt_list_end; stmt++)
+ {
+ rc= mysql_stmt_execute(*stmt);
+ check_execute(*stmt, rc);
+ }
+ for (stmt= stmt_list; stmt < stmt_list_end; stmt++)
+ mysql_stmt_close(*stmt);
+}
+
+
+static void test_bug9159()
+{
+ MYSQL_STMT *stmt;
+ int rc;
+ const char *stmt_text= "select a, b from t1";
+ const unsigned long type= CURSOR_TYPE_READ_ONLY;
+
+ myheader("test_bug9159");
+
+ mysql_query(mysql, "drop table if exists t1");
+ mysql_query(mysql, "create table t1 (a int not null primary key, b int)");
+ rc= mysql_query(mysql, "insert into t1 values (1,1)");
+ myquery(rc);
+
+ stmt= mysql_stmt_init(mysql);
+ mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void *)&type);
+
+ mysql_stmt_execute(stmt);
+ mysql_stmt_close(stmt);
+ rc= mysql_query(mysql, "drop table if exists t1");
+ myquery(rc);
}
/*
@@ -12962,6 +13072,9 @@ static struct my_tests_st my_tests[]= {
{ "test_bug8330", test_bug8330 },
{ "test_bug7990", test_bug7990 },
{ "test_bug8378", test_bug8378 },
+ { "test_bug8722", test_bug8722 },
+ { "test_bug8880", test_bug8880 },
+ { "test_bug9159", test_bug9159 },
{ 0, 0 }
};
diff --git a/vio/test-ssl.c b/vio/test-ssl.c
index 88df6936a1f..a94eb1a21ff 100644
--- a/vio/test-ssl.c
+++ b/vio/test-ssl.c
@@ -115,7 +115,7 @@ main(int argc, char** argv)
{
/* child, therefore, client */
char xbuf[100];
- int r = client_vio->read(client_vio,xbuf, sizeof(xbuf));
+ int r = vio_read(client_vio,xbuf, sizeof(xbuf));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
@@ -130,7 +130,7 @@ main(int argc, char** argv)
else
{
const char* s = "Huhuhuh";
- int r = server_vio->write(server_vio,(gptr)s, strlen(s));
+ int r = vio_write(server_vio,(gptr)s, strlen(s));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c
index 231ce056d8c..3811ba0fb6a 100644
--- a/vio/test-sslclient.c
+++ b/vio/test-sslclient.c
@@ -77,13 +77,13 @@ main( int argc __attribute__((unused)),
sa.sin_port = htons (1111); /* Server Port number */
err = connect(client_vio->sd, (struct sockaddr*) &sa,
- sizeof(sa));
+ sizeof(sa));
/* ----------------------------------------------- */
/* Now we have TCP conncetion. Start SSL negotiation. */
read(client_vio->sd,xbuf, sizeof(xbuf));
sslconnect(ssl_connector,client_vio,60L);
- err = client_vio->read(client_vio,xbuf, sizeof(xbuf));
+ err = vio_read(client_vio,xbuf, sizeof(xbuf));
if (err<=0) {
my_free((gptr)ssl_connector,MYF(0));
fatal_error("client:SSL_read");
diff --git a/zlib/ChangeLog b/zlib/ChangeLog
index 243a5062fae..1af7633d668 100644
--- a/zlib/ChangeLog
+++ b/zlib/ChangeLog
@@ -6,6 +6,48 @@ in MySQL distribution. If you are working on porting MySQL to one of rare
platforms, you might find worth looking at the original zlib distribution
and using appropriate Makefiles/project files from it.
+Changes in 1.2.2 (3 October 2004)
+- Update zlib.h comments on gzip in-memory processing
+- Set adler to 1 in inflateReset() to support Java test suite [Walles]
+- Add contrib/dotzlib [Ravn]
+- Update win32/DLL_FAQ.txt [Truta]
+- Update contrib/minizip [Vollant]
+- Move contrib/visual-basic.txt to old/ [Truta]
+- Fix assembler builds in projects/visualc6/ [Truta]
+
+Changes in 1.2.1.2 (9 September 2004)
+- Update INDEX file
+- Fix trees.c to update strm->data_type (no one ever noticed!)
+- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
+- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
+- Add limited multitasking protection to DYNAMIC_CRC_TABLE
+- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
+- Don't declare strerror() under VMS [Mozilla]
+- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
+- Update contrib/ada [Anisimkov]
+- Update contrib/minizip [Vollant]
+- Fix configure to not hardcode directories for Darwin [Peterson]
+- Fix gzio.c to not return error on empty files [Brown]
+- Fix indentation; update version in contrib/delphi/ZLib.pas and
+ contrib/pascal/zlibpas.pas [Truta]
+- Update mkasm.bat in contrib/masmx86 [Truta]
+- Update contrib/untgz [Truta]
+- Add projects/README.projects [Truta]
+- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
+- Update win32/DLL_FAQ.txt [Truta]
+- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
+- Remove an unnecessary assignment to curr in inftrees.c [Truta]
+- Add OS/2 to exe builds in configure [Poltorak]
+- Remove err dummy parameter in zlib.h [Kientzle]
+
+Changes in 1.2.1.1 (9 January 2004)
+- Update email address in README
+- Several FAQ updates
+- Fix a big fat bug in inftrees.c that prevented decoding valid
+ dynamic blocks with only literals and no distance codes --
+ Thanks to "Hot Emu" for the bug report and sample file
+- Add a note to puff.c on no distance codes case.
+
Changes in 1.2.1 (17 November 2003)
- Remove a tab in contrib/gzappend/gzappend.c
- Update some interfaces in contrib for new zlib functions
diff --git a/zlib/FAQ b/zlib/FAQ
index 7115ec38d60..4f61f1094e6 100644
--- a/zlib/FAQ
+++ b/zlib/FAQ
@@ -21,18 +21,18 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
3. Where can I get a Visual Basic interface to zlib?
See
- * http://www.winimage.com/zLibDll/
* http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm
* contrib/visual-basic.txt in the zlib distribution
+ * win32/DLL_FAQ.txt in the zlib distribution
- 4. compress() returns Z_BUF_ERROR
+ 4. compress() returns Z_BUF_ERROR.
Make sure that before the call of compress, the length of the compressed
buffer is equal to the total size of the compressed buffer and not
zero. For Visual Basic, check that this parameter is passed by reference
("as any"), not by value ("as long").
- 5. deflate() or inflate() returns Z_BUF_ERROR
+ 5. deflate() or inflate() returns Z_BUF_ERROR.
Before making the call, make sure that avail_in and avail_out are not
zero. When setting the parameter flush equal to Z_FINISH, also make sure
@@ -47,8 +47,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
It's in zlib.h for the moment, and Francis S. Lin has converted it to a
web page zlib.html. Volunteers to transform this to Unix-style man pages,
- please contact Jean-loup Gailly (jloup@gzip.org). Examples of zlib usage
- are in the files example.c and minigzip.c.
+ please contact us (zlib@gzip.org). Examples of zlib usage are in the files
+ example.c and minigzip.c.
7. Why don't you use GNU autoconf or libtool or ...?
@@ -77,7 +77,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
11. Can zlib handle .zip archives?
- See the directory contrib/minizip in the zlib distribution.
+ Not by itself, no. See the directory contrib/minizip in the zlib
+ distribution.
12. Can zlib handle .Z files?
@@ -92,6 +93,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
14. How do I install a shared zlib library on Unix?
+ After the above, then:
+
make install
However, many flavors of Unix come with a shared zlib already installed.
@@ -99,12 +102,31 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
trying to install it, you may want to check if it's already there! If you
can #include <zlib.h>, it's there. The -lz option will probably link to it.
-15. I have a question about OttoPDF
+15. I have a question about OttoPDF.
We are not the authors of OttoPDF. The real author is on the OttoPDF web
- site Joel Hainley jhainley@myndkryme.com.
+ site: Joel Hainley, jhainley@myndkryme.com.
+
+16. Can zlib decode Flate data in an Adobe PDF file?
+
+ Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ .
+ To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ .
+
+17. Why am I getting this "register_frame_info not found" error on Solaris?
+
+ After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
+ generates an error such as:
+
+ ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
+ symbol __register_frame_info: referenced symbol not found
+
+ The symbol __register_frame_info is not part of zlib, it is generated by
+ the C compiler (cc or gcc). You must recompile applications using zlib
+ which have this problem. This problem is specific to Solaris. See
+ http://www.sunfreeware.com for Solaris versions of zlib and applications
+ using zlib.
-16. Why does gzip give an error on a file I make with compress/deflate?
+18. Why does gzip give an error on a file I make with compress/deflate?
The compress and deflate functions produce data in the zlib format, which
is different and incompatible with the gzip format. The gz* functions in
@@ -112,7 +134,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
formats use the same compressed data format internally, but have different
headers and trailers around the compressed data.
-17. Ok, so why are there two different formats?
+19. Ok, so why are there two different formats?
The gzip format was designed to retain the directory information about
a single file, such as the name and last modification date. The zlib
@@ -120,7 +142,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
channel applications, and has a much more compact header and trailer and
uses a faster integrity check than gzip.
-18. Well that's nice, but how do I make a gzip file in memory?
+20. Well that's nice, but how do I make a gzip file in memory?
You can request that deflate write the gzip format instead of the zlib
format using deflateInit2(). You can also request that inflate decode
@@ -133,7 +155,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
function and roll your own gzip encoding and decoding. Read the gzip
RFC 1952 for details of the header and trailer format.
-19. Is zlib thread-safe?
+21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
provided memory allocation routines must also be thread-safe. zlib's gz*
@@ -144,15 +166,15 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
-20. Can I use zlib in my commercial application?
+22. Can I use zlib in my commercial application?
Yes. Please read the license in zlib.h.
-21. Is zlib under the GNU license?
+23. Is zlib under the GNU license?
No. Please read the license in zlib.h.
-22. The license says that altered source versions must be "plainly marked". So
+24. The license says that altered source versions must be "plainly marked". So
what exactly do I need to do to meet that requirement?
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
@@ -175,24 +197,24 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
in zlib.h as you would for a full source distribution.
-23. Will zlib work on a big-endian or little-endian architecture, and can I
+25. Will zlib work on a big-endian or little-endian architecture, and can I
exchange compressed data between them?
Yes and yes.
-24. Will zlib work on a 64-bit machine?
+26. Will zlib work on a 64-bit machine?
It should. It has been tested on 64-bit machines, and has no dependence
on any data types being limited to 32-bits in length. If you have any
difficulties, please provide a complete problem report to zlib@gzip.org
-25. Will zlib decompress data from the PKWare Data Compression Library?
+27. Will zlib decompress data from the PKWare Data Compression Library?
No. The PKWare DCL uses a completely different compressed data format
than does PKZIP and zlib. However, you can look in zlib's contrib/blast
directory for a possible solution to your problem.
-26. Can I access data randomly in a compressed stream?
+28. Can I access data randomly in a compressed stream?
No, not without some preparation. If when compressing you periodically
use Z_FULL_FLUSH, carefully write all the pending data at those points,
@@ -200,27 +222,27 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
at those points. You have to be careful to not use Z_FULL_FLUSH too
often, since it can significantly degrade compression.
-27. Does zlib work on MVS, OS/390, CICS, etc.?
+29. Does zlib work on MVS, OS/390, CICS, etc.?
We don't know for sure. We have heard occasional reports of success on
these systems. If you do use it on one of these, please provide us with
a report, instructions, and patches that we can reference when we get
these questions. Thanks.
-28. Is there some simpler, easier to read version of inflate I can look at
+30. Is there some simpler, easier to read version of inflate I can look at
to understand the deflate format?
First off, you should read RFC 1951. Second, yes. Look in zlib's
contrib/puff directory.
-29. Does zlib infringe on any patents?
+31. Does zlib infringe on any patents?
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
http://www.gzip.org/#faq11
-30. Can zlib work with greater than 4 GB of data?
+32. Can zlib work with greater than 4 GB of data?
Yes. inflate() and deflate() will process any amount of data correctly.
Each call of inflate() or deflate() is limited to input and output chunks
@@ -238,7 +260,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
only if the compiler's "long" type is 32 bits. If the compiler's "long"
type is 64 bits, then the limit is 16 exabytes.
-31. Does zlib have any security vulnerabilities?
+33. Does zlib have any security vulnerabilities?
The only one that we are aware of is potentially in gzprintf(). If zlib
is compiled to use sprintf() or vsprintf(), then there is no protection
@@ -258,35 +280,35 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
Note that you should be using the most recent version of zlib. Versions
1.1.3 and before were subject to a double-free vulnerability.
-32. Is there a Java version of zlib?
+34. Is there a Java version of zlib?
Probably what you want is to use zlib in Java. zlib is already included
as part of the Java SDK in the java.util.zip package. If you really want
a version of zlib written in the Java language, look on the zlib home
page for links: http://www.zlib.org/
-33. I get this or that compiler or source-code scanner warning when I crank it
- up to maximally-pendantic. Can't you guys write proper code?
+35. I get this or that compiler or source-code scanner warning when I crank it
+ up to maximally-pedantic. Can't you guys write proper code?
Many years ago, we gave up attempting to avoid warnings on every compiler
in the universe. It just got to be a waste of time, and some compilers
were downright silly. So now, we simply make sure that the code always
works.
-34. Will zlib read the (insert any ancient or arcane format here) compressed
+36. Will zlib read the (insert any ancient or arcane format here) compressed
data format?
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
-35. How can I encrypt/decrypt zip files with zlib?
+37. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very weak
and can be broken with freely available programs. To get strong encryption,
- use gpg ( http://www.gnupg.org/ ) which already includes zlib compression.
+ use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
For PKZIP compatible "encryption", look at http://www.info-zip.org/
-36. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
+38. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion
@@ -302,14 +324,14 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
Bottom line: use the gzip format for HTTP 1.1 encoding.
-37. Does zlib support the new "Deflate64" format introduced by PKWare?
+39. Does zlib support the new "Deflate64" format introduced by PKWare?
No. PKWare has apparently decided to keep that format proprietary, since
they have not documented it as they have previous compression formats.
In any case, the compression improvements are so modest compared to other
more modern approaches, that it's not worth the effort to implement.
-38. Can you please sign these lengthy legal documents and fax them back to us
+40. Can you please sign these lengthy legal documents and fax them back to us
so that we can use your software in our product?
No. Go away. Shoo.
diff --git a/zlib/INDEX b/zlib/INDEX
index a9de7844d16..0587e5902bd 100644
--- a/zlib/INDEX
+++ b/zlib/INDEX
@@ -8,9 +8,12 @@ algorithm.txt description of the (de)compression algorithm
configure configure script for Unix
zconf.in.h template for zconf.h (used by configure)
+amiga/ makefiles for Amiga SAS C
+as400/ makefiles for IBM AS/400
msdos/ makefiles for MSDOS
old/ makefiles for various architectures and zlib documentation
files that have not yet been updated for zlib 1.2.x
+projects/ projects for various Integrated Development Environments
qnx/ makefiles for QNX
win32/ makefiles for Windows
diff --git a/zlib/README b/zlib/README
index 0f1205481c1..df95ae13f54 100644
--- a/zlib/README
+++ b/zlib/README
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.1 is a general purpose data compression library. All the code is
+zlib 1.2.2 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@@ -34,7 +34,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
-The changes made in version 1.2.1 are documented in the file ChangeLog.
+The changes made in version 1.2.2 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
@@ -46,7 +46,7 @@ A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
CPAN (Comprehensive Perl Archive Network) sites
http://www.cpan.org/modules/by-module/Compress/
-A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> is
+A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
http://www.python.org/doc/lib/module-zlib.html
@@ -93,7 +93,7 @@ Acknowledgments:
Copyright notice:
- (C) 1995-2003 Jean-loup Gailly and Mark Adler
+ (C) 1995-2004 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/zlib/crc32.c b/zlib/crc32.c
index 689b2883b43..b39c7e1253e 100644
--- a/zlib/crc32.c
+++ b/zlib/crc32.c
@@ -11,6 +11,14 @@
/* @(#) $Id$ */
+/*
+ Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
+ protection on the static variables used to control the first-use generation
+ of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
+ first call get_crc_table() to initialize the tables before allowing more than
+ one thread to use crc32().
+ */
+
#ifdef MAKECRCH
# include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE
@@ -58,7 +66,7 @@
#ifdef DYNAMIC_CRC_TABLE
-local int crc_table_empty = 1;
+local volatile int crc_table_empty = 1;
local unsigned long FAR crc_table[TBLS][256];
local void make_crc_table OF((void));
#ifdef MAKECRCH
@@ -95,38 +103,51 @@ local void make_crc_table()
{
unsigned long c;
int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
+ unsigned long poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
+ static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
+ /* See if another task is already doing this (not thread-safe, but better
+ than nothing -- significantly reduces duration of vulnerability in
+ case the advice about DYNAMIC_CRC_TABLE is ignored) */
+ if (first) {
+ first = 0;
+
+ /* make exclusive-or pattern from polynomial (0xedb88320UL) */
+ poly = 0UL;
+ for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
+ poly |= 1UL << (31 - p[n]);
+
+ /* generate a crc for every 8-bit value */
+ for (n = 0; n < 256; n++) {
+ c = (unsigned long)n;
+ for (k = 0; k < 8; k++)
+ c = c & 1 ? poly ^ (c >> 1) : c >> 1;
+ crc_table[0][n] = c;
+ }
#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros, and
- then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
+ /* generate crc for each value followed by one, two, and three zeros,
+ and then the byte reversal of those as well as the first table */
+ for (n = 0; n < 256; n++) {
+ c = crc_table[0][n];
+ crc_table[4][n] = REV(c);
+ for (k = 1; k < 4; k++) {
+ c = crc_table[0][c & 0xff] ^ (c >> 8);
+ crc_table[k][n] = c;
+ crc_table[k + 4][n] = REV(c);
+ }
}
- }
#endif /* BYFOUR */
- crc_table_empty = 0;
+ crc_table_empty = 0;
+ }
+ else { /* not first */
+ /* wait for the other guy to finish (not efficient, but rare) */
+ while (crc_table_empty)
+ ;
+ }
#ifdef MAKECRCH
/* write out CRC tables to crc32.h */
@@ -180,9 +201,10 @@ local void write_table(out, table)
const unsigned long FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty) make_crc_table();
+ if (crc_table_empty)
+ make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
+ return (const unsigned long FAR *)crc_table;
}
/* ========================================================================= */
diff --git a/zlib/deflate.c b/zlib/deflate.c
index 0525b2f33ca..0fc53bc1e82 100644
--- a/zlib/deflate.c
+++ b/zlib/deflate.c
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2004 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.1 Copyright 1995-2003 Jean-loup Gailly ";
+ " deflate 1.2.2 Copyright 1995-2004 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
diff --git a/zlib/deflate.h b/zlib/deflate.h
index e31f66be521..410681d18a4 100644
--- a/zlib/deflate.h
+++ b/zlib/deflate.h
@@ -95,7 +95,6 @@ typedef struct internal_state {
Bytef *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- Byte data_type; /* UNKNOWN, BINARY or ASCII */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
diff --git a/zlib/gzio.c b/zlib/gzio.c
index 4afd102b3f3..5e71b0ab3ae 100644
--- a/zlib/gzio.c
+++ b/zlib/gzio.c
@@ -455,6 +455,10 @@ int ZEXPORT gzread (file, buf, len)
s->z_err = Z_ERRNO;
break;
}
+ if (feof(s->file)) { /* avoid error for empty file */
+ s->z_err = Z_STREAM_END;
+ break;
+ }
}
s->stream.next_in = s->inbuf;
}
diff --git a/zlib/infback.c b/zlib/infback.c
index 110b03b857f..262f97c73ac 100644
--- a/zlib/infback.c
+++ b/zlib/infback.c
@@ -434,6 +434,9 @@ void FAR *out_desc;
}
}
+ /* handle error breaks in while */
+ if (state->mode == BAD) break;
+
/* build code tables */
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
diff --git a/zlib/inffast.c b/zlib/inffast.c
index c716440a92a..8c02a178d04 100644
--- a/zlib/inffast.c
+++ b/zlib/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -19,7 +19,7 @@
- none
No measurable difference:
- Pentium III (Anderson)
- - 68060 (Nikl)
+ - M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0
diff --git a/zlib/inflate.c b/zlib/inflate.c
index a53b5c7446e..c6d38266d07 100644
--- a/zlib/inflate.c
+++ b/zlib/inflate.c
@@ -109,6 +109,7 @@ z_streamp strm;
state = (struct inflate_state FAR *)strm->state;
strm->total_in = strm->total_out = state->total = 0;
strm->msg = Z_NULL;
+ strm->adler = 1; /* to support ill-conceived Java test suite */
state->mode = HEAD;
state->last = 0;
state->havedict = 0;
@@ -861,6 +862,9 @@ int flush;
}
}
+ /* handle error breaks in while */
+ if (state->mode == BAD) break;
+
/* build code tables */
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
diff --git a/zlib/inftrees.c b/zlib/inftrees.c
index 3bb56398e1c..8a896b28793 100644
--- a/zlib/inftrees.c
+++ b/zlib/inftrees.c
@@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
+ " inflate 1.2.2 Copyright 1995-2004 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 76, 66};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -114,7 +114,15 @@ unsigned short FAR *work;
for (max = MAXBITS; max >= 1; max--)
if (count[max] != 0) break;
if (root > max) root = max;
- if (max == 0) return -1; /* no codes! */
+ if (max == 0) { /* no symbols to code at all */
+ this.op = (unsigned char)64; /* invalid code marker */
+ this.bits = (unsigned char)1;
+ this.val = (unsigned short)0;
+ *(*table)++ = this; /* make a table to force an error */
+ *(*table)++ = this;
+ *bits = 1;
+ return 0; /* no symbols, but wait for decoding to report error */
+ }
for (min = 1; min <= MAXBITS; min++)
if (count[min] != 0) break;
if (root < min) root = min;
@@ -295,7 +303,6 @@ unsigned short FAR *work;
drop = 0;
len = root;
next = *table;
- curr = root;
this.bits = (unsigned char)len;
}
diff --git a/zlib/trees.c b/zlib/trees.c
index bb09554938b..52c820fa2e9 100644
--- a/zlib/trees.c
+++ b/zlib/trees.c
@@ -931,7 +931,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (s->level > 0) {
/* Check if the file is ascii or binary */
- if (s->data_type == Z_UNKNOWN) set_data_type(s);
+ if (s->strm->data_type == Z_UNKNOWN) set_data_type(s);
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
@@ -1131,7 +1131,7 @@ local void set_data_type(s)
while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
- s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
+ s->strm->data_type = bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII;
}
/* ===========================================================================
diff --git a/zlib/zconf.h b/zlib/zconf.h
index 3cea897eda7..3c21403fce6 100644
--- a/zlib/zconf.h
+++ b/zlib/zconf.h
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2004 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -13,43 +13,46 @@
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflatePrime z_deflatePrime
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
+# define deflateInit_ z_deflateInit_
+# define deflate z_deflate
+# define deflateEnd z_deflateEnd
+# define inflateInit_ z_inflateInit_
+# define inflate z_inflate
+# define inflateEnd z_inflateEnd
+# define deflateInit2_ z_deflateInit2_
+# define deflateSetDictionary z_deflateSetDictionary
+# define deflateCopy z_deflateCopy
+# define deflateReset z_deflateReset
+# define deflateParams z_deflateParams
+# define deflateBound z_deflateBound
+# define deflatePrime z_deflatePrime
+# define inflateInit2_ z_inflateInit2_
+# define inflateSetDictionary z_inflateSetDictionary
+# define inflateSync z_inflateSync
+# define inflateSyncPoint z_inflateSyncPoint
+# define inflateCopy z_inflateCopy
+# define inflateReset z_inflateReset
+# define inflateBack z_inflateBack
+# define inflateBackEnd z_inflateBackEnd
+# define compress z_compress
+# define compress2 z_compress2
+# define compressBound z_compressBound
+# define uncompress z_uncompress
+# define adler32 z_adler32
+# define crc32 z_crc32
+# define get_crc_table z_get_crc_table
+# define zError z_zError
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
+# define Byte z_Byte
+# define uInt z_uInt
+# define uLong z_uLong
+# define Bytef z_Bytef
+# define charf z_charf
+# define intf z_intf
+# define uIntf z_uIntf
+# define uLongf z_uLongf
+# define voidpf z_voidpf
+# define voidp z_voidp
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
@@ -281,7 +284,7 @@ typedef uLong FAR uLongf;
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
-# define z_off_t off_t
+# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
@@ -289,11 +292,11 @@ typedef uLong FAR uLongf;
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
-# define z_off_t long
+# define z_off_t long
#endif
#if defined(__OS400__)
-#define NO_vsnprintf
+# define NO_vsnprintf
#endif
#if defined(__MVS__)
diff --git a/zlib/zlib.3 b/zlib/zlib.3
index 890098449dd..3139e2467f2 100644
--- a/zlib/zlib.3
+++ b/zlib/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "17 November 2003"
+.TH ZLIB 3 "3 October 2004"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -133,8 +133,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
-Version 1.2.1
-Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org)
+Version 1.2.2
+Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
This software is provided "as-is,"
diff --git a/zlib/zlib.h b/zlib/zlib.h
index 92edf96ff3e..b4ddd34395c 100644
--- a/zlib/zlib.h
+++ b/zlib/zlib.h
@@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.1, November 17th, 2003
+ version 1.2.2, October 3rd, 2004
- Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -37,8 +37,8 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.2.1"
-#define ZLIB_VERNUM 0x1210
+#define ZLIB_VERSION "1.2.2"
+#define ZLIB_VERNUM 0x1220
/*
The 'zlib' compression library provides in-memory compression and
@@ -53,24 +53,22 @@ extern "C" {
application must provide more input and/or consume the output
(providing more output space) before each call.
- The compressed data format used by the in-memory functions is the zlib
- format, which is a zlib wrapper documented in RFC 1950, wrapped around a
- deflate stream, which is itself documented in RFC 1951.
+ The compressed data format used by default by the in-memory functions is
+ the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
+ around a deflate stream, which is itself documented in RFC 1951.
The library also supports reading and writing files in gzip (.gz) format
with an interface similar to that of stdio using the functions that start
with "gz". The gzip format is different from the zlib format. gzip is a
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+ This library can optionally read and write gzip streams in memory as well.
+
The zlib format was designed to be compact and fast for use in memory
and on communications channels. The gzip format was designed for single-
file compression on file systems, has a larger header than zlib to maintain
directory information, and uses a different, slower check method than zlib.
- This library does not provide any functions to write gzip files in memory.
- However such functions could be easily written using zlib's deflate function,
- the documentation in the gzip RFC, and the examples in gzio.c.
-
The library does not install any signal handler. The decoder checks
the consistency of the compressed data, so the library should never
crash even in case of corrupted input.
@@ -401,7 +399,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
because Z_BLOCK is used.
If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm-adler to the adler32 checksum of the dictionary
+ below), inflate sets strm->adler to the adler32 checksum of the dictionary
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
strm->adler to the adler32 checksum of all output produced so far (that is,
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
@@ -478,7 +476,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
16 to windowBits to write a simple gzip header and trailer around the
compressed data instead of a zlib wrapper. The gzip header will have no
file name, no extra data, no comment, no modification time (set to zero),
- no header crc, and the operating system will be set to 255 (unknown).
+ no header crc, and the operating system will be set to 255 (unknown). If a
+ gzip stream is being written, strm->adler is a crc32 instead of an adler32.
The memLevel parameter specifies how much memory should be allocated
for the internal compression state. memLevel=1 uses minimum memory but
@@ -649,7 +648,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR).
+ return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is
+ a crc32 instead of an adler32.
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
@@ -1189,7 +1189,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif
-ZEXTERN const char * ZEXPORT zError OF((int err));
+ZEXTERN const char * ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
diff --git a/zlib/zutil.h b/zlib/zutil.h
index 87b70acec23..7b42edcaa98 100644
--- a/zlib/zutil.h
+++ b/zlib/zutil.h
@@ -189,9 +189,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define NO_vsnprintf
# endif
#endif
+#ifdef VMS
+# define NO_vsnprintf
+#endif
#ifdef HAVE_STRERROR
- extern char *strerror OF((int));
+# ifndef VMS
+ extern char *strerror OF((int));
+# endif
# define zstrerror(errnum) strerror(errnum)
#else
# define zstrerror(errnum) ""