Merge mysql.com:/home/psergey/mysql-5.0-latest-pull

into mysql.com:/dbdata/psergey/mysql-5.0-imerge-unique
This commit is contained in:
sergefp@mysql.com 2003-12-20 00:54:38 +03:00
commit 23b25675f2
222 changed files with 4543 additions and 1374 deletions

View file

@ -13,6 +13,7 @@ antony@ltantony.rdg.cyberkinetica.homeunix.net
arjen@co3064164-a.bitbike.com
arjen@fred.bitbike.com
arjen@george.bitbike.com
bar@bar.intranet.mysql.r18.ru
bar@bar.mysql.r18.ru
bar@bar.udmsearch.izhnet.ru
bar@gw.udmsearch.izhnet.ru

View file

@ -99,6 +99,8 @@ if (defined $opt_build_command)
print_help("") if ($opt_help);
defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used!");
$subject= "Bootstrap of $REPO failed" if $opt_mail;
&logger("Starting build");
&abort("The directory \"$REPO\" could not be found!") if (!-d $REPO);
&logger("Using $REPO as the BK parent repository");
@ -274,11 +276,13 @@ if (defined $opt_changelog)
#
unless ($opt_skip_manual)
{
$msg= "Adding manual.texi";
$msg= "Updating manual files";
&logger($msg);
$command= "install -m 644 $opt_docdir/Docs/{internals,manual,reservedwords}.texi";
$command.= " $target_dir/Docs/";
&run_command($command, "Could not update the manual in $target_dir/Docs/!");
foreach $file qw/internals manual reservedwords/
{
system ("bk cat $opt_docdir/Docs/$file.texi > $target_dir/Docs/$file.texi") == 0
or &abort("Could not update $file.texi in $target_dir/Docs/!");
}
}
#
@ -364,11 +368,13 @@ sub print_help
Usage: Bootstrap [options] <bk repository>
Checks out (exports) a clear-text version of the given local BitKeeper
Creates a MySQL source distribution to be used for the release builds.
It checks out (exports) a clear-text version of the given local BitKeeper
repository, creates and adds a Changelog file (if requested), adds the
latest manual.texi from the mysqldoc tree and builds a source distribution
(*.tar.gz) file. Optionally, the test suite can be run before the source
archive is being created.
latest manual files from the mysqldoc BK tree and builds a source
distribution (*.tar.gz) file. Optionally, the test suite and the
distribution check can be run before the source archive is being created.
Options:

View file

@ -1,6 +1,8 @@
#!/usr/bin/perl -w
use File::Basename;
use Getopt::Long;
use Sys::Hostname;
@config_options= ();
@make_options= ();
@ -76,7 +78,7 @@ if (@config_env > 0)
$opt_config_env= join(" ", @config_env);
}
chomp($host=`hostname`);
$host= hostname();
chomp($uname=`uname`);
$full_host_name=$host;
$connect_option= ($opt_tcpip ? "--host=$host" : "");
@ -84,7 +86,7 @@ $host =~ /^([^.-]*)/;
$host=$1 . $opt_suffix;
$email="$opt_user\@mysql.com";
chomp($pwd = `pwd`);
$VER= `basename $opt_distribution`; chop $VER;
$VER= basename($opt_distribution);
$VER=~ /mysql.*-([1-9]\.[0-9]{1,2}\.[0-9]{1,2}.*)\.tar*/; $version=$1;
($major, $minor, $release) = split(/\./,$version);
$log="$pwd/Logs/$host-$major.$minor$opt_version_suffix.log";
@ -111,7 +113,7 @@ if (defined($gcc_version) && ! $opt_config_env)
$new_opt_tmp=0;
if ($opt_tmp)
{
if (! -d $opt_tmp)
unless (-d $opt_tmp)
{
safe_system("mkdir $opt_tmp");
$new_opt_tmp=1;

View file

@ -3,14 +3,12 @@
# Do-rpm - compile RPM packages out of a source tarball and move the
# resulting RPM packages into the current directory.
#
# The script currently assumes the following environment (which should exist
# like that, if the Do-compile script was used to build the binary
# distribution)
# The script currently assumes the following environment:
#
# - there must be a source distribution (mysql-<version>.tar.gz)
# in the current directory
# - there must be a spec file (mysql-<version>.spec) in the directory
# $HOME/<hostname>/mysql-<version>/support-files/
# - You must provide the name of an RPM spec file (mysql-<version>.spec)
# as the argument
#
# Use the "--help" option for more info!
#
@ -35,7 +33,10 @@ $opt_log= undef;
$opt_mail= "";
$opt_verbose= undef;
# Set a dummy version until we know the correct one
$VERSION= "x.y.z";
$MAJOR= $MINOR= $RELEASE= 0;
$SUFFIX= "";
GetOptions(
"cc=s",
@ -50,7 +51,9 @@ GetOptions(
"verbose|v",
) || &print_help;
defined($VERSION=$ARGV[0]) || print_help("Please provide the MySQL version!");
&print_help("") if ($opt_help);
defined($SPECFILE=$ARGV[0]) || print_help("Please provide the spec file name!");
# Include helper functions
$PWD= cwd();
@ -64,6 +67,30 @@ else
die "ERROR: $LOGGER cannot be found!\n";
}
$subject= "RPM build for $SPECFILE failed" if $opt_mail;
# Open the spec file and extract the version number
open(SPEC, $SPECFILE) or &abort("Unable to open \"$ARGV[0]\": $!");
@spec= <SPEC>;
close SPEC;
foreach (@spec)
{
if (m/^%define\s*mysql_version\s*(.*)/)
{
$VERSION= $1;
($MAJOR, $MINOR, $RELEASE)= split(/\./,$VERSION);
($RELEASE, $SUFFIX)= split(/\-/,$RELEASE);
$SUFFIX= "-" . $SUFFIX if ($SUFFIX);
}
}
$HOST= hostname();
$HOST=~ /^([^.-]*)/;
$HOST= $1;
$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log";
&logger("Using spec file for version: $VERSION");
#
# Override predefined Log file name
#
@ -82,14 +109,6 @@ if (defined $opt_log)
}
}
($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION);
$HOST= hostname();
$HOST=~ /^([^.-]*)/;
$HOST= $1;
$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log";
&print_help("") if ($opt_help);
#
# Newer RPM versions ship with a separate tool "rpmbuild" to build RPMs
#
@ -120,8 +139,7 @@ chomp($SOURCEDIR= `$RPM --eval "%{_sourcedir}" 2> /dev/null`);
chomp($SPECDIR= `$RPM --eval "%{_specdir}" 2> /dev/null`);
chomp($SRCRPMDIR= `$RPM --eval "%{_srcrpmdir}" 2> /dev/null`);
$SOURCEFILE= "mysql-$VERSION.tar.gz";
$SPECFILE= "$PWD/$HOST/mysql-$VERSION/support-files/mysql-$VERSION.spec";
$SOURCEFILE= glob "mysql*-$VERSION.tar.gz";
&logger("Starting RPM build of MySQL-$VERSION on $HOST");
@ -134,10 +152,13 @@ foreach $file ($SOURCEFILE, $SPECFILE)
# Install source and spec file
#
&logger("Copying SOURCE and SPEC file to build directories.");
copy($SOURCEFILE, $SOURCEDIR)
or &abort("Unable to copy $SOURCEFILE to $SOURCEDIR!");
copy($SPECFILE, $SPECDIR)
or &abort("Unable to copy $SPECFILE to $SPECDIR!");
unless ($opt_dry_run)
{
copy($SOURCEFILE, $SOURCEDIR)
or &abort("Unable to copy $SOURCEFILE to $SOURCEDIR!");
copy($SPECFILE, $SPECDIR)
or &abort("Unable to copy $SPECFILE to $SPECDIR!");
}
#
# Set environment variables - these are being used in the
@ -168,11 +189,13 @@ $command.= basename($SPECFILE);
$command= "mv";
$command.= " -v " if ($opt_verbose);
$command.= "$SRCRPMDIR/MySQL*$VERSION*.src.rpm $PWD";
&logger("Moving source RPM to current dir.");
&run_command($command, "Error moving source RPM!");
$command= "mv";
$command.= " -v " if ($opt_verbose);
$command.= "$RPMDIR/$RPMARCH/MySQL*$VERSION*.$RPMARCH.rpm $PWD";
$command.= " $RPMDIR/$RPMARCH/MySQL*$VERSION*.$RPMARCH.rpm $PWD";
&logger("Moving binary RPMs to current dir.");
&run_command($command, "Error moving binary RPMs!");
#
@ -181,11 +204,14 @@ $command.= "$RPMDIR/$RPMARCH/MySQL*$VERSION*.$RPMARCH.rpm $PWD";
if ($opt_clean)
{
&logger("Removing spec file and source package");
unlink("$SPECDIR/" . basename($SPECFILE));
unlink("$SOURCEDIR/$SOURCEFILE");
unless ($opt_dry_run)
{
unlink("$SPECDIR/" . basename($SPECFILE));
unlink("$SOURCEDIR/$SOURCEFILE");
}
}
&logger("SUCCESS: RPM files successfully created.") if (!$opt_dry_run);
&logger("SUCCESS: RPM files successfully created.") unless ($opt_dry_run);
exit 0;
sub print_help
@ -198,11 +224,14 @@ sub print_help
}
print <<EOF;
Usage: Do-rpm <options> <version>
Usage: Do-rpm [options] <specfile>
Creates a binary RPM package out of a MySQL source distribution and moves the
resulting RPMs into the current directory. <version> is the MySQL version
number (e.g. 4.0.11-gamma)
Creates a binary RPM package out of a MySQL source distribution and moves
the resulting RPMs into the current directory. <specfile> is the MySQL RPM
spec file to use (e.g. mysql-4.0.17.spec).
This script expects to find the required MySQL source distribution
(mysql-<version>.tar.gz) in the current directory.
Options:
@ -222,6 +251,10 @@ Options:
Example: --mail=user\\\@domain.com
-v, --verbose Verbose execution
Example:
Do-rpm -cv mysql-4.0.17.spec
EOF
exit 1;
}

View file

@ -53,7 +53,6 @@ sub abort
if ($opt_mail && !$opt_dry_run)
{
$messagefile= "/tmp/message.$$";
$subject= "Bootstrap of $REPO failed";
open(TMP,">$messagefile");
print TMP "$message\n\n";
close TMP;

View file

@ -19,5 +19,5 @@ ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able t
[General]
Language=0009
Type=STRINGTABLESPECIFIC
Version=@VERSION@
Version=1.00.000

View file

@ -19,5 +19,5 @@ ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able t
[General]
Language=0009
Type=STRINGTABLESPECIFIC
Version=@VERSION@
Version=1.00.000

View file

@ -19,5 +19,5 @@ ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able t
[General]
Language=0009
Type=STRINGTABLESPECIFIC
Version=@VERSION@
Version=1.00.000

View file

@ -785,7 +785,7 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [
for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \
/usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib /usr/local/lib/ ; do
if test -f $d/libssl.a ; then
if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl.dylib ; then
OPENSSL_LIB=$d
fi
done
@ -797,7 +797,7 @@ AC_DEFUN(MYSQL_FIND_OPENSSL, [
if test -f $incs/openssl/ssl.h ; then
OPENSSL_INCLUDE=-I$incs
fi
if test -f $libs/libssl.a ; then
if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl.dylib ; then
OPENSSL_LIB=$libs
fi
;;

View file

@ -380,7 +380,7 @@ int main(int argc,char *argv[])
put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
INFO_INFO);
sprintf((char*) glob_buffer.ptr(),
"Your MySQL connection id is %ld to server version: %s\n",
"Your MySQL connection id is %lu to server version: %s\n",
mysql_thread_id(&mysql),mysql_get_server_info(&mysql));
put_info((char*) glob_buffer.ptr(),INFO_INFO);
@ -613,8 +613,8 @@ static struct my_option my_long_options[] =
0, 1},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, 16 *1024L*1024L, 4096, 512*1024L*1024L, MALLOC_OVERHEAD,
1024, 0},
REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,
MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0, GET_ULONG,
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
@ -2346,7 +2346,7 @@ com_connect(String *buffer, char *line)
if (connected)
{
sprintf(buff,"Connection id: %ld",mysql_thread_id(&mysql));
sprintf(buff,"Connection id: %lu",mysql_thread_id(&mysql));
put_info(buff,INFO_INFO);
sprintf(buff,"Current database: %s\n",
current_db ? current_db : "*** NONE ***");
@ -2545,8 +2545,11 @@ static int
sql_real_connect(char *host,char *database,char *user,char *password,
uint silent)
{
mysql_close(&mysql);
connected= 0;
if (connected)
{
connected= 0;
mysql_close(&mysql);
}
mysql_init(&mysql);
if (opt_connect_timeout)
{
@ -2652,7 +2655,7 @@ com_status(String *buffer __attribute__((unused)),
{
MYSQL_RES *result;
LINT_INIT(result);
tee_fprintf(stdout, "\nConnection id:\t\t%ld\n",mysql_thread_id(&mysql));
tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
if (!mysql_query(&mysql,"select DATABASE(),USER()") &&
(result=mysql_use_result(&mysql)))
{

View file

@ -37,7 +37,7 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/
#define DUMP_VERSION "10.3"
#define DUMP_VERSION "10.4"
#include <my_global.h>
#include <my_sys.h>
@ -81,7 +81,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick= 1, extended_insert= 1,
opt_alldbs=0,opt_create_db=0,opt_first_slave=0,opt_set_names=0,
opt_autocommit=0,opt_master_data,opt_disable_keys=1,opt_xml=0,
opt_delete_master_logs=0, tty_password=0,
opt_single_transaction=0;
opt_single_transaction=0, opt_comments= 0;
static MYSQL mysql_connection,*sock=0;
static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*current_host=0,*path=0,*fields_terminated=0,
@ -89,11 +89,7 @@ static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*where=0,
*opt_compatible_mode_str= 0,
*err_ptr= 0;
#ifdef HAVE_CHARSET_utf8
static char *default_charset= (char*) "utf8";
#else
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
#endif
static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET;
static ulong opt_compatible_mode= 0;
static uint opt_mysql_port= 0, err_len= 0;
static my_string opt_mysql_unix_port=0;
@ -280,12 +276,15 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0,
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, 1024*1024L*1024L,
MALLOC_OVERHEAD, 1024, 0},
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
(longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0,
GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L,
MALLOC_OVERHEAD-1024, 1024, 0},
{"comments", 'i', "Write additional information.",
(gptr*) &opt_comments, (gptr*) &opt_comments, 0, GET_BOOL, NO_ARG,
1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@ -302,6 +301,8 @@ static int init_dumping(char *);
static int dump_databases(char **);
static int dump_all_databases();
static char *quote_name(const char *name, char *buff, my_bool force);
static const char *check_if_ignore_table(const char *table_name);
static void print_version(void)
{
@ -345,7 +346,7 @@ static void write_header(FILE *sql_file, char *db_name)
fputs("<?xml version=\"1.0\"?>\n", sql_file);
fputs("<mysqldump>\n", sql_file);
}
else
else if (opt_comments)
{
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
fprintf(sql_file, "-- Host: %s Database: %s\n",
@ -656,6 +657,23 @@ static char *quote_name(const char *name, char *buff, my_bool force)
} /* quote_name */
static char *quote_for_like(const char *name, char *buff)
{
char *to= buff;
*to++= '\'';
while (*name)
{
if (*name == '\'' || *name == '_' || *name == '\\' || *name == '%')
*to++= '\\';
*to++= *name++;
}
to[0]= '\'';
to[1]= 0;
return buff;
}
/*
Quote and print a string.
@ -854,7 +872,8 @@ static uint getTableStructure(char *table, char* db)
}
write_header(sql_file, db);
}
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
if (!opt_xml && opt_comments)
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
result_table);
if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", opt_quoted_table);
@ -930,7 +949,7 @@ static uint getTableStructure(char *table, char* db)
}
write_header(sql_file, db);
}
if (!opt_xml)
if (!opt_xml && opt_comments)
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
result_table);
if (opt_drop)
@ -1067,16 +1086,9 @@ static uint getTableStructure(char *table, char* db)
/* Get MySQL specific create options */
if (create_options)
{
ulong len= strlen(table);
char *tmp= (char*) my_malloc(len * 2 + 1, MYF(MY_WME));
if (!tmp)
{
ignore_errors= 0;
safe_exit(EX_MYSQLERR);
}
mysql_real_escape_string(&mysql_connection, tmp, table, len);
sprintf(buff,"show table status like \"%s\"", tmp);
my_free(tmp, MYF(MY_WME));
char show_name_buff[FN_REFLEN];
sprintf(buff,"show table status like %s",
quote_for_like(table, show_name_buff));
if (mysql_query(sock, buff))
{
if (mysql_errno(sock) != ER_PARSE_ERROR)
@ -1191,11 +1203,23 @@ static void dumpTable(uint numFields, char *table)
MYSQL_FIELD *field;
MYSQL_ROW row;
ulong rownr, row_break, total_length, init_length;
const char *table_type;
result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
/* Check table type */
if ((table_type= check_if_ignore_table(table)))
{
if (verbose)
fprintf(stderr,
"-- Skipping data for table '%s' because it's of type %s\n",
table, table_type);
return;
}
if (verbose)
fprintf(stderr, "-- Sending SELECT query...\n");
result_table= quote_name(table,table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
@ -1234,14 +1258,14 @@ static void dumpTable(uint numFields, char *table)
}
else
{
if (!opt_xml)
if (!opt_xml && opt_comments)
fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n",
result_table);
sprintf(query, "SELECT /*!40001 SQL_NO_CACHE */ * FROM %s",
result_table);
if (where)
{
if (!opt_xml)
if (!opt_xml && opt_comments)
fprintf(md_result_file,"-- WHERE: %s\n",where);
strxmov(strend(query), " WHERE ",where,NullS);
}
@ -1337,11 +1361,23 @@ static void dumpTable(uint numFields, char *table)
}
else
{
/* change any strings ("inf","nan",..) into NULL */
/* change any strings ("inf", "-inf", "nan") into NULL */
char *ptr = row[i];
dynstr_append(&extended_row,
(!my_isalpha(charset_info,*ptr)) ?
ptr : "NULL");
if (my_isalpha(charset_info, *ptr) || (*ptr == '-' &&
my_isalpha(charset_info, ptr[1])))
dynstr_append(&extended_row, "NULL");
else
{
if (field->type == FIELD_TYPE_DECIMAL)
{
/* add " signs around */
dynstr_append(&extended_row, "\"");
dynstr_append(&extended_row, ptr);
dynstr_append(&extended_row, "\"");
}
else
dynstr_append(&extended_row, ptr);
}
}
}
else
@ -1373,7 +1409,7 @@ static void dumpTable(uint numFields, char *table)
}
else
{
/* change any strings ("inf","nan",..) into NULL */
/* change any strings ("inf", "-inf", "nan") into NULL */
char *ptr = row[i];
if (opt_xml)
{
@ -1383,19 +1419,20 @@ static void dumpTable(uint numFields, char *table)
md_result_file);
fputs("</field>\n", md_result_file);
}
else if (my_isalpha(charset_info, *ptr) ||
(*ptr == '-' && my_isalpha(charset_info, ptr[1])))
fputs("NULL", md_result_file);
else if (field->type == FIELD_TYPE_DECIMAL)
{
/* add " signs around */
fputs("\"", md_result_file);
fputs(ptr, md_result_file);
fputs("\"", md_result_file);
}
else
fputs((!my_isalpha(charset_info,*ptr)) ?
ptr : "NULL", md_result_file);
fputs(ptr, md_result_file);
}
}
else
{
if (opt_xml)
print_xml_tag1(md_result_file, "\t\t", "field name=",
field->name, "NULL</field>\n");
else
fputs("NULL", md_result_file);
}
}
}
@ -1533,8 +1570,8 @@ static int init_dumping(char *database)
*/
char quoted_database_buf[64*2+3];
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
if (opt_comments)
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
if (!opt_create_db)
{
char qbuf[256];
@ -1730,6 +1767,61 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
} /* print_value */
/*
Check if we the table is one of the table types that should be ignored:
MRG_ISAM, MRG_MYISAM
SYNOPSIS
check_if_ignore_table()
table_name Table name to check
GLOBAL VARIABLES
sock MySQL socket
verbose Write warning messages
RETURN
0 Table should be backuped
# Type of table (that should be skipped)
*/
static const char *check_if_ignore_table(const char *table_name)
{
char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
MYSQL_RES *res;
MYSQL_ROW row;
const char *result= 0;
sprintf(buff,"show table status like %s",
quote_for_like(table_name, show_name_buff));
if (mysql_query(sock, buff))
{
if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */
if (verbose)
fprintf(stderr,
"-- Warning: Couldn't get status information for table %s (%s)\n",
table_name,mysql_error(sock));
return 0; /* assume table is ok */
}
}
if (!(res= mysql_store_result(sock)) ||
!(row= mysql_fetch_row(res)))
{
fprintf(stderr,
"Error: Couldn't read status information for table %s (%s)\n",
table_name, mysql_error(sock));
if (res)
mysql_free_result(res);
return 0; /* assume table is ok */
}
if (strcmp(row[1], (result= "MRG_MyISAM")) &&
strcmp(row[1], (result= "MRG_ISAM")))
result= 0;
mysql_free_result(res);
return result;
}
int main(int argc, char **argv)
{
MYSQL_ROW row;
@ -1799,8 +1891,9 @@ int main(int argc, char **argv)
row = mysql_fetch_row(master);
if (row && row[0] && row[1])
{
fprintf(md_result_file,
"\n--\n-- Position to start replication from\n--\n\n");
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication from\n--\n\n");
fprintf(md_result_file,
"CHANGE MASTER TO MASTER_LOG_FILE='%s', \
MASTER_LOG_POS=%s ;\n",row[0],row[1]);

View file

@ -2153,7 +2153,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
DYNAMIC_STRING *ds;
DYNAMIC_STRING ds_tmp;
DYNAMIC_STRING eval_query;
char* query, buff[MAX_DELIMITER + 1]= {0};
char* query;
int query_len;
DBUG_ENTER("run_query");
@ -2188,8 +2188,8 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
if ((flags & QUERY_SEND) && !disable_query_log && !counter)
{
replace_dynstr_append_mem(ds,query, query_len);
sprintf(buff, "%s\n", delimiter);
dynstr_append_mem(ds, buff, delimiter_length + 1);
dynstr_append_mem(ds, delimiter, delimiter_length);
dynstr_append_mem(ds, "\n", 1);
}
if (!(flags & QUERY_REAP))
DBUG_RETURN(0);

View file

@ -731,7 +731,7 @@ AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
sys/ioctl.h malloc.h sys/malloc.h)
sys/ioctl.h malloc.h sys/malloc.h linux/config.h)
#--------------------------------------------------------------------
# Check for system libraries. Adds the library to $LIBS

View file

@ -501,7 +501,7 @@ void _db_push_ (const char *control)
if (! _db_fp_)
_db_fp_= stderr; /* Output stream, default stderr */
if (control && *control == '-')
if (*control == '-')
{
if (*++control == '#')
control++;

View file

@ -93,6 +93,7 @@ functions */
#define LONGLONG_MIN ((__int64) 0x8000000000000000)
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
#define ULONGLONG_MAX ((unsigned __int64) 0xFFFFFFFFFFFFFFFF)
#define LL(A) ((__int64) A)
/* Type information */
@ -158,6 +159,10 @@ typedef uint rf_SetTimer;
#define USE_MB_IDENT 1
#define USE_STRCOLL 1
/* All windows servers should support .sym files */
#undef USE_SYMDIR
#define USE_SYMDIR
/* If LOAD DATA LOCAL INFILE should be enabled by default */
#define ENABLED_LOCAL_INFILE 1

View file

@ -86,5 +86,4 @@ extern const char *client_errors[]; /* Error messages */
#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2045
#define CR_CONN_UNKNOW_PROTOCOL 2046
#define CR_INVALID_CONN_HANDLE 2047
#define CR_MYSQL_SERVER_INIT_MISSED 2048
#define CR_SECURE_AUTH 2049
#define CR_SECURE_AUTH 2048

View file

@ -190,11 +190,17 @@ enum ha_base_keytype {
/* poor old NISAM has 8-bit flags :-( */
#define HA_SORT_ALLOWS_SAME 128 /* Intern bit when sorting records */
#endif
/*
Key has a part that can have end space. If this is an unique key
we have to handle it differently from other unique keys as we can find
many matching rows for one key (becaue end space are not compared)
*/
#define HA_END_SPACE_KEY 4096
/* These flags can be order to key-seg-flag */
/* These flags can be added to key-seg-flag */
#define HA_SPACE_PACK 1 /* Pack space in key-seg */
#define HA_PART_KEY 4 /* Used by MySQL for part-key-cols */
#define HA_PART_KEY_SEG 4 /* Used by MySQL for part-key-cols */
#define HA_VAR_LENGTH 8
#define HA_NULL_PART 16
#define HA_BLOB_PART 32

View file

@ -74,14 +74,21 @@ typedef struct my_stat
#endif /* USE_MY_STAT_STRUCT */
typedef struct fileinfo /* Struct returned from my_dir & my_stat */
/* Struct describing one file returned from my_dir */
typedef struct fileinfo
{
char *name;
MY_STAT mystat;
MY_STAT *mystat;
} FILEINFO;
typedef struct st_my_dir /* Struct returned from my_dir */
{
/*
These members are just copies of parts of DYNAMIC_ARRAY structure,
which is allocated right after the end of MY_DIR structure (MEM_ROOT
for storing names is also resides there). We've left them here because
we don't want to change code that uses my_dir.
*/
struct fileinfo *dir_entry;
uint number_off_files;
} MY_DIR;

View file

@ -294,6 +294,9 @@ C_MODE_END
#endif
#ifdef HAVE_ATOMIC_ADD
#define __SMP__
#ifdef HAVE_LINUX_CONFIG_H
#include <linux/config.h> /* May define CONFIG_SMP */
#endif
#ifndef CONFIG_SMP
#define CONFIG_SMP
#endif
@ -633,11 +636,26 @@ extern double my_atof(const char*);
#define HAVE_LONG_LONG 1
#endif
/*
Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
Also on Windows we define these constants by hand in config-win.h.
*/
#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
#define LONGLONG_MIN ((long long) 0x8000000000000000LL)
#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
#endif
#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
/* First check for ANSI C99 definition: */
#ifdef ULLONG_MAX
#define ULONGLONG_MAX ULLONG_MAX
#else
#define ULONGLONG_MAX ((unsigned long long)(~0ULL))
#endif
#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
#if SIZEOF_LONG == 4
#define INT_MIN32 (long) 0x80000000L
#define INT_MAX32 (long) 0x7FFFFFFFL
@ -1162,4 +1180,10 @@ typedef union {
#endif
#endif
#ifdef HAVE_CHARSET_utf8
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
#else
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
#endif
#endif /* my_global_h */

View file

@ -117,6 +117,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#undef SAFE_MUTEX /* This will cause conflicts */
#define pthread_key(T,V) DWORD V
#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
#define pthread_key_delete(A) TlsFree(A)
#define pthread_getspecific(A) (TlsGetValue(A))
#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
@ -125,6 +126,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#else
#define pthread_key(T,V) __declspec(thread) T V
#define pthread_key_create(A,B) pthread_dummy(0)
#define pthread_key_delete(A) pthread_dummy(0)
#define pthread_getspecific(A) (&(A))
#define my_pthread_getspecific(T,A) (&(A))
#define my_pthread_getspecific_ptr(T,V) (V)
@ -180,6 +182,7 @@ extern int pthread_mutex_destroy (pthread_mutex_t *);
typedef int pthread_attr_t; /* Needed by Unixware 7.0.0 */
#define pthread_key_create(A,B) thr_keycreate((A),(B))
#define pthread_key_delete(A) thr_keydelete(A)
#define pthread_handler_decl(A,B) void *A(void *B)
#define pthread_key(T,V) pthread_key_t V

View file

@ -163,7 +163,7 @@ extern char *my_strdup_with_length(const byte *from, uint length,
#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
#pragma alloca
#endif /* _AIX */
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H)
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
#define alloca __builtin_alloca
#endif /* GNUC */
#define my_alloca(SZ) alloca((size_t) (SZ))
@ -583,7 +583,7 @@ extern int my_printf_error _VARARGS((uint my_err, const char *format,
extern int my_message(uint my_err, const char *str,myf MyFlags);
extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
extern void my_init(void);
extern my_bool my_init(void);
extern void my_end(int infoflag);
extern int my_redel(const char *from, const char *to, int MyFlags);
extern int my_copystat(const char *from, const char *to, int MyFlags);

View file

@ -638,9 +638,6 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
(*(mysql)->methods->advanced_command)(mysql, command, \
NullS, 0, arg, length, skip_check)
unsigned long net_safe_read(MYSQL* mysql);
void mysql_once_init(void);
extern my_bool server_inited;
#ifdef __NETWARE__
#pragma pack(pop) /* restore alignment */

View file

@ -356,7 +356,7 @@ const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
/* Some other useful functions */
void my_init(void);
my_bool my_init(void);
int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
my_bool my_thread_init(void);

View file

@ -32,4 +32,6 @@
#undef MYSQL_SERVER_SUFFIX
#define MYSQL_SERVER_SUFFIX "-embedded"
#undef HAVE_QUERY_CACHE /* Cache dosn't work yet */
#endif /* EMBEDDED_LIBRARY */

View file

@ -301,7 +301,7 @@
#define ER_BAD_FT_COLUMN 1282
#define ER_UNKNOWN_KEY_CACHE 1283
#define ER_WARN_HOSTNAME_WONT_WORK 1284
#define ER_UNKNOWN_TABLE_ENGINE 1285
#define ER_UNKNOWN_STORAGE_ENGINE 1285
#define ER_WARN_DEPRECATED_SYNTAX 1286
#define ER_SP_NO_RECURSIVE_CREATE 1287
#define ER_SP_ALREADY_EXISTS 1288

View file

@ -161,7 +161,7 @@ ER_WARN_DATA_OUT_OF_RANGE, "01000", "",
ER_WARN_DATA_TRUNCATED, "01000", "",
ER_WRONG_NAME_FOR_INDEX, "42000", "",
ER_WRONG_NAME_FOR_CATALOG, "42000", "",
ER_UNKNOWN_TABLE_ENGINE, "42000", "",
ER_UNKNOWN_STORAGE_ENGINE, "42000", "",
/* 5.0 */
ER_SP_NO_RECURSIVE_CREATE, "2F003", "",
ER_SP_ALREADY_EXISTS, "42000", "",

View file

@ -1151,7 +1151,6 @@ btr_cur_pessimistic_insert(
}
/*==================== B-TREE UPDATE =========================*/
/* Only clustered index records are modified using these functions */
/*****************************************************************
For an update, checks the locks and does the undo logging. */
@ -1175,12 +1174,16 @@ btr_cur_upd_lock_and_undo(
ut_ad(cursor && update && thr && roll_ptr);
/* Only clustered index records are updated using this function */
ut_ad((cursor->index)->type & DICT_CLUSTERED);
rec = btr_cur_get_rec(cursor);
index = cursor->index;
if (!(index->type & DICT_CLUSTERED)) {
/* We do undo logging only when we update a clustered index
record */
return(lock_sec_rec_modify_check_and_lock(flags, rec, index,
thr));
}
/* Check if we have to wait for a lock: enqueue an explicit lock
request if yes */
@ -1227,6 +1230,13 @@ btr_cur_update_in_place_log(
mach_write_to_1(log_ptr, flags);
log_ptr++;
/* The code below assumes index is a clustered index: change index to
the clustered index if we are updating a secondary index record (or we
could as well skip writing the sys col values to the log in this case
because they are not needed for a secondary index record update) */
index = dict_table_get_first_index(index->table);
log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr,
mtr);
mach_write_to_2(log_ptr, rec - buf_frame_align(rec));
@ -1394,13 +1404,10 @@ btr_cur_update_in_place(
buf_block_t* block;
ulint err;
rec_t* rec;
dulint roll_ptr;
dulint roll_ptr = ut_dulint_zero;
trx_t* trx;
ibool was_delete_marked;
/* Only clustered index records are updated using this function */
ut_ad(cursor->index->type & DICT_CLUSTERED);
rec = btr_cur_get_rec(cursor);
index = cursor->index;
trx = thr_get_trx(thr);
@ -1425,7 +1432,12 @@ btr_cur_update_in_place(
block = buf_block_align(rec);
if (block->is_hashed) {
if (row_upd_changes_ord_field_binary(NULL, index, update)) {
/* The function row_upd_changes_ord_field_binary works only
if the update vector was built for a clustered index, we must
NOT call it if index is secondary */
if (!(index->type & DICT_CLUSTERED)
|| row_upd_changes_ord_field_binary(NULL, index, update)) {
/* Remove possible hash index pointer to this record */
btr_search_update_hash_on_delete(cursor);
@ -1499,9 +1511,6 @@ btr_cur_optimistic_update(
mem_heap_t* heap;
ibool reorganized = FALSE;
ulint i;
/* Only clustered index records are updated using this function */
ut_ad((cursor->index)->type & DICT_CLUSTERED);
page = btr_cur_get_page(cursor);
rec = btr_cur_get_rec(cursor);
@ -1551,8 +1560,8 @@ btr_cur_optimistic_update(
new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap);
row_upd_index_replace_new_col_vals(new_entry, index, update, NULL);
row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
NULL);
old_rec_size = rec_get_size(rec);
new_rec_size = rec_get_converted_size(new_entry);
@ -1735,7 +1744,6 @@ btr_cur_pessimistic_update(
index = cursor->index;
tree = index->tree;
ut_ad(index->type & DICT_CLUSTERED);
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
@ -1786,8 +1794,8 @@ btr_cur_pessimistic_update(
new_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap);
row_upd_index_replace_new_col_vals(new_entry, index, update, heap);
row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
heap);
if (!(flags & BTR_KEEP_SYS_FLAG)) {
row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
roll_ptr);

View file

@ -188,22 +188,6 @@ btr_cur_pessimistic_insert(
que_thr_t* thr, /* in: query thread or NULL */
mtr_t* mtr); /* in: mtr */
/*****************************************************************
Updates a secondary index record when the update causes no size
changes in its fields. The only case when this function is currently
called is that in a char field characters change to others which
are identified in the collation order. */
ulint
btr_cur_update_sec_rec_in_place(
/*============================*/
/* out: DB_SUCCESS or error number */
btr_cur_t* cursor, /* in: cursor on the record to update;
cursor stays valid and positioned on the
same record */
upd_t* update, /* in: update vector */
que_thr_t* thr, /* in: query thread */
mtr_t* mtr); /* in: mtr */
/*****************************************************************
Updates a record when the update causes no size changes in its fields. */
ulint

View file

@ -123,8 +123,8 @@ row_upd_changes_field_size_or_external(
/* out: TRUE if the update changes the size of
some field in index or the field is external
in rec or update */
rec_t* rec, /* in: record in clustered index */
dict_index_t* index, /* in: clustered index */
rec_t* rec, /* in: record in index */
dict_index_t* index, /* in: index */
upd_t* update);/* in: update vector */
/***************************************************************
Replaces the new column values stored in the update vector to the record
@ -171,13 +171,31 @@ row_upd_build_difference_binary(
Replaces the new column values stored in the update vector to the index entry
given. */
void
row_upd_index_replace_new_col_vals_index_pos(
/*=========================================*/
dtuple_t* entry, /* in/out: index entry where replaced */
dict_index_t* index, /* in: index; NOTE that this may also be a
non-clustered index */
upd_t* update, /* in: an update vector built for the index so
that the field number in an upd_field is the
index position */
mem_heap_t* heap); /* in: memory heap to which we allocate and
copy the new values, set this as NULL if you
do not want allocation */
/***************************************************************
Replaces the new column values stored in the update vector to the index entry
given. */
void
row_upd_index_replace_new_col_vals(
/*===============================*/
dtuple_t* entry, /* in/out: index entry where replaced */
dict_index_t* index, /* in: index; NOTE that may also be a
dict_index_t* index, /* in: index; NOTE that this may also be a
non-clustered index */
upd_t* update, /* in: update vector */
upd_t* update, /* in: an update vector built for the
CLUSTERED index so that the field number in
an upd_field is the clustered index position */
mem_heap_t* heap); /* in: memory heap to which we allocate and
copy the new values, set this as NULL if you
do not want allocation */
@ -199,7 +217,9 @@ row_upd_changes_ord_field_binary(
known when this function is called, e.g., at
compile time */
dict_index_t* index, /* in: index of the record */
upd_t* update);/* in: update vector for the row */
upd_t* update);/* in: update vector for the row; NOTE: the
field numbers in this MUST be clustered index
positions! */
/***************************************************************
Checks if an update vector changes an ordering field of an index record.
This function is fast if the update vector is short or the number of ordering
@ -271,7 +291,10 @@ row_upd_index_parse(
/* Update vector field */
struct upd_field_struct{
ulint field_no; /* field number in the clustered
ulint field_no; /* field number in an index, usually
the clustered index, but in updating
a secondary index record in btr0cur.c
this is the position in the secondary
index */
que_node_t* exp; /* expression for calculating a new
value: it refers to column values and

View file

@ -339,6 +339,11 @@ lock_deadlock_recursive(
ulint* cost); /* in/out: number of calculation steps thus
far: if this exceeds LOCK_MAX_N_STEPS_...
we return TRUE */
#define lock_mutex_enter_kernel() mutex_enter(&kernel_mutex)
#define lock_mutex_exit_kernel() mutex_exit(&kernel_mutex)
#ifdef notdefined
/*************************************************************************
Reserves the kernel mutex. This function is used in this module to allow
monitoring the contention degree on the kernel mutex caused by the lock
@ -362,6 +367,7 @@ lock_mutex_exit_kernel(void)
{
mutex_exit(&kernel_mutex);
}
#endif
#ifdef notdefined

View file

@ -225,11 +225,15 @@ ulint
row_ins_sec_index_entry_by_modify(
/*==============================*/
/* out: DB_SUCCESS or error code */
ulint mode, /* in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE,
depending on whether mtr holds just a leaf
latch or also a tree latch */
btr_cur_t* cursor, /* in: B-tree cursor */
dtuple_t* entry, /* in: index entry to insert */
que_thr_t* thr, /* in: query thread */
mtr_t* mtr) /* in: mtr */
{
big_rec_t* dummy_big_rec;
mem_heap_t* heap;
upd_t* update;
rec_t* rec;
@ -241,16 +245,28 @@ row_ins_sec_index_entry_by_modify(
ut_ad(rec_get_deleted_flag(rec));
/* We know that in the alphabetical ordering, entry and rec are
identical. But in their binary form there may be differences if
identified. But in their binary form there may be differences if
there are char fields in them. Therefore we have to calculate the
difference and do an update-in-place if necessary. */
difference. */
heap = mem_heap_create(1024);
update = row_upd_build_sec_rec_difference_binary(cursor->index,
entry, rec, heap);
if (mode == BTR_MODIFY_LEAF) {
/* Try an optimistic updating of the record, keeping changes
within the page */
err = btr_cur_update_sec_rec_in_place(cursor, update, thr, mtr);
err = btr_cur_optimistic_update(BTR_KEEP_SYS_FLAG, cursor,
update, 0, thr, mtr);
if (err == DB_OVERFLOW || err == DB_UNDERFLOW) {
err = DB_FAIL;
}
} else {
ut_a(mode == BTR_MODIFY_TREE);
err = btr_cur_pessimistic_update(BTR_KEEP_SYS_FLAG, cursor,
&dummy_big_rec, update, 0, thr, mtr);
}
mem_heap_free(heap);
@ -1838,7 +1854,8 @@ row_ins_index_entry_low(
ext_vec, n_ext_vec,
thr, &mtr);
} else {
err = row_ins_sec_index_entry_by_modify(&cursor, entry,
err = row_ins_sec_index_entry_by_modify(mode, &cursor,
entry,
thr, &mtr);
}

View file

@ -51,7 +51,8 @@ to que_run_threads: this is to allow canceling runaway queries */
/************************************************************************
Returns TRUE if the user-defined column values in a secondary index record
are the same as the corresponding columns in the clustered index record.
are alphabetically the same as the corresponding columns in the clustered
index record.
NOTE: the comparison is NOT done as a binary comparison, but character
fields are compared with collation! */
static
@ -96,11 +97,6 @@ row_sel_sec_rec_is_for_clust_rec(
clust_len = ifield->prefix_len;
}
if (sec_len != clust_len) {
return(FALSE);
}
if (0 != cmp_data_data(dict_col_get_type(col),
clust_field, clust_len,
sec_field, sec_len)) {

View file

@ -377,8 +377,14 @@ row_undo_mod_del_mark_or_remove_sec_low(
}
/***************************************************************
Delete marks or removes a secondary index entry if found. */
UNIV_INLINE
Delete marks or removes a secondary index entry if found.
NOTE that if we updated the fields of a delete-marked secondary index record
so that alphabetically they stayed the same, e.g., 'abc' -> 'aBc', we cannot
return to the original values because we do not know them. But this should
not cause problems because in row0sel.c, in queries we always retrieve the
clustered index record or an earlier version of it, if the secondary index
record through which we do the search is delete-marked. */
static
ulint
row_undo_mod_del_mark_or_remove_sec(
/*================================*/
@ -403,20 +409,31 @@ row_undo_mod_del_mark_or_remove_sec(
}
/***************************************************************
Delete unmarks a secondary index entry which must be found. */
Delete unmarks a secondary index entry which must be found. It might not be
delete-marked at the moment, but it does not harm to unmark it anyway. We also
need to update the fields of the secondary index record if we updated its
fields but alphabetically they stayed the same, e.g., 'abc' -> 'aBc'. */
static
void
row_undo_mod_del_unmark_sec(
/*========================*/
ulint
row_undo_mod_del_unmark_sec_and_undo_update(
/*========================================*/
/* out: DB_FAIL or DB_SUCCESS or
DB_OUT_OF_FILE_SPACE */
ulint mode, /* in: search mode: BTR_MODIFY_LEAF or
BTR_MODIFY_TREE */
undo_node_t* node, /* in: row undo node */
que_thr_t* thr, /* in: query thread */
dict_index_t* index, /* in: index */
dtuple_t* entry) /* in: index entry */
{
mem_heap_t* heap;
btr_pcur_t pcur;
btr_cur_t* btr_cur;
ulint err;
upd_t* update;
rec_t* rec;
ulint err = DB_SUCCESS;
ibool found;
big_rec_t* dummy_big_rec;
mtr_t mtr;
char err_buf[1000];
@ -425,8 +442,8 @@ row_undo_mod_del_unmark_sec(
log_free_check();
mtr_start(&mtr);
found = row_search_index_entry(index, entry, BTR_MODIFY_LEAF, &pcur,
&mtr);
found = row_search_index_entry(index, entry, mode, &pcur, &mtr);
if (!found) {
fprintf(stderr,
"InnoDB: error in sec index entry del undo in\n"
@ -443,17 +460,47 @@ row_undo_mod_del_unmark_sec(
"%s\nInnoDB: Make a detailed bug report and send it\n",
err_buf);
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
} else {
btr_cur = btr_pcur_get_btr_cur(&pcur);
rec = btr_cur_get_rec(btr_cur);
err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG,
btr_cur, FALSE, thr, &mtr);
ut_ad(err == DB_SUCCESS);
ut_a(err == DB_SUCCESS);
heap = mem_heap_create(100);
update = row_upd_build_sec_rec_difference_binary(index, entry,
rec, heap);
if (upd_get_n_fields(update) == 0) {
/* Do nothing */
} else if (mode == BTR_MODIFY_LEAF) {
/* Try an optimistic updating of the record, keeping
changes within the page */
err = btr_cur_optimistic_update(BTR_KEEP_SYS_FLAG
| BTR_NO_LOCKING_FLAG,
btr_cur, update, 0, thr, &mtr);
if (err == DB_OVERFLOW || err == DB_UNDERFLOW) {
err = DB_FAIL;
}
} else {
ut_a(mode == BTR_MODIFY_TREE);
err = btr_cur_pessimistic_update(BTR_KEEP_SYS_FLAG
| BTR_NO_LOCKING_FLAG,
btr_cur, &dummy_big_rec,
update, 0, thr, &mtr);
}
mem_heap_free(heap);
}
btr_pcur_close(&pcur);
mtr_commit(&mtr);
return(err);
}
/***************************************************************
@ -501,13 +548,14 @@ static
ulint
row_undo_mod_del_mark_sec(
/*======================*/
/* out: DB_SUCCESS */
/* out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
undo_node_t* node, /* in: row undo node */
que_thr_t* thr) /* in: query thread */
{
mem_heap_t* heap;
dtuple_t* entry;
dict_index_t* index;
ulint err;
heap = mem_heap_create(1024);
@ -516,7 +564,21 @@ row_undo_mod_del_mark_sec(
entry = row_build_index_entry(node->row, index, heap);
row_undo_mod_del_unmark_sec(node, thr, index, entry);
err = row_undo_mod_del_unmark_sec_and_undo_update(
BTR_MODIFY_LEAF,
node, thr, index, entry);
if (err == DB_FAIL) {
err = row_undo_mod_del_unmark_sec_and_undo_update(
BTR_MODIFY_TREE,
node, thr, index, entry);
}
if (err != DB_SUCCESS) {
mem_heap_free(heap);
return(err);
}
node->index = dict_table_get_next_index(node->index);
}
@ -532,7 +594,7 @@ static
ulint
row_undo_mod_upd_exist_sec(
/*=======================*/
/* out: DB_SUCCESS or error code */
/* out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
undo_node_t* node, /* in: row undo node */
que_thr_t* thr) /* in: query thread */
{
@ -558,22 +620,48 @@ row_undo_mod_upd_exist_sec(
/* Build the newest version of the index entry */
entry = row_build_index_entry(node->row, index, heap);
/* NOTE that if we updated the fields of a
delete-marked secondary index record so that
alphabetically they stayed the same, e.g.,
'abc' -> 'aBc', we cannot return to the original
values because we do not know them. But this should
not cause problems because in row0sel.c, in queries
we always retrieve the clustered index record or an
earlier version of it, if the secondary index record
through which we do the search is delete-marked. */
err = row_undo_mod_del_mark_or_remove_sec(node, thr,
index, entry);
index, entry);
if (err != DB_SUCCESS) {
mem_heap_free(heap);
return(err);
}
/* We may have to update the delete mark in the
secondary index record of the previous version of
the row */
the row. We also need to update the fields of
the secondary index record if we updated its fields
but alphabetically they stayed the same, e.g.,
'abc' -> 'aBc'. */
row_upd_index_replace_new_col_vals(entry, index,
node->update, NULL);
err = row_undo_mod_del_unmark_sec_and_undo_update(
BTR_MODIFY_LEAF,
node, thr, index, entry);
if (err == DB_FAIL) {
err =
row_undo_mod_del_unmark_sec_and_undo_update(
BTR_MODIFY_TREE,
node, thr, index, entry);
}
row_undo_mod_del_unmark_sec(node, thr, index, entry);
if (err != DB_SUCCESS) {
mem_heap_free(heap);
return(err);
}
}
node->index = dict_table_get_next_index(node->index);

View file

@ -361,8 +361,8 @@ row_upd_changes_field_size_or_external(
/* out: TRUE if the update changes the size of
some field in index or the field is external
in rec or update */
rec_t* rec, /* in: record in clustered index */
dict_index_t* index, /* in: clustered index */
rec_t* rec, /* in: record in index */
dict_index_t* index, /* in: index */
upd_t* update) /* in: update vector */
{
upd_field_t* upd_field;
@ -372,8 +372,6 @@ row_upd_changes_field_size_or_external(
ulint n_fields;
ulint i;
ut_ad(index->type & DICT_CLUSTERED);
n_fields = upd_get_n_fields(update);
for (i = 0; i < n_fields; i++) {
@ -698,7 +696,7 @@ row_upd_build_sec_rec_difference_binary(
ulint i;
/* This function is used only for a secondary index */
ut_ad(0 == (index->type & DICT_CLUSTERED));
ut_a(0 == (index->type & DICT_CLUSTERED));
update = upd_create(dtuple_get_n_fields(entry), heap);
@ -710,7 +708,13 @@ row_upd_build_sec_rec_difference_binary(
dfield = dtuple_get_nth_field(entry, i);
ut_a(len == dfield_get_len(dfield));
/* NOTE that it may be that len != dfield_get_len(dfield) if we
are updating in a character set and collation where strings of
different length can be equal in an alphabetical comparison,
and also in the case where we have a column prefix index
and the last characters in the index field are spaces; the
latter case probably caused the assertion failures reported at
row0upd.c line 713 in versions 4.0.14 - 4.0.16. */
/* NOTE: we compare the fields as binary strings!
(No collation) */
@ -819,13 +823,77 @@ skip_compare:
Replaces the new column values stored in the update vector to the index entry
given. */
void
row_upd_index_replace_new_col_vals_index_pos(
/*=========================================*/
dtuple_t* entry, /* in/out: index entry where replaced */
dict_index_t* index, /* in: index; NOTE that this may also be a
non-clustered index */
upd_t* update, /* in: an update vector built for the index so
that the field number in an upd_field is the
index position */
mem_heap_t* heap) /* in: memory heap to which we allocate and
copy the new values, set this as NULL if you
do not want allocation */
{
dict_field_t* field;
upd_field_t* upd_field;
dfield_t* dfield;
dfield_t* new_val;
ulint j;
ulint i;
ut_ad(index);
dtuple_set_info_bits(entry, update->info_bits);
for (j = 0; j < dict_index_get_n_fields(index); j++) {
field = dict_index_get_nth_field(index, j);
for (i = 0; i < upd_get_n_fields(update); i++) {
upd_field = upd_get_nth_field(update, i);
if (upd_field->field_no == j) {
dfield = dtuple_get_nth_field(entry, j);
new_val = &(upd_field->new_val);
dfield_set_data(dfield, new_val->data,
new_val->len);
if (heap && new_val->len != UNIV_SQL_NULL) {
dfield->data = mem_heap_alloc(heap,
new_val->len);
ut_memcpy(dfield->data, new_val->data,
new_val->len);
}
if (field->prefix_len > 0
&& new_val->len != UNIV_SQL_NULL
&& new_val->len > field->prefix_len) {
dfield->len = field->prefix_len;
}
}
}
}
}
/***************************************************************
Replaces the new column values stored in the update vector to the index entry
given. */
void
row_upd_index_replace_new_col_vals(
/*===============================*/
dtuple_t* entry, /* in/out: index entry where replaced */
dict_index_t* index, /* in: index; NOTE that this may also be a
non-clustered index */
upd_t* update, /* in: update vector */
upd_t* update, /* in: an update vector built for the
CLUSTERED index so that the field number in
an upd_field is the clustered index position */
mem_heap_t* heap) /* in: memory heap to which we allocate and
copy the new values, set this as NULL if you
do not want allocation */
@ -893,7 +961,9 @@ row_upd_changes_ord_field_binary(
known when this function is called, e.g., at
compile time */
dict_index_t* index, /* in: index of the record */
upd_t* update) /* in: update vector for the row */
upd_t* update) /* in: update vector for the row; NOTE: the
field numbers in this MUST be clustered index
positions! */
{
upd_field_t* upd_field;
dict_field_t* ind_field;

View file

@ -117,9 +117,10 @@ row_vers_impl_x_locked_off_kernel(
return(NULL);
}
/* We look up if some earlier version of the clustered index record
would require rec to be in a different state (delete marked or
unmarked, or not existing). If there is such a version, then rec was
/* We look up if some earlier version, which was modified by the trx_id
transaction, of the clustered index record would require rec to be in
a different state (delete marked or unmarked, or have different field
values, or not existing). If there is such a version, then rec was
modified by the trx_id transaction, and it has an implicit x-lock on
rec. Note that if clust_rec itself would require rec to be in a
different state, then the trx_id transaction has not yet had time to
@ -188,6 +189,8 @@ row_vers_impl_x_locked_off_kernel(
vers_del = rec_get_deleted_flag(prev_version);
/* We check if entry and rec are identified in the alphabetical
ordering */
if (0 == cmp_dtuple_rec(entry, rec)) {
/* The delete marks of rec and prev_version should be
equal for rec to be in the state required by
@ -198,6 +201,20 @@ row_vers_impl_x_locked_off_kernel(
break;
}
/* It is possible that the row was updated so that the
secondary index record remained the same in
alphabetical ordering, but the field values changed
still. For example, 'abc' -> 'ABC'. Check also that. */
dtuple_set_types_binary(entry,
dtuple_get_n_fields(entry));
if (0 != cmp_dtuple_rec(entry, rec)) {
trx = trx_get_on_id(trx_id);
break;
}
} else if (!rec_del) {
/* The delete mark should be set in rec for it to be
in the state required by prev_version */
@ -256,8 +273,8 @@ row_vers_must_preserve_del_marked(
Finds out if a version of the record, where the version >= the current
purge view, should have ientry as its secondary index entry. We check
if there is any not delete marked version of the record where the trx
id >= purge view, and the secondary index entry == ientry; exactly in
this case we return TRUE. */
id >= purge view, and the secondary index entry and ientry are identified in
the alphabetical ordering; exactly in this case we return TRUE. */
ibool
row_vers_old_has_index_entry(

View file

@ -58,3 +58,14 @@ int cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt);
int cli_unbuffered_fetch(MYSQL *mysql, char **row);
const char * cli_read_statistic(MYSQL *mysql);
#ifdef EMBEDDED_LIBRARY
int init_embedded_server(int argc, char **argv, char **groups);
void end_embedded_server();
#else
/* Prevent warnings of unused parameters */
#define init_embedded_server(a,b,c) ((void)a, (void)b, (void)c, 0)
#define end_embedded_server()
#endif /*EMBEDDED_LIBRARY*/

View file

@ -72,7 +72,6 @@ const char *client_errors[]=
"Can't open shared memory. Can't send the request event to server (%lu)",
"Wrong or unknown protocol",
"Invalid connection handle",
"mysql_server_init wasn't called",
"Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)"
};
@ -129,7 +128,6 @@ const char *client_errors[]=
"Can't open shared memory. Can't send the request event to server (%lu)",
"Wrong or unknown protocol",
"Invalid connection handle",
"mysql_server_init wasn't called",
"Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)"
};
@ -184,7 +182,6 @@ const char *client_errors[]=
"Can't open shared memory. Can't send the request event to server (%lu)",
"Wrong or unknown protocol",
"Invalid connection handle",
"mysql_server_init wasn't called",
"Connection using old (pre 4.1.1) authentication protocol refused (client option 'secure_auth' enabled)"
};
#endif

View file

@ -94,13 +94,34 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
static my_bool mysql_client_init= 0;
static my_bool org_my_init_done= 0;
void mysql_once_init(void)
/*
Initialize the MySQL client library
SYNOPSIS
mysql_server_init()
NOTES
Should be called before doing any other calls to the MySQL
client library to initialize thread specific variables etc.
It's called by mysql_init() to ensure that things will work for
old not threaded applications that doesn't call mysql_server_init()
directly.
RETURN
0 ok
1 could not initialize environment (out of memory or thread keys)
*/
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
int result= 0;
if (!mysql_client_init)
{
mysql_client_init=1;
org_my_init_done=my_init_done;
my_init(); /* Will init threads */
if (my_init()) /* Will init threads */
return 1;
init_client_errs();
if (!mysql_port)
{
@ -131,24 +152,19 @@ void mysql_once_init(void)
#if defined(SIGPIPE) && !defined(__WIN__)
(void) signal(SIGPIPE, SIG_IGN);
#endif
result= init_embedded_server(argc, argv, groups);
}
#ifdef THREAD
else
my_thread_init(); /* Init if new thread */
result= (int)my_thread_init(); /* Init if new thread */
#endif
return result;
}
#ifndef EMBEDDED_LIBRARY
int STDCALL mysql_server_init(int argc __attribute__((unused)),
char **argv __attribute__((unused)),
char **groups __attribute__((unused)))
{
mysql_once_init();
return 0;
}
void STDCALL mysql_server_end()
{
end_embedded_server();
/* If library called my_init(), free memory allocated by it */
if (!org_my_init_done)
{
@ -163,8 +179,6 @@ void STDCALL mysql_server_end()
mysql_client_init= org_my_init_done= 0;
}
#endif /*EMBEDDED_LIBRARY*/
my_bool STDCALL mysql_thread_init()
{
#ifdef THREAD

View file

@ -28,5 +28,4 @@ extern void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db);
extern void *create_embedded_thd(int client_flag, char *db);
extern MYSQL_METHODS embedded_methods;
void free_old_query(MYSQL *mysql);
extern my_bool server_inited;
C_MODE_END

View file

@ -42,9 +42,6 @@ C_MODE_START
#include "errmsg.h"
#include <sql_common.h>
static my_bool org_my_init_done;
my_bool server_inited;
static my_bool
emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
@ -305,7 +302,7 @@ extern "C"
char ** copy_arguments_ptr= 0;
int STDCALL mysql_server_init(int argc, char **argv, char **groups)
int init_embedded_server(int argc, char **argv, char **groups)
{
char glob_hostname[FN_REFLEN];
@ -329,17 +326,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
if (!groups)
groups= (char**) fake_groups;
/* Only call MY_INIT() if it hasn't been called before */
if (!server_inited)
{
server_inited=1;
org_my_init_done=my_init_done;
}
if (!org_my_init_done)
{
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
}
my_progname= (char *)"mysql_embedded";
if (init_common_variables("my", *argcp, *argvp, (const char **)groups))
{
@ -438,14 +425,11 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
return 0;
}
void STDCALL mysql_server_end()
void end_embedded_server()
{
my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR));
copy_arguments_ptr=0;
clean_up(0);
/* If library called my_init(), free memory allocated by it */
if (!org_my_init_done)
my_end(0);
}
} /* extern "C" */

View file

@ -163,20 +163,12 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
db ? db : "(Null)",
user ? user : "(Null)"));
#if defined(EMBEDDED_LIBRARY) || !defined(DBUG_OFF)
if (!server_inited)
{
mysql->net.last_errno=CR_MYSQL_SERVER_INIT_MISSED;
strmov(mysql->net.last_error,ER(mysql->net.last_errno));
goto error;
}
#endif
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION ||
(mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION &&
host && strcmp(host,LOCAL_HOST)))
cli_mysql_real_connect(mysql, host, user,
passwd, db, port, unix_socket, client_flag);
DBUG_RETURN(cli_mysql_real_connect(mysql, host, user,
passwd, db, port,
unix_socket, client_flag));
mysql->methods= &embedded_methods;

View file

@ -373,10 +373,13 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
to alloc queue with alloc_root()
*/
res=ftb->queue.max_elements=1+query_len/(min(ft_min_word_len,2)+1);
ftb->queue.root=(byte **)alloc_root(&ftb->mem_root, (res+1)*sizeof(void*));
if (!(ftb->queue.root=
(byte **)alloc_root(&ftb->mem_root, (res+1)*sizeof(void*))))
goto err;
reinit_queue(& ftb->queue, res, 0, 0,
(int (*)(void*,byte*,byte*))FTB_WORD_cmp, 0);
ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR));
if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR))))
goto err;
ftbe->weight=1;
ftbe->flags=FTB_FLAG_YES;
ftbe->nos=1;
@ -394,6 +397,10 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
if (ftb->queue.elements<2) ftb->with_scan &= ~FTB_FLAG_TRUNC;
ftb->state=READY;
return ftb;
err:
free_root(& ftb->mem_root, MYF(0));
my_free((gptr)ftb,MYF(0));
return 0;
}

View file

@ -112,20 +112,13 @@ int chk_status(MI_CHECK *param, register MI_INFO *info)
int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag)
{
reg2 ha_rows i;
uint j,delete_link_length;
uint delete_link_length;
my_off_t empty,next_link,old_link;
char buff[22],buff2[22];
DBUG_ENTER("chk_del");
if (!(test_flag & T_SILENT))
puts("- check key delete-chain");
LINT_INIT(old_link);
param->record_checksum=0;
param->key_file_blocks=info->s->base.keystart;
for (j=0 ; j < info->s->state.header.max_block_size ; j++)
if (check_k_link(param,info,j))
goto wrong;
delete_link_length=((info->s->options & HA_OPTION_PACK_RECORD) ? 20 :
info->s->rec_reflength+1);
@ -352,6 +345,18 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
char buff[22],buff2[22];
DBUG_ENTER("chk_key");
if (!(param->testflag & T_SILENT))
puts("- check key delete-chain");
param->key_file_blocks=info->s->base.keystart;
for (key=0 ; key < info->s->state.header.max_block_size ; key++)
if (check_k_link(param,info,key))
{
if (param->testflag & T_VERBOSE) puts("");
mi_check_print_error(param,"key delete-link-chain corrupted");
DBUG_RETURN(-1);
}
if (!(param->testflag & T_SILENT)) puts("- check index reference");
all_keydata=all_totaldata=key_totlength=0;
@ -507,6 +512,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
DBUG_RETURN(result);
} /* chk_key */
static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
my_off_t page, uchar *buff, ha_rows *keys,
ha_checksum *key_checksum, uint level)
@ -548,7 +554,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
uint used_length,comp_flag,nod_flag,key_length,not_used;
uchar key[MI_MAX_POSSIBLE_KEY_BUFF],*temp_buff,*keypos,*old_keypos,*endpos;
my_off_t next_page,record;
char llbuff[22],llbuff2[22];
char llbuff[22];
DBUG_ENTER("chk_index");
DBUG_DUMP("buff",(byte*) buff,mi_getint(buff));
@ -646,7 +652,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
if (record >= info->state->data_file_length)
{
#ifndef DBUG_OFF
char llbuff3[22];
char llbuff2[22], llbuff3[22];
#endif
mi_check_print_error(param,"Found key at page %s that points to record outside datafile",llstr(page,llbuff));
DBUG_PRINT("test",("page: %s record: %s filelength: %s",
@ -1208,9 +1214,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
fn_format(param->temp_filename,name,"", MI_NAME_DEXT,2+4+32);
if ((new_file=my_raid_create(fn_format(param->temp_filename,
param->temp_filename,"",
share->data_file_name, "",
DATA_TMP_EXT, 2+4),
0,param->tmpfile_createflag,
share->base.raid_type,
@ -1882,11 +1887,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
fn_format(param->temp_filename,name,"", MI_NAME_DEXT,2+4+32);
if ((new_file=my_raid_create(fn_format(param->temp_filename,
param->temp_filename, "",
DATA_TMP_EXT,
2+4),
share->data_file_name, "",
DATA_TMP_EXT, 2+4),
0,param->tmpfile_createflag,
share->base.raid_type,
share->base.raid_chunks,
@ -2248,9 +2251,8 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
fn_format(param->temp_filename,name,"", MI_NAME_DEXT,2+4+32);
if ((new_file=my_raid_create(fn_format(param->temp_filename,
param->temp_filename, "",
share->data_file_name, "",
DATA_TMP_EXT,
2+4),
0,param->tmpfile_createflag,

View file

@ -137,6 +137,10 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg,
{
uint tmp_length;
get_key_length(tmp_length,key);
/*
The following command sometimes gives a warning from valgrind.
Not yet sure if the bug is in valgrind, glibc or mysqld
*/
VOID(fprintf(stream,"%.*s",(int) tmp_length,key));
key+=tmp_length;
break;

View file

@ -19,6 +19,7 @@
#include "myisamdef.h"
#include "m_ctype.h"
#include "sp_defs.h"
#include <assert.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
@ -397,53 +398,86 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf)
return(-1); /* Wrong data to read */
}
/*
Update auto_increment info
/* Update auto_increment info */
SYNOPSIS
update_auto_increment()
info MyISAM handler
record Row to update
IMPLEMENTATION
Only replace the auto_increment value if it is higher than the previous
one. For signed columns we don't update the auto increment value if it's
less than zero.
*/
void update_auto_increment(MI_INFO *info,const byte *record)
{
ulonglong value;
HA_KEYSEG *keyseg=info->s->keyinfo[info->s->base.auto_key-1].seg;
const uchar *key=(uchar*) record+keyseg->start;
ulonglong value= 0; /* Store unsigned values here */
longlong s_value= 0; /* Store signed values here */
HA_KEYSEG *keyseg= info->s->keyinfo[info->s->base.auto_key-1].seg;
const uchar *key= (uchar*) record + keyseg->start;
switch (keyseg->type) {
case HA_KEYTYPE_INT8:
s_value= (longlong) *(char*)key;
break;
case HA_KEYTYPE_BINARY:
value=(ulonglong) *(uchar*) key;
break;
case HA_KEYTYPE_SHORT_INT:
s_value= (longlong) sint2korr(key);
break;
case HA_KEYTYPE_USHORT_INT:
value=(ulonglong) uint2korr(key);
break;
case HA_KEYTYPE_LONG_INT:
s_value= (longlong) sint4korr(key);
break;
case HA_KEYTYPE_ULONG_INT:
value=(ulonglong) uint4korr(key);
break;
case HA_KEYTYPE_INT24:
s_value= (longlong) sint3korr(key);
break;
case HA_KEYTYPE_UINT24:
value=(ulonglong) uint3korr(key);
break;
case HA_KEYTYPE_FLOAT: /* This shouldn't be used */
case HA_KEYTYPE_FLOAT: /* This shouldn't be used */
{
float f_1;
float4get(f_1,key);
value = (ulonglong) f_1;
/* Ignore negative values */
value = (f_1 < (float) 0.0) ? 0 : (ulonglong) f_1;
break;
}
case HA_KEYTYPE_DOUBLE: /* This shouldn't be used */
case HA_KEYTYPE_DOUBLE: /* This shouldn't be used */
{
double f_1;
float8get(f_1,key);
value = (ulonglong) f_1;
/* Ignore negative values */
value = (f_1 < 0.0) ? 0 : (ulonglong) f_1;
break;
}
case HA_KEYTYPE_LONGLONG:
s_value= sint8korr(key);
break;
case HA_KEYTYPE_ULONGLONG:
value= uint8korr(key);
break;
default:
value=0; /* Error */
DBUG_ASSERT(0);
value=0; /* Error */
break;
}
set_if_bigger(info->s->state.auto_increment,value);
/*
The following code works becasue if s_value < 0 then value is 0
and if s_value == 0 then value will contain either s_value or the
correct value.
*/
set_if_bigger(info->s->state.auto_increment,
(s_value > 0) ? (ulonglong) s_value : value);
}

View file

@ -867,6 +867,8 @@ char *mi_state_info_read(char *ptr, MI_STATE_INFO *state)
state->status = mi_uint4korr(ptr); ptr +=4;
state->update_count=mi_uint4korr(ptr); ptr +=4;
ptr+= state->state_diff_length;
for (i=0; i < keys; i++)
{
state->key_root[i]= mi_sizekorr(ptr); ptr +=8;
@ -875,7 +877,6 @@ char *mi_state_info_read(char *ptr, MI_STATE_INFO *state)
{
state->key_del[i] = mi_sizekorr(ptr); ptr +=8;
}
ptr+= state->state_diff_length;
state->sec_index_changed = mi_uint4korr(ptr); ptr +=4;
state->sec_index_used = mi_uint4korr(ptr); ptr +=4;
state->version = mi_uint4korr(ptr); ptr +=4;

View file

@ -106,6 +106,32 @@ Table Op Msg_type Msg_text
test.t1 check warning Found row where the auto_increment column has the value 0
test.t1 check status OK
drop table t1;
create table t1 (a int not null auto_increment primary key);
insert into t1 values (NULL);
insert into t1 values (-1);
select last_insert_id();
last_insert_id()
1
insert into t1 values (NULL);
select * from t1;
a
-1
1
2
drop table t1;
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
insert into t1 values (NULL);
insert into t1 values (-1);
select last_insert_id();
last_insert_id()
1
insert into t1 values (NULL);
select * from t1;
a
1
-1
2
drop table t1;
create table t1 (i tinyint unsigned not null auto_increment primary key);
insert into t1 set i = 254;
insert into t1 set i = null;

View file

@ -1145,3 +1145,14 @@ x
7
6
drop table t1;
create table t1 ( c char(8) not null ) engine=bdb;
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
alter table t1 add b char(8) not null;
alter table t1 add a char(8) not null;
alter table t1 add primary key (a,b,c);
update t1 set a=c, b=c;
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=bdb;
insert into t2 select * from t1;
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
drop table t1,t2;

View file

@ -66,6 +66,7 @@ concat("-",a,"-",b,"-")
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
select concat("-",a,"-",b,"-") from t1 where b="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
concat("-",a,"-",b,"-")
-hello-hello-

View file

@ -189,9 +189,9 @@ select * from t1;
if('2002'='2002','Y','N')
Y
drop table if exists t1;
SET SESSION table_type="heap";
SELECT @@table_type;
@@table_type
SET SESSION storage_engine="heap";
SELECT @@storage_engine;
@@storage_engine
HEAP
CREATE TABLE t1 (a int not null);
show create table t1;
@ -200,10 +200,10 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=latin1
drop table t1;
SET SESSION table_type="gemini";
SET SESSION storage_engine="gemini";
ERROR 42000: Unknown table engine 'gemini'
SELECT @@table_type;
@@table_type
SELECT @@storage_engine;
@@storage_engine
HEAP
CREATE TABLE t1 (a int not null);
show create table t1;
@ -211,7 +211,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=latin1
SET SESSION table_type=default;
SET SESSION storage_engine=default;
drop table t1;
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
insert into t1 values ("a", 1), ("b", 2);
@ -334,9 +334,9 @@ ERROR 42000: Incorrect table name 'a/a'
drop table t1, t2, t3;
drop table t3;
drop database test_$1;
SET SESSION table_type="heap";
SELECT @@table_type;
@@table_type
SET SESSION storage_engine="heap";
SELECT @@storage_engine;
@@storage_engine
HEAP
CREATE TABLE t1 (a int not null);
show create table t1;
@ -345,10 +345,10 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=latin1
drop table t1;
SET SESSION table_type="gemini";
SET SESSION storage_engine="gemini";
ERROR 42000: Unknown table engine 'gemini'
SELECT @@table_type;
@@table_type
SELECT @@storage_engine;
@@storage_engine
HEAP
CREATE TABLE t1 (a int not null);
show create table t1;
@ -356,7 +356,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=latin1
SET SESSION table_type=default;
SET SESSION storage_engine=default;
drop table t1;
create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
insert into t1(a)values(1);

View file

@ -0,0 +1,20 @@
SET @@character_set_server=latin5;
CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251;
USE db1;
CREATE DATABASE db2;
SHOW CREATE DATABASE db1;
Database Create Database
db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET cp1251 */
SHOW CREATE DATABASE db2;
Database Create Database
db2 CREATE DATABASE `db2` /*!40100 DEFAULT CHARACTER SET latin5 */
DROP DATABASE db2;
USE db1;
CREATE TABLE t1 (a char(10));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=cp1251
DROP TABLE t1;
DROP DATABASE db1;

View file

@ -47,7 +47,7 @@ sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_
21 6 3.5000 1.7078 2.9167 7 0 1 6 E
select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
NULL NULL 0 NULL NULL NULL 0 0 NULL NULL
NULL NULL 0 NULL NULL NULL 0 18446744073709551615 NULL NULL
1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a
2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c
3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E
@ -576,8 +576,8 @@ insert into t1 values (1,null);
insert into t1 values (2,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 0 NULL NULL NULL NULL NULL 0 0
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 0 NULL NULL NULL NULL NULL 18446744073709551615 0
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
@ -585,8 +585,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
insert into t1 values (2,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
@ -594,8 +594,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1
3 1 1 1.0000 0.0000 1 1 1 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) bit_xor(b)
@ -632,3 +632,14 @@ select a from t1 having a=1;
a
1
drop table t1;
create table t1 (col int);
insert into t1 values (-1), (-2), (-3);
select bit_and(col), bit_or(col) from t1;
bit_and(col) bit_or(col)
18446744073709551612 18446744073709551615
select SQL_BIG_RESULT bit_and(col), bit_or(col) from t1 group by col;
bit_and(col) bit_or(col)
18446744073709551613 18446744073709551613
18446744073709551614 18446744073709551614
18446744073709551615 18446744073709551615
drop table t1;

View file

@ -17,3 +17,21 @@ Note 1003 select high_priority (1 | (1 + 1)) AS `1 | (1+1)`,(5 & 3) AS `5 & 3`,b
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
1 << 32 1 << 63 1 << 64 4 >> 2 4 >> 63 1<< 63 >> 60
4294967296 9223372036854775808 0 1 0 8
select -1 | 0, -1 ^ 0, -1 & 0;
-1 | 0 -1 ^ 0 -1 & 0
18446744073709551615 18446744073709551615 0
select -1 | 1, -1 ^ 1, -1 & 1;
-1 | 1 -1 ^ 1 -1 & 1
18446744073709551615 18446744073709551614 1
select 1 | -1, 1 ^ -1, 1 & -1;
1 | -1 1 ^ -1 1 & -1
18446744073709551615 18446744073709551614 1
select 0 | -1, 0 ^ -1, 0 & -1;
0 | -1 0 ^ -1 0 & -1
18446744073709551615 18446744073709551615 0
select -1 >> 0, -1 << 0;
-1 >> 0 -1 << 0
18446744073709551615 18446744073709551615
select -1 >> 1, -1 << 1;
-1 >> 1 -1 << 1
9223372036854775807 18446744073709551614

View file

@ -144,12 +144,12 @@ montymontymontymontymonty * *
select reverse('abc'),reverse('abcd');
reverse('abc') reverse('abcd')
cba dcba
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12');
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12')
a111 a121 abc
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12');
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12')
111a 121a abc
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12') rpad(11, 10 , 22) rpad("ab", 10, 22)
a111 a121 abc 1122222222 ab22222222
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22);
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12') lpad(11, 10 , 22)
111a 121a abc 2222222211
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
rpad(741653838,17,'0') lpad(741653838,17,'0')
74165383800000000 00000000741653838
@ -159,6 +159,12 @@ abcdaba abaabcd
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
rpad('abcd',1,'ab') lpad('abcd',1,'ab')
a a
select rpad('STRING', 20, CONCAT('p','a','d') );
rpad('STRING', 20, CONCAT('p','a','d') )
STRINGpadpadpadpadpa
select lpad('STRING', 20, CONCAT('p','a','d') );
lpad('STRING', 20, CONCAT('p','a','d') )
padpadpadpadpaSTRING
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
HAROLD HARRY
@ -183,6 +189,9 @@ NULL '\0\Z'
select length(quote(concat(char(0),"test")));
length(quote(concat(char(0),"test")))
8
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
27E0E3E6E7E8EAEB27
select reverse("");
reverse("")

View file

@ -95,11 +95,34 @@ week(19981231,2) week(19981231,3) week(20000101,2) week(20000101,3)
52 53 52 52
select week(20001231,2),week(20001231,3);
week(20001231,2) week(20001231,3)
1 52
53 52
select week(19981231,0) as '0', week(19981231,1) as '1', week(19981231,2) as '2', week(19981231,3) as '3', week(19981231,4) as '4', week(19981231,5) as '5', week(19981231,6) as '6', week(19981231,7) as '7';
0 1 2 3 4 5 6 7
52 53 52 53 52 52 52 52
select week(20000101,0) as '0', week(20000101,1) as '1', week(20000101,2) as '2', week(20000101,3) as '3', week(20000101,4) as '4', week(20000101,5) as '5', week(20000101,6) as '6', week(20000101,7) as '7';
0 1 2 3 4 5 6 7
0 0 52 52 0 0 52 52
select week(20000106,0) as '0', week(20000106,1) as '1', week(20000106,2) as '2', week(20000106,3) as '3', week(20000106,4) as '4', week(20000106,5) as '5', week(20000106,6) as '6', week(20000106,7) as '7';
0 1 2 3 4 5 6 7
1 1 1 1 1 1 1 1
select week(20001231,0) as '0', week(20001231,1) as '1', week(20001231,2) as '2', week(20001231,3) as '3', week(20001231,4) as '4', week(20001231,5) as '5', week(20001231,6) as '6', week(20001231,7) as '7';
0 1 2 3 4 5 6 7
53 52 53 52 53 52 1 52
select week(20010101,0) as '0', week(20010101,1) as '1', week(20010101,2) as '2', week(20010101,3) as '3', week(20010101,4) as '4', week(20010101,5) as '5', week(20010101,6) as '6', week(20010101,7) as '7';
0 1 2 3 4 5 6 7
0 1 53 1 1 1 1 1
select yearweek(20001231,0), yearweek(20001231,1), yearweek(20001231,2), yearweek(20001231,3), yearweek(20001231,4), yearweek(20001231,5), yearweek(20001231,6), yearweek(20001231,7);
yearweek(20001231,0) yearweek(20001231,1) yearweek(20001231,2) yearweek(20001231,3) yearweek(20001231,4) yearweek(20001231,5) yearweek(20001231,6) yearweek(20001231,7)
200053 200052 200053 200052 200101 200052 200101 200052
set default_week_format = 6;
select week(20001231), week(20001231,6);
week(20001231) week(20001231,6)
1 1
set default_week_format = 0;
set default_week_format = 2;
select week(20001231),week(20001231,2),week(20001231,0);
week(20001231) week(20001231,2) week(20001231,0)
1 1 53
53 53 53
set default_week_format = 0;
select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
date_format('1998-12-31','%x-%v') date_format('1999-01-01','%x-%v')
@ -408,6 +431,15 @@ select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
start ctime1 ctime2
2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
drop table t1,t2,t3;
select @a:=FROM_UNIXTIME(1);
@a:=FROM_UNIXTIME(1)
1970-01-01 03:00:01
select unix_timestamp(@a);
unix_timestamp(@a)
1
select unix_timestamp('1969-12-01 19:00:01');
unix_timestamp('1969-12-01 19:00:01')
0
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
SELECT * from t1;

View file

@ -291,7 +291,7 @@ Warnings:
Note 1003 select high_priority big_result test.t1.spID AS `spid`,sum(test.t1.userID) AS `sum(userid)` from test.t1 group by test.t1.spID desc
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 8
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort
select sql_big_result spid,sum(userid) from t1 group by spid desc;
spid sum(userid)
7 3
@ -600,3 +600,32 @@ count(*) category
1 3
1 4
drop table t1;
CREATE TABLE t1 (
userid int(10) unsigned,
score smallint(5) unsigned,
key (score)
);
INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3);
SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
userid count(*)
3 5
2 1
1 2
EXPLAIN SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (
i int(11) default NULL,
j int(11) default NULL
);
INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5);
SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
i COUNT(DISTINCT(i))
1 1
2 1
4 4
explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
DROP TABLE t1;

View file

@ -1,2 +0,0 @@
Variable_name Value
timezone MEST

View file

@ -0,0 +1,2 @@
FROM_UNIXTIME(24*3600)
1970-01-02 01:00:00

View file

@ -1312,17 +1312,41 @@ a b
111 100
111 100
drop table t1;
create table t1 ( c char(8) not null ) engine=innodb;
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
alter table t1 add b char(8) not null;
alter table t1 add a char(8) not null;
alter table t1 add primary key (a,b,c);
update t1 set a=c, b=c;
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
insert into t2 select * from t1;
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
drop table t1,t2;
SET AUTOCOMMIT=1;
create table t1 (a integer auto_increment primary key) engine=innodb;
insert into t1 (a) values (NULL),(NULL);
truncate table t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
a
3
4
drop table t1;
CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
(stamp))ENGINE=InnoDB;
insert into t1 values (1),(2),(3);
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 );
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
Warnings:
Warning 1264 Data truncated for column 'stamp' at row 3
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
'20020204120000' GROUP BY col1;
col1
1
2
3
4
drop table t1,t2;
CREATE TABLE t1 (
`id` int(10) unsigned NOT NULL auto_increment,

View file

@ -73,7 +73,7 @@ drop table t1;
create table t1 (email varchar(50));
insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com');
create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2));
insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
insert delayed into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
select * from t2;
id t2
1 mysql.com

View file

@ -665,3 +665,20 @@ left outer join t2 using (f2)
left outer join t3 using (f3);
ERROR 42S22: Unknown column 'test.t2.f3' in 'on clause'
drop table t1,t2,t3;
create table t1 (a1 int, a2 int);
create table t2 (b1 int not null, b2 int);
create table t3 (c1 int, c2 int);
insert into t1 values (1,2), (2,2), (3,2);
insert into t2 values (1,3), (2,3);
insert into t3 values (2,4), (3,4);
select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
a1 a2 b1 b2 c1 c2
1 2 1 3 NULL NULL
2 2 2 3 NULL NULL
3 2 NULL NULL 3 4
explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
drop table t1, t2, t3;

View file

@ -40,8 +40,8 @@ SELECT @@medium.key_buffer_size;
SET @@global.key_buffer_size=@save_key_buffer;
SELECT @@default.key_buffer_size;
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 'default.key_buffer_size' at line 1
SELECT @@skr.table_type="test";
ERROR HY000: Variable 'table_type' is not a variable component (Can't be used as XXXX.variable_name)
SELECT @@skr.storage_engine="test";
ERROR HY000: Variable 'storage_engine' is not a variable component (Can't be used as XXXX.variable_name)
select @@keycache1.key_cache_block_size;
@@keycache1.key_cache_block_size
0

View file

@ -36,9 +36,7 @@ a b
3 4
drop table t1;
create table t1 (i int);
insert into t1 (i) values(1);
insert into t1 (i) values(1);
insert into t1 (i) values(1);
insert into t1 (i) values(1),(1),(1);
delete from t1 limit 1;
update t1 set i=2 limit 1;
delete from t1 limit 0;
@ -50,3 +48,22 @@ i
drop table t1;
select 0 limit 0;
0
CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2));
INSERT INTO t1 (id2) values (0),(0),(0);
DELETE FROM t1 WHERE id=1;
INSERT INTO t1 SET id2=0;
SELECT * FROM t1;
id id2
4 0
2 0
3 0
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1;
SELECT * FROM t1;
id id2
4 0
3 0
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
SELECT * FROM t1;
id id2
3 0
DROP TABLE t1;

View file

@ -31,7 +31,7 @@ drop table t1;
create table t1 (a text, b text);
load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
Warnings:
Warning 1260 Record count is fewer than the column count at row 3
Warning 1260 Row 3 doesn't contain data for all columns
select concat('|',a,'|'), concat('|',b,'|') from t1;
concat('|',a,'|') concat('|',b,'|')
|Field A| |Field B|
@ -40,3 +40,29 @@ Field 3,'Field 4|
|Field 5' ,'Field 6| NULL
|Field 6| | 'Field 7'|
drop table t1;
create table t1 (a int, b char(10));
load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
Warnings:
Warning 1264 Data truncated for column 'a' at row 3
Warning 1261 Row 3 was truncated; It contained more data than there where input columns
Warning 1264 Data truncated for column 'a' at row 5
Warning 1261 Row 5 was truncated; It contained more data than there where input columns
select * from t1;
a b
1 row 1
2 row 2
0 1234567890
3 row 3
0 1234567890
truncate table t1;
load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines;
Warnings:
Warning 1264 Data truncated for column 'a' at row 4
Warning 1260 Row 4 doesn't contain data for all columns
select * from t1;
a b
1 row 1
2 row 2
3 row 3
0
drop table t1;

View file

@ -1,6 +1,8 @@
drop table if exists t1,t2,t3;
drop table if exists t1,t2,t3,t4,T1;
create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
create table t4 (id int primary key, Word varchar(40) not null);
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
INSERT INTO T4 VALUES(1,'match');
SELECT * FROM t1;
id Word
1 a
@ -12,6 +14,9 @@ id
SELECT T2.id from t1 as T2 LIMIT 1;
id
1
SELECT * from t1 left join t4 on (test.t1.id= TEST.t4.id) where TEST.t1.id >= test.t4.id;
id Word id Word
1 a 1 match
SELECT T2.id from t1 as t2 LIMIT 1;
id
1
@ -21,7 +26,8 @@ ALTER TABLE T2 RENAME T3;
show tables like 't_';
Tables_in_test (t_)
t3
drop table t3;
t4
drop table t3,t4;
create table t1 (a int);
select count(*) from T1;
count(*)

View file

@ -341,6 +341,38 @@ select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and
a b a b
2 2 NULL NULL
drop table t1,t2;
create table t1 (a int not null auto_increment primary key, b int not null);
insert into t1 (b) values (1),(2),(3),(4);
update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a;
select * from t1;
a b
1 2
2 3
3 4
4 5
drop table t1;
create table t1(id1 smallint(5), field char(5));
create table t2(id2 smallint(5), field char(5));
insert into t1 values (1, 'a'), (2, 'aa');
insert into t2 values (1, 'b'), (2, 'bb');
select * from t1;
id1 field
1 a
2 aa
select * from t2;
id2 field
1 b
2 bb
update t2 inner join t1 on t1.id1=t2.id2
set t2.field=t1.field
where 0=1;
update t2, t1 set t2.field=t1.field
where t1.id1=t2.id2 and 0=1;
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2
where 0=1;
delete t1, t2 from t2,t1
where t1.id1=t2.id2 and 0=1;
drop table t1,t2;
create table t1 ( a int not null, b int not null) ;
alter table t1 add index i1(a);
delete from t1 where a > 2000000;
@ -364,8 +396,8 @@ select 't1 rows after big delete', count(*) from t1;
t1 rows after big delete count(*)
t1 rows after big delete 1900001
drop table t1,t2;
set @ttype_save=@@table_type;
set @@table_type=innodb;
set @ttype_save=@@storage_engine;
set @@storage_engine=innodb;
create table t1 ( c char(8) not null );
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
@ -377,7 +409,7 @@ create table t2 like t1;
insert into t2 select * from t1;
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
drop table t1,t2;
set @@table_type=bdb;
set @@storage_engine=bdb;
create table t1 ( c char(8) not null );
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
@ -388,5 +420,5 @@ update t1 set a=c, b=c;
create table t2 like t1;
insert into t2 select * from t1;
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
set @@table_type=@ttype_save;
set @@storage_engine=@ttype_save;
drop table t1,t2;

View file

@ -17,6 +17,47 @@ INSERT INTO t1 VALUES (1), (2);
</table_data>
</database>
</mysqldump>
DROP TABLE t1;
CREATE TABLE t1 (a decimal(240, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a decimal(240,20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE t1 DISABLE KEYS */;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890.00000000000000000000"),("0987654321098765432109876543210987654321.00000000000000000000");
UNLOCK TABLES;
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES (-9e999999);
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE t1 DISABLE KEYS */;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES (RES);
UNLOCK TABLES;
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
DROP TABLE t1;
CREATE TABLE t1(a int, b text, c varchar(3));
INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
@ -64,30 +105,11 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5');
-- MySQL dump 10.3
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.0.0-alpha-debug-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
--
-- Table structure for table `t1`
--
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=koi8r;
--
-- Dumping data for table `t1`
--
/*!40000 ALTER TABLE t1 DISABLE KEYS */;
LOCK TABLES t1 WRITE;

View file

@ -370,16 +370,23 @@ insert into mysqltest.t1 (a) values (1);
select * from mysqltest.t1 where i is null;
i a
1 1
create table t1(a int);
select * from t1;
a
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
select * from mysqltest.t1;
i a
1 1
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
Qcache_queries_in_cache 2
drop database mysqltest;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
Qcache_queries_in_cache 1
drop table t1;
create table t1 (a char(1) not null collate koi8r_general_ci);
insert into t1 values(_koi8r"á");
set CHARACTER SET koi8r;

View file

@ -0,0 +1,16 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a int) engine=myisam;
flush tables;
drop table t1;
create table t1 (a int, unique(a)) engine=myisam;
set sql_log_bin=0;
insert into t1 values(2);
set sql_log_bin=1;
insert into t1 values(1),(2);
ERROR 23000: Duplicate entry '2' for key 1
drop table t1;

View file

@ -0,0 +1,26 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (
a int unsigned not null auto_increment primary key,
b int unsigned,
) ENGINE=MyISAM;
CREATE TABLE t2 (
a int unsigned not null auto_increment primary key,
b int unsigned
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (NULL, 0);
INSERT INTO t1 SELECT NULL, 0 FROM t1;
INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
SELECT * FROM t1 ORDER BY a;
a b
1 0
2 0
SELECT * FROM t2 ORDER BY a;
a b
1 0
2 1
UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a;

View file

@ -1,11 +1,11 @@
drop table if exists t1, t2, t3, t4;
drop table if exists t1, t2, t3, t4;
start slave;
ERROR HY000: Could not initialize master info structure, check permisions on master.info
ERROR HY000: Could not initialize master info structure, more error messages can be found in the MySQL error log
start slave;
ERROR HY000: Could not initialize master info structure, check permisions on master.info
ERROR HY000: Could not initialize master info structure, more error messages can be found in the MySQL error log
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
ERROR HY000: Could not initialize master info structure, check permisions on master.info
ERROR HY000: Could not initialize master info structure, more error messages can be found in the MySQL error log
reset slave;
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
reset master;
@ -68,6 +68,9 @@ m
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");
create table t3 (n int);
select count(*) from t3 where n >= 4;
count(*)
100
create table t4 select * from temp_table;
show binary logs;
Log_name

View file

@ -189,3 +189,22 @@ SELECT FOUND_ROWS();
FOUND_ROWS()
3
drop table t1;
create table t1 (id int, primary key (id));
insert into t1 values (1), (2), (3), (4), (5);
select SQL_CALC_FOUND_ROWS * from t1 where id > 3 limit 0, 1;
id
4
select FOUND_ROWS();
FOUND_ROWS()
2
select SQL_CALC_FOUND_ROWS * from t1 where id > 3 AND 1=2 limit 0, 1;
id
select FOUND_ROWS();
FOUND_ROWS()
0
select SQL_CALC_FOUND_ROWS * from t1 where id > 6 limit 0, 1;
id
select FOUND_ROWS();
FOUND_ROWS()
0
drop table t1;

View file

@ -0,0 +1,203 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
gender CHAR(1),
name VARCHAR(20)
);
SELECT SUM(DISTINCT LENGTH(name)) s1 FROM t1;
s1
NULL
INSERT INTO t1 (gender, name) VALUES (NULL, NULL);
INSERT INTO t1 (gender, name) VALUES (NULL, NULL);
INSERT INTO t1 (gender, name) VALUES (NULL, NULL);
SELECT SUM(DISTINCT LENGTH(name)) s1 FROM t1;
s1
NULL
INSERT INTO t1 (gender, name) VALUES ('F', 'Helen'), ('F', 'Anastasia'),
('F', 'Katherine'), ('F', 'Margo'), ('F', 'Magdalene'), ('F', 'Mary');
CREATE TABLE t2 SELECT name FROM t1;
SELECT (SELECT SUM(DISTINCT LENGTH(name)) FROM t1) FROM t2;
(SELECT SUM(DISTINCT LENGTH(name)) FROM t1)
18
18
18
18
18
18
18
18
18
DROP TABLE t2;
INSERT INTO t1 (gender, name) VALUES ('F', 'Eva'), ('F', 'Sofia'),
('F', 'Sara'), ('F', 'Golda'), ('F', 'Toba'), ('F', 'Victory'),
('F', 'Faina'), ('F', 'Miriam'), ('F', 'Beki'), ('F', 'America'),
('F', 'Susan'), ('F', 'Glory'), ('F', 'Priscilla'), ('F', 'Rosmary'),
('F', 'Rose'), ('F', 'Margareth'), ('F', 'Elizabeth'), ('F', 'Meredith'),
('F', 'Julie'), ('F', 'Xenia'), ('F', 'Zena'), ('F', 'Olga'),
('F', 'Brunhilda'), ('F', 'Nataly'), ('F', 'Lara'), ('F', 'Svetlana'),
('F', 'Grethem'), ('F', 'Irene');
SELECT
SUM(DISTINCT LENGTH(name)) s1,
SUM(DISTINCT SUBSTRING(NAME, 1, 3)) s2,
SUM(DISTINCT LENGTH(SUBSTRING(name, 1, 4))) s3
FROM t1;
s1 s2 s3
42 0 7
SELECT
SUM(DISTINCT LENGTH(g1.name)) s1,
SUM(DISTINCT SUBSTRING(g2.name, 1, 3)) s2,
SUM(DISTINCT LENGTH(SUBSTRING(g3.name, 1, 4))) s3
FROM t1 g1, t1 g2, t1 g3;
s1 s2 s3
42 0 7
SELECT
SUM(DISTINCT LENGTH(g1.name)) s1,
SUM(DISTINCT SUBSTRING(g2.name, 1, 3)) s2,
SUM(DISTINCT LENGTH(SUBSTRING(g3.name, 1, 4))) s3
FROM t1 g1, t1 g2, t1 g3 GROUP BY LENGTH(SUBSTRING(g3.name, 5, 10));
s1 s2 s3
42 0 NULL
42 0 7
42 0 4
42 0 4
42 0 4
42 0 4
42 0 4
SELECT SQL_BUFFER_RESULT
SUM(DISTINCT LENGTH(name)) s1,
SUM(DISTINCT SUBSTRING(NAME, 1, 3)) s2,
SUM(DISTINCT LENGTH(SUBSTRING(name, 1, 4))) s3
FROM t1;
s1 s2 s3
42 0 7
SELECT SQL_BUFFER_RESULT
SUM(DISTINCT LENGTH(g1.name)) s1,
SUM(DISTINCT SUBSTRING(g2.name, 1, 3)) s2,
SUM(DISTINCT LENGTH(SUBSTRING(g3.name, 1, 4))) s3
FROM t1 g1, t1 g2, t1 g3 GROUP BY LENGTH(SUBSTRING(g3.name, 5, 10));
s1 s2 s3
42 0 NULL
42 0 7
42 0 4
42 0 4
42 0 4
42 0 4
42 0 4
SET @l=1;
UPDATE t1 SET name=CONCAT(name, @l:=@l+1);
SELECT SUM(DISTINCT RIGHT(name, 1)) FROM t1;
SUM(DISTINCT RIGHT(name, 1))
45
SELECT SUM(DISTINCT id) FROM t1;
SUM(DISTINCT id)
703
SELECT SUM(DISTINCT id % 11) FROM t1;
SUM(DISTINCT id % 11)
55
DROP TABLE t1;
CREATE TABLE t1 (id INTEGER);
CREATE TABLE t2 (id INTEGER);
INSERT INTO t1 (id) VALUES (1), (1), (1),(1);
INSERT INTO t2 (id) SELECT id FROM t1;
INSERT INTO t1 (id) SELECT id FROM t2;
/* 8 */
INSERT INTO t1 (id) SELECT id FROM t2;
/* 12 */
INSERT INTO t1 (id) SELECT id FROM t2;
/* 16 */
INSERT INTO t1 (id) SELECT id FROM t2;
/* 20 */
INSERT INTO t1 (id) SELECT id FROM t2;
/* 24 */
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+1 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+2 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+4 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+8 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+16 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+32 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+64 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+128 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+256 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+512 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+1024 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+2048 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+4096 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 (id) SELECT id+8192 FROM t1;
INSERT INTO t1 SELECT id FROM t2;
DELETE FROM t2;
INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand();
SELECT SUM(DISTINCT id) sm FROM t1;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t2;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t1 group by id % 13;
sm
10327590
10328851
10330112
10331373
10332634
10317510
10318770
10320030
10321290
10322550
10323810
10325070
10326330
SET max_heap_table_size=16384;
SHOW variables LIKE 'max_heap_table_size';
Variable_name Value
max_heap_table_size 16384
SELECT SUM(DISTINCT id) sm FROM t1;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t2;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t1 GROUP BY id % 13;
sm
10327590
10328851
10330112
10331373
10332634
10317510
10318770
10320030
10321290
10322550
10323810
10325070
10326330
DROP TABLE t1;
DROP TABLE t2;

View file

@ -64,3 +64,25 @@ t9 CREATE TABLE `t9` (
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
drop database mysqltest;
create table t1 (a int not null) type=myisam;
Warnings:
Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 add b int;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;

View file

@ -1,4 +1,13 @@
DROP TABLE IF EXISTS t1;
show variables like "timezone";
Variable_name Value
timezone MET
select @a:=FROM_UNIXTIME(1);
@a:=FROM_UNIXTIME(1)
1970-01-01 01:00:01
select unix_timestamp(@a);
unix_timestamp(@a)
1
CREATE TABLE t1 (ts int);
INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00'));
INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 02:00'));

View file

@ -23,3 +23,12 @@ n
drop table t1;
truncate non_existing_table;
ERROR 42S02: Table 'test.non_existing_table' doesn't exist
create table t1 (a integer auto_increment primary key);
insert into t1 (a) values (NULL),(NULL);
truncate table t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
a
1
2
drop table t1;

View file

@ -510,3 +510,149 @@ show full fields from t1;
Field Type Collation Null Key Default Extra Privileges Comment
load_file('../../std_data/words.dat') longblob NULL YES NULL select,insert,update,references
drop table t1;
create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20)));
insert into t1 (txt) values ('Chevy'), ('Chevy ');
select * from t1 where txt='Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy ' or txt='Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where id='1' or id='2';
id txt
1 Chevy
2 Chevy
insert into t1 (txt) values('Ford');
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
id txt
1 Chevy
2 Chevy
3 Ford
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt in ('Chevy ','Chevy');
id txt
1 Chevy
2 Chevy
select * from t1 where txt in ('Chevy');
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt < 'Chevy ';
id txt
select * from t1 where txt <= 'Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt > 'Chevy';
id txt
3 Ford
select * from t1 where txt >= 'Chevy';
id txt
1 Chevy
2 Chevy
3 Ford
drop table t1;
create table t1 (id integer primary key auto_increment, txt text, unique index txt_index (txt (20)));
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
select * from t1 where txt='Chevy' or txt is NULL;
id txt
1 Chevy
2 Chevy
3 NULL
select * from t1 where txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy ' or txt='Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where id='1' or id='2';
id txt
1 Chevy
2 Chevy
insert into t1 (txt) values('Ford');
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
id txt
1 Chevy
2 Chevy
4 Ford
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt in ('Chevy ','Chevy');
id txt
1 Chevy
2 Chevy
select * from t1 where txt in ('Chevy');
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt < 'Chevy ';
id txt
select * from t1 where txt < 'Chevy ' or txt is NULL;
id txt
3 NULL
select * from t1 where txt <= 'Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt > 'Chevy';
id txt
4 Ford
select * from t1 where txt >= 'Chevy';
id txt
1 Chevy
2 Chevy
4 Ford
drop table t1;

View file

@ -1,6 +1,12 @@
drop table if exists t1;
create table t1 (t datetime);
insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959);
insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030102030460),(20030102036301),(20030102240401),(20030132030401),(20031302030460);
Warnings:
Warning 1264 Data truncated for column 't' at row 13
Warning 1264 Data truncated for column 't' at row 14
Warning 1264 Data truncated for column 't' at row 15
Warning 1264 Data truncated for column 't' at row 16
Warning 1264 Data truncated for column 't' at row 17
select * from t1;
t
2000-01-01 00:00:00
@ -15,6 +21,11 @@ t
1999-12-31 23:59:59
1000-01-01 00:00:00
9999-12-31 23:59:59
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
delete from t1 where t > 0;
optimize table t1;
Table Op Msg_type Msg_text
@ -22,7 +33,8 @@ test.t1 optimize status OK
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959");
delete from t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030102030460"),("20030102036301"),("20030102240401"),("20030132030401"),("20031302030460");
select * from t1;
t
2000-01-01 00:00:00
@ -38,6 +50,11 @@ t
1999-12-31 23:59:59
1000-01-01 00:00:00
9999-12-31 23:59:59
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
drop table t1;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());

View file

@ -444,3 +444,321 @@ CREATE TABLE t1 (a_dec DECIMAL(-2,1));
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 '-2,1))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
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 '-1,1))' at line 1
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
Warnings:
Warning 1263 Data truncated, out of range for column 'a' at row 27
Warning 1263 Data truncated, out of range for column 'a' at row 30
Warning 1263 Data truncated, out of range for column 'a' at row 31
Warning 1263 Data truncated, out of range for column 'a' at row 32
Warning 1263 Data truncated, out of range for column 'a' at row 33
Warning 1263 Data truncated, out of range for column 'a' at row 34
Warning 1263 Data truncated, out of range for column 'a' at row 35
Warning 1263 Data truncated, out of range for column 'a' at row 36
Warning 1263 Data truncated, out of range for column 'a' at row 37
Warning 1263 Data truncated, out of range for column 'a' at row 38
Warning 1263 Data truncated, out of range for column 'a' at row 39
Warning 1263 Data truncated, out of range for column 'a' at row 40
Warning 1263 Data truncated, out of range for column 'a' at row 41
Warning 1263 Data truncated, out of range for column 'a' at row 42
Warning 1263 Data truncated, out of range for column 'a' at row 43
Warning 1263 Data truncated, out of range for column 'a' at row 44
Warning 1263 Data truncated, out of range for column 'a' at row 45
Warning 1263 Data truncated, out of range for column 'a' at row 46
Warning 1263 Data truncated, out of range for column 'a' at row 47
Warning 1263 Data truncated, out of range for column 'a' at row 48
Warning 1263 Data truncated, out of range for column 'a' at row 49
Warning 1263 Data truncated, out of range for column 'a' at row 50
Warning 1263 Data truncated, out of range for column 'a' at row 51
Warning 1263 Data truncated, out of range for column 'a' at row 52
Warning 1263 Data truncated, out of range for column 'a' at row 53
Warning 1263 Data truncated, out of range for column 'a' at row 54
Warning 1263 Data truncated, out of range for column 'a' at row 55
Warning 1263 Data truncated, out of range for column 'a' at row 56
Warning 1263 Data truncated, out of range for column 'a' at row 57
Warning 1263 Data truncated, out of range for column 'a' at row 58
Warning 1263 Data truncated, out of range for column 'a' at row 59
Warning 1263 Data truncated, out of range for column 'a' at row 60
select * from t1;
a
1.000
+1.000
-1.000
00001.000
+0001.000
-0001.000
10.000
+10.000
-10.000
00010.000
+0010.000
-0010.000
100.000
+100.000
-100.000
00100.000
+0100.000
-0100.000
1000.000
+1000.000
-1000.000
01000.000
+1000.000
-1000.000
10000.000
10000.000
-9999.999
10000.000
10000.000
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
99999.999
99999.999
-9999.999
drop table t1;
create table t1(a decimal(7,3) unsigned);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
Warnings:
Warning 1263 Data truncated, out of range for column 'a' at row 3
Warning 1263 Data truncated, out of range for column 'a' at row 6
Warning 1263 Data truncated, out of range for column 'a' at row 9
Warning 1263 Data truncated, out of range for column 'a' at row 12
Warning 1263 Data truncated, out of range for column 'a' at row 15
Warning 1263 Data truncated, out of range for column 'a' at row 18
Warning 1263 Data truncated, out of range for column 'a' at row 21
Warning 1263 Data truncated, out of range for column 'a' at row 24
Warning 1263 Data truncated, out of range for column 'a' at row 25
Warning 1263 Data truncated, out of range for column 'a' at row 26
Warning 1263 Data truncated, out of range for column 'a' at row 27
Warning 1263 Data truncated, out of range for column 'a' at row 28
Warning 1263 Data truncated, out of range for column 'a' at row 29
Warning 1263 Data truncated, out of range for column 'a' at row 30
Warning 1263 Data truncated, out of range for column 'a' at row 31
Warning 1263 Data truncated, out of range for column 'a' at row 32
Warning 1263 Data truncated, out of range for column 'a' at row 33
Warning 1263 Data truncated, out of range for column 'a' at row 34
Warning 1263 Data truncated, out of range for column 'a' at row 35
Warning 1263 Data truncated, out of range for column 'a' at row 36
Warning 1263 Data truncated, out of range for column 'a' at row 37
Warning 1263 Data truncated, out of range for column 'a' at row 38
Warning 1263 Data truncated, out of range for column 'a' at row 39
Warning 1263 Data truncated, out of range for column 'a' at row 40
Warning 1263 Data truncated, out of range for column 'a' at row 41
Warning 1263 Data truncated, out of range for column 'a' at row 42
Warning 1263 Data truncated, out of range for column 'a' at row 43
Warning 1263 Data truncated, out of range for column 'a' at row 44
Warning 1263 Data truncated, out of range for column 'a' at row 45
Warning 1263 Data truncated, out of range for column 'a' at row 46
Warning 1263 Data truncated, out of range for column 'a' at row 47
Warning 1263 Data truncated, out of range for column 'a' at row 48
Warning 1263 Data truncated, out of range for column 'a' at row 49
Warning 1263 Data truncated, out of range for column 'a' at row 50
Warning 1263 Data truncated, out of range for column 'a' at row 51
Warning 1263 Data truncated, out of range for column 'a' at row 52
Warning 1263 Data truncated, out of range for column 'a' at row 53
Warning 1263 Data truncated, out of range for column 'a' at row 54
Warning 1263 Data truncated, out of range for column 'a' at row 55
Warning 1263 Data truncated, out of range for column 'a' at row 56
Warning 1263 Data truncated, out of range for column 'a' at row 57
Warning 1263 Data truncated, out of range for column 'a' at row 58
Warning 1263 Data truncated, out of range for column 'a' at row 59
Warning 1263 Data truncated, out of range for column 'a' at row 60
select * from t1;
a
1.000
+1.000
0.000
0001.000
+001.000
0.000
10.000
+10.000
0.000
0010.000
+010.000
0.000
100.000
+100.000
0.000
0100.000
+100.000
0.000
1000.000
1000.000
0.000
1000.000
1000.000
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
drop table t1;
create table t1(a decimal(7,3) zerofill);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
Warnings:
Warning 1263 Data truncated, out of range for column 'a' at row 3
Warning 1263 Data truncated, out of range for column 'a' at row 6
Warning 1263 Data truncated, out of range for column 'a' at row 9
Warning 1263 Data truncated, out of range for column 'a' at row 12
Warning 1263 Data truncated, out of range for column 'a' at row 15
Warning 1263 Data truncated, out of range for column 'a' at row 18
Warning 1263 Data truncated, out of range for column 'a' at row 21
Warning 1263 Data truncated, out of range for column 'a' at row 24
Warning 1263 Data truncated, out of range for column 'a' at row 25
Warning 1263 Data truncated, out of range for column 'a' at row 26
Warning 1263 Data truncated, out of range for column 'a' at row 27
Warning 1263 Data truncated, out of range for column 'a' at row 28
Warning 1263 Data truncated, out of range for column 'a' at row 29
Warning 1263 Data truncated, out of range for column 'a' at row 30
Warning 1263 Data truncated, out of range for column 'a' at row 31
Warning 1263 Data truncated, out of range for column 'a' at row 32
Warning 1263 Data truncated, out of range for column 'a' at row 33
Warning 1263 Data truncated, out of range for column 'a' at row 34
Warning 1263 Data truncated, out of range for column 'a' at row 35
Warning 1263 Data truncated, out of range for column 'a' at row 36
Warning 1263 Data truncated, out of range for column 'a' at row 37
Warning 1263 Data truncated, out of range for column 'a' at row 38
Warning 1263 Data truncated, out of range for column 'a' at row 39
Warning 1263 Data truncated, out of range for column 'a' at row 40
Warning 1263 Data truncated, out of range for column 'a' at row 41
Warning 1263 Data truncated, out of range for column 'a' at row 42
Warning 1263 Data truncated, out of range for column 'a' at row 43
Warning 1263 Data truncated, out of range for column 'a' at row 44
Warning 1263 Data truncated, out of range for column 'a' at row 45
Warning 1263 Data truncated, out of range for column 'a' at row 46
Warning 1263 Data truncated, out of range for column 'a' at row 47
Warning 1263 Data truncated, out of range for column 'a' at row 48
Warning 1263 Data truncated, out of range for column 'a' at row 49
Warning 1263 Data truncated, out of range for column 'a' at row 50
Warning 1263 Data truncated, out of range for column 'a' at row 51
Warning 1263 Data truncated, out of range for column 'a' at row 52
Warning 1263 Data truncated, out of range for column 'a' at row 53
Warning 1263 Data truncated, out of range for column 'a' at row 54
Warning 1263 Data truncated, out of range for column 'a' at row 55
Warning 1263 Data truncated, out of range for column 'a' at row 56
Warning 1263 Data truncated, out of range for column 'a' at row 57
Warning 1263 Data truncated, out of range for column 'a' at row 58
Warning 1263 Data truncated, out of range for column 'a' at row 59
Warning 1263 Data truncated, out of range for column 'a' at row 60
select * from t1;
a
0001.000
0001.000
0000.000
0001.000
0001.000
0000.000
0010.000
0010.000
0000.000
0010.000
0010.000
0000.000
0100.000
0100.000
0000.000
0100.000
0100.000
0000.000
1000.000
1000.000
0000.000
1000.000
1000.000
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
drop table t1;

View file

@ -1635,6 +1635,20 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('','a','b') NOT NULL default 'b'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a enum ('0','1'));
insert into t1 set a='foobar';
Warnings:
Warning 1264 Data truncated for column 'a' at row 1
select * from t1;
a
update t1 set a = replace(a,'x','y');
Warnings:
Warning 1264 Data truncated for column 'a' at row 1
select * from t1;
a
drop table t1;
set names latin1;
create table t1 (a enum(0xE4, '1', '2') not null default 0xE4);

View file

@ -43,7 +43,13 @@ date_format(a,"%Y %y") year(a) year(now())
1970 70 1970 1970
drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101);
Warnings:
Warning 1264 Data truncated for column 'ix' at row 10
Warning 1264 Data truncated for column 'ix' at row 11
Warning 1264 Data truncated for column 'ix' at row 12
Warning 1264 Data truncated for column 'ix' at row 13
Warning 1264 Data truncated for column 'ix' at row 14
select ix+0 from t1;
ix+0
19991101000000
@ -55,6 +61,24 @@ ix+0
19990501000000
19991101000000
19990501000000
0
0
0
0
0
delete from t1;
insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101");
select ix+0 from t1;
ix+0
19991101000000
19990102030405
19990630232922
19990601000000
0
0
0
0
0
drop table t1;
CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959);
@ -104,3 +128,5 @@ t2 t4 t6 t8 t10 t12 t14
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
drop table t1;
create table t1 (a timestamp default 1);
ERROR 42000: Invalid default value for 'a'

View file

@ -3,7 +3,7 @@ CREATE TABLE t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
CREATE TABLE t2 (a int not null, b char (10) not null);
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
select a,b from t1 union select a,b from t2;
select a,b from t1 union distinct select a,b from t2;
a b
1 a
2 b
@ -434,7 +434,15 @@ a
3
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
ERROR 42000: Wrong usage/placement of 'SQL_CALC_FOUND_ROWS'
create temporary table t1 select a from t1 union select a from t2;
drop temporary table t1;
create table t1 select a from t1 union select a from t2;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
drop table t1,t2;
select length(version()) > 1 as `*` UNION select 2;
*
1
2
CREATE TABLE t1 ( id int(3) unsigned default '0') ENGINE=MyISAM;
INSERT INTO t1 (id) VALUES("1");
CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) ENGINE=MyISAM;

View file

@ -137,13 +137,13 @@ set global concurrent_insert=DEFAULT;
show variables like 'concurrent_insert';
Variable_name Value
concurrent_insert ON
set table_type=MYISAM, table_type="HEAP", global table_type="INNODB";
show local variables like 'table_type';
set storage_engine=MYISAM, storage_engine="HEAP", global storage_engine="INNODB";
show local variables like 'storage_engine';
Variable_name Value
table_type HEAP
show global variables like 'table_type';
storage_engine HEAP
show global variables like 'storage_engine';
Variable_name Value
table_type InnoDB
storage_engine InnoDB
set GLOBAL query_cache_size=100000;
set GLOBAL myisam_max_sort_file_size=2000000;
show global variables like 'myisam_max_sort_file_size';
@ -240,17 +240,17 @@ set unknown_variable=1;
ERROR HY000: Unknown system variable 'unknown_variable'
set max_join_size="hello";
ERROR 42000: Wrong argument type to variable 'max_join_size'
set table_type=UNKNOWN_TABLE_TYPE;
set storage_engine=UNKNOWN_TABLE_TYPE;
ERROR 42000: Unknown table engine 'UNKNOWN_TABLE_TYPE'
set table_type=INNODB, big_tables=2;
set storage_engine=INNODB, big_tables=2;
ERROR 42000: Variable 'big_tables' can't be set to the value of '2'
show local variables like 'table_type';
show local variables like 'storage_engine';
Variable_name Value
table_type HEAP
storage_engine HEAP
set SESSION query_cache_size=10000;
ERROR HY000: Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
set GLOBAL table_type=DEFAULT;
ERROR 42000: Variable 'table_type' doesn't have a default value
set GLOBAL storage_engine=DEFAULT;
ERROR 42000: Variable 'storage_engine' doesn't have a default value
set character_set_client=UNKNOWN_CHARACTER_SET;
ERROR 42000: Unknown character set: 'UNKNOWN_CHARACTER_SET'
set collation_connection=UNKNOWN_COLLATION;
@ -372,7 +372,7 @@ set sql_select_limit=1;
set global sql_slave_skip_counter=100;
set sql_warnings=1;
set global table_cache=100;
set table_type=myisam;
set storage_engine=myisam;
set global thread_cache_size=100;
set timestamp=1, timestamp=default;
set tmp_table_size=100;

View file

@ -49,9 +49,9 @@ Warnings:
Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2
Warning 1264 Data truncated for column 'd' at row 3
Warning 1264 Data truncated for column 'c' at row 4
Warning 1260 Record count is fewer than the column count at row 5
Warning 1260 Row 5 doesn't contain data for all columns
Warning 1264 Data truncated for column 'b' at row 6
Warning 1261 Record count is more than the column count at row 7
Warning 1261 Row 7 was truncated; It contained more data than there where input columns
Warning 1263 Data truncated, out of range for column 'a' at row 8
select @@warning_count;
@@warning_count
@ -133,3 +133,6 @@ alter table t1 type=myisam;
Warnings:
Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead.
drop table t1;
set table_type=MYISAM;
Warnings:
Warning 1286 'table_type' is deprecated. Use 'storage_engine' instead.

View file

@ -0,0 +1,6 @@
number row data
1 row 1
2 row 2
error 12345678901234567890123456789012345678901234567890
3 row 3
wrong end 12345678901234567890123456789012345678901234567890

View file

@ -0,0 +1 @@
test row data 1 row 1 2 row 2 3 row 3

View file

@ -73,6 +73,25 @@ select * from t1;
check table t1;
drop table t1;
#
# Test negative values (Bug #1366)
#
create table t1 (a int not null auto_increment primary key);
insert into t1 values (NULL);
insert into t1 values (-1);
select last_insert_id();
insert into t1 values (NULL);
select * from t1;
drop table t1;
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
insert into t1 values (NULL);
insert into t1 values (-1);
select last_insert_id();
insert into t1 values (NULL);
select * from t1;
drop table t1;
#
# last_insert_id() madness
#

View file

@ -789,3 +789,22 @@ select * from t1 where x <= 10 and x >= 7 order by x desc;
select * from t1 where x <= 8 and x >= 5 order by x desc;
select * from t1 where x < 8 and x > 5 order by x desc;
drop table t1;
#
# Test of multi-table-updates (bug #1980).
#
create table t1 ( c char(8) not null ) engine=bdb;
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
alter table t1 add b char(8) not null;
alter table t1 add a char(8) not null;
alter table t1 add primary key (a,b,c);
update t1 set a=c, b=c;
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=bdb;
insert into t2 select * from t1;
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
drop table t1,t2;

View file

@ -152,17 +152,17 @@ drop table if exists t1;
#
# Test default table type
#
SET SESSION table_type="heap";
SELECT @@table_type;
SET SESSION storage_engine="heap";
SELECT @@storage_engine;
CREATE TABLE t1 (a int not null);
show create table t1;
drop table t1;
--error 1285
SET SESSION table_type="gemini";
SELECT @@table_type;
SET SESSION storage_engine="gemini";
SELECT @@storage_engine;
CREATE TABLE t1 (a int not null);
show create table t1;
SET SESSION table_type=default;
SET SESSION storage_engine=default;
drop table t1;
@ -272,17 +272,17 @@ drop database test_$1;
#
# Test default table type
#
SET SESSION table_type="heap";
SELECT @@table_type;
SET SESSION storage_engine="heap";
SELECT @@storage_engine;
CREATE TABLE t1 (a int not null);
show create table t1;
drop table t1;
--error 1285
SET SESSION table_type="gemini";
SELECT @@table_type;
SET SESSION storage_engine="gemini";
SELECT @@storage_engine;
CREATE TABLE t1 (a int not null);
show create table t1;
SET SESSION table_type=default;
SET SESSION storage_engine=default;
drop table t1;
#

View file

@ -0,0 +1,39 @@
#
# Test for various CREATE statements and character sets
#
# Check that the database charset is taken from server charset by default:
# - Change local character_set_server variable to latin5.
# - Create database with and without CHARACTER SET specification.
# At the same time check fix for the
# Bug#2151:
# "USE db" with non-default character set should never affect
# further CREATE DATABASEs.
SET @@character_set_server=latin5;
CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251;
USE db1;
CREATE DATABASE db2;
#
# This should be cp1251
#
SHOW CREATE DATABASE db1;
#
# This should take the default latin5 value from server level.
#
SHOW CREATE DATABASE db2;
DROP DATABASE db2;
#
# Check that table value uses database level by default
#
USE db1;
CREATE TABLE t1 (a char(10));
SHOW CREATE TABLE t1;
DROP TABLE t1;
DROP DATABASE db1;

View file

@ -370,3 +370,11 @@ insert into t1 values (1);
select max(a) as b from t1 having b=1;
select a from t1 having a=1;
drop table t1;
#
# Bug #1972: test for bit_and(), bit_or() and negative values
#
create table t1 (col int);
insert into t1 values (-1), (-2), (-3);
select bit_and(col), bit_or(col) from t1;
select SQL_BIG_RESULT bit_and(col), bit_or(col) from t1 group by col;
drop table t1;

View file

@ -7,3 +7,12 @@ explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
select 1 | (1+1),5 & 3,bit_count(7) ;
explain extended select 1 | (1+1),5 & 3,bit_count(7) ;
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
#
# bug #1993: bit functions must be unsigned
#
select -1 | 0, -1 ^ 0, -1 & 0;
select -1 | 1, -1 ^ 1, -1 & 1;
select 1 | -1, 1 ^ -1, 1 & -1;
select 0 | -1, 0 ^ -1, 0 & -1;
select -1 >> 0, -1 << 0;
select -1 >> 1, -1 << 1;

View file

@ -61,11 +61,13 @@ select aes_decrypt("a","a");
select aes_decrypt(aes_encrypt("","a"),"a");
select repeat('monty',5),concat('*',space(5),'*');
select reverse('abc'),reverse('abcd');
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12');
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12');
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22);
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
select rpad('STRING', 20, CONCAT('p','a','d') );
select lpad('STRING', 20, CONCAT('p','a','d') );
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0");
@ -77,6 +79,7 @@ select quote('\'\"\\test');
select quote(concat('abc\'', '\\cba'));
select quote(1/0), quote('\0\Z');
select length(quote(concat(char(0),"test")));
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
#
# Wrong usage of functions

View file

@ -42,6 +42,18 @@ select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', y
select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
select week(20001231,2),week(20001231,3);
select week(19981231,0) as '0', week(19981231,1) as '1', week(19981231,2) as '2', week(19981231,3) as '3', week(19981231,4) as '4', week(19981231,5) as '5', week(19981231,6) as '6', week(19981231,7) as '7';
select week(20000101,0) as '0', week(20000101,1) as '1', week(20000101,2) as '2', week(20000101,3) as '3', week(20000101,4) as '4', week(20000101,5) as '5', week(20000101,6) as '6', week(20000101,7) as '7';
select week(20000106,0) as '0', week(20000106,1) as '1', week(20000106,2) as '2', week(20000106,3) as '3', week(20000106,4) as '4', week(20000106,5) as '5', week(20000106,6) as '6', week(20000106,7) as '7';
select week(20001231,0) as '0', week(20001231,1) as '1', week(20001231,2) as '2', week(20001231,3) as '3', week(20001231,4) as '4', week(20001231,5) as '5', week(20001231,6) as '6', week(20001231,7) as '7';
select week(20010101,0) as '0', week(20010101,1) as '1', week(20010101,2) as '2', week(20010101,3) as '3', week(20010101,4) as '4', week(20010101,5) as '5', week(20010101,6) as '6', week(20010101,7) as '7';
select yearweek(20001231,0), yearweek(20001231,1), yearweek(20001231,2), yearweek(20001231,3), yearweek(20001231,4), yearweek(20001231,5), yearweek(20001231,6), yearweek(20001231,7);
set default_week_format = 6;
select week(20001231), week(20001231,6);
set default_week_format = 0;
set default_week_format = 2;
select week(20001231),week(20001231,2),week(20001231,0);
set default_week_format = 0;
@ -193,6 +205,13 @@ select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
drop table t1,t2,t3;
#
# Test unix timestamp
#
select @a:=FROM_UNIXTIME(1);
select unix_timestamp(@a);
select unix_timestamp('1969-12-01 19:00:01');
#
# Test types from + INTERVAL
#

View file

@ -432,3 +432,27 @@ select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(q
select count(*), case interval(qty,2,3,4,5,6,7,8) when -1 then NULL when 0 then "zero" when 1 then "one" when 2 then "two" end as category from t1 group by category;
select count(*), interval(qty,2,3,4,5,6,7,8) as category from t1 group by category;
drop table t1;
#
# Tests for bug #1355: 'Using filesort' is missing in EXPLAIN when ORDER BY
# NULL is used.
#
CREATE TABLE t1 (
userid int(10) unsigned,
score smallint(5) unsigned,
key (score)
);
INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3);
# Here we select unordered GROUP BY into a temporary talbe,
# and then sort it with filesort (GROUP BY in MySQL
# implies sorted order of results)
SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
EXPLAIN SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
DROP TABLE t1;
CREATE TABLE t1 (
i int(11) default NULL,
j int(11) default NULL
);
INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5);
SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
DROP TABLE t1;

View file

@ -902,12 +902,47 @@ update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
drop table t1;
#
# Test of multi-table-updates (bug #1980).
#
create table t1 ( c char(8) not null ) engine=innodb;
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
alter table t1 add b char(8) not null;
alter table t1 add a char(8) not null;
alter table t1 add primary key (a,b,c);
update t1 set a=c, b=c;
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
insert into t2 select * from t1;
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
drop table t1,t2;
#
# test autoincrement with TRUNCATE
#
SET AUTOCOMMIT=1;
create table t1 (a integer auto_increment primary key) engine=innodb;
insert into t1 (a) values (NULL),(NULL);
truncate table t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
drop table t1;
#
# Test timestamps
#
CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
(stamp))ENGINE=InnoDB;
insert into t1 values (1),(2),(3);
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 );
# Note that timestamp 3 is wrong
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
'20020204120000' GROUP BY col1;
drop table t1,t2;

View file

@ -71,7 +71,7 @@ drop table t1;
create table t1 (email varchar(50));
insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com');
create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2));
insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
insert delayed into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
select * from t2;
drop table t1,t2;

View file

@ -438,3 +438,16 @@ select * from t1
left outer join t2 using (f2)
left outer join t3 using (f3);
drop table t1,t2,t3;
create table t1 (a1 int, a2 int);
create table t2 (b1 int not null, b2 int);
create table t3 (c1 int, c2 int);
insert into t1 values (1,2), (2,2), (3,2);
insert into t2 values (1,3), (2,3);
insert into t3 values (2,4), (3,4);
select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
drop table t1, t2, t3;

View file

@ -42,7 +42,7 @@ SET @@global.key_buffer_size=@save_key_buffer;
--error 1064
SELECT @@default.key_buffer_size;
--error 1271
SELECT @@skr.table_type="test";
SELECT @@skr.storage_engine="test";
select @@keycache1.key_cache_block_size;
select @@keycache1.key_buffer_size;

View file

@ -22,9 +22,7 @@ select * from t1;
drop table t1;
create table t1 (i int);
insert into t1 (i) values(1);
insert into t1 (i) values(1);
insert into t1 (i) values(1);
insert into t1 (i) values(1),(1),(1);
delete from t1 limit 1;
update t1 set i=2 limit 1;
delete from t1 limit 0;
@ -32,4 +30,22 @@ update t1 set i=3 limit 0;
select * from t1;
drop table t1;
# LIMIT 0
select 0 limit 0;
#
# Test with DELETE, ORDER BY and limit (bug #1024)
#
CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2));
INSERT INTO t1 (id2) values (0),(0),(0);
DELETE FROM t1 WHERE id=1;
INSERT INTO t1 SET id2=0;
SELECT * FROM t1;
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1;
# should have deleted WHERE id=2
SELECT * FROM t1;
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
SELECT * FROM t1;
DROP TABLE t1;

Some files were not shown because too many files have changed in this diff Show more