summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBUILD/check-cpu4
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--client/mysql.cc7
-rw-r--r--client/mysqltest.c19
-rw-r--r--cmd-line-utils/libedit/readline/readline.h2
-rw-r--r--cmd-line-utils/libedit/vi.c2
-rw-r--r--configure.in5
-rw-r--r--include/mysql.h1
-rw-r--r--innobase/row/row0mysql.c12
-rw-r--r--libmysql/libmysql.c40
-rw-r--r--libmysql/libmysql.def1
-rw-r--r--libmysqld/Makefile.am5
-rw-r--r--man/mysqldump.1.in3
-rw-r--r--myisam/mi_check.c36
-rw-r--r--myisam/mi_key.c31
-rw-r--r--mysql-test/include/have_outfile.inc5
-rw-r--r--mysql-test/include/test_outfile.inc1
-rw-r--r--mysql-test/lib/init_db.sql5
-rw-r--r--mysql-test/lib/mtr_process.pl2
-rw-r--r--mysql-test/lib/mtr_report.pl13
-rwxr-xr-xmysql-test/mysql-test-run.pl233
-rw-r--r--mysql-test/mysql-test-run.sh9
-rw-r--r--mysql-test/r/alter_table.result189
-rw-r--r--mysql-test/r/auto_increment.result14
-rw-r--r--mysql-test/r/ctype_ucs.result18
-rw-r--r--mysql-test/r/have_outfile.require3
-rw-r--r--mysql-test/r/innodb.result4
-rw-r--r--mysql-test/r/insert_update.result9
-rw-r--r--mysql-test/r/myisam.result14
-rw-r--r--mysql-test/r/outfile.resultbin330 -> 959 bytes
-rw-r--r--mysql-test/r/ps_grant.result8
-rw-r--r--mysql-test/r/select.result4
-rw-r--r--mysql-test/r/subselect.result24
-rw-r--r--mysql-test/suppress.purify10
-rw-r--r--mysql-test/t/alter_table.test151
-rw-r--r--mysql-test/t/auto_increment.test12
-rw-r--r--mysql-test/t/ctype_ucs.test10
-rw-r--r--mysql-test/t/innodb.test10
-rw-r--r--mysql-test/t/insert_update.test6
-rw-r--r--mysql-test/t/myisam.test15
-rw-r--r--mysql-test/t/outfile.test66
-rw-r--r--mysql-test/t/ps_grant.test9
-rw-r--r--mysql-test/t/select.test4
-rw-r--r--mysql-test/t/subselect.test24
-rw-r--r--sql/ha_blackhole.cc3
-rw-r--r--sql/handler.h1
-rw-r--r--sql/hostname.cc4
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item.h10
-rw-r--r--sql/item_func.cc5
-rw-r--r--sql/share/danish/errmsg.txt2
-rw-r--r--sql/share/serbian/errmsg.txt2
-rw-r--r--sql/sql_table.cc15
-rw-r--r--sql/sql_yacc.yy29
-rw-r--r--sql/unireg.cc85
-rw-r--r--strings/ctype-big5.c2
-rw-r--r--strings/ctype-cp932.c2
-rw-r--r--strings/ctype-ucs2.c8
58 files changed, 827 insertions, 384 deletions
diff --git a/BUILD/check-cpu b/BUILD/check-cpu
index dfdf96d6b29..7619224314b 100755
--- a/BUILD/check-cpu
+++ b/BUILD/check-cpu
@@ -55,6 +55,10 @@ case "$cpu_family--$model_name" in
*Pentium*III*CPU*)
cpu_flag="pentium3";
;;
+ *Pentium*M*pro*)
+ cpu_flag="pentium-m";
+ cpu_flag_old="pentium";
+ ;;
*Athlon*64*)
cpu_flag="athlon64";
cpu_flag_old="athlon";
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 246de2fffa2..daacb337570 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -29,6 +29,7 @@ bar@gw.udmsearch.izhnet.ru
bar@mysql.com
bar@noter.intranet.mysql.r18.ru
bell@51.0.168.192.in-addr.arpa
+bell@book.sanja.is.com.ua
bell@laptop.sanja.is.com.ua
bell@sanja.is.com.ua
bk@admin.bk
diff --git a/client/mysql.cc b/client/mysql.cc
index 6a76a1fbd1b..a3262c818f3 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2051,7 +2051,8 @@ print_table_data(MYSQL_RES *result)
separator.fill(separator.length()+length+2,'-');
separator.append('+');
}
- tee_puts(separator.c_ptr_safe(), PAGER);
+ separator.append('\0'); // End marker for \0
+ tee_puts((char*) separator.ptr(), PAGER);
if (column_names)
{
mysql_field_seek(result,0);
@@ -2064,7 +2065,7 @@ print_table_data(MYSQL_RES *result)
num_flag[off]= IS_NUM(field->type);
}
(void) tee_fputs("\n", PAGER);
- tee_puts(separator.c_ptr(), PAGER);
+ tee_puts((char*) separator.ptr(), PAGER);
}
while ((cur= mysql_fetch_row(result)))
@@ -2093,7 +2094,7 @@ print_table_data(MYSQL_RES *result)
}
(void) tee_fputs("\n", PAGER);
}
- tee_puts(separator.c_ptr(), PAGER);
+ tee_puts((char*) separator.ptr(), PAGER);
my_afree((gptr) num_flag);
}
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 3eab182a74d..e60d9ecd1c5 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -572,7 +572,7 @@ static void abort_not_supported_test()
printf("skipped\n");
free_used_memory();
my_end(MY_CHECK_ERROR);
- exit(2);
+ exit(62);
}
static void verbose_msg(const char* fmt, ...)
@@ -2597,6 +2597,8 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
if (!disable_result_log)
{
+ ulong affected_rows; /* Ok to be undef if 'disable_info' is set */
+
if (res)
{
MYSQL_FIELD *field= mysql_fetch_fields(res);
@@ -2619,6 +2621,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
append_result(ds, res);
}
+ /*
+ Need to call mysql_affected_rows() before the new
+ query to find the warnings
+ */
+ if (!disable_info)
+ affected_rows= (ulong)mysql_affected_rows(mysql);
+
/* Add all warnings to the result */
if (!disable_warnings && mysql_warning_count(mysql))
{
@@ -2641,7 +2650,7 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
if (!disable_info)
{
char buf[40];
- sprintf(buf,"affected rows: %lu\n",(ulong) mysql_affected_rows(mysql));
+ sprintf(buf,"affected rows: %lu\n", affected_rows);
dynstr_append(ds, buf);
if (mysql_info(mysql))
{
@@ -3522,6 +3531,12 @@ int main(int argc, char **argv)
if (q->query == q->query_buf)
q->query += q->first_word_len + 1;
display_result_vertically= (q->type==Q_QUERY_VERTICAL);
+ if (save_file[0])
+ {
+ strmov(q->record_file,save_file);
+ q->require_file=require_file;
+ save_file[0]=0;
+ }
error|= run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND);
display_result_vertically= old_display_result_vertically;
break;
diff --git a/cmd-line-utils/libedit/readline/readline.h b/cmd-line-utils/libedit/readline/readline.h
index 902179c208a..c43f71fb51d 100644
--- a/cmd-line-utils/libedit/readline/readline.h
+++ b/cmd-line-utils/libedit/readline/readline.h
@@ -73,7 +73,7 @@ typedef KEYMAP_ENTRY *Keymap;
#ifndef CTRL
#include <sys/ioctl.h>
-#ifdef __GLIBC__
+#if defined(__GLIBC__) || defined(__MWERKS__)
#include <sys/ttydefaults.h>
#endif
#ifndef CTRL
diff --git a/cmd-line-utils/libedit/vi.c b/cmd-line-utils/libedit/vi.c
index 4a0352859dd..b977ce716c6 100644
--- a/cmd-line-utils/libedit/vi.c
+++ b/cmd-line-utils/libedit/vi.c
@@ -1014,7 +1014,7 @@ vi_histedit(EditLine *el, int c)
return CC_ERROR;
case 0:
close(fd);
- execlp("vi", "vi", tempfile, 0);
+ execlp("vi", "vi", tempfile, (char *) NULL);
exit(0);
/*NOTREACHED*/
default:
diff --git a/configure.in b/configure.in
index 52f368f0c2d..7dd49ca8dea 100644
--- a/configure.in
+++ b/configure.in
@@ -5,7 +5,7 @@ AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
# remember to also change ndb version below and update version.c in ndb
-AM_INIT_AUTOMAKE(mysql, 4.1.12)
+AM_INIT_AUTOMAKE(mysql, 4.1.13)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
@@ -145,8 +145,11 @@ AC_ARG_WITH(darwin-mwcc,
export CC CXX LD AR RANLIB
AC_SUBST(AR)
AC_SUBST(RANLIB)
+ with_darwin_mwcc=yes
])
+AM_CONDITIONAL(DARWIN_MWCC, test x$with_darwin_mwcc = xyes)
+
if test "x${CFLAGS-}" = x ; then
cflags_is_set=no
else
diff --git a/include/mysql.h b/include/mysql.h
index d8a56126756..ab61fe694d9 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -381,6 +381,7 @@ unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
const char * STDCALL mysql_info(MYSQL *mysql);
unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
const char * STDCALL mysql_character_set_name(MYSQL *mysql);
+int STDCALL mysql_set_character_set(MYSQL *mysql, char *csname);
MYSQL * STDCALL mysql_init(MYSQL *mysql);
my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 9410f2ce7cc..280c306cce4 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -1606,10 +1606,18 @@ row_create_table_for_mysql(
trx_general_rollback_for_mysql(trx, FALSE, NULL);
if (err == DB_OUT_OF_FILE_SPACE) {
- fputs("InnoDB: Warning: cannot create table ", stderr);
+ ut_print_timestamp(stderr);
+
+ fputs(" InnoDB: Warning: cannot create table ",
+ stderr);
ut_print_name(stderr, trx, table->name);
fputs(" because tablespace full\n", stderr);
- row_drop_table_for_mysql(table->name, trx, FALSE);
+
+ if (dict_table_get_low(table->name)) {
+
+ row_drop_table_for_mysql(table->name, trx,
+ FALSE);
+ }
} else if (err == DB_DUPLICATE_KEY) {
ut_print_timestamp(stderr);
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index c663dab7476..4d92db26406 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1510,6 +1510,39 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql)
}
+int STDCALL mysql_set_character_set(MYSQL *mysql, char *cs_name)
+{
+ struct charset_info_st *cs;
+ const char *save_csdir= charsets_dir;
+
+ if (mysql->options.charset_dir)
+ charsets_dir= mysql->options.charset_dir;
+
+ if ((cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))))
+ {
+ char buff[MY_CS_NAME_SIZE + 10];
+ charsets_dir= save_csdir;
+ sprintf(buff, "SET NAMES %s", cs_name);
+ if (!mysql_query(mysql, buff))
+ {
+ mysql->charset= cs;
+ }
+ }
+ else
+ {
+ char cs_dir_name[FN_REFLEN];
+ get_charsets_dir(cs_dir_name);
+ mysql->net.last_errno= CR_CANT_READ_CHARSET;
+ strmov(mysql->net.sqlstate, unknown_sqlstate);
+ my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error) - 1,
+ ER(mysql->net.last_errno), cs_name, cs_dir_name);
+
+ }
+ charsets_dir= save_csdir;
+ return mysql->net.last_errno;
+}
+
+
uint STDCALL mysql_thread_safe(void)
{
#ifdef THREAD
@@ -3914,9 +3947,12 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
/*
We only need to check that stmt->field_count - if it is not null
stmt->bind was initialized in mysql_stmt_prepare
- */
+ stmt->bind overlaps with bind if mysql_stmt_bind_param
+ is called from mysql_stmt_store_result.
+ */
- memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
+ if (stmt->bind != bind)
+ memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count);
for (param= stmt->bind, end= param + bind_count, field= stmt->fields ;
param < end ;
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index c5579e9ec2b..57c97ab08ee 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -146,4 +146,5 @@ EXPORTS
mysql_rpl_query_type
mysql_slave_query
mysql_embedded
+ mysql_set_character_set
get_defaults_files
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 4cf2c3f67a7..f578e87ae4a 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -83,6 +83,9 @@ INC_LIB= $(top_builddir)/regex/libregex.a \
# generate a total libmysqld.a from all library files,
libmysqld.a: libmysqld_int.a $(INC_LIB)
+if DARWIN_MWCC
+ mwld -lib -o $@ libmysqld_int.a `ls -1 $(INC_LIB) | sort -u`
+else
if test "$(host_os)" = "netware" ; \
then \
$(libmysqld_a_AR) libmysqld.a libmysqld_int.a $(INC_LIB) ; \
@@ -104,7 +107,7 @@ libmysqld.a: libmysqld_int.a $(INC_LIB)
rm -f tmp/* ; \
$(RANLIB) libmysqld.a ; \
fi
-
+endif
## XXX: any time the client interface changes, we'll need to bump
## the version info for libmysqld; however, it's possible for the
diff --git a/man/mysqldump.1.in b/man/mysqldump.1.in
index 4d841117e59..0f581429af7 100644
--- a/man/mysqldump.1.in
+++ b/man/mysqldump.1.in
@@ -218,7 +218,8 @@ or
), mysqldump will create rows up to net_buffer_length length. If you increase this variable, you should also ensure that the max_allowed_packet variable in the MySQL server is bigger than the net_buffer_length.
.SH EXAMPLES
.TP
-The most normal use of mysqldump is probably for making a backup of whole databases. See Mysql Manual section 21.2 Database Backups.
+The most normal use of mysqldump is probably for making a backup of whole
+databases. See the section on Database Backups in the MySQL Reference Manual.
.TP
mysqldump \-\-opt \fP\fIdatabase\fP > backup-file.sql
.TP
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index f710d3a8454..d59c9b9c697 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -3243,6 +3243,9 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a)
cmp=ha_key_cmp(sort_param->seg,sort_info->key_block->lastkey,
(uchar*) a, USE_WHOLE_KEY,SEARCH_FIND | SEARCH_UPDATE,
&diff_pos);
+ ha_key_cmp(sort_param->seg,sort_info->key_block->lastkey,
+ (uchar*) a, USE_WHOLE_KEY,SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL,
+ &diff_pos);
sort_param->unique[diff_pos-1]++;
}
else
@@ -3955,7 +3958,38 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
return;
}
- /* calculate unique keys for each part key */
+
+/*
+ Update statistics for each part of an index
+
+ SYNOPSIS
+ update_key_parts()
+ keyinfo Index information (only key->keysegs used)
+ rec_per_key_part OUT Store statistics here
+ unique IN Array of #distinct values collected over index
+ run.
+ records Number of records in the table
+
+ NOTES
+ Unique is an array:
+ unique[0]= (#different values of {keypart1}) - 1
+ unique[1]= (#different values of {keypart2,keypart1} tuple) - unique[0] - 1
+ ...
+ Here we assume that NULL != NULL (see SEARCH_NULL_ARE_NOT_EQUAL). The
+ 'unique' array is collected in one sequential scan through the entire
+ index. This is done in two places: in chk_index() and in sort_key_write().
+
+ Output is an array:
+ rec_per_key_part[k] =
+ = E(#records in the table such that keypart_1=c_1 AND ... AND
+ keypart_k=c_k for arbitrary constants c_1 ... c_k)
+
+ = {assuming that values have uniform distribution and index contains all
+ tuples from the domain (or that {c_1, ..., c_k} tuple is choosen from
+ index tuples}
+
+ = #tuples-in-the-index / #distinct-tuples-in-the-index.
+*/
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
ulonglong *unique, ulonglong records)
diff --git a/myisam/mi_key.c b/myisam/mi_key.c
index 3545756779f..b7240f34538 100644
--- a/myisam/mi_key.c
+++ b/myisam/mi_key.c
@@ -301,8 +301,25 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
} /* _mi_pack_key */
- /* Put a key in record */
- /* Used when only-keyread is wanted */
+
+/*
+ Store found key in record
+
+ SYNOPSIS
+ _mi_put_key_in_record()
+ info MyISAM handler
+ keynr Key number that was used
+ record Store key here
+
+ Last read key is in info->lastkey
+
+ NOTES
+ Used when only-keyread is wanted
+
+ RETURN
+ 0 ok
+ 1 error
+*/
static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
byte *record)
@@ -313,14 +330,8 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
byte *blob_ptr;
DBUG_ENTER("_mi_put_key_in_record");
- if (info->s->base.blobs && info->s->keyinfo[keynr].flag & HA_VAR_LENGTH_KEY)
- {
- if (!(blob_ptr=
- mi_alloc_rec_buff(info, info->s->keyinfo[keynr].keylength,
- &info->rec_buff)))
- goto err;
- }
- key=(byte*) info->lastkey;
+ blob_ptr= info->lastkey2; /* Place to put blob parts */
+ key=(byte*) info->lastkey; /* KEy that was read */
key_end=key+info->lastkey_length;
for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
{
diff --git a/mysql-test/include/have_outfile.inc b/mysql-test/include/have_outfile.inc
new file mode 100644
index 00000000000..31e95f4810a
--- /dev/null
+++ b/mysql-test/include/have_outfile.inc
@@ -0,0 +1,5 @@
+-- require r/have_outfile.require
+disable_query_log;
+select load_file(concat(@tmpdir,"/outfile.test"));
+--exec rm $MYSQL_TEST_DIR/var/tmp/outfile.test
+enable_query_log;
diff --git a/mysql-test/include/test_outfile.inc b/mysql-test/include/test_outfile.inc
new file mode 100644
index 00000000000..0bede4938c6
--- /dev/null
+++ b/mysql-test/include/test_outfile.inc
@@ -0,0 +1 @@
+eval select "Outfile OK" into outfile "$MYSQL_TEST_DIR/var/tmp/outfile.test";
diff --git a/mysql-test/lib/init_db.sql b/mysql-test/lib/init_db.sql
index 902af0b0842..6d5ec55a6ae 100644
--- a/mysql-test/lib/init_db.sql
+++ b/mysql-test/lib/init_db.sql
@@ -1,4 +1,5 @@
-USE mysql;
+use mysql;
+set table_type=myisam;
CREATE TABLE db (
Host char(60) binary DEFAULT '' NOT NULL,
@@ -193,7 +194,7 @@ INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES
CREATE TABLE time_zone (
Time_zone_id int unsigned NOT NULL auto_increment,
- Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,
+ Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
PRIMARY KEY TzId (Time_zone_id)
) engine=MyISAM
CHARACTER SET utf8
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 8aefc235d72..78758e54aa4 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -344,7 +344,7 @@ sub mtr_kill_leftovers () {
# We scan the "var/run/" directory for other process id's to kill
# FIXME $path_run_dir or something
- my $rundir= "$::glob_mysql_test_dir/var/run";
+ my $rundir= "$::opt_vardir/run";
if ( -d $rundir )
{
diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl
index fd665b154b8..cb41549422f 100644
--- a/mysql-test/lib/mtr_report.pl
+++ b/mysql-test/lib/mtr_report.pl
@@ -89,9 +89,10 @@ sub mtr_report_test_passed ($) {
my $tinfo= shift;
my $timer= "";
- if ( $::opt_timer and -f "$::glob_mysql_test_dir/var/log/timer" )
+ if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
{
- $timer= mtr_fromfile("$::glob_mysql_test_dir/var/log/timer");
+ $timer= mtr_fromfile("$::opt_vardir/log/timer");
+ $::glob_tot_real_time += $timer;
$timer= sprintf "%12s", $timer;
}
$tinfo->{'result'}= 'MTR_RES_PASSED';
@@ -177,8 +178,8 @@ sub mtr_report_stats ($) {
# Report if there was any fatal warnings/errors in the log files
#
- unlink("$::glob_mysql_test_dir/var/log/warnings");
- unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
+ unlink("$::opt_vardir/log/warnings");
+ unlink("$::opt_vardir/log/warnings.tmp");
# Remove some non fatal warnings from the log files
# FIXME what is going on ????? ;-)
@@ -196,11 +197,11 @@ sub mtr_report_stats ($) {
# found_error=1
# }
# done
-# unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
+# unlink("$::opt_vardir/log/warnings.tmp");
# if ( $found_error= "1" )
# {
# print "WARNING: Got errors/warnings while running tests. Please examine\n"
-# print "$::glob_mysql_test_dir/var/log/warnings for details.\n"
+# print "$::opt_vardir/log/warnings for details.\n"
# }
# }
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 5a188dc6927..9d809593ea7 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -84,7 +84,7 @@ use Sys::Hostname;
#use Carp;
use IO::Socket;
use IO::Socket::INET;
-#use Data::Dumper;
+use Data::Dumper;
use strict;
#use diagnostics;
@@ -177,6 +177,7 @@ our $path_timefile;
our $path_manager_log; # Used by mysqldadmin
our $path_slave_load_tmpdir; # What is this?!
our $path_my_basedir;
+our $opt_vardir; # A path but set directly on cmd line
our $opt_tmpdir; # A path but set directly on cmd line
our $opt_usage;
@@ -447,8 +448,6 @@ sub initial_setup () {
$glob_basedir= dirname($glob_mysql_test_dir);
$glob_mysql_bench_dir= "$glob_basedir/mysql-bench"; # FIXME make configurable
- $path_timefile= "$glob_mysql_test_dir/var/log/mysqltest-time";
-
# needs to be same length to test logging (FIXME what???)
$path_slave_load_tmpdir= "../../var/tmp";
@@ -469,11 +468,6 @@ sub command_line_setup () {
# These are defaults for things that are set on the command line
$opt_suite= "main"; # Special default suite
- $opt_tmpdir= "$glob_mysql_test_dir/var/tmp";
- # FIXME maybe unneded?
- $path_manager_log= "$glob_mysql_test_dir/var/log/manager.log";
- $opt_current_test= "$glob_mysql_test_dir/var/log/current_test";
-
my $opt_master_myport= 9306;
my $opt_slave_myport= 9308;
$opt_ndbcluster_port= 9350;
@@ -549,6 +543,7 @@ sub command_line_setup () {
'unified-diff|udiff' => \$opt_udiff,
'user-test=s' => \$opt_user_test,
'user=s' => \$opt_user,
+ 'vardir=s' => \$opt_vardir,
'verbose' => \$opt_verbose,
'wait-timeout=i' => \$opt_wait_timeout,
'warnings|log-warnings' => \$opt_warnings,
@@ -564,51 +559,35 @@ sub command_line_setup () {
@opt_cases= @ARGV;
- # Put this into a hash, will be a C struct
-
- $master->[0]->{'path_myddir'}= "$glob_mysql_test_dir/var/master-data";
- $master->[0]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/master.err";
- $master->[0]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/master.log";
- $master->[0]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/master.pid";
- $master->[0]->{'path_mysock'}= "$opt_tmpdir/master.sock";
- $master->[0]->{'path_myport'}= $opt_master_myport;
- $master->[0]->{'start_timeout'}= 400; # enough time create innodb tables
-
- $master->[0]->{'ndbcluster'}= 1; # ndbcluster not started
+ # --------------------------------------------------------------------------
+ # Set the "var/" directory, as it is the base for everything else
+ # --------------------------------------------------------------------------
- $master->[1]->{'path_myddir'}= "$glob_mysql_test_dir/var/master1-data";
- $master->[1]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/master1.err";
- $master->[1]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/master1.log";
- $master->[1]->{'path_mypid'}= "$glob_mysql_test_dir/var/run/master1.pid";
- $master->[1]->{'path_mysock'}= "$opt_tmpdir/master1.sock";
- $master->[1]->{'path_myport'}= $opt_master_myport + 1;
- $master->[1]->{'start_timeout'}= 400; # enough time create innodb tables
+ if ( ! $opt_vardir )
+ {
+ $opt_vardir= "$glob_mysql_test_dir/var";
+ }
- $slave->[0]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave-data";
- $slave->[0]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave.err";
- $slave->[0]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/slave.log";
- $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;
+ if ( $opt_vardir !~ m,^/, )
+ {
+ # Make absolute path, relative test dir
+ $opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
+ }
- $slave->[1]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave1-data";
- $slave->[1]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave1.err";
- $slave->[1]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/slave1.log";
- $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'}= 300;
+ # --------------------------------------------------------------------------
+ # If not set, set these to defaults
+ # --------------------------------------------------------------------------
- $slave->[2]->{'path_myddir'}= "$glob_mysql_test_dir/var/slave2-data";
- $slave->[2]->{'path_myerr'}= "$glob_mysql_test_dir/var/log/slave2.err";
- $slave->[2]->{'path_mylog'}= "$glob_mysql_test_dir/var/log/slave2.log";
- $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'}= 300;
+ $opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir;
+ # FIXME maybe not needed?
+ $path_manager_log= "$opt_vardir/log/manager.log"
+ unless $path_manager_log;
+ $opt_current_test= "$opt_vardir/log/current_test"
+ unless $opt_current_test;
+ # --------------------------------------------------------------------------
# Do sanity checks of command line arguments
+ # --------------------------------------------------------------------------
if ( $opt_extern and $opt_local )
{
@@ -621,13 +600,6 @@ sub command_line_setup () {
$opt_socket= "/tmp/mysql.sock"; # FIXME
}
- if ( $opt_extern )
- {
- $glob_use_running_server= 1;
- $opt_skip_rpl= 1; # We don't run rpl test cases
- $master->[0]->{'path_mysock'}= $opt_socket;
- }
-
# --------------------------------------------------------------------------
# Look at the command line options and set script flags
# --------------------------------------------------------------------------
@@ -746,6 +718,58 @@ sub command_line_setup () {
}
}
+ # Put this into a hash, will be a C struct
+
+ $master->[0]->{'path_myddir'}= "$opt_vardir/master-data";
+ $master->[0]->{'path_myerr'}= "$opt_vardir/log/master.err";
+ $master->[0]->{'path_mylog'}= "$opt_vardir/log/master.log";
+ $master->[0]->{'path_mypid'}= "$opt_vardir/run/master.pid";
+ $master->[0]->{'path_mysock'}= "$opt_tmpdir/master.sock";
+ $master->[0]->{'path_myport'}= $opt_master_myport;
+ $master->[0]->{'start_timeout'}= 400; # enough time create innodb tables
+
+ $master->[0]->{'ndbcluster'}= 1; # ndbcluster not started
+
+ $master->[1]->{'path_myddir'}= "$opt_vardir/master1-data";
+ $master->[1]->{'path_myerr'}= "$opt_vardir/log/master1.err";
+ $master->[1]->{'path_mylog'}= "$opt_vardir/log/master1.log";
+ $master->[1]->{'path_mypid'}= "$opt_vardir/run/master1.pid";
+ $master->[1]->{'path_mysock'}= "$opt_tmpdir/master1.sock";
+ $master->[1]->{'path_myport'}= $opt_master_myport + 1;
+ $master->[1]->{'start_timeout'}= 400; # enough time create innodb tables
+
+ $slave->[0]->{'path_myddir'}= "$opt_vardir/slave-data";
+ $slave->[0]->{'path_myerr'}= "$opt_vardir/log/slave.err";
+ $slave->[0]->{'path_mylog'}= "$opt_vardir/log/slave.log";
+ $slave->[0]->{'path_mypid'}= "$opt_vardir/run/slave.pid";
+ $slave->[0]->{'path_mysock'}= "$opt_tmpdir/slave.sock";
+ $slave->[0]->{'path_myport'}= $opt_slave_myport;
+ $slave->[0]->{'start_timeout'}= 400;
+
+ $slave->[1]->{'path_myddir'}= "$opt_vardir/slave1-data";
+ $slave->[1]->{'path_myerr'}= "$opt_vardir/log/slave1.err";
+ $slave->[1]->{'path_mylog'}= "$opt_vardir/log/slave1.log";
+ $slave->[1]->{'path_mypid'}= "$opt_vardir/run/slave1.pid";
+ $slave->[1]->{'path_mysock'}= "$opt_tmpdir/slave1.sock";
+ $slave->[1]->{'path_myport'}= $opt_slave_myport + 1;
+ $slave->[1]->{'start_timeout'}= 300;
+
+ $slave->[2]->{'path_myddir'}= "$opt_vardir/slave2-data";
+ $slave->[2]->{'path_myerr'}= "$opt_vardir/log/slave2.err";
+ $slave->[2]->{'path_mylog'}= "$opt_vardir/log/slave2.log";
+ $slave->[2]->{'path_mypid'}= "$opt_vardir/run/slave2.pid";
+ $slave->[2]->{'path_mysock'}= "$opt_tmpdir/slave2.sock";
+ $slave->[2]->{'path_myport'}= $opt_slave_myport + 2;
+ $slave->[2]->{'start_timeout'}= 300;
+
+ if ( $opt_extern )
+ {
+ $glob_use_running_server= 1;
+ $opt_skip_rpl= 1; # We don't run rpl test cases
+ $master->[0]->{'path_mysock'}= $opt_socket;
+ }
+
+ $path_timefile= "$opt_vardir/log/mysqltest-time";
}
@@ -892,8 +916,8 @@ sub executable_setup () {
}
$path_ndb_backup_dir=
- "$glob_mysql_test_dir/var/ndbcluster-$opt_ndbcluster_port";
- $file_ndb_testrun_log= "$glob_mysql_test_dir/var/log/ndb_testrun.log";
+ "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
+ $file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
}
@@ -981,7 +1005,7 @@ sub kill_running_server () {
# leftovers from previous runs.
mtr_report("Killing Possible Leftover Processes");
- mkpath("$glob_mysql_test_dir/var/log"); # Needed for mysqladmin log
+ mkpath("$opt_vardir/log"); # Needed for mysqladmin log
mtr_kill_leftovers();
ndbcluster_stop();
@@ -995,15 +1019,20 @@ sub kill_and_cleanup () {
mtr_report("Removing Stale Files");
- rmtree("$glob_mysql_test_dir/var/log");
- rmtree("$glob_mysql_test_dir/var/ndbcluster-$opt_ndbcluster_port");
- rmtree("$glob_mysql_test_dir/var/run");
- rmtree("$glob_mysql_test_dir/var/tmp");
+ if ( -l $opt_vardir and ! unlink($opt_vardir) )
+ {
+ mtr_error("Can't remove soft link \"$opt_vardir\"");
+ }
+
+ rmtree("$opt_vardir/log");
+ rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port");
+ rmtree("$opt_vardir/run");
+ rmtree("$opt_vardir/tmp");
- mkpath("$glob_mysql_test_dir/var/log");
- mkpath("$glob_mysql_test_dir/var/run");
- mkpath("$glob_mysql_test_dir/var/tmp");
- mkpath($opt_tmpdir);
+ mkpath("$opt_vardir/log");
+ mkpath("$opt_vardir/run");
+ mkpath("$opt_vardir/tmp");
+ mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
# FIXME do we really need to create these all, or are they
# created for us when tables are created?
@@ -1027,6 +1056,16 @@ sub kill_and_cleanup () {
rmtree("$slave->[2]->{'path_myddir'}");
mkpath("$slave->[2]->{'path_myddir'}/mysql");
mkpath("$slave->[2]->{'path_myddir'}/test");
+
+ # To make some old test cases work, we create a soft
+ # link from the old "var" location to the new one
+
+ if ( ! $glob_win32 and $opt_vardir ne "$glob_mysql_test_dir/var" )
+ {
+ # FIXME why bother with the above, why not always remove all of var?!
+ rmtree("$glob_mysql_test_dir/var"); # Clean old var, FIXME or rename it?!
+ symlink($opt_vardir, "$glob_mysql_test_dir/var");
+ }
}
@@ -1050,7 +1089,7 @@ sub ndbcluster_install () {
if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
["--port=$opt_ndbcluster_port",
"--port-base=$ndbcluster_port_base",
- "--data-dir=$glob_mysql_test_dir/var",
+ "--data-dir=$opt_vardir",
$ndbcluster_opts,
"--initial"],
"", "", "", "") )
@@ -1074,7 +1113,7 @@ sub ndbcluster_start () {
# FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
["--port=$opt_ndbcluster_port",
- "--data-dir=$glob_mysql_test_dir/var"],
+ "--data-dir=$opt_vardir"],
"", "/dev/null", "", "") )
{
mtr_error("Error ndbcluster_start");
@@ -1094,7 +1133,7 @@ sub ndbcluster_stop () {
# FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
["--port=$opt_ndbcluster_port",
- "--data-dir=$glob_mysql_test_dir/var",
+ "--data-dir=$opt_vardir",
"--stop"],
"", "/dev/null", "", "");
@@ -1497,15 +1536,15 @@ sub run_testcase ($) {
{
mtr_report_test_passed($tinfo);
}
- elsif ( $res == 2 )
+ elsif ( $res == 62 )
{
# Testcase itself tell us to skip this one
mtr_report_test_skipped($tinfo);
}
else
{
- # Test case failed
- if ( $res > 2 )
+ # Test case failed, if in control mysqltest returns 1
+ if ( $res != 1 )
{
mtr_tofile($path_timefile,
"mysqltest returned unexpected code $res, " .
@@ -1566,17 +1605,17 @@ sub do_before_start_master ($$) {
$tname ne "rpl_crash_binlog_ib_3b")
{
# FIXME we really want separate dir for binlogs
- foreach my $bin ( glob("$glob_mysql_test_dir/var/log/master*-bin.*") )
+ foreach my $bin ( glob("$opt_vardir/log/master*-bin.*") )
{
unlink($bin);
}
}
# Remove old master.info and relay-log.info files
- unlink("$glob_mysql_test_dir/var/master-data/master.info");
- unlink("$glob_mysql_test_dir/var/master-data/relay-log.info");
- unlink("$glob_mysql_test_dir/var/master1-data/master.info");
- unlink("$glob_mysql_test_dir/var/master1-data/relay-log.info");
+ unlink("$opt_vardir/master-data/master.info");
+ unlink("$opt_vardir/master-data/relay-log.info");
+ unlink("$opt_vardir/master1-data/master.info");
+ unlink("$opt_vardir/master1-data/relay-log.info");
# Run master initialization shell script if one exists
if ( $init_script )
@@ -1603,13 +1642,13 @@ sub do_before_start_slave ($$) {
$tname ne "rpl_crash_binlog_ib_3b" )
{
# FIXME we really want separate dir for binlogs
- foreach my $bin ( glob("$glob_mysql_test_dir/var/log/slave*-bin.*") )
+ foreach my $bin ( glob("$opt_vardir/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");
+ unlink("$opt_vardir/slave-data/master.info");
+ unlink("$opt_vardir/slave-data/relay-log.info");
}
# Run slave initialization shell script if one exists
@@ -1623,8 +1662,8 @@ sub do_before_start_slave ($$) {
}
}
- `rm -f $glob_mysql_test_dir/var/slave-data/log.*`;
-# unlink("$glob_mysql_test_dir/var/slave-data/log.*");
+ `rm -f $opt_vardir/slave-data/log.*`;
+# unlink("$opt_vardir/slave-data/log.*");
}
sub mysqld_arguments ($$$$$) {
@@ -1670,8 +1709,7 @@ sub mysqld_arguments ($$$$$) {
if ( $type eq 'master' )
{
- mtr_add_arg($args, "%s--log-bin=%s/var/log/master-bin", $prefix,
- $glob_mysql_test_dir);
+ mtr_add_arg($args, "%s--log-bin=%s/log/master-bin", $prefix, $opt_vardir);
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
$master->[$idx]->{'path_mypid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
@@ -1695,8 +1733,8 @@ sub mysqld_arguments ($$$$$) {
# 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-bin=%s/log/slave%s-bin", $prefix,
+ $opt_vardir, $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,
@@ -1706,8 +1744,8 @@ sub mysqld_arguments ($$$$$) {
$slave->[$idx]->{'path_mypid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
$slave->[$idx]->{'path_myport'});
- mtr_add_arg($args, "%s--relay-log=%s/var/log/slave%s-relay-bin", $prefix,
- $glob_mysql_test_dir, $sidx);
+ mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
+ $opt_vardir, $sidx);
mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
mtr_add_arg($args, "%s--report-port=%d", $prefix,
$slave->[$idx]->{'path_myport'});
@@ -1745,13 +1783,13 @@ sub mysqld_arguments ($$$$$) {
{
if ( $type eq 'master' )
{
- mtr_add_arg($args, "%s--debug=d:t:i:A,%s/var/log/master%s.trace",
- $prefix, $glob_mysql_test_dir, $sidx);
+ mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/master%s.trace",
+ $prefix, $opt_vardir, $sidx);
}
if ( $type eq 'slave' )
{
- mtr_add_arg($args, "%s--debug=d:t:i:A,%s/var/log/slave%s.trace",
- $prefix, $glob_mysql_test_dir, $sidx);
+ mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/slave%s.trace",
+ $prefix, $opt_vardir, $sidx);
}
}
@@ -2003,7 +2041,7 @@ sub run_mysqltest ($$) {
if ( $opt_debug )
{
$cmdline_mysqldump .=
- " --debug=d:t:A,$glob_mysql_test_dir/var/log/mysqldump.trace";
+ " --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
}
my $cmdline_mysqlbinlog=
@@ -2012,7 +2050,7 @@ sub run_mysqltest ($$) {
if ( $opt_debug )
{
$cmdline_mysqlbinlog .=
- " --debug=d:t:A,$glob_mysql_test_dir/var/log/mysqlbinlog.trace";
+ " --debug=d:t:A,$opt_vardir/log/mysqlbinlog.trace";
}
my $cmdline_mysql=
@@ -2075,13 +2113,13 @@ sub run_mysqltest ($$) {
{
$exe= "strace"; # FIXME there are ktrace, ....
mtr_add_arg($args, "-o");
- mtr_add_arg($args, "%s/var/log/mysqltest.strace", $glob_mysql_test_dir);
+ mtr_add_arg($args, "%s/log/mysqltest.strace", $opt_vardir);
mtr_add_arg($args, "$exe_mysqltest");
}
if ( $opt_timer )
{
- mtr_add_arg($args, "--timer-file=%s/var/log/timer", $glob_mysql_test_dir);
+ mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
}
if ( $opt_big_test )
@@ -2106,8 +2144,7 @@ sub run_mysqltest ($$) {
if ( $opt_debug )
{
- mtr_add_arg($args, "--debug=d:t:A,%s/var/log/mysqltest.trace",
- $glob_mysql_test_dir);
+ mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir);
}
if ( $opt_with_openssl )
@@ -2129,7 +2166,7 @@ sub run_mysqltest ($$) {
mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[]);
}
- return mtr_run_test($exe_mysqltest,$args,$tinfo->{'path'},"",$path_timefile,"");
+ return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,"");
}
##############################################################################
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index bdbd46ae8dd..581c6c66fdd 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -569,10 +569,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
NDB_MGM="$BASEDIR/ndb/src/mgmclient/ndb_mgm"
if [ -n "$USE_PURIFY" ] ; then
- PSUP="$MYSQL_TEST_DIR/purify.suppress"
- echo "suppress UMR rw_read_held; mi_open; ha_myisam::open64; handler::ha_open; openfrm" > $PSUP
- echo "suppress UMR my_end; main" >> $PSUP
- echo "suppress UMR _doprnt; fprintf; my_end; main" >> $PSUP
+ PSUP="$MYSQL_TEST_DIR/suppress.purify"
PURIFYOPTIONS="-windows=no -log-file=%v.purifylog -append-logfile -add-suppression-files=$PSUP"
if [ -f "${MYSQL_TEST}-purify" ] ; then
MYSQL_TEST="${MYSQL_TEST}-purify"
@@ -1660,11 +1657,11 @@ run_testcase ()
$ECHO "$RES$RES_SPACE [ pass ] $TIMER"
else
# why the following ``if'' ? That is why res==1 is special ?
- if [ $res = 2 ]; then
+ if [ $res = 62 ]; then
skip_inc
$ECHO "$RES$RES_SPACE [ skipped ]"
else
- if [ $res -gt 2 ]; then
+ if [ $res -ne 1 ]; then
$ECHO "mysqltest returned unexpected code $res, it has probably crashed" >> $TIMEFILE
fi
total_inc
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 222477cece9..b7d47a09bee 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -303,6 +303,120 @@ ALTER TABLE t1 DISABLE KEYS;
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
ALTER TABLE t1 ENABLE KEYS;
drop table t1;
+CREATE TABLE t1 (
+Host varchar(16) binary NOT NULL default '',
+User varchar(16) binary NOT NULL default '',
+PRIMARY KEY (Host,User)
+) ENGINE=MyISAM;
+ALTER TABLE t1 DISABLE KEYS;
+LOCK TABLES t1 WRITE;
+INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
+t1 0 PRIMARY 2 User A 3 NULL NULL BTREE
+ALTER TABLE t1 ENABLE KEYS;
+UNLOCK TABLES;
+CHECK TABLES t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
+CREATE TABLE t1 (
+Host varchar(16) binary NOT NULL default '',
+User varchar(16) binary NOT NULL default '',
+PRIMARY KEY (Host,User),
+KEY (Host)
+) ENGINE=MyISAM;
+ALTER TABLE t1 DISABLE KEYS;
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
+t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
+t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
+LOCK TABLES t1 WRITE;
+INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
+t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
+t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
+ALTER TABLE t1 ENABLE KEYS;
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
+t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
+t1 1 Host 1 Host A 1 NULL NULL BTREE
+UNLOCK TABLES;
+CHECK TABLES t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+LOCK TABLES t1 WRITE;
+ALTER TABLE t1 RENAME t2;
+UNLOCK TABLES;
+select * from t2;
+Host User
+localhost
+localhost root
+DROP TABLE t2;
+CREATE TABLE t1 (
+Host varchar(16) binary NOT NULL default '',
+User varchar(16) binary NOT NULL default '',
+PRIMARY KEY (Host,User),
+KEY (Host)
+) ENGINE=MyISAM;
+LOCK TABLES t1 WRITE;
+ALTER TABLE t1 DISABLE KEYS;
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
+t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
+t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
+DROP TABLE t1;
+create table t1 (a int);
+alter table t1 rename to `t1\\`;
+ERROR 42000: Incorrect table name 't1\\'
+rename table t1 to `t1\\`;
+ERROR 42000: Incorrect table name 't1\\'
+drop table t1;
+drop table if exists t1, t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
+create table t1 ( a varchar(10) not null primary key ) engine=myisam;
+create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
+flush tables;
+alter table t1 modify a varchar(10);
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` varchar(10) NOT NULL default '',
+ PRIMARY KEY (`a`)
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
+flush tables;
+alter table t1 modify a varchar(10) not null;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` varchar(10) NOT NULL default '',
+ PRIMARY KEY (`a`)
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
+drop table if exists t1, t2;
+create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
+insert into t1 (a) values(1);
+show table status like 't1';
+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 1 37 X X X X X X X X latin1_swedish_ci NULL
+alter table t1 modify a int;
+show table status like 't1';
+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 1 37 X X X X X X X X latin1_swedish_ci NULL
+drop table t1;
+create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
+insert into t1 (a) values(1);
+show table status like 't1';
+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 1 37 X X X X X X X X latin1_swedish_ci NULL
+drop table t1;
set names koi8r;
create table t1 (a char(10) character set koi8r);
insert into t1 values ('ΤΕΣΤ');
@@ -382,75 +496,6 @@ t1 CREATE TABLE `t1` (
`mytext` longtext character set latin1 collate latin1_general_cs
) ENGINE=MyISAM DEFAULT CHARSET=latin2
drop table t1;
-CREATE TABLE t1 (
-Host varchar(16) binary NOT NULL default '',
-User varchar(16) binary NOT NULL default '',
-PRIMARY KEY (Host,User)
-) ENGINE=MyISAM;
-ALTER TABLE t1 DISABLE KEYS;
-LOCK TABLES t1 WRITE;
-INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
-SHOW INDEX FROM t1;
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
-t1 0 PRIMARY 2 User A 3 NULL NULL BTREE
-ALTER TABLE t1 ENABLE KEYS;
-UNLOCK TABLES;
-CHECK TABLES t1;
-Table Op Msg_type Msg_text
-test.t1 check status OK
-DROP TABLE t1;
-CREATE TABLE t1 (
-Host varchar(16) binary NOT NULL default '',
-User varchar(16) binary NOT NULL default '',
-PRIMARY KEY (Host,User),
-KEY (Host)
-) ENGINE=MyISAM;
-ALTER TABLE t1 DISABLE KEYS;
-SHOW INDEX FROM t1;
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
-t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
-t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
-LOCK TABLES t1 WRITE;
-INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
-SHOW INDEX FROM t1;
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
-t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
-t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
-ALTER TABLE t1 ENABLE KEYS;
-SHOW INDEX FROM t1;
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
-t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
-t1 1 Host 1 Host A 1 NULL NULL BTREE
-UNLOCK TABLES;
-CHECK TABLES t1;
-Table Op Msg_type Msg_text
-test.t1 check status OK
-LOCK TABLES t1 WRITE;
-ALTER TABLE t1 RENAME t2;
-UNLOCK TABLES;
-select * from t2;
-Host User
-localhost
-localhost root
-DROP TABLE t2;
-CREATE TABLE t1 (
-Host varchar(16) binary NOT NULL default '',
-User varchar(16) binary NOT NULL default '',
-PRIMARY KEY (Host,User),
-KEY (Host)
-) ENGINE=MyISAM;
-LOCK TABLES t1 WRITE;
-ALTER TABLE t1 DISABLE KEYS;
-SHOW INDEX FROM t1;
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
-t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
-t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
-DROP TABLE t1;
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
@@ -469,12 +514,6 @@ alter table t1 drop key no_such_key;
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
alter table t1 drop key a;
drop table t1;
-create table t1 (a int);
-alter table t1 rename to `t1\\`;
-ERROR 42000: Incorrect table name 't1\\'
-rename table t1 to `t1\\`;
-ERROR 42000: Incorrect table name 't1\\'
-drop table t1;
create table t1 (a text) character set koi8r;
insert into t1 values (_koi8r'ΤΕΣΤ');
select hex(a) from t1;
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index 428b2769fdb..9f3695cb1b1 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -341,3 +341,17 @@ a b
2 3
3 4
drop table t1;
+CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
+INSERT INTO t1 (b) VALUES ('aaaa');
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (b) VALUES ('');
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (b) VALUES ('bbbb');
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 3face9b1ba6..5902dd247ce 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -598,6 +598,24 @@ ucs2_bin 00610009
ucs2_bin 0061
ucs2_bin 00610020
drop table t1;
+select hex(substr(_ucs2 0x00e400e50068,1));
+hex(substr(_ucs2 0x00e400e50068,1))
+00E400E50068
+select hex(substr(_ucs2 0x00e400e50068,2));
+hex(substr(_ucs2 0x00e400e50068,2))
+00E50068
+select hex(substr(_ucs2 0x00e400e50068,3));
+hex(substr(_ucs2 0x00e400e50068,3))
+0068
+select hex(substr(_ucs2 0x00e400e50068,-1));
+hex(substr(_ucs2 0x00e400e50068,-1))
+0068
+select hex(substr(_ucs2 0x00e400e50068,-2));
+hex(substr(_ucs2 0x00e400e50068,-2))
+00E50068
+select hex(substr(_ucs2 0x00e400e50068,-3));
+hex(substr(_ucs2 0x00e400e50068,-3))
+00E400E50068
SET NAMES latin1;
SET collation_connection='ucs2_swedish_ci';
CREATE TABLE t1 (Field1 int(10) default '0');
diff --git a/mysql-test/r/have_outfile.require b/mysql-test/r/have_outfile.require
new file mode 100644
index 00000000000..9fc2f8fdb5a
--- /dev/null
+++ b/mysql-test/r/have_outfile.require
@@ -0,0 +1,3 @@
+load_file(concat(@tmpdir,"/outfile.test"))
+Outfile OK
+
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index a8af3f5f658..4c983014d4b 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1643,3 +1643,7 @@ select distinct concat(a, b) from t1;
concat(a, b)
11113333
drop table t1;
+CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
+SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
+ERROR HY000: The used table type doesn't support FULLTEXT indexes
+DROP TABLE t1;
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index f78372541f2..2143538469b 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -167,7 +167,7 @@ a b c VALUES(a)
2 1 11 NULL
DROP TABLE t1;
DROP TABLE t2;
-create table t1 (a int not null unique);
+create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2;
select * from t1;
@@ -179,4 +179,11 @@ select * from t1;
a
1
3
+insert into t1 select 1 on duplicate key update a=2;
+select * from t1;
+a
+2
+3
+insert into t1 select a from t1 on duplicate key update a=a+1 ;
+ERROR 23000: Duplicate entry '3' for key 1
drop table t1;
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 5b69ce68a79..4def82e5752 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -581,3 +581,17 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+create table t1 (a int, key(a));
+insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+show keys 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 A 8 NULL NULL YES BTREE
+alter table t1 disable keys;
+alter table t1 enable keys;
+show keys 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 A 8 NULL NULL YES BTREE
+drop table t1;
diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result
index 4dc09f65b7c..5eb24a78ef0 100644
--- a/mysql-test/r/outfile.result
+++ b/mysql-test/r/outfile.result
Binary files differ
diff --git a/mysql-test/r/ps_grant.result b/mysql-test/r/ps_grant.result
index 4c60bb03165..0787f30c643 100644
--- a/mysql-test/r/ps_grant.result
+++ b/mysql-test/r/ps_grant.result
@@ -1,7 +1,3 @@
-prepare stmt4 from ' show full processlist ';
-execute stmt4;
-Id User Host db Command Time State Info
-number root localhost test Query time NULL show full processlist
test_sequence
------ grant/revoke/drop affects a parallel session test ------
show grants for second_user@localhost ;
@@ -79,3 +75,7 @@ commit ;
show grants for second_user@localhost ;
ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost'
drop database mysqltest;
+prepare stmt4 from ' show full processlist ';
+execute stmt4;
+Id User Host db Command Time State Info
+number root localhost test Query time NULL show full processlist
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 50300ed9b76..387e7eff693 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2451,7 +2451,7 @@ a
select distinct distinct * from t1;
a
select all distinct * from t1;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct * from t1' at line 1
+ERROR HY000: Incorrect usage of ALL and DISTINCT
select distinct all * from t1;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all * from t1' at line 1
+ERROR HY000: Incorrect usage of ALL and DISTINCT
drop table t1;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 8f17f545d1a..1f3542802a7 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -2697,3 +2697,27 @@ 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` (
+`itemid` bigint(20) unsigned NOT NULL auto_increment,
+`sessionid` bigint(20) unsigned default NULL,
+`time` int(10) unsigned NOT NULL default '0',
+`type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT
+NULL default '',
+`data` text collate latin1_general_ci NOT NULL,
+PRIMARY KEY (`itemid`)
+) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO `t1` VALUES (1, 1, 1, 'D', '');
+CREATE TABLE `t2` (
+`sessionid` bigint(20) unsigned NOT NULL auto_increment,
+`pid` int(10) unsigned NOT NULL default '0',
+`date` int(10) unsigned NOT NULL default '0',
+`ip` varchar(15) collate latin1_general_ci NOT NULL default '',
+PRIMARY KEY (`sessionid`)
+) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
+SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
+ip count( e.itemid )
+10.10.10.1 1
+drop tables t1,t2;
diff --git a/mysql-test/suppress.purify b/mysql-test/suppress.purify
new file mode 100644
index 00000000000..58553130c51
--- /dev/null
+++ b/mysql-test/suppress.purify
@@ -0,0 +1,10 @@
+suppress UMR rw_read_held; mi_open; ha_myisam::open64; handler::ha_open; openfrm
+suppress UMR my_end; main
+suppress UMR _doprnt; fprintf; my_end; main
+suppress umr rw_read_held; mi_open
+suppress umr _putmsg; putmsg; _tx_sndudata
+suppress umr rw_read_held; Query_cache::store_query(THD*,st_table_list*); mysql_execute_command(THD*)
+suppress sig ...; _select; select; handle_connections_sockets; main; _start
+suppress sig ...; read; vio_read; my_real_read(st_net*,unsigned long*); my_net_read; do_command(THD*)
+suppress sig ...; read; vio_read; my_real_read(st_net*,unsigned long*); my_net_read; net_safe_read
+suppress sig ...; write; vio_write; net_real_write; net_write_buff(st_net*,const char*,unsigned long); my_net_write
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index 92651442041..c3ba2c8a7a4 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -166,56 +166,6 @@ ALTER TABLE t1 ENABLE KEYS;
drop table t1;
#
-# Test that data get converted when character set is changed
-# Test that data doesn't get converted when src or dst is BINARY/BLOB
-#
-set names koi8r;
-create table t1 (a char(10) character set koi8r);
-insert into t1 values ('ΤΕΣΤ');
-select a,hex(a) from t1;
-alter table t1 change a a char(10) character set cp1251;
-select a,hex(a) from t1;
-alter table t1 change a a binary(10);
-select a,hex(a) from t1;
-alter table t1 change a a char(10) character set cp1251;
-select a,hex(a) from t1;
-alter table t1 change a a char(10) character set koi8r;
-select a,hex(a) from t1;
-alter table t1 change a a varchar(10) character set cp1251;
-select a,hex(a) from t1;
-alter table t1 change a a char(10) character set koi8r;
-select a,hex(a) from t1;
-alter table t1 change a a text character set cp1251;
-select a,hex(a) from t1;
-alter table t1 change a a char(10) character set koi8r;
-select a,hex(a) from t1;
-delete from t1;
-
-#
-# Test ALTER TABLE .. CHARACTER SET ..
-#
-show create table t1;
-alter table t1 DEFAULT CHARACTER SET latin1;
-show create table t1;
-alter table t1 CONVERT TO CHARACTER SET latin1;
-show create table t1;
-alter table t1 DEFAULT CHARACTER SET cp1251;
-show create table t1;
-
-drop table t1;
-
-#
-# Bug#2821
-# Test that table CHARACTER SET does not affect blobs
-#
-create table t1 (myblob longblob,mytext longtext)
-default charset latin1 collate latin1_general_cs;
-show create table t1;
-alter table t1 character set latin2;
-show create table t1;
-drop table t1;
-
-#
# Test ALTER TABLE ENABLE/DISABLE keys when things are locked
#
@@ -278,6 +228,97 @@ SHOW INDEX FROM t1;
DROP TABLE t1;
#
+# BUG#4717 - check for valid table names
+#
+create table t1 (a int);
+--error 1103
+alter table t1 rename to `t1\\`;
+--error 1103
+rename table t1 to `t1\\`;
+drop table t1;
+
+#
+# BUG#6236 - ALTER TABLE MODIFY should set implicit NOT NULL on PK columns
+#
+drop table if exists t1, t2;
+create table t1 ( a varchar(10) not null primary key ) engine=myisam;
+create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
+flush tables;
+alter table t1 modify a varchar(10);
+show create table t2;
+flush tables;
+alter table t1 modify a varchar(10) not null;
+show create table t2;
+drop table if exists t1, t2;
+
+# The following is also part of bug #6236 (CREATE TABLE didn't properly count
+# not null columns for primary keys)
+
+create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
+insert into t1 (a) values(1);
+--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
+show table status like 't1';
+alter table t1 modify a int;
+--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
+show table status like 't1';
+drop table t1;
+create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
+insert into t1 (a) values(1);
+--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
+show table status like 't1';
+drop table t1;
+
+#
+# Test that data get converted when character set is changed
+# Test that data doesn't get converted when src or dst is BINARY/BLOB
+#
+set names koi8r;
+create table t1 (a char(10) character set koi8r);
+insert into t1 values ('ΤΕΣΤ');
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a binary(10);
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+alter table t1 change a a varchar(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+alter table t1 change a a text character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+delete from t1;
+
+#
+# Test ALTER TABLE .. CHARACTER SET ..
+#
+show create table t1;
+alter table t1 DEFAULT CHARACTER SET latin1;
+show create table t1;
+alter table t1 CONVERT TO CHARACTER SET latin1;
+show create table t1;
+alter table t1 DEFAULT CHARACTER SET cp1251;
+show create table t1;
+
+drop table t1;
+
+#
+# Bug#2821
+# Test that table CHARACTER SET does not affect blobs
+#
+create table t1 (myblob longblob,mytext longtext)
+default charset latin1 collate latin1_general_cs;
+show create table t1;
+alter table t1 character set latin2;
+show create table t1;
+drop table t1;
+
+#
# Bug 2361 (Don't drop UNIQUE with DROP PRIMARY KEY)
#
@@ -297,16 +338,6 @@ alter table t1 drop key a;
drop table t1;
#
-# BUG#4717 - check for valid table names
-#
-create table t1 (a int);
---error 1103
-alter table t1 rename to `t1\\`;
---error 1103
-rename table t1 to `t1\\`;
-drop table t1;
-
-#
# Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
#
# The column's character set was changed but the actual data was not
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 8e11a3d68a5..ef344df5fb6 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -206,3 +206,15 @@ alter table t1 modify b varchar(255);
insert into t1 values (0,4);
select * from t1;
drop table t1;
+
+#
+# BUG #10045: Problem with composite AUTO_INCREMENT + BLOB key
+
+CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
+INSERT INTO t1 (b) VALUES ('aaaa');
+CHECK TABLE t1;
+INSERT INTO t1 (b) VALUES ('');
+CHECK TABLE t1;
+INSERT INTO t1 (b) VALUES ('bbbb');
+CHECK TABLE t1;
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index db5b13cf1b4..6c72c409463 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -374,6 +374,16 @@ SET NAMES latin1;
SET collation_connection='ucs2_bin';
-- source include/ctype_filesort.inc
+#
+# Bug#10344 Some string functions fail for UCS2
+#
+select hex(substr(_ucs2 0x00e400e50068,1));
+select hex(substr(_ucs2 0x00e400e50068,2));
+select hex(substr(_ucs2 0x00e400e50068,3));
+select hex(substr(_ucs2 0x00e400e50068,-1));
+select hex(substr(_ucs2 0x00e400e50068,-2));
+select hex(substr(_ucs2 0x00e400e50068,-3));
+
SET NAMES latin1;
#
# Bug#8235
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 4e18cfb224b..201489c0ddb 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -1177,3 +1177,13 @@ create table t1(a int(1) , b int(1)) engine=innodb;
insert into t1 values ('1111', '3333');
select distinct concat(a, b) from t1;
drop table t1;
+
+#
+# BUG#7709 test case - Boolean fulltext query against unsupported
+# engines does not fail
+#
+
+CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
+--error 1214;
+SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
+DROP TABLE t1;
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
index 0fa366586b3..f5857840588 100644
--- a/mysql-test/t/insert_update.test
+++ b/mysql-test/t/insert_update.test
@@ -85,10 +85,14 @@ DROP TABLE t2;
# Bug#9725 - "disapearing query/hang" and "unknown error" with "on duplicate key update"
# INSERT INGORE...UPDATE gives bad error or breaks protocol.
#
-create table t1 (a int not null unique);
+create table t1 (a int not null unique) engine=myisam;
insert into t1 values (1),(2);
insert ignore into t1 select 1 on duplicate key update a=2;
select * from t1;
insert ignore into t1 select a from t1 on duplicate key update a=a+1 ;
select * from t1;
+insert into t1 select 1 on duplicate key update a=2;
+select * from t1;
+--error 1062
+insert into t1 select a from t1 on duplicate key update a=a+1 ;
drop table t1;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 46a6499adad..7d7985fd8ac 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -560,3 +560,18 @@ update t1 set c2='A B' where c1=2;
check table t1;
drop table t1;
+
+# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
+# different statistics on the same table with NULL values.
+create table t1 (a int, key(a));
+
+insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
+analyze table t1;
+show keys from t1;
+
+alter table t1 disable keys;
+alter table t1 enable keys;
+show keys from t1;
+
+drop table t1;
+
diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test
index 59ce6cc56fe..4b12f9e4e50 100644
--- a/mysql-test/t/outfile.test
+++ b/mysql-test/t/outfile.test
@@ -1,3 +1,9 @@
+disable_query_log;
+-- source include/test_outfile.inc
+eval set @tmpdir="$MYSQL_TEST_DIR/var/tmp";
+enable_query_log;
+-- source include/have_outfile.inc
+
#
# test of into outfile|dumpfile
#
@@ -6,29 +12,45 @@
drop table if exists t1;
--enable_warnings
-# We need to check that we have 'file' privilege.
+create table t1 (`a` blob);
+insert into t1 values("hello world"),("Hello mars"),(NULL);
+disable_query_log;
+eval select * into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.1" from t1;
+enable_query_log;
+select load_file(concat(@tmpdir,"/outfile-test.1"));
+disable_query_log;
+eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.2" from t1 limit 1;
+enable_query_log;
+select load_file(concat(@tmpdir,"/outfile-test.2"));
+disable_query_log;
+eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.3" from t1 where a is null;
+enable_query_log;
+select load_file(concat(@tmpdir,"/outfile-test.3"));
-#create table t1 (`a` blob);
-#insert into t1 values("hello world"),("Hello mars"),(NULL);
-#select * into outfile "/tmp/select-test.1" from t1;
-#select load_file("/tmp/select-test.1");
-#select * into dumpfile "/tmp/select-test.2" from t1 limit 1;
-#select load_file("/tmp/select-test.2");
-#select * into dumpfile "/tmp/select-test.3" from t1 where a is null;
-#select load_file("/tmp/select-test.3");
-#
-## the following should give errors
-#
-#select * into outfile "/tmp/select-test.1" from t1;
-#select * into dumpfile "/tmp/select-test.1" from t1;
-#select * into dumpfile "/tmp/select-test.99" from t1;
-#select load_file("/tmp/select-test.not-exist");
-#drop table t1;
-#drop table if exists t;
-#CREATE TABLE t ( t timestamp NOT NULL, c char(200) character set latin1 NOT NULL default '', i int(11), v varchar(200), b blob, KEY t (t)) ENGINE=MyISAM;
-#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb");
-#select * from t into outfile "check";
-#drop table if exists t;
+# the following should give errors
+
+#disabled as error message has variable path
+#disable_query_log;
+#--error 1086
+#eval select * into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.1" from t1;
+#--error 1086
+#eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.2" from t1;
+#--error 1086
+#eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.3" from t1;
+#enable_query_log;
+--error 13,2
+select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
+--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.1
+--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.2
+--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.3
+drop table t1;
+
+# Bug#8191
+disable_query_log;
+eval select 1 into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.4";
+enable_query_log;
+select load_file(concat(@tmpdir,"/outfile-test.4"));
+--exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.4
#
# Bug #5382: 'explain select into outfile' crashes the server
diff --git a/mysql-test/t/ps_grant.test b/mysql-test/t/ps_grant.test
index 06613072824..d6448dd152a 100644
--- a/mysql-test/t/ps_grant.test
+++ b/mysql-test/t/ps_grant.test
@@ -1,10 +1,6 @@
# Can't test grants with embedded server
-- source include/not_embedded.inc
-# Tested here simply so it is not tested with embedded server
-prepare stmt4 from ' show full processlist ';
---replace_column 1 number 6 time 3 localhost
-execute stmt4;
let $type= 'MYISAM' ;
@@ -116,4 +112,9 @@ show grants for second_user@localhost ;
drop database mysqltest;
+# Tested here simply so it is not tested with embedded server
+prepare stmt4 from ' show full processlist ';
+--replace_column 1 number 6 time 3 localhost
+execute stmt4;
+
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 6d6d5f6b6e1..a46522c1510 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -1987,9 +1987,9 @@ drop table t1;
create table t1 (a int(11));
select all all * from t1;
select distinct distinct * from t1;
---error 1064
+--error 1221
select all distinct * from t1;
---error 1064
+--error 1221
select distinct all * from t1;
drop table t1;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 1882a04936c..e585022563f 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1722,3 +1722,27 @@ select (1,2,3) = (select * from t1);
-- error 1241
select (select * from t1) = (1,2,3);
drop table t1
+
+#
+# Item_int_with_ref check (BUG#10020)
+#
+CREATE TABLE `t1` (
+ `itemid` bigint(20) unsigned NOT NULL auto_increment,
+ `sessionid` bigint(20) unsigned default NULL,
+ `time` int(10) unsigned NOT NULL default '0',
+ `type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT
+NULL default '',
+ `data` text collate latin1_general_ci NOT NULL,
+ PRIMARY KEY (`itemid`)
+) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO `t1` VALUES (1, 1, 1, 'D', '');
+CREATE TABLE `t2` (
+ `sessionid` bigint(20) unsigned NOT NULL auto_increment,
+ `pid` int(10) unsigned NOT NULL default '0',
+ `date` int(10) unsigned NOT NULL default '0',
+ `ip` varchar(15) collate latin1_general_ci NOT NULL default '',
+ PRIMARY KEY (`sessionid`)
+) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
+SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
+drop tables t1,t2;
diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc
index 7c6e7cb56b6..c9c94b3a9d7 100644
--- a/sql/ha_blackhole.cc
+++ b/sql/ha_blackhole.cc
@@ -129,8 +129,9 @@ THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
+ if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
+ lock.type=lock_type;
*to++= &lock;
-
return to;
}
diff --git a/sql/handler.h b/sql/handler.h
index df623afcd79..de932cd51a4 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -204,6 +204,7 @@ typedef struct st_ha_create_information
SQL_LIST merge_list;
enum db_type db_type;
enum row_type row_type;
+ uint null_bits; /* NULL bits at start of record */
uint options; /* OR of HA_CREATE_ options */
uint raid_type,raid_chunks;
uint merge_insert_method;
diff --git a/sql/hostname.cc b/sql/hostname.cc
index ec5c6f29a27..39223556024 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -209,8 +209,8 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
if (errno == HOST_NOT_FOUND || errno == NO_DATA)
- add_wrong_ip(in); /* only cache negative responses, not failures */
-
+ goto add_wrong_ip_and_return;
+ /* Failure, don't cache responce */
DBUG_RETURN(0);
}
if (!hp->h_name[0]) // Don't allow empty hostnames
diff --git a/sql/item.cc b/sql/item.cc
index 6c1506e10e8..59785813566 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2034,7 +2034,7 @@ bool Item_int::eq(const Item *arg, bool binary_cmp) const
Item *Item_int_with_ref::new_item()
{
- DBUG_ASSERT(ref->basic_const_item());
+ DBUG_ASSERT(ref->const_item());
/*
We need to evaluate the constant to make sure it works with
parameter markers.
diff --git a/sql/item.h b/sql/item.h
index 8fed871e623..2edbeef400c 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1027,12 +1027,14 @@ public:
void print(String *str);
};
+
/*
The following class is used to optimize comparing of date and bigint columns
- We need to save the original item, to be able to set the field to the
- original value in 'opt_range'.
- An instance of Item_int_with_ref may refer to a signed or an unsigned
- integer.
+ We need to save the original item ('ref') to be able to call
+ ref->save_in_field(). This is used to create index search keys.
+
+ An instance of Item_int_with_ref may have signed or unsigned integer value.
+
*/
class Item_int_with_ref :public Item_int
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 9c6c19f3ec9..05b76eb1604 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3174,6 +3174,11 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
return 1;
}
table=((Item_field *)item)->field->table;
+ if (!(table->file->table_flags() & HA_CAN_FULLTEXT))
+ {
+ my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0));
+ return 1;
+ }
table->fulltext_searched=1;
return agg_arg_collations_for_comparison(cmp_collation, args+1, arg_count-1);
}
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 384625f7112..4983d39714a 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -262,7 +262,7 @@ character-set=latin1
"Key reference and table reference don't match",
"Operand should contain %d column(s)",
"Subquery returns more than 1 row",
-"Unknown prepared statement handler (%ld) given to %s",
+"Unknown prepared statement handler (%.*s) given to %s",
"Help database is corrupt or does not exist",
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index accf1926abb..adda7d7cf53 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -252,7 +252,7 @@ character-set=cp1250
"Key reference and table reference don't match",
"Operand should contain %d column(s)",
"Subquery returns more than 1 row",
-"Unknown prepared statement handler (%ld) given to %s",
+"Unknown prepared statement handler (%.*s) given to %s",
"Help database is corrupt or does not exist",
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index c03edfdb012..67aade519f5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -451,7 +451,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
const char *key_name;
create_field *sql_field,*dup_field;
uint field,null_fields,blob_columns;
- ulong pos;
+ ulong record_offset= 0;
KEY *key_info;
KEY_PART_INFO *key_part_info;
int timestamps= 0, timestamps_with_niladic= 0;
@@ -629,10 +629,9 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
it2.rewind();
}
- /* If fixed row records, we need one bit to check for deleted rows */
- if (!(db_options & HA_OPTION_PACK_RECORD))
- null_fields++;
- pos=(null_fields+7)/8;
+
+ /* record_offset will be increased with 'length-of-null-bits' later */
+ record_offset= 0;
it.rewind();
while ((sql_field=it++))
@@ -737,10 +736,10 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (!(sql_field->flags & NOT_NULL_FLAG))
sql_field->pack_flag|=FIELDFLAG_MAYBE_NULL;
- sql_field->offset= pos;
+ sql_field->offset= record_offset;
if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
auto_increment++;
- pos+=sql_field->pack_length;
+ record_offset+= sql_field->pack_length;
}
if (timestamps_with_niladic > 1)
{
@@ -1048,6 +1047,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
/* Implicitly set primary key fields to NOT NULL for ISO conf. */
sql_field->flags|= NOT_NULL_FLAG;
sql_field->pack_flag&= ~FIELDFLAG_MAYBE_NULL;
+ null_fields--;
}
else
key_info->flags|= HA_NULL_PART_KEY;
@@ -1205,6 +1205,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
/* Sort keys in optimized order */
qsort((gptr) key_info_buffer, *key_count, sizeof(KEY),
(qsort_cmp) sort_keys);
+ create_info->null_bits= null_fields;
DBUG_RETURN(0);
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index abe7a716a69..28d3560e5f0 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2467,7 +2467,14 @@ select_from:
select_options:
/* empty*/
- | select_option_list;
+ | select_option_list
+ {
+ if (test_all_bits(Select->options, SELECT_ALL | SELECT_DISTINCT))
+ {
+ net_printf(Lex->thd, ER_WRONG_USAGE, "ALL", "DISTINCT");
+ YYABORT;
+ }
+ }
select_option_list:
select_option_list select_option
@@ -2481,15 +2488,7 @@ select_option:
YYABORT;
Lex->lock_option= TL_READ_HIGH_PRIORITY;
}
- | DISTINCT
- {
- if (Select->options & SELECT_ALL)
- {
- yyerror(ER(ER_SYNTAX_ERROR));
- YYABORT;
- }
- Select->options|= SELECT_DISTINCT;
- }
+ | DISTINCT { Select->options|= SELECT_DISTINCT; }
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
| SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
| SQL_BUFFER_RESULT
@@ -2509,15 +2508,7 @@ select_option:
{
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
}
- | ALL
- {
- if (Select->options & SELECT_DISTINCT)
- {
- yyerror(ER(ER_SYNTAX_ERROR));
- YYABORT;
- }
- Select->options|= SELECT_ALL;
- }
+ | ALL { Select->options|= SELECT_ALL; }
;
select_lock_type:
diff --git a/sql/unireg.cc b/sql/unireg.cc
index a550b06a466..72960640b1b 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -32,18 +32,21 @@
static uchar * pack_screens(List<create_field> &create_fields,
uint *info_length, uint *screens, bool small_file);
-static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info);
+static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info,
+ ulong data_offset);
static bool pack_header(uchar *forminfo,enum db_type table_type,
List<create_field> &create_fields,
uint info_length, uint screens, uint table_options,
- handler *file);
+ ulong data_offset, handler *file);
static uint get_interval_id(uint *int_count,List<create_field> &create_fields,
create_field *last_field);
-static bool pack_fields(File file, List<create_field> &create_fields);
+static bool pack_fields(File file, List<create_field> &create_fields,
+ ulong data_offset);
static bool make_empty_rec(int file, enum db_type table_type,
uint table_options,
List<create_field> &create_fields,
- uint reclength,uint null_fields);
+ uint reclength, uint null_fields,
+ ulong data_offset);
/*
Create a frm (table definition) file
@@ -71,7 +74,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
{
uint reclength,info_length,screens,key_info_length,maxlength,null_fields;
File file;
- ulong filepos;
+ ulong filepos, data_offset;
uchar fileinfo[64],forminfo[288],*keybuff;
TYPELIB formnames;
uchar *screen_buff;
@@ -81,9 +84,16 @@ bool mysql_create_frm(THD *thd, my_string file_name,
if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,0)))
DBUG_RETURN(1);
if (db_file == NULL)
- db_file=get_new_handler((TABLE*) 0, create_info->db_type);
+ db_file= get_new_handler((TABLE*) 0, create_info->db_type);
+
+ /* If fixed row records, we need one bit to check for deleted rows */
+ if (!(create_info->table_options & HA_OPTION_PACK_RECORD))
+ create_info->null_bits++;
+ data_offset= (create_info->null_bits + 7) / 8;
+
if (pack_header(forminfo, create_info->db_type,create_fields,info_length,
- screens, create_info->table_options, db_file))
+ screens, create_info->table_options,
+ data_offset, db_file))
{
my_free((gptr) screen_buff,MYF(0));
if (thd->net.last_errno != ER_TOO_MANY_FIELDS)
@@ -94,7 +104,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1)))
DBUG_RETURN(1);
if (pack_header(forminfo, create_info->db_type, create_fields,info_length,
- screens, create_info->table_options, db_file))
+ screens, create_info->table_options, data_offset, db_file))
{
my_free((gptr) screen_buff,MYF(0));
DBUG_RETURN(1);
@@ -112,7 +122,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
uint key_buff_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
keybuff=(uchar*) my_malloc(key_buff_length, MYF(0));
- key_info_length=pack_keys(keybuff,keys,key_info);
+ key_info_length= pack_keys(keybuff, keys, key_info, data_offset);
VOID(get_form_pos(file,fileinfo,&formnames));
if (!(filepos=make_new_entry(file,fileinfo,&formnames,"")))
goto err;
@@ -135,13 +145,13 @@ bool mysql_create_frm(THD *thd, my_string file_name,
(ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
MY_SEEK_SET,MYF(0)));
if (make_empty_rec(file,create_info->db_type,create_info->table_options,
- create_fields,reclength,null_fields))
+ create_fields,reclength, null_fields, data_offset))
goto err;
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
if (my_write(file,(byte*) forminfo,288,MYF_RW) ||
my_write(file,(byte*) screen_buff,info_length,MYF_RW) ||
- pack_fields(file,create_fields))
+ pack_fields(file, create_fields, data_offset))
goto err;
#ifdef HAVE_CRYPTED_FRM
@@ -313,7 +323,8 @@ static uchar * pack_screens(List<create_field> &create_fields,
/* Pack keyinfo and keynames to keybuff for save in form-file. */
-static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
+static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
+ ulong data_offset)
{
uint key_parts,length;
uchar *pos, *keyname_pos;
@@ -340,10 +351,13 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
key_part++)
{
- DBUG_PRINT("loop",("field: %d startpos: %ld length: %ld",
- key_part->fieldnr,key_part->offset,key_part->length));
+ uint offset;
+ DBUG_PRINT("loop",("field: %d startpos: %lu length: %ld",
+ key_part->fieldnr, key_part->offset + data_offset,
+ key_part->length));
int2store(pos,key_part->fieldnr+1+FIELD_NAME_USED);
- int2store(pos+2,key_part->offset+1);
+ offset= (uint) (key_part->offset+data_offset+1);
+ int2store(pos+2, offset);
pos[4]=0; // Sort order
int2store(pos+5,key_part->key_type);
int2store(pos+7,key_part->length);
@@ -384,8 +398,8 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
static bool pack_header(uchar *forminfo, enum db_type table_type,
List<create_field> &create_fields,
- uint info_length, uint screens,uint table_options,
- handler *file)
+ uint info_length, uint screens, uint table_options,
+ ulong data_offset, handler *file)
{
uint length,int_count,int_length,no_empty, int_parts;
uint time_stamp_pos,null_fields;
@@ -425,10 +439,10 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
if (field->sql_type == FIELD_TYPE_TIMESTAMP &&
MTYP_TYPENR(field->unireg_check) != Field::NONE &&
!time_stamp_pos)
- time_stamp_pos=(int) field->offset+1;
+ time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1;
length=field->pack_length;
- if ((int) field->offset+length > reclength)
- reclength=(int) field->offset+length;
+ if ((uint) field->offset+ (uint) data_offset+ length > reclength)
+ reclength=(uint) (field->offset+ data_offset + length);
n_length+= (ulong) strlen(field->field_name)+1;
field->interval_id=0;
if (field->interval)
@@ -538,7 +552,8 @@ static uint get_interval_id(uint *int_count,List<create_field> &create_fields,
/* Save fields, fieldnames and intervals */
-static bool pack_fields(File file,List<create_field> &create_fields)
+static bool pack_fields(File file, List<create_field> &create_fields,
+ ulong data_offset)
{
reg2 uint i;
uint int_count, comment_length=0;
@@ -553,11 +568,13 @@ static bool pack_fields(File file,List<create_field> &create_fields)
int_count=0;
while ((field=it++))
{
+ uint recpos;
buff[0]= (uchar) field->row;
buff[1]= (uchar) field->col;
buff[2]= (uchar) field->sc_length;
int2store(buff+3, field->length);
- uint recpos=(uint) field->offset+1;
+ /* The +1 is here becasue the col offset in .frm file have offset 1 */
+ recpos= field->offset+1 + (uint) data_offset;
int3store(buff+5,recpos);
int2store(buff+8,field->pack_flag);
int2store(buff+10,field->unireg_check);
@@ -643,11 +660,12 @@ static bool pack_fields(File file,List<create_field> &create_fields)
static bool make_empty_rec(File file,enum db_type table_type,
uint table_options,
List<create_field> &create_fields,
- uint reclength, uint null_fields)
+ uint reclength, uint null_fields,
+ ulong data_offset)
{
int error;
Field::utype type;
- uint firstpos,null_count,null_length;
+ uint firstpos,null_count;
uchar *buff,*null_pos;
TABLE table;
create_field *field;
@@ -672,17 +690,16 @@ static bool make_empty_rec(File file,enum db_type table_type,
firstpos=reclength;
null_count=0;
if (!(table_options & HA_OPTION_PACK_RECORD))
- {
- null_fields++; // Need one bit for delete mark
- null_count++;
- }
- bfill(buff,(null_length=(null_fields+7)/8),255);
+ null_count++; // Need one bit for delete mark
+ DBUG_ASSERT(data_offset == ((null_fields + null_count + 7) / 8));
+ bfill(buff, (uint) data_offset, 255);
null_pos=buff;
List_iterator<create_field> it(create_fields);
while ((field=it++))
{
- Field *regfield=make_field((char*) buff+field->offset,field->length,
+ Field *regfield=make_field((char*) buff+field->offset + data_offset,
+ field->length,
field->flags & NOT_NULL_FLAG ? 0:
null_pos+null_count/8,
1 << (null_count & 7),
@@ -698,9 +715,9 @@ static bool make_empty_rec(File file,enum db_type table_type,
if (!(field->flags & NOT_NULL_FLAG))
null_count++;
- if ((uint) field->offset < firstpos &&
+ if ((uint) (field->offset + data_offset) < firstpos &&
regfield->type() != FIELD_TYPE_NULL)
- firstpos= field->offset;
+ firstpos= field->offset + data_offset;
type= (Field::utype) MTYP_TYPENR(field->unireg_check);
@@ -724,8 +741,8 @@ static bool make_empty_rec(File file,enum db_type table_type,
}
/* Fill not used startpos */
- bfill((byte*) buff+null_length,firstpos-null_length,255);
- error=(int) my_write(file,(byte*) buff,(uint) reclength,MYF_RW);
+ bfill((byte*) buff+data_offset, firstpos- (uint) data_offset, 255);
+ error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW);
my_free((gptr) buff,MYF(MY_FAE));
delete handler;
DBUG_RETURN(error);
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 07b30205f89..52886116ff2 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6285,7 +6285,7 @@ uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
const char *emb= e - 1; /* Last possible end of an MB character */
*error= 0;
- while (pos && b < e)
+ while (pos-- && b < e)
{
if ((uchar) b[0] < 128)
{
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c
index 0db38afa1f7..d9e3bbd5866 100644
--- a/strings/ctype-cp932.c
+++ b/strings/ctype-cp932.c
@@ -5417,7 +5417,7 @@ uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)),
{
const char *b0= b;
*error= 0;
- while (pos && b < e)
+ while (pos-- && b < e)
{
/*
Cast to int8 for extra safety.
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index f5d0721fa9b..12c1ae905cf 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1251,7 +1251,7 @@ static
uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e)
{
- return (e-b)/2;
+ return (uint) (e-b)/2;
}
@@ -1261,7 +1261,8 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *e __attribute__((unused)),
uint pos)
{
- return pos*2;
+ uint string_length= (uint) (e - b);
+ return pos > string_length ? string_length + 2 : pos * 2;
}
@@ -1270,7 +1271,8 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e,
uint nchars, int *error)
{
- uint nbytes= (e-b) & ~ (uint)1;
+ /* Ensure string length is dividable with 2 */
+ uint nbytes= ((uint) (e-b)) & ~(uint) 1;
*error= 0;
nchars*= 2;
return min(nbytes, nchars);