mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
mysql-test-run.sh:
Added timing output for each test case. Added --embedded-server option. mysqltest.c: Added 'start_timer', 'end_timer' commands Makefile.am: Include mysys/my_getsystime.c to get time function in mysqltest Many files: new file
This commit is contained in:
@ -34,7 +34,7 @@ mysqlcheck_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
|
||||
mysqlshow_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
|
||||
mysqldump_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
|
||||
mysqlimport_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
|
||||
mysqltest_SOURCES= mysqltest.c
|
||||
mysqltest_SOURCES= mysqltest.c ../mysys/my_getsystime.c
|
||||
mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
|
||||
mysqlbinlog_SOURCES = mysqlbinlog.cc ../mysys/mf_tempdir.c
|
||||
mysqlbinlog_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) $(DEPLIB)
|
||||
|
@ -58,6 +58,13 @@
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <violite.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 256
|
||||
#endif
|
||||
|
||||
#define MAX_QUERY 131072
|
||||
#define MAX_VAR_NAME 256
|
||||
@ -75,7 +82,7 @@
|
||||
#ifndef MYSQL_MANAGER_PORT
|
||||
#define MYSQL_MANAGER_PORT 23546
|
||||
#endif
|
||||
#define MAX_SERVER_ARGS 20
|
||||
#define MAX_SERVER_ARGS 64
|
||||
|
||||
/*
|
||||
Sometimes in a test the client starts before
|
||||
@ -132,6 +139,13 @@ static char *embedded_server_args[MAX_SERVER_ARGS];
|
||||
|
||||
static my_bool display_result_vertically= FALSE, display_metadata= FALSE;
|
||||
|
||||
/* See the timer_output() definition for details */
|
||||
static char *timer_file = NULL;
|
||||
static ulonglong timer_start;
|
||||
static int got_end_timer= FALSE;
|
||||
static void timer_output(void);
|
||||
static ulonglong timer_now(void);
|
||||
|
||||
static const char *embedded_server_groups[] = {
|
||||
"server",
|
||||
"embedded",
|
||||
@ -230,6 +244,7 @@ Q_ENABLE_METADATA, Q_DISABLE_METADATA,
|
||||
Q_EXEC, Q_DELIMITER,
|
||||
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
|
||||
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL,
|
||||
Q_START_TIMER, Q_END_TIMER,
|
||||
|
||||
Q_UNKNOWN, /* Unknown command. */
|
||||
Q_COMMENT, /* Comments, ignored. */
|
||||
@ -308,6 +323,8 @@ const char *command_names[]=
|
||||
"horizontal_results",
|
||||
"query_vertical",
|
||||
"query_horizontal",
|
||||
"start_timer",
|
||||
"end_timer",
|
||||
0
|
||||
};
|
||||
|
||||
@ -1986,6 +2003,8 @@ static struct my_option my_long_options[] =
|
||||
#include "sslopt-longopts.h"
|
||||
{"test-file", 'x', "Read test from/in this file (default stdin).",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"timer-file", 'm', "File where the timing in micro seconds is stored.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"tmpdir", 't', "Temporary directory where sockets are put.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"user", 'u', "User for login.", (gptr*) &user, (gptr*) &user, 0, GET_STR,
|
||||
@ -2047,6 +2066,19 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
die("Could not open %s: errno = %d", argument, errno);
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
static char buff[FN_REFLEN];
|
||||
if (!test_if_hard_path(argument))
|
||||
{
|
||||
strxmov(buff, opt_basedir, argument, NullS);
|
||||
argument= buff;
|
||||
}
|
||||
fn_format(buff, argument, "", "", 4);
|
||||
timer_file= buff;
|
||||
unlink(timer_file); /* Ignore error, may not exist */
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
if (argument)
|
||||
{
|
||||
@ -2128,7 +2160,7 @@ char* safe_str_append(char* buf, const char* str, int size)
|
||||
void str_to_file(const char* fname, char* str, int size)
|
||||
{
|
||||
int fd;
|
||||
char buff[FN_REFLEN];
|
||||
char buff[MAXPATHLEN];
|
||||
if (!test_if_hard_path(fname))
|
||||
{
|
||||
strxmov(buff, opt_basedir, fname, NullS);
|
||||
@ -2599,6 +2631,9 @@ int main(int argc, char **argv)
|
||||
DBUG_ENTER("main");
|
||||
DBUG_PROCESS(argv[0]);
|
||||
|
||||
/* Use all time until exit if no explicit 'start_timer' */
|
||||
timer_start= timer_now();
|
||||
|
||||
save_file[0]=0;
|
||||
TMPDIR[0]=0;
|
||||
memset(cons, 0, sizeof(cons));
|
||||
@ -2813,6 +2848,15 @@ int main(int argc, char **argv)
|
||||
case Q_EXEC:
|
||||
(void) do_exec(q);
|
||||
break;
|
||||
case Q_START_TIMER:
|
||||
/* Overwrite possible earlier start of timer */
|
||||
timer_start= timer_now();
|
||||
break;
|
||||
case Q_END_TIMER:
|
||||
/* End timer before ending mysqltest */
|
||||
timer_output();
|
||||
got_end_timer= TRUE;
|
||||
break;
|
||||
default: processed = 0; break;
|
||||
}
|
||||
}
|
||||
@ -2847,6 +2891,8 @@ int main(int argc, char **argv)
|
||||
printf("ok\n");
|
||||
}
|
||||
|
||||
if (!got_end_timer)
|
||||
timer_output(); /* No end_timer cmd, end it */
|
||||
free_used_memory();
|
||||
exit(error ? 1 : 0);
|
||||
return error ? 1 : 0; /* Keep compiler happy */
|
||||
@ -2900,6 +2946,45 @@ static int read_server_arguments(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************\
|
||||
*
|
||||
* A primitive timer that give results in milliseconds if the
|
||||
* --timer-file=<filename> is given. The timer result is written
|
||||
* to that file when the result is available. To not confuse
|
||||
* mysql-test-run with an old obsolete result, we remove the file
|
||||
* before executing any commands. The time we measure is
|
||||
*
|
||||
* - If no explicit 'start_timer' or 'end_timer' is given in the
|
||||
* test case, the timer measure how long we execute in mysqltest.
|
||||
*
|
||||
* - If only 'start_timer' is given we measure how long we execute
|
||||
* from that point until we terminate mysqltest.
|
||||
*
|
||||
* - If only 'end_timer' is given we measure how long we execute
|
||||
* from that we enter mysqltest to the 'end_timer' is command is
|
||||
* executed.
|
||||
*
|
||||
* - If both 'start_timer' and 'end_timer' are given we measure
|
||||
* the time between executing the two commands.
|
||||
*
|
||||
\****************************************************************************/
|
||||
|
||||
static void timer_output(void)
|
||||
{
|
||||
if (timer_file)
|
||||
{
|
||||
char buf[1024];
|
||||
ulonglong timer= timer_now() - timer_start;
|
||||
sprintf(buf,"%llu",timer);
|
||||
str_to_file(timer_file,buf,strlen(buf));
|
||||
}
|
||||
}
|
||||
|
||||
static ulonglong timer_now(void)
|
||||
{
|
||||
return my_getsystime() / 10000;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Handle replacement of strings
|
||||
****************************************************************************/
|
||||
|
@ -232,9 +232,13 @@ DBUSER=""
|
||||
START_WAIT_TIMEOUT=10
|
||||
STOP_WAIT_TIMEOUT=10
|
||||
MYSQL_TEST_SSL_OPTS=""
|
||||
USE_EMBEDDED_SERVER=""
|
||||
RESULT_EXT=""
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
--embedded-server) USE_EMBEDDED_SERVER=1 ; USE_MANAGER=0 ; NO_SLAVE=1 ; \
|
||||
USE_RUNNING_SERVER="" RESULT_EXT=".es" ;;
|
||||
--user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;;
|
||||
--force) FORCE=1 ;;
|
||||
--verbose-manager) MANAGER_QUIET_OPT="" ;;
|
||||
@ -458,18 +462,27 @@ fi
|
||||
|
||||
if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi
|
||||
E=`$EXPR $COLUMNS - 8`
|
||||
DASH72=`$ECHO '------------------------------------------'|$CUT -c 1-$E`
|
||||
DASH72=`$ECHO '-------------------------------------------------------'|$CUT -c 1-$E`
|
||||
|
||||
# on source dist, we pick up freshly build executables
|
||||
# on binary, use what is installed
|
||||
if [ x$SOURCE_DIST = x1 ] ; then
|
||||
MYSQLD="$VALGRIND $BASEDIR/sql/mysqld"
|
||||
if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then
|
||||
MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest"
|
||||
elif [ -f "$BASEDIR/client/.libs/mysqltest" ] ; then
|
||||
MYSQL_TEST="$BASEDIR/client/.libs/mysqltest"
|
||||
if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
|
||||
if [ -f "$BASEDIR/libmysqld/examples/mysqltest" ] ; then
|
||||
MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest"
|
||||
else
|
||||
echo "Fatal error: Cannot find embedded server 'mysqltest'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
MYSQL_TEST="$BASEDIR/client/mysqltest"
|
||||
MYSQLD="$VALGRIND $BASEDIR/sql/mysqld"
|
||||
if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then
|
||||
MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest"
|
||||
elif [ -f "$BASEDIR/client/.libs/mysqltest" ] ; then
|
||||
MYSQL_TEST="$BASEDIR/client/.libs/mysqltest"
|
||||
else
|
||||
MYSQL_TEST="$BASEDIR/client/mysqltest"
|
||||
fi
|
||||
fi
|
||||
if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then
|
||||
MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump"
|
||||
@ -565,7 +578,8 @@ export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR
|
||||
|
||||
MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
|
||||
--user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \
|
||||
--tmpdir=$MYSQL_TMP_DIR --port=$MASTER_MYPORT $MYSQL_TEST_SSL_OPTS"
|
||||
--tmpdir=$MYSQL_TMP_DIR --port=$MASTER_MYPORT --timer-file=$MY_LOG_DIR/timer \
|
||||
$MYSQL_TEST_SSL_OPTS"
|
||||
MYSQL_TEST_BIN=$MYSQL_TEST
|
||||
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
|
||||
GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
|
||||
@ -599,6 +613,13 @@ show_failed_diff ()
|
||||
result_file=r/$1.result
|
||||
eval_file=r/$1.eval
|
||||
|
||||
# If we have an special externsion for result files we use it if we are recording
|
||||
# or a result file with that extension exists.
|
||||
if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ]
|
||||
then
|
||||
result_file="$result_file$RESULT_EXT"
|
||||
fi
|
||||
|
||||
if [ -f $eval_file ]
|
||||
then
|
||||
result_file=$eval_file
|
||||
@ -880,6 +901,8 @@ EOF
|
||||
abort_if_failed "Could not execute manager command"
|
||||
}
|
||||
|
||||
# The embedded server needs the cleanup so we do some of the start work
|
||||
# but stop before actually running mysqld or anything.
|
||||
|
||||
start_master()
|
||||
{
|
||||
@ -949,6 +972,18 @@ start_master()
|
||||
CUR_MYERR=$MASTER_MYERR
|
||||
CUR_MYSOCK=$MASTER_MYSOCK
|
||||
|
||||
# For embedded server we collect the server flags and return
|
||||
if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
|
||||
# Add a -A to each argument to pass it to embedded server
|
||||
EMBEDDED_SERVER_OPTS=""
|
||||
for opt in $master_args
|
||||
do
|
||||
EMBEDDED_SERVER_OPTS="$EMBEDDED_SERVER_OPTS -A $opt"
|
||||
done
|
||||
EXTRA_MYSQL_TEST_OPT="$EMBEDDED_SERVER_OPTS"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ x$DO_DDD = x1 ]
|
||||
then
|
||||
$ECHO "set args $master_args" > $GDB_MASTER_INIT
|
||||
@ -1159,22 +1194,26 @@ stop_master ()
|
||||
{
|
||||
if [ x$MASTER_RUNNING = x1 ]
|
||||
then
|
||||
pid=`$CAT $MASTER_MYPID`
|
||||
manager_term $pid master
|
||||
if [ $? != 0 ] && [ -f $MASTER_MYPID ]
|
||||
then # try harder!
|
||||
$ECHO "master not cooperating with mysqladmin, will try manual kill"
|
||||
kill $pid
|
||||
sleep_until_file_deleted $pid $MASTER_MYPID
|
||||
if [ -f $MASTER_MYPID ] ; then
|
||||
$ECHO "master refused to die. Sending SIGKILL"
|
||||
kill -9 `$CAT $MASTER_MYPID`
|
||||
$RM -f $MASTER_MYPID
|
||||
# For embedded server we don't stop anyting but mark that
|
||||
# MASTER_RUNNING=0 to get cleanup when calling start_master().
|
||||
if [ x$USE_EMBEDDED_SERVER != x1 ] ; then
|
||||
pid=`$CAT $MASTER_MYPID`
|
||||
manager_term $pid master
|
||||
if [ $? != 0 ] && [ -f $MASTER_MYPID ]
|
||||
then # try harder!
|
||||
$ECHO "master not cooperating with mysqladmin, will try manual kill"
|
||||
kill $pid
|
||||
sleep_until_file_deleted $pid $MASTER_MYPID
|
||||
if [ -f $MASTER_MYPID ] ; then
|
||||
$ECHO "master refused to die. Sending SIGKILL"
|
||||
kill -9 `$CAT $MASTER_MYPID`
|
||||
$RM -f $MASTER_MYPID
|
||||
else
|
||||
$ECHO "master responded to SIGTERM "
|
||||
fi
|
||||
else
|
||||
$ECHO "master responded to SIGTERM "
|
||||
sleep $SLEEP_TIME_AFTER_RESTART
|
||||
fi
|
||||
else
|
||||
sleep $SLEEP_TIME_AFTER_RESTART
|
||||
fi
|
||||
MASTER_RUNNING=0
|
||||
fi
|
||||
@ -1217,9 +1256,13 @@ run_testcase ()
|
||||
master_init_script=$TESTDIR/$tname-master.sh
|
||||
slave_init_script=$TESTDIR/$tname-slave.sh
|
||||
slave_master_info_file=$TESTDIR/$tname.slave-mi
|
||||
result_file=$tname
|
||||
tsrcdir=$TESTDIR/$tname-src
|
||||
result_file="r/$tname.result"
|
||||
echo $tname > $CURRENT_TEST
|
||||
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
|
||||
if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then
|
||||
result_file="$result_file$RESULT_EXT"
|
||||
fi
|
||||
if [ "$USE_MANAGER" = 1 ] ; then
|
||||
many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)`
|
||||
fi
|
||||
@ -1249,11 +1292,46 @@ run_testcase ()
|
||||
return
|
||||
fi
|
||||
|
||||
# Stop all slave threads, so that we don't have useless reconnection attempts
|
||||
# and error messages in case the slave and master servers restart.
|
||||
stop_slave_threads
|
||||
stop_slave_threads 1
|
||||
stop_slave_threads 2
|
||||
if [ "x$USE_EMBEDDED_SERVER" != "x1" ] ; then
|
||||
# Stop all slave threads, so that we don't have useless reconnection
|
||||
# attempts and error messages in case the slave and master servers restart.
|
||||
stop_slave_threads
|
||||
stop_slave_threads 1
|
||||
stop_slave_threads 2
|
||||
fi
|
||||
|
||||
# FIXME temporary solution, we will get a new C version of this
|
||||
# script soon anyway so it is not worth it spending the time
|
||||
if [ "x$USE_EMBEDDED_SERVER" = "x1" -a -z "$DO_TEST" ] ; then
|
||||
for t in \
|
||||
|
||||
"bdb-deadlock" \
|
||||
"connect" \
|
||||
"flush_block_commit" \
|
||||
"grant2" \
|
||||
"grant_cache" \
|
||||
"grant" \
|
||||
"init_connect" \
|
||||
"innodb-deadlock" \
|
||||
"innodb-lock" \
|
||||
"mix_innodb_myisam_binlog" \
|
||||
"mysqlbinlog2" \
|
||||
"mysqlbinlog" \
|
||||
"mysqldump" \
|
||||
"mysql_protocols" \
|
||||
"ps_1general" \
|
||||
"rename" \
|
||||
"show_check" \
|
||||
"system_mysql_db_fix" \
|
||||
"user_var" \
|
||||
"variables"
|
||||
do
|
||||
if [ "$tname" = "$t" ] ; then
|
||||
skip_test $tname
|
||||
return
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$USE_RUNNING_SERVER" ] ;
|
||||
then
|
||||
@ -1269,6 +1347,10 @@ run_testcase ()
|
||||
;;
|
||||
--result-file=*)
|
||||
result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"`
|
||||
result_file="r/$result_file.result"
|
||||
if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then
|
||||
result_file="$result_file$RESULT_EXT"
|
||||
fi
|
||||
# Note that this must be set to space, not "" for test-reset to work
|
||||
EXTRA_MASTER_OPT=" "
|
||||
;;
|
||||
@ -1278,7 +1360,11 @@ run_testcase ()
|
||||
start_master
|
||||
TZ=$MY_TZ; export TZ
|
||||
else
|
||||
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || [ -f $master_init_script ]
|
||||
# If we had extra master opts to the previous run
|
||||
# or there is no master running (FIXME strange.....)
|
||||
# or there is a master init script
|
||||
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || \
|
||||
[ -f $master_init_script ]
|
||||
then
|
||||
EXTRA_MASTER_OPT=""
|
||||
stop_master
|
||||
@ -1289,47 +1375,50 @@ run_testcase ()
|
||||
fi
|
||||
fi
|
||||
|
||||
do_slave_restart=0
|
||||
if [ -f $slave_opt_file ] ;
|
||||
then
|
||||
EXTRA_SLAVE_OPT=`$CAT $slave_opt_file | $SED -e "s;\\$MYSQL_TEST_DIR;$MYSQL_TEST_DIR;"`
|
||||
do_slave_restart=1
|
||||
else
|
||||
if [ ! -z "$EXTRA_SLAVE_OPT" ] || [ x$SLAVE_RUNNING != x1 ] ;
|
||||
then
|
||||
EXTRA_SLAVE_OPT=""
|
||||
do_slave_restart=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f $slave_master_info_file ] ; then
|
||||
SLAVE_MASTER_INFO=`$CAT $slave_master_info_file`
|
||||
do_slave_restart=1
|
||||
else
|
||||
if [ ! -z "$SLAVE_MASTER_INFO" ] || [ x$SLAVE_RUNNING != x1 ] ;
|
||||
# We never start a slave if embedded server is used
|
||||
if [ "x$USE_EMBEDDED_SERVER" != "x1" ] ; then
|
||||
do_slave_restart=0
|
||||
if [ -f $slave_opt_file ] ;
|
||||
then
|
||||
SLAVE_MASTER_INFO=""
|
||||
EXTRA_SLAVE_OPT=`$CAT $slave_opt_file | $SED -e "s;\\$MYSQL_TEST_DIR;$MYSQL_TEST_DIR;"`
|
||||
do_slave_restart=1
|
||||
else
|
||||
if [ ! -z "$EXTRA_SLAVE_OPT" ] || [ x$SLAVE_RUNNING != x1 ] ;
|
||||
then
|
||||
EXTRA_SLAVE_OPT=""
|
||||
do_slave_restart=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x$do_slave_restart = x1 ] ; then
|
||||
stop_slave
|
||||
echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
|
||||
start_slave
|
||||
else
|
||||
echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
|
||||
fi
|
||||
if [ x$many_slaves = x1 ]; then
|
||||
start_slave 1
|
||||
start_slave 2
|
||||
if [ -f $slave_master_info_file ] ; then
|
||||
SLAVE_MASTER_INFO=`$CAT $slave_master_info_file`
|
||||
do_slave_restart=1
|
||||
else
|
||||
if [ ! -z "$SLAVE_MASTER_INFO" ] || [ x$SLAVE_RUNNING != x1 ] ;
|
||||
then
|
||||
SLAVE_MASTER_INFO=""
|
||||
do_slave_restart=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x$do_slave_restart = x1 ] ; then
|
||||
stop_slave
|
||||
echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
|
||||
start_slave
|
||||
else
|
||||
echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
|
||||
fi
|
||||
if [ x$many_slaves = x1 ]; then
|
||||
start_slave 1
|
||||
start_slave 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
cd $MYSQL_TEST_DIR
|
||||
|
||||
if [ -f $tf ] ; then
|
||||
$RM -f r/$tname.*reject
|
||||
mysql_test_args="-R r/$result_file.result $EXTRA_MYSQL_TEST_OPT"
|
||||
mysql_test_args="-R $result_file $EXTRA_MYSQL_TEST_OPT"
|
||||
if [ -z "$DO_CLIENT_GDB" ] ; then
|
||||
`$MYSQL_TEST $mysql_test_args < $tf 2> $TIMEFILE`;
|
||||
else
|
||||
@ -1349,7 +1438,12 @@ run_testcase ()
|
||||
if [ $res = 0 ]; then
|
||||
total_inc
|
||||
pass_inc
|
||||
$ECHO "$RES$RES_SPACE [ pass ]"
|
||||
TIMER=""
|
||||
if [ -f "$MY_LOG_DIR/timer" ]; then
|
||||
TIMER=`cat $MY_LOG_DIR/timer`
|
||||
TIMER=`$PRINTF "%13s" $TIMER`
|
||||
fi
|
||||
$ECHO "$RES$RES_SPACE [ pass ] $TIMER"
|
||||
else
|
||||
# why the following ``if'' ? That is why res==1 is special ?
|
||||
if [ $res = 2 ]; then
|
||||
@ -1364,12 +1458,13 @@ run_testcase ()
|
||||
$ECHO "$RES$RES_SPACE [ fail ]"
|
||||
$ECHO
|
||||
error_is
|
||||
show_failed_diff $result_file
|
||||
show_failed_diff $tname
|
||||
$ECHO
|
||||
if [ x$FORCE != x1 ] ; then
|
||||
$ECHO "Aborting: $tname failed. To continue, re-run with '--force'."
|
||||
$ECHO
|
||||
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
|
||||
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
|
||||
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
|
||||
then
|
||||
mysql_stop
|
||||
stop_manager
|
||||
@ -1377,7 +1472,8 @@ run_testcase ()
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
|
||||
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
|
||||
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
|
||||
then
|
||||
mysql_restart
|
||||
fi
|
||||
@ -1511,7 +1607,7 @@ then
|
||||
fi
|
||||
|
||||
$ECHO
|
||||
$ECHO " TEST RESULT"
|
||||
$ECHO "TEST RESULT TIME (ms)"
|
||||
$ECHO $DASH72
|
||||
|
||||
if [ -z "$1" ] ;
|
||||
|
483
mysql-test/r/alter_table.result.es
Normal file
483
mysql-test/r/alter_table.result.es
Normal file
@ -0,0 +1,483 @@
|
||||
drop table if exists t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create table t1 (
|
||||
col1 int not null auto_increment primary key,
|
||||
col2 varchar(30) not null,
|
||||
col3 varchar (20) not null,
|
||||
col4 varchar(4) not null,
|
||||
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
|
||||
col6 int not null, to_be_deleted int);
|
||||
insert into t1 values (2,4,3,5,"PENDING",1,7);
|
||||
alter table t1
|
||||
add column col4_5 varchar(20) not null after col4,
|
||||
add column col7 varchar(30) not null after col5,
|
||||
add column col8 datetime not null, drop column to_be_deleted,
|
||||
change column col2 fourth varchar(30) not null after col3,
|
||||
modify column col6 int not null first;
|
||||
select * from t1;
|
||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||
1 2 3 4 5 PENDING 0000-00-00 00:00:00
|
||||
drop table t1;
|
||||
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
||||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
||||
alter table t1 add column new_col int, order by payoutid,bandid;
|
||||
select * from t1;
|
||||
bandID payoutID new_col
|
||||
6 1 NULL
|
||||
3 4 NULL
|
||||
1 6 NULL
|
||||
2 6 NULL
|
||||
4 9 NULL
|
||||
5 10 NULL
|
||||
7 12 NULL
|
||||
8 12 NULL
|
||||
alter table t1 order by bandid,payoutid;
|
||||
select * from t1;
|
||||
bandID payoutID new_col
|
||||
1 6 NULL
|
||||
2 6 NULL
|
||||
3 4 NULL
|
||||
4 9 NULL
|
||||
5 10 NULL
|
||||
6 1 NULL
|
||||
7 12 NULL
|
||||
8 12 NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
|
||||
NAME varchar(80) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (GROUP_ID,LANG_ID),
|
||||
KEY NAME (NAME));
|
||||
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
GROUP_ID int(10) unsigned NULL PRI 0
|
||||
LANG_ID smallint(5) unsigned NULL PRI 0
|
||||
NAME char(80) latin1_swedish_ci MUL
|
||||
DROP TABLE t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values(9),(3),(12),(10);
|
||||
alter table t1 order by n;
|
||||
select * from t1;
|
||||
n
|
||||
3
|
||||
9
|
||||
10
|
||||
12
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) unsigned NOT NULL default '0',
|
||||
category_id tinyint(4) unsigned NOT NULL default '0',
|
||||
type_id tinyint(4) unsigned NOT NULL default '0',
|
||||
body text NOT NULL,
|
||||
user_id int(11) unsigned NOT NULL default '0',
|
||||
status enum('new','old') NOT NULL default 'new',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (AnamneseId int(10) unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
|
||||
insert into t1 values (null,"hello");
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 ADD Column new_col int not null;
|
||||
UNLOCK TABLES;
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
DROP TABLE t1;
|
||||
create table t1 (i int unsigned not null auto_increment primary key);
|
||||
insert into t1 values (null),(null),(null),(null);
|
||||
alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
|
||||
select * from t1;
|
||||
i
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
drop table t1;
|
||||
create table t1 (name char(15));
|
||||
insert into t1 (name) values ("current");
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (name char(15));
|
||||
insert into mysqltest.t1 (name) values ("mysqltest");
|
||||
select * from t1;
|
||||
name
|
||||
current
|
||||
select * from mysqltest.t1;
|
||||
name
|
||||
mysqltest
|
||||
alter table t1 rename mysqltest.t1;
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
select * from t1;
|
||||
name
|
||||
current
|
||||
select * from mysqltest.t1;
|
||||
name
|
||||
mysqltest
|
||||
drop table t1;
|
||||
drop database mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (a int,b int,c int);
|
||||
grant all on mysqltest.t1 to mysqltest_1@localhost;
|
||||
alter table t1 rename t2;
|
||||
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
|
||||
delete from mysql.user where user=_binary'mysqltest_1';
|
||||
drop database mysqltest;
|
||||
create table t1 (n1 int not null, n2 int, n3 int, n4 float,
|
||||
unique(n1),
|
||||
key (n1, n2, n3, n4),
|
||||
key (n2, n3, n4, n1),
|
||||
key (n3, n4, n1, n2),
|
||||
key (n4, n1, n2, n3) );
|
||||
alter table t1 disable keys;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 n1 1 n1 A 0 NULL NULL BTREE
|
||||
t1 1 n1_2 1 n1 A NULL NULL NULL BTREE disabled
|
||||
t1 1 n1_2 2 n2 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n1_2 3 n3 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n1_2 4 n4 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n2 1 n2 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n2 2 n3 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n2 3 n4 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n2 4 n1 A NULL NULL NULL BTREE disabled
|
||||
t1 1 n3 1 n3 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n3 2 n4 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n3 3 n1 A NULL NULL NULL BTREE disabled
|
||||
t1 1 n3 4 n2 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n4 1 n4 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n4 2 n1 A NULL NULL NULL BTREE disabled
|
||||
t1 1 n4 3 n2 A NULL NULL NULL YES BTREE disabled
|
||||
t1 1 n4 4 n3 A NULL NULL NULL YES BTREE disabled
|
||||
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(9,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(8,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(7,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(6,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(5,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(4,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(3,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(2,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(1,RAND()*1000,RAND()*1000,RAND());
|
||||
alter table t1 enable keys;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 n1 1 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n1_2 1 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n1_2 2 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n1_2 3 n3 A 10 NULL NULL YES BTREE
|
||||
t1 1 n1_2 4 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 1 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 2 n3 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 3 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 4 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n3 1 n3 A 10 NULL NULL YES BTREE
|
||||
t1 1 n3 2 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n3 3 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n3 4 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n4 1 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n4 2 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n4 3 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n4 4 n3 A 10 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
create table t1 (i int unsigned not null auto_increment primary key);
|
||||
alter table t1 rename t2;
|
||||
alter table t2 rename t1, add c char(10) comment "no comment";
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
i int(10) unsigned PRI NULL auto_increment
|
||||
c char(10) YES NULL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values(1,100), (2,100), (3, 100);
|
||||
insert into t1 values(1,99), (2,99), (3, 99);
|
||||
insert into t1 values(1,98), (2,98), (3, 98);
|
||||
insert into t1 values(1,97), (2,97), (3, 97);
|
||||
insert into t1 values(1,96), (2,96), (3, 96);
|
||||
insert into t1 values(1,95), (2,95), (3, 95);
|
||||
insert into t1 values(1,94), (2,94), (3, 94);
|
||||
insert into t1 values(1,93), (2,93), (3, 93);
|
||||
insert into t1 values(1,92), (2,92), (3, 92);
|
||||
insert into t1 values(1,91), (2,91), (3, 91);
|
||||
insert into t1 values(1,90), (2,90), (3, 90);
|
||||
insert into t1 values(1,89), (2,89), (3, 89);
|
||||
insert into t1 values(1,88), (2,88), (3, 88);
|
||||
insert into t1 values(1,87), (2,87), (3, 87);
|
||||
insert into t1 values(1,86), (2,86), (3, 86);
|
||||
insert into t1 values(1,85), (2,85), (3, 85);
|
||||
insert into t1 values(1,84), (2,84), (3, 84);
|
||||
insert into t1 values(1,83), (2,83), (3, 83);
|
||||
insert into t1 values(1,82), (2,82), (3, 82);
|
||||
insert into t1 values(1,81), (2,81), (3, 81);
|
||||
insert into t1 values(1,80), (2,80), (3, 80);
|
||||
insert into t1 values(1,79), (2,79), (3, 79);
|
||||
insert into t1 values(1,78), (2,78), (3, 78);
|
||||
insert into t1 values(1,77), (2,77), (3, 77);
|
||||
insert into t1 values(1,76), (2,76), (3, 76);
|
||||
insert into t1 values(1,75), (2,75), (3, 75);
|
||||
insert into t1 values(1,74), (2,74), (3, 74);
|
||||
insert into t1 values(1,73), (2,73), (3, 73);
|
||||
insert into t1 values(1,72), (2,72), (3, 72);
|
||||
insert into t1 values(1,71), (2,71), (3, 71);
|
||||
insert into t1 values(1,70), (2,70), (3, 70);
|
||||
insert into t1 values(1,69), (2,69), (3, 69);
|
||||
insert into t1 values(1,68), (2,68), (3, 68);
|
||||
insert into t1 values(1,67), (2,67), (3, 67);
|
||||
insert into t1 values(1,66), (2,66), (3, 66);
|
||||
insert into t1 values(1,65), (2,65), (3, 65);
|
||||
insert into t1 values(1,64), (2,64), (3, 64);
|
||||
insert into t1 values(1,63), (2,63), (3, 63);
|
||||
insert into t1 values(1,62), (2,62), (3, 62);
|
||||
insert into t1 values(1,61), (2,61), (3, 61);
|
||||
insert into t1 values(1,60), (2,60), (3, 60);
|
||||
insert into t1 values(1,59), (2,59), (3, 59);
|
||||
insert into t1 values(1,58), (2,58), (3, 58);
|
||||
insert into t1 values(1,57), (2,57), (3, 57);
|
||||
insert into t1 values(1,56), (2,56), (3, 56);
|
||||
insert into t1 values(1,55), (2,55), (3, 55);
|
||||
insert into t1 values(1,54), (2,54), (3, 54);
|
||||
insert into t1 values(1,53), (2,53), (3, 53);
|
||||
insert into t1 values(1,52), (2,52), (3, 52);
|
||||
insert into t1 values(1,51), (2,51), (3, 51);
|
||||
insert into t1 values(1,50), (2,50), (3, 50);
|
||||
insert into t1 values(1,49), (2,49), (3, 49);
|
||||
insert into t1 values(1,48), (2,48), (3, 48);
|
||||
insert into t1 values(1,47), (2,47), (3, 47);
|
||||
insert into t1 values(1,46), (2,46), (3, 46);
|
||||
insert into t1 values(1,45), (2,45), (3, 45);
|
||||
insert into t1 values(1,44), (2,44), (3, 44);
|
||||
insert into t1 values(1,43), (2,43), (3, 43);
|
||||
insert into t1 values(1,42), (2,42), (3, 42);
|
||||
insert into t1 values(1,41), (2,41), (3, 41);
|
||||
insert into t1 values(1,40), (2,40), (3, 40);
|
||||
insert into t1 values(1,39), (2,39), (3, 39);
|
||||
insert into t1 values(1,38), (2,38), (3, 38);
|
||||
insert into t1 values(1,37), (2,37), (3, 37);
|
||||
insert into t1 values(1,36), (2,36), (3, 36);
|
||||
insert into t1 values(1,35), (2,35), (3, 35);
|
||||
insert into t1 values(1,34), (2,34), (3, 34);
|
||||
insert into t1 values(1,33), (2,33), (3, 33);
|
||||
insert into t1 values(1,32), (2,32), (3, 32);
|
||||
insert into t1 values(1,31), (2,31), (3, 31);
|
||||
insert into t1 values(1,30), (2,30), (3, 30);
|
||||
insert into t1 values(1,29), (2,29), (3, 29);
|
||||
insert into t1 values(1,28), (2,28), (3, 28);
|
||||
insert into t1 values(1,27), (2,27), (3, 27);
|
||||
insert into t1 values(1,26), (2,26), (3, 26);
|
||||
insert into t1 values(1,25), (2,25), (3, 25);
|
||||
insert into t1 values(1,24), (2,24), (3, 24);
|
||||
insert into t1 values(1,23), (2,23), (3, 23);
|
||||
insert into t1 values(1,22), (2,22), (3, 22);
|
||||
insert into t1 values(1,21), (2,21), (3, 21);
|
||||
insert into t1 values(1,20), (2,20), (3, 20);
|
||||
insert into t1 values(1,19), (2,19), (3, 19);
|
||||
insert into t1 values(1,18), (2,18), (3, 18);
|
||||
insert into t1 values(1,17), (2,17), (3, 17);
|
||||
insert into t1 values(1,16), (2,16), (3, 16);
|
||||
insert into t1 values(1,15), (2,15), (3, 15);
|
||||
insert into t1 values(1,14), (2,14), (3, 14);
|
||||
insert into t1 values(1,13), (2,13), (3, 13);
|
||||
insert into t1 values(1,12), (2,12), (3, 12);
|
||||
insert into t1 values(1,11), (2,11), (3, 11);
|
||||
insert into t1 values(1,10), (2,10), (3, 10);
|
||||
insert into t1 values(1,9), (2,9), (3, 9);
|
||||
insert into t1 values(1,8), (2,8), (3, 8);
|
||||
insert into t1 values(1,7), (2,7), (3, 7);
|
||||
insert into t1 values(1,6), (2,6), (3, 6);
|
||||
insert into t1 values(1,5), (2,5), (3, 5);
|
||||
insert into t1 values(1,4), (2,4), (3, 4);
|
||||
insert into t1 values(1,3), (2,3), (3, 3);
|
||||
insert into t1 values(1,2), (2,2), (3, 2);
|
||||
insert into t1 values(1,1), (2,1), (3, 1);
|
||||
alter table t1 add unique (a,b), add key (b);
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A NULL NULL NULL YES BTREE
|
||||
t1 0 a 2 b A NULL NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 100 NULL NULL YES BTREE
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 a 1 a A 3 NULL NULL YES BTREE
|
||||
t1 0 a 2 b A 300 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 100 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (i int(10), index(i) );
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set koi8r);
|
||||
insert into t1 values ('<27><><EFBFBD><EFBFBD>');
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a binary(10);
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a varchar(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
alter table t1 change a a text character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> D4C5D3D4
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) character set koi8r default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 DEFAULT CHARACTER SET latin1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) character set koi8r default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 CONVERT TO CHARACTER SET latin1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 DEFAULT CHARACTER SET cp1251;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) character set latin1 default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=cp1251
|
||||
drop table t1;
|
||||
create table t1 (myblob longblob,mytext longtext)
|
||||
default charset latin1 collate latin1_general_cs;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`myblob` longblob,
|
||||
`mytext` longtext collate latin1_general_cs
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
|
||||
alter table t1 character set latin2;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`myblob` longblob,
|
||||
`mytext` longtext character set latin1 collate latin1_general_cs
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
LOCK TABLES t1 WRITE;
|
||||
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 3 NULL NULL BTREE
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
UNLOCK TABLES;
|
||||
CHECK TABLES t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User),
|
||||
KEY (Host)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
LOCK TABLES t1 WRITE;
|
||||
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A 1 NULL NULL BTREE
|
||||
UNLOCK TABLES;
|
||||
CHECK TABLES t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 RENAME t2;
|
||||
UNLOCK TABLES;
|
||||
select * from t2;
|
||||
Host User
|
||||
localhost
|
||||
localhost root
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User),
|
||||
KEY (Host)
|
||||
) ENGINE=MyISAM;
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
|
||||
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL default '0',
|
||||
`b` int(11) default NULL,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int, key(a));
|
||||
insert into t1 values (1,1), (2,2);
|
||||
alter table t1 drop key no_such_key;
|
||||
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
|
||||
alter table t1 drop key a;
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
alter table t1 rename to `t1\\`;
|
||||
ERROR 42000: Incorrect table name 't1\\'
|
||||
rename table t1 to `t1\\`;
|
||||
ERROR 42000: Incorrect table name 't1\\'
|
||||
drop table t1;
|
12
mysql-test/r/drop_temp_table.result.es
Normal file
12
mysql-test/r/drop_temp_table.result.es
Normal file
@ -0,0 +1,12 @@
|
||||
reset master;
|
||||
create database `drop-temp+table-test`;
|
||||
use `drop-temp+table-test`;
|
||||
create temporary table `table:name` (a int);
|
||||
select get_lock("a",10);
|
||||
get_lock("a",10)
|
||||
1
|
||||
select get_lock("a",10);
|
||||
get_lock("a",10)
|
||||
1
|
||||
show binlog events;
|
||||
drop database `drop-temp+table-test`;
|
628
mysql-test/r/insert_select.result.es
Normal file
628
mysql-test/r/insert_select.result.es
Normal file
@ -0,0 +1,628 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
||||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
||||
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
|
||||
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
|
||||
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
ERROR 23000: Duplicate entry '16' for key 1
|
||||
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
select * from t2;
|
||||
payoutID
|
||||
1
|
||||
4
|
||||
6
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
14
|
||||
16
|
||||
19
|
||||
20
|
||||
22
|
||||
drop table t1,t2;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
||||
`icone` tinyint(4) unsigned NOT NULL default '0',
|
||||
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
||||
`contenu` text NOT NULL,
|
||||
`pseudo` varchar(50) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ip` bigint(11) NOT NULL default '0',
|
||||
`signature` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`)
|
||||
,KEY `ip` (`ip`),
|
||||
KEY `date` (`date`),
|
||||
KEY `pseudo` (`pseudo`),
|
||||
KEY `numreponse` (`numreponse`)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE `t2` (
|
||||
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
||||
`icone` tinyint(4) unsigned NOT NULL default '0',
|
||||
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
||||
`contenu` text NOT NULL,
|
||||
`pseudo` varchar(50) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ip` bigint(11) NOT NULL default '0',
|
||||
`signature` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
KEY `ip` (`ip`),
|
||||
KEY `date` (`date`),
|
||||
KEY `pseudo` (`pseudo`),
|
||||
KEY `numreponse` (`numreponse`)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2
|
||||
(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES
|
||||
(9,1,56,'test','joce','2001-07-25 13:50:53'
|
||||
,3649052399,0);
|
||||
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
show variables like '%bulk%';
|
||||
Variable_name Value
|
||||
bulk_insert_buffer_size 8388608
|
||||
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
DROP TABLE t1,t2;
|
||||
create table t1(a int, unique(a));
|
||||
insert into t1 values(2);
|
||||
create table t2(a int);
|
||||
insert into t2 values(1),(2);
|
||||
reset master;
|
||||
insert into t1 select * from t2;
|
||||
ERROR 23000: Duplicate entry '2' for key 1
|
||||
show binlog events;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
drop table t1, t2;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (a+2);
|
||||
insert into t1 values (a+3);
|
||||
insert into t1 values (4),(a+5);
|
||||
insert into t1 select * from t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t1 select * from t1 as t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t2 select * from t1 as t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t1 select t2.a from t1,t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
insert into t1 select * from t1,t1;
|
||||
ERROR 42000: Not unique table/alias: 't1'
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null primary key, b char(10));
|
||||
create table t2 (a int not null, b char(10));
|
||||
insert into t1 values (1,"t1:1"),(3,"t1:3");
|
||||
insert into t2 values (2,"t2:2"), (3,"t2:3");
|
||||
insert into t1 select * from t2;
|
||||
ERROR 23000: Duplicate entry '3' for key 1
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
3 t1:3
|
||||
2 t2:2
|
||||
replace into t1 select * from t2;
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
3 t2:3
|
||||
2 t2:2
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
|
||||
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
|
||||
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
|
||||
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1(
|
||||
Month date NOT NULL,
|
||||
Type tinyint(3) unsigned NOT NULL auto_increment,
|
||||
Field int(10) unsigned NOT NULL,
|
||||
Count int(10) unsigned NOT NULL,
|
||||
UNIQUE KEY Month (Month,Type,Field)
|
||||
);
|
||||
insert into t1 Values
|
||||
(20030901, 1, 1, 100),
|
||||
(20030901, 1, 2, 100),
|
||||
(20030901, 2, 1, 100),
|
||||
(20030901, 2, 2, 100),
|
||||
(20030901, 3, 1, 100);
|
||||
select * from t1;
|
||||
Month Type Field Count
|
||||
2003-09-01 1 1 100
|
||||
2003-09-01 1 2 100
|
||||
2003-09-01 2 1 100
|
||||
2003-09-01 2 2 100
|
||||
2003-09-01 3 1 100
|
||||
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
||||
NULL Field Count
|
||||
NULL 1 100
|
||||
NULL 2 100
|
||||
create table t2(No int not null, Field int not null, Count int not null);
|
||||
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
||||
Warnings:
|
||||
Warning 1263 Data truncated; NULL supplied to NOT NULL column 'No' at row 1
|
||||
Warning 1263 Data truncated; NULL supplied to NOT NULL column 'No' at row 2
|
||||
select * from t2;
|
||||
No Field Count
|
||||
0 1 100
|
||||
0 2 100
|
||||
drop table t1, t2;
|
26
mysql-test/r/packet.result.es
Normal file
26
mysql-test/r/packet.result.es
Normal file
@ -0,0 +1,26 @@
|
||||
set global max_allowed_packet=100;
|
||||
set max_allowed_packet=100;
|
||||
set global net_buffer_length=100;
|
||||
set net_buffer_length=100;
|
||||
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
|
||||
len
|
||||
1024
|
||||
select repeat('a',2000);
|
||||
repeat('a',2000)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1301 Result of repeat() was larger than max_allowed_packet (1024) - truncated
|
||||
select @@net_buffer_length, @@max_allowed_packet;
|
||||
@@net_buffer_length @@max_allowed_packet
|
||||
1024 1024
|
||||
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
|
||||
set global max_allowed_packet=default;
|
||||
set max_allowed_packet=default;
|
||||
set global net_buffer_length=default;
|
||||
set net_buffer_length=default;
|
||||
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
|
||||
len
|
||||
100
|
||||
select length(repeat('a',2000));
|
||||
length(repeat('a',2000))
|
||||
2000
|
910
mysql-test/r/query_cache.result.es
Normal file
910
mysql-test/r/query_cache.result.es
Normal file
@ -0,0 +1,910 @@
|
||||
set GLOBAL query_cache_size=1355776;
|
||||
flush query cache;
|
||||
flush query cache;
|
||||
reset query cache;
|
||||
flush status;
|
||||
drop table if exists t1,t2,t3,t4,t11,t21;
|
||||
drop database if exists mysqltest;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select sql_no_cache * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select length(now()) from t1;
|
||||
length(now())
|
||||
19
|
||||
19
|
||||
19
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
show status like "Qcache_inserts";
|
||||
Variable_name Value
|
||||
Qcache_inserts 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 1
|
||||
drop table t1;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
create table t2 (a int not null);
|
||||
insert into t2 values (4),(5),(6);
|
||||
create table t3 (a int not null) engine=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
|
||||
select * from t3;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
select * from t3;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
insert into t2 values (7);
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 3
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
insert into t3 values (8);
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t3;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
8
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
update t2 set a=9 where a=7;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
8
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
update t3 set a=10 where a=1;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t3;
|
||||
a
|
||||
10
|
||||
2
|
||||
3
|
||||
8
|
||||
4
|
||||
5
|
||||
6
|
||||
9
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
delete from t2 where a=9;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t1;
|
||||
a
|
||||
10
|
||||
2
|
||||
3
|
||||
8
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
delete from t3 where a=10;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
create table t2 (a int not null);
|
||||
insert into t2 values (1),(2),(3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
insert into t1 values (4);
|
||||
show status like "Qcache_free_blocks";
|
||||
Variable_name Value
|
||||
Qcache_free_blocks 2
|
||||
flush query cache;
|
||||
show status like "Qcache_free_blocks";
|
||||
Variable_name Value
|
||||
Qcache_free_blocks 1
|
||||
drop table t1, t2;
|
||||
create table t1 (a text not null);
|
||||
create table t11 (a text not null);
|
||||
create table t2 (a text not null);
|
||||
create table t21 (a text not null);
|
||||
create table t3 (a text not null);
|
||||
insert into t1 values("1111111111111111111111111111111111111111111111111111");
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t11 select * from t1;
|
||||
insert into t21 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t3 select * from t1;
|
||||
insert into t3 select * from t2;
|
||||
insert into t3 select * from t1;
|
||||
select * from t11;
|
||||
select * from t21;
|
||||
show status like "Qcache_total_blocks";
|
||||
Variable_name Value
|
||||
Qcache_total_blocks 7
|
||||
show status like "Qcache_free_blocks";
|
||||
Variable_name Value
|
||||
Qcache_free_blocks 1
|
||||
insert into t11 values("");
|
||||
select * from t3;
|
||||
show status like "Qcache_total_blocks";
|
||||
Variable_name Value
|
||||
Qcache_total_blocks 8
|
||||
show status like "Qcache_free_blocks";
|
||||
Variable_name Value
|
||||
Qcache_free_blocks 2
|
||||
flush query cache;
|
||||
show status like "Qcache_total_blocks";
|
||||
Variable_name Value
|
||||
Qcache_total_blocks 7
|
||||
show status like "Qcache_free_blocks";
|
||||
Variable_name Value
|
||||
Qcache_free_blocks 1
|
||||
drop table t1, t2, t3, t11, t21;
|
||||
set query_cache_type=demand;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select sql_cache * from t1 union select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
set query_cache_type=2;
|
||||
select sql_cache * from t1 union select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t1 union select sql_cache * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 4
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
set query_cache_type=on;
|
||||
reset query cache;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select sql_no_cache * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
drop table t1;
|
||||
create table t1 (a text not null);
|
||||
select CONNECTION_ID() from t1;
|
||||
CONNECTION_ID()
|
||||
select FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
0
|
||||
select NOW() from t1;
|
||||
NOW()
|
||||
select CURDATE() from t1;
|
||||
CURDATE()
|
||||
select CURTIME() from t1;
|
||||
CURTIME()
|
||||
select DATABASE() from t1;
|
||||
DATABASE()
|
||||
select ENCRYPT("test") from t1;
|
||||
ENCRYPT("test")
|
||||
select LAST_INSERT_ID() from t1;
|
||||
LAST_INSERT_ID()
|
||||
select RAND() from t1;
|
||||
RAND()
|
||||
select UNIX_TIMESTAMP() from t1;
|
||||
UNIX_TIMESTAMP()
|
||||
select USER() from t1;
|
||||
USER()
|
||||
select benchmark(1,1) from t1;
|
||||
benchmark(1,1)
|
||||
explain extended select benchmark(1,1) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select sql_no_cache benchmark(1,1) AS `benchmark(1,1)` from test.t1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
create table t2 (a text not null);
|
||||
insert into t1 values("1111111111111111111111111111111111111111111111111111");
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 4
|
||||
show status like "Qcache_lowmem_prunes";
|
||||
Variable_name Value
|
||||
Qcache_lowmem_prunes 0
|
||||
select a as a1, a as a2 from t1;
|
||||
select a as a2, a as a3 from t1;
|
||||
select a as a3, a as a4 from t1;
|
||||
select a as a1, a as a2 from t1;
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 4
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
show status like "Qcache_lowmem_prunes";
|
||||
Variable_name Value
|
||||
Qcache_lowmem_prunes 2
|
||||
reset query cache;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
insert into t2 select * from t1;
|
||||
insert into t1 select * from t2;
|
||||
select * from t1;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
drop table t1,t2;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i));
|
||||
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 2
|
||||
select * from mysqltest.t1;
|
||||
i a
|
||||
1 1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 3
|
||||
drop database mysqltest;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
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"<EFBFBD>");
|
||||
set CHARACTER SET koi8r;
|
||||
select * from t1;
|
||||
a
|
||||
<EFBFBD>
|
||||
set CHARACTER SET cp1251_koi8;
|
||||
select * from t1;
|
||||
a
|
||||
<EFBFBD>
|
||||
set CHARACTER SET DEFAULT;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 4
|
||||
drop table t1;
|
||||
create database if not exists mysqltest;
|
||||
create table mysqltest.t1 (i int not null);
|
||||
create table t1 (i int not null);
|
||||
insert into mysqltest.t1 (i) values (1);
|
||||
insert into t1 (i) values (2);
|
||||
select * from t1;
|
||||
i
|
||||
2
|
||||
use mysqltest;
|
||||
select * from t1;
|
||||
i
|
||||
1
|
||||
select * from t1;
|
||||
i
|
||||
1
|
||||
use test;
|
||||
select * from t1;
|
||||
i
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
drop database mysqltest;
|
||||
drop table t1;
|
||||
create table t1 (i int not null);
|
||||
insert into t1 (i) values (1),(2),(3),(4);
|
||||
select SQL_CALC_FOUND_ROWS * from t1 limit 2;
|
||||
i
|
||||
1
|
||||
2
|
||||
select FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
4
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
select * from t1 where i=1;
|
||||
i
|
||||
1
|
||||
select FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
select SQL_CALC_FOUND_ROWS * from t1 limit 2;
|
||||
i
|
||||
1
|
||||
2
|
||||
select FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
4
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 7
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
select * from t1 where i=1;
|
||||
i
|
||||
1
|
||||
select FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 8
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
drop table t1;
|
||||
flush query cache;
|
||||
reset query cache;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
insert delayed into t1 values (4);
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
drop table t1;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show global variables like "query_cache_min_res_unit";
|
||||
Variable_name Value
|
||||
query_cache_min_res_unit 4096
|
||||
set GLOBAL query_cache_min_res_unit=1001;
|
||||
show global variables like "query_cache_min_res_unit";
|
||||
Variable_name Value
|
||||
query_cache_min_res_unit 1008
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
create table t2 (a int not null);
|
||||
insert into t2 values (1),(2),(3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 11
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
drop table t1;
|
||||
select a from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
select a from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 12
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
drop table t2;
|
||||
set GLOBAL query_cache_min_res_unit=default;
|
||||
show global variables like "query_cache_min_res_unit";
|
||||
Variable_name Value
|
||||
query_cache_min_res_unit 4096
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1);
|
||||
select "aaa" from t1;
|
||||
aaa
|
||||
aaa
|
||||
select "AAA" from t1;
|
||||
AAA
|
||||
AAA
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
set GLOBAL query_cache_size=1000;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=1024;
|
||||
Warnings:
|
||||
Warning 1282 Query cache failed to set size 1024; new query cache size is 0
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=10240;
|
||||
Warnings:
|
||||
Warning 1282 Query cache failed to set size 10240; new query cache size is 0
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=20480;
|
||||
Warnings:
|
||||
Warning 1282 Query cache failed to set size 20480; new query cache size is 0
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=40960;
|
||||
Warnings:
|
||||
Warning 1282 Query cache failed to set size 40960; new query cache size is 0
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=51200;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 51200
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=61440;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 61440
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=81920;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 81920
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=102400;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 102400
|
||||
select * from t1;
|
||||
a
|
||||
drop table t1;
|
||||
set GLOBAL query_cache_size=1048576;
|
||||
create table t1 (i int not null);
|
||||
create table t2 (i int not null);
|
||||
select * from t1;
|
||||
i
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
create temporary table t3 (i int not null);
|
||||
select * from t2;
|
||||
i
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
select * from t3;
|
||||
i
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
update t1 set i=(select distinct 1 from (select * from t2) a);
|
||||
drop table t1, t2, t3;
|
||||
use mysql;
|
||||
select * from db;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
use test;
|
||||
select * from mysql.db;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
create table t1(id int auto_increment primary key);
|
||||
insert into t1 values (NULL), (NULL), (NULL);
|
||||
select * from t1 where id=2;
|
||||
id
|
||||
2
|
||||
alter table t1 rename to t2;
|
||||
select * from t1 where id=2;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
drop table t2;
|
||||
select * from t1 where id=2;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t1 (word char(20) not null);
|
||||
select * from t1;
|
||||
word
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
load data infile 'TEST_DIR/std_data/words.dat' into table t1;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
70
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t1 into outfile "query_cache.out.file";
|
||||
select * from t1 into outfile "query_cache.out.file";
|
||||
ERROR HY000: File 'query_cache.out.file' already exists
|
||||
select * from t1 limit 1 into dumpfile "query_cache.dump.file";
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
SET OPTION SQL_SELECT_LIMIT=1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
SET OPTION SQL_SELECT_LIMIT=DEFAULT;
|
||||
drop table t1;
|
||||
flush query cache;
|
||||
reset query cache;
|
||||
flush status;
|
||||
set GLOBAL query_cache_size=1048576;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1),(2),(3);
|
||||
create table t2 (a text not null);
|
||||
create table t3 (a text not null);
|
||||
insert into t3 values("1111111111111111111111111111111111111111111111111111");
|
||||
insert into t2 select * from t3;
|
||||
insert into t3 select * from t2;
|
||||
insert into t2 select * from t3;
|
||||
insert into t3 select * from t2;
|
||||
insert into t2 select * from t3;
|
||||
insert into t3 select * from t2;
|
||||
insert into t2 select * from t3;
|
||||
insert into t3 select * from t2;
|
||||
insert into t2 select * from t3;
|
||||
insert into t3 select * from t2;
|
||||
drop table t2;
|
||||
create table t2 (a int not null);
|
||||
insert into t2 values (1),(2),(3);
|
||||
create table t4 (a int not null);
|
||||
insert into t4 values (1),(2),(3);
|
||||
select * from t4;
|
||||
select * from t2;
|
||||
select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
|
||||
select * from t2;
|
||||
select * from t4;
|
||||
select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
|
||||
select * from t2;
|
||||
select * from t4;
|
||||
select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
|
||||
delete from t2 where a=1;
|
||||
flush query cache;
|
||||
select * from t3;
|
||||
delete from t4 where a=1;
|
||||
flush query cache;
|
||||
drop table t1,t2,t3,t4;
|
||||
set query_cache_wlock_invalidate=1;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
select * from t1;
|
||||
a
|
||||
select * from t2;
|
||||
a
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
lock table t1 write, t2 read;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
unlock table;
|
||||
drop table t1,t2;
|
||||
set query_cache_wlock_invalidate=default;
|
||||
SET NAMES koi8r;
|
||||
CREATE TABLE t1 (a char(1) character set koi8r);
|
||||
INSERT INTO t1 VALUES (_koi8r'<27>'),(_koi8r'<27>');
|
||||
SELECT a,'<27>','<27>'='<27>' FROM t1;
|
||||
a б 'Б'='б'
|
||||
<EFBFBD> <EFBFBD> 1
|
||||
<EFBFBD> <EFBFBD> 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
set collation_connection=koi8r_bin;
|
||||
SELECT a,'<27>','<27>'='<27>' FROM t1;
|
||||
a б 'Б'='б'
|
||||
<EFBFBD> <EFBFBD> 0
|
||||
<EFBFBD> <EFBFBD> 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
set character_set_client=cp1251;
|
||||
SELECT a,'<27>','<27>'='<27>' FROM t1;
|
||||
a В 'в'='В'
|
||||
<EFBFBD> <EFBFBD> 0
|
||||
<EFBFBD> <EFBFBD> 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 3
|
||||
set character_set_results=cp1251;
|
||||
SELECT a,'<27>','<27>'='<27>' FROM t1;
|
||||
a В 'в'='В'
|
||||
<EFBFBD> <EFBFBD> 0
|
||||
<EFBFBD> <EFBFBD> 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 6
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int(1));
|
||||
CREATE DATABASE mysqltest;
|
||||
USE mysqltest;
|
||||
DROP DATABASE mysqltest;
|
||||
SELECT * FROM test.t1;
|
||||
a
|
||||
USE test;
|
||||
DROP TABLE t1;
|
||||
set character_set_results=null;
|
||||
select @@character_set_results;
|
||||
@@character_set_results
|
||||
NULL
|
||||
set character_set_results=default;
|
||||
set GLOBAL query_cache_size=1355776;
|
||||
create table t1 (id int auto_increment primary key, c char(25));
|
||||
insert into t1 set c = repeat('x',24);
|
||||
insert into t1 set c = concat(repeat('x',24),'x');
|
||||
insert into t1 set c = concat(repeat('x',24),'w');
|
||||
insert into t1 set c = concat(repeat('x',24),'y');
|
||||
set max_sort_length=200;
|
||||
select c from t1 order by c, id;
|
||||
c
|
||||
xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxw
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxy
|
||||
reset query cache;
|
||||
set max_sort_length=20;
|
||||
select c from t1 order by c, id;
|
||||
c
|
||||
xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxw
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxy
|
||||
set max_sort_length=200;
|
||||
select c from t1 order by c, id;
|
||||
c
|
||||
xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxw
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxy
|
||||
set max_sort_length=default;
|
||||
select '1' || '3' from t1;
|
||||
'1' || '3'
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
set SQL_MODE=oracle;
|
||||
select '1' || '3' from t1;
|
||||
'1' || '3'
|
||||
13
|
||||
13
|
||||
13
|
||||
13
|
||||
set SQL_MODE=default;
|
||||
drop table t1;
|
||||
create table t1 (a varchar(20), b int);
|
||||
insert into t1 values ('12345678901234567890', 1);
|
||||
set group_concat_max_len=10;
|
||||
select group_concat(a) FROM t1 group by b;
|
||||
group_concat(a)
|
||||
1234567890
|
||||
set group_concat_max_len=1024;
|
||||
select group_concat(a) FROM t1 group by b;
|
||||
group_concat(a)
|
||||
12345678901234567890
|
||||
set group_concat_max_len=default;
|
||||
drop table t1;
|
||||
SET GLOBAL query_cache_size=0;
|
2366
mysql-test/r/select.result.es
Normal file
2366
mysql-test/r/select.result.es
Normal file
File diff suppressed because it is too large
Load Diff
692
mysql-test/r/type_blob.result.es
Normal file
692
mysql-test/r/type_blob.result.es
Normal file
@ -0,0 +1,692 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7;
|
||||
CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
a blob YES NULL
|
||||
b text YES NULL
|
||||
c blob YES NULL
|
||||
d mediumtext YES NULL
|
||||
e longtext YES NULL
|
||||
CREATE TABLE t2 (a char(257), b varbinary(70000), c varchar(70000000));
|
||||
Warnings:
|
||||
Warning 1246 Converting column 'a' from CHAR to TEXT
|
||||
Warning 1246 Converting column 'b' from CHAR to BLOB
|
||||
Warning 1246 Converting column 'c' from CHAR to TEXT
|
||||
show columns from t2;
|
||||
Field Type Null Key Default Extra
|
||||
a text YES NULL
|
||||
b mediumblob YES NULL
|
||||
c longtext YES NULL
|
||||
create table t3 (a long, b long byte);
|
||||
show create TABLE t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` mediumtext,
|
||||
`b` mediumblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1,t2,t3
|
||||
#;
|
||||
CREATE TABLE t1 (a char(257) default "hello");
|
||||
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB instead
|
||||
CREATE TABLE t2 (a blob default "hello");
|
||||
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
|
||||
insert into t1 values (null,"a","A");
|
||||
insert into t1 values (null,"bbb","BBB");
|
||||
insert into t1 values (null,"ccc","CCC");
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
3
|
||||
select * from t1,t1 as t2;
|
||||
nr b str nr b str
|
||||
1 a A 1 a A
|
||||
2 bbb BBB 1 a A
|
||||
3 ccc CCC 1 a A
|
||||
1 a A 2 bbb BBB
|
||||
2 bbb BBB 2 bbb BBB
|
||||
3 ccc CCC 2 bbb BBB
|
||||
1 a A 3 ccc CCC
|
||||
2 bbb BBB 3 ccc CCC
|
||||
3 ccc CCC 3 ccc CCC
|
||||
drop table t1;
|
||||
create table t1 (a text);
|
||||
insert into t1 values ('where');
|
||||
update t1 set a='Where';
|
||||
select * from t1;
|
||||
a
|
||||
Where
|
||||
drop table t1;
|
||||
create table t1 (t text,c char(10),b blob, d binary(10));
|
||||
insert into t1 values (NULL,NULL,NULL,NULL);
|
||||
insert into t1 values ("","","","");
|
||||
insert into t1 values ("hello","hello","hello","hello");
|
||||
insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
|
||||
insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
|
||||
insert into t1 values ("a","a","a","a");
|
||||
insert into t1 values (1,1,1,1);
|
||||
insert into t1 values (NULL,NULL,NULL,NULL);
|
||||
update t1 set c="",b=null where c="1";
|
||||
lock tables t1 READ;
|
||||
show full fields from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
t text latin1_swedish_ci YES NULL
|
||||
c varchar(10) latin1_swedish_ci YES NULL
|
||||
b blob NULL YES NULL
|
||||
d varbinary(10) NULL YES NULL
|
||||
lock tables t1 WRITE;
|
||||
show full fields from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
t text latin1_swedish_ci YES NULL
|
||||
c varchar(10) latin1_swedish_ci YES NULL
|
||||
b blob NULL YES NULL
|
||||
d varbinary(10) NULL YES NULL
|
||||
unlock tables;
|
||||
select t from t1 where t like "hello";
|
||||
t
|
||||
hello
|
||||
HELLO
|
||||
select c from t1 where c like "hello";
|
||||
c
|
||||
hello
|
||||
HELLO
|
||||
select b from t1 where b like "hello";
|
||||
b
|
||||
hello
|
||||
select d from t1 where d like "hello";
|
||||
d
|
||||
hello
|
||||
select c from t1 having c like "hello";
|
||||
c
|
||||
hello
|
||||
HELLO
|
||||
select d from t1 having d like "hello";
|
||||
d
|
||||
hello
|
||||
select t from t1 where t like "%HELLO%";
|
||||
t
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
select c from t1 where c like "%HELLO%";
|
||||
c
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
select b from t1 where b like "%HELLO%";
|
||||
b
|
||||
HELLO
|
||||
HELLO MY
|
||||
select d from t1 where d like "%HELLO%";
|
||||
d
|
||||
HELLO
|
||||
HELLO MY
|
||||
select c from t1 having c like "%HELLO%";
|
||||
c
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
select d from t1 having d like "%HELLO%";
|
||||
d
|
||||
HELLO
|
||||
HELLO MY
|
||||
select d from t1 having d like "%HE%LLO%";
|
||||
d
|
||||
HELLO
|
||||
HELLO MY
|
||||
select t from t1 order by t;
|
||||
t
|
||||
NULL
|
||||
NULL
|
||||
|
||||
1
|
||||
a
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
select c from t1 order by c;
|
||||
c
|
||||
NULL
|
||||
NULL
|
||||
|
||||
|
||||
a
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
select b from t1 order by b;
|
||||
b
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
select d from t1 order by d;
|
||||
d
|
||||
NULL
|
||||
NULL
|
||||
|
||||
1
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
select distinct t from t1;
|
||||
t
|
||||
NULL
|
||||
|
||||
hello
|
||||
HELLO MY
|
||||
a
|
||||
1
|
||||
select distinct b from t1;
|
||||
b
|
||||
NULL
|
||||
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
select distinct t from t1 order by t;
|
||||
t
|
||||
NULL
|
||||
|
||||
1
|
||||
a
|
||||
hello
|
||||
HELLO MY
|
||||
select distinct b from t1 order by b;
|
||||
b
|
||||
NULL
|
||||
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
select t from t1 group by t;
|
||||
t
|
||||
NULL
|
||||
|
||||
1
|
||||
a
|
||||
hello
|
||||
HELLO MY
|
||||
select b from t1 group by b;
|
||||
b
|
||||
NULL
|
||||
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
set option sql_big_tables=1;
|
||||
select distinct t from t1;
|
||||
t
|
||||
NULL
|
||||
|
||||
hello
|
||||
HELLO MY
|
||||
a
|
||||
1
|
||||
select distinct b from t1;
|
||||
b
|
||||
NULL
|
||||
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
select distinct t from t1 order by t;
|
||||
t
|
||||
NULL
|
||||
|
||||
1
|
||||
a
|
||||
hello
|
||||
HELLO MY
|
||||
select distinct b from t1 order by b;
|
||||
b
|
||||
NULL
|
||||
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
select distinct c from t1;
|
||||
c
|
||||
NULL
|
||||
|
||||
hello
|
||||
HELLO MY
|
||||
a
|
||||
select distinct d from t1;
|
||||
d
|
||||
NULL
|
||||
|
||||
hello
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
1
|
||||
select distinct c from t1 order by c;
|
||||
c
|
||||
NULL
|
||||
|
||||
a
|
||||
hello
|
||||
HELLO MY
|
||||
select distinct d from t1 order by d;
|
||||
d
|
||||
NULL
|
||||
|
||||
1
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
select c from t1 group by c;
|
||||
c
|
||||
NULL
|
||||
|
||||
a
|
||||
hello
|
||||
HELLO MY
|
||||
select d from t1 group by d;
|
||||
d
|
||||
NULL
|
||||
|
||||
1
|
||||
HELLO
|
||||
HELLO MY
|
||||
a
|
||||
hello
|
||||
set option sql_big_tables=0;
|
||||
select distinct * from t1;
|
||||
t c b d
|
||||
NULL NULL NULL NULL
|
||||
|
||||
hello hello hello hello
|
||||
HELLO HELLO HELLO HELLO
|
||||
HELLO MY HELLO MY HELLO MY HELLO MY
|
||||
a a a a
|
||||
1 NULL 1
|
||||
select t,count(*) from t1 group by t;
|
||||
t count(*)
|
||||
NULL 2
|
||||
1
|
||||
1 1
|
||||
a 1
|
||||
hello 2
|
||||
HELLO MY 1
|
||||
select b,count(*) from t1 group by b;
|
||||
b count(*)
|
||||
NULL 3
|
||||
1
|
||||
HELLO 1
|
||||
HELLO MY 1
|
||||
a 1
|
||||
hello 1
|
||||
select c,count(*) from t1 group by c;
|
||||
c count(*)
|
||||
NULL 2
|
||||
2
|
||||
a 1
|
||||
hello 2
|
||||
HELLO MY 1
|
||||
select d,count(*) from t1 group by d;
|
||||
d count(*)
|
||||
NULL 2
|
||||
1
|
||||
1 1
|
||||
HELLO 1
|
||||
HELLO MY 1
|
||||
a 1
|
||||
hello 1
|
||||
drop table t1;
|
||||
create table t1 (a text, unique (a(2100)));
|
||||
ERROR 42000: Specified key was too long; max key length is 1000 bytes
|
||||
create table t1 (a text, key (a(2100)));
|
||||
Warnings:
|
||||
Warning 1071 Specified key was too long; max key length is 1000 bytes
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` text,
|
||||
KEY `a` (`a`(1000))
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
t1_id bigint(21) NOT NULL auto_increment,
|
||||
_field_72 varchar(128) DEFAULT '' NOT NULL,
|
||||
_field_95 varchar(32),
|
||||
_field_115 tinyint(4) DEFAULT '0' NOT NULL,
|
||||
_field_122 tinyint(4) DEFAULT '0' NOT NULL,
|
||||
_field_126 tinyint(4),
|
||||
_field_134 tinyint(4),
|
||||
PRIMARY KEY (t1_id),
|
||||
UNIQUE _field_72 (_field_72),
|
||||
KEY _field_115 (_field_115),
|
||||
KEY _field_122 (_field_122)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
|
||||
INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
|
||||
INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
|
||||
CREATE TABLE t2 (
|
||||
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
|
||||
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (seq_0_id,seq_1_id)
|
||||
);
|
||||
INSERT INTO t2 VALUES (1,1);
|
||||
INSERT INTO t2 VALUES (2,1);
|
||||
INSERT INTO t2 VALUES (2,2);
|
||||
CREATE TABLE t3 (
|
||||
t3_id bigint(21) NOT NULL auto_increment,
|
||||
_field_131 varchar(128),
|
||||
_field_133 tinyint(4) DEFAULT '0' NOT NULL,
|
||||
_field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
_field_137 tinyint(4),
|
||||
_field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
_field_140 blob,
|
||||
_field_142 tinyint(4) DEFAULT '0' NOT NULL,
|
||||
_field_145 tinyint(4) DEFAULT '0' NOT NULL,
|
||||
_field_148 tinyint(4) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (t3_id),
|
||||
KEY _field_133 (_field_133),
|
||||
KEY _field_135 (_field_135),
|
||||
KEY _field_139 (_field_139),
|
||||
KEY _field_142 (_field_142),
|
||||
KEY _field_145 (_field_145),
|
||||
KEY _field_148 (_field_148)
|
||||
);
|
||||
INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
|
||||
INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
|
||||
CREATE TABLE t4 (
|
||||
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
|
||||
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (seq_0_id,seq_1_id)
|
||||
);
|
||||
INSERT INTO t4 VALUES (1,1);
|
||||
INSERT INTO t4 VALUES (2,1);
|
||||
CREATE TABLE t5 (
|
||||
t5_id bigint(21) NOT NULL auto_increment,
|
||||
_field_149 tinyint(4),
|
||||
_field_156 varchar(128) DEFAULT '' NOT NULL,
|
||||
_field_157 varchar(128) DEFAULT '' NOT NULL,
|
||||
_field_158 varchar(128) DEFAULT '' NOT NULL,
|
||||
_field_159 varchar(128) DEFAULT '' NOT NULL,
|
||||
_field_160 varchar(128) DEFAULT '' NOT NULL,
|
||||
_field_161 varchar(128) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (t5_id),
|
||||
KEY _field_156 (_field_156),
|
||||
KEY _field_157 (_field_157),
|
||||
KEY _field_158 (_field_158),
|
||||
KEY _field_159 (_field_159),
|
||||
KEY _field_160 (_field_160),
|
||||
KEY _field_161 (_field_161)
|
||||
);
|
||||
INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
|
||||
INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
|
||||
CREATE TABLE t6 (
|
||||
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
|
||||
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (seq_0_id,seq_1_id)
|
||||
);
|
||||
INSERT INTO t6 VALUES (1,1);
|
||||
INSERT INTO t6 VALUES (1,2);
|
||||
INSERT INTO t6 VALUES (2,2);
|
||||
CREATE TABLE t7 (
|
||||
t7_id bigint(21) NOT NULL auto_increment,
|
||||
_field_143 tinyint(4),
|
||||
_field_165 varchar(32),
|
||||
_field_166 smallint(6) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (t7_id),
|
||||
KEY _field_166 (_field_166)
|
||||
);
|
||||
INSERT INTO t7 VALUES (1,0,'High',1);
|
||||
INSERT INTO t7 VALUES (2,0,'Medium',2);
|
||||
INSERT INTO t7 VALUES (3,0,'Low',3);
|
||||
select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
|
||||
replace(t3._field_140, "\r","^M") t3_id min(t3._field_131) min(t3._field_135) min(t3._field_139) min(t3._field_137) min(link_alias_142._field_165) min(link_alias_133._field_72) min(t3._field_145) min(link_alias_148._field_156) replace(min(t3._field_140), "\r","^M") t3_id
|
||||
test^M
|
||||
job^M
|
||||
1 1 test job 1 0000-00-00 00:00:00 1999-02-25 22:43:32 0 High admin 0 tomato test^M
|
||||
job^M
|
||||
1 1
|
||||
drop table t1,t2,t3,t4,t5,t6,t7;
|
||||
create table t1 (a blob);
|
||||
insert into t1 values ("empty"),("");
|
||||
select a,reverse(a) from t1;
|
||||
a reverse(a)
|
||||
empty ytpme
|
||||
|
||||
drop table t1;
|
||||
create table t1 (a blob, key (a(10)));
|
||||
insert into t1 values ("bye"),("hello"),("hello"),("hello word");
|
||||
select * from t1 where a like "hello%";
|
||||
a
|
||||
hello
|
||||
hello
|
||||
hello word
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
f1 int(11) DEFAULT '0' NOT NULL,
|
||||
f2 varchar(16) DEFAULT '' NOT NULL,
|
||||
f5 text,
|
||||
KEY index_name (f1,f2,f5(16))
|
||||
);
|
||||
INSERT INTO t1 VALUES (0,'traktor','1111111111111');
|
||||
INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
|
||||
select count(*) from t1 where f2='traktor';
|
||||
count(*)
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (foobar tinyblob not null, boggle smallint not null, key (foobar(32), boggle));
|
||||
insert into t1 values ('fish', 10),('bear', 20);
|
||||
select foobar, boggle from t1 where foobar = 'fish';
|
||||
foobar boggle
|
||||
fish 10
|
||||
select foobar, boggle from t1 where foobar = 'fish' and boggle = 10;
|
||||
foobar boggle
|
||||
fish 10
|
||||
drop table t1;
|
||||
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null);
|
||||
insert into t1 (id) values (1);
|
||||
select
|
||||
charset(load_file('../../std_data/words.dat')),
|
||||
collation(load_file('../../std_data/words.dat')),
|
||||
coercibility(load_file('../../std_data/words.dat'));
|
||||
charset(load_file('../../std_data/words.dat')) collation(load_file('../../std_data/words.dat')) coercibility(load_file('../../std_data/words.dat'))
|
||||
NULL NULL 3
|
||||
explain extended select
|
||||
charset(load_file('../../std_data/words.dat')),
|
||||
collation(load_file('../../std_data/words.dat')),
|
||||
coercibility(load_file('../../std_data/words.dat'));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select sql_no_cache charset(load_file(_latin1'../../std_data/words.dat')) AS `charset(load_file('../../std_data/words.dat'))`,collation(load_file(_latin1'../../std_data/words.dat')) AS `collation(load_file('../../std_data/words.dat'))`,coercibility(load_file(_latin1'../../std_data/words.dat')) AS `coercibility(load_file('../../std_data/words.dat'))`
|
||||
update t1 set imagem=load_file('../../std_data/words.dat') where id=1;
|
||||
Warnings:
|
||||
Warning 1263 Data truncated; NULL supplied to NOT NULL column 'imagem' at row 1
|
||||
select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
|
||||
if(imagem is null, "ERROR", "OK") length(imagem)
|
||||
OK 0
|
||||
drop table t1;
|
||||
create table t1 select load_file('../../std_data/words.dat');
|
||||
show full fields from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
load_file('../../std_data/words.dat') longblob NULL YES NULL
|
||||
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
|
||||
3 NULL
|
||||
1 Chevy
|
||||
2 Chevy
|
||||
explain select * from t1 where txt='Chevy' or txt is NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range txt_index txt_index 23 NULL 2 Using where
|
||||
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
|
||||
alter table t1 modify column txt blob;
|
||||
explain select * from t1 where txt='Chevy' or txt is NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where
|
||||
select * from t1 where txt='Chevy' or txt is NULL;
|
||||
id txt
|
||||
1 Chevy
|
||||
3 NULL
|
||||
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort
|
||||
select * from t1 where txt='Chevy' or txt is NULL order by txt;
|
||||
id txt
|
||||
3 NULL
|
||||
1 Chevy
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1)));
|
||||
INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
|
||||
select max(i) from t1 where c = '';
|
||||
max(i)
|
||||
4
|
||||
drop table t1;
|
143
mysql-test/r/type_float.result.es
Normal file
143
mysql-test/r/type_float.result.es
Normal file
@ -0,0 +1,143 @@
|
||||
drop table if exists t1;
|
||||
SELECT 10,10.0,10.,.1e+2,100.0e-1;
|
||||
10 10.0 10. .1e+2 100.0e-1
|
||||
10 10.0 10 10 10
|
||||
SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
|
||||
6e-05 -6e-05 --6e-05 -6e-05+1.000000
|
||||
6e-05 -6e-05 6e-05 0.99994
|
||||
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
|
||||
1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1
|
||||
10 10 10 10 10 10 0.1 0.1 0.1
|
||||
create table t1 (f1 float(24),f2 float(52));
|
||||
show full columns from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
f1 float NULL YES NULL
|
||||
f2 double NULL YES NULL
|
||||
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
|
||||
Warnings:
|
||||
Warning 1264 Data truncated; out of range for column 'f1' at row 7
|
||||
Warning 1264 Data truncated; out of range for column 'f1' at row 8
|
||||
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
|
||||
select * from t1;
|
||||
f1 f2
|
||||
10 10
|
||||
100000 100000
|
||||
1.23457e+09 1234567890
|
||||
1e+10 10000000000
|
||||
1e+15 1e+15
|
||||
1e+20 1e+20
|
||||
3.40282e+38 1e+50
|
||||
3.40282e+38 1e+150
|
||||
-10 -10
|
||||
1e-05 1e-05
|
||||
1e-10 1e-10
|
||||
1e-15 1e-15
|
||||
1e-20 1e-20
|
||||
0 1e-50
|
||||
0 1e-150
|
||||
drop table t1;
|
||||
create table t1 (datum double);
|
||||
insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5);
|
||||
select * from t1;
|
||||
datum
|
||||
0.5
|
||||
1
|
||||
1.5
|
||||
2
|
||||
2.5
|
||||
select * from t1 where datum < 1.5;
|
||||
datum
|
||||
0.5
|
||||
1
|
||||
select * from t1 where datum > 1.5;
|
||||
datum
|
||||
2
|
||||
2.5
|
||||
select * from t1 where datum = 1.5;
|
||||
datum
|
||||
1.5
|
||||
drop table t1;
|
||||
create table t1 (a decimal(7,3) not null, key (a));
|
||||
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
|
||||
select a from t1 order by a;
|
||||
a
|
||||
-0.010
|
||||
-0.002
|
||||
-0.000
|
||||
0.000
|
||||
1.000
|
||||
select min(a) from t1;
|
||||
min(a)
|
||||
-0.010
|
||||
drop table t1;
|
||||
create table t1 (c1 double, c2 varchar(20));
|
||||
insert t1 values (121,"16");
|
||||
select c1 + c1 * (c2 / 100) as col from t1;
|
||||
col
|
||||
140.36
|
||||
create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;
|
||||
select * from t2;
|
||||
col1 col2 col3 col4
|
||||
140.36 121.00000 121 3.47850542618522e-07
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`col1` double default NULL,
|
||||
`col2` double(22,5) default NULL,
|
||||
`col3` double default NULL,
|
||||
`col4` double default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1,t2;
|
||||
create table t1 (a float);
|
||||
insert into t1 values (1);
|
||||
select max(a),min(a),avg(a) from t1;
|
||||
max(a) min(a) avg(a)
|
||||
1 1 1
|
||||
drop table t1;
|
||||
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
|
||||
show full columns from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
f float NULL YES NULL
|
||||
f2 float NULL YES NULL
|
||||
f3 float(6,2) NULL YES NULL
|
||||
d double NULL YES NULL
|
||||
d2 double NULL YES NULL
|
||||
d3 double(10,3) NULL YES NULL
|
||||
de decimal(10,0) NULL YES NULL
|
||||
de2 decimal(6,0) NULL YES NULL
|
||||
de3 decimal(5,2) NULL YES NULL
|
||||
n decimal(10,0) NULL YES NULL
|
||||
n2 decimal(8,0) NULL YES NULL
|
||||
n3 decimal(7,6) NULL YES NULL
|
||||
drop table t1;
|
||||
create table t1 (a decimal(7,3) not null, key (a));
|
||||
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
|
||||
select a from t1 order by a;
|
||||
a
|
||||
-0.010
|
||||
-0.002
|
||||
-0.000
|
||||
0.000
|
||||
1.000
|
||||
select min(a) from t1;
|
||||
min(a)
|
||||
-0.010
|
||||
drop table t1;
|
||||
create table t1 (a float(200,100), b double(200,100));
|
||||
insert t1 values (1.0, 2.0);
|
||||
select * from t1;
|
||||
a b
|
||||
1.000000000000000000000000000000 2.000000000000000000000000000000
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` float(200,30) default NULL,
|
||||
`b` double(200,30) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (c20 char);
|
||||
insert into t1 values (5000.0);
|
||||
drop table t1;
|
||||
create table t1 (f float(54));
|
||||
ERROR 42000: Incorrect column specifier for column 'f'
|
||||
drop table if exists t1;
|
320
mysql-test/r/type_ranges.result.es
Normal file
320
mysql-test/r/type_ranges.result.es
Normal file
@ -0,0 +1,320 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
SET SQL_WARNINGS=1;
|
||||
CREATE TABLE t1 (
|
||||
auto int(5) unsigned NOT NULL auto_increment,
|
||||
string char(10) default "hello",
|
||||
tiny tinyint(4) DEFAULT '0' NOT NULL ,
|
||||
short smallint(6) DEFAULT '1' NOT NULL ,
|
||||
medium mediumint(8) DEFAULT '0' NOT NULL,
|
||||
long_int int(11) DEFAULT '0' NOT NULL,
|
||||
longlong bigint(13) DEFAULT '0' NOT NULL,
|
||||
real_float float(13,1) DEFAULT 0.0 NOT NULL,
|
||||
real_double double(16,4),
|
||||
utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
|
||||
ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
|
||||
umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
|
||||
ulong int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
|
||||
time_stamp timestamp,
|
||||
date_field date,
|
||||
time_field time,
|
||||
date_time datetime,
|
||||
blob_col blob,
|
||||
tinyblob_col tinyblob,
|
||||
mediumblob_col mediumblob not null,
|
||||
longblob_col longblob not null,
|
||||
options enum('one','two','tree') not null,
|
||||
flags set('one','two','tree') not null,
|
||||
PRIMARY KEY (auto),
|
||||
KEY (utiny),
|
||||
KEY (tiny),
|
||||
KEY (short),
|
||||
KEY any_name (medium),
|
||||
KEY (longlong),
|
||||
KEY (real_float),
|
||||
KEY (ushort),
|
||||
KEY (umedium),
|
||||
KEY (ulong),
|
||||
KEY (ulonglong,ulong),
|
||||
KEY (options,flags)
|
||||
);
|
||||
show full fields from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
auto int(5) unsigned NULL PRI NULL auto_increment
|
||||
string varchar(10) latin1_swedish_ci YES hello
|
||||
tiny tinyint(4) NULL MUL 0
|
||||
short smallint(6) NULL MUL 1
|
||||
medium mediumint(8) NULL MUL 0
|
||||
long_int int(11) NULL 0
|
||||
longlong bigint(13) NULL MUL 0
|
||||
real_float float(13,1) NULL MUL 0.0
|
||||
real_double double(16,4) NULL YES NULL
|
||||
utiny tinyint(3) unsigned NULL MUL 0
|
||||
ushort smallint(5) unsigned zerofill NULL MUL 00000
|
||||
umedium mediumint(8) unsigned NULL MUL 0
|
||||
ulong int(11) unsigned NULL MUL 0
|
||||
ulonglong bigint(13) unsigned NULL MUL 0
|
||||
time_stamp timestamp NULL YES CURRENT_TIMESTAMP
|
||||
date_field date NULL YES NULL
|
||||
time_field time NULL YES NULL
|
||||
date_time datetime NULL YES NULL
|
||||
blob_col blob NULL YES NULL
|
||||
tinyblob_col tinyblob NULL YES NULL
|
||||
mediumblob_col mediumblob NULL
|
||||
longblob_col longblob NULL
|
||||
options enum('one','two','tree') latin1_swedish_ci MUL one
|
||||
flags set('one','two','tree') latin1_swedish_ci
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE
|
||||
t1 1 utiny 1 utiny A NULL NULL NULL BTREE
|
||||
t1 1 tiny 1 tiny A NULL NULL NULL BTREE
|
||||
t1 1 short 1 short A NULL NULL NULL BTREE
|
||||
t1 1 any_name 1 medium A NULL NULL NULL BTREE
|
||||
t1 1 longlong 1 longlong A NULL NULL NULL BTREE
|
||||
t1 1 real_float 1 real_float A NULL NULL NULL BTREE
|
||||
t1 1 ushort 1 ushort A NULL NULL NULL BTREE
|
||||
t1 1 umedium 1 umedium A NULL NULL NULL BTREE
|
||||
t1 1 ulong 1 ulong A NULL NULL NULL BTREE
|
||||
t1 1 ulonglong 1 ulonglong A NULL NULL NULL BTREE
|
||||
t1 1 ulonglong 2 ulong A NULL NULL NULL BTREE
|
||||
t1 1 options 1 options A NULL NULL NULL BTREE
|
||||
t1 1 options 2 flags A NULL NULL NULL BTREE
|
||||
CREATE UNIQUE INDEX test on t1 ( auto ) ;
|
||||
CREATE INDEX test2 on t1 ( ulonglong,ulong) ;
|
||||
CREATE INDEX test3 on t1 ( medium ) ;
|
||||
DROP INDEX test ON t1;
|
||||
insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
|
||||
insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
|
||||
insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3);
|
||||
insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
|
||||
Warnings:
|
||||
Warning 1264 Data truncated; out of range for column 'utiny' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'ushort' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'umedium' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'ulong' at row 1
|
||||
Warning 1265 Data truncated for column 'options' at row 1
|
||||
Warning 1265 Data truncated for column 'flags' at row 1
|
||||
insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'string' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'tiny' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'short' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'medium' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'long_int' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'utiny' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'ushort' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'umedium' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'ulong' at row 1
|
||||
Warning 1265 Data truncated for column 'options' at row 1
|
||||
insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
|
||||
Warnings:
|
||||
Warning 1264 Data truncated; out of range for column 'tiny' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'short' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'medium' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'long_int' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'utiny' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'ushort' at row 1
|
||||
Warning 1264 Data truncated; out of range for column 'umedium' at row 1
|
||||
Warning 1265 Data truncated for column 'options' at row 1
|
||||
insert into t1 (tiny) values (1);
|
||||
select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,utiny,ushort,umedium,ulong,ulonglong,mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000),date_field,time_field,date_time,blob_col,tinyblob_col,mediumblob_col,longblob_col from t1;
|
||||
auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col
|
||||
10 1 1 1 1 1 1 1.0 1.0000 1 00001 1 1 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 1 1 1
|
||||
11 2 2 2 2 2 2 2.0 2.0000 2 00002 2 2 2 0 NULL NULL NULL NULL NULL 2 2
|
||||
12 0.33 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3
|
||||
13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 18446744073709551615 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1
|
||||
14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 18446744069414584321 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295
|
||||
15 4294967295 127 32767 8388607 2147483647 4294967295 4294967296.0 4294967295.0000 255 65535 16777215 4294967295 4294967295 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4294967295 4294967295 4294967295 4294967295
|
||||
16 hello 1 1 0 0 0 0.0 NULL 0 00000 0 0 0 0 NULL NULL NULL NULL NULL
|
||||
ALTER TABLE t1
|
||||
add new_field char(10) default "new" not null,
|
||||
change blob_col new_blob_col varchar(20),
|
||||
change date_field date_field char(10),
|
||||
alter column string set default "new default",
|
||||
alter short drop default,
|
||||
DROP INDEX utiny,
|
||||
DROP INDEX ushort,
|
||||
DROP PRIMARY KEY,
|
||||
DROP FOREIGN KEY any_name,
|
||||
ADD INDEX (auto);
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1
|
||||
RENAME as t2,
|
||||
DROP longblob_col;
|
||||
UNLOCK TABLES;
|
||||
ALTER TABLE t2 rename as t3;
|
||||
LOCK TABLES t3 WRITE ;
|
||||
ALTER TABLE t3 rename as t1;
|
||||
UNLOCK TABLES;
|
||||
select auto,new_field,new_blob_col,date_field from t1 ;
|
||||
auto new_field new_blob_col date_field
|
||||
10 new 1 0000-00-00
|
||||
11 new NULL NULL
|
||||
12 new 1997-03-03
|
||||
13 new -1 1997-08-07
|
||||
14 new -4294967295 0000-00-00
|
||||
15 new 4294967295 0000-00-00
|
||||
16 new NULL NULL
|
||||
CREATE TABLE t2 (
|
||||
auto int(5) unsigned NOT NULL auto_increment,
|
||||
string char(20),
|
||||
mediumblob_col mediumblob not null,
|
||||
new_field char(2),
|
||||
PRIMARY KEY (auto)
|
||||
);
|
||||
INSERT INTO t2 (string,mediumblob_col,new_field) SELECT string,mediumblob_col,new_field from t1 where auto > 10;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'new_field' at row 2
|
||||
Warning 1265 Data truncated for column 'new_field' at row 3
|
||||
Warning 1265 Data truncated for column 'new_field' at row 4
|
||||
Warning 1265 Data truncated for column 'new_field' at row 5
|
||||
Warning 1265 Data truncated for column 'new_field' at row 6
|
||||
Warning 1265 Data truncated for column 'new_field' at row 7
|
||||
select * from t2;
|
||||
auto string mediumblob_col new_field
|
||||
1 2 2 ne
|
||||
2 0.33 ne
|
||||
3 -1 -1 ne
|
||||
4 -429496729 -4294967295 ne
|
||||
5 4294967295 4294967295 ne
|
||||
6 hello ne
|
||||
select distinct flags from t1;
|
||||
flags
|
||||
|
||||
one,two,tree
|
||||
one
|
||||
one,two
|
||||
select flags from t1 where find_in_set("two",flags)>0;
|
||||
flags
|
||||
one,two,tree
|
||||
one,two,tree
|
||||
one,two
|
||||
one,two
|
||||
select flags from t1 where find_in_set("unknown",flags)>0;
|
||||
flags
|
||||
select options,flags from t1 where options="ONE" and flags="ONE";
|
||||
options flags
|
||||
one one
|
||||
select options,flags from t1 where options="one" and flags="one";
|
||||
options flags
|
||||
one one
|
||||
drop table t2;
|
||||
create table t2 select * from t1;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'options' at row 4
|
||||
Warning 1265 Data truncated for column 'options' at row 5
|
||||
Warning 1265 Data truncated for column 'options' at row 6
|
||||
update t2 set string="changed" where auto=16;
|
||||
show full columns from t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
auto int(5) unsigned NULL MUL NULL auto_increment
|
||||
string varchar(10) latin1_swedish_ci YES new defaul
|
||||
tiny tinyint(4) NULL MUL 0
|
||||
short smallint(6) NULL MUL 0
|
||||
medium mediumint(8) NULL MUL 0
|
||||
long_int int(11) NULL 0
|
||||
longlong bigint(13) NULL MUL 0
|
||||
real_float float(13,1) NULL MUL 0.0
|
||||
real_double double(16,4) NULL YES NULL
|
||||
utiny tinyint(3) unsigned NULL 0
|
||||
ushort smallint(5) unsigned zerofill NULL 00000
|
||||
umedium mediumint(8) unsigned NULL MUL 0
|
||||
ulong int(11) unsigned NULL MUL 0
|
||||
ulonglong bigint(13) unsigned NULL MUL 0
|
||||
time_stamp timestamp NULL YES CURRENT_TIMESTAMP
|
||||
date_field varchar(10) latin1_swedish_ci YES NULL
|
||||
time_field time NULL YES NULL
|
||||
date_time datetime NULL YES NULL
|
||||
new_blob_col varchar(20) latin1_swedish_ci YES NULL
|
||||
tinyblob_col tinyblob NULL YES NULL
|
||||
mediumblob_col mediumblob NULL
|
||||
options enum('one','two','tree') latin1_swedish_ci MUL one
|
||||
flags set('one','two','tree') latin1_swedish_ci
|
||||
new_field varchar(10) latin1_swedish_ci new
|
||||
show full columns from t2;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
auto int(5) unsigned NULL 0
|
||||
string varchar(10) latin1_swedish_ci YES new defaul
|
||||
tiny tinyint(4) NULL 0
|
||||
short smallint(6) NULL 0
|
||||
medium mediumint(8) NULL 0
|
||||
long_int int(11) NULL 0
|
||||
longlong bigint(13) NULL 0
|
||||
real_float float(13,1) NULL 0.0
|
||||
real_double double(16,4) NULL YES NULL
|
||||
utiny tinyint(3) unsigned NULL 0
|
||||
ushort smallint(5) unsigned zerofill NULL 00000
|
||||
umedium mediumint(8) unsigned NULL 0
|
||||
ulong int(11) unsigned NULL 0
|
||||
ulonglong bigint(13) unsigned NULL 0
|
||||
time_stamp timestamp NULL YES 0000-00-00 00:00:00
|
||||
date_field varchar(10) latin1_swedish_ci YES NULL
|
||||
time_field time NULL YES NULL
|
||||
date_time datetime NULL YES NULL
|
||||
new_blob_col varchar(20) latin1_swedish_ci YES NULL
|
||||
tinyblob_col tinyblob NULL YES NULL
|
||||
mediumblob_col mediumblob NULL
|
||||
options enum('one','two','tree') latin1_swedish_ci one
|
||||
flags set('one','two','tree') latin1_swedish_ci
|
||||
new_field varchar(10) latin1_swedish_ci new
|
||||
select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null)));
|
||||
auto auto
|
||||
16 16
|
||||
select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and not (t1.string<=>t2.string and t1.tiny<=>t2.tiny and t1.short<=>t2.short and t1.medium<=>t2.medium and t1.long_int<=>t2.long_int and t1.longlong<=>t2.longlong and t1.real_float<=>t2.real_float and t1.real_double<=>t2.real_double and t1.utiny<=>t2.utiny and t1.ushort<=>t2.ushort and t1.umedium<=>t2.umedium and t1.ulong<=>t2.ulong and t1.ulonglong<=>t2.ulonglong and t1.time_stamp<=>t2.time_stamp and t1.date_field<=>t2.date_field and t1.time_field<=>t2.time_field and t1.date_time<=>t2.date_time and t1.new_blob_col<=>t2.new_blob_col and t1.tinyblob_col<=>t2.tinyblob_col and t1.mediumblob_col<=>t2.mediumblob_col and t1.options<=>t2.options and t1.flags<=>t2.flags and t1.new_field<=>t2.new_field);
|
||||
auto auto
|
||||
16 16
|
||||
drop table t2;
|
||||
create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1;
|
||||
show full columns from t2;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
auto bigint(17) unsigned NULL PRI 0
|
||||
t1 bigint(1) NULL 0
|
||||
t2 char(1) latin1_swedish_ci
|
||||
t3 longtext latin1_swedish_ci
|
||||
t4 longblob NULL
|
||||
select * from t2;
|
||||
auto t1 t2 t3 t4
|
||||
11 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
12 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
13 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
14 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
15 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
16 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
17 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
drop table t1,t2;
|
||||
create table t1 (c int);
|
||||
insert into t1 values(1),(2);
|
||||
create table t2 select * from t1;
|
||||
create table t3 select * from t1, t2;
|
||||
ERROR 42S21: Duplicate column name 'c'
|
||||
create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
|
||||
show full columns from t3;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
c1 int(11) NULL YES NULL
|
||||
c2 int(11) NULL YES NULL
|
||||
const bigint(1) NULL 0
|
||||
drop table t1,t2,t3;
|
||||
create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield));
|
||||
drop table t1;
|
||||
create table t1 ( id integer unsigned not null primary key );
|
||||
create table t2 ( id integer unsigned not null primary key );
|
||||
insert into t1 values (1), (2);
|
||||
insert into t2 values (1);
|
||||
select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
|
||||
id_A id_B
|
||||
1 1
|
||||
2 NULL
|
||||
create table t3 (id_A integer unsigned not null, id_B integer unsigned null );
|
||||
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
|
||||
select * from t3;
|
||||
id_A id_B
|
||||
1 1
|
||||
2 NULL
|
||||
drop table t3;
|
||||
create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
|
||||
select * from t3;
|
||||
id_A id_B
|
||||
1 1
|
||||
2 NULL
|
||||
drop table t1,t2,t3;
|
Reference in New Issue
Block a user