Commit b3021da2 authored by unknown's avatar unknown

Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.0

into sinisa.nasamreza.org:/mnt/work/mysql-4.0


sql/item_cmpfunc.cc:
  Auto merged
parents 9f353c22 906dc7df
......@@ -56,6 +56,7 @@ monty@bitch.mysql.fi
monty@butch.
monty@donna.mysql.fi
monty@hundin.mysql.fi
monty@mashka.(none)
monty@mashka.mysql.fi
monty@narttu.
monty@narttu.mysql.fi
......@@ -71,6 +72,7 @@ mysqldev@build.mysql2.com
nick@mysql.com
nick@nick.leippe.com
paul@central.snake.net
paul@ice.local
paul@teton.kitebird.com
pem@mysql.com
peter@linux.local
......
......@@ -38,11 +38,13 @@ $opt_export_only= undef;
$opt_help= $opt_verbose= 0;
$opt_log= undef;
$opt_mail= "";
$opt_revision= undef;
$opt_suffix= "";
$opt_test= undef;
$opt_skip_check= undef;
$opt_skip_manual= undef;
$version= "unknown";
$major=$minor=$release=0;
GetOptions(
"build-command|b=s",
......@@ -149,6 +151,7 @@ if (!$opt_dry_run)
{
m/^AM_INIT_AUTOMAKE\(mysql, ([1-9]\.[0-9]{1,2}\.[0-9]{1,2}.*)\)/;
$version= $1;
($major, $minor, $release) = split(/\./,$version);
}
&logger("Found version string: $version");
......@@ -218,7 +221,7 @@ if (defined $opt_changelog)
{
if (!$opt_revision)
{
$revision= `bk changes -t -d':REV:' -n $REPO | head -1`;
$revision= `bk changes -t -d':REV:::TAG:' -n $REPO | grep mysql-$major.$minor | head -1 | cut -f1 -d ":"`;
}
else
{
......
......@@ -208,7 +208,7 @@ INSTALL-BINARY: mysql.info $(GT)
perl -w $(GT) mysql.info "LGPL license" "Function Index" > $@
../support-files/MacOSX/ReadMe.txt: mysql.info $(GT)
perl -w $(GT) mysql.info "Mac OS X installation" "Netware installation" > $@
perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@
# Don't update the files from bitkeeper
%::SCCS/s.%
#!/my/gnu/bin/perl -w -*- perl -*-
#!/usr/bin/perl -w -*- perl -*-
# Generate text files from top directory from the manual.
$from = shift(@ARGV);
$fnode = shift(@ARGV);
$tnode = shift(@ARGV);
open(IN, "$from") || die;
open(IN, "$from") || die "Cannot open $from: $!";
$in = 0;
......@@ -19,7 +19,7 @@ while (<IN>)
}
elsif (/^File: mysql.info/ || (/^/))
{
# Just Skip node begginigs
# Just Skip node beginnings
}
else
{
......@@ -38,3 +38,6 @@ while (<IN>)
}
close(IN);
die "Could not find node \"$tnode\"" if ($in == 1);
exit 0;
......@@ -126,12 +126,19 @@ AC_DEFUN(MYSQL_CHECK_ZLIB_WITH_COMPRESS, [
save_LIBS="$LIBS"
LIBS="-l$1 $LIBS"
AC_CACHE_CHECK([if libz with compress], mysql_cv_compress,
[AC_TRY_LINK([#include <zlib.h>
[AC_TRY_RUN([#include <zlib.h>
#ifdef __cplusplus
extern "C"
#endif
],
[ return compress(0, (unsigned long*) 0, "", 0);
int main(int argv, char **argc)
{
return 0;
}
int link_test()
{
return compress(0, (unsigned long*) 0, "", 0);
}
], mysql_cv_compress=yes, mysql_cv_compress=no)])
if test "$mysql_cv_compress" = "yes"
then
......@@ -706,7 +713,7 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [
/usr/include/ssl /opt/ssl/include /opt/openssl/include \
/usr/local/ssl/include /usr/local/include ; do
if test -f $d/openssl/ssl.h ; then
OPENSSL_INCLUDE=$d
OPENSSL_INCLUDE=-I$d
fi
done
......@@ -717,6 +724,15 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [
fi
done
# On RedHat 9 we need kerberos to compile openssl
for d in /usr/kerberos/include
do
if test -f $d/krb5.h ; then
OPENSSL_INCLUDE="$OPENSSL_INCLUDE -I$d"
fi
done
if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then
echo "Could not find an installation of OpenSSL"
if test -n "$OPENSSL_LIB" ; then
......@@ -749,9 +765,9 @@ AC_MSG_CHECKING(for OpenSSL)
openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto"
# Don't set openssl_includes to /usr/include as this gives us a lot of
# compiler warnings when using gcc 3.x
if test "$OPENSSL_INCLUDE" != "/usr/include"
if test "$OPENSSL_INCLUDE" != "-I/usr/include"
then
openssl_includes="-I$OPENSSL_INCLUDE"
openssl_includes="$OPENSSL_INCLUDE"
fi
AC_DEFINE(HAVE_OPENSSL)
......
......@@ -71,7 +71,7 @@ char *get_tty_password(char *opt_message)
char *pos=to,*end=to+sizeof(to)-1;
int i=0;
DBUG_ENTER("get_tty_password");
fprintf(stderr,opt_message ? opt_message : "Enter password: ");
_cputs(opt_message ? opt_message : "Enter password: ");
for (;;)
{
char tmp;
......
......@@ -111,7 +111,7 @@ static void usage(void)
{
print_version();
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
printf("Print a description for a system error code or a error code from\na MyISAM/ISAM/BDB table handler.\n");
printf("Print a description for a system error code or an error code from\na MyISAM/ISAM/BDB table handler.\n");
printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n");
printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname);
my_print_help(my_long_options);
......
......@@ -175,7 +175,11 @@ os_file_create(
file is created (if exists, error), OS_FILE_OVERWRITE
if a new file is created or an old overwritten */
ulint purpose,/* in: OS_FILE_AIO, if asynchronous, non-buffered i/o
is desired, OS_FILE_NORMAL, if any normal file */
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_.. and srv_..
variables whether we really use async i/o or
unbuffered i/o: look in the function source code for
the exact rules */
ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success);/* out: TRUE if succeed, FALSE if error */
/***************************************************************************
......
......@@ -168,6 +168,7 @@ what these mean */
#define SRV_UNIX_O_DSYNC 2
#define SRV_UNIX_LITTLESYNC 3
#define SRV_UNIX_NOSYNC 4
#define SRV_UNIX_O_DIRECT 5
/* Alternatives for file i/o in Windows */
#define SRV_WIN_IO_NORMAL 1
......
......@@ -211,9 +211,9 @@ os_file_get_last_error(void)
if (err != ERROR_DISK_FULL && err != ERROR_FILE_EXISTS) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Operating system error number %li in a file operation.\n"
" InnoDB: Operating system error number %lu in a file operation.\n"
"InnoDB: See http://www.innodb.com/ibman.html for installation help.\n",
(long) err);
err);
if (err == ERROR_PATH_NOT_FOUND) {
fprintf(stderr,
......@@ -255,9 +255,9 @@ os_file_get_last_error(void)
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Operating system error number %li in a file operation.\n"
" InnoDB: Operating system error number %lu in a file operation.\n"
"InnoDB: See http://www.innodb.com/ibman.html for installation help.\n",
(long) err);
err);
if (err == ENOENT) {
fprintf(stderr,
......@@ -351,7 +351,8 @@ os_file_handle_error(
fprintf(stderr, "InnoDB: File name %s\n", name);
}
fprintf(stderr, "InnoDB: System call %s.\n", operation);
fprintf(stderr, "InnoDB: File operation call: '%s'.\n",
operation);
fprintf(stderr, "InnoDB: Cannot continue operation.\n");
fflush(stderr);
......@@ -599,7 +600,11 @@ os_file_create(
file is created (if exists, error), OS_FILE_OVERWRITE
if a new is created or an old overwritten */
ulint purpose,/* in: OS_FILE_AIO, if asynchronous, non-buffered i/o
is desired, OS_FILE_NORMAL, if any normal file */
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_.. and srv_..
variables whether we really use async i/o or
unbuffered i/o: look in the function source code for
the exact rules */
ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success)/* out: TRUE if succeed, FALSE if error */
{
......@@ -624,8 +629,8 @@ os_file_create(
}
if (purpose == OS_FILE_AIO) {
/* use asynchronous (overlapped) io and no buffering
of writes in the OS */
/* If specified, use asynchronous (overlapped) io and no
buffering of writes in the OS */
attributes = 0;
#ifdef WIN_ASYNC_IO
if (os_aio_use_native_aio) {
......@@ -633,17 +638,13 @@ os_file_create(
}
#endif
#ifdef UNIV_NON_BUFFERED_IO
if (type == OS_LOG_FILE) {
if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) {
/* Do not use unbuffered i/o to log files because
to allow group commit to work when MySQL binlogging
is used we must separate log file write and log
file flush to disk. */
} else {
if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes
| FILE_FLAG_NO_BUFFERING;
}
value 2 denotes that we do not flush the log at every
commit, but only once per second */
} else if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes | FILE_FLAG_NO_BUFFERING;
}
#endif
} else if (purpose == OS_FILE_NORMAL) {
......@@ -653,12 +654,9 @@ os_file_create(
/* Do not use unbuffered i/o to log files because
value 2 denotes that we do not flush the log at every
commit, but only once per second */
} else {
if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes
| FILE_FLAG_NO_BUFFERING;
}
} else if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes | FILE_FLAG_NO_BUFFERING;
}
#endif
} else {
......@@ -700,29 +698,69 @@ os_file_create(
os_file_t file;
int create_flag;
ibool retry;
const char* mode_str = NULL;
const char* type_str = NULL;
const char* purpose_str = NULL;
try_again:
ut_a(name);
if (create_mode == OS_FILE_OPEN) {
mode_str = "OPEN";
create_flag = O_RDWR;
} else if (create_mode == OS_FILE_CREATE) {
mode_str = "CREATE";
create_flag = O_RDWR | O_CREAT | O_EXCL;
} else if (create_mode == OS_FILE_OVERWRITE) {
mode_str = "OVERWRITE";
create_flag = O_RDWR | O_CREAT | O_TRUNC;
} else {
create_flag = 0;
ut_error;
}
UT_NOT_USED(purpose);
if (type == OS_LOG_FILE) {
type_str = "LOG";
} else if (type == OS_DATA_FILE) {
type_str = "DATA";
} else {
ut_a(0);
}
if (purpose == OS_FILE_AIO) {
purpose_str = "AIO";
} else if (purpose == OS_FILE_NORMAL) {
purpose_str = "NORMAL";
} else {
ut_a(0);
}
/* printf("Opening file %s, mode %s, type %s, purpose %s\n",
name, mode_str, type_str, purpose_str); */
#ifdef O_SYNC
if ((!srv_use_doublewrite_buf || type != OS_DATA_FILE)
/* We let O_SYNC only affect log files; note that we map O_DSYNC to
O_SYNC because the datasync options seemed to corrupt files in 2001
in both Linux and Solaris */
if (type == OS_LOG_FILE
&& srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) {
/* printf("Using O_SYNC for file %s\n", name); */
create_flag = create_flag | O_SYNC;
}
#endif
#ifdef O_DIRECT
/* We let O_DIRECT only affect data files */
if (type != OS_LOG_FILE
&& srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
/* printf("Using O_DIRECT for file %s\n", name); */
create_flag = create_flag | O_DIRECT;
}
#endif
if (create_mode == OS_FILE_CREATE) {
file = open(name, create_flag, os_innodb_umask);
......@@ -1319,6 +1357,7 @@ os_file_write(
DWORD high;
ulint i;
ulint n_retries = 0;
ulint err;
ut_a((offset & 0xFFFFFFFF) == offset);
......@@ -1386,18 +1425,27 @@ os_file_write(
if (!os_has_said_disk_full) {
err = (ulint)GetLastError();
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: Write to file %s failed at offset %lu %lu.\n"
"InnoDB: %lu bytes should have been written, only %lu were written.\n"
"InnoDB: Operating system error number %lu.\n"
"InnoDB: Look from section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: what the error number means.\n"
"InnoDB: Check that your OS and file system support files of this size.\n"
"InnoDB: Check also that the disk is not full or a disk quota exceeded.\n",
name, offset_high, offset, n, (ulint)len,
(ulint)GetLastError());
err);
if (strerror((int)err) != NULL) {
fprintf(stderr,
"InnoDB: Error number %lu means '%s'.\n", err, strerror((int)err));
}
fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: about operating system error numbers.\n");
os_has_said_disk_full = TRUE;
}
......@@ -1421,12 +1469,19 @@ os_file_write(
" InnoDB: Error: Write to file %s failed at offset %lu %lu.\n"
"InnoDB: %lu bytes should have been written, only %ld were written.\n"
"InnoDB: Operating system error number %lu.\n"
"InnoDB: Look from section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: what the error number means or use the perror program of MySQL.\n"
"InnoDB: Check that your OS and file system support files of this size.\n"
"InnoDB: Check also that the disk is not full or a disk quota exceeded.\n",
name, offset_high, offset, n, (long int)ret,
(ulint)errno);
if (strerror(errno) != NULL) {
fprintf(stderr,
"InnoDB: Error number %lu means '%s'.\n", (ulint)errno, strerror(errno));
}
fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: about operating system error numbers.\n");
os_has_said_disk_full = TRUE;
}
......
......@@ -1739,7 +1739,7 @@ srv_conc_enter_innodb(
trx_t* trx) /* in: transaction object associated with the
thread */
{
ibool has_slept = FALSE;
ibool has_slept = FALSE;
srv_conc_slot_t* slot;
ulint i;
char err_buf[1000];
......@@ -1758,9 +1758,9 @@ srv_conc_enter_innodb(
return;
}
retry:
os_fast_mutex_lock(&srv_conc_mutex);
os_fast_mutex_lock(&srv_conc_mutex);
retry:
if (trx->declared_to_be_inside_innodb) {
ut_print_timestamp(stderr);
......@@ -1769,6 +1769,9 @@ srv_conc_enter_innodb(
fprintf(stderr,
" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
"InnoDB: it already is declared.\n%s\n", err_buf);
os_fast_mutex_unlock(&srv_conc_mutex);
return;
}
if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
......@@ -1782,21 +1785,27 @@ srv_conc_enter_innodb(
return;
}
/* If the transaction is not holding resources, let it sleep
for 100 milliseconds, and try again then */
/* If the transaction is not holding resources, let it sleep for 50
milliseconds, and try again then */
if (!has_slept && !trx->has_search_latch
&& NULL == UT_LIST_GET_FIRST(trx->trx_locks)) {
has_slept = TRUE; /* We let is sleep only once to avoid
starvation */
has_slept = TRUE; /* We let is sleep only once to avoid
starvation */
os_fast_mutex_unlock(&srv_conc_mutex);
srv_conc_n_waiting_threads++;
os_thread_sleep(100000);
os_fast_mutex_unlock(&srv_conc_mutex);
os_thread_sleep(50000);
os_fast_mutex_lock(&srv_conc_mutex);
srv_conc_n_waiting_threads--;
goto retry;
}
}
/* Too many threads inside: put the current thread to a queue */
......@@ -2110,7 +2119,8 @@ srv_suspend_mysql_thread(
os_event_t event;
double wait_time;
trx_t* trx;
ibool had_dict_lock = FALSE;
ibool had_dict_lock = FALSE;
ibool was_declared_inside_innodb = FALSE;
ut_ad(!mutex_own(&kernel_mutex));
......@@ -2158,11 +2168,16 @@ srv_suspend_mysql_thread(
mutex_exit(&kernel_mutex);
/* We must declare this OS thread to exit InnoDB, since a possible
other thread holding a lock which this thread waits for must be
allowed to enter, sooner or later */
if (trx->declared_to_be_inside_innodb) {
was_declared_inside_innodb = TRUE;
srv_conc_force_exit_innodb(thr_get_trx(thr));
/* We must declare this OS thread to exit InnoDB, since a
possible other thread holding a lock which this thread waits
for must be allowed to enter, sooner or later */
srv_conc_force_exit_innodb(trx);
}
/* Release possible foreign key check latch */
if (trx->dict_operation_lock_mode == RW_S_LATCH) {
......@@ -2183,9 +2198,12 @@ srv_suspend_mysql_thread(
row_mysql_freeze_data_dictionary(trx);
}
/* Return back inside InnoDB */
if (was_declared_inside_innodb) {
/* Return back inside InnoDB */
srv_conc_force_enter_innodb(thr_get_trx(thr));
srv_conc_force_enter_innodb(trx);
}
mutex_enter(&kernel_mutex);
......
......@@ -1055,6 +1055,10 @@ innobase_start_or_create_for_mysql(void)
(char*)"O_DSYNC")) {
srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str,
(char*)"O_DIRECT")) {
srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
} else if (0 == ut_strcmp(srv_file_flush_method_str,
(char*)"littlesync")) {
srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
......
......@@ -896,7 +896,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
if (_mi_rec_unpack(info,record,info->rec_buff,block_info.rec_len) ==
MY_FILE_ERROR)
{
mi_check_print_error(param,"Found wrong record at %s", llstr(start_recpos,llbuff));
mi_check_print_error(param,"Found wrong record at %s",
llstr(start_recpos,llbuff));
got_error=1;
}
else
......@@ -3611,6 +3612,7 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update)
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
my_bool repair_only)
{
byte *record;
if (!info->s->base.auto_key ||
!(((ulonglong) 1 << (info->s->base.auto_key-1)
& info->s->state.key_map)))
......@@ -3624,13 +3626,24 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
if (!(param->testflag & T_SILENT) &&
!(param->testflag & T_REP))
printf("Updating MyISAM file: %s\n", param->isam_file_name);
/* We have to use keyread here as a normal read uses info->rec_buff */
/*
We have to use an allocated buffer instead of info->rec_buff as
_mi_put_key_in_record() may use info->rec_buff
*/
if (!(record= (byte*) my_malloc((uint) info->s->base.pack_reclength,
MYF(0))))
{
mi_check_print_error(param,"Not enough memory for extra record");
return;
}
mi_extra(info,HA_EXTRA_KEYREAD,0);
if (mi_rlast(info,info->rec_buff, info->s->base.auto_key-1))
if (mi_rlast(info, record, info->s->base.auto_key-1))
{
if (my_errno != HA_ERR_END_OF_FILE)
{
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
my_free((char*) record, MYF(0));
mi_check_print_error(param,"%d when reading last record",my_errno);
return;
}
......@@ -3642,10 +3655,11 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
ulonglong auto_increment= (repair_only ? info->s->state.auto_increment :
param->auto_increment_value);
info->s->state.auto_increment=0;
update_auto_increment(info,info->rec_buff);
update_auto_increment(info, record);
set_if_bigger(info->s->state.auto_increment,auto_increment);
}
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
my_free((char*) record, MYF(0));
update_state_info(param, info, UPDATE_AUTO_INC);
return;
}
......
......@@ -264,7 +264,7 @@ 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->blobs && info->s->keyinfo[keynr].flag & HA_VAR_LENGTH_KEY)
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,
......
......@@ -33,7 +33,7 @@
MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
{
int save_errno,i,errpos;
uint files,dir_length,length,options, key_parts;
uint files,dir_length,length,key_parts;
ulonglong file_offset;
char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end;
MYRG_INFO info,*m_info;
......@@ -110,13 +110,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
}
errpos=2;
options= (uint) ~0;
for (i=files ; i-- > 0 ; )
{
uint j;
m_info->open_tables[i].table=isam;
m_info->options|=isam->s->options;
options&=isam->s->options;
m_info->records+=isam->state->records;
m_info->del+=isam->state->del;
m_info->data_file_length+=isam->state->data_file_length;
......@@ -125,9 +123,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
if (i)
isam=(MI_INFO*) (isam->open_list.next->data);
}
/* Don't force readonly if not all tables are readonly */
if (! (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA)))
m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA);
/* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */
m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA);
/* Fix fileinfo for easyer debugging (actually set by rrnd) */
file_offset=0;
......
......@@ -176,3 +176,5 @@ Column 'k1' cannot be null
insert into t1 values (NULL, NULL);
Column 'k1' cannot be null
drop table t1;
create table t1 select x'4132';
drop table t1;
......@@ -196,6 +196,9 @@ strcmp('
select strcmp('u','a'),strcmp('u','');
strcmp('u','a') strcmp('u','')
1 1
select strcmp('s', 'a'), strcmp('a', 'x');
strcmp('s', 'a') strcmp('a', 'x')
-1 -1
create table t1 (a varchar(10), key(a), fulltext (a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
select * from t1 where a like "abc%";
......
......@@ -25,3 +25,6 @@ find_in_set("","a,b,c") find_in_set("","a,b,c,") find_in_set("",",a,b,c")
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
find_in_set("abc","abc") find_in_set("ab","abc") find_in_set("abcd","abc")
1 0 0
select interval(null, 1, 10, 100);
interval(null, 1, 10, 100)
-1
......@@ -587,3 +587,8 @@ a b
3 t2:3
2 t2:2
drop table t1,t2;
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2;
......@@ -9,7 +9,7 @@ insert into t1 values (1),(1);
Duplicate entry '1' for key 1
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254
127.0.0.1 root MASTER_PORT 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254
show tables like 't1';
Tables_in_test (t1)
drop table t1;
......@@ -14,4 +14,4 @@ slave start;
flush logs;
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root SLAVE_PORT 60 slave-bin.001 79 relay-log.002 119 slave-bin.001 Yes Yes 0 0 79 119
127.0.0.1 root SLAVE_PORT 60 slave-bin.001 79 relay-log.002 4 slave-bin.001 Yes Yes 0 0 79 4
......@@ -16,7 +16,7 @@ select @@global.max_relay_log_size;
start slave;
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 50477 slave-relay-bin.014 1221 master-bin.001 Yes Yes 0 0 50477 1221
127.0.0.1 root MASTER_PORT 1 master-bin.001 50477 slave-relay-bin.014 1221 master-bin.001 Yes Yes 0 0 50477 1221
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;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 50477 slave-relay-bin.004 9457 master-bin.001 Yes Yes 0 0 50477 9457
127.0.0.1 root MASTER_PORT 1 master-bin.001 50477 slave-relay-bin.004 9457 master-bin.001 Yes Yes 0 0 50477 9457
stop slave;
reset slave;
set global max_relay_log_size=0;
......@@ -36,25 +36,25 @@ select @@global.max_relay_log_size;
start slave;
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 50477 slave-relay-bin.008 1283 master-bin.001 Yes Yes 0 0 50477 1283
127.0.0.1 root MASTER_PORT 1 master-bin.001 50477 slave-relay-bin.008 1283 master-bin.001 Yes Yes 0 0 50477 1283
stop slave;
reset slave;
flush logs;
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 4 slave-relay-bin.001 4 No No 0 0 0 4
127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.001 4 No No 0 0 0 4
reset slave;
start slave;
flush logs;
create table t1 (a int);
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 50535 slave-relay-bin.009 62 master-bin.001 Yes Yes 0 0 50535 62
127.0.0.1 root MASTER_PORT 1 master-bin.001 50535 slave-relay-bin.009 62 master-bin.001 Yes Yes 0 0 50535 62
flush logs;
drop table t1;
show slave status;
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 Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root 9306 1 master-bin.001 50583 slave-relay-bin.010 52 master-bin.001 Yes Yes 0 0 50583 52
127.0.0.1 root MASTER_PORT 1 master-bin.001 50583 slave-relay-bin.010 52 master-bin.001 Yes Yes 0 0 50583 52
flush logs;
show master status;
File Position Binlog_do_db Binlog_ignore_db
......
......@@ -127,3 +127,10 @@ insert into t1 values ("a", 1), ("b", 2);
!$1048 insert into t1 values (NULL, 3);
!$1048 insert into t1 values (NULL, NULL);
drop table t1;
#
# Bug # 801
#
create table t1 select x'4132';
drop table t1;
......@@ -34,6 +34,10 @@ select strcmp('af','
select strcmp('a','ss'),strcmp('ssa',''),strcmp('sssb','sa'),strcmp('','s');
select strcmp('u','a'),strcmp('u','');
#
# overlapping combo's
#
select strcmp('s', 'a'), strcmp('a', 'x');
#
# Some other simple tests with the current character set
#
......
......@@ -15,3 +15,4 @@ select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N",""
select elt(2,1),field(NULL,"a","b","c");
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
select interval(null, 1, 10, 100);
......@@ -122,3 +122,13 @@ select * from t1;
replace into t1 select * from t2;
select * from t1;
drop table t1,t2;
#
# Test that caused uninitialized memory access in auto_increment_key update
#
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2;
--replicate-ignore-table=test.t1
\ No newline at end of file
--replicate-ignore-table=test.t1
......@@ -12,6 +12,9 @@ save_master_pos;
connection slave;
# as the t1 table is ignored on the slave, the slave should be able to sync
sync_with_master;
# The port number is different when doing the release build with
# Do-compile, hence we have to replace the port number here accordingly
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
# check that the table has been ignored, because otherwise the test is nonsense
show tables like 't1';
......
......@@ -14,6 +14,7 @@ slave stop;
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$SLAVE_MYPORT;
slave start;
sleep 5;
flush logs;
sleep 5;
--replace_result $SLAVE_MYPORT SLAVE_PORT
......
......@@ -28,6 +28,7 @@ set global max_relay_log_size=8192-1; # mapped to 4096
select @@global.max_relay_log_size;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
show slave status;
stop slave;
reset slave;
......@@ -35,6 +36,7 @@ set global max_relay_log_size=(5*4096);
select @@global.max_relay_log_size;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
show slave status;
stop slave;
reset slave;
......@@ -42,6 +44,7 @@ set global max_relay_log_size=0;
select @@global.max_relay_log_size;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
show slave status;
# Tests below are mainly to ensure that we have not coded with wrong assumptions
......@@ -51,6 +54,7 @@ reset slave;
# test of relay log rotation when the slave is stopped
# (to make sure it does not crash).
flush logs;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
show slave status;
reset slave;
......@@ -65,6 +69,7 @@ create table t1 (a int);
save_master_pos;
connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
show slave status;
# one more rotation, to be sure Relay_log_space is correctly updated
flush logs;
......@@ -73,6 +78,7 @@ drop table t1;
save_master_pos;
connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
show slave status;
connection master;
......
......@@ -374,11 +374,11 @@ void TERMINATE(FILE *file)
{
if (file)
{
fprintf(file, "Warning: Not freed memory segments: %d\n",
fprintf(file, "Warning: Not freed memory segments: %u\n",
sf_malloc_count);
(void) fflush(file);
}
DBUG_PRINT("safe",("sf_malloc_count: %d", sf_malloc_count));
DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count));
}
/*
......@@ -482,7 +482,7 @@ int _sanity(const char *filename, uint lineno)
pthread_mutex_lock(&THR_LOCK_malloc);
#ifndef PEDANTIC_SAFEMALLOC
if (sf_malloc_tampered && sf_malloc_count < 0)
if (sf_malloc_tampered && (int) sf_malloc_count < 0)
sf_malloc_count=0;
#endif
count=sf_malloc_count;
......
......@@ -172,10 +172,13 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
return 0;
}
static void check_locks(THR_LOCK *lock, const char *where,
my_bool allow_no_locks)
{
uint old_found_errors=found_errors;
DBUG_ENTER("check_locks");
if (found_errors < MAX_FOUND_ERRORS)
{
if (check_lock(&lock->write,"write",where,1,1) |
......@@ -252,18 +255,21 @@ static void check_locks(THR_LOCK *lock, const char *where,
}
if (lock->read.data)
{
if ((!pthread_equal(lock->write.data->thread,
lock->read.data->thread) &&
lock->write.data->type > TL_WRITE_DELAYED &&
lock->write.data->type != TL_WRITE_ONLY) ||
((lock->write.data->type == TL_WRITE_CONCURRENT_INSERT ||
lock->write.data->type == TL_WRITE_ALLOW_WRITE) &&
lock->read_no_write_count))
if (!pthread_equal(lock->write.data->thread,
lock->read.data->thread) &&
((lock->write.data->type > TL_WRITE_DELAYED &&
lock->write.data->type != TL_WRITE_ONLY) ||
((lock->write.data->type == TL_WRITE_CONCURRENT_INSERT ||
lock->write.data->type == TL_WRITE_ALLOW_WRITE) &&
lock->read_no_write_count)))
{
found_errors++;
fprintf(stderr,
"Warning at '%s': Found lock of type %d that is write and read locked\n",
where, lock->write.data->type);
DBUG_PRINT("warning",("At '%s': Found lock of type %d that is write and read locked\n",
where, lock->write.data->type));
}
}
if (lock->read_wait.data)
......@@ -286,6 +292,7 @@ static void check_locks(THR_LOCK *lock, const char *where,
DBUG_PRINT("error",("Found wrong lock"));
}
}
DBUG_VOID_RETURN;
}
#else /* EXTRA_DEBUG */
......
......@@ -274,12 +274,16 @@ then
fi
#
# Uncomment the following lines if you want all tables to be automaticly
# checked and repaired at start
# Uncomment the following lines if you want all tables to be automatically
# checked and repaired during startup. You should add sensible key_buffer
# and sort_buffer values to my.cnf to improve check performance or require
# less disk space.
# Alternatively, you can start mysqld with the "myisam-recover" option. See
# the manual for details.
#
# echo "Checking tables in $DATADIR"
# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check -O key_buffer=64M -O sort_buffer=64M $DATADIR/*/*.MYI
# $MY_BASEDIR_VERSION/bin/isamchk --silent --force -O sort_buffer=64M $DATADIR/*/*.ISM
# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
echo "Starting $MYSQLD daemon with databases from $DATADIR"
......
......@@ -569,22 +569,22 @@ sub copy_files {
print "Copying ".@$files." files...\n" unless $opt{quiet};
if ($method =~ /^s?cp\b/) { # cp or scp with optional flags
my @cp = ($method);
my $cp = $method;
# add option to preserve mod time etc of copied files
# not critical, but nice to have
push @cp, "-p" if $^O =~ m/^(solaris|linux|freebsd|darwin)$/;
$cp.= " -p" if $^O =~ m/^(solaris|linux|freebsd|darwin)$/;
# add recursive option for scp
push @cp, "-r" if $^O =~ /m^(solaris|linux|freebsd|darwin)$/ && $method =~ /^scp\b/;
$cp.= " -r" if $^O =~ /m^(solaris|linux|freebsd|darwin)$/ && $method =~ /^scp\b/;
my @non_raid = map { "'$_'" } grep { ! m:/\d{2}/[^/]+$: } @$files;
# add files to copy and the destination directory
safe_system( @cp, @non_raid, "'$target'" ) if (@non_raid);
safe_system( $cp, @non_raid, "'$target'" ) if (@non_raid);
foreach my $rd ( @$raid_dirs ) {
my @raid = map { "'$_'" } grep { m:$rd/: } @$files;
safe_system( @cp, @raid, "'$target'/$rd" ) if ( @raid );
safe_system( $cp, @raid, "'$target'/$rd" ) if ( @raid );
}
}
else
......@@ -646,26 +646,54 @@ sub copy_index
}
sub safe_system
{
my @cmd= @_;
if ( $opt{dryrun} )
{
print "@cmd\n";
return;
sub safe_system {
my @sources= @_;
my $method= shift @sources;
my $target= pop @sources;
## @sources = list of source file names
## We have to deal with very long command lines, otherwise they may generate
## "Argument list too long".
## With 10000 tables the command line can be around 1MB, much more than 128kB
## which is the common limit on Linux (can be read from
## /usr/src/linux/include/linux/binfmts.h
## see http://www.linuxjournal.com/article.php?sid=6060).
my $chunk_limit= 100 * 1024; # 100 kB
my @chunk= ();
my $chunk_length= 0;
foreach (@sources) {
push @chunk, $_;
$chunk_length+= length($_);
if ($chunk_length > $chunk_limit) {
safe_simple_system($method, @chunk, $target);
@chunk=();
$chunk_length= 0;
}
}
## for some reason system fails but backticks works ok for scp...
print "Executing '@cmd'\n" if $opt{debug};
my $cp_status = system "@cmd > /dev/null";
if ($cp_status != 0) {
warn "Executing command failed ($cp_status). Trying backtick execution...\n";
## try something else
`@cmd` || die "Error: @cmd failed ($?) while copying files.\n";
if ($chunk_length > 0) { # do not forget last small chunk
safe_simple_system($method, @chunk, $target);
}
}
sub safe_simple_system {
my @cmd= @_;
if ( $opt{dryrun} ) {
print "@cmd\n";
}
else {
## for some reason system fails but backticks works ok for scp...
print "Executing '@cmd'\n" if $opt{debug};
my $cp_status = system "@cmd > /dev/null";
if ($cp_status != 0) {
warn "Executing command failed ($cp_status). Trying backtick execution...\n";
## try something else
`@cmd` || die "Error: @cmd failed ($?) while copying files.\n";
}
}
}
sub retire_directory {
my ( @dir ) = @_;
......
......@@ -32,7 +32,6 @@ typedef struct st_innobase_share {
uint table_name_length,use_count;
} INNOBASE_SHARE;
/* The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
......
......@@ -801,6 +801,9 @@ void handler::print_error(int error, myf errflag)
int textno=ER_GET_ERRNO;
switch (error) {
case EACCES:
textno=ER_OPEN_AS_READONLY;
break;
case EAGAIN:
textno=ER_FILE_USED;
break;
......
......@@ -320,26 +320,25 @@ void Item_func_interval::split_sum_func(List<Item> &fields)
longlong Item_func_interval::val_int()
{
double value=item->val();
double value= item->val();
if (item->null_value)
return -1; // -1 if null /* purecov: inspected */
return -1; // -1 if NULL
if (intervals)
{ // Use binary search to find interval
uint start,end;
start=0; end=arg_count-1;
uint start= 0, end= arg_count - 1;
while (start != end)
{
uint mid=(start+end+1)/2;
uint mid= (start + end + 1) / 2;
if (intervals[mid] <= value)
start=mid;
start= mid;
else
end=mid-1;
end= mid - 1;
}
return (value < intervals[start]) ? 0 : start+1;
return (value < intervals[start]) ? 0 : start + 1;
}
if (args[0]->val() > value)
return 0;
for (uint i=1 ; i < arg_count ; i++)
for (uint i= 1; i < arg_count; i++)
{
if (args[i]->val() > value)
return i;
......
......@@ -1471,6 +1471,10 @@ String *Item_func_format::val_str(String *str)
return 0; /* purecov: inspected */
dec= decimals ? decimals+1 : 0;
str->set(nr,decimals);
#ifdef HAVE_ISNAN
if (isnan(nr))
return str;
#endif
str_length=str->length();
if (nr < 0)
str_length--; // Don't count sign
......
This diff is collapsed.
......@@ -1966,12 +1966,9 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
if (type == LOG_BIN)
{
char *p = fn_ext(opt_name);
if (p)
{
uint length=(uint) (p-opt_name);
strmake(tmp,opt_name,min(length,FN_REFLEN));
opt_name=tmp;
}
uint length=(uint) (p-opt_name);
strmake(tmp,opt_name,min(length,FN_REFLEN));
opt_name=tmp;
}
return log->open(opt_name, type, 0, index_file_name,
(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
......@@ -2019,6 +2016,17 @@ int main(int argc, char **argv)
}
#endif
/*
Init mutexes for the global MYSQL_LOG objects.
As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of
global MYSQL_LOGs in their constructors, because then they would be inited
before MY_INIT(). So we do it here.
*/
mysql_log.init_pthread_objects();
mysql_update_log.init_pthread_objects();
mysql_slow_log.init_pthread_objects();
mysql_bin_log.init_pthread_objects();
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql");
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
......@@ -4202,8 +4210,8 @@ static void usage(void)
puts("\
Copyright (C) 2000 MySQL AB, by Monty and others\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n\
Starts the MySQL server\n");
and you are welcome to modify and redistribute it under the GPL license\n\n\
Starts the MySQL database server\n");
printf("Usage: %s [OPTIONS]\n", my_progname);
#ifdef __WIN__
......
......@@ -119,7 +119,7 @@
"Unknown character set: '%-.64s'",
"Too many tables. MySQL can only use %d tables in a join",
"Too many columns",
"Too big row size. The maximum row size, not counting BLOBs, is %d. You have to change some fields to BLOBs",
"Too big row size. The maximum row size, not counting BLOBs, is %d (can be lower for some table types). You have to change some fields to BLOBs",
"Thread stack overrun: Used: %ld of a %ld stack. Use 'mysqld -O thread_stack=#' to specify a bigger stack if needed",
"Cross dependency found in OUTER JOIN. Examine your ON conditions",
"Column '%-.64s' is used with UNIQUE or INDEX but is not defined as NOT NULL",
......
......@@ -1314,7 +1314,7 @@ file '%s')", fname);
if (info_fd >= 0)
my_close(info_fd, MYF(0));
rli->info_fd= -1;
rli->relay_log.close(1);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1);
}
......@@ -1374,7 +1374,7 @@ relay_log_pos=%s", rli->relay_log_name, llstr(rli->relay_log_pos, llbuf));
if (info_fd >= 0)
my_close(info_fd, MYF(0));
rli->info_fd= -1;
rli->relay_log.close(1);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1);
}
......@@ -1736,6 +1736,7 @@ st_relay_log_info::st_relay_log_info()
pthread_cond_init(&start_cond, NULL);
pthread_cond_init(&stop_cond, NULL);
pthread_cond_init(&log_space_cond, NULL);
relay_log.init_pthread_objects();
}
......@@ -2988,7 +2989,7 @@ void end_relay_log_info(RELAY_LOG_INFO* rli)
rli->cur_log_fd = -1;
}
rli->inited = 0;
rli->relay_log.close(1);
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
DBUG_VOID_RETURN;
}
......@@ -3443,14 +3444,18 @@ void rotate_relay_log(MASTER_INFO* mi)
{
DBUG_ENTER("rotate_relay_log");
RELAY_LOG_INFO* rli= &mi->rli;
/* If this server is not a slave (or RESET SLAVE has just been run) */
lock_slave_threads(mi);
pthread_mutex_lock(&rli->data_lock);
/*
We need to test inited because otherwise, new_file() will attempt to lock
LOCK_log, which may not be inited (if we're not a slave).
*/
if (!rli->inited)
{
DBUG_PRINT("info", ("rli->inited == 0"));
DBUG_VOID_RETURN;
goto end;
}
lock_slave_threads(mi);
pthread_mutex_lock(&rli->data_lock);
/* If the relay log is closed, new_file() will do nothing. */
rli->relay_log.new_file(1);
......@@ -3469,6 +3474,7 @@ void rotate_relay_log(MASTER_INFO* mi)
0 as they probably have been harvested.
*/
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
end:
pthread_mutex_unlock(&rli->data_lock);
unlock_slave_threads(mi);
DBUG_VOID_RETURN;
......
......@@ -1136,7 +1136,11 @@ find_acl_user(const char *host, const char *user)
{
ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
DBUG_PRINT("info",("strcmp('%s','%s'), compare_hostname('%s','%s'),",
user,acl_user->user,(host),(acl_user->host)));
user,
acl_user->user ? acl_user->user : "",
host,
acl_user->host.hostname ? acl_user->host.hostname :
""));
if (!acl_user->user && !user[0] ||
acl_user->user && !strcmp(user,acl_user->user))
{
......
......@@ -30,20 +30,24 @@ class Slave_log_event;
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY };
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_IGNORE };
enum enum_log_type { LOG_CLOSED, LOG_NORMAL, LOG_NEW, LOG_BIN };
enum enum_log_type { LOG_CLOSED, LOG_TO_BE_OPENED, LOG_NORMAL, LOG_NEW, LOG_BIN};
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
DELAY_KEY_WRITE_ALL };
// log info errors
/* log info errors */
#define LOG_INFO_EOF -1
#define LOG_INFO_IO -2
#define LOG_INFO_INVALID -3
#define LOG_INFO_SEEK -4
#define LOG_INFO_PURGE_NO_ROTATE -5
#define LOG_INFO_MEM -6
#define LOG_INFO_FATAL -7
#define LOG_INFO_IN_USE -8
/* bitmap to SQL_LOG::close() */
#define LOG_CLOSE_INDEX 1
#define LOG_CLOSE_TO_BE_OPENED 2
#define LOG_CLOSE_STOP_EVENT 4
struct st_relay_log_info;
typedef struct st_log_info
......@@ -59,8 +63,10 @@ typedef struct st_log_info
class Log_event;
class MYSQL_LOG {
class MYSQL_LOG
{
private:
/* LOCK_log and LOCK_index are inited by init_pthread_objects() */
pthread_mutex_t LOCK_log, LOCK_index;
pthread_cond_t update_cond;
ulonglong bytes_written;
......@@ -80,8 +86,7 @@ class MYSQL_LOG {
*/
volatile enum_log_type log_type;
enum cache_type io_cache_type;
bool write_error,inited;
bool no_rotate;
bool write_error, inited;
bool need_start_event;
bool no_auto_events; // for relay binlog
/*
......@@ -123,6 +128,7 @@ class MYSQL_LOG {
void init(enum_log_type log_type_arg,
enum cache_type io_cache_type_arg,
bool no_auto_events_arg, ulong max_size);
void init_pthread_objects();
void cleanup();
bool open(const char *log_name,enum_log_type log_type,
const char *new_name, const char *index_file_name_arg,
......@@ -149,8 +155,7 @@ class MYSQL_LOG {
int purge_logs(THD* thd, const char* to_log);
int purge_first_log(struct st_relay_log_info* rli);
bool reset_logs(THD* thd);
// if we are exiting, we also want to close the index file
void close(bool exiting = 0);
void close(uint exiting);
// iterating through the log index file
int find_log_pos(LOG_INFO* linfo, const char* log_name,
......@@ -158,7 +163,6 @@ class MYSQL_LOG {
int find_next_log(LOG_INFO* linfo, bool need_mutex);
int get_current_log(LOG_INFO* linfo);
uint next_file_id();
inline bool is_open() { return log_type != LOG_CLOSED; }
inline char* get_index_fname() { return index_file_name;}
inline char* get_log_fname() { return log_file_name; }
......
......@@ -282,8 +282,6 @@ int purge_master_logs(THD* thd, const char* to_log)
case LOG_INFO_INVALID: errmsg = "Server configuration does not permit \
binlog purge"; break;
case LOG_INFO_SEEK: errmsg = "Failed on fseek()"; break;
case LOG_INFO_PURGE_NO_ROTATE: errmsg = "Cannot purge unrotatable log";
break;
case LOG_INFO_MEM: errmsg = "Out of memory"; break;
case LOG_INFO_FATAL: errmsg = "Fatal error during purge"; break;
case LOG_INFO_IN_USE: errmsg = "A purgeable log is in use, will not purge";
......@@ -1128,7 +1126,7 @@ int show_binlog_info(THD* thd)
/*
Send a lost of all binary logs to client
Send a list of all binary logs to client
SYNOPSIS
show_binlogs()
......
......@@ -3664,6 +3664,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item::STRING_ITEM:
case Item::REF_ITEM:
case Item::NULL_ITEM:
case Item::VARBIN_ITEM:
{
bool maybe_null=item->maybe_null;
Field *new_field;
......
......@@ -102,6 +102,7 @@ uchar to_upper_latin1_de[] = {
* Ü, ü, Ö, ö, Ä, ä
*/
/* QQ: why it is necessary ? */
uchar sort_order_latin1_de[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
......@@ -121,6 +122,41 @@ uchar sort_order_latin1_de[] = {
68, 78, 79, 79, 79, 79,214,247,216, 85, 85, 85,220, 89,222, 89
};
/* same as sort_order_latin_de, but maps ALL accented chars to unacented ones */
uchar combo1map[]={
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
65, 65, 65, 65, 65, 65, 92, 67, 69, 69, 69, 69, 73, 73, 73, 73,
68, 78, 79, 79, 79, 79, 79,215,216, 85, 85, 85, 85, 89,222, 83,
65, 65, 65, 65, 65, 65, 92, 67, 69, 69, 69, 69, 73, 73, 73, 73,
68, 78, 79, 79, 79, 79, 79,247,216, 85, 85, 85, 85, 89,222, 89
};
uchar combo2map[]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,69, 0, 0, 0, 0, 0,69, 0, 0,83, 0, 0, 0, 0,69, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,69, 0, 0, 0, 0, 0,69, 0, 0, 0, 0
};
/* no longer needed
#define L1_AE 196
#define L1_ae 228
#define L1_OE 214
......@@ -128,7 +164,7 @@ uchar sort_order_latin1_de[] = {
#define L1_UE 220
#define L1_ue 252
#define L1_ss 223
*/
/*
Some notes about the following comparison rules:
......@@ -143,95 +179,23 @@ uchar sort_order_latin1_de[] = {
sort_order_latin_de[] at all
*/
#define CHECK_S1_COMBO(ch1, ch2, str1, str1_end, res_if_str1_smaller, str2, fst, snd, accent) \
/* Invariant: ch1 == fst == sort_order_latin1_de[accent] && ch1 != ch2 */ \
if (ch2 != accent) \
{ \
ch1= fst; \
goto normal; \
} \
if (str1 == str1_end) \
return res_if_str1_smaller; \
{ \
int diff = (int) sort_order_latin1_de[*str1] - snd; \
if (diff) \
return diff*(-(res_if_str1_smaller)); \
/* They are equal (e.g., "Ae" == 'ä') */ \
str1++; \
}
int my_strnncoll_latin1_de(const uchar * s1, int len1,
const uchar * s2, int len2)
{
const uchar *e1 = s1 + len1;
const uchar *e2 = s2 + len2;
uchar c1, c12=0, c2, c22=0;
while (s1 < e1 && s2 < e2)
while ((s1 < e1 || c12) && (s2 < e2 || c22))
{
/*
Because sort_order_latin1_de doesn't convert 'Ä', Ü or ß we
can use it here.
*/
uchar c1 = sort_order_latin1_de[*s1++];
uchar c2 = sort_order_latin1_de[*s2++];
if (c1 != c2)
{
switch (c1) {
case 'A':
CHECK_S1_COMBO(c1, c2, s1, e1, -1, s2, 'A', 'E', L1_AE);
break;
case 'O':
CHECK_S1_COMBO(c1, c2, s1, e1, -1, s2, 'O', 'E', L1_OE);
break;
case 'U':
CHECK_S1_COMBO(c1, c2, s1, e1, -1, s2, 'U', 'E', L1_UE);
break;
case 'S':
CHECK_S1_COMBO(c1, c2, s1, e1, -1, s2, 'S', 'S', L1_ss);
break;
case L1_AE:
CHECK_S1_COMBO(c1, c2, s2, e2, 1, s1, 'A', 'E', 'A');
break;
case L1_OE:
CHECK_S1_COMBO(c1, c2, s2, e2, 1, s1, 'O', 'E', 'O');
break;
case L1_UE:
CHECK_S1_COMBO(c1, c2, s2, e2, 1, s1, 'U', 'E', 'U');
break;
case L1_ss:
CHECK_S1_COMBO(c1, c2, s2, e2, 1, s1, 'S', 'S', 'S');
break;
default:
/*
Handle the case where 'c2' is a special character
If this is true, we know that c1 can't match this character.
*/
normal:
switch (c2) {
case L1_AE:
return (int) c1 - (int) 'A';
case L1_OE:
return (int) c1 - (int) 'O';
case L1_UE:
return (int) c1 - (int) 'U';
case L1_ss:
return (int) c1 - (int) 'S';
default:
{
int diff= (int) c1 - (int) c2;
if (diff)
return diff;
}
break;
}
}
}
if (c12) { c1=c12; c12=0; } else { c12=combo2map[*s1]; c1=combo1map[*s1++]; }
if (c22) { c2=c22; c22=0; } else { c22=combo2map[*s2]; c2=combo1map[*s2++]; }
if (c1 != c2) return (int)c1 - (int)c2;
}
/* A simple test of string lengths won't work -- we test to see
* which string ran out first */
return s1 < e1 ? 1 : s2 < e2 ? -1 : 0;
return (s1 < e1 || c12)? 1 : (s2 < e2 || c22)? -1 : 0;
}
......@@ -240,35 +204,12 @@ int my_strnxfrm_latin1_de(uchar * dest, const uchar * src, int len, int srclen)
const uchar *dest_orig = dest;
const uchar *de = dest + len;
const uchar *se = src + srclen;
while (src < se && dest < de)
for ( ; src < se && dest < de ; src++)
{
uchar chr=sort_order_latin1_de[*src];
switch (chr) {
case L1_AE:
*dest++ = 'A';
if (dest < de)
*dest++ = 'E';
break;
case L1_OE:
*dest++ = 'O';
if (dest < de)
*dest++ = 'E';
break;
case L1_UE:
*dest++ = 'U';
if (dest < de)
*dest++ = 'E';
break;
case L1_ss:
*dest++ = 'S';
if (dest < de)
*dest++ = 'S';
break;
default:
*dest++= chr;
break;
}
++src;
uchar chr=combo1map[*src];
*dest++=chr;
if ((chr=combo2map[*src]) && dest < de)
*dest++=chr;
}
return dest - dest_orig;
}
......
This diff is collapsed.
......@@ -26,8 +26,8 @@
#include <mysql_com.h>
#include <errno.h>
#include <violite.h>
#include <my_sys.h>
#include <violite.h>
#include <my_net.h>
#include <m_string.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment