Merge jlindstrom@build.mysql.com:/home/bk/mysql-4.1

into hundin.mysql.fi:/home/jan/mysql-4.1
This commit is contained in:
jan@hundin.mysql.fi 2004-09-29 08:22:37 +03:00
commit 2be1005bcf
260 changed files with 10834 additions and 5063 deletions

View file

@ -102,6 +102,7 @@ miguel@hegel.txg.br
miguel@light.
miguel@light.local
miguel@sartre.local
mikael@mc04.(none)
mikron@c-fb0ae253.1238-1-64736c10.cust.bredbandsbolaget.se
mikron@mikael-ronstr-ms-dator.local
mleich@mysql.com
@ -132,6 +133,7 @@ mwagner@here.mwagner.org
mwagner@work.mysql.com
mydev@mysql.com
mysql@home.(none)
mysql@mc04.(none)
mysqldev@build.mysql2.com
mysqldev@melody.local
mysqldev@mysql.com
@ -161,6 +163,7 @@ ram@ram.(none)
ranger@regul.home.lan
rburnett@build.mysql.com
root@home.(none)
root@mc04.(none)
root@x3.internalnet
salle@banica.(none)
salle@geopard.(none)

View file

@ -1548,16 +1548,43 @@ dnl Sets HAVE_NDBCLUSTER_DB if --with-ndbcluster is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [
AC_ARG_WITH([ndb-sci],
AC_HELP_STRING([--with-ndb-sci=DIR],
[Provide MySQL with a custom location of
sci library. Given DIR, sci library is
assumed to be in $DIR/lib and header files
in $DIR/include.]),
[mysql_sci_dir=${withval}],
[mysql_sci_dir=""])
case "$mysql_sci_dir" in
"no" )
have_ndb_sci=no
AC_MSG_RESULT([-- not including sci transporter])
;;
* )
if test -f "$mysql_sci_dir/lib/libsisci.a" -a \
-f "$mysql_sci_dir/include/sisci_api.h"; then
NDB_SCI_INCLUDES="-I$mysql_sci_dir/include"
NDB_SCI_LIBS="-L$mysql_sci_dir/lib -lsisci"
AC_MSG_RESULT([-- including sci transporter])
AC_DEFINE([NDB_SCI_TRANSPORTER], [1],
[Including Ndb Cluster DB sci transporter])
AC_SUBST(NDB_SCI_INCLUDES)
AC_SUBST(NDB_SCI_LIBS)
have_ndb_sci="yes"
AC_MSG_RESULT([found sci transporter in $mysql_sci_dir/{include, lib}])
else
AC_MSG_RESULT([could not find sci transporter in $mysql_sci_dir/{include, lib}])
fi
;;
esac
AC_ARG_WITH([ndb-shm],
[
--with-ndb-shm Include the NDB Cluster shared memory transporter],
[ndb_shm="$withval"],
[ndb_shm=no])
AC_ARG_WITH([ndb-sci],
[
--with-ndb-sci Include the NDB Cluster sci transporter],
[ndb_sci="$withval"],
[ndb_sci=no])
AC_ARG_WITH([ndb-test],
[
--with-ndb-test Include the NDB Cluster ndbapi test programs],
@ -1590,19 +1617,6 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [
;;
esac
have_ndb_sci=no
case "$ndb_sci" in
yes )
AC_MSG_RESULT([-- including sci transporter])
AC_DEFINE([NDB_SCI_TRANSPORTER], [1],
[Including Ndb Cluster DB sci transporter])
have_ndb_sci="yes"
;;
* )
AC_MSG_RESULT([-- not including sci transporter])
;;
esac
have_ndb_test=no
case "$ndb_test" in
yes )

View file

@ -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)

View file

@ -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
};
@ -844,10 +861,10 @@ int do_source(struct st_query* q)
1 error
*/
int do_exec(struct st_query* q)
static void do_exec(struct st_query* q)
{
int error= 0;
DYNAMIC_STRING *ds;
int error;
DYNAMIC_STRING *ds= NULL; /* Assign just to avoid warning */
DYNAMIC_STRING ds_tmp;
char buf[1024];
FILE *res_file;
@ -884,7 +901,15 @@ int do_exec(struct st_query* q)
while (fgets(buf, sizeof(buf), res_file))
replace_dynstr_append_mem(ds, buf, strlen(buf));
}
error= pclose(res_file);
if (error != 0)
die("command \"%s\" failed", cmd);
if (!disable_result_log)
{
if (glob_replace)
free_replace();
@ -902,9 +927,6 @@ int do_exec(struct st_query* q)
if (ds == &ds_tmp)
dynstr_free(&ds_tmp);
}
pclose(res_file);
DBUG_RETURN(error);
}
@ -1986,6 +2008,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 +2071,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 +2165,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 +2636,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));
@ -2811,7 +2851,16 @@ int main(int argc, char **argv)
(void) mysql_ping(&cur_con->mysql);
break;
case Q_EXEC:
(void) do_exec(q);
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 +2896,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 +2951,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
****************************************************************************/

View file

@ -3024,11 +3024,11 @@ AC_SUBST([ndb_port_base])
ndb_transporter_opt_objs=""
if test X"$have_ndb_shm" = Xyes
then
ndb_transporter_opt_objs="$(ndb_transporter_opt_objs) SHM_Transporter.lo SHM_Transporter.unix.lo"
ndb_transporter_opt_objs="$ndb_transporter_opt_objs SHM_Transporter.lo SHM_Transporter.unix.lo"
fi
if test X"$have_ndb_sci" = Xyes
then
ndb_transporter_opt_objs="$(ndb_transporter_opt_objs) SCI_Transporter.lo"
ndb_transporter_opt_objs="$ndb_transporter_opt_objs SCI_Transporter.lo"
fi
AC_SUBST([ndb_transporter_opt_objs])

View file

@ -1190,13 +1190,13 @@ execute stmt1 using @arg00 ;
######## SELECT .. WHERE column(year)=value(DOUBLE(m,n)/DOUBLE) ########
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;

View file

@ -540,6 +540,10 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
--enable_metadata
prepare stmt1 from @stmt ;
#
# Result log was disabled upon test case failure in the optimized build.
#
--disable_result_log
execute stmt1 ;
--disable_metadata
execute stmt1 ;
@ -588,6 +592,7 @@ execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
--disable_metadata
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
--enable_result_log
drop table t2 ;

View file

@ -208,6 +208,7 @@ MYSQL_MANAGER_LOG=$MYSQL_TEST_DIR/var/log/manager.log
MYSQL_MANAGER_USER=root
NO_SLAVE=0
USER_TEST=
FAILED_CASES=
EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
@ -232,11 +233,17 @@ DBUSER=""
START_WAIT_TIMEOUT=10
STOP_WAIT_TIMEOUT=10
MYSQL_TEST_SSL_OPTS=""
USE_TIMER=""
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 ;;
--timer) USE_TIMER=1 ;;
--verbose-manager) MANAGER_QUIET_OPT="" ;;
--old-master) MASTER_40_ARGS="";;
--master-binary=*)
@ -295,6 +302,11 @@ while test $# -gt 0; do
--record)
RECORD=1;
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
--small-bench)
DO_SMALL_BENCH=1
DO_BENCH=1
NO_SLAVE=1
;;
--bench)
DO_BENCH=1
NO_SLAVE=1
@ -458,18 +470,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"
@ -566,6 +587,9 @@ 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"
if [ x$USE_TIMER = x1 ] ; then
MYSQL_TEST_ARGS="$MYSQL_TEST_ARGS --timer-file=$MY_LOG_DIR/timer"
fi
MYSQL_TEST_BIN=$MYSQL_TEST
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
@ -599,6 +623,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 +911,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 +982,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 +1204,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 +1266,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 +1302,45 @@ 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 +1356,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 +1369,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 +1384,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 +1447,12 @@ run_testcase ()
if [ $res = 0 ]; then
total_inc
pass_inc
$ECHO "$RES$RES_SPACE [ pass ]"
TIMER=""
if [ x$USE_TIMER = x1 -a -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,20 +1467,22 @@ 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
fi
exit 1
fi
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
FAILED_CASES="$FAILED_CASES $tname"
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
then
mysql_restart
fi
@ -1451,7 +1556,13 @@ then
if [ -z "$USE_RUNNING_NDBCLUSTER" ]
then
echo "Starting ndbcluster"
./ndb/ndbcluster --port-base=$NDBCLUSTER_PORT --small --diskless --initial --data-dir=$MYSQL_TEST_DIR/var || exit 1
if [ "$DO_BENCH" = 1 ]
then
NDBCLUSTER_OPTS=""
else
NDBCLUSTER_OPTS="--small"
fi
./ndb/ndbcluster --port-base=$NDBCLUSTER_PORT $NDBCLUSTER_OPTS --diskless --initial --data-dir=$MYSQL_TEST_DIR/var || exit 1
USE_NDBCLUSTER="$USE_NDBCLUSTER --ndb-connectstring=\"host=localhost:$NDBCLUSTER_PORT\""
else
USE_NDBCLUSTER="$USE_NDBCLUSTER --ndb-connectstring=\"$USE_RUNNING_NDBCLUSTER\""
@ -1485,9 +1596,14 @@ if [ "$DO_BENCH" = 1 ]
then
start_master
if [ "$DO_SMALL_BENCH" = 1 ]
then
EXTRA_BENCH_ARGS="--small-test --small-tables"
fi
if [ ! -z "$USE_NDBCLUSTER" ]
then
EXTRA_BENCH_ARGS="--create-options=TYPE=ndb"
EXTRA_BENCH_ARGS="--create-options=TYPE=ndb $EXTRA_BENCH_ARGS"
fi
BENCHDIR=$BASEDIR/sql-bench/
@ -1495,7 +1611,7 @@ then
cd $BENCHDIR
if [ -z "$1" ]
then
./run-all-tests --socket=$MASTER_MYSOCK --user=root $EXTRA_BENCH_ARGS
./run-all-tests --socket=$MASTER_MYSOCK --user=root $EXTRA_BENCH_ARGS --log
else
if [ -x "./$1" ]
then
@ -1511,7 +1627,11 @@ then
fi
$ECHO
$ECHO " TEST RESULT"
if [ x$USE_TIMER = x1 ] ; then
$ECHO "TEST RESULT TIME (ms)"
else
$ECHO "TEST RESULT"
fi
$ECHO $DASH72
if [ -z "$1" ] ;
@ -1562,4 +1682,10 @@ $ECHO
[ "$DO_GCOV" ] && gcov_collect # collect coverage information
[ "$DO_GPROF" ] && gprof_collect # collect coverage information
exit 0
if [ $TOT_FAIL -ne 0 ]; then
$ECHO "mysql-test-run: *** Failing the test(s):$FAILED_CASES"
$ECHO
exit 1
else
exit 0
fi

View file

@ -6,6 +6,7 @@ IndexMemory= CHOOSE_IndexMemory
Diskless= CHOOSE_Diskless
TimeBetweenWatchDogCheck= 30000
DataDir= CHOOSE_FILESYSTEM
MaxNoOfOrderedIndexes= CHOOSE_MaxNoOfOrderedIndexes
[ndbd]
HostName= CHOOSE_HOSTNAME_1

View file

@ -44,7 +44,8 @@ initial_ndb=
status_ndb=
ndb_diskless=0
ndb_con_op=100000
ndb_no_ord=512
ndb_con_op=105000
ndb_dmem=80M
ndb_imem=24M
@ -65,6 +66,7 @@ while test $# -gt 0; do
status_ndb=1
;;
--small)
ndb_no_ord=128
ndb_con_op=10000
ndb_dmem=40M
ndb_imem=12M
@ -128,6 +130,7 @@ port_transporter=`expr $ndb_mgmd_port + 2`
if [ $initial_ndb ] ; then
sed \
-e s,"CHOOSE_MaxNoOfOrderedIndexes","$ndb_no_ord",g \
-e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \
-e s,"CHOOSE_DataMemory","$ndb_dmem",g \
-e s,"CHOOSE_IndexMemory","$ndb_imem",g \

View 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 ('ÔÅÓÔ');
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ D4C5D3D4
alter table t1 change a a char(10) character set cp1251;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ F2E5F1F2
alter table t1 change a a binary(10);
select a,hex(a) from t1;
a hex(a)
òåñò F2E5F1F2
alter table t1 change a a char(10) character set cp1251;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ F2E5F1F2
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ D4C5D3D4
alter table t1 change a a varchar(10) character set cp1251;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ F2E5F1F2
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ D4C5D3D4
alter table t1 change a a text character set cp1251;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ F2E5F1F2
alter table t1 change a a char(10) character set koi8r;
select a,hex(a) from t1;
a hex(a)
ÔÅÓÔ 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;

View 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`;

View 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;

View file

@ -72,4 +72,82 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8
1 100 3 4 5 PENDING 0000-00-00 00:00:00
1 101 3 4 5 PENDING 0000-00-00 00:00:00
2 102 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00
delete from t1;
insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
SET SQL_MODE='';
insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
0 0 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00
1 103 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00
alter table t1 drop column col4_5;
insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
col6 col1 col3 fourth col4 col5 col7 col8
0 0 4 3 5 PENDING EXTRA 2004-01-01 00:00:00
1 103 4 3 5 PENDING EXTRA 2004-01-01 00:00:00
2 104 4 3 5 PENDING EXTRA 2004-01-01 00:00:00
drop table t1;
CREATE TABLE t1 (
a INT NOT NULL,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (9410,9412);
ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1 order by a;
a b c
9410 9412 0
select * from t1 order by a;
a b c
9410 9412 0
alter table t1 drop c;
select * from t1 order by a;
a b
9410 9412
drop table t1;
select * from t1 order by a;
ERROR 42S02: Table 'test.t1' doesn't exist
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1 order by a;
a b
0 1
17 18
alter table t1 modify column a int not null auto_increment;
select * from t1 order by a;
a b
0 1
17 18
INSERT INTO t1 VALUES (0,19),(20,21);
select * from t1 order by a;
a b
0 1
17 18
18 19
20 21
drop table t1;
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1;
a b
17 18
0 1
alter table t1 add c int not null unique auto_increment;
select * from t1 order by a;
a b c
0 1 2
17 18 1
INSERT INTO t1 VALUES (18,19,3),(20,21,0);
select * from t1 order by a;
a b c
0 1 2
17 18 1
18 19 3
20 21 4
drop table t1;

View file

@ -0,0 +1,191 @@
drop table if exists t1;
create table t1 (
a char(3) character set latin1 collate latin1_bin primary key
) engine=ndb;
insert into t1 values('aAa');
insert into t1 values('aaa');
insert into t1 values('AAA');
select * from t1 order by a;
a
AAA
aAa
aaa
select * from t1 where a = 'aAa';
a
aAa
select * from t1 where a = 'aaa';
a
aaa
select * from t1 where a = 'AaA';
a
select * from t1 where a = 'AAA';
a
AAA
drop table t1;
create table t1 (
a char(3) character set latin1 collate latin1_swedish_ci primary key
) engine=ndb;
insert into t1 values('aAa');
insert into t1 values('aaa');
ERROR 23000: Duplicate entry 'aaa' for key 1
insert into t1 values('AAA');
ERROR 23000: Duplicate entry 'AAA' for key 1
select * from t1 order by a;
a
aAa
select * from t1 where a = 'aAa';
a
aAa
select * from t1 where a = 'aaa';
a
aAa
select * from t1 where a = 'AaA';
a
aAa
select * from t1 where a = 'AAA';
a
aAa
drop table t1;
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
unique key(a)
) engine=ndb;
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
select * from t1 order by p;
p a
1 aAa
2 aaa
3 AAA
select * from t1 where a = 'aAa';
p a
1 aAa
select * from t1 where a = 'aaa';
p a
2 aaa
select * from t1 where a = 'AaA';
p a
select * from t1 where a = 'AAA';
p a
3 AAA
drop table t1;
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_swedish_ci not null,
unique key(a)
) engine=ndb;
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
ERROR 23000: Can't write, because of unique constraint, to table 't1'
insert into t1 values(3, 'AAA');
ERROR 23000: Can't write, because of unique constraint, to table 't1'
select * from t1 order by p;
p a
1 aAa
select * from t1 where a = 'aAa';
p a
1 aAa
select * from t1 where a = 'aaa';
p a
1 aAa
select * from t1 where a = 'AaA';
p a
1 aAa
select * from t1 where a = 'AAA';
p a
1 aAa
drop table t1;
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
index(a)
) engine=ndb;
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
insert into t1 values(4, 'aAa');
insert into t1 values(5, 'aaa');
insert into t1 values(6, 'AAA');
select * from t1 order by p;
p a
1 aAa
2 aaa
3 AAA
4 aAa
5 aaa
6 AAA
explain select * from t1 where a = 'zZz' order by p;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 3 const 10 Using where; Using filesort
select * from t1 where a = 'aAa' order by p;
p a
1 aAa
4 aAa
select * from t1 where a = 'aaa' order by p;
p a
2 aaa
5 aaa
select * from t1 where a = 'AaA' order by p;
p a
select * from t1 where a = 'AAA' order by p;
p a
3 AAA
6 AAA
drop table t1;
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_swedish_ci not null,
index(a)
) engine=ndb;
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
insert into t1 values(4, 'aAa');
insert into t1 values(5, 'aaa');
insert into t1 values(6, 'AAA');
select * from t1 order by p;
p a
1 aAa
2 aaa
3 AAA
4 aAa
5 aaa
6 AAA
explain select * from t1 where a = 'zZz' order by p;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 3 const 10 Using where; Using filesort
select * from t1 where a = 'aAa' order by p;
p a
1 aAa
2 aaa
3 AAA
4 aAa
5 aaa
6 AAA
select * from t1 where a = 'aaa' order by p;
p a
1 aAa
2 aaa
3 AAA
4 aAa
5 aaa
6 AAA
select * from t1 where a = 'AaA' order by p;
p a
1 aAa
2 aaa
3 AAA
4 aAa
5 aaa
6 AAA
select * from t1 where a = 'AAA' order by p;
p a
1 aAa
2 aaa
3 AAA
4 aAa
5 aaa
6 AAA
drop table t1;

View file

@ -4,7 +4,7 @@ PORT varchar(16) NOT NULL,
ACCESSNODE varchar(16) NOT NULL,
POP varchar(48) NOT NULL,
ACCESSTYPE int unsigned NOT NULL,
CUSTOMER_ID varchar(20) NOT NULL,
CUSTOMER_ID varchar(20) collate latin1_bin NOT NULL,
PROVIDER varchar(16),
TEXPIRE int unsigned,
NUM_IP int unsigned,

View 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

View file

@ -908,53 +908,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
execute stmt1 ;
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -977,56 +935,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -3192,17 +3108,21 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t9;

View file

@ -908,53 +908,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
execute stmt1 ;
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -977,56 +935,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -3175,17 +3091,21 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t9;

View file

@ -909,53 +909,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
execute stmt1 ;
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -978,56 +936,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -3176,17 +3092,21 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t9;

View file

@ -951,53 +951,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
execute stmt1 ;
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -1020,56 +978,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -3115,19 +3031,23 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t9 ;
create table t1
(
@ -4039,53 +3959,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
execute stmt1 ;
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -4108,56 +3986,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
2 0 1 0
18 1 0 1
2 0 1 0
18 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -6203,18 +6039,22 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t1_1, t1_2,
t9_1, t9_2, t9;

View file

@ -908,53 +908,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
2.0000 0 1 0
18.0000 1 0 1
18.0000 1 0 1
execute stmt1 ;
scalar_s exists_s in_s in_row_s
2.0000 0 1 0
2.0000 0 1 0
18.0000 1 0 1
18.0000 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2
1 PRIMARY t9 ALL NULL NULL NULL NULL 3 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2
1 PRIMARY t9 ALL NULL NULL NULL NULL 3 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -977,56 +935,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
2 0 1 0
2 0 1 0
18 1 0 1
18 1 0 1
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
2 0 1 0
2 0 1 0
18 1 0 1
18 1 0 1
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2
1 PRIMARY t9 ALL NULL NULL NULL NULL 3 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2
1 PRIMARY t9 ALL NULL NULL NULL NULL 3 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -3175,17 +3091,21 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t9;

View file

@ -909,53 +909,11 @@ FROM t9,
(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 21 7 Y 32768 4 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
execute stmt1 ;
scalar_s exists_s in_s in_row_s
18.0000 1 0 1
2.0000 0 1 0
18.0000 1 0 1
2.0000 0 1 0
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
set @stmt= ' SELECT
(SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2
GROUP BY t9.c15 LIMIT 1) as scalar_s,
@ -978,56 +936,14 @@ set @arg09= 40e-1 ;
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def scalar_s 5 23 2 Y 32768 31 8
def exists_s 8 1 1 N 32769 0 8
def in_s 8 21 1 Y 32768 0 8
def in_row_s 8 21 1 Y 32768 0 8
scalar_s exists_s in_s in_row_s
18 1 0 1
2 0 1 0
18 1 0 1
2 0 1 0
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
scalar_s exists_s in_s in_row_s
18 1 0 1
2 0 1 0
18 1 0 1
2 0 1 0
set @stmt= concat('explain ',@stmt);
prepare stmt1 from @stmt ;
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def id 8 3 1 N 32801 0 8
def select_type 253 19 18 N 1 31 8
def table 253 64 10 N 1 31 8
def type 253 10 3 N 1 31 8
def possible_keys 253 4096 0 Y 0 31 8
def key 253 64 0 Y 0 31 8
def key_len 8 3 0 Y 32800 0 8
def ref 253 1024 0 Y 0 31 8
def rows 8 10 1 N 32801 0 8
def Extra 253 255 44 N 1 31 8
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,
@arg07, @arg08, @arg09 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t9 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived6> ALL NULL NULL NULL NULL 2 Using where
6 DERIVED t2 ALL NULL NULL NULL NULL 2
5 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
drop table t2 ;
select 1 < (select a from t1) ;
ERROR 21000: Subquery returns more than 1 row
@ -3154,17 +3070,21 @@ found
true
set @arg00= 1.991e+3 ;
select 'true' as found from t9
where c1= 20 and c17= 1.991e+3 ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ;
found
true
select 'true' as found from t9
where c1= 20 and c17= @arg00 ;
where c1= 20 and abs(c17 - @arg00) < 0.01 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= 1.991e+3" ;
where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c17= ?" ;
where c1= 20 and abs(c17 - ?) < 0.01" ;
execute stmt1 using @arg00 ;
found
true
drop table t1, t9;

View 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"á");
set CHARACTER SET koi8r;
select * from t1;
a
á
set CHARACTER SET cp1251_koi8;
select * from t1;
a
À
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'á'),(_koi8r'Á');
SELECT a,'Â','â'='Â' FROM t1;
a б 'Б'='б'
á Â 1
Á Â 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,'Â','â'='Â' FROM t1;
a б 'Б'='б'
á Â 0
Á Â 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,'Â','â'='Â' FROM t1;
a Р'в'='В'
á ÷ 0
Á ÷ 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,'Â','â'='Â' FROM t1;
a Р'в'='В'
À Â 0
à Â 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;

File diff suppressed because it is too large Load diff

View 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;

View 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;

View 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;

View file

@ -0,0 +1,2 @@
-- disable_result_log
--exec ../tests/client_test --testcase --user=root --socket=var/tmp/master.sock --port=$MYSQL_TCP_PORT

View file

@ -47,6 +47,71 @@ select * from t1 order by col1;
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
show table status;
select * from t1 order by col1;
delete from t1;
insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
SET SQL_MODE='';
insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
alter table t1 drop column col4_5;
insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
drop table t1;
#
# Check that invalidating dictionary cache works
#
CREATE TABLE t1 (
a INT NOT NULL,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (9410,9412);
connect (con1,localhost,,,test);
connect (con2,localhost,,,test);
connection con1;
ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1 order by a;
connection con2;
select * from t1 order by a;
alter table t1 drop c;
connection con1;
select * from t1 order by a;
drop table t1;
connection con2;
--error 1146
select * from t1 order by a;
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1 order by a;
alter table t1 modify column a int not null auto_increment;
select * from t1 order by a;
INSERT INTO t1 VALUES (0,19),(20,21);
select * from t1 order by a;
drop table t1;
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1;
alter table t1 add c int not null unique auto_increment;
select * from t1 order by a;
INSERT INTO t1 VALUES (18,19,3),(20,21,0);
select * from t1 order by a;
drop table t1;
#--disable_warnings

View file

@ -0,0 +1,159 @@
--source include/have_ndb.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
#
# Minimal NDB charset test.
#
# pk - binary
create table t1 (
a char(3) character set latin1 collate latin1_bin primary key
) engine=ndb;
# ok
insert into t1 values('aAa');
insert into t1 values('aaa');
insert into t1 values('AAA');
# 3
select * from t1 order by a;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 0
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# pk - case insensitive
create table t1 (
a char(3) character set latin1 collate latin1_swedish_ci primary key
) engine=ndb;
# ok
insert into t1 values('aAa');
# fail
--error 1062
insert into t1 values('aaa');
--error 1062
insert into t1 values('AAA');
# 1
select * from t1 order by a;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 1
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# unique hash index - binary
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
unique key(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
# 3
select * from t1 order by p;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 0
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# unique hash index - case insensitive
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_swedish_ci not null,
unique key(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
# fail
--error 1169
insert into t1 values(2, 'aaa');
--error 1169
insert into t1 values(3, 'AAA');
# 1
select * from t1 order by p;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 1
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# ordered index - binary
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
index(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
insert into t1 values(4, 'aAa');
insert into t1 values(5, 'aaa');
insert into t1 values(6, 'AAA');
# 6
select * from t1 order by p;
# plan
explain select * from t1 where a = 'zZz' order by p;
# 2
select * from t1 where a = 'aAa' order by p;
# 2
select * from t1 where a = 'aaa' order by p;
# 0
select * from t1 where a = 'AaA' order by p;
# 2
select * from t1 where a = 'AAA' order by p;
drop table t1;
# ordered index - case insensitive
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_swedish_ci not null,
index(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
insert into t1 values(4, 'aAa');
insert into t1 values(5, 'aaa');
insert into t1 values(6, 'AAA');
# 6
select * from t1 order by p;
# plan
explain select * from t1 where a = 'zZz' order by p;
# 6
select * from t1 where a = 'aAa' order by p;
# 6
select * from t1 where a = 'aaa' order by p;
# 6
select * from t1 where a = 'AaA' order by p;
# 6
select * from t1 where a = 'AAA' order by p;
drop table t1;

View file

@ -9,7 +9,7 @@ CREATE TABLE t1 (
ACCESSNODE varchar(16) NOT NULL,
POP varchar(48) NOT NULL,
ACCESSTYPE int unsigned NOT NULL,
CUSTOMER_ID varchar(20) NOT NULL,
CUSTOMER_ID varchar(20) collate latin1_bin NOT NULL,
PROVIDER varchar(16),
TEXPIRE int unsigned,
NUM_IP int unsigned,

View file

@ -3,7 +3,7 @@ LDADD += $(top_builddir)/ndb/test/src/libNDBT.a \
$(top_builddir)/ndb/src/libndbclient.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include \

View file

@ -3,7 +3,7 @@ LDADD += \
$(top_builddir)/ndb/src/libndbclient.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include \

View file

@ -46,9 +46,9 @@
*
* NdbDictionary::Column
* setName()
* setPrimaryKey()
* setType()
* setLength()
* setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
@ -234,9 +234,9 @@ int create_table(Ndb * myNdb)
* Column REG_NO
*/
myColumn.setName("REG_NO");
myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@ -244,9 +244,9 @@ int create_table(Ndb * myNdb)
* Column BRAND
*/
myColumn.setName("BRAND");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@ -254,9 +254,9 @@ int create_table(Ndb * myNdb)
* Column COLOR
*/
myColumn.setName("COLOR");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@ -454,6 +454,7 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB" ); // Object representing the database
/*******************************************
@ -493,5 +494,3 @@ int main()
std::cout << "Number of temporary errors: " << tempErrors << std::endl;
delete myNdb;
}

View file

@ -44,6 +44,7 @@
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_1" ); // Object representing the database
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
@ -78,16 +79,16 @@ int main()
myTable.setName("MYTABLENAME");
myColumn.setName("ATTR1");
myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("ATTR2");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);

View file

@ -39,6 +39,7 @@ static void callback(int result, NdbConnection* NdbObject, void* aObject);
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_2" ); // Object representing the database
NdbConnection* myNdbConnection[2]; // For transactions

View file

@ -176,6 +176,7 @@ int executeInsertTransaction(int transactionId, Ndb* myNdb) {
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_1" ); // Object representing the database
/*******************************************

View file

@ -44,6 +44,7 @@
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB_1" ); // Object representing the database
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
@ -79,16 +80,16 @@ int main()
myTable.setName("MYTABLENAME");
myColumn.setName("ATTR1");
myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("ATTR2");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);

View file

@ -65,6 +65,7 @@ int myCreateEvent(Ndb* myNdb,
int main()
{
ndb_init();
Ndb* myNdb = myCreateNdb();
NdbDictionary::Dictionary *myDict;

View file

@ -47,9 +47,9 @@
*
* NdbDictionary::Column
* setName()
* setPrimaryKey()
* setType()
* setLength()
* setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
@ -165,24 +165,24 @@ int create_table(Ndb * myNdb)
myTable.setName("GARAGE");
myColumn.setName("REG_NO");
myColumn.setPrimaryKey(true);
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("BRAND");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("COLOR");
myColumn.setPrimaryKey(false);
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
@ -761,6 +761,7 @@ int scan_print(Ndb * myNdb, int parallelism,
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB" ); // Object representing the database
@ -813,4 +814,3 @@ int main()
delete myNdb;
}

View file

@ -112,6 +112,7 @@ const char* ResultSetContainer::getAttrName(int i) const {return m_names[i];}
int main(int argc, const char** argv)
{
ndb_init();
Ndb* myNdb = new Ndb("ndbapi_example4"); // Object representing the database
NdbConnection* myNdbConnection; // For transactions
NdbOperation* myNdbOperation; // For operations

View file

@ -24,6 +24,32 @@
#include <kernel/LogLevel.hpp>
#include <signaldata/EventReport.hpp>
class EventLoggerBase {
public:
virtual ~EventLoggerBase();
/**
* LogLevel settings
*/
LogLevel m_logLevel;
/**
* This matrix defines which event should be printed when
*
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
struct EventRepLogLevelMatrix {
EventReport::EventType eventType;
LogLevel::EventCategory eventCategory;
Uint32 threshold;
Logger::LoggerLevel severity;
};
static const EventRepLogLevelMatrix matrix[];
static const Uint32 matrixSize;
};
/**
* The EventLogger is primarily used for logging NDB events
* in the Management Server. It inherits all logging functionality of Logger.
@ -58,7 +84,7 @@
* @see Logger
* @version #@ $Id: EventLogger.hpp,v 1.3 2003/09/01 10:15:52 innpeno Exp $
*/
class EventLogger : public Logger
class EventLogger : public EventLoggerBase, public Logger
{
public:
/**
@ -70,7 +96,7 @@ public:
/**
* Destructor.
*/
~EventLogger();
virtual ~EventLogger();
/**
* Opens/creates the eventlog with the specified filename.
@ -92,16 +118,6 @@ public:
*/
void close();
/**
* Logs the NDB event.
*
* @param nodeId the node id of event origin.
* @param eventType the type of event.
* @param theData the event data.
* @deprecated use log(int eventType, const Uint32* theData, NodeId nodeId)
*/
void log(NodeId nodeId, int eventType, const Uint32* theData);
/**
* Logs the NDB event.
*
@ -109,32 +125,8 @@ public:
* @param theData the event data.
* @param nodeId the node id of event origin.
*/
void log(int eventType, const Uint32* theData, NodeId nodeId = 0);
/**
* Returns the current log levels.
* Enable, disable log levels to filter the events that are sent to the
* eventlog.
*
* @return the log level.
*/
LogLevel& getLoglevel();
virtual void log(int, const Uint32*, NodeId = 0,const class LogLevel * = 0);
/**
* Returns the log level that is used to filter an event. The event will not
* be logged unless its event category's log level is <= levelFilter.
*
* @return the log level filter that is used for all event categories.
*/
int getFilterLevel() const;
/**
* Sets log level filter. The event will be logged if
* the event category's log level is <= 'filterLevel'.
*
* @param level the log level to filter.
*/
void setFilterLevel(int filterLevel);
/**
* Returns the event text for the specified event report type.
*
@ -143,72 +135,25 @@ public:
* @param nodeId a node id.
* @return the event report text.
*/
static const char* getText(int type,
static const char* getText(char * dst, size_t dst_len,
int type,
const Uint32* theData, NodeId nodeId = 0);
/**
* Find a category matching the string
*
* @param str string to match.
* @param cat the event category.
* @param exactMatch only do exact matching.
*
* @return TRUE if match is found, then cat is modified
* FALSE if match is not found
*/
static bool matchEventCategory(const char * str,
LogLevel::EventCategory * cat,
bool exactMatch = false);
/**
* Returns category name or NULL if not found.
* Returns the log level that is used to filter an event. The event will not
* be logged unless its event category's log level is <= levelFilter.
*
* @param cat the event category.
* @return category name.
* @return the log level filter that is used for all event categories.
*/
static const char * getEventCategoryName(LogLevel::EventCategory cat);
int getFilterLevel() const;
/**
* Specifies allowed event categories/log levels.
*/
struct EventCategoryName {
LogLevel::EventCategory category;
const char * name;
};
static const EventCategoryName eventCategoryNames[];
static const Uint32 noOfEventCategoryNames;
/**
* This matrix defines which event should be printed when
* Sets log level filter. The event will be logged if
* the event category's log level is <= 'filterLevel'.
*
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
struct EventRepLogLevelMatrix {
EventReport::EventType eventType;
LogLevel::EventCategory eventCategory;
Uint32 threshold;
Logger::LoggerLevel severity;
};
static const EventRepLogLevelMatrix matrix[];
/**
* Default log levels for management nodes.
*
* threshold - is in range [0-15]
* @param level the log level to filter.
*/
struct EventLogMatrix {
LogLevel::EventCategory eventCategory;
Uint32 threshold;
};
static const EventLogMatrix defEventLogMatrix[];
static const Uint32 matrixSize;
static const Uint32 defEventLogMatrixSize;
void setFilterLevel(int filterLevel);
private:
/** Prohibit */
@ -216,11 +161,10 @@ private:
EventLogger operator = (const EventLogger&);
bool operator == (const EventLogger&);
LogLevel m_logLevel;
Uint32 m_filterLevel;
STATIC_CONST(MAX_TEXT_LENGTH = 256);
static char m_text[MAX_TEXT_LENGTH];
char m_text[MAX_TEXT_LENGTH];
};

View file

@ -45,81 +45,30 @@ public:
* Copy operator
*/
LogLevel & operator= (const LogLevel &);
static const Uint32 MIN_LOGLEVEL_ID = CFG_LOGLEVEL_STARTUP;
enum EventCategory {
/**
* Events during all kind of startups
*/
llStartUp = CFG_LOGLEVEL_STARTUP - MIN_LOGLEVEL_ID,
/**
* Events during shutdown
*/
llShutdown = CFG_LOGLEVEL_SHUTDOWN - MIN_LOGLEVEL_ID,
/**
* Transaction statistics
* Job level
* TCP/IP speed
*/
llStatistic = CFG_LOGLEVEL_STATISTICS - MIN_LOGLEVEL_ID,
/**
* Checkpoints
*/
llCheckpoint = CFG_LOGLEVEL_CHECKPOINT - MIN_LOGLEVEL_ID,
/**
* Events during node restart
*/
llNodeRestart = CFG_LOGLEVEL_NODERESTART - MIN_LOGLEVEL_ID,
/**
* Events related to connection / communication
*/
llConnection = CFG_LOGLEVEL_CONNECTION - MIN_LOGLEVEL_ID,
/**
* Assorted event w.r.t unexpected happenings
*/
llError = CFG_LOGLEVEL_ERROR - MIN_LOGLEVEL_ID,
/**
* Assorted event w.r.t warning
*/
llWarning = CFG_LOGLEVEL_WARNING - MIN_LOGLEVEL_ID,
/**
* Assorted event w.r.t information
*/
llInfo = CFG_LOGLEVEL_INFO - MIN_LOGLEVEL_ID,
/**
* Events related to global replication
*/
llGrep = CFG_LOGLEVEL_GREP - MIN_LOGLEVEL_ID
llStartUp = CFG_LOGLEVEL_STARTUP - CFG_MIN_LOGLEVEL,
llShutdown = CFG_LOGLEVEL_SHUTDOWN - CFG_MIN_LOGLEVEL,
llStatistic = CFG_LOGLEVEL_STATISTICS - CFG_MIN_LOGLEVEL,
llCheckpoint = CFG_LOGLEVEL_CHECKPOINT - CFG_MIN_LOGLEVEL,
llNodeRestart = CFG_LOGLEVEL_NODERESTART - CFG_MIN_LOGLEVEL,
llConnection = CFG_LOGLEVEL_CONNECTION - CFG_MIN_LOGLEVEL,
llInfo = CFG_LOGLEVEL_INFO - CFG_MIN_LOGLEVEL,
llWarning = CFG_LOGLEVEL_WARNING - CFG_MIN_LOGLEVEL,
llError = CFG_LOGLEVEL_ERROR - CFG_MIN_LOGLEVEL,
llGrep = CFG_LOGLEVEL_GREP - CFG_MIN_LOGLEVEL,
llDebug = CFG_LOGLEVEL_DEBUG - CFG_MIN_LOGLEVEL
,llBackup = CFG_LOGLEVEL_BACKUP - CFG_MIN_LOGLEVEL
};
struct LogLevelCategoryName {
const char* name;
};
/**
* Log/event level category names. Remember to update the names whenever
* a new category is added.
*/
static const LogLevelCategoryName LOGLEVEL_CATEGORY_NAME[];
/**
* No of categories
*/
#define _LOGLEVEL_CATEGORIES 10
#define _LOGLEVEL_CATEGORIES (CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1);
static const Uint32 LOGLEVEL_CATEGORIES = _LOGLEVEL_CATEGORIES;
void clear();
/**
* Note level is valid as 0-15
*/
@ -130,26 +79,33 @@ public:
*/
Uint32 getLogLevel(EventCategory ec) const;
/**
* Set this= max(this, ll) per category
*/
LogLevel& set_max(const LogLevel& ll);
bool operator==(const LogLevel& l) const {
return memcmp(this, &l, sizeof(* this)) == 0;
}
LogLevel& operator=(const class EventSubscribeReq & req);
private:
/**
* The actual data
*/
Uint32 logLevelData[LOGLEVEL_CATEGORIES];
LogLevel(const LogLevel &);
Uint8 logLevelData[LOGLEVEL_CATEGORIES];
};
inline
LogLevel::LogLevel(){
clear();
clear();
}
inline
LogLevel &
LogLevel::operator= (const LogLevel & org){
for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
logLevelData[i] = org.logLevelData[i];
}
memcpy(logLevelData, org.logLevelData, sizeof(logLevelData));
return * this;
}
@ -165,7 +121,7 @@ inline
void
LogLevel::setLogLevel(EventCategory ec, Uint32 level){
assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
logLevelData[ec] = level;
logLevelData[ec] = (Uint8)level;
}
inline
@ -173,8 +129,30 @@ Uint32
LogLevel::getLogLevel(EventCategory ec) const{
assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
return logLevelData[ec];
return (Uint32)logLevelData[ec];
}
inline
LogLevel &
LogLevel::set_max(const LogLevel & org){
for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
if(logLevelData[i] < org.logLevelData[i])
logLevelData[i] = org.logLevelData[i];
}
return * this;
}
#include <signaldata/EventSubscribeReq.hpp>
inline
LogLevel&
LogLevel::operator=(const EventSubscribeReq& req)
{
clear();
for(size_t i = 0; i<req.noOfEntries; i++){
logLevelData[(req.theData[i] >> 16)] = req.theData[i] & 0xFFFF;
}
return * this;
}
#endif

View file

@ -89,7 +89,8 @@ public:
ArraySizeTooBig = 737,
RecordTooBig = 738,
InvalidPrimaryKeySize = 739,
NullablePrimaryKey = 740
NullablePrimaryKey = 740,
InvalidCharset = 743
};
private:

View file

@ -438,8 +438,8 @@ public:
case DictTabInfo::ExtText:
AttributeType = DictTabInfo::StringType;
AttributeSize = DictTabInfo::an8Bit;
// head + inline part [ attr precision ]
AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + AttributeExtPrecision;
// head + inline part [ attr precision lower half ]
AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF);
return true;
};
return false;

View file

@ -135,12 +135,17 @@ public:
//GREP
GrepSubscriptionInfo = 52,
GrepSubscriptionAlert = 53
};
GrepSubscriptionAlert = 53,
//BACKUP
BackupStarted = 54,
BackupFailedToStart = 55,
BackupCompleted = 56,
BackupAborted = 57
};
void setEventType(EventType type);
EventType getEventType() const;
private:
UintR eventType; // DATA 0
};

View file

@ -27,7 +27,7 @@
* RECIVER: SimBlockCMCtrBlck
*/
class EventSubscribeReq {
struct EventSubscribeReq {
/**
* Receiver(s)
*/
@ -38,9 +38,8 @@ class EventSubscribeReq {
*/
friend class MgmtSrvr;
public:
STATIC_CONST( SignalLength = 22 );
private:
STATIC_CONST( SignalLength = 2 + LogLevel::LOGLEVEL_CATEGORIES );
/**
* Note: If you use the same blockRef as you have used earlier,
* you update your ongoing subscription
@ -53,8 +52,15 @@ private:
*/
Uint32 noOfEntries;
Uint32 theCategories[10];
Uint32 theLevels[10];
Uint32 theData[LogLevel::LOGLEVEL_CATEGORIES];
EventSubscribeReq& operator= (const LogLevel& ll){
noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
for(size_t i = 0; i<noOfEntries; i++){
theData[i] = (i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);
}
return * this;
}
};
#endif

View file

@ -130,7 +130,7 @@ private:
Uint32 keyLength;
Uint32 nextLCP;
Uint32 noOfKeyAttr;
Uint32 noOfNewAttr;
Uint32 noOfNewAttr; // noOfCharsets in upper half
Uint32 checksumIndicator;
Uint32 noOfAttributeGroups;
Uint32 GCPIndicator;

View file

@ -18,6 +18,7 @@
#define SET_LOGLEVEL_ORD_HPP
#include <LogLevel.hpp>
#include "EventSubscribeReq.hpp"
#include "SignalData.hpp"
/**
@ -39,11 +40,10 @@ class SetLogLevelOrd {
friend class NodeLogLevel;
private:
STATIC_CONST( SignalLength = 25 );
STATIC_CONST( SignalLength = 1 + LogLevel::LOGLEVEL_CATEGORIES );
Uint32 noOfEntries;
Uint32 theCategories[12];
Uint32 theLevels[12];
Uint32 theData[LogLevel::LOGLEVEL_CATEGORIES];
void clear();
@ -51,6 +51,22 @@ private:
* Note level is valid as 0-15
*/
void setLogLevel(LogLevel::EventCategory ec, int level = 7);
SetLogLevelOrd& operator= (const LogLevel& ll){
noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
for(size_t i = 0; i<noOfEntries; i++){
theData[i] = (i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);
}
return * this;
}
SetLogLevelOrd& operator= (const EventSubscribeReq& ll){
noOfEntries = ll.noOfEntries;
for(size_t i = 0; i<noOfEntries; i++){
theData[i] = ll.theData[i];
}
return * this;
}
};
inline
@ -62,9 +78,7 @@ SetLogLevelOrd::clear(){
inline
void
SetLogLevelOrd::setLogLevel(LogLevel::EventCategory ec, int level){
assert(noOfEntries < 12);
theCategories[noOfEntries] = ec;
theLevels[noOfEntries] = level;
theData[noOfEntries] = (ec << 16) | level;
noOfEntries++;
}

View file

@ -119,12 +119,13 @@ class TupAddAttrReq {
friend class Dblqh;
friend class Dbtux;
public:
STATIC_CONST( SignalLength = 4 );
STATIC_CONST( SignalLength = 5 );
private:
Uint32 tupConnectPtr;
Uint32 notused1;
Uint32 attrId;
Uint32 attrDescriptor;
Uint32 extTypeInfo;
};
class TupAddAttrConf {
@ -141,6 +142,10 @@ class TupAddAttrRef {
friend class Dbtup;
public:
STATIC_CONST( SignalLength = 2 );
enum ErrorCode {
NoError = 0,
InvalidCharset = 743
};
private:
Uint32 userPtr;
Uint32 errorCode;
@ -178,7 +183,8 @@ public:
STATIC_CONST( SignalLength = 2 );
enum ErrorCode {
NoError = 0,
InvalidAttributeType = 831,
InvalidAttributeType = 742,
InvalidCharset = 743,
InvalidNodeSize = 832
};
private:

View file

@ -55,24 +55,6 @@
extern "C" {
#endif
/**
* Format of statistical information from the NDB Cluster.
* STATISTIC_LINE is sent on the statistical port from the Management server,
* each line is timestamped with STATISTIC_DATE.
*/
#define STATISTIC_LINE "date=%s epochsecs=%d nodeid=%u trans=%u commit=%u " \
"read=%u insert=%u attrinfo=%u cops=%u abort=%u"
/**
* Format of statistical information from the NDB Cluster.
* STATISTIC_LINE is sent on the statistical port from the Management server,
* each line is timestamped with STATISTIC_DATE.
*/
#define STATISTIC_DATE "%d-%.2d-%.2d/%.2d:%.2d:%.2d"
/**
* Format of statistical information from the NDB Cluster.
*/
#define OP_STATISTIC_LINE "date=%s epochsecs=%d nodeid=%d operations=%u"
/**
* The NdbMgmHandle.
*/
@ -272,19 +254,35 @@ extern "C" {
* Log categories
*/
enum ndb_mgm_event_category {
NDB_MGM_EVENT_CATEGORY_STARTUP, ///< Events during all kinds
///< of startups
NDB_MGM_EVENT_CATEGORY_SHUTDOWN, ///< Events during shutdown
NDB_MGM_EVENT_CATEGORY_STATISTIC, ///< Transaction statistics
///< (Job level, TCP/IP speed)
NDB_MGM_EVENT_CATEGORY_CHECKPOINT, ///< Checkpoints
NDB_MGM_EVENT_CATEGORY_NODE_RESTART, ///< Events during node restart
NDB_MGM_EVENT_CATEGORY_CONNECTION, ///< Events related to connection
///< and communication
NDB_MGM_EVENT_CATEGORY_ERROR ///< Assorted event w.r.t.
///< unexpected happenings
};
NDB_MGM_ILLEGAL_EVENT_CATEGORY = -1, ///< Invalid
/**
* Events during all kinds of startups
*/
NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP,
/**
* Events during shutdown
*/
NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN,
/**
* Transaction statistics (Job level, TCP/IP speed)
*/
NDB_MGM_EVENT_CATEGORY_STATISTIC = CFG_LOGLEVEL_STATISTICS,
NDB_MGM_EVENT_CATEGORY_CHECKPOINT = CFG_LOGLEVEL_CHECKPOINT,
NDB_MGM_EVENT_CATEGORY_NODE_RESTART = CFG_LOGLEVEL_NODERESTART,
NDB_MGM_EVENT_CATEGORY_CONNECTION = CFG_LOGLEVEL_CONNECTION,
NDB_MGM_EVENT_CATEGORY_DEBUG = CFG_LOGLEVEL_DEBUG,
NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO,
NDB_MGM_EVENT_CATEGORY_WARNING = CFG_LOGLEVEL_WARNING,
NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR,
NDB_MGM_EVENT_CATEGORY_GREP = CFG_LOGLEVEL_GREP,
NDB_MGM_EVENT_CATEGORY_BACKUP = CFG_LOGLEVEL_BACKUP,
NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL,
NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL
};
/***************************************************************************/
/**
* @name Functions: Error Handling
@ -420,6 +418,9 @@ extern "C" {
*/
const char * ndb_mgm_get_node_status_string(enum ndb_mgm_node_status status);
ndb_mgm_event_category ndb_mgm_match_event_category(const char *);
const char * ndb_mgm_get_event_category_string(enum ndb_mgm_event_category);
/** @} *********************************************************************/
/**
* @name Functions: State of cluster
@ -580,8 +581,7 @@ extern "C" {
*/
int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle,
int nodeId,
/*enum ndb_mgm_event_category category*/
char * category,
enum ndb_mgm_event_category category,
int level,
struct ndb_mgm_reply* reply);
@ -597,8 +597,7 @@ extern "C" {
*/
int ndb_mgm_set_loglevel_node(NdbMgmHandle handle,
int nodeId,
/*enum ndb_mgm_event_category category*/
char * category,
enum ndb_mgm_event_category category,
int level,
struct ndb_mgm_reply* reply);
@ -669,6 +668,15 @@ extern "C" {
int ndb_mgm_exit_single_user(NdbMgmHandle handle,
struct ndb_mgm_reply* reply);
/**
* Listen event
*
* @param filter pairs of { level, category } that will be
* pushed to fd, level=0 ends lists
* @return fd which events will be pushed to
*/
int ndb_mgm_listen_event(NdbMgmHandle handle, int filter[]);
/**
* Get configuration
* @param handle NDB management handle.

View file

@ -1,7 +1,6 @@
#ifndef MGMAPI_CONFIG_PARAMTERS_H
#define MGMAPI_CONFIG_PARAMTERS_H
#define CFG_SYS_NAME 3
#define CFG_SYS_PRIMARY_MGM_NODE 1
#define CFG_SYS_CONFIG_GENERATION 2
@ -64,16 +63,6 @@
#define CFG_DB_BACKUP_LOG_BUFFER_MEM 135
#define CFG_DB_BACKUP_WRITE_SIZE 136
#define CFG_LOGLEVEL_STARTUP 137
#define CFG_LOGLEVEL_SHUTDOWN 138
#define CFG_LOGLEVEL_STATISTICS 139
#define CFG_LOGLEVEL_CHECKPOINT 140
#define CFG_LOGLEVEL_NODERESTART 141
#define CFG_LOGLEVEL_CONNECTION 142
#define CFG_LOGLEVEL_INFO 143
#define CFG_LOGLEVEL_WARNING 144
#define CFG_LOGLEVEL_ERROR 145
#define CFG_LOGLEVEL_GREP 146
#define CFG_LOG_DESTINATION 147
#define CFG_DB_DISCLESS 148
@ -95,6 +84,21 @@
#define CFG_NODE_ARBIT_RANK 200
#define CFG_NODE_ARBIT_DELAY 201
#define CFG_MIN_LOGLEVEL 250
#define CFG_LOGLEVEL_STARTUP 250
#define CFG_LOGLEVEL_SHUTDOWN 251
#define CFG_LOGLEVEL_STATISTICS 252
#define CFG_LOGLEVEL_CHECKPOINT 253
#define CFG_LOGLEVEL_NODERESTART 254
#define CFG_LOGLEVEL_CONNECTION 255
#define CFG_LOGLEVEL_INFO 256
#define CFG_LOGLEVEL_WARNING 257
#define CFG_LOGLEVEL_ERROR 258
#define CFG_LOGLEVEL_GREP 259
#define CFG_LOGLEVEL_DEBUG 260
#define CFG_LOGLEVEL_BACKUP 261
#define CFG_MAX_LOGLEVEL 261
#define CFG_MGM_PORT 300
#define CFG_CONNECTION_NODE_1 400
@ -104,9 +108,9 @@
#define CFG_CONNECTION_NODE_1_SYSTEM 404
#define CFG_CONNECTION_NODE_2_SYSTEM 405
#define CFG_CONNECTION_SERVER_PORT 406
#define CFG_CONNECTION_HOSTNAME_1 407
#define CFG_CONNECTION_HOSTNAME_2 408
#define CFG_TCP_HOSTNAME_1 450
#define CFG_TCP_HOSTNAME_2 451
#define CFG_TCP_SERVER 452
#define CFG_TCP_SEND_BUFFER_SIZE 454
#define CFG_TCP_RECEIVE_BUFFER_SIZE 455
@ -117,19 +121,13 @@
#define CFG_SHM_KEY 502
#define CFG_SHM_BUFFER_MEM 503
#define CFG_SCI_ID_0 550
#define CFG_SCI_ID_1 551
#define CFG_SCI_SEND_LIMIT 552
#define CFG_SCI_BUFFER_MEM 553
#define CFG_SCI_NODE1_ADAPTERS 554
#define CFG_SCI_NODE1_ADAPTER0 555
#define CFG_SCI_NODE1_ADAPTER1 556
#define CFG_SCI_NODE2_ADAPTERS 554
#define CFG_SCI_NODE2_ADAPTER0 555
#define CFG_SCI_NODE2_ADAPTER1 556
#define CFG_SCI_HOST1_ID_0 550
#define CFG_SCI_HOST1_ID_1 551
#define CFG_SCI_HOST2_ID_0 552
#define CFG_SCI_HOST2_ID_1 553
#define CFG_SCI_SEND_LIMIT 554
#define CFG_SCI_BUFFER_MEM 555
#define CFG_OSE_HOSTNAME_1 600
#define CFG_OSE_HOSTNAME_2 601
#define CFG_OSE_PRIO_A_SIZE 602
#define CFG_OSE_PRIO_B_SIZE 603
#define CFG_OSE_RECEIVE_ARRAY_SIZE 604

View file

@ -28,19 +28,13 @@
*/
class ConfigRetriever {
public:
ConfigRetriever(Uint32 version, Uint32 nodeType);
ConfigRetriever(LocalConfig &local_config, Uint32 version, Uint32 nodeType);
~ConfigRetriever();
/**
* Read local config
* @return Own node id, -1 means fail
*/
int init();
int do_connect(int exit_on_connect_failure= false);
/**
* Get configuration for current (nodeId given in local config file) node.
* Get configuration for current node.
*
* Configuration is fetched from one MGM server configured in local config
* file. The method loops over all the configured MGM servers and tries
@ -54,16 +48,6 @@ public:
const char * getErrorString();
/**
* Sets connectstring which can be used instead of local config file
*/
void setConnectString(const char * connectString);
/**
* Sets name of local config file (usually not needed)
*/
void setLocalConfigFileName(const char * connectString);
/**
* @return Node id of this node (as stated in local config or connectString)
*/
@ -83,6 +67,9 @@ public:
* Verify config
*/
bool verifyConfig(const struct ndb_mgm_configuration *, Uint32 nodeid);
Uint32 get_mgmd_port() const {return m_mgmd_port;};
const char *get_mgmd_host() const {return m_mgmd_host;};
private:
BaseString errorString;
enum ErrorType {
@ -93,12 +80,11 @@ private:
void setError(ErrorType, const char * errorMsg);
BaseString _localConfigFileName;
struct LocalConfig _localConfig;
struct LocalConfig& _localConfig;
Uint32 _ownNodeId;
BaseString m_connectString;
Uint32 m_mgmd_port;
const char *m_mgmd_host;
Uint32 m_version;
Uint32 m_node_type;
NdbMgmHandle m_handle;

View file

@ -76,6 +76,10 @@ extern "C" {
#include <assert.h>
/* call in main() - does not return on error */
extern int ndb_init(void);
extern void ndb_end(int);
#ifndef HAVE_STRDUP
extern char * strdup(const char *s);
#endif

View file

@ -32,6 +32,8 @@
#include <ndb_types.h>
class Ndb;
struct charset_info_st;
typedef struct charset_info_st CHARSET_INFO;
/**
* @class NdbDictionary
@ -257,6 +259,10 @@ public:
/**
* Set type of column
* @param type Type of column
*
* @note setType resets <em>all</em> column attributes
* to (type dependent) defaults and should be the first
* method to call. Default type is Unsigned.
*/
void setType(Type type);
@ -301,28 +307,36 @@ public:
*/
int getLength() const;
/**
* For Char or Varchar or Text, set or get MySQL CHARSET_INFO. This
* specifies both character set and collation. See get_charset()
* etc in MySQL. (The cs is not "const" in MySQL).
*/
void setCharset(CHARSET_INFO* cs);
CHARSET_INFO* getCharset() const;
/**
* For blob, set or get "inline size" i.e. number of initial bytes
* to store in table's blob attribute. This part is normally in
* main memory and can be indexed and interpreted.
*/
void setInlineSize(int size) { setPrecision(size); }
int getInlineSize() const { return getPrecision(); }
void setInlineSize(int size);
int getInlineSize() const;
/**
* For blob, set or get "part size" i.e. number of bytes to store in
* each tuple of the "blob table". Can be set to zero to omit parts
* and to allow only inline bytes ("tinyblob").
*/
void setPartSize(int size) { setScale(size); }
int getPartSize() const { return getScale(); }
void setPartSize(int size);
int getPartSize() const;
/**
* For blob, set or get "stripe size" i.e. number of consecutive
* <em>parts</em> to store in each node group.
*/
void setStripeSize(int size) { setLength(size); }
int getStripeSize() const { return getLength(); }
void setStripeSize(int size);
int getStripeSize() const;
/**
* Get size of element

View file

@ -49,6 +49,15 @@ public:
* @{
*/
/**
* Define the NdbIndexOperation to be a standard operation of type readTuple.
* When calling NdbConnection::execute, this operation
* reads a tuple.
*
* @return 0 if successful otherwise -1.
*/
int readTuple(LockMode);
/**
* Define the NdbIndexOperation to be a standard operation of type readTuple.
* When calling NdbConnection::execute, this operation

View file

@ -51,6 +51,19 @@ public:
* @{
*/
/**
* Lock when performing read
*/
enum LockMode {
LM_Read = 0,
LM_Exclusive = 1,
LM_CommittedRead = 2,
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
LM_Dirty = 2
#endif
};
/**
* Define the NdbOperation to be a standard operation of type insertTuple.
* When calling NdbConnection::execute, this operation
@ -88,6 +101,15 @@ public:
*/
virtual int deleteTuple();
/**
* Define the NdbOperation to be a standard operation of type readTuple.
* When calling NdbConnection::execute, this operation
* reads a tuple.
*
* @return 0 if successful otherwise -1.
*/
virtual int readTuple(LockMode);
/**
* Define the NdbOperation to be a standard operation of type readTuple.
* When calling NdbConnection::execute, this operation

View file

@ -53,18 +53,6 @@ public:
IndexCursor = 2
};
/**
* Lock when performing scan
*/
enum LockMode {
LM_Read = 0,
LM_Exclusive = 1,
LM_CommittedRead = 2,
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
LM_Dirty = 2
#endif
};
/**
* Type of cursor
*/

View file

@ -19,6 +19,7 @@
#define CLUSTER_CONNECTION_HPP
class TransporterFacade;
class LocalConfig;
class ConfigRetriever;
class NdbThread;
@ -37,6 +38,7 @@ private:
void connect_thread();
char *m_connect_string;
TransporterFacade *m_facade;
LocalConfig *m_local_config;
ConfigRetriever *m_config_retriever;
NdbThread *m_connect_thread;
int (*m_connect_callback)(void);

View file

@ -59,8 +59,6 @@ struct TCP_TransporterConfiguration {
NodeId localNodeId;
Uint32 sendBufferSize; // Size of SendBuffer of priority B
Uint32 maxReceiveSize; // Maximum no of bytes to receive
Uint32 byteOrder;
bool compression;
bool checksum;
bool signalId;
};
@ -72,10 +70,8 @@ struct SHM_TransporterConfiguration {
Uint32 port;
NodeId remoteNodeId;
NodeId localNodeId;
bool compression;
bool checksum;
bool signalId;
int byteOrder;
Uint32 shmKey;
Uint32 shmSize;
@ -89,10 +85,8 @@ struct OSE_TransporterConfiguration {
const char *localHostName;
NodeId remoteNodeId;
NodeId localNodeId;
bool compression;
bool checksum;
bool signalId;
int byteOrder;
Uint32 prioASignalSize;
Uint32 prioBSignalSize;
@ -103,20 +97,20 @@ struct OSE_TransporterConfiguration {
* SCI Transporter Configuration
*/
struct SCI_TransporterConfiguration {
const char *remoteHostName;
const char *localHostName;
Uint32 port;
Uint32 sendLimit; // Packet size
Uint32 bufferSize; // Buffer size
Uint32 nLocalAdapters; // 1 or 2, the number of adapters on local host
Uint32 nRemoteAdapters;
Uint32 remoteSciNodeId0; // SCInodeId for adapter 1
Uint32 remoteSciNodeId1; // SCInodeId for adapter 2
NodeId localNodeId; // Local node Id
NodeId remoteNodeId; // Remote node Id
Uint32 byteOrder;
bool compression;
bool checksum;
bool signalId;

View file

@ -218,15 +218,18 @@ public:
void printState();
#endif
unsigned short m_service_port;
class Transporter_interface {
public:
unsigned short m_service_port;
const char *m_interface;
};
Vector<Transporter_interface> m_transporter_interface;
void add_transporter_interface(const char *interface, unsigned short port);
protected:
private:
void * callbackObj;
TransporterService *m_transporter_service;
char *m_interface_name;
struct NdbThread *m_start_clients_thread;
bool m_run_start_clients_thread;

View file

@ -40,11 +40,14 @@ public:
* Compare kernel attribute values. Returns -1, 0, +1 for less,
* equal, greater, respectively. Parameters are pointers to values,
* full attribute size in words, and size of available data in words.
* There is also pointer to type specific extra info. Char types
* receive CHARSET_INFO in it.
*
* If available size is less than full size, CmpUnknown may be
* returned. If a value cannot be parsed, it compares like NULL i.e.
* less than any valid value.
*/
typedef int Cmp(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size);
typedef int Cmp(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size);
enum CmpResult {
CmpLess = -1,
@ -55,6 +58,7 @@ public:
/**
* Kernel data types. Must match m_typeList in NdbSqlUtil.cpp.
* Now also must match types in NdbDictionary.
*/
struct Type {
enum Enum {
@ -90,6 +94,18 @@ public:
*/
static const Type& getType(Uint32 typeId);
/**
* Get type by id but replace char type by corresponding binary type.
*/
static const Type& getTypeBinary(Uint32 typeId);
/**
* Check character set.
*/
static bool usable_in_pk(Uint32 typeId, const void* cs);
static bool usable_in_hash_index(Uint32 typeId, const void* cs);
static bool usable_in_ordered_index(Uint32 typeId, const void* cs);
private:
/**
* List of all types. Must match Type::Enum.

View file

@ -76,7 +76,7 @@ public:
* then close the socket
* Returns true if succeding in binding
*/
bool tryBind(unsigned short port, const char * intface = 0) const;
static bool tryBind(unsigned short port, const char * intface = 0);
/**
* Setup socket

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@ SUBDIRS = signaldata
noinst_LTLIBRARIES = libtrace.la
libtrace_la_SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp LogLevel.cpp EventLogger.cpp GrepError.cpp
libtrace_la_SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp EventLogger.cpp GrepError.cpp
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_kernel.mk.am

View file

@ -18,6 +18,7 @@
#include <ndb_version.h>
#include <ConfigRetriever.hpp>
#include <SocketServer.hpp>
#include "LocalConfig.hpp"
#include <NdbSleep.h>
@ -44,11 +45,14 @@
//****************************************************************************
//****************************************************************************
ConfigRetriever::ConfigRetriever(Uint32 version, Uint32 node_type) {
ConfigRetriever::ConfigRetriever(LocalConfig &local_config,
Uint32 version, Uint32 node_type)
: _localConfig(local_config)
{
m_handle= 0;
m_version = version;
m_node_type = node_type;
_ownNodeId = _localConfig._ownNodeId;
}
ConfigRetriever::~ConfigRetriever(){
@ -63,23 +67,12 @@ ConfigRetriever::~ConfigRetriever(){
//****************************************************************************
//****************************************************************************
int
ConfigRetriever::init() {
if (!_localConfig.init(m_connectString.c_str(),
_localConfigFileName.c_str())){
setError(CR_ERROR, "error in retrieving contact info for mgmtsrvr");
_localConfig.printError();
_localConfig.printUsage();
return -1;
}
return _ownNodeId = _localConfig._ownNodeId;
}
int
ConfigRetriever::do_connect(int exit_on_connect_failure){
m_mgmd_port= 0;
m_mgmd_host= 0;
if(!m_handle)
m_handle= ndb_mgm_create_handle();
@ -96,10 +89,18 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){
BaseString tmp;
for (unsigned int i = 0; i<_localConfig.ids.size(); i++){
MgmtSrvrId * m = &_localConfig.ids[i];
DBUG_PRINT("info",("trying %s:%d",
m->name.c_str(),
m->port));
switch(m->type){
case MgmId_TCP:
tmp.assfmt("%s:%d", m->name.c_str(), m->port);
if (ndb_mgm_connect(m_handle, tmp.c_str()) == 0) {
m_mgmd_port= m->port;
m_mgmd_host= m->name.c_str();
DBUG_PRINT("info",("connected to ndb_mgmd at %s:%d",
m_mgmd_host,
m_mgmd_port));
return 0;
}
setError(CR_RETRY, ndb_mgm_get_latest_error_desc(m_handle));
@ -107,9 +108,10 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){
break;
}
}
if (exit_on_connect_failure)
return 1;
if(latestErrorType == CR_RETRY){
DBUG_PRINT("info",("CR_RETRY"));
if (exit_on_connect_failure)
return 1;
REPORT_WARNING("Failed to retrieve cluster configuration");
ndbout << "(Cause of failure: " << getErrorString() << ")" << endl;
ndbout << "Attempt " << retry << " of " << retry_max << ". "
@ -124,6 +126,8 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){
ndb_mgm_destroy_handle(&m_handle);
m_handle= 0;
m_mgmd_port= 0;
m_mgmd_host= 0;
return -1;
}
@ -229,16 +233,6 @@ ConfigRetriever::getErrorString(){
return errorString.c_str();
}
void
ConfigRetriever::setLocalConfigFileName(const char * localConfigFileName) {
_localConfigFileName.assign(localConfigFileName ? localConfigFileName : "");
}
void
ConfigRetriever::setConnectString(const char * connectString) {
m_connectString.assign(connectString ? connectString : "");
}
bool
ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 nodeid){
@ -272,43 +266,15 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
NdbConfig_SetPath(datadir);
}
char localhost[MAXHOSTNAMELEN];
if(NdbHost_GetHostName(localhost) != 0){
snprintf(buf, 255, "Unable to get own hostname");
if (hostname && hostname[0] != 0 &&
!SocketServer::tryBind(0,hostname)) {
snprintf(buf, 255, "Config hostname(%s) don't match a local interface,"
" tried to bind, error = %d - %s",
hostname, errno, strerror(errno));
setError(CR_ERROR, buf);
return false;
}
do {
if(strlen(hostname) == 0)
break;
if(strcasecmp(hostname, localhost) == 0)
break;
if(strcasecmp(hostname, "localhost") == 0)
break;
struct in_addr local, config;
bool b1 = false, b2 = false, b3 = false;
b1 = Ndb_getInAddr(&local, localhost) == 0;
b2 = Ndb_getInAddr(&config, hostname) == 0;
b3 = memcmp(&local, &config, sizeof(local)) == 0;
if(b1 && b2 && b3)
break;
b1 = Ndb_getInAddr(&local, "localhost") == 0;
b3 = memcmp(&local, &config, sizeof(local)) == 0;
if(b1 && b2 && b3)
break;
snprintf(buf, 255, "Local hostname(%s) and config hostname(%s) dont match",
localhost, hostname);
setError(CR_ERROR, buf);
return false;
} while(false);
unsigned int _type;
if(ndb_mgm_get_int_parameter(it, CFG_TYPE_OF_SECTION, &_type)){
snprintf(buf, 255, "Unable to get type of node(%d) from config",
@ -344,7 +310,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
const char * name;
struct in_addr addr;
BaseString tmp;
if(!iter.get(CFG_TCP_HOSTNAME_1, &name) && strlen(name)){
if(!iter.get(CFG_CONNECTION_HOSTNAME_1, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d",
@ -354,7 +320,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
}
}
if(!iter.get(CFG_TCP_HOSTNAME_2, &name) && strlen(name)){
if(!iter.get(CFG_CONNECTION_HOSTNAME_2, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d",

View file

@ -133,7 +133,6 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
Uint32 compression;
Uint32 checksum;
if(!tmp->get("SendSignalId", &sendSignalId)) continue;
if(!tmp->get("Compression", &compression)) continue;
if(!tmp->get("Checksum", &checksum)) continue;
const char * type;
@ -143,8 +142,6 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
SHM_TransporterConfiguration conf;
conf.localNodeId = the_ownId;
conf.remoteNodeId = (nodeId1 != the_ownId ? nodeId1 : nodeId2);
conf.byteOrder = 0;
conf.compression = compression;
conf.checksum = checksum;
conf.signalId = sendSignalId;
@ -164,8 +161,6 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
SCI_TransporterConfiguration conf;
conf.localNodeId = the_ownId;
conf.remoteNodeId = (nodeId1 != the_ownId ? nodeId1 : nodeId2);
conf.byteOrder = 0;
conf.compression = compression;
conf.checksum = checksum;
conf.signalId = sendSignalId;
@ -174,18 +169,16 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
if(the_ownId == nodeId1){
if(!tmp->get("Node1_NoOfAdapters", &conf.nLocalAdapters)) continue;
if(!tmp->get("Node2_NoOfAdapters", &conf.nRemoteAdapters)) continue;
if(!tmp->get("Node2_Adapter", 0, &conf.remoteSciNodeId0)) continue;
if(conf.nRemoteAdapters > 1){
if(conf.nLocalAdapters > 1){
if(!tmp->get("Node2_Adapter", 1, &conf.remoteSciNodeId1)) continue;
}
} else {
if(!tmp->get("Node2_NoOfAdapters", &conf.nLocalAdapters)) continue;
if(!tmp->get("Node1_NoOfAdapters", &conf.nRemoteAdapters)) continue;
if(!tmp->get("Node1_Adapter", 0, &conf.remoteSciNodeId0)) continue;
if(conf.nRemoteAdapters > 1){
if(conf.nLocalAdapters > 1){
if(!tmp->get("Node1_Adapter", 1, &conf.remoteSciNodeId1)) continue;
}
}
@ -243,8 +236,6 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
conf.localHostName = ownHostName;
conf.remoteNodeId = remoteNodeId;
conf.localNodeId = ownNodeId;
conf.byteOrder = 0;
conf.compression = compression;
conf.checksum = checksum;
conf.signalId = sendSignalId;
@ -270,8 +261,6 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
conf.localHostName = ownHostName;
conf.remoteNodeId = remoteNodeId;
conf.localNodeId = ownNodeId;
conf.byteOrder = 0;
conf.compression = compression;
conf.checksum = checksum;
conf.signalId = sendSignalId;
@ -344,19 +333,29 @@ Uint32
IPCConfig::configureTransporters(Uint32 nodeId,
const class ndb_mgm_configuration & config,
class TransporterRegistry & tr){
DBUG_ENTER("IPCConfig::configureTransporters");
Uint32 noOfTransportersCreated= 0, server_port= 0;
Uint32 noOfTransportersCreated= 0;
ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION);
for(iter.first(); iter.valid(); iter.next()){
Uint32 nodeId1, nodeId2, remoteNodeId;
const char * remoteHostName= 0, * localHostName= 0;
if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue;
if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue;
if(nodeId1 != nodeId && nodeId2 != nodeId) continue;
remoteNodeId = (nodeId == nodeId1 ? nodeId2 : nodeId1);
{
const char * host1= 0, * host2= 0;
iter.get(CFG_CONNECTION_HOSTNAME_1, &host1);
iter.get(CFG_CONNECTION_HOSTNAME_2, &host2);
localHostName = (nodeId == nodeId1 ? host1 : host2);
remoteHostName = (nodeId == nodeId1 ? host2 : host1);
}
Uint32 sendSignalId = 1;
Uint32 checksum = 1;
if(iter.get(CFG_CONNECTION_SEND_SIGNAL_ID, &sendSignalId)) continue;
@ -365,71 +364,77 @@ IPCConfig::configureTransporters(Uint32 nodeId,
Uint32 type = ~0;
if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue;
Uint32 tmp_server_port= 0;
if(iter.get(CFG_CONNECTION_SERVER_PORT, &tmp_server_port)) break;
Uint32 server_port= 0;
if(iter.get(CFG_CONNECTION_SERVER_PORT, &server_port)) break;
if (nodeId <= nodeId1 && nodeId <= nodeId2) {
if (server_port && server_port != tmp_server_port) {
ndbout << "internal error in config setup of server ports line= " << __LINE__ << endl;
exit(-1);
}
server_port= tmp_server_port;
tr.add_transporter_interface(localHostName, server_port);
}
DBUG_PRINT("info", ("Transporter between this node %d and node %d using port %d, signalId %d, checksum %d",
nodeId, remoteNodeId, server_port, sendSignalId, checksum));
switch(type){
case CONNECTION_TYPE_SHM:{
SHM_TransporterConfiguration conf;
conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId;
conf.byteOrder = 0;
conf.compression = 0;
conf.checksum = checksum;
conf.signalId = sendSignalId;
if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break;
if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break;
conf.port= tmp_server_port;
conf.port= server_port;
if(!tr.createTransporter(&conf)){
DBUG_PRINT("error", ("Failed to create SHM Transporter from %d to %d",
conf.localNodeId, conf.remoteNodeId));
ndbout << "Failed to create SHM Transporter from: "
<< conf.localNodeId << " to: " << conf.remoteNodeId << endl;
} else {
noOfTransportersCreated++;
}
DBUG_PRINT("info", ("Created SHM Transporter using shmkey %d, buf size = %d",
conf.shmKey, conf.shmSize));
break;
}
case CONNECTION_TYPE_SCI:{
SCI_TransporterConfiguration conf;
conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId;
conf.byteOrder = 0;
conf.compression = 0;
conf.checksum = checksum;
conf.signalId = sendSignalId;
conf.port= server_port;
conf.localHostName = localHostName;
conf.remoteHostName = remoteHostName;
if(iter.get(CFG_SCI_SEND_LIMIT, &conf.sendLimit)) break;
if(iter.get(CFG_SCI_BUFFER_MEM, &conf.bufferSize)) break;
if(nodeId == nodeId1){
if(iter.get(CFG_SCI_NODE1_ADAPTERS, &conf.nLocalAdapters)) break;
if(iter.get(CFG_SCI_NODE2_ADAPTERS, &conf.nRemoteAdapters)) break;
if(iter.get(CFG_SCI_NODE2_ADAPTER0, &conf.remoteSciNodeId0)) break;
if(conf.nRemoteAdapters > 1){
if(iter.get(CFG_SCI_NODE2_ADAPTER1, &conf.remoteSciNodeId1)) break;
}
if (nodeId == nodeId1) {
if(iter.get(CFG_SCI_HOST2_ID_0, &conf.remoteSciNodeId0)) break;
if(iter.get(CFG_SCI_HOST2_ID_1, &conf.remoteSciNodeId1)) break;
} else {
if(iter.get(CFG_SCI_NODE2_ADAPTERS, &conf.nLocalAdapters)) break;
if(iter.get(CFG_SCI_NODE1_ADAPTERS, &conf.nRemoteAdapters)) break;
if(iter.get(CFG_SCI_NODE1_ADAPTER0, &conf.remoteSciNodeId0)) break;
if(conf.nRemoteAdapters > 1){
if(iter.get(CFG_SCI_NODE1_ADAPTER1, &conf.remoteSciNodeId1)) break;
}
if(iter.get(CFG_SCI_HOST1_ID_0, &conf.remoteSciNodeId0)) break;
if(iter.get(CFG_SCI_HOST1_ID_1, &conf.remoteSciNodeId1)) break;
}
if(!tr.createTransporter(&conf)){
if (conf.remoteSciNodeId1 == 0) {
conf.nLocalAdapters = 1;
} else {
conf.nLocalAdapters = 2;
}
if(!tr.createTransporter(&conf)){
DBUG_PRINT("error", ("Failed to create SCI Transporter from %d to %d",
conf.localNodeId, conf.remoteNodeId));
ndbout << "Failed to create SCI Transporter from: "
<< conf.localNodeId << " to: " << conf.remoteNodeId << endl;
} else {
DBUG_PRINT("info", ("Created SCI Transporter: Adapters = %d, remote SCI node id %d",
conf.nLocalAdapters, conf.remoteSciNodeId0));
DBUG_PRINT("info", ("Host 1 = %s, Host 2 = %s, sendLimit = %d, buf size = %d",
conf.localHostName, conf.remoteHostName, conf.sendLimit, conf.bufferSize));
if (conf.nLocalAdapters > 1) {
DBUG_PRINT("info", ("Fault-tolerant with 2 Remote Adapters, second remote SCI node id = %d",
conf.remoteSciNodeId1));
}
noOfTransportersCreated++;
continue;
}
@ -437,14 +442,10 @@ IPCConfig::configureTransporters(Uint32 nodeId,
case CONNECTION_TYPE_TCP:{
TCP_TransporterConfiguration conf;
const char * host1, * host2;
if(iter.get(CFG_TCP_HOSTNAME_1, &host1)) break;
if(iter.get(CFG_TCP_HOSTNAME_2, &host2)) break;
if(iter.get(CFG_TCP_SEND_BUFFER_SIZE, &conf.sendBufferSize)) break;
if(iter.get(CFG_TCP_RECEIVE_BUFFER_SIZE, &conf.maxReceiveSize)) break;
conf.port= tmp_server_port;
conf.port= server_port;
const char * proxy;
if (!iter.get(CFG_TCP_PROXY, &proxy)) {
if (strlen(proxy) > 0 && nodeId2 == nodeId) {
@ -455,10 +456,8 @@ IPCConfig::configureTransporters(Uint32 nodeId,
conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId;
conf.localHostName = (nodeId == nodeId1 ? host1 : host2);
conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1);
conf.byteOrder = 0;
conf.compression = 0;
conf.localHostName = localHostName;
conf.remoteHostName = remoteHostName;
conf.checksum = checksum;
conf.signalId = sendSignalId;
@ -468,23 +467,20 @@ IPCConfig::configureTransporters(Uint32 nodeId,
} else {
noOfTransportersCreated++;
}
DBUG_PRINT("info", ("Created TCP Transporter: sendBufferSize = %d, maxReceiveSize = %d",
conf.sendBufferSize, conf.maxReceiveSize));
break;
case CONNECTION_TYPE_OSE:{
OSE_TransporterConfiguration conf;
const char * host1, * host2;
if(iter.get(CFG_OSE_HOSTNAME_1, &host1)) break;
if(iter.get(CFG_OSE_HOSTNAME_2, &host2)) break;
if(iter.get(CFG_OSE_PRIO_A_SIZE, &conf.prioASignalSize)) break;
if(iter.get(CFG_OSE_PRIO_B_SIZE, &conf.prioBSignalSize)) break;
if(iter.get(CFG_OSE_RECEIVE_ARRAY_SIZE, &conf.receiveBufferSize)) break;
conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId;
conf.localHostName = (nodeId == nodeId1 ? host1 : host2);
conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1);
conf.byteOrder = 0;
conf.compression = 0;
conf.localHostName = localHostName;
conf.remoteHostName = remoteHostName;
conf.checksum = checksum;
conf.signalId = sendSignalId;
@ -502,9 +498,6 @@ IPCConfig::configureTransporters(Uint32 nodeId,
}
}
}
tr.m_service_port= server_port;
return noOfTransportersCreated;
DBUG_RETURN(noOfTransportersCreated);
}

View file

@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <NdbMutex.h>
#include <NdbTCP.h>
@ -27,13 +28,14 @@ static NdbMutex LOCK_gethostbyname = NDB_MUTEX_INITIALIZER;
extern "C"
int
Ndb_getInAddr(struct in_addr * dst, const char *address) {
DBUG_ENTER("Ndb_getInAddr");
struct hostent * hostPtr;
NdbMutex_Lock(&LOCK_gethostbyname);
hostPtr = gethostbyname(address);
if (hostPtr != NULL) {
dst->s_addr = ((struct in_addr *) *hostPtr->h_addr_list)->s_addr;
NdbMutex_Unlock(&LOCK_gethostbyname);
return 0;
DBUG_RETURN(0);
}
NdbMutex_Unlock(&LOCK_gethostbyname);
@ -47,9 +49,11 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) {
#endif
)
{
return 0;
DBUG_RETURN(0);
}
return -1;
DBUG_PRINT("error",("inet_addr(%s) - %d - %s",
address, errno, strerror(errno)));
DBUG_RETURN(-1);
}
#if 0

View file

@ -13,7 +13,7 @@ EXTRA_libtransporter_la_SOURCES = SHM_Transporter.cpp SHM_Transporter.unix.cpp S
libtransporter_la_LIBADD = @ndb_transporter_opt_objs@
libtransporter_la_DEPENDENCIES = @ndb_transporter_opt_objs@
INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/include/transporter
INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/include/transporter @NDB_SCI_INCLUDES@
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am

View file

@ -21,6 +21,7 @@
#include <TransporterCallback.hpp>
#include <RefConvert.hpp>
#define MAX_RECEIVED_SIGNALS 1024
Uint32
TransporterRegistry::unpack(Uint32 * readPtr,
Uint32 sizeOfData,
@ -30,12 +31,15 @@ TransporterRegistry::unpack(Uint32 * readPtr,
LinearSectionPtr ptr[3];
Uint32 usedData = 0;
Uint32 loop_count = 0;
if(state == NoHalt || state == HaltOutput){
while(sizeOfData >= 4 + sizeof(Protocol6)){
while ((sizeOfData >= 4 + sizeof(Protocol6)) &&
(loop_count < MAX_RECEIVED_SIGNALS)) {
Uint32 word1 = readPtr[0];
Uint32 word2 = readPtr[1];
Uint32 word3 = readPtr[2];
loop_count++;
#if 0
if(Protocol6::getByteOrder(word1) != MY_OWN_BYTE_ORDER){
@ -112,10 +116,12 @@ TransporterRegistry::unpack(Uint32 * readPtr,
} else {
/** state = HaltIO || state == HaltInput */
while(sizeOfData >= 4 + sizeof(Protocol6)){
while ((sizeOfData >= 4 + sizeof(Protocol6)) &&
(loop_count < MAX_RECEIVED_SIGNALS)) {
Uint32 word1 = readPtr[0];
Uint32 word2 = readPtr[1];
Uint32 word3 = readPtr[2];
loop_count++;
#if 0
if(Protocol6::getByteOrder(word1) != MY_OWN_BYTE_ORDER){
@ -208,12 +214,13 @@ TransporterRegistry::unpack(Uint32 * readPtr,
IOState state) {
static SignalHeader signalHeader;
static LinearSectionPtr ptr[3];
Uint32 loop_count = 0;
if(state == NoHalt || state == HaltOutput){
while(readPtr < eodPtr){
while ((readPtr < eodPtr) && (loop_count < MAX_RECEIVED_SIGNALS)) {
Uint32 word1 = readPtr[0];
Uint32 word2 = readPtr[1];
Uint32 word3 = readPtr[2];
loop_count++;
#if 0
if(Protocol6::getByteOrder(word1) != MY_OWN_BYTE_ORDER){
//Do funky stuff
@ -280,11 +287,11 @@ TransporterRegistry::unpack(Uint32 * readPtr,
} else {
/** state = HaltIO || state == HaltInput */
while(readPtr < eodPtr){
while ((readPtr < eodPtr) && (loop_count < MAX_RECEIVED_SIGNALS)) {
Uint32 word1 = readPtr[0];
Uint32 word2 = readPtr[1];
Uint32 word3 = readPtr[2];
loop_count++;
#if 0
if(Protocol6::getByteOrder(word1) != MY_OWN_BYTE_ORDER){
//Do funky stuff

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,7 @@
#include <ndb_types.h>
/**
/**
* The SCI Transporter
*
* The design goal of the SCI transporter is to deliver high performance
@ -135,15 +135,17 @@ public:
bool getConnectionStatus();
private:
SCI_Transporter(Uint32 packetSize,
SCI_Transporter(TransporterRegistry &t_reg,
const char *local_host,
const char *remote_host,
int port,
Uint32 packetSize,
Uint32 bufferSize,
Uint32 nAdapters,
Uint16 remoteSciNodeId0,
Uint16 remoteSciNodeId1,
NodeId localNodeID,
NodeId remoteNodeID,
int byteorder,
bool compression,
bool checksum,
bool signalId,
Uint32 reportFreq = 4096);
@ -160,7 +162,8 @@ private:
/**
* For statistics on transfered packets
*/
#ifdef DEBUG_TRANSPORTER
//#ifdef DEBUG_TRANSPORTER
#if 1
Uint32 i1024;
Uint32 i2048;
Uint32 i2049;
@ -177,10 +180,8 @@ private:
struct {
Uint32 * m_buffer; // The buffer
Uint32 m_dataSize; // No of words in buffer
Uint32 m_bufferSize; // Buffer size
Uint32 m_sendBufferSize; // Buffer size
Uint32 m_forceSendLimit; // Send when buffer is this full
bool full() const { return (m_dataSize * 4) > m_forceSendLimit ;}
} m_sendBuffer;
SHM_Reader * reader;
@ -196,7 +197,7 @@ private:
Uint32 m_adapters;
Uint32 m_numberOfRemoteNodes;
Uint16* m_remoteNodes;
Uint16 m_remoteNodes[2];
typedef struct SciAdapter {
sci_desc_t scidesc;
@ -296,12 +297,11 @@ private:
*/
bool sendIsPossible(struct timeval * timeout);
void getReceivePtr(Uint32 ** ptr, Uint32 ** eod){
reader->getReadPtr(* ptr, * eod);
}
void updateReceivePtr(Uint32 * ptr){
void updateReceivePtr(Uint32 *ptr){
reader->updateReadPtr(ptr);
}
@ -341,7 +341,9 @@ private:
*/
void failoverShmWriter();
bool init_local();
bool init_remote();
protected:
/** Perform a connection between segment
@ -350,7 +352,8 @@ protected:
* retrying.
* @return Returns true on success, otherwize falser
*/
bool connectImpl(Uint32 timeOutMillis);
bool connect_server_impl(NDB_SOCKET_TYPE sockfd);
bool connect_client_impl(NDB_SOCKET_TYPE sockfd);
/**
* We will disconnect if:

View file

@ -52,7 +52,7 @@ public:
}
void clear() {
m_readIndex = * m_sharedReadIndex;
m_readIndex = 0;
}
/**
@ -71,7 +71,7 @@ public:
/**
* Update read ptr
*/
inline void updateReadPtr(Uint32 * readPtr);
inline void updateReadPtr(Uint32 *ptr);
private:
char * const m_startOfBuffer;
@ -98,8 +98,8 @@ SHM_Reader::empty() const{
*/
inline
void
SHM_Reader::getReadPtr(Uint32 * & ptr, Uint32 * & eod){
SHM_Reader::getReadPtr(Uint32 * & ptr, Uint32 * & eod)
{
Uint32 tReadIndex = m_readIndex;
Uint32 tWriteIndex = * m_sharedWriteIndex;
@ -117,14 +117,14 @@ SHM_Reader::getReadPtr(Uint32 * & ptr, Uint32 * & eod){
*/
inline
void
SHM_Reader::updateReadPtr(Uint32 * ptr){
Uint32 tReadIndex = ((char *)ptr) - m_startOfBuffer;
SHM_Reader::updateReadPtr(Uint32 *ptr)
{
Uint32 tReadIndex = ((char*)ptr) - m_startOfBuffer;
assert(tReadIndex < m_totalBufferSize);
if(tReadIndex >= m_bufferSize){
tReadIndex = 0; //-= m_bufferSize;
tReadIndex = 0;
}
m_readIndex = tReadIndex;
@ -149,7 +149,7 @@ public:
}
void clear() {
m_writeIndex = * m_sharedWriteIndex;
m_writeIndex = 0;
}
inline char * getWritePtr(Uint32 sz);
@ -206,7 +206,7 @@ SHM_Writer::updateWritePtr(Uint32 sz){
assert(tWriteIndex < m_totalBufferSize);
if(tWriteIndex >= m_bufferSize){
tWriteIndex = 0; //-= m_bufferSize;
tWriteIndex = 0;
}
m_writeIndex = tWriteIndex;

View file

@ -32,13 +32,12 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
int r_port,
NodeId lNodeId,
NodeId rNodeId,
bool compression,
bool checksum,
bool signalId,
key_t _shmKey,
Uint32 _shmSize) :
Transporter(t_reg, lHostName, rHostName, r_port, lNodeId, rNodeId,
0, compression, checksum, signalId),
0, false, checksum, signalId),
shmKey(_shmKey),
shmSize(_shmSize)
{
@ -48,7 +47,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
shmBuf = 0;
reader = 0;
writer = 0;
setupBuffersDone=false;
#ifdef DEBUG_TRANSPORTER
printf("shm key (%d - %d) = %d\n", lNodeId, rNodeId, shmKey);
@ -92,8 +91,6 @@ SHM_Transporter::setupBuffers(){
clientStatusFlag = base2 + 4;
char * startOfBuf2 = ((char *)base2)+sharedSize;
* sharedReadIndex2 = * sharedWriteIndex2 = 0;
if(isServer){
* serverStatusFlag = 0;
reader = new SHM_Reader(startOfBuf1,
@ -109,10 +106,10 @@ SHM_Transporter::setupBuffers(){
sharedWriteIndex2);
* sharedReadIndex1 = 0;
* sharedWriteIndex2 = 0;
* sharedWriteIndex1 = 0;
* sharedReadIndex2 = 0;
* sharedWriteIndex1 = 0;
* sharedWriteIndex2 = 0;
reader->clear();
writer->clear();
@ -224,6 +221,7 @@ SHM_Transporter::prepareSend(const SignalHeader * const signalHeader,
bool
SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
{
DBUG_ENTER("SHM_Transporter::connect_server_impl");
SocketOutputStream s_output(sockfd);
SocketInputStream s_input(sockfd);
char buf[256];
@ -233,7 +231,7 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
if (!ndb_shm_create()) {
report_error(TE_SHM_UNABLE_TO_CREATE_SEGMENT);
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_RETURN(false);
}
_shmSegCreated = true;
}
@ -243,7 +241,7 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
if (!ndb_shm_attach()) {
report_error(TE_SHM_UNABLE_TO_ATTACH_SEGMENT);
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_RETURN(false);
}
_attached = true;
}
@ -254,7 +252,7 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
// Wait for ok from client
if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_RETURN(false);
}
int r= connect_common(sockfd);
@ -265,17 +263,20 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
// Wait for ok from client
if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_RETURN(false);
}
DBUG_PRINT("info", ("Successfully connected server to node %d",
remoteNodeId));
}
NDB_CLOSE_SOCKET(sockfd);
return r;
DBUG_RETURN(r);
}
bool
SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
{
DBUG_ENTER("SHM_Transporter::connect_client_impl");
SocketInputStream s_input(sockfd);
SocketOutputStream s_output(sockfd);
char buf[256];
@ -283,14 +284,18 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
// Wait for server to create and attach
if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_PRINT("error", ("Server id %d did not attach",
remoteNodeId));
DBUG_RETURN(false);
}
// Create
if(!_shmSegCreated){
if (!ndb_shm_get()) {
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_PRINT("error", ("Failed create of shm seg to node %d",
remoteNodeId));
DBUG_RETURN(false);
}
_shmSegCreated = true;
}
@ -300,7 +305,9 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
if (!ndb_shm_attach()) {
report_error(TE_SHM_UNABLE_TO_ATTACH_SEGMENT);
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_PRINT("error", ("Failed attach of shm seg to node %d",
remoteNodeId));
DBUG_RETURN(false);
}
_attached = true;
}
@ -314,21 +321,28 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
// Wait for ok from server
if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd);
return false;
DBUG_PRINT("error", ("No ok from server node %d",
remoteNodeId));
DBUG_RETURN(false);
}
// Send ok to server
s_output.println("shm client 2 ok");
DBUG_PRINT("info", ("Successfully connected client to node %d",
remoteNodeId));
}
NDB_CLOSE_SOCKET(sockfd);
return r;
DBUG_RETURN(r);
}
bool
SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
{
if (!checkConnected())
if (!checkConnected()) {
DBUG_PRINT("error", ("Already connected to node %d",
remoteNodeId));
return false;
}
if(!setupBuffersDone) {
setupBuffers();
@ -341,5 +355,7 @@ SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
return true;
}
DBUG_PRINT("error", ("Failed to set up buffers to node %d",
remoteNodeId));
return false;
}

View file

@ -38,7 +38,6 @@ public:
int r_port,
NodeId lNodeId,
NodeId rNodeId,
bool compression,
bool checksum,
bool signalId,
key_t shmKey,
@ -127,6 +126,7 @@ protected:
private:
bool _shmSegCreated;
bool _attached;
bool m_connected;
key_t shmKey;
volatile Uint32 * serverStatusFlag;

View file

@ -70,11 +70,10 @@ TCP_Transporter::TCP_Transporter(TransporterRegistry &t_reg,
int r_port,
NodeId lNodeId,
NodeId rNodeId,
int byte_order,
bool compr, bool chksm, bool signalId,
bool chksm, bool signalId,
Uint32 _reportFreq) :
Transporter(t_reg, lHostName, rHostName, r_port, lNodeId, rNodeId,
byte_order, compr, chksm, signalId),
0, false, chksm, signalId),
m_sendBuffer(sendBufSize)
{
maxReceiveSize = maxRecvSize;
@ -106,12 +105,14 @@ TCP_Transporter::~TCP_Transporter() {
bool TCP_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
{
return connect_common(sockfd);
DBUG_ENTER("TCP_Transpporter::connect_server_impl");
DBUG_RETURN(connect_common(sockfd));
}
bool TCP_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
{
return connect_common(sockfd);
DBUG_ENTER("TCP_Transpporter::connect_client_impl");
DBUG_RETURN(connect_common(sockfd));
}
bool TCP_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
@ -119,6 +120,8 @@ bool TCP_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
theSocket = sockfd;
setSocketOptions();
setSocketNonBlocking(theSocket);
DBUG_PRINT("info", ("Successfully set-up TCP transporter to node %d",
remoteNodeId));
return true;
}
@ -359,50 +362,56 @@ TCP_Transporter::doReceive() {
// Select-function must return the socket for read
// before this method is called
// It reads the external TCP/IP interface once
const int nBytesRead = recv(theSocket,
receiveBuffer.insertPtr, maxReceiveSize, 0);
if (nBytesRead > 0) {
receiveBuffer.sizeOfData += nBytesRead;
receiveBuffer.insertPtr += nBytesRead;
int size = receiveBuffer.sizeOfBuffer - receiveBuffer.sizeOfData;
if(size > 0){
const int nBytesRead = recv(theSocket,
receiveBuffer.insertPtr,
size < maxReceiveSize ? size : maxReceiveSize,
0);
if(receiveBuffer.sizeOfData > receiveBuffer.sizeOfBuffer){
if (nBytesRead > 0) {
receiveBuffer.sizeOfData += nBytesRead;
receiveBuffer.insertPtr += nBytesRead;
if(receiveBuffer.sizeOfData > receiveBuffer.sizeOfBuffer){
#ifdef DEBUG_TRANSPORTER
ndbout_c("receiveBuffer.sizeOfData(%d) > receiveBuffer.sizeOfBuffer(%d)",
receiveBuffer.sizeOfData, receiveBuffer.sizeOfBuffer);
ndbout_c("nBytesRead = %d", nBytesRead);
ndbout_c("receiveBuffer.sizeOfData(%d) > receiveBuffer.sizeOfBuffer(%d)",
receiveBuffer.sizeOfData, receiveBuffer.sizeOfBuffer);
ndbout_c("nBytesRead = %d", nBytesRead);
#endif
ndbout_c("receiveBuffer.sizeOfData(%d) > receiveBuffer.sizeOfBuffer(%d)",
receiveBuffer.sizeOfData, receiveBuffer.sizeOfBuffer);
report_error(TE_INVALID_MESSAGE_LENGTH);
return 0;
}
receiveCount ++;
receiveSize += nBytesRead;
if(receiveCount == reportFreq){
reportReceiveLen(get_callback_obj(), remoteNodeId, receiveCount, receiveSize);
receiveCount = 0;
receiveSize = 0;
ndbout_c("receiveBuffer.sizeOfData(%d) > receiveBuffer.sizeOfBuffer(%d)",
receiveBuffer.sizeOfData, receiveBuffer.sizeOfBuffer);
report_error(TE_INVALID_MESSAGE_LENGTH);
return 0;
}
receiveCount ++;
receiveSize += nBytesRead;
if(receiveCount == reportFreq){
reportReceiveLen(get_callback_obj(), remoteNodeId, receiveCount, receiveSize);
receiveCount = 0;
receiveSize = 0;
}
return nBytesRead;
} else {
#if defined DEBUG_TRANSPORTER
ndbout_c("Receive Failure(disconnect==%d) to node = %d nBytesSent = %d "
"errno = %d strerror = %s",
DISCONNECT_ERRNO(InetErrno, nBytesRead),
remoteNodeId, nBytesRead, InetErrno,
(char*)ndbstrerror(InetErrno));
#endif
if(DISCONNECT_ERRNO(InetErrno, nBytesRead)){
// The remote node has closed down
doDisconnect();
report_disconnect(InetErrno);
}
}
return nBytesRead;
} else {
#if defined DEBUG_TRANSPORTER
ndbout_c("Receive Failure(disconnect==%d) to node = %d nBytesSent = %d "
"errno = %d strerror = %s",
DISCONNECT_ERRNO(InetErrno, nBytesRead),
remoteNodeId, nBytesRead, InetErrno,
(char*)ndbstrerror(InetErrno));
#endif
if(DISCONNECT_ERRNO(InetErrno, nBytesRead)){
// The remote node has closed down
doDisconnect();
report_disconnect(InetErrno);
}
return 0;
}
return nBytesRead;
}
void

View file

@ -52,8 +52,7 @@ private:
int r_port,
NodeId lHostId,
NodeId rHostId,
int byteorder,
bool compression, bool checksum, bool signalId,
bool checksum, bool signalId,
Uint32 reportFreq = 4096);
// Disconnect, delete send buffers and receive buffer

View file

@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <my_pthread.h>
#include <TransporterRegistry.hpp>
#include "TransporterInternalDefinitions.hpp"
@ -48,9 +49,10 @@
SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
{
DBUG_ENTER("SocketServer::Session * TransporterService::newSession");
if (m_auth && !m_auth->server_authenticate(sockfd)){
NDB_CLOSE_SOCKET(sockfd);
return 0;
DBUG_RETURN(0);
}
{
@ -60,27 +62,32 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
char buf[256];
if (s_input.gets(buf, 256) == 0) {
NDB_CLOSE_SOCKET(sockfd);
return 0;
DBUG_PRINT("error", ("Could not get node id from client"));
DBUG_RETURN(0);
}
if (sscanf(buf, "%d", &nodeId) != 1) {
NDB_CLOSE_SOCKET(sockfd);
return 0;
DBUG_PRINT("error", ("Error in node id from client"));
DBUG_RETURN(0);
}
//check that nodeid is valid and that there is an allocated transporter
if ( nodeId < 0 || nodeId >= (int) m_transporter_registry->maxTransporters) {
NDB_CLOSE_SOCKET(sockfd);
return 0;
if ( nodeId < 0 || nodeId >= (int)m_transporter_registry->maxTransporters) {
NDB_CLOSE_SOCKET(sockfd);
DBUG_PRINT("error", ("Node id out of range from client"));
DBUG_RETURN(0);
}
if (m_transporter_registry->theTransporters[nodeId] == 0) {
NDB_CLOSE_SOCKET(sockfd);
return 0;
DBUG_PRINT("error", ("No transporter for this node id from client"));
DBUG_RETURN(0);
}
//check that the transporter should be connected
if (m_transporter_registry->performStates[nodeId] != TransporterRegistry::CONNECTING) {
NDB_CLOSE_SOCKET(sockfd);
return 0;
DBUG_PRINT("error", ("Transporter in wrong state for this node id from client"));
DBUG_RETURN(0);
}
Transporter *t= m_transporter_registry->theTransporters[nodeId];
@ -93,14 +100,13 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
t->connect_server(sockfd);
}
return 0;
DBUG_RETURN(0);
}
TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters,
unsigned sizeOfLongSignalMemory) {
m_transporter_service= 0;
nodeIdSpecified = false;
maxTransporters = _maxTransporters;
sendCounter = 1;
@ -209,8 +215,6 @@ TransporterRegistry::createTransporter(TCP_TransporterConfiguration *config) {
config->port,
localNodeId,
config->remoteNodeId,
config->byteOrder,
config->compression,
config->checksum,
config->signalId);
if (t == NULL)
@ -264,8 +268,6 @@ TransporterRegistry::createTransporter(OSE_TransporterConfiguration *conf) {
conf->localHostName,
conf->remoteNodeId,
conf->remoteHostName,
conf->byteOrder,
conf->compression,
conf->checksum,
conf->signalId);
if (t == NULL)
@ -306,15 +308,17 @@ TransporterRegistry::createTransporter(SCI_TransporterConfiguration *config) {
if(theTransporters[config->remoteNodeId] != NULL)
return false;
SCI_Transporter * t = new SCI_Transporter(config->sendLimit,
SCI_Transporter * t = new SCI_Transporter(*this,
config->localHostName,
config->remoteHostName,
config->port,
config->sendLimit,
config->bufferSize,
config->nLocalAdapters,
config->remoteSciNodeId0,
config->remoteSciNodeId1,
localNodeId,
config->remoteNodeId,
config->byteOrder,
config->compression,
config->checksum,
config->signalId);
@ -357,7 +361,6 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) {
config->port,
localNodeId,
config->remoteNodeId,
config->compression,
config->checksum,
config->signalId,
config->shmKey,
@ -855,8 +858,8 @@ TransporterRegistry::performReceive(){
if(t->isConnected() && t->checkConnected()){
Uint32 * readPtr, * eodPtr;
t->getReceivePtr(&readPtr, &eodPtr);
readPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]);
t->updateReceivePtr(readPtr);
Uint32 *newPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]);
t->updateReceivePtr(newPtr);
}
}
}
@ -870,8 +873,8 @@ TransporterRegistry::performReceive(){
if(t->isConnected() && t->checkConnected()){
Uint32 * readPtr, * eodPtr;
t->getReceivePtr(&readPtr, &eodPtr);
readPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]);
t->updateReceivePtr(readPtr);
Uint32 *newPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]);
t->updateReceivePtr(newPtr);
}
}
}
@ -1023,7 +1026,9 @@ TransporterRegistry::setIOState(NodeId nodeId, IOState state) {
static void *
run_start_clients_C(void * me)
{
my_thread_init();
((TransporterRegistry*) me)->start_clients_thread();
my_thread_end();
NdbThread_Exit(0);
return me;
}
@ -1106,6 +1111,7 @@ TransporterRegistry::update_connections()
void
TransporterRegistry::start_clients_thread()
{
DBUG_ENTER("TransporterRegistry::start_clients_thread");
while (m_run_start_clients_thread) {
NdbSleep_MilliSleep(100);
for (int i= 0, n= 0; n < nTransporters && m_run_start_clients_thread; i++){
@ -1129,6 +1135,7 @@ TransporterRegistry::start_clients_thread()
}
}
}
DBUG_VOID_RETURN;
}
bool
@ -1159,55 +1166,67 @@ TransporterRegistry::stop_clients()
return true;
}
void
TransporterRegistry::add_transporter_interface(const char *interface, unsigned short port)
{
DBUG_ENTER("TransporterRegistry::add_transporter_interface");
DBUG_PRINT("enter",("interface=%s, port= %d", interface, port));
if (interface && strlen(interface) == 0)
interface= 0;
for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{
Transporter_interface &tmp= m_transporter_interface[i];
if (port != tmp.m_service_port)
continue;
if (interface != 0 && tmp.m_interface != 0 &&
strcmp(interface, tmp.m_interface) == 0)
{
DBUG_VOID_RETURN; // found match, no need to insert
}
if (interface == 0 && tmp.m_interface == 0)
{
DBUG_VOID_RETURN; // found match, no need to insert
}
}
Transporter_interface t;
t.m_service_port= port;
t.m_interface= interface;
m_transporter_interface.push_back(t);
DBUG_PRINT("exit",("interface and port added"));
DBUG_VOID_RETURN;
}
bool
TransporterRegistry::start_service(SocketServer& socket_server)
{
#if 0
for (int i= 0, n= 0; n < nTransporters; i++){
Transporter * t = theTransporters[i];
if (!t)
continue;
n++;
if (t->isServer) {
t->m_service = new TransporterService(new SocketAuthSimple("ndbd passwd"));
if(!socket_server.setup(t->m_service, t->m_r_port, 0))
{
ndbout_c("Unable to setup transporter service port: %d!\n"
"Please check if the port is already used,\n"
"(perhaps a mgmt server is already running)",
m_service_port);
delete t->m_service;
return false;
}
}
if (m_transporter_interface.size() > 0 && nodeIdSpecified != true)
{
ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified");
return false;
}
#endif
if (m_service_port != 0) {
m_transporter_service = new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
if (nodeIdSpecified != true) {
ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified");
for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{
Transporter_interface &t= m_transporter_interface[i];
if (t.m_service_port == 0)
{
continue;
}
TransporterService *transporter_service =
new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
if(!socket_server.setup(transporter_service,
t.m_service_port, t.m_interface))
{
ndbout_c("Unable to setup transporter service port: %s:%d!\n"
"Please check if the port is already used,\n"
"(perhaps the node is already running)",
t.m_interface ? t.m_interface : "*", t.m_service_port);
delete transporter_service;
return false;
}
//m_interface_name = "ndbd";
m_interface_name = 0;
if(!socket_server.setup(m_transporter_service, m_service_port, m_interface_name))
{
ndbout_c("Unable to setup transporter service port: %d!\n"
"Please check if the port is already used,\n"
"(perhaps a mgmt server is already running)",
m_service_port);
delete m_transporter_service;
return false;
}
m_transporter_service->setTransporterRegistry(this);
} else
m_transporter_service= 0;
transporter_service->setTransporterRegistry(this);
}
return true;
}
@ -1281,3 +1300,5 @@ NdbOut & operator <<(NdbOut & out, SignalHeader & sh){
out << "trace: " << (int)sh.theTrace << endl;
return out;
}
template class Vector<TransporterRegistry::Transporter_interface>;

View file

@ -9,7 +9,7 @@ libgeneral_la_SOURCES = \
NdbSqlUtil.cpp new.cpp \
uucode.c random.c getarg.c version.c \
strdup.c strlcat.c strlcpy.c \
ConfigValues.cpp
ConfigValues.cpp ndb_init.c
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am

View file

@ -176,10 +176,29 @@ NdbSqlUtil::getType(Uint32 typeId)
return m_typeList[Type::Undefined];
}
const NdbSqlUtil::Type&
NdbSqlUtil::getTypeBinary(Uint32 typeId)
{
switch (typeId) {
case Type::Char:
typeId = Type::Binary;
break;
case Type::Varchar:
typeId = Type::Varbinary;
break;
case Type::Text:
typeId = Type::Blob;
break;
default:
break;
}
return getType(typeId);
}
// compare
int
NdbSqlUtil::cmpTinyint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpTinyint(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; Int8 v; } u1, u2;
@ -193,7 +212,7 @@ NdbSqlUtil::cmpTinyint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 s
}
int
NdbSqlUtil::cmpTinyunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpTinyunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; Uint8 v; } u1, u2;
@ -207,7 +226,7 @@ NdbSqlUtil::cmpTinyunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uin
}
int
NdbSqlUtil::cmpSmallint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpSmallint(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; Int16 v; } u1, u2;
@ -221,7 +240,7 @@ NdbSqlUtil::cmpSmallint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32
}
int
NdbSqlUtil::cmpSmallunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpSmallunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; Uint16 v; } u1, u2;
@ -235,7 +254,7 @@ NdbSqlUtil::cmpSmallunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Ui
}
int
NdbSqlUtil::cmpMediumint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpMediumint(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { const Uint32* p; const unsigned char* v; } u1, u2;
@ -251,7 +270,7 @@ NdbSqlUtil::cmpMediumint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32
}
int
NdbSqlUtil::cmpMediumunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpMediumunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { const Uint32* p; const unsigned char* v; } u1, u2;
@ -267,7 +286,7 @@ NdbSqlUtil::cmpMediumunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, U
}
int
NdbSqlUtil::cmpInt(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpInt(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; Int32 v; } u1, u2;
@ -281,7 +300,7 @@ NdbSqlUtil::cmpInt(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
}
int
NdbSqlUtil::cmpUnsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpUnsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; Uint32 v; } u1, u2;
@ -295,7 +314,7 @@ NdbSqlUtil::cmpUnsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32
}
int
NdbSqlUtil::cmpBigint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpBigint(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
if (size >= 2) {
@ -314,7 +333,7 @@ NdbSqlUtil::cmpBigint(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 si
}
int
NdbSqlUtil::cmpBigunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpBigunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
if (size >= 2) {
@ -333,7 +352,7 @@ NdbSqlUtil::cmpBigunsigned(const Uint32* p1, const Uint32* p2, Uint32 full, Uint
}
int
NdbSqlUtil::cmpFloat(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpFloat(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
union { Uint32 p[1]; float v; } u1, u2;
@ -348,7 +367,7 @@ NdbSqlUtil::cmpFloat(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 siz
}
int
NdbSqlUtil::cmpDouble(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpDouble(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
if (size >= 2) {
@ -368,7 +387,7 @@ NdbSqlUtil::cmpDouble(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 si
}
int
NdbSqlUtil::cmpDecimal(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpDecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
// not used by MySQL or NDB
@ -377,27 +396,34 @@ NdbSqlUtil::cmpDecimal(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 s
}
int
NdbSqlUtil::cmpChar(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpChar(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
// collation does not work on prefix for some charsets
assert(full == size && size > 0);
/*
* Char is blank-padded to length and null-padded to word size. There
* is no terminator so we compare the full values.
* Char is blank-padded to length and null-padded to word size.
*/
union { const Uint32* p; const char* v; } u1, u2;
union { const Uint32* p; const uchar* v; } u1, u2;
u1.p = p1;
u2.p = p2;
int k = memcmp(u1.v, u2.v, size << 2);
return k < 0 ? -1 : k > 0 ? +1 : full == size ? 0 : CmpUnknown;
// not const in MySQL
CHARSET_INFO* cs = (CHARSET_INFO*)(info);
// length in bytes including null padding to Uint32
uint l1 = (full << 2);
int k = (*cs->coll->strnncollsp)(cs, u1.v, l1, u2.v, l1);
return k < 0 ? -1 : k > 0 ? +1 : 0;
}
int
NdbSqlUtil::cmpVarchar(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpVarchar(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
/*
* Varchar is not allowed to contain a null byte and the value is
* null-padded. Therefore comparison does not need to use the length.
*
* Not used before MySQL 5.0. Format is likely to change. Handle
* only binary collation for now.
*/
union { const Uint32* p; const char* v; } u1, u2;
u1.p = p1;
@ -408,7 +434,7 @@ NdbSqlUtil::cmpVarchar(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 s
}
int
NdbSqlUtil::cmpBinary(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpBinary(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
/*
@ -422,12 +448,14 @@ NdbSqlUtil::cmpBinary(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 si
}
int
NdbSqlUtil::cmpVarbinary(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpVarbinary(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
/*
* Binary data of variable length padded with nulls. The comparison
* does not need to use the length.
*
* Not used before MySQL 5.0. Format is likely to change.
*/
union { const Uint32* p; const unsigned char* v; } u1, u2;
u1.p = p1;
@ -438,11 +466,13 @@ NdbSqlUtil::cmpVarbinary(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32
}
int
NdbSqlUtil::cmpDatetime(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpDatetime(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
/*
* Datetime is CC YY MM DD hh mm ss \0
*
* Not used via MySQL.
*/
union { const Uint32* p; const unsigned char* v; } u1, u2;
u1.p = p1;
@ -459,11 +489,13 @@ NdbSqlUtil::cmpDatetime(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32
}
int
NdbSqlUtil::cmpTimespec(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpTimespec(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
/*
* Timespec is CC YY MM DD hh mm ss \0 NN NN NN NN
*
* Not used via MySQL.
*/
union { const Uint32* p; const unsigned char* v; } u1, u2;
u1.p = p1;
@ -490,12 +522,11 @@ NdbSqlUtil::cmpTimespec(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32
}
int
NdbSqlUtil::cmpBlob(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpBlob(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
/*
* Blob comparison is on the inline bytes. Except for larger header
* the format is like Varbinary.
* Blob comparison is on the inline bytes (null padded).
*/
const unsigned head = NDB_BLOB_HEAD_SIZE;
// skip blob head
@ -510,25 +541,107 @@ NdbSqlUtil::cmpBlob(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size
}
int
NdbSqlUtil::cmpText(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpText(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
assert(full >= size && size > 0);
// collation does not work on prefix for some charsets
assert(full == size && size > 0);
/*
* Text comparison is on the inline bytes. Except for larger header
* the format is like Varchar.
* Text comparison is on the inline bytes (blank padded). Currently
* not supported for multi-byte charsets.
*/
const unsigned head = NDB_BLOB_HEAD_SIZE;
// skip blob head
if (size >= head + 1) {
union { const Uint32* p; const char* v; } u1, u2;
union { const Uint32* p; const uchar* v; } u1, u2;
u1.p = p1 + head;
u2.p = p2 + head;
int k = memcmp(u1.v, u2.v, (size - head) << 2);
return k < 0 ? -1 : k > 0 ? +1 : full == size ? 0 : CmpUnknown;
// not const in MySQL
CHARSET_INFO* cs = (CHARSET_INFO*)(info);
// length in bytes including null padding to Uint32
uint l1 = (full << 2);
int k = (*cs->coll->strnncollsp)(cs, u1.v, l1, u2.v, l1);
return k < 0 ? -1 : k > 0 ? +1 : 0;
}
return CmpUnknown;
}
// check charset
bool
NdbSqlUtil::usable_in_pk(Uint32 typeId, const void* info)
{
const Type& type = getType(typeId);
switch (type.m_typeId) {
case Type::Undefined:
break;
case Type::Char:
{
const CHARSET_INFO *cs = (const CHARSET_INFO*)info;
return
cs != 0 &&
cs->cset != 0 &&
cs->coll != 0 &&
cs->coll->strnxfrm != 0 &&
cs->strxfrm_multiply == 1; // current limitation
}
break;
case Type::Varchar:
return true; // Varchar not used via MySQL
case Type::Blob:
case Type::Text:
break;
default:
return true;
}
return false;
}
bool
NdbSqlUtil::usable_in_hash_index(Uint32 typeId, const void* info)
{
return usable_in_pk(typeId, info);
}
bool
NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info)
{
const Type& type = getType(typeId);
switch (type.m_typeId) {
case Type::Undefined:
break;
case Type::Char:
{
const CHARSET_INFO *cs = (const CHARSET_INFO*)info;
return
cs != 0 &&
cs->cset != 0 &&
cs->coll != 0 &&
cs->coll->strnxfrm != 0 &&
cs->coll->strnncollsp != 0 &&
cs->strxfrm_multiply == 1; // current limitation
}
break;
case Type::Varchar:
return true; // Varchar not used via MySQL
case Type::Text:
{
const CHARSET_INFO *cs = (const CHARSET_INFO*)info;
return
cs != 0 &&
cs->mbmaxlen == 1 && // extra limitation
cs->cset != 0 &&
cs->coll != 0 &&
cs->coll->strnxfrm != 0 &&
cs->coll->strnncollsp != 0 &&
cs->strxfrm_multiply == 1; // current limitation
}
break;
default:
return true;
}
return false;
}
#ifdef NDB_SQL_UTIL_TEST
#include <NdbTick.h>
@ -556,6 +669,7 @@ const Testcase testcase[] = {
int
main(int argc, char** argv)
{
ndb_init(); // for charsets
unsigned count = argc > 1 ? atoi(argv[1]) : 1000000;
ndbout_c("count = %u", count);
assert(count != 0);

View file

@ -16,6 +16,7 @@
#include <ndb_global.h>
#include <my_pthread.h>
#include <SocketServer.hpp>
@ -46,7 +47,7 @@ SocketServer::~SocketServer() {
}
bool
SocketServer::tryBind(unsigned short port, const char * intface) const {
SocketServer::tryBind(unsigned short port, const char * intface) {
struct sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
@ -83,7 +84,8 @@ bool
SocketServer::setup(SocketServer::Service * service,
unsigned short port,
const char * intface){
DBUG_ENTER("SocketServer::setup");
DBUG_PRINT("enter",("interface=%s, port=%d", intface, port));
struct sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
@ -92,36 +94,44 @@ SocketServer::setup(SocketServer::Service * service,
if(intface != 0){
if(Ndb_getInAddr(&servaddr.sin_addr, intface))
return false;
DBUG_RETURN(false);
}
const NDB_SOCKET_TYPE sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == NDB_INVALID_SOCKET) {
return false;
DBUG_PRINT("error",("socket() - %d - %s",
errno, strerror(errno)));
DBUG_RETURN(false);
}
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
DBUG_PRINT("error",("getsockopt() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
return false;
DBUG_RETURN(false);
}
if (bind(sock, (struct sockaddr*) &servaddr, sizeof(servaddr)) == -1) {
DBUG_PRINT("error",("bind() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
return false;
DBUG_RETURN(false);
}
if (listen(sock, m_maxSessions) == -1){
DBUG_PRINT("error",("listen() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
return false;
DBUG_RETURN(false);
}
ServiceInstance i;
i.m_socket = sock;
i.m_service = service;
m_services.push_back(i);
return true;
DBUG_RETURN(true);
}
void
@ -177,8 +187,9 @@ void*
socketServerThread_C(void* _ss){
SocketServer * ss = (SocketServer *)_ss;
my_thread_init();
ss->doRun();
my_thread_end();
NdbThread_Exit(0);
return 0;
}
@ -287,8 +298,10 @@ void*
sessionThread_C(void* _sc){
SocketServer::Session * si = (SocketServer::Session *)_sc;
my_thread_init();
if(!transfer(si->m_socket)){
si->m_stopped = true;
my_thread_end();
NdbThread_Exit(0);
return 0;
}
@ -301,6 +314,7 @@ sessionThread_C(void* _sc){
}
si->m_stopped = true;
my_thread_end();
NdbThread_Exit(0);
return 0;
}

View file

@ -14,17 +14,22 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <LogLevel.hpp>
#include <ndb_global.h>
#include <my_sys.h>
const LogLevel::LogLevelCategoryName LogLevel::LOGLEVEL_CATEGORY_NAME[] = {
{ "LogLevelStartup" },
{ "LogLevelShutdown" },
{ "LogLevelStatistic" },
{ "LogLevelCheckpoint" },
{ "LogLevelNodeRestart" },
{ "LogLevelConnection" },
{ "LogLevelError" },
{ "LogLevelWarning" },
{ "LogLevelInfo" },
{ "LogLevelGrep" }
};
int
ndb_init()
{
if (my_init()) {
const char* err = "my_init() failed - exit\n";
write(2, err, strlen(err));
exit(1);
}
return 0;
}
void
ndb_end(int flags)
{
my_end(flags);
}

View file

@ -47,7 +47,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
fun, \
desc }
desc, 0 }
#define CPCD_ARG(name, type, opt, desc) \
{ name, \
@ -58,7 +58,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
desc }
desc, 0 }
#define CPCD_ARG2(name, type, opt, min, max, desc) \
{ name, \
@ -69,7 +69,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
min, max, \
0, \
desc }
desc, 0 }
#define CPCD_END() \
{ 0, \
@ -80,7 +80,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
0 }
0, 0 }
#define CPCD_CMD_ALIAS(name, realName, fun) \
{ name, \
@ -91,7 +91,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
0 }
0, 0 }
#define CPCD_ARG_ALIAS(name, realName, fun) \
{ name, \
@ -102,7 +102,7 @@
ParserRow<CPCDAPISession>::IgnoreMinMax, \
0, 0, \
0, \
0 }
0, 0 }
const
ParserRow<CPCDAPISession> commands[] =

View file

@ -378,7 +378,7 @@ CPCD::getProcessList() {
}
void
CPCD::RequestStatus::err(enum RequestStatusCode status, char *msg) {
CPCD::RequestStatus::err(enum RequestStatusCode status, const char *msg) {
m_status = status;
snprintf(m_errorstring, sizeof(m_errorstring), "%s", msg);
}

View file

@ -91,7 +91,7 @@ public:
RequestStatus() { m_status = OK; m_errorstring[0] = '\0'; };
/** @brief Sets an errorcode and a printable message */
void err(enum RequestStatusCode, char *);
void err(enum RequestStatusCode, const char *);
/** @brief Returns the error message */
char *getErrMsg() { return m_errorstring; };

View file

@ -7,7 +7,7 @@ LDADD_LOC = \
$(top_builddir)/ndb/src/libndbclient.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am

View file

@ -28,12 +28,12 @@
#include "common.hpp"
static char *work_dir = CPCD_DEFAULT_WORK_DIR;
static const char *work_dir = CPCD_DEFAULT_WORK_DIR;
static int port = CPCD_DEFAULT_TCP_PORT;
static int use_syslog = 0;
static char *logfile = NULL;
static char *config_file = CPCD_DEFAULT_CONFIG_FILE;
static char *user = 0;
static const char *logfile = NULL;
static const char *config_file = CPCD_DEFAULT_CONFIG_FILE;
static const char *user = 0;
static struct getargs args[] = {
{ "work-dir", 'w', arg_string, &work_dir,

View file

@ -55,7 +55,7 @@ LDADD += \
$(top_builddir)/ndb/src/common/util/libgeneral.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
# Don't update the files from bitkeeper
%::SCCS/s.%

View file

@ -40,6 +40,7 @@
#include <signaldata/BackupImpl.hpp>
#include <signaldata/BackupSignalData.hpp>
#include <signaldata/BackupContinueB.hpp>
#include <signaldata/EventReport.hpp>
#include <signaldata/UtilSequence.hpp>
@ -944,6 +945,13 @@ Backup::sendBackupRef(BlockReference senderRef, Signal *signal,
ref->errorCode = errorCode;
ref->masterRef = numberToRef(BACKUP, getMasterNodeId());
sendSignal(senderRef, GSN_BACKUP_REF, signal, BackupRef::SignalLength, JBB);
if(errorCode != BackupRef::IAmNotMaster){
signal->theData[0] = EventReport::BackupFailedToStart;
signal->theData[1] = senderRef;
signal->theData[2] = errorCode;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
}
}
void
@ -1226,7 +1234,13 @@ Backup::defineBackupReply(Signal* signal, BackupRecordPtr ptr, Uint32 nodeId)
conf->nodes = ptr.p->nodes;
sendSignal(ptr.p->clientRef, GSN_BACKUP_CONF, signal,
BackupConf::SignalLength, JBB);
signal->theData[0] = EventReport::BackupStarted;
signal->theData[1] = ptr.p->clientRef;
signal->theData[2] = ptr.p->backupId;
ptr.p->nodes.copyto(NdbNodeBitmask::Size, signal->theData+3);
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3+NdbNodeBitmask::Size, JBB);
ptr.p->masterData.state.setState(DEFINED);
/**
* Prepare Trig
@ -2069,6 +2083,18 @@ Backup::stopBackupReply(Signal* signal, BackupRecordPtr ptr, Uint32 nodeId)
rep->nodes = ptr.p->nodes;
sendSignal(ptr.p->clientRef, GSN_BACKUP_COMPLETE_REP, signal,
BackupCompleteRep::SignalLength, JBB);
signal->theData[0] = EventReport::BackupCompleted;
signal->theData[1] = ptr.p->clientRef;
signal->theData[2] = ptr.p->backupId;
signal->theData[3] = ptr.p->startGCP;
signal->theData[4] = ptr.p->stopGCP;
signal->theData[5] = ptr.p->noOfBytes;
signal->theData[6] = ptr.p->noOfRecords;
signal->theData[7] = ptr.p->noOfLogBytes;
signal->theData[8] = ptr.p->noOfLogRecords;
ptr.p->nodes.copyto(NdbNodeBitmask::Size, signal->theData+9);
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 9+NdbNodeBitmask::Size, JBB);
}
/*****************************************************************************
@ -2259,6 +2285,12 @@ Backup::masterSendAbortBackup(Signal* signal, BackupRecordPtr ptr)
rep->reason = ptr.p->errorCode;
sendSignal(ptr.p->clientRef, GSN_BACKUP_ABORT_REP, signal,
BackupAbortRep::SignalLength, JBB);
signal->theData[0] = EventReport::BackupAborted;
signal->theData[1] = ptr.p->clientRef;
signal->theData[2] = ptr.p->backupId;
signal->theData[3] = ptr.p->errorCode;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 4, JBB);
}//if
// ptr.p->masterData.state.setState(INITIAL);

View file

@ -48,6 +48,7 @@ static Uint32 logEntryNo;
int
main(int argc, const char * argv[]){
ndb_init();
if(argc <= 1){
printf("Usage: %s <filename>", argv[0]);
exit(1);

View file

@ -7,7 +7,7 @@ LDADD_LOC = \
$(top_builddir)/ndb/src/libndbclient.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
include $(top_srcdir)/ndb/config/common.mk.am

View file

@ -206,6 +206,7 @@ free_data_callback()
int
main(int argc, const char** argv)
{
ndb_init();
if (!readArguments(argc, argv))
{
return -1;
@ -331,7 +332,7 @@ main(int argc, const char** argv)
for (i= 0; i < g_consumers.size(); i++)
g_consumers[i]->endOfTuples();
RestoreLogIterator logIter(metaData);
if (!logIter.readHeader())
{
@ -357,7 +358,7 @@ main(int argc, const char** argv)
}
}
clearConsumers();
return 1;
return 0;
} // main
template class Vector<BackupConsumer*>;

View file

@ -97,7 +97,7 @@ Cmvmi::Cmvmi(const Configuration & conf) :
const ndb_mgm_configuration_iterator * db = theConfig.getOwnConfigIterator();
for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){
Uint32 logLevel;
if(!ndb_mgm_get_int_parameter(db, LogLevel::MIN_LOGLEVEL_ID+j, &logLevel)){
if(!ndb_mgm_get_int_parameter(db, CFG_MIN_LOGLEVEL+j, &logLevel)){
clogLevel.setLogLevel((LogLevel::EventCategory)j,
logLevel);
}
@ -169,9 +169,9 @@ void Cmvmi::execSET_LOGLEVELORD(Signal* signal)
jamEntry();
for(unsigned int i = 0; i<llOrd->noOfEntries; i++){
category = (LogLevel::EventCategory)llOrd->theCategories[i];
level = llOrd->theLevels[i];
category = (LogLevel::EventCategory)(llOrd->theData[i] >> 16);
level = llOrd->theData[i] & 0xFFFF;
clogLevel.setLogLevel(category, level);
}
}//execSET_LOGLEVELORD()
@ -196,10 +196,10 @@ void Cmvmi::execEVENT_REP(Signal* signal)
Uint32 threshold = 16;
LogLevel::EventCategory eventCategory = (LogLevel::EventCategory)0;
for(unsigned int i = 0; i< EventLogger::matrixSize; i++){
if(EventLogger::matrix[i].eventType == eventType){
eventCategory = EventLogger::matrix[i].eventCategory;
threshold = EventLogger::matrix[i].threshold;
for(unsigned int i = 0; i< EventLoggerBase::matrixSize; i++){
if(EventLoggerBase::matrix[i].eventType == eventType){
eventCategory = EventLoggerBase::matrix[i].eventCategory;
threshold = EventLoggerBase::matrix[i].threshold;
break;
}
}
@ -250,17 +250,7 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
sendSignal(subReq->blockRef, GSN_EVENT_SUBSCRIBE_REF, signal, 1, JBB);
return;
}
/**
* If it's a new subscription, clear the loglevel
*
* Clear only if noOfEntries is 0, this is needed beacuse we set
* the default loglevels for the MGMT nodes during the inital connect phase.
* See reportConnected().
*/
if (subReq->noOfEntries == 0){
ptr.p->logLevel.clear();
}
ptr.p->logLevel.clear();
ptr.p->blockRef = subReq->blockRef;
}
@ -276,10 +266,9 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
LogLevel::EventCategory category;
Uint32 level = 0;
for(Uint32 i = 0; i<subReq->noOfEntries; i++){
category = (LogLevel::EventCategory)subReq->theCategories[i];
level = subReq->theLevels[i];
ptr.p->logLevel.setLogLevel(category,
level);
category = (LogLevel::EventCategory)(subReq->theData[i] >> 16);
level = subReq->theData[i] & 0xFFFF;
ptr.p->logLevel.setLogLevel(category, level);
}
}
@ -384,11 +373,6 @@ void Cmvmi::execCLOSE_COMREQ(Signal* signal)
globalTransporterRegistry.setIOState(i, HaltIO);
globalTransporterRegistry.do_disconnect(i);
/**
* Cancel possible event subscription
*/
cancelSubscription(i);
}
}
if (failNo != 0) {
@ -494,6 +478,8 @@ void Cmvmi::execDISCONNECT_REP(Signal *signal)
globalTransporterRegistry.do_connect(hostId);
}
cancelSubscription(hostId);
signal->theData[0] = EventReport::Disconnected;
signal->theData[1] = hostId;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
@ -539,20 +525,6 @@ void Cmvmi::execCONNECT_REP(Signal *signal){
if(type == NodeInfo::MGM){
jam();
globalTransporterRegistry.setIOState(hostId, NoHalt);
EventSubscribeReq* dst = (EventSubscribeReq *)&signal->theData[0];
for (Uint32 i = 0; i < EventLogger::defEventLogMatrixSize; i++) {
dst->theCategories[i] = EventLogger::defEventLogMatrix[i].eventCategory;
dst->theLevels[i] = EventLogger::defEventLogMatrix[i].threshold;
}
dst->noOfEntries = EventLogger::defEventLogMatrixSize;
/* The BlockNumber is hardcoded as 1 in MgmtSrvr */
dst->blockRef = numberToRef(MIN_API_BLOCK_NO, hostId);
execEVENT_SUBSCRIBE_REQ(signal);
}
//------------------------------------------

View file

@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <my_sys.h>
#define DBDICT_C
#include "Dbdict.hpp"
@ -2866,8 +2867,6 @@ Dbdict::execALTER_TABLE_REQ(Signal* signal)
if(parseRecord.errorCode != 0){
jam();
c_opCreateTable.release(alterTabPtr);
parseRecord.tablePtr.p->tabState = TableRecord::NOT_DEFINED;
releaseTableObject(parseRecord.tablePtr.i, false);
alterTableRef(signal, req,
(AlterTableRef::ErrorCode) parseRecord.errorCode,
aParseRecord);
@ -3052,8 +3051,6 @@ Dbdict::execALTER_TAB_REQ(Signal * signal)
if(parseRecord.errorCode != 0){
jam();
c_opCreateTable.release(alterTabPtr);
parseRecord.tablePtr.p->tabState = TableRecord::NOT_DEFINED;
releaseTableObject(parseRecord.tablePtr.i, false);
alterTabRef(signal, req,
(AlterTableRef::ErrorCode) parseRecord.errorCode,
aParseRecord);
@ -3438,7 +3435,6 @@ Dbdict::execALTER_TAB_CONF(Signal * signal){
// Release resources
TableRecordPtr tabPtr;
c_tableRecordPool.getPtr(tabPtr, regAlterTabPtr->m_tablePtrI);
tabPtr.p->tabState = TableRecord::NOT_DEFINED;
releaseTableObject(tabPtr.i, false);
c_opCreateTable.release(alterTabPtr);
c_blockState = BS_IDLE;
@ -3479,12 +3475,19 @@ int Dbdict::handleAlterTab(AlterTabReq * req,
jam();
// Table rename
// Remove from hashtable
#ifdef VM_TRACE
TableRecordPtr tmp;
ndbrequire(c_tableRecordHash.find(tmp, *origTablePtr.p));
#endif
c_tableRecordHash.remove(origTablePtr);
strcpy(regAlterTabPtr->previousTableName, origTablePtr.p->tableName);
strcpy(origTablePtr.p->tableName, newTablePtr.p->tableName);
// Set new schema version
origTablePtr.p->tableVersion = newTablePtr.p->tableVersion;
// Put it back
#ifdef VM_TRACE
ndbrequire(!c_tableRecordHash.find(tmp, *origTablePtr.p));
#endif
c_tableRecordHash.add(origTablePtr);
return 0;
@ -3505,12 +3508,19 @@ void Dbdict::revertAlterTable(Signal * signal,
TableRecordPtr tablePtr;
c_tableRecordPool.getPtr(tablePtr, tableId);
// Remove from hashtable
#ifdef VM_TRACE
TableRecordPtr tmp;
ndbrequire(c_tableRecordHash.find(tmp, * tablePtr.p));
#endif
c_tableRecordHash.remove(tablePtr);
// Restore name
strcpy(tablePtr.p->tableName, regAlterTabPtr->previousTableName);
// Revert schema version
tablePtr.p->tableVersion = tablePtr.p->tableVersion - 1;
// Put it back
#ifdef VM_TRACE
ndbrequire(!c_tableRecordHash.find(tmp, * tablePtr.p));
#endif
c_tableRecordHash.add(tablePtr);
return;
@ -3572,7 +3582,6 @@ Dbdict::alterTab_writeTableConf(Signal* signal,
jam();
// Release resources
c_tableRecordPool.getPtr(tabPtr, regAlterTabPtr->m_tablePtrI);
tabPtr.p->tabState = TableRecord::NOT_DEFINED;
releaseTableObject(tabPtr.i, false);
c_opCreateTable.release(alterTabPtr);
c_blockState = BS_IDLE;
@ -4100,6 +4109,8 @@ Dbdict::execADD_FRAGREQ(Signal* signal) {
req->noOfKeyAttr = tabPtr.p->noOfPrimkey;
req->noOfNewAttr = 0;
// noOfCharsets passed to TUP in upper half
req->noOfNewAttr |= (tabPtr.p->noOfCharsets << 16);
req->checksumIndicator = 1;
req->noOfAttributeGroups = 1;
req->GCPIndicator = 0;
@ -4161,6 +4172,8 @@ Dbdict::sendLQHADDATTRREQ(Signal* signal,
entry.attrId = attrPtr.p->attributeId;
entry.attrDescriptor = attrPtr.p->attributeDescriptor;
entry.extTypeInfo = attrPtr.p->extType;
// charset number passed to TUP, TUX in upper half
entry.extTypeInfo |= (attrPtr.p->extPrecision & ~0xFFFF);
if (tabPtr.p->isIndex()) {
Uint32 primaryAttrId;
if (attrPtr.p->nextAttrInTable != RNIL) {
@ -4456,7 +4469,6 @@ Dbdict::createTab_dropComplete(Signal* signal,
TableRecordPtr tabPtr;
c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_tablePtrI);
tabPtr.p->tabState = TableRecord::NOT_DEFINED;
releaseTableObject(tabPtr.i);
PageRecordPtr pagePtr;
@ -4540,6 +4552,15 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it,
parseP->errorLine = __LINE__;
return;
}
if(parseP->requestType == DictTabInfo::AlterTableFromAPI)
{
ndbrequire(!checkExist);
}
if(!checkExist)
{
ndbrequire(parseP->requestType == DictTabInfo::AlterTableFromAPI);
}
/* ---------------------------------------------------------------- */
// Verify that table name is an allowed table name.
@ -4554,14 +4575,15 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it,
TableRecordPtr tablePtr;
c_tableRecordHash.find(tablePtr, keyRecord);
if (checkExist)
if (checkExist){
jam();
/* ---------------------------------------------------------------- */
// Check if table already existed.
/* ---------------------------------------------------------------- */
tabRequire(tablePtr.i == RNIL, CreateTableRef::TableAlreadyExist);
}
switch (parseP->requestType) {
case DictTabInfo::CreateTableFromAPI: {
jam();
@ -4634,12 +4656,13 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it,
strcpy(tablePtr.p->tableName, keyRecord.tableName);
if (parseP->requestType != DictTabInfo::AlterTableFromAPI) {
jam();
#ifdef VM_TRACE
ndbout_c("Dbdict: name=%s,id=%u", tablePtr.p->tableName, tablePtr.i);
TableRecordPtr tmp;
ndbrequire(!c_tableRecordHash.find(tmp, * tablePtr.p));
#endif
c_tableRecordHash.add(tablePtr);
}
#ifdef VM_TRACE
ndbout_c("Dbdict: name=%s,id=%u", tablePtr.p->tableName, tablePtr.i);
#endif
//tablePtr.p->noOfPrimkey = tableDesc.NoOfKeyAttr;
//tablePtr.p->noOfNullAttr = tableDesc.NoOfNullable;
@ -4678,11 +4701,12 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it,
handleTabInfo(it, parseP);
if(parseP->errorCode != 0){
if(parseP->errorCode != 0)
{
/**
* Release table
*/
releaseTableObject(tablePtr.i);
releaseTableObject(tablePtr.i, checkExist);
}
}//handleTabInfoInit()
@ -4697,6 +4721,8 @@ void Dbdict::handleTabInfo(SimpleProperties::Reader & it,
Uint32 keyLength = 0;
Uint32 attrCount = tablePtr.p->noOfAttributes;
Uint32 nullCount = 0;
Uint32 noOfCharsets = 0;
Uint16 charsets[128];
Uint32 recordLength = 0;
AttributeRecordPtr attrPtr;
c_attributeRecordHash.removeAll();
@ -4751,6 +4777,31 @@ void Dbdict::handleTabInfo(SimpleProperties::Reader & it,
attrPtr.p->extPrecision = attrDesc.AttributeExtPrecision;
attrPtr.p->extScale = attrDesc.AttributeExtScale;
attrPtr.p->extLength = attrDesc.AttributeExtLength;
// charset in upper half of precision
unsigned csNumber = (attrPtr.p->extPrecision >> 16);
if (csNumber != 0) {
CHARSET_INFO* cs = get_charset(csNumber, MYF(0));
if (cs == NULL) {
parseP->errorCode = CreateTableRef::InvalidCharset;
parseP->errorLine = __LINE__;
return;
}
unsigned i = 0;
while (i < noOfCharsets) {
if (charsets[i] == csNumber)
break;
i++;
}
if (i == noOfCharsets) {
noOfCharsets++;
if (noOfCharsets > sizeof(charsets)/sizeof(charsets[0])) {
parseP->errorCode = CreateTableRef::InvalidFormat;
parseP->errorLine = __LINE__;
return;
}
charsets[i] = csNumber;
}
}
/**
* Ignore incoming old-style type and recompute it.
@ -4814,6 +4865,7 @@ void Dbdict::handleTabInfo(SimpleProperties::Reader & it,
tablePtr.p->noOfPrimkey = keyCount;
tablePtr.p->noOfNullAttr = nullCount;
tablePtr.p->noOfCharsets = noOfCharsets;
tablePtr.p->tupKeyLength = keyLength;
tabRequire(recordLength<= MAX_TUPLE_SIZE_IN_WORDS,
@ -5465,7 +5517,14 @@ void Dbdict::releaseTableObject(Uint32 tableId, bool removeFromHash)
AttributeRecordPtr attrPtr;
c_tableRecordPool.getPtr(tablePtr, tableId);
if (removeFromHash)
{
#ifdef VM_TRACE
TableRecordPtr tmp;
ndbrequire(c_tableRecordHash.find(tmp, * tablePtr.p));
#endif
c_tableRecordHash.remove(tablePtr);
}
tablePtr.p->tabState = TableRecord::NOT_DEFINED;
Uint32 nextAttrRecord = tablePtr.p->firstAttribute;
while (nextAttrRecord != RNIL) {
@ -6317,6 +6376,8 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr)
w.add(DictTabInfo::AttributeStoredInd, (Uint32)DictTabInfo::Stored);
// ext type overrides
w.add(DictTabInfo::AttributeExtType, aRec->extType);
w.add(DictTabInfo::AttributeExtPrecision, aRec->extPrecision);
w.add(DictTabInfo::AttributeExtScale, aRec->extScale);
w.add(DictTabInfo::AttributeExtLength, aRec->extLength);
w.add(DictTabInfo::AttributeEnd, (Uint32)true);
}
@ -6510,6 +6571,8 @@ Dbdict::execDROP_INDX_REQ(Signal* signal)
jamEntry();
DropIndxReq* const req = (DropIndxReq*)signal->getDataPtrSend();
OpDropIndexPtr opPtr;
int err = DropIndxRef::BadRequestType;
const Uint32 senderRef = signal->senderBlockRef();
const DropIndxReq::RequestType requestType = req->getRequestType();
if (requestType == DropIndxReq::RT_USER) {
@ -6524,6 +6587,34 @@ Dbdict::execDROP_INDX_REQ(Signal* signal)
return;
}
// forward initial request plus operation key to all
Uint32 indexId= req->getIndexId();
Uint32 indexVersion= req->getIndexVersion();
TableRecordPtr tmp;
int res = getMetaTablePtr(tmp, indexId, indexVersion);
switch(res){
case MetaData::InvalidArgument:
err = DropIndxRef::IndexNotFound;
goto error;
case MetaData::TableNotFound:
case MetaData::InvalidTableVersion:
err = DropIndxRef::InvalidIndexVersion;
goto error;
}
if (! tmp.p->isIndex()) {
jam();
err = DropIndxRef::NotAnIndex;
goto error;
}
if (tmp.p->indexState == TableRecord::IS_DROPPING){
jam();
err = DropIndxRef::IndexNotFound;
goto error;
}
tmp.p->indexState = TableRecord::IS_DROPPING;
req->setOpKey(++c_opRecordSequence);
NodeReceiverGroup rg(DBDICT, c_aliveNodes);
sendSignal(rg, GSN_DROP_INDX_REQ,
@ -6573,12 +6664,13 @@ Dbdict::execDROP_INDX_REQ(Signal* signal)
return;
}
}
error:
jam();
// return to sender
OpDropIndex opBad;
opPtr.p = &opBad;
opPtr.p->save(req);
opPtr.p->m_errorCode = DropIndxRef::BadRequestType;
opPtr.p->m_errorCode = (DropIndxRef::ErrorCode)err;
opPtr.p->m_errorLine = __LINE__;
dropIndex_sendReply(signal, opPtr, true);
}

View file

@ -455,7 +455,7 @@ public:
Uint16 totalAttrReceived;
Uint16 fragCopyCreation;
Uint16 noOfKeyAttr;
Uint16 noOfNewAttr;
Uint32 noOfNewAttr; // noOfCharsets in upper half
Uint16 noOfAttributeGroups;
Uint16 lh3DistrBits;
Uint16 tableType;

View file

@ -1444,6 +1444,7 @@ Dblqh::sendAddAttrReq(Signal* signal)
tupreq->notused1 = 0;
tupreq->attrId = attrId;
tupreq->attrDescriptor = entry.attrDescriptor;
tupreq->extTypeInfo = entry.extTypeInfo;
sendSignal(fragptr.p->tupBlockref, GSN_TUP_ADD_ATTRREQ,
signal, TupAddAttrReq::SignalLength, JBB);
return;
@ -7699,6 +7700,7 @@ void Dblqh::accScanConfScanLab(Signal* signal)
ndbrequire(sz == boundAiLength);
EXECUTE_DIRECT(DBTUX, GSN_TUX_BOUND_INFO,
signal, TuxBoundInfo::SignalLength + boundAiLength);
jamEntry();
if (req->errorCode != 0) {
jam();
/*

View file

@ -22,26 +22,59 @@ class AttributeOffset {
private:
static void setOffset(Uint32 & desc, Uint32 offset);
static void setCharsetPos(Uint32 & desc, Uint32 offset);
static void setNullFlagPos(Uint32 & desc, Uint32 offset);
static Uint32 getOffset(const Uint32 &);
static bool getCharsetFlag(const Uint32 &);
static Uint32 getCharsetPos(const Uint32 &);
static Uint32 getNullFlagPos(const Uint32 &);
static Uint32 getNullFlagOffset(const Uint32 &);
static Uint32 getNullFlagBitOffset(const Uint32 &);
static bool isNULL(const Uint32 &, const Uint32 &);
};
#define AO_ATTRIBUTE_OFFSET_MASK (0xffff)
#define AO_NULL_FLAG_POS_MASK (0x7ff)
#define AO_NULL_FLAG_POS_SHIFT (21)
#define AO_NULL_FLAG_WORD_MASK (31)
#define AO_NULL_FLAG_OFFSET_SHIFT (5)
/**
* Allow for 4096 attributes, all nullable, and for 128 different
* character sets.
*
* a = Attribute offset - 11 bits 0-10 ( addr word in 8 kb )
* c = Has charset flag 1 bits 11-11
* s = Charset pointer position - 7 bits 12-18 ( in table descriptor )
* f = Null flag offset in word - 5 bits 20-24 ( address 32 bits )
* w = Null word offset - 7 bits 25-32 ( f+w addr 4096 attrs )
*
* 1111111111222222222233
* 01234567890123456789012345678901
* aaaaaaaaaaacsssssss fffffwwwwwww
*/
#define AO_ATTRIBUTE_OFFSET_SHIFT 0
#define AO_ATTRIBUTE_OFFSET_MASK 0x7ff
#define AO_CHARSET_FLAG_SHIFT 11
#define AO_CHARSET_POS_SHIFT 12
#define AO_CHARSET_POS_MASK 127
#define AO_NULL_FLAG_POS_MASK 0xfff // f+w
#define AO_NULL_FLAG_POS_SHIFT 20
#define AO_NULL_FLAG_WORD_MASK 31 // f
#define AO_NULL_FLAG_OFFSET_SHIFT 5
inline
void
AttributeOffset::setOffset(Uint32 & desc, Uint32 offset){
ASSERT_MAX(offset, AO_ATTRIBUTE_OFFSET_MASK, "AttributeOffset::setOffset");
desc |= offset;
desc |= (offset << AO_ATTRIBUTE_OFFSET_SHIFT);
}
inline
void
AttributeOffset::setCharsetPos(Uint32 & desc, Uint32 offset) {
ASSERT_MAX(offset, AO_CHARSET_POS_MASK, "AttributeOffset::setCharsetPos");
desc |= (1 << AO_CHARSET_FLAG_SHIFT);
desc |= (offset << AO_CHARSET_POS_SHIFT);
}
inline
@ -55,7 +88,21 @@ inline
Uint32
AttributeOffset::getOffset(const Uint32 & desc)
{
return desc & AO_ATTRIBUTE_OFFSET_MASK;
return (desc >> AO_ATTRIBUTE_OFFSET_SHIFT) & AO_ATTRIBUTE_OFFSET_MASK;
}
inline
bool
AttributeOffset::getCharsetFlag(const Uint32 & desc)
{
return (desc >> AO_CHARSET_FLAG_SHIFT) & 1;
}
inline
Uint32
AttributeOffset::getCharsetPos(const Uint32 & desc)
{
return (desc >> AO_CHARSET_POS_SHIFT) & AO_CHARSET_POS_MASK;
}
inline

View file

@ -502,6 +502,7 @@ struct Fragoperrec {
Uint32 attributeCount;
Uint32 freeNullBit;
Uint32 noOfNewAttrCount;
Uint32 charsetIndex;
BlockReference lqhBlockrefFrag;
};
typedef Ptr<Fragoperrec> FragoperrecPtr;
@ -514,6 +515,7 @@ struct Fragrecord {
Uint32 emptyPrimPage;
Uint32 firstusedOprec;
Uint32 lastusedOprec;
Uint32 thFreeFirst;
Uint32 thFreeCopyFirst;
@ -785,6 +787,7 @@ struct Tablerec {
ReadFunction* readFunctionArray;
UpdateFunction* updateFunctionArray;
CHARSET_INFO** charsetArray;
Uint32 readKeyArray;
Uint32 tabDescriptor;
@ -796,6 +799,7 @@ struct Tablerec {
Uint16 tupheadsize;
Uint16 noOfAttr;
Uint16 noOfKeyAttr;
Uint16 noOfCharsets;
Uint16 noOfNewAttr;
Uint16 noOfNullAttr;
Uint16 noOfAttributeGroups;
@ -1001,17 +1005,20 @@ public:
void tuxGetNode(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32*& node);
/*
* TUX reads primary table attributes for index keys. Input is
* attribute ids in AttributeHeader format. Output is pointers to
* attribute data within tuple or 0 for NULL value.
* TUX reads primary table attributes for index keys. Tuple is
* specified by location of original tuple and version number. Input
* is attribute ids in AttributeHeader format. Output is attribute
* data with headers. Uses readAttributes with xfrm option set.
* Returns number of words or negative (-terrorCode) on error.
*/
void tuxReadAttrs(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32 tupVersion, Uint32 numAttrs, const Uint32* attrIds, const Uint32** attrData);
int tuxReadAttrs(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32 tupVersion, const Uint32* attrIds, Uint32 numAttrs, Uint32* dataOut);
/*
* TUX reads primary key without headers into an array of words. Used
* for md5 summing and when returning keyinfo.
* for md5 summing and when returning keyinfo. Returns number of
* words or negative (-terrorCode) on error.
*/
void tuxReadKeys(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* pkSize, Uint32* pkData);
int tuxReadPk(Uint32 fragPtrI, Uint32 pageId, Uint32 pageOffset, Uint32* dataOut);
/*
* TUX checks if tuple is visible to scan.
@ -1365,10 +1372,11 @@ private:
//------------------------------------------------------------------
int readAttributes(Page* const pagePtr,
Uint32 TupHeadOffset,
Uint32* inBuffer,
const Uint32* inBuffer,
Uint32 inBufLen,
Uint32* outBuffer,
Uint32 TmaxRead);
Uint32 TmaxRead,
bool xfrmFlag);
//------------------------------------------------------------------
//------------------------------------------------------------------
@ -1614,6 +1622,20 @@ private:
Uint32 attrDescriptor,
Uint32 attrDes2);
// *****************************************************************
// Read char routines optionally (tXfrmFlag) apply strxfrm
// *****************************************************************
bool readCharNotNULL(Uint32* outBuffer,
AttributeHeader* ahOut,
Uint32 attrDescriptor,
Uint32 attrDes2);
bool readCharNULLable(Uint32* outBuffer,
AttributeHeader* ahOut,
Uint32 attrDescriptor,
Uint32 attrDes2);
//------------------------------------------------------------------
//------------------------------------------------------------------
bool nullFlagCheck(Uint32 attrDes2);
@ -1632,7 +1654,7 @@ private:
//------------------------------------------------------------------
//------------------------------------------------------------------
void initOpConnection(Operationrec* const regOperPtr);
void initOpConnection(Operationrec* regOperPtr, Fragrecord*);
//------------------------------------------------------------------
//------------------------------------------------------------------
@ -1909,7 +1931,8 @@ private:
void updatePackedList(Signal* signal, Uint16 ahostIndex);
void setUpDescriptorReferences(Uint32 descriptorReference,
Tablerec* const regTabPtr);
Tablerec* const regTabPtr,
const Uint32* offset);
void setUpKeyArray(Tablerec* const regTabPtr);
bool addfragtotab(Tablerec* const regTabPtr, Uint32 fragId, Uint32 fragIndex);
void deleteFragTab(Tablerec* const regTabPtr, Uint32 fragId);
@ -2098,7 +2121,8 @@ private:
//-----------------------------------------------------------------------------
// Public methods
Uint32 allocTabDescr(Uint32 noOfAttributes, Uint32 noOfKeyAttr, Uint32 noOfAttributeGroups);
Uint32 getTabDescrOffsets(const Tablerec* regTabPtr, Uint32* offset);
Uint32 allocTabDescr(const Tablerec* regTabPtr, Uint32* offset);
void freeTabDescr(Uint32 retRef, Uint32 retNo);
Uint32 getTabDescrWord(Uint32 index);
void setTabDescrWord(Uint32 index, Uint32 word);
@ -2217,6 +2241,7 @@ private:
Uint32 tMaxRead;
Uint32 tOutBufIndex;
Uint32* tTupleHeader;
bool tXfrmFlag;
// updateAttributes module
Uint32 tInBufIndex;

View file

@ -77,7 +77,7 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal)
if (regOperPtr.p->optype == ZREAD) {
ljam();
freeAllAttrBuffers(regOperPtr.p);
initOpConnection(regOperPtr.p);
initOpConnection(regOperPtr.p, 0);
return;
}//if
@ -134,7 +134,7 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal)
ndbrequire(regOperPtr.p->tupleState == ALREADY_ABORTED);
commitUpdate(signal, regOperPtr.p, regFragPtr.p, regTabPtr.p);
}//if
initOpConnection(regOperPtr.p);
initOpConnection(regOperPtr.p, regFragPtr.p);
}//execTUP_ABORTREQ()
void Dbtup::setTupleStateOnPreviousOps(Uint32 prevOpIndex)
@ -459,7 +459,7 @@ void Dbtup::tupkeyErrorLab(Signal* signal)
freeAllAttrBuffers(regOperPtr);
abortUpdate(signal, regOperPtr, fragptr.p, tabptr.p);
removeActiveOpList(regOperPtr);
initOpConnection(regOperPtr);
initOpConnection(regOperPtr, fragptr.p);
regOperPtr->transstate = IDLE;
regOperPtr->tupleState = NO_OTHER_OP;
TupKeyRef * const tupKeyRef = (TupKeyRef *)signal->getDataPtrSend();

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