mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Merge kishkin.ru:/home/wax/mysql-4.1 into kishkin.ru:/home/wax/mysql-4g
This commit is contained in:
commit
ed02be687c
226 changed files with 4798 additions and 1971 deletions
|
@ -399,6 +399,7 @@ libmysqld/sql_rename.cc
|
|||
libmysqld/sql_repl.cc
|
||||
libmysqld/sql_select.cc
|
||||
libmysqld/sql_show.cc
|
||||
libmysqld/sql_state.c
|
||||
libmysqld/sql_string.cc
|
||||
libmysqld/sql_table.cc
|
||||
libmysqld/sql_test.cc
|
||||
|
@ -552,6 +553,7 @@ sql-bench/test-select
|
|||
sql-bench/test-transactions
|
||||
sql-bench/test-wisconsin
|
||||
sql/.gdbinit
|
||||
sql/client.c
|
||||
sql/gen_lex_hash
|
||||
sql/gmon.out
|
||||
sql/lex_hash.h
|
||||
|
@ -586,6 +588,7 @@ stamp-h4
|
|||
strings/conf_to_src
|
||||
strings/ctype_autoconf.c
|
||||
strings/ctype_extra_sources.c
|
||||
strings/str_test
|
||||
support-files/MacOSX/Description.plist
|
||||
support-files/MacOSX/Info.plist
|
||||
support-files/MacOSX/ReadMe.txt
|
||||
|
@ -619,4 +622,3 @@ vio/test-ssl
|
|||
vio/test-sslclient
|
||||
vio/test-sslserver
|
||||
vio/viotest-ssl
|
||||
sql/client.c
|
||||
|
|
|
@ -71,6 +71,22 @@ else
|
|||
make=make
|
||||
fi
|
||||
|
||||
if test -z $CXX ; then
|
||||
if test -z "$CXX" ; then
|
||||
CXX=gcc
|
||||
fi
|
||||
|
||||
# If ccache (a compiler cache which reduces build time)
|
||||
# (http://samba.org/ccache) is installed, use it.
|
||||
# We use 'grep' and hope 'grep' will work as expected
|
||||
# (returns 0 if finds lines)
|
||||
if ccache -V > /dev/null 2>&1
|
||||
then
|
||||
if ! (echo "$CC" | grep "ccache" > /dev/null)
|
||||
then
|
||||
CC="ccache $CC"
|
||||
fi
|
||||
if ! (echo "$CXX" | grep "ccache" > /dev/null)
|
||||
then
|
||||
CXX="ccache $CXX"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -40,6 +40,7 @@ jani@hynda.mysql.fi
|
|||
jani@janikt.pp.saunalahti.fi
|
||||
jani@rhols221.adsl.netsonic.fi
|
||||
jani@rhols221.arenanet.fi
|
||||
jani@ua126d19.elisa.omakaista.fi
|
||||
jcole@abel.spaceapes.com
|
||||
jcole@main.burghcom.com
|
||||
jcole@mugatu.spaceapes.com
|
||||
|
|
|
@ -104,6 +104,10 @@ SOURCE=..\mysys\charset.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\libmysql\client.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\completion_hash.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -430,10 +434,6 @@ SOURCE=..\mysys\safemalloc.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\select_test.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\mysys\sha1.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -123,6 +123,10 @@ SOURCE=..\mysys\charset.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\strings\ctype-big5.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -215,10 +219,6 @@ SOURCE=.\libmysql.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Libmysql.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -403,6 +403,10 @@ SOURCE=..\sql\net_serv.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\password.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -411,10 +415,6 @@ SOURCE=..\mysys\safemalloc.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\client\select_test.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\mysys\sha1.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -87,10 +87,10 @@ LINK32=link.exe
|
|||
# Name "libmysqld - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\convert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\derror.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -180,6 +180,10 @@ SOURCE=..\sql\item_func.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\item_geofunc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\item_row.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -236,10 +240,6 @@ SOURCE=..\sql\mf_iocache.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\mini_client.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\net_serv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -256,6 +256,10 @@ SOURCE=..\sql\opt_sum.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\libmysql\pack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\libmysql\password.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -88,6 +88,10 @@ LINK32=link.exe
|
|||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\mysys\mf_tempdir.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\client\mysqlbinlog.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
|
|
|
@ -84,10 +84,6 @@ LIB32=xilink6.exe -lib
|
|||
# Name "mysqldemb - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\convert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\derror.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -220,10 +216,6 @@ SOURCE=..\sql\mf_iocache.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\mini_client.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sql\net_serv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -178,7 +178,7 @@ LINK32=xilink6.exe
|
|||
# Name "mysqld - Win32 Max"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\convert.cpp
|
||||
SOURCE=.\client.c
|
||||
|
||||
!IF "$(CFG)" == "mysqld - Win32 Release"
|
||||
|
||||
|
@ -486,6 +486,10 @@ SOURCE=.\item_func.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\item_geofunc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\item_row.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -656,10 +660,6 @@ SOURCE=.\mf_iocache.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mini_client.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\myisammrg\myrg_rnext_same.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -742,6 +742,10 @@ SOURCE=.\OPT_SUM.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\password.c
|
||||
|
||||
!IF "$(CFG)" == "mysqld - Win32 Release"
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
const char *VER= "14.0";
|
||||
const char *VER= "14.1";
|
||||
|
||||
/* Don't try to make a nice table if the data is too big */
|
||||
#define MAX_COLUMN_LENGTH 1024
|
||||
|
@ -200,7 +200,9 @@ static int com_nopager(String *str, char*), com_pager(String *str, char*),
|
|||
static int read_lines(bool execute_commands);
|
||||
static int sql_connect(char *host,char *database,char *user,char *password,
|
||||
uint silent);
|
||||
static int put_info(const char *str,INFO_TYPE info,uint error=0);
|
||||
static int put_info(const char *str,INFO_TYPE info,uint error=0,
|
||||
const char *sql_state=0);
|
||||
static int put_error(MYSQL *mysql);
|
||||
static void safe_put_field(const char *pos,ulong length);
|
||||
static void xmlencode_print(const char *src, uint length);
|
||||
static void init_pager();
|
||||
|
@ -1437,7 +1439,7 @@ int mysql_real_query_for_lazy(const char *buf, int length)
|
|||
{
|
||||
if (!mysql_real_query(&mysql,buf,length))
|
||||
return 0;
|
||||
uint error=put_info(mysql_error(&mysql),INFO_ERROR, mysql_errno(&mysql));
|
||||
int error= put_error(&mysql);
|
||||
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||
|
||||
!opt_reconnect)
|
||||
return error;
|
||||
|
@ -1452,8 +1454,7 @@ int mysql_store_result_for_lazy(MYSQL_RES **result)
|
|||
return 0;
|
||||
|
||||
if (mysql_error(&mysql)[0])
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
|
||||
return put_error(&mysql);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1664,9 +1665,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
|||
if (quick)
|
||||
{
|
||||
if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql))
|
||||
{
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
}
|
||||
return put_error(&mysql);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1728,7 +1727,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
|||
put_info("",INFO_RESULT); // Empty row
|
||||
|
||||
if (result && !mysql_eof(result)) /* Something wrong when using quick */
|
||||
error=put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
error= put_error(&mysql);
|
||||
else if (unbuffered)
|
||||
fflush(stdout);
|
||||
mysql_free_result(result);
|
||||
|
@ -2442,12 +2441,12 @@ com_use(String *buffer __attribute__((unused)), char *line)
|
|||
if (mysql_select_db(&mysql,tmp))
|
||||
{
|
||||
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR)
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
return put_error(&mysql);
|
||||
|
||||
if (reconnect())
|
||||
return opt_reconnect ? -1 : 1; // Fatal error
|
||||
if (mysql_select_db(&mysql,tmp))
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
return put_error(&mysql);
|
||||
}
|
||||
my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
current_db=my_strdup(tmp,MYF(MY_WME));
|
||||
|
@ -2569,7 +2568,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
|||
(mysql_errno(&mysql) != CR_CONN_HOST_ERROR &&
|
||||
mysql_errno(&mysql) != CR_CONNECTION_ERROR))
|
||||
{
|
||||
put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
(void) put_error(&mysql);
|
||||
(void) fflush(stdout);
|
||||
return ignore_errors ? -1 : 1; // Abort
|
||||
}
|
||||
|
@ -2719,7 +2718,7 @@ select_limit, max_join_size);
|
|||
|
||||
|
||||
static int
|
||||
put_info(const char *str,INFO_TYPE info_type,uint error)
|
||||
put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
|
||||
{
|
||||
FILE *file= (info_type == INFO_ERROR ? stderr : stdout);
|
||||
static int inited=0;
|
||||
|
@ -2764,7 +2763,12 @@ put_info(const char *str,INFO_TYPE info_type,uint error)
|
|||
putchar('\007'); /* This should make a bell */
|
||||
vidattr(A_STANDOUT);
|
||||
if (error)
|
||||
(void) tee_fprintf(file, "ERROR %d: ", error);
|
||||
{
|
||||
if (sqlstate)
|
||||
(void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
|
||||
else
|
||||
(void) tee_fprintf(file, "ERROR %d: ", error);
|
||||
}
|
||||
else
|
||||
tee_puts("ERROR: ", file);
|
||||
}
|
||||
|
@ -2779,6 +2783,14 @@ put_info(const char *str,INFO_TYPE info_type,uint error)
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
put_error(MYSQL *mysql)
|
||||
{
|
||||
return put_info(mysql_error(mysql), INFO_ERROR, mysql_errno(mysql),
|
||||
mysql_sqlstate(mysql));
|
||||
}
|
||||
|
||||
|
||||
static void remove_cntrl(String &buffer)
|
||||
{
|
||||
char *start,*end;
|
||||
|
@ -2929,14 +2941,18 @@ static const char* construct_prompt()
|
|||
add_int_to_prompt(++prompt_counter);
|
||||
break;
|
||||
case 'v':
|
||||
processed_prompt.append(mysql_get_server_info(&mysql));
|
||||
if (connected)
|
||||
processed_prompt.append(mysql_get_server_info(&mysql));
|
||||
else
|
||||
processed_prompt.append("not_connected");
|
||||
break;
|
||||
case 'd':
|
||||
processed_prompt.append(current_db ? current_db : "(none)");
|
||||
break;
|
||||
case 'h':
|
||||
{
|
||||
const char *prompt=mysql_get_host_info(&mysql);
|
||||
const char *prompt;
|
||||
prompt= connected ? mysql_get_host_info(&mysql) : "not_connected";
|
||||
if (strstr(prompt, "Localhost"))
|
||||
processed_prompt.append("localhost");
|
||||
else
|
||||
|
@ -2948,8 +2964,13 @@ static const char* construct_prompt()
|
|||
}
|
||||
case 'p':
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (!connected)
|
||||
{
|
||||
processed_prompt.append("not_connected");
|
||||
break;
|
||||
}
|
||||
if (strstr(mysql_get_host_info(&mysql),"TCP/IP") ||
|
||||
! mysql.unix_socket)
|
||||
!mysql.unix_socket)
|
||||
add_int_to_prompt(mysql.port);
|
||||
else
|
||||
{
|
||||
|
@ -3097,4 +3118,3 @@ void sql_element_free(void *ptr)
|
|||
my_free((gptr) ptr,MYF(0));
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#define MTEST_VERSION "1.27"
|
||||
#define MTEST_VERSION "1.28"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <mysql_embed.h>
|
||||
|
@ -523,8 +523,12 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
|
|||
|
||||
if (!my_stat(eval_file, &stat_info, MYF(MY_WME)))
|
||||
die(NullS);
|
||||
if (!eval_result && stat_info.st_size != ds->length)
|
||||
if (!eval_result && (uint) stat_info.st_size != ds->length)
|
||||
{
|
||||
DBUG_PRINT("info",("Size differs: result size: %u file size: %u",
|
||||
ds->length, stat_info.st_size));
|
||||
DBUG_RETURN(2);
|
||||
}
|
||||
if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
|
||||
die(NullS);
|
||||
|
||||
|
@ -2147,6 +2151,10 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
|
|||
if (i == 0 && q->expected_errors == 1)
|
||||
{
|
||||
/* Only log error if there is one possible error */
|
||||
dynstr_append_mem(ds,"ERROR ",6);
|
||||
replace_dynstr_append_mem(ds, mysql_sqlstate(mysql),
|
||||
strlen(mysql_sqlstate(mysql)));
|
||||
dynstr_append_mem(ds,": ",2);
|
||||
replace_dynstr_append_mem(ds,mysql_error(mysql),
|
||||
strlen(mysql_error(mysql)));
|
||||
dynstr_append_mem(ds,"\n",1);
|
||||
|
|
14
configure.in
14
configure.in
|
@ -359,7 +359,7 @@ then
|
|||
# we will gets some problems when linking static programs.
|
||||
# The following code is used to fix this problem.
|
||||
|
||||
if test "$CXX" = "gcc"
|
||||
if test "$CXX" = "gcc" -o "$CXX" = "ccache gcc"
|
||||
then
|
||||
if $CXX -v 2>&1 | grep 'version 3' > /dev/null 2>&1
|
||||
then
|
||||
|
@ -1023,8 +1023,16 @@ case $SYSTEM_TYPE in
|
|||
;;
|
||||
*freebsd*)
|
||||
echo "Adding fix for interrupted reads"
|
||||
CFLAGS="$CFLAGS -DHAVE_BROKEN_REALPATH"
|
||||
CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000 -DHAVE_BROKEN_REALPATH"
|
||||
OSVERSION=`sysctl -a | grep osreldate | awk '{ print $2 }'`
|
||||
if test "$OSVERSION" -gt "480100" && \
|
||||
test "$OSVERSION" -lt "500000" || \
|
||||
test "$OSVERSION" -gt "500109"
|
||||
then
|
||||
CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000"
|
||||
else
|
||||
CFLAGS="$CFLAGS -DHAVE_BROKEN_REALPATH"
|
||||
CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000 -DHAVE_BROKEN_REALPATH"
|
||||
fi
|
||||
;;
|
||||
*netbsd*)
|
||||
echo "Adding flag -Dunix"
|
||||
|
|
24
dbug/dbug.c
24
dbug/dbug.c
|
@ -280,7 +280,7 @@ static BOOLEAN Writable(char *pathname);
|
|||
static void ChangeOwner(char *pathname);
|
||||
/* Allocate memory for runtime support */
|
||||
#endif
|
||||
static char *DbugMalloc(int size);
|
||||
static char *DbugMalloc(size_t size);
|
||||
/* Remove leading pathname components */
|
||||
static char *BaseName(const char *pathname);
|
||||
static void DoPrefix(uint line);
|
||||
|
@ -1120,7 +1120,7 @@ static void PushState ()
|
|||
init_done=TRUE;
|
||||
}
|
||||
(void) code_state(); /* Alloc memory */
|
||||
new_malloc = (struct state *) DbugMalloc (sizeof (struct state));
|
||||
new_malloc = (struct state *) DbugMalloc(sizeof (struct state));
|
||||
new_malloc -> flags = 0;
|
||||
new_malloc -> delay = 0;
|
||||
new_malloc -> maxdepth = MAXDEPTH;
|
||||
|
@ -1341,11 +1341,10 @@ struct link *linkp)
|
|||
*/
|
||||
|
||||
|
||||
static char *StrDup (
|
||||
const char *str)
|
||||
static char *StrDup (const char *str)
|
||||
{
|
||||
reg1 char *new_malloc;
|
||||
new_malloc = DbugMalloc ((int) strlen (str) + 1);
|
||||
new_malloc = DbugMalloc((size_t) strlen (str) + 1);
|
||||
(void) strcpy (new_malloc, str);
|
||||
return (new_malloc);
|
||||
}
|
||||
|
@ -1606,14 +1605,13 @@ static void DbugExit (const char *why)
|
|||
*
|
||||
*/
|
||||
|
||||
static char *DbugMalloc (
|
||||
int size)
|
||||
static char *DbugMalloc (size_t size)
|
||||
{
|
||||
register char *new_malloc;
|
||||
register char *new_malloc;
|
||||
|
||||
if (!(new_malloc = (char*) malloc ((unsigned int) size)))
|
||||
DbugExit ("out of memory");
|
||||
return (new_malloc);
|
||||
if (!(new_malloc = (char*) malloc((size_t) size)))
|
||||
DbugExit ("out of memory");
|
||||
return (new_malloc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1622,9 +1620,7 @@ int size)
|
|||
* separator (to allow directory-paths in dos).
|
||||
*/
|
||||
|
||||
static char *static_strtok (
|
||||
char *s1,
|
||||
pchar separator)
|
||||
static char *static_strtok (char *s1, pchar separator)
|
||||
{
|
||||
static char *end = NULL;
|
||||
reg1 char *rtnval,*cpy;
|
||||
|
|
|
@ -138,6 +138,11 @@ typedef uint rf_SetTimer;
|
|||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_OFF_T 8
|
||||
#ifdef _WIN64
|
||||
#define SIZEOF_CHARP 8
|
||||
#else
|
||||
#define SIZEOF_CHARP 4
|
||||
#endif
|
||||
#define HAVE_BROKEN_NETINET_INCLUDES
|
||||
#ifdef __NT__
|
||||
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
|
||||
|
@ -203,6 +208,7 @@ inline double ulonglong2double(ulonglong value)
|
|||
|
||||
/* Optimized store functions for Intel x86 */
|
||||
|
||||
#ifndef _WIN64
|
||||
#define sint2korr(A) (*((int16 *) (A)))
|
||||
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
||||
(((uint32) 255L << 24) | \
|
||||
|
@ -243,7 +249,7 @@ inline double ulonglong2double(ulonglong value)
|
|||
#define float8get(V,M) doubleget((V),(M))
|
||||
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
|
||||
#define float8store(V,M) doublestore((V),(M))
|
||||
|
||||
#endif /* _WIN64 */
|
||||
|
||||
#define HAVE_PERROR
|
||||
#define HAVE_VFPRINT
|
||||
|
@ -333,3 +339,5 @@ inline double ulonglong2double(ulonglong value)
|
|||
|
||||
#define shared_memory_buffer_length 16000
|
||||
#define default_shared_memory_base_name "MYSQL"
|
||||
#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
|
||||
#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
|
||||
|
|
|
@ -74,14 +74,14 @@
|
|||
/* Unixware 7 */
|
||||
#if !defined(HAVE_BFILL)
|
||||
# define bfill(A,B,C) memset((A),(C),(B))
|
||||
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
|
||||
# define bmove_align(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BCMP)
|
||||
# define bcopy(s, d, n) memcpy((d), (s), (n))
|
||||
# define bcmp(A,B,C) memcmp((A),(B),(C))
|
||||
# define bzero(A,B) memset((A),0,(B))
|
||||
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
|
||||
# define bmove_align(A,B,C) memcpy((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(OS2)
|
||||
|
@ -111,11 +111,11 @@ extern char NEAR _dig_vec[]; /* Declared in int2str() */
|
|||
#endif
|
||||
|
||||
#ifdef MSDOS
|
||||
#undef bmove_allign
|
||||
#define bmove512(A,B,C) bmove_allign(A,B,C)
|
||||
#undef bmove_align
|
||||
#define bmove512(A,B,C) bmove_align(A,B,C)
|
||||
#define my_itoa(A,B,C) itoa(A,B,C)
|
||||
#define my_ltoa(A,B,C) ltoa(A,B,C)
|
||||
extern void bmove_allign(gptr dst,const gptr src,uint len);
|
||||
extern void bmove_align(gptr dst,const gptr src,uint len);
|
||||
#endif
|
||||
|
||||
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2000 MySQL AB
|
||||
/* Copyright (C) 2000-2003 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -266,7 +266,7 @@ C_MODE_END
|
|||
# endif
|
||||
#endif /* TIME_WITH_SYS_TIME */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT)
|
||||
#if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
|
||||
#define crypt unistd_crypt
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
@ -654,7 +654,13 @@ extern double my_atof(const char*);
|
|||
Max size that must be added to a so that we know Size to make
|
||||
adressable obj.
|
||||
*/
|
||||
#if SIZEOF_CHARP == 4
|
||||
typedef long my_ptrdiff_t;
|
||||
#else
|
||||
typedef long long my_ptrdiff_t;
|
||||
#endif
|
||||
|
||||
|
||||
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
||||
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
||||
/* Size to make adressable obj. */
|
||||
|
@ -731,6 +737,8 @@ typedef unsigned __int64 my_ulonglong;
|
|||
typedef unsigned long long my_ulonglong;
|
||||
#endif
|
||||
|
||||
/* typedef used for length of string; Should be unsigned! */
|
||||
typedef ulong size_str;
|
||||
|
||||
#ifdef USE_RAID
|
||||
/*
|
||||
|
@ -869,7 +877,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */
|
|||
*/
|
||||
|
||||
/* Optimized store functions for Intel x86 */
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__) && !defined(_WIN64)
|
||||
#define sint2korr(A) (*((int16 *) (A)))
|
||||
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
||||
(((uint32) 255L << 24) | \
|
||||
|
|
|
@ -268,7 +268,8 @@ typedef struct st_mysql
|
|||
my_bool free_me; /* If free in mysql_close */
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
unsigned int last_errno;
|
||||
char *last_error;
|
||||
char *last_error; /* Used by embedded server */
|
||||
char sqlstate[SQLSTATE_LENGTH+1]; /* Used by embedded server */
|
||||
} MYSQL;
|
||||
|
||||
#endif
|
||||
|
@ -566,6 +567,7 @@ unsigned long STDCALL mysql_param_count(MYSQL_STMT * stmt);
|
|||
my_bool STDCALL mysql_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
|
||||
my_bool STDCALL mysql_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
|
||||
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
|
||||
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
|
||||
unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
|
||||
const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
|
||||
const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
|
||||
|
|
|
@ -324,6 +324,7 @@ my_bool check_scramble(const char *, const char *message,
|
|||
unsigned long *salt,my_bool old_ver);
|
||||
char *get_tty_password(char *opt_message);
|
||||
void hash_password(unsigned long *result, const char *password);
|
||||
const char *mysql_errno_to_sqlstate(uint mysql_errno);
|
||||
|
||||
/* Some other useful functions */
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#else
|
||||
#define PROTOCOL_VERSION @PROTOCOL_VERSION@
|
||||
#define MYSQL_SERVER_VERSION "@VERSION@"
|
||||
#define MYSQL_BASE_VERSION "mysqld-@MYSQL_BASE_VERSION@"
|
||||
#ifndef MYSQL_SERVER_SUFFIX
|
||||
#define MYSQL_SERVER_SUFFIX "@MYSQL_SERVER_SUFFIX@"
|
||||
#endif
|
||||
|
|
|
@ -282,4 +282,6 @@
|
|||
#define ER_WARN_DATA_TRUNCATED 1263
|
||||
#define ER_WARN_USING_OTHER_HANDLER 1264
|
||||
#define ER_CANT_AGGREGATE_COLLATIONS 1265
|
||||
#define ER_DROP_USER 1266
|
||||
#define ER_REVOKE_GRANTS 1267
|
||||
#define ER_ERROR_MESSAGES 266
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
|
||||
extern const char *unknown_sqlstate;
|
||||
extern const char *not_error_sqlstate;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
164
include/sql_state.h
Normal file
164
include/sql_state.h
Normal file
|
@ -0,0 +1,164 @@
|
|||
/* Copyright (C) 2000-2003 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/*
|
||||
This file includes a mapping from mysql_errno.h to sql_state (as used by
|
||||
MyODBC) and jdbc_state.
|
||||
It's suitable to include into a C struct for further processing
|
||||
|
||||
The first column is the mysqld server error (declared in mysqld_error.h),
|
||||
the second column is the ODBC state (which the 4.1 server sends out by
|
||||
default) and the last is the state used by the JDBC driver.
|
||||
If the last column is "" then it means that the JDBC driver is using the
|
||||
ODBC state
|
||||
|
||||
The errors in this file is sorted in the same order as in mysqld_error.h
|
||||
to allow on to do binary searches for the sqlstate.
|
||||
*/
|
||||
|
||||
ER_DUP_KEY, "23000", "",
|
||||
ER_OUTOFMEMORY, "HY001", "S1001",
|
||||
ER_OUT_OF_SORTMEMORY, "HY001", "S1001",
|
||||
ER_CON_COUNT_ERROR, "08004", "",
|
||||
ER_BAD_HOST_ERROR, "08S01", "",
|
||||
ER_HANDSHAKE_ERROR, "08S01", "",
|
||||
ER_DBACCESS_DENIED_ERROR, "42000", "",
|
||||
ER_ACCESS_DENIED_ERROR, "42000", "28000",
|
||||
ER_NO_DB_ERROR, "42000", "",
|
||||
ER_UNKNOWN_COM_ERROR, "08S01", "",
|
||||
ER_BAD_NULL_ERROR, "23000", "",
|
||||
ER_BAD_DB_ERROR, "42000", "",
|
||||
ER_TABLE_EXISTS_ERROR, "42S01", "",
|
||||
ER_BAD_TABLE_ERROR, "42S02", "",
|
||||
ER_NON_UNIQ_ERROR, "23000", "",
|
||||
ER_SERVER_SHUTDOWN, "08S01", "",
|
||||
ER_BAD_FIELD_ERROR, "42S22", "S0022",
|
||||
ER_WRONG_FIELD_WITH_GROUP, "42000", "S1009",
|
||||
ER_WRONG_GROUP_FIELD, "42000", "S1009",
|
||||
ER_WRONG_SUM_SELECT, "42000", "S1009",
|
||||
ER_WRONG_VALUE_COUNT, "21S01", "",
|
||||
ER_TOO_LONG_IDENT, "42000", "S1009",
|
||||
ER_DUP_FIELDNAME, "42S21", "S1009",
|
||||
ER_DUP_KEYNAME, "42000", "S1009",
|
||||
ER_DUP_ENTRY, "23000", "S1009",
|
||||
ER_WRONG_FIELD_SPEC, "42000", "S1009",
|
||||
ER_PARSE_ERROR, "42000", "",
|
||||
ER_EMPTY_QUERY, "42000" , "",
|
||||
ER_NONUNIQ_TABLE, "42000", "S1009",
|
||||
ER_INVALID_DEFAULT, "42000", "S1009",
|
||||
ER_MULTIPLE_PRI_KEY, "42000", "S1009",
|
||||
ER_TOO_MANY_KEYS, "42000", "S1009",
|
||||
ER_TOO_MANY_KEY_PARTS, "42000", "S1009",
|
||||
ER_TOO_LONG_KEY, "42000", "S1009",
|
||||
ER_KEY_COLUMN_DOES_NOT_EXITS, "42000", "S1009",
|
||||
ER_BLOB_USED_AS_KEY, "42000", "S1009",
|
||||
ER_TOO_BIG_FIELDLENGTH, "42000", "S1009",
|
||||
ER_WRONG_AUTO_KEY, "42000", "S1009",
|
||||
ER_FORCING_CLOSE, "08S01", "",
|
||||
ER_IPSOCK_ERROR, "088S01", "",
|
||||
ER_NO_SUCH_INDEX, "42S12", "S1009",
|
||||
ER_WRONG_FIELD_TERMINATORS, "42000", "S1009",
|
||||
ER_BLOBS_AND_NO_TERMINATED, "42000", "S1009",
|
||||
ER_CANT_REMOVE_ALL_FIELDS, "42000", "",
|
||||
ER_CANT_DROP_FIELD_OR_KEY, "42000", "",
|
||||
ER_BLOB_CANT_HAVE_DEFAULT, "42000", "",
|
||||
ER_WRONG_DB_NAME, "42000", "",
|
||||
ER_WRONG_TABLE_NAME, "42000", "",
|
||||
ER_TOO_BIG_SELECT, "42000", "",
|
||||
ER_UNKNOWN_PROCEDURE, "42000", "",
|
||||
ER_WRONG_PARAMCOUNT_TO_PROCEDURE, "42000", "",
|
||||
ER_UNKNOWN_TABLE, "42S02", "",
|
||||
ER_FIELD_SPECIFIED_TWICE, "42000", "",
|
||||
ER_UNSUPPORTED_EXTENSION, "42000", "",
|
||||
ER_TABLE_MUST_HAVE_COLUMNS, "42000", "",
|
||||
ER_UNKNOWN_CHARACTER_SET, "42000", "",
|
||||
ER_TOO_BIG_ROWSIZE, "42000", "",
|
||||
ER_STACK_OVERRUN, "HY000", "",
|
||||
ER_WRONG_OUTER_JOIN, "42000", "",
|
||||
ER_NULL_COLUMN_IN_INDEX, "42000", "",
|
||||
ER_PASSWORD_ANONYMOUS_USER, "42000", "",
|
||||
ER_PASSWORD_NOT_ALLOWED, "42000", "",
|
||||
ER_PASSWORD_NO_MATCH, "42000", "",
|
||||
ER_WRONG_VALUE_COUNT_ON_ROW, "21S01", "",
|
||||
ER_INVALID_USE_OF_NULL, "42000", "",
|
||||
ER_REGEXP_ERROR, "42000", "",
|
||||
ER_MIX_OF_GROUP_FUNC_AND_FIELDS,"42000", "",
|
||||
ER_NONEXISTING_GRANT, "42000", "",
|
||||
ER_TABLEACCESS_DENIED_ERROR, "42000", "",
|
||||
ER_COLUMNACCESS_DENIED_ERROR, "42000", "",
|
||||
ER_ILLEGAL_GRANT_FOR_TABLE, "42000", "",
|
||||
ER_GRANT_WRONG_HOST_OR_USER, "42000", "",
|
||||
ER_NO_SUCH_TABLE, "42S02", "",
|
||||
ER_NONEXISTING_TABLE_GRANT, "42000", "",
|
||||
ER_NOT_ALLOWED_COMMAND, "42000", "",
|
||||
ER_SYNTAX_ERROR, "42000", "",
|
||||
ER_ABORTING_CONNECTION, "08S01", "",
|
||||
ER_NET_PACKET_TOO_LARGE, "08S01", "",
|
||||
ER_NET_READ_ERROR_FROM_PIPE, "08S01", "",
|
||||
ER_NET_FCNTL_ERROR, "08S01", "",
|
||||
ER_NET_PACKETS_OUT_OF_ORDER, "08S01", "",
|
||||
ER_NET_UNCOMPRESS_ERROR, "08S01", "",
|
||||
ER_NET_READ_ERROR, "08S01", "",
|
||||
ER_NET_READ_INTERRUPTED, "08S01", "",
|
||||
ER_NET_ERROR_ON_WRITE, "08S01", "",
|
||||
ER_NET_WRITE_INTERRUPTED, "08S01", "",
|
||||
ER_TOO_LONG_STRING, "42000", "",
|
||||
ER_TABLE_CANT_HANDLE_BLOB, "42000", "",
|
||||
ER_TABLE_CANT_HANDLE_AUTO_INCREMENT, "42000", "",
|
||||
ER_WRONG_COLUMN_NAME, "42000", "",
|
||||
ER_WRONG_KEY_COLUMN, "42000", "",
|
||||
ER_DUP_UNIQUE, "23000", "",
|
||||
ER_BLOB_KEY_WITHOUT_LENGTH, "42000", "",
|
||||
ER_PRIMARY_CANT_HAVE_NULL, "42000", "",
|
||||
ER_TOO_MANY_ROWS, "42000", "",
|
||||
ER_REQUIRES_PRIMARY_KEY, "42000", "",
|
||||
ER_CHECK_NO_SUCH_TABLE, "42000", "",
|
||||
ER_CHECK_NOT_IMPLEMENTED, "42000", "",
|
||||
ER_CANT_DO_THIS_DURING_AN_TRANSACTION, "25000", "",
|
||||
ER_ERROR_DURING_COMMIT, "HY000", "",
|
||||
ER_ERROR_DURING_ROLLBACK, "HY000", "",
|
||||
ER_NEW_ABORTING_CONNECTION, "08S01", "",
|
||||
ER_MASTER_NET_READ, "08S01", "",
|
||||
ER_MASTER_NET_WRITE, "08S01", "",
|
||||
ER_TOO_MANY_USER_CONNECTIONS, "42000", "",
|
||||
ER_READ_ONLY_TRANSACTION, "25000", "",
|
||||
ER_NO_PERMISSION_TO_CREATE_USER,"42000", "",
|
||||
ER_LOCK_DEADLOCK, "40001", "",
|
||||
ER_NO_REFERENCED_ROW, "23000", "",
|
||||
ER_ROW_IS_REFERENCED, "23000", "",
|
||||
ER_CONNECT_TO_MASTER, "08S01", "",
|
||||
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,"21000", "",
|
||||
ER_USER_LIMIT_REACHED, "42000", "",
|
||||
ER_NO_DEFAULT, "42000", "",
|
||||
ER_WRONG_VALUE_FOR_VAR, "42000", "",
|
||||
ER_WRONG_TYPE_FOR_VAR, "42000", "",
|
||||
ER_CANT_USE_OPTION_HERE, "42000", "",
|
||||
ER_NOT_SUPPORTED_YET, "42000", "",
|
||||
ER_WRONG_FK_DEF, "42000", "",
|
||||
ER_CARDINALITY_COL, "21000", "",
|
||||
ER_SUBSELECT_NO_1_ROW, "21000", "",
|
||||
ER_ILLEGAL_REFERENCE, "42S22", "",
|
||||
ER_DERIVED_MUST_HAVE_ALIAS, "42000", "",
|
||||
ER_SELECT_REDUCED, "01000", "",
|
||||
ER_TABLENAME_NOT_ALLOWED_HERE, "42000", "",
|
||||
ER_NOT_SUPPORTED_AUTH_MODE, "08004", "",
|
||||
ER_SPATIAL_CANT_HAVE_NULL, "42000", "",
|
||||
ER_COLLATION_CHARSET_MISMATCH, "42000", "",
|
||||
ER_WARN_TOO_FEW_RECORDS, "01000", "",
|
||||
ER_WARN_TOO_MANY_RECORDS, "01000", "",
|
||||
ER_WARN_NULL_TO_NOTNULL, "01000", "",
|
||||
ER_WARN_DATA_OUT_OF_RANGE, "01000", "",
|
||||
ER_WARN_DATA_TRUNCATED, "01000", "",
|
|
@ -100,10 +100,10 @@ typedef struct st_alarm {
|
|||
#define thr_alarm_init(A) (*(A))=0
|
||||
#define thr_alarm_in_use(A) (*(A)!= 0)
|
||||
void init_thr_alarm(uint max_alarm);
|
||||
bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
|
||||
my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
|
||||
void thr_alarm_kill(pthread_t thread_id);
|
||||
void thr_end_alarm(thr_alarm_t *alarmed);
|
||||
void end_thr_alarm(void);
|
||||
void end_thr_alarm(my_bool free_structures);
|
||||
sig_handler process_alarm(int);
|
||||
#ifndef thr_got_alarm
|
||||
bool thr_got_alarm(thr_alarm_t *alrm);
|
||||
|
|
|
@ -103,7 +103,8 @@ struct com_shm_endpoint_struct{
|
|||
the area currently may contain a datagram;
|
||||
NOTE: automatic event */
|
||||
os_event_t empty; /* this is in the signaled state if the area
|
||||
currently may be empty; NOTE: automatic event */
|
||||
currently may be empty; NOTE: automatic
|
||||
event */
|
||||
ip_mutex_hdl_t* ip_mutex; /* handle to the interprocess mutex
|
||||
protecting the shared memory */
|
||||
UT_LIST_NODE_T(com_shm_endpoint_t) list; /* If the endpoint struct
|
||||
|
@ -793,16 +794,18 @@ com_shm_create_or_open(
|
|||
|
||||
ut_strcpy(buf + len, (char*)"_IBSHM_EV_NE"),
|
||||
|
||||
event_ne = os_event_create_auto(buf);
|
||||
event_ne = os_event_create(buf);
|
||||
|
||||
ut_ad(event_ne);
|
||||
|
||||
ut_strcpy(buf + len, (char*)"_IBSHM_EV_EM"),
|
||||
|
||||
event_em = os_event_create_auto(buf);
|
||||
event_em = os_event_create(buf);
|
||||
|
||||
ut_ad(event_em);
|
||||
|
||||
ut_a(0); /* event_ne and event_em should be auto events! */
|
||||
|
||||
com_shm_endpoint_set_shm(ep, shm);
|
||||
com_shm_endpoint_set_map(ep, map);
|
||||
|
||||
|
|
|
@ -301,6 +301,13 @@ os_aio(
|
|||
are ignored */
|
||||
void* message2);
|
||||
/****************************************************************************
|
||||
Wakes up all async i/o threads so that they know to exit themselves in
|
||||
shutdown. */
|
||||
|
||||
void
|
||||
os_aio_wake_all_threads_at_shutdown(void);
|
||||
/*=====================================*/
|
||||
/****************************************************************************
|
||||
Waits until there are no pending writes in os_aio_write_array. There can
|
||||
be other, synchronous, pending writes. */
|
||||
|
||||
|
|
|
@ -10,15 +10,29 @@ Created 9/6/1995 Heikki Tuuri
|
|||
#define os0sync_h
|
||||
|
||||
#include "univ.i"
|
||||
#include "ut0lst.h"
|
||||
|
||||
#ifdef __WIN__
|
||||
|
||||
#define os_fast_mutex_t CRITICAL_SECTION
|
||||
typedef void* os_event_t;
|
||||
|
||||
typedef HANDLE os_native_event_t;
|
||||
|
||||
typedef struct os_event_struct os_event_struct_t;
|
||||
typedef os_event_struct_t* os_event_t;
|
||||
|
||||
struct os_event_struct {
|
||||
os_native_event_t handle;
|
||||
/* Windows event */
|
||||
UT_LIST_NODE_T(os_event_struct_t) os_event_list;
|
||||
/* list of all created events */
|
||||
};
|
||||
#else
|
||||
|
||||
typedef pthread_mutex_t os_fast_mutex_t;
|
||||
|
||||
typedef struct os_event_struct os_event_struct_t;
|
||||
typedef os_event_struct_t* os_event_t;
|
||||
|
||||
struct os_event_struct {
|
||||
os_fast_mutex_t os_mutex; /* this mutex protects the next
|
||||
fields */
|
||||
|
@ -26,9 +40,9 @@ struct os_event_struct {
|
|||
not reserved */
|
||||
pthread_cond_t cond_var; /* condition variable is used in
|
||||
waiting for the event */
|
||||
UT_LIST_NODE_T(os_event_struct_t) os_event_list;
|
||||
/* list of all created events */
|
||||
};
|
||||
typedef struct os_event_struct os_event_struct_t;
|
||||
typedef os_event_struct_t* os_event_t;
|
||||
#endif
|
||||
|
||||
typedef struct os_mutex_struct os_mutex_str_t;
|
||||
|
@ -38,10 +52,32 @@ typedef os_mutex_str_t* os_mutex_t;
|
|||
|
||||
#define OS_SYNC_TIME_EXCEEDED 1
|
||||
|
||||
/* Mutex protecting counts and the event and OS 'slow' mutex lists */
|
||||
extern os_mutex_t os_sync_mutex;
|
||||
|
||||
/* This is incremented by 1 in os_thread_create and decremented by 1 in
|
||||
os_thread_exit */
|
||||
extern ulint os_thread_count;
|
||||
|
||||
extern ulint os_event_count;
|
||||
extern ulint os_mutex_count;
|
||||
extern ulint os_fast_mutex_count;
|
||||
|
||||
/*************************************************************
|
||||
Creates an event semaphore, i.e., a semaphore which may
|
||||
just have two states: signaled and nonsignaled.
|
||||
The created event is manual reset: it must be reset
|
||||
Initializes global event and OS 'slow' mutex lists. */
|
||||
|
||||
void
|
||||
os_sync_init(void);
|
||||
/*==============*/
|
||||
/*************************************************************
|
||||
Frees created events and OS 'slow' mutexes. */
|
||||
|
||||
void
|
||||
os_sync_free(void);
|
||||
/*==============*/
|
||||
/*************************************************************
|
||||
Creates an event semaphore, i.e., a semaphore which may just have two states:
|
||||
signaled and nonsignaled. The created event is manual reset: it must be reset
|
||||
explicitly by calling sync_os_reset_event. */
|
||||
|
||||
os_event_t
|
||||
|
@ -50,10 +86,10 @@ os_event_create(
|
|||
/* out: the event handle */
|
||||
char* name); /* in: the name of the event, if NULL
|
||||
the event is created without a name */
|
||||
#ifdef __WIN__
|
||||
/*************************************************************
|
||||
Creates an auto-reset event semaphore, i.e., an event
|
||||
which is automatically reset when a single thread is
|
||||
released. */
|
||||
Creates an auto-reset event semaphore, i.e., an event which is automatically
|
||||
reset when a single thread is released. Works only in Windows. */
|
||||
|
||||
os_event_t
|
||||
os_event_create_auto(
|
||||
|
@ -61,6 +97,7 @@ os_event_create_auto(
|
|||
/* out: the event handle */
|
||||
char* name); /* in: the name of the event, if NULL
|
||||
the event is created without a name */
|
||||
#endif
|
||||
/**************************************************************
|
||||
Sets an event semaphore to the signaled state: lets waiting threads
|
||||
proceed. */
|
||||
|
@ -85,7 +122,10 @@ os_event_free(
|
|||
/*==========*/
|
||||
os_event_t event); /* in: event to free */
|
||||
/**************************************************************
|
||||
Waits for an event object until it is in the signaled state. */
|
||||
Waits for an event object until it is in the signaled state. If
|
||||
srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the
|
||||
waiting thread when the event becomes signaled (or immediately if the
|
||||
event is already in the signaled state). */
|
||||
|
||||
void
|
||||
os_event_wait(
|
||||
|
@ -93,7 +133,7 @@ os_event_wait(
|
|||
os_event_t event); /* in: event to wait */
|
||||
/**************************************************************
|
||||
Waits for an event object until it is in the signaled state or
|
||||
a timeout is exceeded. */
|
||||
a timeout is exceeded. In Unix the timeout is always infinite. */
|
||||
|
||||
ulint
|
||||
os_event_wait_time(
|
||||
|
@ -104,8 +144,9 @@ os_event_wait_time(
|
|||
os_event_t event, /* in: event to wait */
|
||||
ulint time); /* in: timeout in microseconds, or
|
||||
OS_SYNC_INFINITE_TIME */
|
||||
#ifdef __WIN__
|
||||
/**************************************************************
|
||||
Waits for any event in an event array. Returns if even a single
|
||||
Waits for any event in an OS native event array. Returns if even a single
|
||||
one is signaled or becomes signaled. */
|
||||
|
||||
ulint
|
||||
|
@ -113,14 +154,15 @@ os_event_wait_multiple(
|
|||
/*===================*/
|
||||
/* out: index of the event
|
||||
which was signaled */
|
||||
ulint n, /* in: number of events in the
|
||||
ulint n, /* in: number of events in the
|
||||
array */
|
||||
os_event_t* event_array); /* in: pointer to an array of event
|
||||
os_native_event_t* native_event_array);
|
||||
/* in: pointer to an array of event
|
||||
handles */
|
||||
#endif
|
||||
/*************************************************************
|
||||
Creates an operating system mutex semaphore.
|
||||
Because these are slow, the mutex semaphore of the database
|
||||
itself (sync_mutex_t) should be used where possible. */
|
||||
Creates an operating system mutex semaphore. Because these are slow, the
|
||||
mutex semaphore of InnoDB itself (mutex_t) should be used where possible. */
|
||||
|
||||
os_mutex_t
|
||||
os_mutex_create(
|
||||
|
|
|
@ -44,4 +44,3 @@ os_fast_mutex_trylock(
|
|||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ typedef os_thread_t os_thread_id_t; /* In Unix we use the thread
|
|||
the thread */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define a function pointer type to use in a typecast */
|
||||
typedef void* (*os_posix_f_t) (void*);
|
||||
|
||||
|
@ -66,7 +65,9 @@ os_thread_pf(
|
|||
/********************************************************************
|
||||
Creates a new thread of execution. The execution starts from
|
||||
the function given. The start function takes a void* parameter
|
||||
and returns a ulint. */
|
||||
and returns a ulint.
|
||||
NOTE: We count the number of threads in os_thread_exit(). A created
|
||||
thread should always use that to exit and not use return() to exit. */
|
||||
|
||||
os_thread_t
|
||||
os_thread_create(
|
||||
|
@ -83,12 +84,13 @@ os_thread_create(
|
|||
os_thread_id_t* thread_id); /* out: id of the created
|
||||
thread */
|
||||
/*********************************************************************
|
||||
A thread calling this function ends its execution. */
|
||||
Exits the current thread. */
|
||||
|
||||
void
|
||||
os_thread_exit(
|
||||
/*===========*/
|
||||
ulint code); /* in: exit code */
|
||||
void* exit_value); /* in: exit value; in Windows this void*
|
||||
is cast as a DWORD */
|
||||
/*********************************************************************
|
||||
Returns the thread identifier of current thread. */
|
||||
|
||||
|
@ -144,7 +146,6 @@ ulint
|
|||
os_thread_get_last_error(void);
|
||||
/*==========================*/
|
||||
|
||||
|
||||
#ifndef UNIV_NONINL
|
||||
#include "os0thread.ic"
|
||||
#endif
|
||||
|
|
|
@ -212,6 +212,12 @@ void
|
|||
srv_init(void);
|
||||
/*==========*/
|
||||
/*************************************************************************
|
||||
Frees the OS fast mutex created in srv_init(). */
|
||||
|
||||
void
|
||||
srv_free(void);
|
||||
/*==========*/
|
||||
/*************************************************************************
|
||||
Initializes the synchronization primitives, memory system, and the thread
|
||||
local storage. */
|
||||
|
||||
|
|
|
@ -86,11 +86,12 @@ extern ibool srv_startup_is_before_trx_rollback_phase;
|
|||
extern ibool srv_is_being_shut_down;
|
||||
|
||||
/* At a shutdown the value first climbs from 0 to SRV_SHUTDOWN_CLEANUP
|
||||
and then to SRV_SHUTDOWN_LAST_PHASE */
|
||||
and then to SRV_SHUTDOWN_LAST_PHASE, and so on */
|
||||
|
||||
extern ulint srv_shutdown_state;
|
||||
|
||||
#define SRV_SHUTDOWN_CLEANUP 1
|
||||
#define SRV_SHUTDOWN_LAST_PHASE 2
|
||||
#define SRV_SHUTDOWN_CLEANUP 1
|
||||
#define SRV_SHUTDOWN_LAST_PHASE 2
|
||||
#define SRV_SHUTDOWN_EXIT_THREADS 3
|
||||
|
||||
#endif
|
||||
|
|
|
@ -187,7 +187,11 @@ management to ensure correct alignment for doubles etc. */
|
|||
/* Another basic type we use is unsigned long integer which is intended to be
|
||||
equal to the word size of the machine. */
|
||||
|
||||
#ifdef _WIN64
|
||||
typedef unsigned __int64 ulint;
|
||||
#else
|
||||
typedef unsigned long int ulint;
|
||||
#endif
|
||||
|
||||
typedef long int lint;
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ log_pad_current_log_block(void)
|
|||
log_close();
|
||||
log_release();
|
||||
|
||||
ut_a((ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE)
|
||||
ut_ad((ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE)
|
||||
== LOG_BLOCK_HDR_SIZE);
|
||||
}
|
||||
|
||||
|
@ -998,6 +998,8 @@ log_group_file_header_flush(
|
|||
{
|
||||
byte* buf;
|
||||
ulint dest_offset;
|
||||
|
||||
UT_NOT_USED(type);
|
||||
|
||||
ut_ad(mutex_own(&(log_sys->mutex)));
|
||||
|
||||
|
@ -1068,8 +1070,8 @@ log_group_write_buf(
|
|||
ulint i;
|
||||
|
||||
ut_ad(mutex_own(&(log_sys->mutex)));
|
||||
ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0);
|
||||
ut_a(ut_dulint_get_low(start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0);
|
||||
ut_ad(len % OS_FILE_LOG_BLOCK_SIZE == 0);
|
||||
ut_ad(ut_dulint_get_low(start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0);
|
||||
|
||||
if (new_data_offset == 0) {
|
||||
write_header = TRUE;
|
||||
|
@ -2901,10 +2903,9 @@ logs_empty_and_mark_files_at_shutdown(void)
|
|||
dulint lsn;
|
||||
ulint arch_log_no;
|
||||
|
||||
if (srv_print_verbose_log)
|
||||
{
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Starting shutdown...\n");
|
||||
if (srv_print_verbose_log) {
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Starting shutdown...\n");
|
||||
}
|
||||
/* Wait until the master thread and all other operations are idle: our
|
||||
algorithm only works if the server is idle at shutdown */
|
||||
|
@ -3006,15 +3007,17 @@ loop:
|
|||
goto loop;
|
||||
}
|
||||
|
||||
/* Make some checks that the server really is quiet */
|
||||
ut_a(buf_all_freed());
|
||||
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn));
|
||||
|
||||
fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
|
||||
|
||||
fil_flush_file_spaces(FIL_TABLESPACE);
|
||||
|
||||
if (srv_print_verbose_log)
|
||||
{
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Shutdown completed\n");
|
||||
}
|
||||
/* Make some checks that the server really is quiet */
|
||||
ut_a(buf_all_freed());
|
||||
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn));
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
|
|
|
@ -80,6 +80,8 @@ struct os_aio_slot_struct{
|
|||
which pending aio operation was
|
||||
completed */
|
||||
#ifdef WIN_ASYNC_IO
|
||||
os_event_t event; /* event object we need in the
|
||||
OVERLAPPED struct */
|
||||
OVERLAPPED control; /* Windows control block for the
|
||||
aio request */
|
||||
#elif defined(POSIX_ASYNC_IO)
|
||||
|
@ -107,11 +109,14 @@ struct os_aio_array_struct{
|
|||
ulint n_reserved;/* Number of reserved slots in the
|
||||
aio array outside the ibuf segment */
|
||||
os_aio_slot_t* slots; /* Pointer to the slots in the array */
|
||||
os_event_t* events; /* Pointer to an array of event handles
|
||||
where we copied the handles from slots,
|
||||
in the same order. This can be used in
|
||||
WaitForMultipleObjects; used only in
|
||||
#ifdef __WIN__
|
||||
os_native_event_t* native_events;
|
||||
/* Pointer to an array of OS native event
|
||||
handles where we copied the handles from
|
||||
slots, in the same order. This can be used
|
||||
in WaitForMultipleObjects; used only in
|
||||
Windows */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Array of events used in simulated aio */
|
||||
|
@ -295,7 +300,8 @@ os_file_handle_error(
|
|||
/* out: TRUE if we should retry the
|
||||
operation */
|
||||
os_file_t file, /* in: file pointer */
|
||||
char* name) /* in: name of a file or NULL */
|
||||
char* name, /* in: name of a file or NULL */
|
||||
const char* operation)/* in: operation */
|
||||
{
|
||||
ulint err;
|
||||
|
||||
|
@ -338,6 +344,7 @@ os_file_handle_error(
|
|||
fprintf(stderr, "InnoDB: File name %s\n", name);
|
||||
}
|
||||
|
||||
fprintf(stderr, "InnoDB: System call %s.\n", operation);
|
||||
fprintf(stderr, "InnoDB: Cannot continue operation.\n");
|
||||
|
||||
fflush(stderr);
|
||||
|
@ -419,8 +426,9 @@ try_again:
|
|||
if (file == INVALID_HANDLE_VALUE) {
|
||||
*success = FALSE;
|
||||
|
||||
retry = os_file_handle_error(file, name);
|
||||
|
||||
retry = os_file_handle_error(file, name,
|
||||
create_mode == OS_FILE_OPEN ?
|
||||
"open" : "create");
|
||||
if (retry) {
|
||||
goto try_again;
|
||||
}
|
||||
|
@ -460,8 +468,9 @@ try_again:
|
|||
if (file == -1) {
|
||||
*success = FALSE;
|
||||
|
||||
retry = os_file_handle_error(file, name);
|
||||
|
||||
retry = os_file_handle_error(file, name,
|
||||
create_mode == OS_FILE_OPEN ?
|
||||
"open" : "create");
|
||||
if (retry) {
|
||||
goto try_again;
|
||||
}
|
||||
|
@ -568,8 +577,9 @@ try_again:
|
|||
if (file == INVALID_HANDLE_VALUE) {
|
||||
*success = FALSE;
|
||||
|
||||
retry = os_file_handle_error(file, name);
|
||||
|
||||
retry = os_file_handle_error(file, name,
|
||||
create_mode == OS_FILE_OPEN ?
|
||||
"open" : "create");
|
||||
if (retry) {
|
||||
goto try_again;
|
||||
}
|
||||
|
@ -615,8 +625,9 @@ try_again:
|
|||
if (file == -1) {
|
||||
*success = FALSE;
|
||||
|
||||
retry = os_file_handle_error(file, name);
|
||||
|
||||
retry = os_file_handle_error(file, name,
|
||||
create_mode == OS_FILE_OPEN ?
|
||||
"open" : "create");
|
||||
if (retry) {
|
||||
goto try_again;
|
||||
}
|
||||
|
@ -649,7 +660,7 @@ os_file_close(
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
os_file_handle_error(file, NULL);
|
||||
os_file_handle_error(file, NULL, "close");
|
||||
return(FALSE);
|
||||
#else
|
||||
int ret;
|
||||
|
@ -657,7 +668,7 @@ os_file_close(
|
|||
ret = close(file);
|
||||
|
||||
if (ret == -1) {
|
||||
os_file_handle_error(file, NULL);
|
||||
os_file_handle_error(file, NULL, "close");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
@ -825,7 +836,7 @@ os_file_flush(
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
os_file_handle_error(file, NULL);
|
||||
os_file_handle_error(file, NULL, "flush");
|
||||
|
||||
/* It is a fatal error if a file flush does not succeed, because then
|
||||
the database can get corrupt on disk */
|
||||
|
@ -858,7 +869,7 @@ os_file_flush(
|
|||
fprintf(stderr,
|
||||
" InnoDB: Error: the OS said file flush did not succeed\n");
|
||||
|
||||
os_file_handle_error(file, NULL);
|
||||
os_file_handle_error(file, NULL, "flush");
|
||||
|
||||
/* It is a fatal error if a file flush does not succeed, because then
|
||||
the database can get corrupt on disk */
|
||||
|
@ -1099,7 +1110,7 @@ try_again:
|
|||
#ifdef __WIN__
|
||||
error_handling:
|
||||
#endif
|
||||
retry = os_file_handle_error(file, NULL);
|
||||
retry = os_file_handle_error(file, NULL, "read");
|
||||
|
||||
if (retry) {
|
||||
goto try_again;
|
||||
|
@ -1295,7 +1306,6 @@ os_aio_array_create(
|
|||
#endif
|
||||
ut_a(n > 0);
|
||||
ut_a(n_segments > 0);
|
||||
ut_a(n % n_segments == 0);
|
||||
|
||||
array = ut_malloc(sizeof(os_aio_array_t));
|
||||
|
||||
|
@ -1309,19 +1319,22 @@ os_aio_array_create(
|
|||
array->n_segments = n_segments;
|
||||
array->n_reserved = 0;
|
||||
array->slots = ut_malloc(n * sizeof(os_aio_slot_t));
|
||||
array->events = ut_malloc(n * sizeof(os_event_t));
|
||||
|
||||
#ifdef __WIN__
|
||||
array->native_events = ut_malloc(n * sizeof(os_native_event_t));
|
||||
#endif
|
||||
for (i = 0; i < n; i++) {
|
||||
slot = os_aio_array_get_nth_slot(array, i);
|
||||
|
||||
slot->pos = i;
|
||||
slot->reserved = FALSE;
|
||||
#ifdef WIN_ASYNC_IO
|
||||
slot->event = os_event_create(NULL);
|
||||
|
||||
over = &(slot->control);
|
||||
|
||||
over->hEvent = os_event_create(NULL);
|
||||
over->hEvent = slot->event->handle;
|
||||
|
||||
*((array->events) + i) = over->hEvent;
|
||||
*((array->native_events) + i) = over->hEvent;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1404,6 +1417,50 @@ os_aio_init(
|
|||
pthread_sigmask(SIG_BLOCK, &sigset, NULL); */
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN_ASYNC_IO
|
||||
/****************************************************************************
|
||||
Wakes up all async i/o threads in the array in Windows async i/o at
|
||||
shutdown. */
|
||||
static
|
||||
void
|
||||
os_aio_array_wake_win_aio_at_shutdown(
|
||||
/*==================================*/
|
||||
os_aio_array_t* array) /* in: aio array */
|
||||
{
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < array->n_slots; i++) {
|
||||
|
||||
os_event_set((array->slots + i)->event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
Wakes up all async i/o threads so that they know to exit themselves in
|
||||
shutdown. */
|
||||
|
||||
void
|
||||
os_aio_wake_all_threads_at_shutdown(void)
|
||||
/*=====================================*/
|
||||
{
|
||||
ulint i;
|
||||
|
||||
#ifdef WIN_ASYNC_IO
|
||||
/* This code wakes up all ai/o threads in Windows native aio */
|
||||
os_aio_array_wake_win_aio_at_shutdown(os_aio_read_array);
|
||||
os_aio_array_wake_win_aio_at_shutdown(os_aio_write_array);
|
||||
os_aio_array_wake_win_aio_at_shutdown(os_aio_ibuf_array);
|
||||
os_aio_array_wake_win_aio_at_shutdown(os_aio_log_array);
|
||||
#endif
|
||||
/* This loop wakes up all simulated ai/o threads */
|
||||
|
||||
for (i = 0; i < os_aio_n_segments; i++) {
|
||||
|
||||
os_event_set(os_aio_segment_wait_events[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Waits until there are no pending writes in os_aio_write_array. There can
|
||||
|
@ -1635,7 +1692,7 @@ loop:
|
|||
control = &(slot->control);
|
||||
control->Offset = (DWORD)offset;
|
||||
control->OffsetHigh = (DWORD)offset_high;
|
||||
os_event_reset(control->hEvent);
|
||||
os_event_reset(slot->event);
|
||||
|
||||
#elif defined(POSIX_ASYNC_IO)
|
||||
|
||||
|
@ -1693,7 +1750,7 @@ os_aio_array_free_slot(
|
|||
}
|
||||
|
||||
#ifdef WIN_ASYNC_IO
|
||||
os_event_reset(slot->control.hEvent);
|
||||
os_event_reset(slot->event);
|
||||
#endif
|
||||
os_mutex_exit(array->mutex);
|
||||
}
|
||||
|
@ -1818,7 +1875,7 @@ os_aio(
|
|||
offset where to read or write */
|
||||
ulint offset_high, /* in: most significant 32 bits of
|
||||
offset */
|
||||
ulint n, /* in: number of bytes to read or write */
|
||||
ulint n, /* in: number of bytes to read or write */
|
||||
void* message1,/* in: messages for the aio handler (these
|
||||
can be used to identify a completed aio
|
||||
operation); if mode is OS_AIO_SYNC, these
|
||||
|
@ -1862,7 +1919,8 @@ os_aio(
|
|||
wait in the Windows case. */
|
||||
|
||||
if (type == OS_FILE_READ) {
|
||||
return(os_file_read(file, buf, offset, offset_high, n));
|
||||
return(os_file_read(file, buf, offset,
|
||||
offset_high, n));
|
||||
}
|
||||
|
||||
ut_a(type == OS_FILE_WRITE);
|
||||
|
@ -1940,8 +1998,7 @@ try_again:
|
|||
#ifdef WIN_ASYNC_IO
|
||||
if (os_aio_use_native_aio) {
|
||||
if ((ret && len == n)
|
||||
|| (!ret && GetLastError() == ERROR_IO_PENDING)) {
|
||||
|
||||
|| (!ret && GetLastError() == ERROR_IO_PENDING)) {
|
||||
/* aio was queued successfully! */
|
||||
|
||||
if (mode == OS_AIO_SYNC) {
|
||||
|
@ -1971,8 +2028,8 @@ try_again:
|
|||
|
||||
os_aio_array_free_slot(array, slot);
|
||||
|
||||
retry = os_file_handle_error(file, name);
|
||||
|
||||
retry = os_file_handle_error(file, name,
|
||||
type == OS_FILE_READ ? "aio read" : "aio write");
|
||||
if (retry) {
|
||||
|
||||
goto try_again;
|
||||
|
@ -2037,15 +2094,15 @@ os_aio_windows_handle(
|
|||
n = array->n_slots / array->n_segments;
|
||||
|
||||
if (array == os_aio_sync_array) {
|
||||
srv_io_thread_op_info[orig_seg] = "wait Windows aio for 1 page";
|
||||
|
||||
ut_ad(pos < array->n_slots);
|
||||
os_event_wait(array->events[pos]);
|
||||
srv_io_thread_op_info[orig_seg] =
|
||||
"wait Windows aio for 1 page";
|
||||
os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
|
||||
i = pos;
|
||||
} else {
|
||||
srv_io_thread_op_info[orig_seg] =
|
||||
"wait Windows aio";
|
||||
i = os_event_wait_multiple(n, (array->events) + segment * n);
|
||||
i = os_event_wait_multiple(n,
|
||||
(array->native_events) + segment * n);
|
||||
}
|
||||
|
||||
os_mutex_enter(array->mutex);
|
||||
|
@ -2070,7 +2127,7 @@ os_aio_windows_handle(
|
|||
ut_a(TRUE == os_file_flush(slot->file));
|
||||
}
|
||||
} else {
|
||||
os_file_handle_error(slot->file, slot->name);
|
||||
os_file_handle_error(slot->file, slot->name, "Windows aio");
|
||||
|
||||
ret_val = FALSE;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ Created 9/6/1995 Heikki Tuuri
|
|||
#endif
|
||||
|
||||
#include "ut0mem.h"
|
||||
#include "srv0start.h"
|
||||
|
||||
/* Type definition for an operating system mutex struct */
|
||||
struct os_mutex_struct{
|
||||
|
@ -26,14 +27,84 @@ struct os_mutex_struct{
|
|||
recursively lock the mutex: we
|
||||
do not assume that the OS mutex
|
||||
supports recursive locking, though
|
||||
NT seems to do that */
|
||||
NT seems to do that */
|
||||
UT_LIST_NODE_T(os_mutex_str_t) os_mutex_list;
|
||||
/* list of all 'slow' OS mutexes created */
|
||||
};
|
||||
|
||||
/* Mutex protecting counts and the lists of OS mutexes and events */
|
||||
os_mutex_t os_sync_mutex;
|
||||
ibool os_sync_mutex_inited = FALSE;
|
||||
|
||||
/* This is incremented by 1 in os_thread_create and decremented by 1 in
|
||||
os_thread_exit */
|
||||
ulint os_thread_count = 0;
|
||||
|
||||
/* The list of all events created */
|
||||
UT_LIST_BASE_NODE_T(os_event_struct_t) os_event_list;
|
||||
|
||||
/* The list of all OS 'slow' mutexes */
|
||||
UT_LIST_BASE_NODE_T(os_mutex_str_t) os_mutex_list;
|
||||
|
||||
ulint os_event_count = 0;
|
||||
ulint os_mutex_count = 0;
|
||||
ulint os_fast_mutex_count = 0;
|
||||
|
||||
|
||||
/*************************************************************
|
||||
Creates an event semaphore, i.e., a semaphore which may
|
||||
just have two states: signaled and nonsignaled.
|
||||
The created event is manual reset: it must be reset
|
||||
explicitly by calling sync_os_reset_event. */
|
||||
Initializes global event and OS 'slow' mutex lists. */
|
||||
|
||||
void
|
||||
os_sync_init(void)
|
||||
/*==============*/
|
||||
{
|
||||
UT_LIST_INIT(os_event_list);
|
||||
UT_LIST_INIT(os_mutex_list);
|
||||
|
||||
os_sync_mutex = os_mutex_create(NULL);
|
||||
|
||||
os_sync_mutex_inited = TRUE;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
Frees created events and OS 'slow' mutexes. */
|
||||
|
||||
void
|
||||
os_sync_free(void)
|
||||
/*==============*/
|
||||
{
|
||||
os_event_t event;
|
||||
os_mutex_t mutex;
|
||||
|
||||
event = UT_LIST_GET_FIRST(os_event_list);
|
||||
|
||||
while (event) {
|
||||
|
||||
os_event_free(event);
|
||||
|
||||
event = UT_LIST_GET_FIRST(os_event_list);
|
||||
}
|
||||
|
||||
mutex = UT_LIST_GET_FIRST(os_mutex_list);
|
||||
|
||||
while (mutex) {
|
||||
if (mutex == os_sync_mutex) {
|
||||
/* Set the flag to FALSE so that we do not try to
|
||||
reserve os_sync_mutex any more in remaining freeing
|
||||
operations in shutdown */
|
||||
os_sync_mutex_inited = FALSE;
|
||||
}
|
||||
|
||||
os_mutex_free(mutex);
|
||||
|
||||
mutex = UT_LIST_GET_FIRST(os_mutex_list);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
Creates an event semaphore, i.e., a semaphore which may just have two
|
||||
states: signaled and nonsignaled. The created event is manual reset: it
|
||||
must be reset explicitly by calling sync_os_reset_event. */
|
||||
|
||||
os_event_t
|
||||
os_event_create(
|
||||
|
@ -43,22 +114,20 @@ os_event_create(
|
|||
the event is created without a name */
|
||||
{
|
||||
#ifdef __WIN__
|
||||
HANDLE event;
|
||||
|
||||
event = CreateEvent(NULL, /* No security attributes */
|
||||
os_event_t event;
|
||||
|
||||
event = ut_malloc(sizeof(struct os_event_struct));
|
||||
|
||||
event->handle = CreateEvent(NULL,/* No security attributes */
|
||||
TRUE, /* Manual reset */
|
||||
FALSE, /* Initial state nonsignaled */
|
||||
name);
|
||||
if (!event) {
|
||||
if (!event->handle) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Could not create a Windows event semaphore; Windows error %lu\n",
|
||||
(ulint)GetLastError());
|
||||
}
|
||||
|
||||
ut_a(event);
|
||||
|
||||
return(event);
|
||||
#else
|
||||
#else /* Unix */
|
||||
os_event_t event;
|
||||
|
||||
UT_NOT_USED(name);
|
||||
|
@ -74,15 +143,24 @@ os_event_create(
|
|||
ut_a(0 == pthread_cond_init(&(event->cond_var), NULL));
|
||||
#endif
|
||||
event->is_set = FALSE;
|
||||
#endif /* __WIN__ */
|
||||
|
||||
/* Put to the list of events */
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
|
||||
UT_LIST_ADD_FIRST(os_event_list, os_event_list, event);
|
||||
|
||||
os_event_count++;
|
||||
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
return(event);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __WIN__
|
||||
/*************************************************************
|
||||
Creates an auto-reset event semaphore, i.e., an event
|
||||
which is automatically reset when a single thread is
|
||||
released. */
|
||||
Creates an auto-reset event semaphore, i.e., an event which is automatically
|
||||
reset when a single thread is released. Works only in Windows. */
|
||||
|
||||
os_event_t
|
||||
os_event_create_auto(
|
||||
|
@ -91,24 +169,33 @@ os_event_create_auto(
|
|||
char* name) /* in: the name of the event, if NULL
|
||||
the event is created without a name */
|
||||
{
|
||||
#ifdef __WIN__
|
||||
HANDLE event;
|
||||
os_event_t event;
|
||||
|
||||
event = CreateEvent(NULL, /* No security attributes */
|
||||
event = ut_malloc(sizeof(struct os_event_struct));
|
||||
|
||||
event->handle = CreateEvent(NULL,/* No security attributes */
|
||||
FALSE, /* Auto-reset */
|
||||
FALSE, /* Initial state nonsignaled */
|
||||
name);
|
||||
ut_a(event);
|
||||
|
||||
if (!event->handle) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Could not create a Windows auto event semaphore; Windows error %lu\n",
|
||||
(ulint)GetLastError());
|
||||
}
|
||||
|
||||
/* Put to the list of events */
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
|
||||
UT_LIST_ADD_FIRST(os_event_list, os_event_list, event);
|
||||
|
||||
os_event_count++;
|
||||
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
return(event);
|
||||
#else
|
||||
/* Does nothing in Posix because we do not need this with MySQL */
|
||||
|
||||
UT_NOT_USED(name);
|
||||
|
||||
return(NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************
|
||||
Sets an event semaphore to the signaled state: lets waiting threads
|
||||
|
@ -121,7 +208,7 @@ os_event_set(
|
|||
{
|
||||
#ifdef __WIN__
|
||||
ut_a(event);
|
||||
ut_a(SetEvent(event));
|
||||
ut_a(SetEvent(event->handle));
|
||||
#else
|
||||
ut_a(event);
|
||||
|
||||
|
@ -150,7 +237,7 @@ os_event_reset(
|
|||
#ifdef __WIN__
|
||||
ut_a(event);
|
||||
|
||||
ut_a(ResetEvent(event));
|
||||
ut_a(ResetEvent(event->handle));
|
||||
#else
|
||||
ut_a(event);
|
||||
|
||||
|
@ -178,19 +265,31 @@ os_event_free(
|
|||
#ifdef __WIN__
|
||||
ut_a(event);
|
||||
|
||||
ut_a(CloseHandle(event));
|
||||
ut_a(CloseHandle(event->handle));
|
||||
#else
|
||||
ut_a(event);
|
||||
|
||||
os_fast_mutex_free(&(event->os_mutex));
|
||||
ut_a(0 == pthread_cond_destroy(&(event->cond_var)));
|
||||
#endif
|
||||
/* Remove from the list of events */
|
||||
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
|
||||
UT_LIST_REMOVE(os_event_list, os_event_list, event);
|
||||
|
||||
os_event_count--;
|
||||
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
ut_free(event);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Waits for an event object until it is in the signaled state. */
|
||||
Waits for an event object until it is in the signaled state. If
|
||||
srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the
|
||||
waiting thread when the event becomes signaled (or immediately if the
|
||||
event is already in the signaled state). */
|
||||
|
||||
void
|
||||
os_event_wait(
|
||||
|
@ -203,15 +302,23 @@ os_event_wait(
|
|||
ut_a(event);
|
||||
|
||||
/* Specify an infinite time limit for waiting */
|
||||
err = WaitForSingleObject(event, INFINITE);
|
||||
err = WaitForSingleObject(event->handle, INFINITE);
|
||||
|
||||
ut_a(err == WAIT_OBJECT_0);
|
||||
|
||||
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
|
||||
os_thread_exit(NULL);
|
||||
}
|
||||
#else
|
||||
os_fast_mutex_lock(&(event->os_mutex));
|
||||
loop:
|
||||
if (event->is_set == TRUE) {
|
||||
os_fast_mutex_unlock(&(event->os_mutex));
|
||||
|
||||
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
|
||||
|
||||
os_thread_exit(NULL);
|
||||
}
|
||||
/* Ok, we may return */
|
||||
|
||||
return;
|
||||
|
@ -228,7 +335,7 @@ loop:
|
|||
|
||||
/**************************************************************
|
||||
Waits for an event object until it is in the signaled state or
|
||||
a timeout is exceeded. */
|
||||
a timeout is exceeded. In Unix the timeout is always infinite. */
|
||||
|
||||
ulint
|
||||
os_event_wait_time(
|
||||
|
@ -245,9 +352,9 @@ os_event_wait_time(
|
|||
ut_a(event);
|
||||
|
||||
if (time != OS_SYNC_INFINITE_TIME) {
|
||||
err = WaitForSingleObject(event, time / 1000);
|
||||
err = WaitForSingleObject(event->handle, time / 1000);
|
||||
} else {
|
||||
err = WaitForSingleObject(event, INFINITE);
|
||||
err = WaitForSingleObject(event->handle, INFINITE);
|
||||
}
|
||||
|
||||
if (err == WAIT_OBJECT_0) {
|
||||
|
@ -271,8 +378,9 @@ os_event_wait_time(
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef __WIN__
|
||||
/**************************************************************
|
||||
Waits for any event in an event array. Returns if even a single
|
||||
Waits for any event in an OS native event array. Returns if even a single
|
||||
one is signaled or becomes signaled. */
|
||||
|
||||
ulint
|
||||
|
@ -280,41 +388,35 @@ os_event_wait_multiple(
|
|||
/*===================*/
|
||||
/* out: index of the event
|
||||
which was signaled */
|
||||
ulint n, /* in: number of events in the
|
||||
ulint n, /* in: number of events in the
|
||||
array */
|
||||
os_event_t* event_array) /* in: pointer to an array of event
|
||||
os_native_event_t* native_event_array)
|
||||
/* in: pointer to an array of event
|
||||
handles */
|
||||
{
|
||||
#ifdef __WIN__
|
||||
DWORD index;
|
||||
|
||||
ut_a(event_array);
|
||||
ut_a(native_event_array);
|
||||
ut_a(n > 0);
|
||||
|
||||
index = WaitForMultipleObjects(n,
|
||||
event_array,
|
||||
index = WaitForMultipleObjects(n, native_event_array,
|
||||
FALSE, /* Wait for any 1 event */
|
||||
INFINITE); /* Infinite wait time
|
||||
limit */
|
||||
ut_a(index >= WAIT_OBJECT_0);
|
||||
ut_a(index < WAIT_OBJECT_0 + n);
|
||||
|
||||
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
|
||||
os_thread_exit(NULL);
|
||||
}
|
||||
|
||||
return(index - WAIT_OBJECT_0);
|
||||
#else
|
||||
ut_a(n == 0);
|
||||
|
||||
/* In Posix we can only wait for a single event */
|
||||
|
||||
os_event_wait(*event_array);
|
||||
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************
|
||||
Creates an operating system mutex semaphore.
|
||||
Because these are slow, the mutex semaphore of the database
|
||||
itself (sync_mutex_t) should be used where possible. */
|
||||
Creates an operating system mutex semaphore. Because these are slow, the
|
||||
mutex semaphore of InnoDB itself (mutex_t) should be used where possible. */
|
||||
|
||||
os_mutex_t
|
||||
os_mutex_create(
|
||||
|
@ -331,30 +433,35 @@ os_mutex_create(
|
|||
FALSE, /* Initial state: no owner */
|
||||
name);
|
||||
ut_a(mutex);
|
||||
#else
|
||||
os_fast_mutex_t* mutex;
|
||||
os_mutex_t mutex_str;
|
||||
|
||||
UT_NOT_USED(name);
|
||||
|
||||
mutex = ut_malloc(sizeof(os_fast_mutex_t));
|
||||
|
||||
os_fast_mutex_init(mutex);
|
||||
#endif
|
||||
mutex_str = ut_malloc(sizeof(os_mutex_str_t));
|
||||
|
||||
mutex_str->handle = mutex;
|
||||
mutex_str->count = 0;
|
||||
|
||||
return(mutex_str);
|
||||
#else
|
||||
os_fast_mutex_t* os_mutex;
|
||||
os_mutex_t mutex_str;
|
||||
if (os_sync_mutex_inited) {
|
||||
/* When creating os_sync_mutex itself we cannot reserve it */
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
}
|
||||
|
||||
UT_NOT_USED(name);
|
||||
|
||||
os_mutex = ut_malloc(sizeof(os_fast_mutex_t));
|
||||
UT_LIST_ADD_FIRST(os_mutex_list, os_mutex_list, mutex_str);
|
||||
|
||||
os_fast_mutex_init(os_mutex);
|
||||
os_mutex_count++;
|
||||
|
||||
mutex_str = ut_malloc(sizeof(os_mutex_str_t));
|
||||
|
||||
mutex_str->handle = os_mutex;
|
||||
mutex_str->count = 0;
|
||||
if (os_sync_mutex_inited) {
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
}
|
||||
|
||||
return(mutex_str);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
|
@ -394,21 +501,14 @@ os_mutex_exit(
|
|||
/*==========*/
|
||||
os_mutex_t mutex) /* in: mutex to release */
|
||||
{
|
||||
#ifdef __WIN__
|
||||
ut_a(mutex);
|
||||
|
||||
ut_a(mutex->count == 1);
|
||||
|
||||
(mutex->count)--;
|
||||
|
||||
#ifdef __WIN__
|
||||
ut_a(ReleaseMutex(mutex->handle));
|
||||
#else
|
||||
ut_a(mutex);
|
||||
|
||||
ut_a(mutex->count == 1);
|
||||
|
||||
(mutex->count)--;
|
||||
|
||||
os_fast_mutex_unlock(mutex->handle);
|
||||
#endif
|
||||
}
|
||||
|
@ -421,10 +521,23 @@ os_mutex_free(
|
|||
/*==========*/
|
||||
os_mutex_t mutex) /* in: mutex to free */
|
||||
{
|
||||
#ifdef __WIN__
|
||||
ut_a(mutex);
|
||||
|
||||
if (os_sync_mutex_inited) {
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
}
|
||||
|
||||
UT_LIST_REMOVE(os_mutex_list, os_mutex_list, mutex);
|
||||
|
||||
os_mutex_count--;
|
||||
|
||||
if (os_sync_mutex_inited) {
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
}
|
||||
|
||||
#ifdef __WIN__
|
||||
ut_a(CloseHandle(mutex->handle));
|
||||
|
||||
ut_free(mutex);
|
||||
#else
|
||||
os_fast_mutex_free(mutex->handle);
|
||||
|
@ -452,6 +565,18 @@ os_fast_mutex_init(
|
|||
ut_a(0 == pthread_mutex_init(fast_mutex, MY_MUTEX_INIT_FAST));
|
||||
#endif
|
||||
#endif
|
||||
if (os_sync_mutex_inited) {
|
||||
/* When creating os_sync_mutex itself (in Unix) we cannot
|
||||
reserve it */
|
||||
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
}
|
||||
|
||||
os_fast_mutex_count++;
|
||||
|
||||
if (os_sync_mutex_inited) {
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
|
@ -499,4 +624,16 @@ os_fast_mutex_free(
|
|||
#else
|
||||
ut_a(0 == pthread_mutex_destroy(fast_mutex));
|
||||
#endif
|
||||
if (os_sync_mutex_inited) {
|
||||
/* When freeing the last mutexes, we have
|
||||
already freed os_sync_mutex */
|
||||
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
}
|
||||
|
||||
os_fast_mutex_count--;
|
||||
|
||||
if (os_sync_mutex_inited) {
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/******************************************************
|
||||
The interface to the operating system
|
||||
process and thread control primitives
|
||||
The interface to the operating system thread control primitives
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
|
@ -17,6 +16,7 @@ Created 9/8/1995 Heikki Tuuri
|
|||
#endif
|
||||
|
||||
#include "srv0srv.h"
|
||||
#include "os0sync.h"
|
||||
|
||||
/*******************************************************************
|
||||
Compares two thread ids for equality. */
|
||||
|
@ -102,6 +102,10 @@ os_thread_create(
|
|||
os_thread_t thread;
|
||||
ulint win_thread_id;
|
||||
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
os_thread_count++;
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
thread = CreateThread(NULL, /* no security attributes */
|
||||
0, /* default size stack */
|
||||
(LPTHREAD_START_ROUTINE)start_f,
|
||||
|
@ -144,6 +148,9 @@ os_thread_create(
|
|||
exit(1);
|
||||
}
|
||||
#endif
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
os_thread_count++;
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
#if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)
|
||||
ret = pthread_create(&pthread, pthread_attr_default, start_f, arg);
|
||||
|
@ -170,6 +177,30 @@ os_thread_create(
|
|||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Exits the current thread. */
|
||||
|
||||
void
|
||||
os_thread_exit(
|
||||
/*===========*/
|
||||
void* exit_value) /* in: exit value; in Windows this void*
|
||||
is cast as a DWORD */
|
||||
{
|
||||
#ifdef UNIV_DEBUG_THREAD_CREATION
|
||||
printf("A thread exits.\n");
|
||||
printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
|
||||
#endif
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
os_thread_count--;
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
#ifdef __WIN__
|
||||
ExitThread((DWORD)exit_value);
|
||||
#else
|
||||
pthread_exit(exit_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Returns handle to the current thread. */
|
||||
|
||||
|
|
|
@ -1275,6 +1275,10 @@ row_ins_unique_report_err(
|
|||
dtuple_t* entry, /* in: index entry to insert in the index */
|
||||
dict_index_t* index) /* in: index */
|
||||
{
|
||||
#ifdef notdefined
|
||||
/* Disable reporting to test if the slowdown of REPLACE in 4.0.13 was
|
||||
caused by this! */
|
||||
|
||||
char* buf = dict_unique_err_buf;
|
||||
|
||||
/* The foreign err mutex protects also dict_unique_err_buf */
|
||||
|
@ -1303,6 +1307,7 @@ row_ins_unique_report_err(
|
|||
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
|
||||
|
||||
mutex_exit(&dict_foreign_err_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
|
|
@ -868,6 +868,7 @@ srv_release_max_if_no_queries(void)
|
|||
mutex_exit(&kernel_mutex);
|
||||
}
|
||||
|
||||
#ifdef notdefined
|
||||
/***********************************************************************
|
||||
Releases one utility thread if no queries are active and
|
||||
the high-water mark 2 for the utility is exceeded. */
|
||||
|
@ -902,7 +903,6 @@ srv_release_one_if_no_queries(void)
|
|||
mutex_exit(&kernel_mutex);
|
||||
}
|
||||
|
||||
#ifdef notdefined
|
||||
/***********************************************************************
|
||||
Decrements the utility meter by the value given and suspends the calling
|
||||
thread, which must be an utility thread of the type given, if necessary. */
|
||||
|
@ -1012,6 +1012,8 @@ srv_communication_init(
|
|||
|
||||
ut_a(ret == 0);
|
||||
}
|
||||
|
||||
#ifdef notdefined
|
||||
|
||||
/*************************************************************************
|
||||
Implements the recovery utility. */
|
||||
|
@ -1072,6 +1074,7 @@ srv_purge_thread(
|
|||
|
||||
return(0);
|
||||
}
|
||||
#endif /* notdefined */
|
||||
|
||||
/*************************************************************************
|
||||
Creates the utility threads. */
|
||||
|
@ -1102,6 +1105,7 @@ srv_create_utility_threads(void)
|
|||
ut_a(thread); */
|
||||
}
|
||||
|
||||
#ifdef notdefined
|
||||
/*************************************************************************
|
||||
Implements the communication threads. */
|
||||
static
|
||||
|
@ -1151,6 +1155,7 @@ srv_com_thread(
|
|||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
Creates the communication threads. */
|
||||
|
@ -1171,6 +1176,7 @@ srv_create_com_threads(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef notdefined
|
||||
/*************************************************************************
|
||||
Implements the worker threads. */
|
||||
static
|
||||
|
@ -1215,6 +1221,7 @@ srv_worker_thread(
|
|||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
Creates the worker threads. */
|
||||
|
@ -1705,7 +1712,17 @@ srv_init(void)
|
|||
ut_a(conc_slot->event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Frees the OS fast mutex created in srv_init(). */
|
||||
|
||||
void
|
||||
srv_free(void)
|
||||
/*==========*/
|
||||
{
|
||||
os_fast_mutex_free(&srv_conc_mutex);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Initializes the synchronization primitives, memory system, and the thread
|
||||
local storage. */
|
||||
|
@ -1714,67 +1731,14 @@ void
|
|||
srv_general_init(void)
|
||||
/*==================*/
|
||||
{
|
||||
os_sync_init();
|
||||
sync_init();
|
||||
mem_init(srv_mem_pool_size);
|
||||
thr_local_init();
|
||||
}
|
||||
|
||||
|
||||
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
|
||||
/* NetWare requires some cleanup of mutexes */
|
||||
|
||||
/*************************************************************************
|
||||
Deinitializes the synchronization primitives, memory system, and the thread
|
||||
local storage. */
|
||||
|
||||
void
|
||||
srv_general_free(void)
|
||||
/*==================*/
|
||||
{
|
||||
sync_close();
|
||||
}
|
||||
#endif /* __NETWARE__ */
|
||||
|
||||
|
||||
/*======================= InnoDB Server FIFO queue =======================*/
|
||||
|
||||
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
|
||||
/* NetWare requires some cleanup of mutexes */
|
||||
|
||||
/*************************************************************************
|
||||
Deinitializes the server. */
|
||||
|
||||
void
|
||||
srv_free(void)
|
||||
/*==========*/
|
||||
{
|
||||
srv_conc_slot_t* conc_slot;
|
||||
srv_slot_t* slot;
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < OS_THREAD_MAX_N; i++)
|
||||
{
|
||||
slot = srv_table_get_nth_slot(i);
|
||||
os_event_free(slot->event);
|
||||
}
|
||||
|
||||
/* TODO: free(srv_sys->threads); */
|
||||
|
||||
for (i = 0; i < OS_THREAD_MAX_N; i++)
|
||||
{
|
||||
slot = srv_mysql_table + i;
|
||||
os_event_free(slot->event);
|
||||
}
|
||||
|
||||
/* TODO: free(srv_mysql_table); */
|
||||
|
||||
for (i = 0; i < OS_THREAD_MAX_N; i++)
|
||||
{
|
||||
conc_slot = srv_conc_slots + i;
|
||||
os_event_free(conc_slot->event);
|
||||
}
|
||||
}
|
||||
#endif /* __NETWARE__ */
|
||||
|
||||
/*************************************************************************
|
||||
Puts an OS thread to wait if there are too many concurrent threads
|
||||
|
@ -2533,6 +2497,10 @@ srv_lock_timeout_and_monitor_thread(
|
|||
char* buf;
|
||||
ulint i;
|
||||
|
||||
#ifdef UNIV_DEBUG_THREAD_CREATION
|
||||
printf("Lock timeout thread starts\n");
|
||||
printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
|
||||
#endif
|
||||
UT_NOT_USED(arg);
|
||||
srv_last_monitor_time = time(NULL);
|
||||
last_table_monitor_time = time(NULL);
|
||||
|
@ -2673,6 +2641,10 @@ loop:
|
|||
exit_func:
|
||||
srv_lock_timeout_and_monitor_active = FALSE;
|
||||
|
||||
/* We count the number of threads in os_thread_exit(). A created
|
||||
thread should always use that to exit and not use return() to exit. */
|
||||
|
||||
os_thread_exit(NULL);
|
||||
#ifndef __WIN__
|
||||
return(NULL);
|
||||
#else
|
||||
|
@ -2698,6 +2670,10 @@ srv_error_monitor_thread(
|
|||
ulint cnt = 0;
|
||||
|
||||
UT_NOT_USED(arg);
|
||||
#ifdef UNIV_DEBUG_THREAD_CREATION
|
||||
printf("Error monitor thread starts\n");
|
||||
printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
|
||||
#endif
|
||||
loop:
|
||||
srv_error_monitor_active = TRUE;
|
||||
|
||||
|
@ -2734,6 +2710,11 @@ loop:
|
|||
|
||||
srv_error_monitor_active = FALSE;
|
||||
|
||||
/* We count the number of threads in os_thread_exit(). A created
|
||||
thread should always use that to exit and not use return() to exit. */
|
||||
|
||||
os_thread_exit(NULL);
|
||||
|
||||
#ifndef __WIN__
|
||||
return(NULL);
|
||||
#else
|
||||
|
@ -2812,6 +2793,10 @@ srv_master_thread(
|
|||
|
||||
UT_NOT_USED(arg);
|
||||
|
||||
#ifdef UNIV_DEBUG_THREAD_CREATION
|
||||
printf("Master thread starts\n");
|
||||
printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
|
||||
#endif
|
||||
srv_main_thread_process_no = os_proc_get_number();
|
||||
srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
|
||||
|
||||
|
@ -3047,6 +3032,15 @@ background_loop:
|
|||
|
||||
n_tables_to_drop = row_drop_tables_for_mysql_in_background();
|
||||
|
||||
if (n_tables_to_drop > 0) {
|
||||
/* Do not monopolize the CPU even if there are tables waiting
|
||||
in the background drop queue. (It is essentially a bug if
|
||||
MySQL tries to drop a table while there are still open handles
|
||||
to it and we had to put it to the background drop queue.) */
|
||||
|
||||
os_thread_sleep(100000);
|
||||
}
|
||||
|
||||
srv_main_thread_op_info = (char*)"purging";
|
||||
|
||||
if (srv_fast_shutdown && srv_shutdown_state > 0) {
|
||||
|
@ -3173,11 +3167,25 @@ suspend_thread:
|
|||
|
||||
os_event_wait(event);
|
||||
|
||||
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
|
||||
/* This is only extra safety, the thread should exit
|
||||
already when the event wait ends */
|
||||
|
||||
os_thread_exit(NULL);
|
||||
}
|
||||
|
||||
/* When there is user activity, InnoDB will set the event and the main
|
||||
thread goes back to loop: */
|
||||
|
||||
goto loop;
|
||||
|
||||
/* We count the number of threads in os_thread_exit(). A created
|
||||
thread should always use that to exit and not use return() to exit.
|
||||
The thread actually never comes here because it is exited in an
|
||||
os_event_wait(). */
|
||||
|
||||
os_thread_exit(NULL);
|
||||
|
||||
#ifndef __WIN__
|
||||
return(NULL);
|
||||
#else
|
||||
|
|
|
@ -414,8 +414,10 @@ io_handler_thread(
|
|||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
/* printf("Io handler thread %lu starts\n", segment); */
|
||||
|
||||
#ifdef UNIV_DEBUG_THREAD_CREATION
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
|
||||
#endif
|
||||
for (i = 0;; i++) {
|
||||
fil_aio_wait(segment);
|
||||
|
||||
|
@ -424,6 +426,13 @@ io_handler_thread(
|
|||
mutex_exit(&ios_mutex);
|
||||
}
|
||||
|
||||
/* We count the number of threads in os_thread_exit(). A created
|
||||
thread should always use that to exit and not use return() to exit.
|
||||
The thread actually never comes here because it is exited in an
|
||||
os_event_wait(). */
|
||||
|
||||
os_thread_exit(NULL);
|
||||
|
||||
#ifndef __WIN__
|
||||
return(NULL);
|
||||
#else
|
||||
|
@ -1481,9 +1490,7 @@ innobase_start_or_create_for_mysql(void)
|
|||
|
||||
os_fast_mutex_unlock(&srv_os_test_mutex);
|
||||
|
||||
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
|
||||
os_fast_mutex_free(&srv_os_test_mutex); /* all platforms? */
|
||||
#endif /* __NETWARE__ */
|
||||
os_fast_mutex_free(&srv_os_test_mutex);
|
||||
|
||||
if (srv_print_verbose_log) {
|
||||
ut_print_timestamp(stderr);
|
||||
|
@ -1509,6 +1516,8 @@ innobase_shutdown_for_mysql(void)
|
|||
/*=============================*/
|
||||
/* out: DB_SUCCESS or error code */
|
||||
{
|
||||
ulint i;
|
||||
|
||||
if (!srv_was_started) {
|
||||
if (srv_is_being_started) {
|
||||
ut_print_timestamp(stderr);
|
||||
|
@ -1521,7 +1530,7 @@ innobase_shutdown_for_mysql(void)
|
|||
return(DB_SUCCESS);
|
||||
}
|
||||
|
||||
/* Flush buffer pool to disk, write the current lsn to
|
||||
/* 1. Flush buffer pool to disk, write the current lsn to
|
||||
the tablespace header(s), and copy all log data to archive */
|
||||
|
||||
logs_empty_and_mark_files_at_shutdown();
|
||||
|
@ -1533,30 +1542,88 @@ innobase_shutdown_for_mysql(void)
|
|||
srv_conc_n_threads);
|
||||
}
|
||||
|
||||
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
|
||||
/*
|
||||
TODO: Fix this temporary solution
|
||||
We are having a race condition occure with io_handler_thread threads.
|
||||
When they yield in os_aio_simulated_handle during shutdown, this
|
||||
thread was able to free the memory early.
|
||||
*/
|
||||
os_thread_yield();
|
||||
/* 2. Make all threads created by InnoDB to exit */
|
||||
|
||||
srv_shutdown_state = SRV_SHUTDOWN_EXIT_THREADS;
|
||||
|
||||
/* All threads end up waiting for certain events. Put those events
|
||||
to the signaled state. Then the threads will exit themselves in
|
||||
os_thread_event_wait(). */
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
/* NOTE: IF YOU CREATE THREADS IN INNODB, YOU MUST EXIT THEM
|
||||
HERE OR EARLIER */
|
||||
|
||||
/* 1. Let the lock timeout thread exit */
|
||||
os_event_set(srv_lock_timeout_thread_event);
|
||||
|
||||
/* 2. srv error monitor thread exits automatically, no need
|
||||
to do anything here */
|
||||
|
||||
/* 3. We wake the master thread so that it exits */
|
||||
srv_wake_master_thread();
|
||||
|
||||
/* 4. Exit the i/o threads */
|
||||
|
||||
os_aio_wake_all_threads_at_shutdown();
|
||||
|
||||
os_mutex_enter(os_sync_mutex);
|
||||
|
||||
if (os_thread_count == 0) {
|
||||
/* All the threads have exited or are just exiting;
|
||||
NOTE that the threads may not have completed their
|
||||
exit yet. Should we use pthread_join() to make sure
|
||||
they have exited? Now we just sleep 0.1 seconds and
|
||||
hope that is enough! */
|
||||
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
os_thread_sleep(100000);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
os_mutex_exit(os_sync_mutex);
|
||||
|
||||
os_thread_sleep(100000);
|
||||
}
|
||||
|
||||
if (i == 1000) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Warning: %lu threads created by InnoDB had not exited at shutdown!\n",
|
||||
os_thread_count);
|
||||
}
|
||||
|
||||
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
|
||||
them */
|
||||
|
||||
sync_close();
|
||||
|
||||
/* 4. Free the os_conc_mutex and all os_events and os_mutexes */
|
||||
|
||||
/* TODO: Where should this be called? */
|
||||
srv_free();
|
||||
os_sync_free();
|
||||
|
||||
/* 5. Free all allocated memory and the os_fast_mutex created in
|
||||
ut0mem.c */
|
||||
|
||||
/* TODO: Where should this be called? */
|
||||
srv_general_free();
|
||||
#endif
|
||||
/*
|
||||
TODO: We should exit the i/o-handler and other utility threads
|
||||
before freeing all memory. Now this can potentially cause a seg
|
||||
fault!
|
||||
*/
|
||||
#if defined(NOT_WORKING_YET) || defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
|
||||
/* NetWare requires this free */
|
||||
ut_free_all_mem();
|
||||
#endif
|
||||
|
||||
if (os_thread_count != 0
|
||||
|| os_event_count != 0
|
||||
|| os_mutex_count != 0
|
||||
|| os_fast_mutex_count != 0) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Warning: some resources were not cleaned up in shutdown:\n"
|
||||
"InnoDB: threads %lu, events %lu, os_mutexes %lu, os_fast_mutexes %lu\n",
|
||||
os_thread_count, os_event_count, os_mutex_count,
|
||||
os_fast_mutex_count);
|
||||
}
|
||||
|
||||
if (srv_print_verbose_log) {
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Shutdown completed\n");
|
||||
}
|
||||
|
||||
return((int) DB_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -235,8 +235,7 @@ mutex_create_func(
|
|||
mutex->cline = cline;
|
||||
|
||||
/* Check that lock_word is aligned; this is important on Intel */
|
||||
|
||||
ut_a(((ulint)(&(mutex->lock_word))) % 4 == 0);
|
||||
ut_ad(((ulint)(&(mutex->lock_word))) % 4 == 0);
|
||||
|
||||
/* NOTE! The very first mutexes are not put to the mutex list */
|
||||
|
||||
|
@ -266,11 +265,14 @@ mutex_free(
|
|||
ut_a(mutex_get_lock_word(mutex) == 0);
|
||||
ut_a(mutex_get_waiters(mutex) == 0);
|
||||
|
||||
mutex_enter(&mutex_list_mutex);
|
||||
if (mutex != &mutex_list_mutex && mutex != &sync_thread_mutex) {
|
||||
|
||||
UT_LIST_REMOVE(list, mutex_list, mutex);
|
||||
mutex_enter(&mutex_list_mutex);
|
||||
|
||||
mutex_exit(&mutex_list_mutex);
|
||||
UT_LIST_REMOVE(list, mutex_list, mutex);
|
||||
|
||||
mutex_exit(&mutex_list_mutex);
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
|
||||
os_fast_mutex_free(&(mutex->os_fast_mutex));
|
||||
|
@ -1230,13 +1232,26 @@ sync_init(void)
|
|||
}
|
||||
|
||||
/**********************************************************************
|
||||
Frees the resources in synchronization data structures. */
|
||||
Frees the resources in InnoDB's own synchronization data structures. Use
|
||||
os_sync_free() after calling this. */
|
||||
|
||||
void
|
||||
sync_close(void)
|
||||
/*===========*/
|
||||
{
|
||||
mutex_t* mutex;
|
||||
|
||||
sync_array_free(sync_primary_wait_array);
|
||||
|
||||
mutex = UT_LIST_GET_FIRST(mutex_list);
|
||||
|
||||
while (mutex) {
|
||||
mutex_free(mutex);
|
||||
mutex = UT_LIST_GET_FIRST(mutex_list);
|
||||
}
|
||||
|
||||
mutex_free(&mutex_list_mutex);
|
||||
mutex_free(&sync_thread_mutex);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -225,6 +225,8 @@ ut_free_all_mem(void)
|
|||
os_fast_mutex_unlock(&ut_list_mutex);
|
||||
|
||||
ut_a(ut_total_allocated_memory == 0);
|
||||
|
||||
os_fast_mutex_free(&ut_list_mutex);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -85,15 +85,10 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT;
|
|||
#define SOCKET_ERROR -1
|
||||
#endif /* __WIN__ */
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
char *shared_memory_base_name=0;
|
||||
const char *def_shared_memory_base_name=default_shared_memory_base_name;
|
||||
#endif
|
||||
|
||||
const char *sql_protocol_names_lib[] =
|
||||
{ "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
|
||||
{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS };
|
||||
TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
|
||||
sql_protocol_names_lib};
|
||||
sql_protocol_names_lib};
|
||||
/*
|
||||
If allowed through some configuration, then this needs to
|
||||
be changed
|
||||
|
@ -128,16 +123,16 @@ void STDCALL mysql_server_end()
|
|||
my_bool STDCALL mysql_thread_init()
|
||||
{
|
||||
#ifdef THREAD
|
||||
return my_thread_init();
|
||||
return my_thread_init();
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void STDCALL mysql_thread_end()
|
||||
{
|
||||
#ifdef THREAD
|
||||
my_thread_end();
|
||||
my_thread_end();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -147,7 +142,7 @@ void STDCALL mysql_thread_end()
|
|||
*/
|
||||
|
||||
#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
|
||||
#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0;
|
||||
#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0
|
||||
#define set_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
|
||||
#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
|
||||
#else
|
||||
|
@ -161,209 +156,7 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
|||
const char* user,
|
||||
const char* passwd);
|
||||
|
||||
/*
|
||||
Create new shared memory connection, return handler of connection
|
||||
|
||||
SYNOPSIS
|
||||
create_shared_memory()
|
||||
mysql Pointer of mysql structure
|
||||
net Pointer of net structure
|
||||
connect_timeout Timeout of connection
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
|
||||
{
|
||||
ulong smem_buffer_length = shared_memory_buffer_length + 4;
|
||||
/*
|
||||
event_connect_request is event object for start connection actions
|
||||
event_connect_answer is event object for confirm, that server put data
|
||||
handle_connect_file_map is file-mapping object, use for create shared memory
|
||||
handle_connect_map is pointer on shared memory
|
||||
handle_map is pointer on shared memory for client
|
||||
event_server_wrote,
|
||||
event_server_read,
|
||||
event_client_wrote,
|
||||
event_client_read are events for transfer data between server and client
|
||||
handle_file_map is file-mapping object, use for create shared memory
|
||||
*/
|
||||
HANDLE event_connect_request = NULL;
|
||||
HANDLE event_connect_answer = NULL;
|
||||
HANDLE handle_connect_file_map = NULL;
|
||||
char *handle_connect_map = NULL;
|
||||
|
||||
char *handle_map = NULL;
|
||||
HANDLE event_server_wrote = NULL;
|
||||
HANDLE event_server_read = NULL;
|
||||
HANDLE event_client_wrote = NULL;
|
||||
HANDLE event_client_read = NULL;
|
||||
HANDLE handle_file_map = NULL;
|
||||
ulong connect_number;
|
||||
char connect_number_char[22], *p;
|
||||
char tmp[64];
|
||||
char *suffix_pos;
|
||||
DWORD error_allow = 0;
|
||||
DWORD error_code = 0;
|
||||
char *shared_memory_base_name = mysql->options.shared_memory_base_name;
|
||||
|
||||
/*
|
||||
The name of event and file-mapping events create agree next rule:
|
||||
shared_memory_base_name+unique_part
|
||||
Where:
|
||||
shared_memory_base_name is unique value for each server
|
||||
unique_part is uniquel value for each object (events and file-mapping)
|
||||
*/
|
||||
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
|
||||
strmov(suffix_pos, "CONNECT_REQUEST");
|
||||
if (!(event_connect_request= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR;
|
||||
goto err;
|
||||
}
|
||||
strmov(suffix_pos, "CONNECT_ANSWER");
|
||||
if (!(event_connect_answer= OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)))
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR;
|
||||
goto err;
|
||||
}
|
||||
strmov(suffix_pos, "CONNECT_DATA");
|
||||
if (!(handle_connect_file_map= OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)))
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR;
|
||||
goto err;
|
||||
}
|
||||
if (!(handle_connect_map= MapViewOfFile(handle_connect_file_map,
|
||||
FILE_MAP_WRITE,0,0,sizeof(DWORD))))
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_MAP_ERROR;
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
Send to server request of connection
|
||||
*/
|
||||
if (!SetEvent(event_connect_request))
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_SET_ERROR;
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
Wait of answer from server
|
||||
*/
|
||||
if (WaitForSingleObject(event_connect_answer,connect_timeout*1000) !=
|
||||
WAIT_OBJECT_0)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR;
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
Get number of connection
|
||||
*/
|
||||
connect_number = uint4korr(handle_connect_map);/*WAX2*/
|
||||
p= int2str(connect_number, connect_number_char, 10);
|
||||
|
||||
/*
|
||||
The name of event and file-mapping events create agree next rule:
|
||||
shared_memory_base_name+unique_part+number_of_connection
|
||||
Where:
|
||||
shared_memory_base_name is uniquel value for each server
|
||||
unique_part is uniquel value for each object (events and file-mapping)
|
||||
number_of_connection is number of connection between server and client
|
||||
*/
|
||||
suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,
|
||||
"_",NullS);
|
||||
strmov(suffix_pos, "DATA");
|
||||
if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_FILE_MAP_ERROR;
|
||||
goto err2;
|
||||
}
|
||||
if ((handle_map = MapViewOfFile(handle_file_map,FILE_MAP_WRITE,0,0,
|
||||
smem_buffer_length)) == NULL)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_MAP_ERROR;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
strmov(suffix_pos, "SERVER_WROTE");
|
||||
if ((event_server_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
strmov(suffix_pos, "SERVER_READ");
|
||||
if ((event_server_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
strmov(suffix_pos, "CLIENT_WROTE");
|
||||
if ((event_client_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
strmov(suffix_pos, "CLIENT_READ");
|
||||
if ((event_client_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
|
||||
{
|
||||
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
|
||||
goto err2;
|
||||
}
|
||||
/*
|
||||
Set event that server should send data
|
||||
*/
|
||||
SetEvent(event_server_read);
|
||||
|
||||
err2:
|
||||
if (error_allow == 0)
|
||||
{
|
||||
net->vio= vio_new_win32shared_memory(net,handle_file_map,handle_map,
|
||||
event_server_wrote,
|
||||
event_server_read,event_client_wrote,
|
||||
event_client_read);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_code = GetLastError();
|
||||
if (event_server_read)
|
||||
CloseHandle(event_server_read);
|
||||
if (event_server_wrote)
|
||||
CloseHandle(event_server_wrote);
|
||||
if (event_client_read)
|
||||
CloseHandle(event_client_read);
|
||||
if (event_client_wrote)
|
||||
CloseHandle(event_client_wrote);
|
||||
if (handle_map)
|
||||
UnmapViewOfFile(handle_map);
|
||||
if (handle_file_map)
|
||||
CloseHandle(handle_file_map);
|
||||
}
|
||||
err:
|
||||
if (error_allow)
|
||||
error_code = GetLastError();
|
||||
if (event_connect_request)
|
||||
CloseHandle(event_connect_request);
|
||||
if (event_connect_answer)
|
||||
CloseHandle(event_connect_answer);
|
||||
if (handle_connect_map)
|
||||
UnmapViewOfFile(handle_connect_map);
|
||||
if (handle_connect_file_map)
|
||||
CloseHandle(handle_connect_file_map);
|
||||
if (error_allow)
|
||||
{
|
||||
net->last_errno=error_allow;
|
||||
strmov(net->sqlstate, unknown_sqlstate);
|
||||
if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR)
|
||||
sprintf(net->last_error,ER(net->last_errno),suffix_pos,error_code);
|
||||
else
|
||||
sprintf(net->last_error,ER(net->last_errno),error_code);
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return(handle_map);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
Expand wildcard to a sql string
|
||||
|
@ -443,7 +236,7 @@ pipe_sig_handler(int sig __attribute__((unused)))
|
|||
|
||||
/* perform query on master */
|
||||
my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length)
|
||||
unsigned long length)
|
||||
{
|
||||
DBUG_ENTER("mysql_master_query");
|
||||
if (mysql_master_send_query(mysql, q, length))
|
||||
|
@ -490,7 +283,7 @@ my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
|
|||
*/
|
||||
mysql->last_used_con = mysql->last_used_slave = slave_to_use;
|
||||
if (!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0,
|
||||
0,0,0,0))
|
||||
0,0,0,0))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(simple_command(slave_to_use, COM_QUERY, q, length, 1));
|
||||
}
|
||||
|
@ -627,7 +420,7 @@ static my_bool get_slaves_from_master(MYSQL* mysql)
|
|||
}
|
||||
|
||||
if (!(slave = spawn_init(mysql, row[1], atoi(row[port_ind]),
|
||||
tmp_user, tmp_pass)))
|
||||
tmp_user, tmp_pass)))
|
||||
goto err;
|
||||
|
||||
/* Now add slave into the circular linked list */
|
||||
|
@ -637,7 +430,7 @@ static my_bool get_slaves_from_master(MYSQL* mysql)
|
|||
error = 0;
|
||||
err:
|
||||
if (res)
|
||||
mysql_free_result(res);
|
||||
mysql_free_result(res);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -800,7 +593,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
|||
if (!passwd)
|
||||
passwd="";
|
||||
|
||||
/* Store user into the buffer */
|
||||
/* Store user into the buffer */
|
||||
end=strmov(end,user)+1;
|
||||
|
||||
/*
|
||||
|
@ -817,15 +610,15 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
|||
*end=0;
|
||||
|
||||
}
|
||||
else /* For empty password*/
|
||||
*end=0; /* Store zero length scramble */
|
||||
else /* For empty password */
|
||||
*end=0; /* zero length scramble */
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
Real scramble is only sent to old servers. This can be blocked
|
||||
by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1);
|
||||
*/
|
||||
/*
|
||||
Real scramble is only sent to old servers. This can be blocked
|
||||
by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1);
|
||||
*/
|
||||
end=scramble(end, mysql->scramble_buff, passwd,
|
||||
(my_bool) (mysql->protocol_version == 9));
|
||||
}
|
||||
|
@ -1031,9 +824,9 @@ STDCALL mysql_set_master(MYSQL* mysql, const char* host,
|
|||
|
||||
int
|
||||
STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd)
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd)
|
||||
{
|
||||
MYSQL* slave;
|
||||
if (!(slave = spawn_init(mysql, host, port, user, passwd)))
|
||||
|
@ -1509,7 +1302,7 @@ mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
|||
if (use_mb_flag && (l = my_ismbchar(charset_info, from, end)))
|
||||
{
|
||||
while (l--)
|
||||
*to++ = *from++;
|
||||
*to++ = *from++;
|
||||
from--;
|
||||
continue;
|
||||
}
|
||||
|
@ -1788,7 +1581,7 @@ static my_bool read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
|||
mysql->server_status|= SERVER_STATUS_IN_TRANS;
|
||||
|
||||
mysql->extra_info= net_field_length_ll(&pos);
|
||||
if (!(fields_data= read_rows(mysql, (MYSQL_FIELD*) 0, 9)))
|
||||
if (!(fields_data= read_rows(mysql, (MYSQL_FIELD*) 0, 7)))
|
||||
DBUG_RETURN(1);
|
||||
if (!(stmt->fields= unpack_fields(fields_data,&stmt->mem_root,
|
||||
field_count,0,
|
||||
|
@ -1884,13 +1677,15 @@ unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
|
|||
like SHOW and DESCRIBE commands
|
||||
*/
|
||||
if (!(stmt->fields= (MYSQL_FIELD *) alloc_root(alloc,
|
||||
sizeof(MYSQL_FIELD) * stmt->field_count)) ||
|
||||
sizeof(MYSQL_FIELD) *
|
||||
stmt->field_count)) ||
|
||||
!(stmt->bind= (MYSQL_BIND *) alloc_root(alloc,
|
||||
sizeof(MYSQL_BIND ) * stmt->field_count)))
|
||||
sizeof(MYSQL_BIND) *
|
||||
stmt->field_count)))
|
||||
return 0;
|
||||
|
||||
for (fields= mysql->fields, end= fields+stmt->field_count,
|
||||
field= stmt->fields;
|
||||
field= stmt->fields;
|
||||
field && fields < end; fields++, field++)
|
||||
{
|
||||
field->db = strdup_root(alloc,fields->db);
|
||||
|
@ -2128,7 +1923,7 @@ static void store_param_datetime(NET *net, MYSQL_BIND *param)
|
|||
|
||||
static void store_param_str(NET *net, MYSQL_BIND *param)
|
||||
{
|
||||
ulong length= min(*param->length, param->buffer_length);
|
||||
ulong length= param->length ? *param->length : param->buffer_length;
|
||||
char *to= (char *) net_store_length((char *) net->write_pos, length);
|
||||
memcpy(to, param->buffer, length);
|
||||
net->write_pos= (uchar*) to+length;
|
||||
|
@ -2620,7 +2415,7 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
|
|||
{
|
||||
char *buffer= param->buffer;
|
||||
|
||||
switch(param->buffer_type) {
|
||||
switch (param->buffer_type) {
|
||||
case MYSQL_TYPE_NULL: /* do nothing */
|
||||
break;
|
||||
case MYSQL_TYPE_TINY:
|
||||
|
@ -2636,33 +2431,34 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
|
|||
int8store(buffer, value);
|
||||
break;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
{
|
||||
float data= (float)value;
|
||||
float4store(buffer, data);
|
||||
break;
|
||||
}
|
||||
{
|
||||
float data= (float)value;
|
||||
float4store(buffer, data);
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
{
|
||||
double data= (double)value;
|
||||
float8store(buffer, data);
|
||||
break;
|
||||
}
|
||||
{
|
||||
double data= (double)value;
|
||||
float8store(buffer, data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
char tmp[NAME_LEN];
|
||||
uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp);
|
||||
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
|
||||
memcpy(buffer, (char *)tmp+param->offset, copy_length);
|
||||
*param->length= length;
|
||||
{
|
||||
char tmp[12];
|
||||
uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp);
|
||||
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
|
||||
memcpy(buffer, (char *)tmp+param->offset, copy_length);
|
||||
*param->length= length;
|
||||
|
||||
if (copy_length != param->buffer_length)
|
||||
*(buffer+copy_length)= '\0';
|
||||
}
|
||||
if (copy_length != param->buffer_length)
|
||||
*(buffer+copy_length)= '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Convert Double to buffer types */
|
||||
|
||||
static void send_data_double(MYSQL_BIND *param, double value)
|
||||
{
|
||||
char *buffer= param->buffer;
|
||||
|
@ -2683,32 +2479,34 @@ static void send_data_double(MYSQL_BIND *param, double value)
|
|||
int8store(buffer, (longlong)value);
|
||||
break;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
{
|
||||
float data= (float)value;
|
||||
float4store(buffer, data);
|
||||
break;
|
||||
}
|
||||
{
|
||||
float data= (float)value;
|
||||
float4store(buffer, data);
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
{
|
||||
double data= (double)value;
|
||||
float8store(buffer, data);
|
||||
break;
|
||||
}
|
||||
{
|
||||
double data= (double)value;
|
||||
float8store(buffer, data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
char tmp[NAME_LEN];
|
||||
uint length= my_sprintf(tmp,(tmp,"%g",value));
|
||||
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
|
||||
memcpy(buffer, (char *)tmp+param->offset, copy_length);
|
||||
*param->length= length;
|
||||
{
|
||||
char tmp[12];
|
||||
uint length= my_sprintf(tmp,(tmp,"%g",value));
|
||||
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
|
||||
memcpy(buffer, (char *)tmp+param->offset, copy_length);
|
||||
*param->length= length;
|
||||
|
||||
if (copy_length != param->buffer_length)
|
||||
*(buffer+copy_length)= '\0';
|
||||
}
|
||||
if (copy_length != param->buffer_length)
|
||||
*(buffer+copy_length)= '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Convert string to buffer types */
|
||||
|
||||
static void send_data_str(MYSQL_BIND *param, char *value, uint length)
|
||||
{
|
||||
char *buffer= param->buffer;
|
||||
|
@ -2773,6 +2571,7 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime,
|
||||
uint length)
|
||||
{
|
||||
|
@ -2808,7 +2607,7 @@ static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime,
|
|||
switch (ltime.time_type) {
|
||||
case MYSQL_TIMESTAMP_DATE:
|
||||
length= my_sprintf(buff,(buff, "%04d-%02d-%02d", ltime.year,
|
||||
ltime.month,ltime.day));
|
||||
ltime.month,ltime.day));
|
||||
break;
|
||||
case MYSQL_TIMESTAMP_FULL:
|
||||
length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
|
@ -2817,7 +2616,7 @@ static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime,
|
|||
break;
|
||||
case MYSQL_TIMESTAMP_TIME:
|
||||
length= my_sprintf(buff, (buff, "%02d:%02d:%02d",
|
||||
ltime.hour,ltime.minute,ltime.second));
|
||||
ltime.hour,ltime.minute,ltime.second));
|
||||
break;
|
||||
default:
|
||||
length= 0;
|
||||
|
@ -2829,8 +2628,8 @@ static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Fetch data to buffers */
|
||||
|
||||
static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
|
||||
my_bool field_is_unsigned)
|
||||
{
|
||||
|
@ -2840,8 +2639,8 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
|
|||
case MYSQL_TYPE_TINY:
|
||||
{
|
||||
char value= (char) **row;
|
||||
longlong data= (field_is_unsigned) ? (longlong) (unsigned char) value:
|
||||
(longlong) value;
|
||||
longlong data= ((field_is_unsigned) ? (longlong) (unsigned char) value:
|
||||
(longlong) value);
|
||||
send_data_long(param,data);
|
||||
length= 1;
|
||||
break;
|
||||
|
@ -2850,8 +2649,8 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
|
|||
case MYSQL_TYPE_YEAR:
|
||||
{
|
||||
short value= sint2korr(*row);
|
||||
longlong data= (field_is_unsigned) ? (longlong) (unsigned short) value:
|
||||
(longlong) value;
|
||||
longlong data= ((field_is_unsigned) ? (longlong) (unsigned short) value:
|
||||
(longlong) value);
|
||||
send_data_long(param,data);
|
||||
length= 2;
|
||||
break;
|
||||
|
@ -2859,8 +2658,8 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
|
|||
case MYSQL_TYPE_LONG:
|
||||
{
|
||||
long value= sint4korr(*row);
|
||||
longlong data= (field_is_unsigned) ? (longlong) (unsigned long) value:
|
||||
(longlong) value;
|
||||
longlong data= ((field_is_unsigned) ? (longlong) (unsigned long) value:
|
||||
(longlong) value);
|
||||
send_data_long(param,data);
|
||||
length= 4;
|
||||
break;
|
||||
|
@ -2924,6 +2723,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
|
|||
*row+= length;
|
||||
}
|
||||
|
||||
|
||||
static void fetch_result_tinyint(MYSQL_BIND *param, uchar **row)
|
||||
{
|
||||
*param->buffer= (uchar) **row;
|
||||
|
@ -3136,6 +2936,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Fetch row data to bind buffers
|
||||
*/
|
||||
|
@ -3155,8 +2956,8 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
|
|||
|
||||
/* Copy complete row to application buffers */
|
||||
for (bind= stmt->bind, end= (MYSQL_BIND *) bind + stmt->field_count,
|
||||
field= stmt->fields,
|
||||
field_end= (MYSQL_FIELD *)stmt->fields+stmt->field_count;
|
||||
field= stmt->fields,
|
||||
field_end= (MYSQL_FIELD *)stmt->fields+stmt->field_count;
|
||||
bind < end && field < field_end;
|
||||
bind++, field++)
|
||||
{
|
||||
|
@ -3183,6 +2984,7 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Fetch and return row data to bound buffers, if any
|
||||
*/
|
||||
|
@ -3203,12 +3005,11 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
|
|||
|
||||
if (!res->data_cursor)
|
||||
{
|
||||
res->current_row= 0;
|
||||
stmt->current_row= 0;
|
||||
goto no_data;
|
||||
}
|
||||
row= (uchar *)res->data_cursor->data;
|
||||
res->data_cursor= res->data_cursor->next;
|
||||
res->current_row= (MYSQL_ROW)row;
|
||||
}
|
||||
else /* un-buffered */
|
||||
{
|
||||
|
@ -3225,8 +3026,8 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
|
|||
goto no_data;
|
||||
}
|
||||
row= mysql->net.read_pos+1;
|
||||
stmt->current_row= row;
|
||||
}
|
||||
}
|
||||
stmt->current_row= row;
|
||||
DBUG_RETURN(stmt_fetch_row(stmt, row));
|
||||
|
||||
no_data:
|
||||
|
@ -3234,6 +3035,7 @@ no_data:
|
|||
DBUG_RETURN(MYSQL_NO_DATA); /* no more data */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Fetch only specified column data to buffers
|
||||
*/
|
||||
|
@ -3247,12 +3049,7 @@ int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
|
|||
|
||||
DBUG_ENTER("mysql_fetch_column");
|
||||
|
||||
if (stmt->result_buffered)
|
||||
{
|
||||
if (!stmt->result || !(row= (uchar *)stmt->result->current_row))
|
||||
goto no_data;
|
||||
}
|
||||
else if (!(row= stmt->current_row))
|
||||
if (!(row= stmt->current_row))
|
||||
goto no_data;
|
||||
|
||||
#ifdef CHECK_EXTRA_ARGUMENTS
|
||||
|
@ -3313,7 +3110,8 @@ int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
|
|||
|
||||
for (i=0; i < icol; i++)
|
||||
{
|
||||
if (!(length= default_binary_field_length((uint)(stmt->fields[i].type))))
|
||||
if (!(length= default_binary_field_length((uint)(stmt->fields[i].
|
||||
type))))
|
||||
length= net_field_length(&row);
|
||||
row+= length;
|
||||
}
|
||||
|
@ -3348,7 +3146,7 @@ no_data:
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
Read all rows of data from server (binary format)
|
||||
*/
|
||||
|
||||
|
@ -3390,7 +3188,7 @@ static MYSQL_DATA *read_binary_rows(MYSQL_STMT *stmt)
|
|||
result->rows++;
|
||||
|
||||
if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc,sizeof(MYSQL_ROWS))) ||
|
||||
!(cur->data= ((MYSQL_ROW) alloc_root(&result->alloc, pkt_len))))
|
||||
!(cur->data= ((MYSQL_ROW) alloc_root(&result->alloc, pkt_len))))
|
||||
{
|
||||
free_rows(result);
|
||||
set_stmt_errmsg(stmt, ER(CR_OUT_OF_MEMORY), CR_OUT_OF_MEMORY,
|
||||
|
@ -3417,6 +3215,7 @@ static MYSQL_DATA *read_binary_rows(MYSQL_STMT *stmt)
|
|||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Store or buffer the binary results to stmt
|
||||
*/
|
||||
|
@ -3438,9 +3237,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
|||
}
|
||||
mysql->status= MYSQL_STATUS_READY; /* server is ready */
|
||||
if (!(result= (MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+
|
||||
sizeof(ulong) *
|
||||
stmt->field_count),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
sizeof(ulong) *
|
||||
stmt->field_count),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
{
|
||||
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
||||
DBUG_RETURN(1);
|
||||
|
@ -3459,6 +3258,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
|||
DBUG_RETURN(0); /* Data buffered, must be fetched with mysql_fetch() */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Seek to desired row in the statement result set
|
||||
*/
|
||||
|
@ -3481,6 +3281,7 @@ mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET row)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Return the current statement row cursor position
|
||||
*/
|
||||
|
@ -3497,6 +3298,7 @@ mysql_stmt_row_tell(MYSQL_STMT *stmt)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Move the stmt result set data cursor to specified row
|
||||
*/
|
||||
|
@ -3520,6 +3322,7 @@ mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong row)
|
|||
DBUG_PRINT("exit", ("stmt doesn't contain any resultset"));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Return total rows the current statement result set
|
||||
*/
|
||||
|
@ -3550,18 +3353,15 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt)
|
|||
0 ok
|
||||
1 error
|
||||
*/
|
||||
my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
||||
{
|
||||
|
||||
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
DBUG_ENTER("mysql_stmt_close");
|
||||
|
||||
DBUG_ASSERT(stmt != 0);
|
||||
|
||||
if (!(mysql= stmt->mysql))
|
||||
{
|
||||
my_free((gptr) stmt, MYF(MY_WME));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
mysql= stmt->mysql;
|
||||
if (mysql->status != MYSQL_STATUS_READY)
|
||||
{
|
||||
/* Clear the current execution status */
|
||||
|
@ -3576,6 +3376,24 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
|||
}
|
||||
mysql->status= MYSQL_STATUS_READY;
|
||||
}
|
||||
mysql_free_result(stmt->result);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
DBUG_ENTER("mysql_stmt_close");
|
||||
|
||||
DBUG_ASSERT(stmt != 0);
|
||||
|
||||
if (!(mysql= stmt->mysql))
|
||||
{
|
||||
my_free((gptr) stmt, MYF(MY_WME));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
mysql_stmt_free_result(stmt);
|
||||
if (stmt->state == MY_ST_PREPARE || stmt->state == MY_ST_EXECUTE)
|
||||
{
|
||||
char buff[4];
|
||||
|
@ -3588,7 +3406,6 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
|||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
mysql_free_result(stmt->result);
|
||||
stmt->field_count= 0;
|
||||
free_root(&stmt->mem_root, MYF(0));
|
||||
if (!skip_list)
|
||||
|
@ -3599,6 +3416,7 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
|
||||
{
|
||||
return stmt_close(stmt, 0);
|
||||
|
@ -3681,16 +3499,16 @@ my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
|
|||
|
||||
my_bool STDCALL mysql_more_results(MYSQL *mysql)
|
||||
{
|
||||
my_bool result;
|
||||
my_bool res;
|
||||
DBUG_ENTER("mysql_more_results");
|
||||
|
||||
result= (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) ?
|
||||
1: 0;
|
||||
|
||||
DBUG_PRINT("exit",("More results exists ? %d", result));
|
||||
DBUG_RETURN(result);
|
||||
res= ((mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) ?
|
||||
1: 0);
|
||||
DBUG_PRINT("exit",("More results exists ? %d", res));
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Reads and returns the next query results
|
||||
*/
|
||||
|
@ -3701,7 +3519,7 @@ my_bool STDCALL mysql_next_result(MYSQL *mysql)
|
|||
|
||||
mysql->net.last_error[0]= 0;
|
||||
mysql->net.last_errno= 0;
|
||||
strmov(mysql->net.sqlstate, unknown_sqlstate);
|
||||
strmov(mysql->net.sqlstate, not_error_sqlstate);
|
||||
mysql->affected_rows= ~(my_ulonglong) 0;
|
||||
|
||||
if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)
|
||||
|
|
|
@ -115,6 +115,7 @@ EXPORTS
|
|||
mysql_param_result
|
||||
mysql_prepare_result
|
||||
mysql_stmt_close
|
||||
mysql_stmt_free_result
|
||||
mysql_stmt_error
|
||||
mysql_stmt_errno
|
||||
mysql_fetch
|
||||
|
|
|
@ -43,7 +43,7 @@ sqlsources = derror.cc field.cc field_conv.cc filesort.cc \
|
|||
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
|
||||
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
|
||||
item_geofunc.cc item_uniq.cc item_subselect.cc item_row.cc\
|
||||
key.cc lock.cc log.cc log_event.cc \
|
||||
key.cc lock.cc log.cc log_event.cc sql_state.c \
|
||||
protocol.cc net_serv.cc opt_ft.cc opt_range.cc \
|
||||
opt_sum.cc procedure.cc records.cc sql_acl.cc \
|
||||
sql_load.cc sql_olap.cc \
|
||||
|
|
|
@ -450,6 +450,7 @@ static inline int mysql_init_charset(MYSQL *mysql)
|
|||
if (!mysql->charset)
|
||||
{
|
||||
mysql->last_errno=CR_CANT_READ_CHARSET;
|
||||
strmov(mysql->sqlstate, "HY0000");
|
||||
if (mysql->options.charset_dir)
|
||||
sprintf(mysql->last_error,ER(mysql->last_errno),
|
||||
charset_name ? charset_name : "unknown",
|
||||
|
@ -1130,6 +1131,7 @@ mysql_stat(MYSQL *mysql)
|
|||
if (!mysql->net.read_pos[0])
|
||||
{
|
||||
mysql->net.last_errno=CR_WRONG_HOST_INFO;
|
||||
strmov(mysql->sqlstate, unknown_sqlstate);
|
||||
strmov(mysql->net.last_error, ER(mysql->net.last_errno));
|
||||
return mysql->net.last_error;
|
||||
}
|
||||
|
@ -1284,12 +1286,12 @@ unsigned int STDCALL mysql_field_count(MYSQL *mysql)
|
|||
|
||||
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
|
||||
{
|
||||
return (mysql)->affected_rows;
|
||||
return mysql->affected_rows;
|
||||
}
|
||||
|
||||
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
|
||||
{
|
||||
return (mysql)->insert_id;
|
||||
return mysql->insert_id;
|
||||
}
|
||||
|
||||
uint STDCALL mysql_errno(MYSQL *mysql)
|
||||
|
@ -1297,6 +1299,11 @@ uint STDCALL mysql_errno(MYSQL *mysql)
|
|||
return mysql->last_errno;
|
||||
}
|
||||
|
||||
const char *STDCALL mysql_sqlstate(MYSQL *mysql)
|
||||
{
|
||||
return mysql->sqlstate;
|
||||
}
|
||||
|
||||
const char * STDCALL mysql_error(MYSQL *mysql)
|
||||
{
|
||||
return mysql->last_error;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.SH NAME
|
||||
mysql_fix_privilege_tables \- Fixes MySQL privilege tables.
|
||||
.SH SYNOPSIS
|
||||
mysql_fix_privilege_tables [options]
|
||||
mysql_fix_privilege_tables [mysql_root_password]
|
||||
.SH DESCRIPTION
|
||||
This scripts updates the mysql.user, mysql.db, mysql.host and the
|
||||
mysql.func tables to MySQL 3.22.14 and above.
|
||||
|
@ -10,10 +10,9 @@ mysql.func tables to MySQL 3.22.14 and above.
|
|||
This is needed if you want to use the new GRANT functions,
|
||||
CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 3.23
|
||||
|
||||
If you get 'Access denied' errors, you should run this script again
|
||||
and give the MySQL root user password as an argument!
|
||||
If you get 'Access denied' errors, run the script again
|
||||
and give the MySQL root user password as an argument.
|
||||
|
||||
For more information start the program with '--help'.
|
||||
.SH "SEE ALSO"
|
||||
mysql (1), mysqld (1)
|
||||
.SH AUTHOR
|
||||
|
|
|
@ -13,12 +13,15 @@ DB=test
|
|||
DBPASSWD=
|
||||
VERBOSE=""
|
||||
USE_MANAGER=0
|
||||
TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
|
||||
MY_TZ=GMT-3
|
||||
TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work
|
||||
|
||||
#++
|
||||
# Program Definitions
|
||||
#--
|
||||
|
||||
LC_COLLATE=C
|
||||
export LC_COLLATE
|
||||
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$PATH
|
||||
MASTER_40_ARGS="--rpl-recovery-rank=1 --init-rpl-role=master"
|
||||
|
||||
|
@ -1163,9 +1166,18 @@ run_testcase ()
|
|||
if [ -f $master_opt_file ] ;
|
||||
then
|
||||
EXTRA_MASTER_OPT=`$CAT $master_opt_file | $SED -e "s;\\$MYSQL_TEST_DIR;$MYSQL_TEST_DIR;"`
|
||||
case "$EXTRA_MASTER_OPT" in
|
||||
--timezone=*)
|
||||
TZ=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--timezone=;;"`
|
||||
export TZ
|
||||
# Note that this must be set to space, not "" for test-reset to work
|
||||
EXTRA_MASTER_OPT=" "
|
||||
;;
|
||||
esac
|
||||
stop_master
|
||||
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
|
||||
start_master
|
||||
TZ=$MY_TZ; export TZ
|
||||
else
|
||||
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || [ -f $master_init_script ]
|
||||
then
|
||||
|
|
|
@ -276,3 +276,8 @@ 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;
|
||||
|
|
|
@ -6,26 +6,26 @@ Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_
|
|||
count(*) 4 4 1 1 0 0 4.0000 0.0000 ENUM('4') NOT NULL
|
||||
select * from t1 procedure analyse();
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
||||
t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
||||
t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
||||
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
||||
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
select * from t1 procedure analyse(2);
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
||||
t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
||||
t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
||||
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
||||
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
create table t2 select * from t1 procedure analyse();
|
||||
select * from t2;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
||||
t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
||||
t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
||||
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
||||
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
||||
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
||||
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
||||
drop table t1,t2;
|
||||
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
|
|
@ -6,5 +6,13 @@ CREATE TABLE t1 (id INT, id2 int);
|
|||
SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
|
||||
id NULL 1 1.1 a
|
||||
SELECT id FROM t1 GROUP BY id2;
|
||||
't1.id' isn't in GROUP BY
|
||||
ERROR 42000: 'test.t1.id' isn't in GROUP BY
|
||||
drop table t1;
|
||||
set sql_mode="MySQL40";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
NO_FIELD_OPTIONS,MYSQL40
|
||||
set sql_mode="ANSI";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI
|
||||
|
|
|
@ -112,7 +112,7 @@ select last_insert_id();
|
|||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
Duplicate entry '255' for key 1
|
||||
ERROR 23000: Duplicate entry '255' for key 1
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
|
@ -140,7 +140,7 @@ select last_insert_id();
|
|||
last_insert_id()
|
||||
2
|
||||
insert into t1 values (NULL, 10);
|
||||
Duplicate entry '10' for key 2
|
||||
ERROR 23000: Duplicate entry '10' for key 2
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
3
|
||||
|
|
|
@ -9,7 +9,7 @@ set autocommit=0;
|
|||
update t2 set x = 1 where id = 0;
|
||||
select x from t1 where id = 0;
|
||||
select x from t2 where id = 0;
|
||||
Deadlock found when trying to get lock; Try restarting transaction
|
||||
ERROR 40001: Deadlock found when trying to get lock; Try restarting transaction
|
||||
commit;
|
||||
x
|
||||
1
|
||||
|
|
|
@ -48,7 +48,7 @@ id parent_id level
|
|||
15 102 2
|
||||
update t1 set id=id+1000;
|
||||
update t1 set id=1024 where id=1009;
|
||||
Duplicate entry '1024' for key 1
|
||||
ERROR 23000: Duplicate entry '1024' for key 1
|
||||
select * from t1;
|
||||
id parent_id level
|
||||
1001 100 0
|
||||
|
@ -270,7 +270,7 @@ n after commit
|
|||
commit;
|
||||
insert into t1 values (5);
|
||||
insert into t1 values (4);
|
||||
Duplicate entry '4' for key 1
|
||||
ERROR 23000: Duplicate entry '4' for key 1
|
||||
commit;
|
||||
select n, "after commit" from t1;
|
||||
n after commit
|
||||
|
@ -279,7 +279,7 @@ n after commit
|
|||
set autocommit=1;
|
||||
insert into t1 values (6);
|
||||
insert into t1 values (4);
|
||||
Duplicate entry '4' for key 1
|
||||
ERROR 23000: Duplicate entry '4' for key 1
|
||||
select n from t1;
|
||||
n
|
||||
4
|
||||
|
@ -309,7 +309,7 @@ drop table t1;
|
|||
CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=bdb;
|
||||
insert into t1 values ('pippo', 12);
|
||||
insert into t1 values ('pippo', 12);
|
||||
Duplicate entry 'pippo' for key 1
|
||||
ERROR 23000: Duplicate entry 'pippo' for key 1
|
||||
delete from t1;
|
||||
delete from t1 where id = 'pippo';
|
||||
select * from t1;
|
||||
|
@ -464,9 +464,9 @@ UNIQUE ggid (ggid)
|
|||
insert into t1 (ggid,passwd) values ('test1','xxx');
|
||||
insert into t1 (ggid,passwd) values ('test2','yyy');
|
||||
insert into t1 (ggid,passwd) values ('test2','this will fail');
|
||||
Duplicate entry 'test2' for key 2
|
||||
ERROR 23000: Duplicate entry 'test2' for key 2
|
||||
insert into t1 (ggid,id) values ('this will fail',1);
|
||||
Duplicate entry '1' for key 1
|
||||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
select * from t1 where ggid='test1';
|
||||
id ggid email passwd
|
||||
1 test1 xxx
|
||||
|
@ -479,7 +479,7 @@ id ggid email passwd
|
|||
replace into t1 (ggid,id) values ('this will work',1);
|
||||
replace into t1 (ggid,passwd) values ('test2','this will work');
|
||||
update t1 set id=100,ggid='test2' where id=1;
|
||||
Duplicate entry 'test2' for key 2
|
||||
ERROR 23000: Duplicate entry 'test2' for key 2
|
||||
select * from t1;
|
||||
id ggid email passwd
|
||||
1 this will work
|
||||
|
@ -1008,7 +1008,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
|
|||
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
|
||||
LOCK TABLES t1 WRITE;
|
||||
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
|
||||
Duplicate entry '1-1' for key 1
|
||||
ERROR 23000: Duplicate entry '1-1' for key 1
|
||||
select id from t1;
|
||||
id
|
||||
0
|
||||
|
@ -1026,7 +1026,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ
|
|||
LOCK TABLES t1 WRITE;
|
||||
begin;
|
||||
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
|
||||
Duplicate entry '1-1' for key 1
|
||||
ERROR 23000: Duplicate entry '1-1' for key 1
|
||||
select id from t1;
|
||||
id
|
||||
0
|
||||
|
|
|
@ -6,7 +6,7 @@ multi line comment */;
|
|||
1
|
||||
1
|
||||
;
|
||||
Query was empty
|
||||
ERROR 42000: Query was empty
|
||||
select 1 /*!32301 +1 */;
|
||||
1 /*!32301 +1
|
||||
2
|
||||
|
|
|
@ -17,29 +17,29 @@ b
|
|||
|
||||
drop table t1;
|
||||
create table t2 type=heap select * from t1;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t2 select auto+1 from t1;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
drop table if exists t1,t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t1 (b char(0) not null, index(b));
|
||||
The used storage engine can't index column 'b'
|
||||
ERROR 42000: The used storage engine can't index column 'b'
|
||||
create table t1 (a int not null auto_increment,primary key (a)) type=heap;
|
||||
create table t1 (a int not null,b text) type=heap;
|
||||
The used table type doesn't support BLOB/TEXT columns
|
||||
ERROR 42000: The used table type doesn't support BLOB/TEXT columns
|
||||
drop table if exists t1;
|
||||
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
|
||||
Incorrect table definition; There can only be one auto column and it must be defined as a key
|
||||
ERROR 42000: Incorrect table definition; There can only be one auto column and it must be defined as a key
|
||||
create table not_existing_database.test (a int);
|
||||
Got one of the listed errors
|
||||
create table `a/a` (a int);
|
||||
Incorrect table name 'a/a'
|
||||
ERROR 42000: Incorrect table name 'a/a'
|
||||
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
|
||||
Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
|
||||
Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
|
||||
ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
|
||||
create table 1ea10 (1a20 int,1e int);
|
||||
insert into 1ea10 values(1,1);
|
||||
select 1ea10.1a20,1e+ 1e+10 from 1ea10;
|
||||
|
@ -61,11 +61,11 @@ create table test_$1.test2$ (a int);
|
|||
drop table test_$1.test2$;
|
||||
drop database test_$1;
|
||||
create table `` (a int);
|
||||
Incorrect table name ''
|
||||
ERROR 42000: Incorrect table name ''
|
||||
drop table if exists ``;
|
||||
Incorrect table name ''
|
||||
ERROR 42000: Incorrect table name ''
|
||||
create table t1 (`` int);
|
||||
Incorrect column name ''
|
||||
ERROR 42000: Incorrect column name ''
|
||||
drop table if exists t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
|
@ -115,17 +115,17 @@ Field Type Null Key Default Extra
|
|||
a int(11) YES NULL
|
||||
drop table if exists t2;
|
||||
create table t2 (a int, a float) select * from t1;
|
||||
Duplicate column name 'a'
|
||||
ERROR 42S21: Duplicate column name 'a'
|
||||
drop table if exists t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t2 (a int) select a as b, a+1 as b from t1;
|
||||
Duplicate column name 'b'
|
||||
ERROR 42S21: Duplicate column name 'b'
|
||||
drop table if exists t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t2 (b int) select a as b, a+1 as b from t1;
|
||||
Duplicate column name 'b'
|
||||
ERROR 42S21: Duplicate column name 'b'
|
||||
drop table if exists t1,t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't2'
|
||||
|
@ -204,11 +204,11 @@ drop table t1;
|
|||
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
|
||||
insert into t1 values ("a", 1), ("b", 2);
|
||||
insert into t1 values ("c", NULL);
|
||||
Column 'k2' cannot be null
|
||||
ERROR 23000: Column 'k2' cannot be null
|
||||
insert into t1 values (NULL, 3);
|
||||
Column 'k1' cannot be null
|
||||
ERROR 23000: Column 'k1' cannot be null
|
||||
insert into t1 values (NULL, NULL);
|
||||
Column 'k1' cannot be null
|
||||
ERROR 23000: Column 'k1' cannot be null
|
||||
drop table t1;
|
||||
create table t1 (a int, key(a));
|
||||
create table t2 (b int, foreign key(b) references t1(a), key(b));
|
||||
|
@ -273,15 +273,15 @@ select * from t2;
|
|||
id name
|
||||
create table t3 like t1;
|
||||
create table t3 like test_$1.t3;
|
||||
Table 't3' already exists
|
||||
ERROR 42S01: Table 't3' already exists
|
||||
create table non_existing_database.t1 like t1;
|
||||
Got one of the listed errors
|
||||
create table t3 like non_existing_table;
|
||||
Unknown table 'non_existing_table'
|
||||
ERROR 42S02: Unknown table 'non_existing_table'
|
||||
create temporary table t3 like t1;
|
||||
Table 't3' already exists
|
||||
ERROR 42S01: Table 't3' already exists
|
||||
create table t3 like `a/a`;
|
||||
Incorrect table name 'a/a'
|
||||
ERROR 42000: Incorrect table name 'a/a'
|
||||
drop table t1, t2, t3;
|
||||
drop table t3;
|
||||
drop database test_$1;
|
||||
|
|
|
@ -6,7 +6,7 @@ latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
|
|||
CREATE TABLE t2 (
|
||||
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
|
||||
);
|
||||
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
|
||||
INSERT INTO t1 (latin1_f) VALUES (_latin1'a');
|
||||
INSERT INTO t1 (latin1_f) VALUES (_latin1'AD');
|
||||
|
@ -180,7 +180,7 @@ z
|
|||
å
|
||||
ü
|
||||
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
|
||||
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
|
||||
latin1_f_as
|
||||
A
|
||||
|
@ -298,7 +298,7 @@ z
|
|||
å
|
||||
ü
|
||||
SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
|
||||
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
|
||||
latin1_f count(*)
|
||||
A 2
|
||||
|
@ -390,7 +390,7 @@ z 1
|
|||
å 1
|
||||
ü 1
|
||||
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
|
||||
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
|
||||
SELECT DISTINCT latin1_f FROM t1;
|
||||
latin1_f
|
||||
A
|
||||
|
@ -482,7 +482,7 @@ y
|
|||
Z
|
||||
z
|
||||
SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
|
||||
COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1'
|
||||
ERROR 42000: COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1'
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
|
@ -524,5 +524,5 @@ SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
|
|||
charset('a') collation('a') coercibility('a') 'a'='A'
|
||||
latin1 latin1_swedish_ci 3 1
|
||||
SET CHARACTER SET 'DEFAULT';
|
||||
Unknown character set: 'DEFAULT'
|
||||
ERROR 42000: Unknown character set: 'DEFAULT'
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -21,7 +21,7 @@ insert delayed into t1 values (1,"b");
|
|||
insert delayed into t1 values (null,"c");
|
||||
insert delayed into t1 values (3,"d"),(null,"e");
|
||||
insert delayed into t1 values (3,"this will give an","error");
|
||||
Column count doesn't match value count at row 1
|
||||
ERROR 21S01: Column count doesn't match value count at row 1
|
||||
select * from t1;
|
||||
a b
|
||||
1 b
|
||||
|
|
|
@ -30,7 +30,7 @@ CREATE TABLE `t1` (
|
|||
PRIMARY KEY (`i`)
|
||||
);
|
||||
DELETE FROM t1 USING t1 WHERE post='1';
|
||||
Unknown column 'post' in 'where clause'
|
||||
ERROR 42S22: Unknown column 'post' in 'where clause'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
bool char(0) default NULL,
|
||||
|
|
|
@ -3,9 +3,9 @@ select * from (select 2 from DUAL) b;
|
|||
2
|
||||
2
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
CREATE TABLE t1 (a int not null, b char (10) not null);
|
||||
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
|
||||
CREATE TABLE t2 (a int not null, b char (10) not null);
|
||||
|
@ -25,18 +25,18 @@ a y
|
|||
3 3
|
||||
3 3
|
||||
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
|
||||
Unknown column 'a' in 'having clause'
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
|
||||
Column: 'a' in having clause is ambiguous
|
||||
ERROR 23000: Column: 'a' in having clause is ambiguous
|
||||
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
|
||||
a a
|
||||
1 2
|
||||
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
|
||||
a a
|
||||
SELECT 1 FROM (SELECT 1) a WHERE a=2;
|
||||
Unknown column 'a' in 'where clause'
|
||||
ERROR 42S22: Unknown column 'a' in 'where clause'
|
||||
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
|
||||
Unknown column 'a' in 'having clause'
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
select * from t1 as x1, (select * from t1) as x2;
|
||||
a b a b
|
||||
1 a 1 a
|
||||
|
@ -146,10 +146,17 @@ select * from (select 1 as a) b left join (select 2 as a) c using(a);
|
|||
a a
|
||||
1 NULL
|
||||
SELECT * FROM (SELECT 1 UNION SELECT a) b;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
select 1 from (select 2) a order by 0;
|
||||
Unknown column '0' in 'order clause'
|
||||
ERROR 42S22: Unknown column '0' in 'order clause'
|
||||
create table t1 (id int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
describe select * from (select * from t1 group by id) bar;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
drop table t1;
|
||||
|
|
|
@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index a a 5 NULL 6 Using index; Using temporary
|
||||
1 SIMPLE t2 index a a 4 NULL 5 Using index; Distinct
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using where; Distinct
|
||||
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
a
|
||||
1
|
||||
|
@ -190,7 +190,7 @@ insert into t3 select * from t4;
|
|||
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index; Using temporary
|
||||
1 SIMPLE t3 ref a a 5 t1.a 10 Using where; Using index; Distinct
|
||||
1 SIMPLE t3 ref a a 5 test.t1.a 10 Using where; Using index; Distinct
|
||||
select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
a
|
||||
1
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
drop table if exists t1;
|
||||
drop table t1;
|
||||
Unknown table 't1'
|
||||
ERROR 42S02: Unknown table 't1'
|
||||
create table t1(n int);
|
||||
insert into t1 values(1);
|
||||
create temporary table t1( n int);
|
||||
insert into t1 values(2);
|
||||
create table t1(n int);
|
||||
Table 't1' already exists
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
drop table t1;
|
||||
select * from t1;
|
||||
n
|
||||
|
@ -48,4 +48,4 @@ Database
|
|||
mysql
|
||||
test
|
||||
drop database mysqltest;
|
||||
Can't drop database 'mysqltest'. Database doesn't exist
|
||||
ERROR HY000: Can't drop database 'mysqltest'. Database doesn't exist
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
drop table if exists t1;
|
||||
insert into t1 values(1);
|
||||
Table 'test.t1' doesn't exist
|
||||
delete from t1;
|
||||
Table 'test.t1' doesn't exist
|
||||
update t1 set a=1;
|
||||
Table 'test.t1' doesn't exist
|
||||
create table t1 (a int);
|
||||
select count(test.t1.b) from t1;
|
||||
Unknown column 'test.t1.b' in 'field list'
|
||||
select count(not_existing_database.t1) from t1;
|
||||
Unknown table 'not_existing_database' in field list
|
||||
select count(not_existing_database.t1.a) from t1;
|
||||
Unknown table 'not_existing_database.t1' in field list
|
||||
select count(not_existing_database.t1.a) from not_existing_database.t1;
|
||||
Got one of the listed errors
|
||||
select 1 from t1 order by 2;
|
||||
Unknown column '2' in 'order clause'
|
||||
select 1 from t1 group by 2;
|
||||
Unknown column '2' in 'group statement'
|
||||
select 1 from t1 order by t1.b;
|
||||
Unknown column 't1.b' in 'order clause'
|
||||
select count(*),b from t1;
|
||||
Unknown column 'b' in 'field list'
|
||||
drop table t1;
|
25
mysql-test/r/errors.result
Normal file
25
mysql-test/r/errors.result
Normal file
|
@ -0,0 +1,25 @@
|
|||
drop table if exists t1;
|
||||
insert into t1 values(1);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
delete from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
update t1 set a=1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t1 (a int);
|
||||
select count(test.t1.b) from t1;
|
||||
ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
|
||||
select count(not_existing_database.t1) from t1;
|
||||
ERROR 42S02: Unknown table 'not_existing_database' in field list
|
||||
select count(not_existing_database.t1.a) from t1;
|
||||
ERROR 42S02: Unknown table 'not_existing_database.t1' in field list
|
||||
select count(not_existing_database.t1.a) from not_existing_database.t1;
|
||||
Got one of the listed errors
|
||||
select 1 from t1 order by 2;
|
||||
ERROR 42S22: Unknown column '2' in 'order clause'
|
||||
select 1 from t1 group by 2;
|
||||
ERROR 42S22: Unknown column '2' in 'group statement'
|
||||
select 1 from t1 order by t1.b;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'order clause'
|
||||
select count(*),b from t1;
|
||||
ERROR 42S22: Unknown column 'b' in 'field list'
|
||||
drop table t1;
|
|
@ -24,9 +24,9 @@ explain select * from t1 use key (str,str) where str="foo";
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const str str 11 const 1
|
||||
explain select * from t1 use key (str,str,foo) where str="foo";
|
||||
Key column 'foo' doesn't exist in table
|
||||
ERROR 42000: Key column 'foo' doesn't exist in table
|
||||
explain select * from t1 ignore key (str,str,foo) where str="foo";
|
||||
Key column 'foo' doesn't exist in table
|
||||
ERROR 42000: Key column 'foo' doesn't exist in table
|
||||
drop table t1;
|
||||
explain select 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
|
|
@ -8,7 +8,7 @@ n
|
|||
3
|
||||
flush tables with read lock;
|
||||
drop table t2;
|
||||
Table 't2' was locked with a READ lock and can't be updated
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
drop table t2;
|
||||
unlock tables;
|
||||
create database mysqltest;
|
||||
|
|
|
@ -162,11 +162,11 @@ KEY tig (ticket),
|
|||
fulltext index tix (inhalt)
|
||||
);
|
||||
select * from t2 where MATCH inhalt AGAINST (t2.inhalt);
|
||||
Wrong arguments to AGAINST
|
||||
ERROR HY000: Wrong arguments to AGAINST
|
||||
select * from t2 where MATCH ticket AGAINST ('foobar');
|
||||
Can't find FULLTEXT index matching the column list
|
||||
ERROR HY000: Can't find FULLTEXT index matching the column list
|
||||
select * from t2,t3 where MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar');
|
||||
Wrong arguments to MATCH
|
||||
ERROR HY000: Wrong arguments to MATCH
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) auto_increment,
|
||||
|
|
|
@ -173,7 +173,7 @@ REQ_ID URL
|
|||
drop table T_URL;
|
||||
drop table T_REQUEST;
|
||||
select group_concat(sum(a)) from t1 group by grp;
|
||||
Invalid use of group function
|
||||
ERROR HY000: Invalid use of group function
|
||||
select grp,group_concat(c order by 2) from t1 group by grp;
|
||||
Unknown column '2' in 'group statement'
|
||||
ERROR 42S22: Unknown column '2' in 'group statement'
|
||||
drop table t1;
|
||||
|
|
|
@ -64,7 +64,7 @@ concat_ws(NULL,'a') concat_ws(',',NULL,'')
|
|||
NULL
|
||||
select concat_ws(',','',NULL,'a');
|
||||
concat_ws(',','',NULL,'a')
|
||||
a
|
||||
,a
|
||||
SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"');
|
||||
CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"')
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
|
||||
|
|
|
@ -37,13 +37,13 @@ version()>=_latin1"3.23.29"
|
|||
select charset(version());
|
||||
charset(version())
|
||||
utf8
|
||||
create table t1 select database(), user(), version();
|
||||
create table t1 (version char(40)) select database(), user(), version() as 'version';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`database()` char(102) character set utf8 NOT NULL default '',
|
||||
`user()` char(231) character set utf8 NOT NULL default '',
|
||||
`version()` char(21) character set utf8 NOT NULL default ''
|
||||
`version` char(40) character set utf8 default NULL
|
||||
) TYPE=MyISAM CHARSET=latin1
|
||||
drop table t1;
|
||||
select TRUE,FALSE,NULL;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
delete from mysql.db where user='mysqltest_1';
|
||||
flush privileges;
|
||||
|
@ -69,3 +71,36 @@ show grants for user@localhost;
|
|||
Grants for user@localhost
|
||||
GRANT USAGE ON *.* TO 'user'@'localhost'
|
||||
GRANT USAGE ON `test`.* TO 'user'@'localhost' WITH GRANT OPTION
|
||||
grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION;
|
||||
show grants for drop_user2@localhost;
|
||||
Grants for drop_user2@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'drop_user2'@'localhost' WITH GRANT OPTION
|
||||
revoke all privileges, grant from drop_user2@localhost;
|
||||
drop user drop_user2@localhost;
|
||||
grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION;
|
||||
grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION;
|
||||
grant select(a) on test.t1 to drop_user@localhost;
|
||||
show grants for drop_user@localhost;
|
||||
Grants for drop_user@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION
|
||||
GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION
|
||||
GRANT SELECT (a) ON `test`.`t1` TO 'drop_user'@'localhost'
|
||||
revoke all privileges, grant from drop_user@localhost;
|
||||
show grants for drop_user@localhost;
|
||||
Grants for drop_user@localhost
|
||||
GRANT USAGE ON *.* TO 'drop_user'@'localhost'
|
||||
drop user drop_user@localhost;
|
||||
revoke all privileges, grant from drop_user@localhost;
|
||||
Can't revoke all privileges, grant for one or more of the requested users
|
||||
grant select(a) on test.t1 to drop_user1@localhost;
|
||||
grant select on test.t1 to drop_user2@localhost;
|
||||
grant select on test.* to drop_user3@localhost;
|
||||
grant select on *.* to drop_user4@localhost;
|
||||
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
|
||||
drop_user4@localhost;
|
||||
Can't drop one or more of the requested users
|
||||
revoke all privileges, grant from drop_user1@localhost, drop_user2@localhost,
|
||||
drop_user3@localhost, drop_user4@localhost;
|
||||
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
|
||||
drop_user4@localhost;
|
||||
drop table t1;
|
||||
|
|
|
@ -84,7 +84,7 @@ a b c a
|
|||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
select * from t2;
|
||||
select command denied to user: 'mysqltest_2@localhost' for table 't2'
|
||||
ERROR 42000: select command denied to user: 'mysqltest_2@localhost' for table 't2'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
|
@ -98,17 +98,17 @@ select "user3";
|
|||
user3
|
||||
user3
|
||||
select * from t1;
|
||||
select command denied to user: 'mysqltest_3@localhost' for column 'b' in table 't1'
|
||||
ERROR 42000: select command denied to user: 'mysqltest_3@localhost' for column 'b' in table 't1'
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
SELECT command denied to user: 'mysqltest_3@localhost' for column 'c' in table 't1'
|
||||
ERROR 42000: SELECT command denied to user: 'mysqltest_3@localhost' for column 'c' in table 't1'
|
||||
select * from t2;
|
||||
select command denied to user: 'mysqltest_3@localhost' for table 't2'
|
||||
ERROR 42000: select command denied to user: 'mysqltest_3@localhost' for table 't2'
|
||||
select mysqltest.t1.c from test.t1,mysqltest.t1;
|
||||
SELECT command denied to user: 'mysqltest_3@localhost' for column 'c' in table 't1'
|
||||
ERROR 42000: SELECT command denied to user: 'mysqltest_3@localhost' for column 'c' in table 't1'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
|
@ -122,7 +122,7 @@ select "user4";
|
|||
user4
|
||||
user4
|
||||
select a from t1;
|
||||
No Database Selected
|
||||
ERROR 42000: No Database Selected
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
drop table if exists t1,t2,t3;
|
||||
SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
|
||||
Invalid use of group function
|
||||
ERROR HY000: Invalid use of group function
|
||||
CREATE TABLE t1 (
|
||||
spID int(10) unsigned,
|
||||
userID int(10) unsigned,
|
||||
|
@ -56,7 +56,7 @@ userid MIN(t1.score+0.0)
|
|||
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.userID 1 Using index
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
PID int(10) unsigned NOT NULL auto_increment,
|
||||
|
@ -79,7 +79,7 @@ KEY payDate (payDate)
|
|||
);
|
||||
INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
|
||||
SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
|
||||
Can't group on 'IsNew'
|
||||
ERROR 42000: Can't group on 'IsNew'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
cid mediumint(9) NOT NULL auto_increment,
|
||||
|
|
|
@ -6,7 +6,7 @@ insert into t1 values
|
|||
(20,"ggg"),(21,"hhh"),(22,"iii");
|
||||
handler t1 open as t2;
|
||||
handler t2 read a=(SELECT 1);
|
||||
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
|
||||
ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
|
||||
handler t2 read a first;
|
||||
a b
|
||||
14 aaa
|
||||
|
@ -51,7 +51,7 @@ handler t2 read a=(16);
|
|||
a b
|
||||
16 ccc
|
||||
handler t2 read a=(19,"fff");
|
||||
Too many key parts specified. Max 1 parts allowed
|
||||
ERROR 42000: Too many key parts specified. Max 1 parts allowed
|
||||
handler t2 read b=(19,"fff");
|
||||
a b
|
||||
19 fff
|
||||
|
@ -62,7 +62,7 @@ handler t2 read b=(19);
|
|||
a b
|
||||
19 fff
|
||||
handler t1 read a last;
|
||||
Unknown table 't1' in HANDLER
|
||||
ERROR 42S02: Unknown table 't1' in HANDLER
|
||||
handler t2 read a=(11);
|
||||
a b
|
||||
handler t2 read a>=(11);
|
||||
|
@ -135,16 +135,16 @@ handler t2 read next;
|
|||
a b
|
||||
19 fff
|
||||
handler t2 read last;
|
||||
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
handler t2 close;
|
||||
handler t1 open as t2;
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (17);
|
||||
handler t2 read first;
|
||||
Unknown table 't2' in HANDLER
|
||||
ERROR 42S02: Unknown table 't2' in HANDLER
|
||||
handler t1 open as t2;
|
||||
alter table t1 type=MyISAM;
|
||||
handler t2 read first;
|
||||
Unknown table 't2' in HANDLER
|
||||
ERROR 42S02: Unknown table 't2' in HANDLER
|
||||
drop table t1;
|
||||
|
|
2
mysql-test/r/have_mest_timezone.require
Normal file
2
mysql-test/r/have_mest_timezone.require
Normal file
|
@ -0,0 +1,2 @@
|
|||
Variable_name Value
|
||||
timezone MEST
|
|
@ -86,7 +86,7 @@ x y x y
|
|||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 t1.x 1
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) type=heap;
|
||||
insert into t1 values(1);
|
||||
|
@ -201,7 +201,7 @@ SELECT * FROM t1 WHERE b<=>NULL;
|
|||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
Duplicate entry '3' for key 1
|
||||
ERROR 23000: Duplicate entry '3' for key 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key(a)) type=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
|
|
|
@ -89,7 +89,7 @@ x y x y
|
|||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 t1.x 1
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) type=heap;
|
||||
insert into t1 values(1);
|
||||
|
@ -217,7 +217,7 @@ SELECT * FROM t1 WHERE b<=>NULL;
|
|||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
Duplicate entry '3' for key 1
|
||||
ERROR 23000: Duplicate entry '3' for key 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap;
|
||||
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
|
||||
|
|
|
@ -86,7 +86,7 @@ x y x y
|
|||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 t1.x 1
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) type=heap;
|
||||
insert into t1 values(1);
|
||||
|
@ -201,7 +201,7 @@ SELECT * FROM t1 WHERE b<=>NULL;
|
|||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
Duplicate entry '3' for key 1
|
||||
ERROR 23000: Duplicate entry '3' for key 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
|
|
|
@ -224,7 +224,7 @@ n after commit
|
|||
commit;
|
||||
insert into t1 values (5);
|
||||
insert into t1 values (4);
|
||||
Duplicate entry '4' for key 1
|
||||
ERROR 23000: Duplicate entry '4' for key 1
|
||||
commit;
|
||||
select n, "after commit" from t1;
|
||||
n after commit
|
||||
|
@ -233,7 +233,7 @@ n after commit
|
|||
set autocommit=1;
|
||||
insert into t1 values (6);
|
||||
insert into t1 values (4);
|
||||
Duplicate entry '4' for key 1
|
||||
ERROR 23000: Duplicate entry '4' for key 1
|
||||
select n from t1;
|
||||
n
|
||||
4
|
||||
|
@ -263,7 +263,7 @@ drop table t1;
|
|||
CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=innodb;
|
||||
insert into t1 values ('pippo', 12);
|
||||
insert into t1 values ('pippo', 12);
|
||||
Duplicate entry 'pippo' for key 1
|
||||
ERROR 23000: Duplicate entry 'pippo' for key 1
|
||||
delete from t1;
|
||||
delete from t1 where id = 'pippo';
|
||||
select * from t1;
|
||||
|
@ -427,9 +427,9 @@ UNIQUE ggid (ggid)
|
|||
insert into t1 (ggid,passwd) values ('test1','xxx');
|
||||
insert into t1 (ggid,passwd) values ('test2','yyy');
|
||||
insert into t1 (ggid,passwd) values ('test2','this will fail');
|
||||
Duplicate entry 'test2' for key 2
|
||||
ERROR 23000: Duplicate entry 'test2' for key 2
|
||||
insert into t1 (ggid,id) values ('this will fail',1);
|
||||
Duplicate entry '1' for key 1
|
||||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
select * from t1 where ggid='test1';
|
||||
id ggid email passwd
|
||||
1 test1 xxx
|
||||
|
@ -442,7 +442,7 @@ id ggid email passwd
|
|||
replace into t1 (ggid,id) values ('this will work',1);
|
||||
replace into t1 (ggid,passwd) values ('test2','this will work');
|
||||
update t1 set id=100,ggid='test2' where id=1;
|
||||
Duplicate entry 'test2' for key 2
|
||||
ERROR 23000: Duplicate entry 'test2' for key 2
|
||||
select * from t1;
|
||||
id ggid email passwd
|
||||
1 this will work
|
||||
|
@ -753,7 +753,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
|
|||
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
|
||||
LOCK TABLES t1 WRITE;
|
||||
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
|
||||
Duplicate entry '1-1' for key 1
|
||||
ERROR 23000: Duplicate entry '1-1' for key 1
|
||||
select id from t1;
|
||||
id
|
||||
0
|
||||
|
@ -771,7 +771,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ
|
|||
LOCK TABLES t1 WRITE;
|
||||
begin;
|
||||
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
|
||||
Duplicate entry '1-1' for key 1
|
||||
ERROR 23000: Duplicate entry '1-1' for key 1
|
||||
select id from t1;
|
||||
id
|
||||
0
|
||||
|
@ -788,7 +788,7 @@ id id3
|
|||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
create table t1 (a char(20), unique (a(5))) type=innodb;
|
||||
Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the store engine doesn't support unique sub keys
|
||||
ERROR HY000: Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the store engine doesn't support unique sub keys
|
||||
create table t1 (a char(20), index (a(5))) type=innodb;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
|
@ -851,7 +851,7 @@ set autocommit=0;
|
|||
create table t1 (a int not null) type= innodb;
|
||||
insert into t1 values(1),(2);
|
||||
truncate table t1;
|
||||
Can't execute the given command because you have active locked tables or an active transaction
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
commit;
|
||||
truncate table t1;
|
||||
select * from t1;
|
||||
|
|
|
@ -49,7 +49,7 @@ handler t2 read a=(16);
|
|||
a b
|
||||
16 ccc
|
||||
handler t2 read a=(19,"fff");
|
||||
Too many key parts specified. Max 1 parts allowed
|
||||
ERROR 42000: Too many key parts specified. Max 1 parts allowed
|
||||
handler t2 read b=(19,"fff");
|
||||
a b
|
||||
19 fff
|
||||
|
@ -60,7 +60,7 @@ handler t2 read b=(19);
|
|||
a b
|
||||
19 fff
|
||||
handler t1 read a last;
|
||||
Unknown table 't1' in HANDLER
|
||||
ERROR 42S02: Unknown table 't1' in HANDLER
|
||||
handler t2 read a=(11);
|
||||
a b
|
||||
handler t2 read a>=(11);
|
||||
|
@ -130,7 +130,7 @@ handler t2 read next;
|
|||
a b
|
||||
18 eee
|
||||
handler t2 read last;
|
||||
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
handler t2 close;
|
||||
handler t1 open as t2;
|
||||
handler t2 read first;
|
||||
|
@ -138,7 +138,7 @@ a b
|
|||
17 ddd
|
||||
alter table t1 type=innodb;
|
||||
handler t2 read first;
|
||||
Unknown table 't2' in HANDLER
|
||||
ERROR 42S02: Unknown table 't2' in HANDLER
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2)) TYPE=InnoDB;
|
||||
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
|
||||
|
|
|
@ -4,7 +4,7 @@ insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,
|
|||
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;
|
||||
Duplicate entry '16' for key 1
|
||||
ERROR 23000: Duplicate entry '16' for key 1
|
||||
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
select * from t2;
|
||||
payoutID
|
||||
|
@ -65,3 +65,14 @@ 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 IF EXISTS 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;
|
||||
Log_name Pos Event_type Server_id Orig_log_pos Info
|
||||
master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
|
||||
drop table t1, t2;
|
||||
|
|
|
@ -26,7 +26,7 @@ a b c
|
|||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
|
||||
Duplicate entry '4' for key 2
|
||||
ERROR 23000: Duplicate entry '4' for key 2
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10010
|
||||
|
|
|
@ -128,7 +128,7 @@ a
|
|||
1
|
||||
2
|
||||
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
|
||||
Too many tables. MySQL can only use XX tables in a join
|
||||
ERROR HY000: Too many tables. MySQL can only use XX tables in a join
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int(11) NOT NULL,
|
||||
|
|
|
@ -95,7 +95,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 Using where
|
||||
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 8 test.t1.a 1 Using where
|
||||
select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
|
||||
grp a c id a c d a
|
||||
1 1 a 1 1 a 1 1
|
||||
|
@ -106,11 +106,11 @@ grp a c id a c d a
|
|||
3 6 D 3 6 C 6 6
|
||||
NULL NULL NULL NULL NULL NULL NULL
|
||||
explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
|
||||
Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
|
||||
Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
|
||||
Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
select t1.*,t2.* from t1 inner join t2 using (a);
|
||||
grp a c id a c d
|
||||
1 1 a 1 1 a 1
|
||||
|
@ -169,7 +169,7 @@ usr_id uniq_id increment usr2_id c_amount max
|
|||
3 4 84676 NULL NULL NULL
|
||||
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
|
||||
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
|
||||
Duplicate entry '2-3' for key 1
|
||||
ERROR 23000: Duplicate entry '2-3' for key 1
|
||||
INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes');
|
||||
SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount;
|
||||
usr_id uniq_id increment usr2_id c_amount max
|
||||
|
@ -406,7 +406,7 @@ insert into t3 values (1);
|
|||
insert into t4 values (1,1);
|
||||
insert into t5 values (1,1);
|
||||
explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
|
||||
Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
|
||||
drop table t1,t2,t3,t4,t5;
|
||||
create table t1 (n int, m int, o int, key(n));
|
||||
create table t2 (n int not null, m int, o int, primary key(n));
|
||||
|
|
|
@ -127,7 +127,7 @@ primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE )
|
|||
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
|
||||
INSERT INTO t1 VALUES (1, 1, 1, 1, 'b');
|
||||
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
|
||||
Duplicate entry '1-1-1-1-a' for key 1
|
||||
ERROR 23000: Duplicate entry '1-1-1-1-a' for key 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a tinytext NOT NULL,
|
||||
|
|
|
@ -15,4 +15,16 @@ a b c d
|
|||
0000-00-00 0000-00-00 0000-00-00 0000-00-00
|
||||
2003-03-03 2003-03-03 2003-03-03 NULL
|
||||
2003-03-03 2003-03-03 2003-03-03 NULL
|
||||
truncate table t1;
|
||||
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
|
||||
Warnings:
|
||||
Warning 1263 Data truncated for column 'c' at row 1
|
||||
Warning 1263 Data truncated for column 'd' at row 1
|
||||
Warning 1263 Data truncated for column 'b' at row 2
|
||||
Warning 1263 Data truncated for column 'd' at row 2
|
||||
SELECT * from t1;
|
||||
a b c d
|
||||
NULL NULL 0000-00-00 0000-00-00
|
||||
NULL 0000-00-00 0000-00-00 0000-00-00
|
||||
NULL 2003-03-03 2003-03-03 NULL
|
||||
drop table t1;
|
||||
|
|
|
@ -8,9 +8,9 @@ NULL 1
|
|||
update t1 set id=-1 where id=1;
|
||||
LOCK TABLE t1 READ;
|
||||
update t1 set id=1 where id=1;
|
||||
Table 't1' was locked with a READ lock and can't be updated
|
||||
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||
create table t2 SELECT * from t1;
|
||||
Table 't2' was not locked with LOCK TABLES
|
||||
ERROR HY000: Table 't2' was not locked with LOCK TABLES
|
||||
create temporary table t2 SELECT * from t1;
|
||||
drop table if exists t2;
|
||||
unlock tables;
|
||||
|
|
|
@ -22,5 +22,5 @@ create table t2 (a int);
|
|||
lock table t1 write, t2 write;
|
||||
insert t1 select * from t2;
|
||||
drop table t2;
|
||||
Table 'test.t2' doesn't exist
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
drop table t1;
|
||||
|
|
|
@ -13,3 +13,17 @@ show tables like 't_';
|
|||
Tables_in_test (t_)
|
||||
t3
|
||||
drop table t3;
|
||||
create table t1 (a int);
|
||||
select count(*) from T1;
|
||||
count(*)
|
||||
0
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
select count(T1.a) from t1;
|
||||
count(T1.a)
|
||||
0
|
||||
select count(bags.a) from t1 as Bags;
|
||||
count(bags.a)
|
||||
0
|
||||
drop table t1;
|
||||
|
|
|
@ -177,9 +177,9 @@ t3 CREATE TABLE `t3` (
|
|||
) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2)
|
||||
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
|
||||
select * from t4;
|
||||
Can't open file: 't4.MRG'. (errno: 143)
|
||||
ERROR HY000: Can't open file: 't4.MRG'. (errno: 143)
|
||||
create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
|
||||
Incorrect table definition; All MERGE tables must be in the same database
|
||||
ERROR HY000: Incorrect table definition; All MERGE tables must be in the same database
|
||||
drop table if exists t5,t4,t3,t1,t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't5'
|
||||
|
|
|
@ -147,11 +147,11 @@ insert into t1 values(1,1);
|
|||
insert into t2 values(1,10),(2,20);
|
||||
LOCK TABLES t1 write, t2 read;
|
||||
DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
|
||||
Table 't2' was locked with a READ lock and can't be updated
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
|
||||
Table 't2' was locked with a READ lock and can't be updated
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
|
||||
Table 't2' was locked with a READ lock and can't be updated
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
unlock tables;
|
||||
LOCK TABLES t1 write, t2 write;
|
||||
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
|
||||
|
@ -172,7 +172,7 @@ create table t2 (n int(10), d int(10));
|
|||
insert into t1 values(1,1);
|
||||
insert into t2 values(1,10),(2,20);
|
||||
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
|
||||
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
|
||||
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
|
||||
set sql_safe_updates=0;
|
||||
drop table t1,t2;
|
||||
set timestamp=1038401397;
|
||||
|
@ -190,7 +190,7 @@ n d unix_timestamp(t)
|
|||
1 10 1038401397
|
||||
2 20 1038401397
|
||||
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
|
||||
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1
|
||||
ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1
|
||||
drop table t1,t2;
|
||||
set timestamp=0;
|
||||
set sql_safe_updates=0;
|
||||
|
|
|
@ -339,10 +339,10 @@ Table Op Msg_type Msg_text
|
|||
test.t1 check status OK
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), KEY t1 (a, b, c));
|
||||
Specified key was too long. Max key length is 500
|
||||
ERROR 42000: Specified key was too long. Max key length is 500
|
||||
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255));
|
||||
ALTER TABLE t1 ADD INDEX t1 (a, b, c);
|
||||
Specified key was too long. Max key length is 500
|
||||
ERROR 42000: Specified key was too long. Max key length is 500
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
|
||||
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
|
||||
|
@ -370,11 +370,11 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL a NULL NULL NULL 2
|
||||
1 SIMPLE t1 ref a a 4 t2.a 3
|
||||
1 SIMPLE t1 ref a a 4 test.t2.a 3
|
||||
explain select * from t1,t2 where t1.b=t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL b NULL NULL NULL 2
|
||||
1 SIMPLE t1 ref b b 5 t2.b 1 Using where
|
||||
1 SIMPLE t1 ref b b 5 test.t2.b 1 Using where
|
||||
explain select * from t1,t2 force index(c) where t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL a NULL NULL NULL 5
|
||||
|
@ -393,7 +393,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
|
||||
This version of MySQL doesn't yet support 'RTREE INDEX'
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX'
|
||||
DROP TABLE IF EXISTS t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
|
|
|
@ -82,33 +82,33 @@ UPDATE t1 SET d=NULL;
|
|||
Warnings:
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'd' at row 1
|
||||
INSERT INTO t1 (a) values (null);
|
||||
Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
INSERT INTO t1 (a) values (1/null);
|
||||
Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
INSERT INTO t1 (a) values (null),(null);
|
||||
Warnings:
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'a' at row 1
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'a' at row 2
|
||||
INSERT INTO t1 (b) values (null);
|
||||
Column 'b' cannot be null
|
||||
ERROR 23000: Column 'b' cannot be null
|
||||
INSERT INTO t1 (b) values (1/null);
|
||||
Column 'b' cannot be null
|
||||
ERROR 23000: Column 'b' cannot be null
|
||||
INSERT INTO t1 (b) values (null),(null);
|
||||
Warnings:
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'b' at row 1
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'b' at row 2
|
||||
INSERT INTO t1 (c) values (null);
|
||||
Column 'c' cannot be null
|
||||
ERROR 23000: Column 'c' cannot be null
|
||||
INSERT INTO t1 (c) values (1/null);
|
||||
Column 'c' cannot be null
|
||||
ERROR 23000: Column 'c' cannot be null
|
||||
INSERT INTO t1 (c) values (null),(null);
|
||||
Warnings:
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'c' at row 1
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'c' at row 2
|
||||
INSERT INTO t1 (d) values (null);
|
||||
Column 'd' cannot be null
|
||||
ERROR 23000: Column 'd' cannot be null
|
||||
INSERT INTO t1 (d) values (1/null);
|
||||
Column 'd' cannot be null
|
||||
ERROR 23000: Column 'd' cannot be null
|
||||
INSERT INTO t1 (d) values (null),(null);
|
||||
Warnings:
|
||||
Warning 1261 Data truncated, NULL supplied to NOT NULL column 'd' at row 1
|
||||
|
|
|
@ -1,27 +1,256 @@
|
|||
drop table if exists t1;
|
||||
create table t1 ( product varchar(32), country varchar(32), year int, profit int);
|
||||
insert into t1 values ( 'Computer', 'India',2000, 1200),
|
||||
( 'TV', 'United States', 1999, 150),
|
||||
( 'Calculator', 'United States', 1999,50),
|
||||
( 'Computer', 'United States', 1999,1500),
|
||||
( 'Computer', 'United States', 2000,1500),
|
||||
( 'TV', 'United States', 2000, 150),
|
||||
( 'TV', 'India', 2000, 100),
|
||||
( 'TV', 'India', 2000, 100),
|
||||
( 'Calculator', 'United States', 2000,75),
|
||||
( 'Calculator', 'India', 2000,75),
|
||||
( 'TV', 'India', 1999, 100),
|
||||
( 'Computer', 'India', 1999,1200),
|
||||
( 'Computer', 'United States', 2000,1500),
|
||||
( 'Calculator', 'United States', 2000,75);
|
||||
select product, country , year, sum(profit) from t1 group by product, country, year with cube;
|
||||
This version of MySQL doesn't yet support 'CUBE'
|
||||
explain select product, country , year, sum(profit) from t1 group by product, country, year with cube;
|
||||
This version of MySQL doesn't yet support 'CUBE'
|
||||
select product, country , year, sum(profit) from t1 group by product, country, year with rollup;
|
||||
This version of MySQL doesn't yet support 'ROLLUP'
|
||||
explain select product, country , year, sum(profit) from t1 group by product, country, year with rollup;
|
||||
This version of MySQL doesn't yet support 'ROLLUP'
|
||||
select product, country , year, sum(profit) from t1 group by product, country, year with cube union all select product, country , year, sum(profit) from t1 group by product, country, year with rollup;
|
||||
This version of MySQL doesn't yet support 'CUBE'
|
||||
drop table t1;
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (product varchar(32), country_id int not null, year int, profit int);
|
||||
insert into t1 values ( 'Computer', 2,2000, 1200),
|
||||
( 'TV', 1, 1999, 150),
|
||||
( 'Calculator', 1, 1999,50),
|
||||
( 'Computer', 1, 1999,1500),
|
||||
( 'Computer', 1, 2000,1500),
|
||||
( 'TV', 1, 2000, 150),
|
||||
( 'TV', 2, 2000, 100),
|
||||
( 'TV', 2, 2000, 100),
|
||||
( 'Calculator', 1, 2000,75),
|
||||
( 'Calculator', 2, 2000,75),
|
||||
( 'TV', 1, 1999, 100),
|
||||
( 'Computer', 1, 1999,1200),
|
||||
( 'Computer', 2, 2000,1500),
|
||||
( 'Calculator', 2, 2000,75),
|
||||
( 'Phone', 3, 2003,10)
|
||||
;
|
||||
create table t2 (country_id int primary key, country char(20) not null);
|
||||
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
|
||||
select product, sum(profit) from t1 group by product;
|
||||
product sum(profit)
|
||||
Calculator 275
|
||||
Computer 6900
|
||||
Phone 10
|
||||
TV 600
|
||||
select product, sum(profit) from t1 group by product with rollup;
|
||||
product sum(profit)
|
||||
Calculator 275
|
||||
Computer 6900
|
||||
Phone 10
|
||||
TV 600
|
||||
NULL 7785
|
||||
select product, sum(profit) from t1 group by 1 with rollup;
|
||||
product sum(profit)
|
||||
Calculator 275
|
||||
Computer 6900
|
||||
Phone 10
|
||||
TV 600
|
||||
NULL 7785
|
||||
select product, sum(profit),avg(profit) from t1 group by product with rollup;
|
||||
product sum(profit) avg(profit)
|
||||
Calculator 275 68.7500
|
||||
Computer 6900 1380.0000
|
||||
Phone 10 10.0000
|
||||
TV 600 120.0000
|
||||
NULL 7785 519.0000
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year;
|
||||
product country_id year sum(profit)
|
||||
Calculator 1 1999 50
|
||||
Calculator 1 2000 75
|
||||
Calculator 2 2000 150
|
||||
Computer 1 1999 2700
|
||||
Computer 1 2000 1500
|
||||
Computer 2 2000 2700
|
||||
Phone 3 2003 10
|
||||
TV 1 1999 250
|
||||
TV 1 2000 150
|
||||
TV 2 2000 200
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
|
||||
product country_id year sum(profit)
|
||||
Calculator 1 1999 50
|
||||
Calculator 1 2000 75
|
||||
Calculator 1 NULL 125
|
||||
Calculator 2 2000 150
|
||||
Calculator 2 NULL 150
|
||||
Calculator NULL NULL 275
|
||||
Computer 1 1999 2700
|
||||
Computer 1 2000 1500
|
||||
Computer 1 NULL 4200
|
||||
Computer 2 2000 2700
|
||||
Computer 2 NULL 2700
|
||||
Computer NULL NULL 6900
|
||||
Phone 3 2003 10
|
||||
Phone 3 NULL 10
|
||||
Phone NULL NULL 10
|
||||
TV 1 1999 250
|
||||
TV 1 2000 150
|
||||
TV 1 NULL 400
|
||||
TV 2 2000 200
|
||||
TV 2 NULL 200
|
||||
TV NULL NULL 600
|
||||
NULL NULL NULL 7785
|
||||
explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using temporary; Using filesort
|
||||
select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup;
|
||||
product country_id sum(profit)
|
||||
TV 1 400
|
||||
TV 2 200
|
||||
TV NULL 600
|
||||
Phone 3 10
|
||||
Phone NULL 10
|
||||
Computer 1 4200
|
||||
Computer 2 2700
|
||||
Computer NULL 6900
|
||||
Calculator 1 125
|
||||
Calculator 2 150
|
||||
Calculator NULL 275
|
||||
NULL NULL 7785
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 5;
|
||||
product country_id year sum(profit)
|
||||
Calculator 1 1999 50
|
||||
Calculator 1 2000 75
|
||||
Calculator 1 NULL 125
|
||||
Calculator 2 2000 150
|
||||
Calculator 2 NULL 150
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 3,3;
|
||||
product country_id year sum(profit)
|
||||
Calculator 2 2000 150
|
||||
Calculator 2 NULL 150
|
||||
Calculator NULL NULL 275
|
||||
select product, country_id, count(*), count(distinct year) from t1 group by product, country_id;
|
||||
product country_id count(*) count(distinct year)
|
||||
Calculator 1 2 2
|
||||
Calculator 2 2 1
|
||||
Computer 1 3 2
|
||||
Computer 2 2 1
|
||||
Phone 3 1 1
|
||||
TV 1 3 2
|
||||
TV 2 2 1
|
||||
select product, country_id, count(*), count(distinct year) from t1 group by product, country_id with rollup;
|
||||
product country_id count(*) count(distinct year)
|
||||
Calculator 1 2 2
|
||||
Calculator 2 2 1
|
||||
Calculator NULL 4 2
|
||||
Computer 1 3 2
|
||||
Computer 2 2 1
|
||||
Computer NULL 5 2
|
||||
Phone 3 1 1
|
||||
Phone NULL 1 1
|
||||
TV 1 3 2
|
||||
TV 2 2 1
|
||||
TV NULL 5 2
|
||||
NULL NULL 15 3
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having country_id = 1;
|
||||
product country_id year sum(profit)
|
||||
Calculator 1 1999 50
|
||||
Calculator 1 2000 75
|
||||
Calculator 1 NULL 125
|
||||
Computer 1 1999 2700
|
||||
Computer 1 2000 1500
|
||||
Computer 1 NULL 4200
|
||||
TV 1 1999 250
|
||||
TV 1 2000 150
|
||||
TV 1 NULL 400
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 200;
|
||||
product country_id year sum(profit)
|
||||
Calculator NULL NULL 275
|
||||
Computer 1 1999 2700
|
||||
Computer 1 2000 1500
|
||||
Computer 1 NULL 4200
|
||||
Computer 2 2000 2700
|
||||
Computer 2 NULL 2700
|
||||
Computer NULL NULL 6900
|
||||
TV 1 1999 250
|
||||
TV 1 NULL 400
|
||||
TV NULL NULL 600
|
||||
NULL NULL NULL 7785
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 7000;
|
||||
product country_id year sum(profit)
|
||||
NULL NULL NULL 7785
|
||||
select concat(product,':',country_id) as 'prod', concat(":",year,":") as 'year',1+1, sum(profit)/count(*) from t1 group by 1,2 with rollup;
|
||||
prod year 1+1 sum(profit)/count(*)
|
||||
Calculator:1 :1999: 2 50.00
|
||||
Calculator:1 :2000: 2 75.00
|
||||
Calculator:1 NULL 2 62.50
|
||||
Calculator:2 :2000: 2 75.00
|
||||
Calculator:2 NULL 2 75.00
|
||||
Computer:1 :1999: 2 1350.00
|
||||
Computer:1 :2000: 2 1500.00
|
||||
Computer:1 NULL 2 1400.00
|
||||
Computer:2 :2000: 2 1350.00
|
||||
Computer:2 NULL 2 1350.00
|
||||
Phone:3 :2003: 2 10.00
|
||||
Phone:3 NULL 2 10.00
|
||||
TV:1 :1999: 2 125.00
|
||||
TV:1 :2000: 2 150.00
|
||||
TV:1 NULL 2 133.33
|
||||
TV:2 :2000: 2 100.00
|
||||
TV:2 NULL 2 100.00
|
||||
NULL NULL 2 519.00
|
||||
select product, sum(profit)/count(*) from t1 group by product with rollup;
|
||||
product sum(profit)/count(*)
|
||||
Calculator 68.75
|
||||
Computer 1380.00
|
||||
Phone 10.00
|
||||
TV 120.00
|
||||
NULL 519.00
|
||||
select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
|
||||
prod sum(profit)/count(*)
|
||||
Calc 68.75
|
||||
Comp 1380.00
|
||||
Phon 10.00
|
||||
TV 120.00
|
||||
NULL 519.00
|
||||
select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup;
|
||||
concat(product,':',country_id) 1+1 sum(profit)/count(*)
|
||||
Calculator:1 2 62.50
|
||||
Calculator:2 2 75.00
|
||||
Computer:1 2 1400.00
|
||||
Computer:2 2 1350.00
|
||||
Phone:3 2 10.00
|
||||
TV:1 2 133.33
|
||||
TV:2 2 100.00
|
||||
NULL 2 519.00
|
||||
select product, country , year, sum(profit) from t1,t2 where t1.country_id=t2.country_id group by product, country, year with rollup;
|
||||
product country year sum(profit)
|
||||
Calculator India 2000 150
|
||||
Calculator India NULL 150
|
||||
Calculator USA 1999 50
|
||||
Calculator USA 2000 75
|
||||
Calculator USA NULL 125
|
||||
Calculator NULL NULL 275
|
||||
Computer India 2000 2700
|
||||
Computer India NULL 2700
|
||||
Computer USA 1999 2700
|
||||
Computer USA 2000 1500
|
||||
Computer USA NULL 4200
|
||||
Computer NULL NULL 6900
|
||||
Phone Finland 2003 10
|
||||
Phone Finland NULL 10
|
||||
Phone NULL NULL 10
|
||||
TV India 2000 200
|
||||
TV India NULL 200
|
||||
TV USA 1999 250
|
||||
TV USA 2000 150
|
||||
TV USA NULL 400
|
||||
TV NULL NULL 600
|
||||
NULL NULL NULL 7785
|
||||
select product, `sum` from (select product, sum(profit) as 'sum' from t1 group by product with rollup) as tmp where product is null;
|
||||
product sum
|
||||
NULL 7785
|
||||
select product from t1 where exists (select product, country_id , sum(profit) from t1 as t2 where t1.product=t2.product group by product, country_id with rollup having sum(profit) > 6000);
|
||||
product
|
||||
Computer
|
||||
Computer
|
||||
Computer
|
||||
Computer
|
||||
Computer
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year having country_id is NULL;
|
||||
product country_id year sum(profit)
|
||||
select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup;
|
||||
concat(':',product,':') sum(profit) avg(profit)
|
||||
:Calculator: 275 68.7500
|
||||
:Computer: 6900 1380.0000
|
||||
:Phone: 10 10.0000
|
||||
:TV: 600 120.0000
|
||||
:TV: 7785 519.0000
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
|
||||
explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -466,25 +466,25 @@ gid sid uid
|
|||
EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index
|
||||
1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
|
||||
1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 test.t1.gid 1
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 Using where; Using index
|
||||
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t1.gid 1 Using where
|
||||
EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
|
||||
1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
|
||||
1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 test.t1.gid 1
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 Using where; Using index
|
||||
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t1.gid 1 Using where
|
||||
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t1.skr 1 Using where
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
`titre` char(80) NOT NULL default '',
|
||||
|
|
|
@ -12,7 +12,7 @@ select @@net_buffer_length, @@max_allowed_packet;
|
|||
@@net_buffer_length @@max_allowed_packet
|
||||
1024 80
|
||||
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
|
||||
Got a packet bigger than 'max_allowed_packet'
|
||||
ERROR 08S01: Got a packet bigger than 'max_allowed_packet'
|
||||
set global max_allowed_packet=default;
|
||||
set max_allowed_packet=default;
|
||||
set global net_buffer_length=default;
|
||||
|
|
|
@ -561,22 +561,62 @@ 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);
|
||||
set GLOBAL query_cache_size=1000;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
set GLOBAL query_cache_size=1100;
|
||||
set GLOBAL query_cache_size=1200;
|
||||
set GLOBAL query_cache_size=1300;
|
||||
set GLOBAL query_cache_size=1400;
|
||||
set GLOBAL query_cache_size=1500;
|
||||
set GLOBAL query_cache_size=1600;
|
||||
set GLOBAL query_cache_size=1700;
|
||||
set GLOBAL query_cache_size=1800;
|
||||
set GLOBAL query_cache_size=1900;
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=1024;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 1024
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=10240;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=20480;
|
||||
show global variables like "query_cache_size";
|
||||
Variable_name Value
|
||||
query_cache_size 0
|
||||
select * from t1;
|
||||
a
|
||||
set GLOBAL query_cache_size=40960;
|
||||
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);
|
||||
|
@ -615,10 +655,10 @@ id
|
|||
2
|
||||
alter table t1 rename to t2;
|
||||
select * from t1 where id=2;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
drop table t2;
|
||||
select * from t1 where id=2;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t1 (word char(20) not null);
|
||||
select * from t1;
|
||||
word
|
||||
|
|
|
@ -36,7 +36,7 @@ select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)));
|
|||
(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)))
|
||||
1
|
||||
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
|
||||
Cardinality error (more/less than 2 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 2 columns)
|
||||
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
|
||||
row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))
|
||||
NULL
|
||||
|
@ -86,7 +86,7 @@ SELECT ROW('test',2,3.33)=ROW('test',2,3.33);
|
|||
ROW('test',2,3.33)=ROW('test',2,3.33)
|
||||
1
|
||||
SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4);
|
||||
Cardinality error (more/less than 3 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 3 columns)
|
||||
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33));
|
||||
ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33))
|
||||
1
|
||||
|
@ -97,7 +97,7 @@ SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL));
|
|||
ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL))
|
||||
NULL
|
||||
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4);
|
||||
Cardinality error (more/less than 2 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 2 columns)
|
||||
create table t1 ( a int, b int, c int);
|
||||
insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL);
|
||||
select * from t1 where ROW(1,2,3)=ROW(a,b,c);
|
||||
|
@ -135,14 +135,14 @@ ROW(1,2,3) IN(row(a,b,c), row(1,2,3))
|
|||
1
|
||||
drop table t1;
|
||||
select ROW(1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
create table t1 (i int);
|
||||
select 1 from t1 where ROW(1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
select count(*) from t1 order by ROW(1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
select count(*) from t1 having (1,1) order by i;
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
drop table t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1, 4);
|
||||
|
|
|
@ -55,7 +55,7 @@ select (@id := id) - id from t2;
|
|||
0
|
||||
kill @id;
|
||||
drop table t2;
|
||||
Server shutdown in progress
|
||||
ERROR 08S01: Server shutdown in progress
|
||||
set global sql_slave_skip_counter=1;
|
||||
start slave;
|
||||
select count(*) from t1;
|
||||
|
|
|
@ -21,7 +21,7 @@ n m
|
|||
drop database mysqltest;
|
||||
drop database if exists mysqltest2;
|
||||
drop database mysqltest;
|
||||
Can't drop database 'mysqltest'. Database doesn't exist
|
||||
ERROR HY000: Can't drop database 'mysqltest'. Database doesn't exist
|
||||
drop database mysqltest2;
|
||||
set sql_log_bin = 0;
|
||||
create database mysqltest2;
|
||||
|
|
|
@ -7,6 +7,6 @@ start slave;
|
|||
show slave status;
|
||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||
load table t1 from master;
|
||||
Error connecting to master: Master is not configured
|
||||
ERROR 08S01: Error connecting to master: Master is not configured
|
||||
load table t1 from master;
|
||||
Error from master: 'Table 'test.t1' doesn't exist'
|
||||
ERROR HY000: Error from master: 'Table 'test.t1' doesn't exist'
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue