Added SQLSTATE to client/server protocol
bmove_allign -> bmove_align Added OLAP function ROLLUP Split mysql_fix_privilege_tables to a script and a .sql data file Added new (MEMROOT*) functions to avoid calling current_thd() when creating some common objects. Added table_alias_charset, for easier --lower-case-table-name handling Better SQL_MODE handling (Setting complex options also sets sub options) New (faster) assembler string functions for x86
This commit is contained in:
parent
7df5635ff2
commit
23145cfed7
@ -617,3 +617,5 @@ vio/test-sslclient
|
||||
vio/test-sslserver
|
||||
vio/viotest-ssl
|
||||
include/readline/*.h
|
||||
strings/str_test
|
||||
libmysqld/sql_state.c
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -1653,9 +1654,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
|
||||
{
|
||||
@ -1717,7 +1716,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);
|
||||
@ -2431,12 +2430,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));
|
||||
@ -2557,7 +2556,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
|
||||
}
|
||||
@ -2707,7 +2706,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;
|
||||
@ -2752,7 +2751,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);
|
||||
}
|
||||
@ -2767,6 +2771,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;
|
||||
@ -3085,4 +3097,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>
|
||||
@ -2147,6 +2147,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);
|
||||
|
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;
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
||||
|
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", "",
|
@ -64,7 +64,8 @@ ulong net_buffer_length=8192;
|
||||
ulong max_allowed_packet= 1024L*1024L*1024L;
|
||||
ulong net_read_timeout= NET_READ_TIMEOUT;
|
||||
ulong net_write_timeout= NET_WRITE_TIMEOUT;
|
||||
const char *unknown_sqlstate= "000000";
|
||||
const char *unknown_sqlstate= "HY000";
|
||||
const char *not_error_sqlstate= "00000";
|
||||
|
||||
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \
|
||||
| CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \
|
||||
@ -91,9 +92,9 @@ 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
|
||||
@ -141,16 +142,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
|
||||
}
|
||||
|
||||
@ -160,7 +161,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
|
||||
@ -409,13 +410,14 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
|
||||
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:
|
||||
/*
|
||||
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)))
|
||||
@ -441,36 +443,34 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
|
||||
error_allow = CR_SHARED_MEMORY_CONNECT_MAP_ERROR;
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
Send to server request of connection
|
||||
*/
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
/* 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
|
||||
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);
|
||||
@ -579,7 +579,7 @@ net_safe_read(MYSQL *mysql)
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
ulong len=0;
|
||||
init_sigpipe_variables
|
||||
init_sigpipe_variables;
|
||||
|
||||
/* Don't give sigpipe errors if the client doesn't want them */
|
||||
set_sigpipe(mysql);
|
||||
@ -645,7 +645,7 @@ advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
my_bool result= 1;
|
||||
init_sigpipe_variables
|
||||
init_sigpipe_variables;
|
||||
|
||||
/* Don't give sigpipe errors if the client doesn't want them */
|
||||
set_sigpipe(mysql);
|
||||
@ -663,8 +663,8 @@ advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
}
|
||||
|
||||
net->last_error[0]=0;
|
||||
net->last_errno=0;
|
||||
strmov(net->sqlstate, unknown_sqlstate);
|
||||
net->last_errno= 0;
|
||||
strmov(net->sqlstate, not_error_sqlstate);
|
||||
mysql->info=0;
|
||||
mysql->affected_rows= ~(my_ulonglong) 0;
|
||||
net_clear(&mysql->net); /* Clear receive buffer */
|
||||
@ -695,7 +695,7 @@ advanced_command(MYSQL *mysql, enum enum_server_command command,
|
||||
if (!skip_check)
|
||||
result= ((mysql->packet_length=net_safe_read(mysql)) == packet_error ?
|
||||
1 : 0);
|
||||
end:
|
||||
end:
|
||||
reset_sigpipe(mysql);
|
||||
return result;
|
||||
}
|
||||
@ -870,7 +870,7 @@ end_server(MYSQL *mysql)
|
||||
DBUG_ENTER("end_server");
|
||||
if (mysql->net.vio != 0)
|
||||
{
|
||||
init_sigpipe_variables
|
||||
init_sigpipe_variables;
|
||||
DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
|
||||
set_sigpipe(mysql);
|
||||
vio_delete(mysql->net.vio);
|
||||
@ -1402,7 +1402,7 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
|
||||
|
||||
/* 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))
|
||||
@ -1449,7 +1449,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));
|
||||
}
|
||||
@ -1586,7 +1586,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 */
|
||||
@ -1596,7 +1596,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);
|
||||
}
|
||||
|
||||
@ -1966,7 +1966,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
struct sockaddr_un UNIXaddr;
|
||||
#endif
|
||||
init_sigpipe_variables
|
||||
init_sigpipe_variables;
|
||||
DBUG_ENTER("mysql_real_connect");
|
||||
LINT_INIT(host_info);
|
||||
|
||||
@ -2529,7 +2529,7 @@ static my_bool mysql_reconnect(MYSQL *mysql)
|
||||
if (!mysql->reconnect ||
|
||||
(mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
|
||||
{
|
||||
/* Allow reconnect next time */
|
||||
/* Allow reconnect next time */
|
||||
mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
|
||||
strmov(mysql->net.sqlstate, unknown_sqlstate);
|
||||
mysql->net.last_errno=CR_SERVER_GONE_ERROR;
|
||||
@ -2575,7 +2575,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;
|
||||
|
||||
/*
|
||||
@ -2592,15 +2592,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));
|
||||
}
|
||||
@ -2793,9 +2793,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)))
|
||||
@ -3670,7 +3670,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;
|
||||
}
|
||||
@ -4045,13 +4045,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);
|
||||
@ -4781,7 +4783,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:
|
||||
@ -4797,33 +4799,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[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;
|
||||
|
||||
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;
|
||||
@ -4969,7 +4972,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",
|
||||
@ -4978,7 +4981,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;
|
||||
@ -4990,8 +4993,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)
|
||||
{
|
||||
@ -5001,8 +5004,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;
|
||||
@ -5011,8 +5014,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;
|
||||
@ -5020,8 +5023,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;
|
||||
@ -5316,8 +5319,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++)
|
||||
{
|
||||
@ -5509,7 +5512,7 @@ no_data:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
Read all rows of data from server (binary format)
|
||||
*/
|
||||
|
||||
@ -5578,6 +5581,7 @@ static MYSQL_DATA *read_binary_rows(MYSQL_STMT *stmt)
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Store or buffer the binary results to stmt
|
||||
*/
|
||||
@ -5599,9 +5603,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);
|
||||
@ -5620,6 +5624,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
|
||||
*/
|
||||
@ -5642,6 +5647,7 @@ mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET row)
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Return the current statement row cursor position
|
||||
*/
|
||||
@ -5842,16 +5848,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
|
||||
*/
|
||||
@ -5862,7 +5868,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)
|
||||
|
@ -44,7 +44,8 @@ sqlsources = derror.cc field.cc field_conv.cc filesort.cc \
|
||||
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
|
||||
item_uniq.cc item_subselect.cc item_row.cc\
|
||||
key.cc lock.cc log.cc log_event.cc mf_iocache.cc\
|
||||
mini_client.cc protocol.cc net_serv.cc opt_ft.cc opt_range.cc \
|
||||
mini_client.cc protocol.cc net_serv.cc sql_state.c \
|
||||
opt_ft.cc opt_range.cc \
|
||||
opt_sum.cc procedure.cc records.cc sql_acl.cc \
|
||||
repl_failsafe.cc slave.cc sql_load.cc sql_olap.cc \
|
||||
sql_analyse.cc sql_base.cc sql_cache.cc sql_class.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;
|
||||
|
@ -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 Collation Null Key Default Extra
|
||||
a int(11) NULL 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 +1,25 @@
|
||||
drop table if exists t1;
|
||||
insert into t1 values(1);
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
delete from t1;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
update t1 set a=1;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: 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'
|
||||
ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
|
||||
select count(not_existing_database.t1) from t1;
|
||||
Unknown table 'not_existing_database' in field list
|
||||
ERROR 42S02: 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
|
||||
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;
|
||||
Unknown column '2' in 'order clause'
|
||||
ERROR 42S22: Unknown column '2' in 'order clause'
|
||||
select 1 from t1 group by 2;
|
||||
Unknown column '2' in 'group statement'
|
||||
ERROR 42S22: Unknown column '2' in 'group statement'
|
||||
select 1 from t1 order by t1.b;
|
||||
Unknown column 't1.b' in 'order clause'
|
||||
ERROR 42S22: Unknown column 't1.b' in 'order clause'
|
||||
select count(*),b from t1;
|
||||
Unknown column 'b' in 'field list'
|
||||
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,
|
||||
|
@ -155,7 +155,7 @@ show warnings;
|
||||
Level Code Message
|
||||
Warning 1258 1 line(s) was(were) cut by group_concat()
|
||||
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 if exists t1;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -615,10 +615,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'
|
||||
|
@ -89,4 +89,4 @@ show slave status;
|
||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||
127.0.0.1 root MASTER_PORT 1 master-bin.000002 170 slave-relay-bin.000002 1469 master-bin.000002 Yes Yes 0 0 170 1473
|
||||
show binlog events in 'slave-bin.000005' from 4;
|
||||
Error when executing command SHOW BINLOG EVENTS: Could not find target log
|
||||
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
|
||||
|
@ -24,5 +24,5 @@ select * from t2;
|
||||
n
|
||||
4
|
||||
select * from t11;
|
||||
Table 'test.t11' doesn't exist
|
||||
ERROR 42S02: Table 'test.t11' doesn't exist
|
||||
drop table if exists t1,t2,t11;
|
||||
|
@ -1,9 +1,9 @@
|
||||
drop table if exists t1, t2, t3, t4;
|
||||
drop table if exists t1, t2, t3, t4;
|
||||
start slave;
|
||||
Could not initialize master info structure, check permisions on master.info
|
||||
ERROR HY000: Could not initialize master info structure, check permisions on master.info
|
||||
start slave;
|
||||
Could not initialize master info structure, check permisions on master.info
|
||||
ERROR HY000: Could not initialize master info structure, check permisions on master.info
|
||||
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
|
||||
Could not initialize master info
|
||||
reset slave;
|
||||
|
@ -1341,9 +1341,9 @@ explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
|
||||
explain select fld3 from t2 ignore index (fld3,not_used);
|
||||
Key column 'not_used' doesn't exist in table
|
||||
ERROR 42000: Key column 'not_used' doesn't exist in table
|
||||
explain select fld3 from t2 use index (not_used);
|
||||
Key column 'not_used' doesn't exist in table
|
||||
ERROR 42000: Key column 'not_used' doesn't exist in table
|
||||
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
|
||||
fld3
|
||||
honeysuckle
|
||||
@ -1807,19 +1807,19 @@ fld3
|
||||
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 Using where; Using index
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
|
||||
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
|
||||
1 SIMPLE t3 ref period period 4 t1.period 4181
|
||||
1 SIMPLE t3 ref period period 4 test.t1.period 4181
|
||||
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index period period 4 NULL 41810
|
||||
1 SIMPLE t1 ref period period 4 t3.period 4181
|
||||
1 SIMPLE t1 ref period period 4 test.t3.period 4181
|
||||
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index period period 4 NULL 41810
|
||||
1 SIMPLE t3 ref period period 4 t1.period 4181
|
||||
1 SIMPLE t3 ref period period 4 test.t1.period 4181
|
||||
select period from t1;
|
||||
period
|
||||
9410
|
||||
|
@ -20,17 +20,17 @@ select 1 from t1,t1 as t2,t1 as t3,t1 as t4;
|
||||
1
|
||||
1
|
||||
update t1 set b="a";
|
||||
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
|
||||
update t1 set b="a" where b="test";
|
||||
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
|
||||
delete from t1;
|
||||
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
|
||||
delete from t1 where b="test";
|
||||
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
|
||||
delete from t1 where a+0=1;
|
||||
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
|
||||
select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
|
||||
The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
ERROR 42000: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
update t1 set b="a" limit 1;
|
||||
update t1 set b="a" where b="b" limit 2;
|
||||
delete from t1 where b="test" limit 1;
|
||||
@ -41,7 +41,7 @@ SELECT @@MAX_JOIN_SIZE, @@SQL_BIG_SELECTS;
|
||||
2 0
|
||||
insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a");
|
||||
SELECT * from t1;
|
||||
The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
ERROR 42000: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
SET SQL_BIG_SELECTS=1;
|
||||
SELECT * from t1;
|
||||
a b
|
||||
@ -51,7 +51,7 @@ a b
|
||||
5 a
|
||||
SET MAX_JOIN_SIZE=2;
|
||||
SELECT * from t1;
|
||||
The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
ERROR 42000: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
SET MAX_JOIN_SIZE=DEFAULT;
|
||||
SELECT * from t1;
|
||||
a b
|
||||
|
@ -26,7 +26,7 @@ t1 0 PRIMARY 1 a A 5 NULL NULL BTREE
|
||||
t1 1 b 1 b A 1 NULL NULL BTREE
|
||||
t1 1 b 2 c A 5 NULL NULL BTREE
|
||||
insert into t1 values (5,5,5);
|
||||
Duplicate entry '5' for key 1
|
||||
ERROR 23000: Duplicate entry '5' for key 1
|
||||
optimize table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
|
@ -71,10 +71,10 @@ t1 CREATE TABLE `t1` (
|
||||
PRIMARY KEY (`a`),
|
||||
UNIQUE KEY `email` (`email`)
|
||||
) TYPE=HEAP ROW_FORMAT=DYNAMIC
|
||||
set @@sql_mode="postgresql,oracle,mssql,db2,sapdb";
|
||||
show variables like 'sql_mode';
|
||||
Variable_name Value
|
||||
sql_mode POSTGRESQL,ORACLE,MSSQL,DB2,SAPDB
|
||||
set sql_mode="postgresql,oracle,mssql,db2,sapdb";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,POSTGRESQL,ORACLE,MSSQL,DB2,SAPDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE "t1" (
|
||||
|
@ -29,14 +29,14 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
Warnings:
|
||||
Note 1247 Select 2 was reduced during optimisation
|
||||
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
|
||||
Reference 'a' not supported (forward reference in item list)
|
||||
ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
||||
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
|
||||
Reference 'b' not supported (forward reference in item list)
|
||||
ERROR 42S22: Reference 'b' not supported (forward reference in item list)
|
||||
SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
|
||||
(SELECT 1) MAX(1)
|
||||
1 1
|
||||
SELECT (SELECT a) as a;
|
||||
Reference 'a' not supported (forward reference in item list)
|
||||
ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
||||
EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
@ -46,17 +46,17 @@ SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
1
|
||||
1
|
||||
SELECT (SELECT 1), a;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
|
||||
a
|
||||
1
|
||||
SELECT 1 FROM (SELECT (SELECT a) b) c;
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id);
|
||||
id
|
||||
1
|
||||
SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
SELECT 1 IN (SELECT 1);
|
||||
1 IN (SELECT 1)
|
||||
1
|
||||
@ -64,9 +64,9 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
|
||||
1
|
||||
1
|
||||
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
|
||||
Wrong usage of PROCEDURE and subquery
|
||||
ERROR HY000: Wrong usage of PROCEDURE and subquery
|
||||
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
|
||||
Incorrect parameters to procedure 'ANALYSE'
|
||||
ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
|
||||
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
|
||||
a
|
||||
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
|
||||
@ -121,19 +121,19 @@ SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
|
||||
(SELECT 1.5,'c','a') = ROW(1.5,2,'a')
|
||||
0
|
||||
SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
SELECT 1 as a,(SELECT a+a) b,(SELECT b);
|
||||
a b (SELECT b)
|
||||
1 2 2
|
||||
create table t1 (a int);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (a int);
|
||||
create table t4 (a int, b int);
|
||||
create table t4 (a int not null, b int not null);
|
||||
insert into t1 values (2);
|
||||
insert into t2 values (1,7),(2,7);
|
||||
insert into t4 values (4,8),(3,8),(5,9);
|
||||
select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
|
||||
Reference 'a1' not supported (forward reference in item list)
|
||||
ERROR 42S22: Reference 'a1' not supported (forward reference in item list)
|
||||
select (select a from t1 where t1.a=t2.a), a from t2;
|
||||
(select a from t1 where t1.a=t2.a) a
|
||||
NULL 1
|
||||
@ -252,15 +252,18 @@ a
|
||||
7
|
||||
delete from t2 where a=100;
|
||||
select * from t3 where a in (select a,b from t2);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
select * from t3 where a in (select * from t2);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9);
|
||||
select b,max(a) as ma from t4 group by b having b < (select max(t2.a)
|
||||
from t2 where t2.b=t4.b);
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10);
|
||||
select b,max(a) as ma from t4 group by b having b < (select max(t2.a) from t2 where t2.b=t4.b);
|
||||
b ma
|
||||
select b,max(a) as ma from t4 group by b having b >= (select max(t2.a)
|
||||
from t2 where t2.b=t4.b);
|
||||
insert into t2 values (2,10);
|
||||
select b,max(a) as ma from t4 group by b having ma < (select max(t2.a) from t2 where t2.b=t4.b);
|
||||
b ma
|
||||
10 1
|
||||
delete from t2 where a=2 and b=10;
|
||||
select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 where t2.b=t4.b);
|
||||
b ma
|
||||
7 12
|
||||
create table t5 (a int);
|
||||
@ -284,7 +287,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1
|
||||
3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where
|
||||
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
|
||||
create table t7( uq int primary key, name char(25));
|
||||
insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
|
||||
@ -297,9 +300,9 @@ patient_uq clinic_uq
|
||||
explain select * from t6 where exists (select * from t7 where uq = clinic_uq);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1
|
||||
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1
|
||||
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
|
||||
Column: 'a' in field list is ambiguous
|
||||
ERROR 23000: Column: 'a' in field list is ambiguous
|
||||
drop table if exists t1,t2,t3;
|
||||
CREATE TABLE t3 (a varchar(20),b char(1) NOT NULL default '0');
|
||||
INSERT INTO t3 VALUES ('W','a'),('A','c'),('J','b');
|
||||
@ -333,15 +336,15 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 35 1
|
||||
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
|
||||
t8 WHERE pseudo='joce');
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
|
||||
pseudo='joce');
|
||||
Cardinality error (more/less than 1 columns)
|
||||
ERROR 21000: Cardinality error (more/less than 1 columns)
|
||||
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
|
||||
pseudo
|
||||
joce
|
||||
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
|
||||
CREATE TABLE `t1` (
|
||||
`topic` mediumint(8) unsigned NOT NULL default '0',
|
||||
@ -371,7 +374,7 @@ SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
|
||||
1
|
||||
1
|
||||
SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL topic 3 NULL 2 Using index
|
||||
@ -401,9 +404,9 @@ numeropost maxnumrep
|
||||
43506 2
|
||||
40143 1
|
||||
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
|
||||
Unknown column 'a' in 'having clause'
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
|
||||
Unknown column 'a' in 'having clause'
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic);
|
||||
mot topic date pseudo
|
||||
joce 40143 2002-10-22 joce
|
||||
@ -458,9 +461,9 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`)
|
||||
) TYPE=MyISAM ROW_FORMAT=FIXED;
|
||||
INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
|
||||
select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
@ -473,7 +476,7 @@ drop table t1;
|
||||
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
|
||||
INSERT INTO t1 VALUES ();
|
||||
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL default '0',
|
||||
@ -484,14 +487,14 @@ UNIQUE KEY `numreponse` (`numreponse`),
|
||||
KEY `pseudo` (`pseudo`,`numeropost`)
|
||||
) TYPE=MyISAM;
|
||||
SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a;
|
||||
Reference 'numreponse' not supported (forward reference in item list)
|
||||
ERROR 42S22: Reference 'numreponse' not supported (forward reference in item list)
|
||||
SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a;
|
||||
Unknown column 'a' in 'having clause'
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a;
|
||||
numreponse (SELECT numeropost FROM t1 HAVING numreponse=1)
|
||||
INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
|
||||
EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
@ -516,9 +519,9 @@ a b
|
||||
1 11
|
||||
2 12
|
||||
update t1 set b= (select b from t1);
|
||||
You can't specify target table 't1' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
update t1 set b= (select b from t2);
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
update t1 set b= (select b from t2 where t1.a = t2.a);
|
||||
select * from t1;
|
||||
a b
|
||||
@ -539,9 +542,9 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
|
||||
a b
|
||||
2 12
|
||||
delete from t1 where b = (select b from t1);
|
||||
You can't specify target table 't1' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
delete from t1 where b = (select b from t2);
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
delete from t1 where b = (select b from t2 where t1.a = t2.a);
|
||||
select * from t1;
|
||||
a b
|
||||
@ -565,9 +568,9 @@ a b
|
||||
22 11
|
||||
2 12
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
|
||||
You can't specify target table 't12' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't12' for update in FROM clause
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
|
||||
select * from t11;
|
||||
a b
|
||||
@ -584,9 +587,9 @@ create table t3 (a int);
|
||||
insert into t2 values (1);
|
||||
insert into t3 values (1),(2);
|
||||
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
|
||||
You can't specify target table 't1' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
INSERT INTO t1 (x) VALUES ((SELECT a FROM t3));
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
|
||||
select * from t1;
|
||||
x
|
||||
@ -605,7 +608,7 @@ x
|
||||
3
|
||||
3
|
||||
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
|
||||
You can't specify target table 't1' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
|
||||
select * from t1;
|
||||
x
|
||||
@ -623,9 +626,9 @@ insert into t3 values (1),(2);
|
||||
select * from t1;
|
||||
x y
|
||||
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
|
||||
You can't specify target table 't1' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
|
||||
select * from t1;
|
||||
x y
|
||||
@ -652,7 +655,7 @@ x y
|
||||
2 1
|
||||
drop table t1, t2, t3;
|
||||
SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *);
|
||||
No tables used
|
||||
ERROR HY000: No tables used
|
||||
CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
SELECT * FROM t2 WHERE id IN (SELECT 1);
|
||||
@ -687,9 +690,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
|
||||
id
|
||||
2
|
||||
INSERT INTO t2 VALUES ((SELECT * FROM t2));
|
||||
You can't specify target table 't2' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
||||
INSERT INTO t2 VALUES ((SELECT id FROM t2));
|
||||
You can't specify target table 't2' for update in FROM clause
|
||||
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
||||
SELECT * FROM t2;
|
||||
id
|
||||
1
|
||||
@ -697,7 +700,7 @@ id
|
||||
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 values (1),(1);
|
||||
UPDATE t2 SET id=(SELECT * FROM t1);
|
||||
Subselect returns more than 1 record
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
drop table t2, t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
@ -828,9 +831,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
drop table t1,t2;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5);
|
||||
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
drop table t1;
|
||||
create table t1 (a int, b int, c varchar(10));
|
||||
create table t2 (a int);
|
||||
@ -882,7 +885,7 @@ select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
|
||||
ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a')
|
||||
1
|
||||
select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
|
||||
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1);
|
||||
@ -897,13 +900,13 @@ select @a;
|
||||
1
|
||||
drop table t1;
|
||||
do (SELECT a from t1);
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
set @a:=(SELECT a from t1);
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
CREATE TABLE t1 (a int, KEY(a));
|
||||
HANDLER t1 OPEN;
|
||||
HANDLER t1 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
|
||||
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
|
||||
HANDLER t1 CLOSE;
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
@ -926,7 +929,7 @@ drop table t1, t2;
|
||||
CREATE TABLE `t1` (`i` int(11) NOT NULL default '0',PRIMARY KEY (`i`)) TYPE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
|
||||
Invalid use of group function
|
||||
ERROR HY000: Invalid use of group function
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int(1));
|
||||
EXPLAIN SELECT (SELECT RAND() FROM t1) FROM t1;
|
||||
@ -1033,7 +1036,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
3 UNCACHEABLE SUBQUERY t1 ALL NULL NULL NULL NULL 3
|
||||
drop table t1;
|
||||
select t1.Continent, t2.Name, t2.Population from t1 LEFT JOIN t2 ON t1.Code = t2.Country where t2.Population IN (select max(t2.Population) AS Population from t2, t1 where t2.Country = t1.Code group by Continent);
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
name char(35) NOT NULL default '',
|
||||
@ -1098,11 +1101,11 @@ PRIMARY KEY (`i`)
|
||||
) TYPE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i));
|
||||
Invalid use of group function
|
||||
ERROR HY000: Invalid use of group function
|
||||
UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
|
||||
Invalid use of group function
|
||||
ERROR HY000: Invalid use of group function
|
||||
UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
|
||||
Unknown table 't' in field list
|
||||
ERROR 42S02: Unknown table 't' in field list
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) default NULL
|
||||
|
@ -24,9 +24,9 @@ a b
|
||||
create TEMPORARY TABLE t2 type=heap select * from t1;
|
||||
create TEMPORARY TABLE IF NOT EXISTS t2 (a int) type=heap;
|
||||
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
|
||||
Table 't1' already exists
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
ALTER TABLE t1 RENAME t2;
|
||||
Table 't2' already exists
|
||||
ERROR 42S01: Table 't2' already exists
|
||||
select * from t2;
|
||||
a b
|
||||
4 e
|
||||
@ -74,7 +74,7 @@ drop table t1,t2;
|
||||
create temporary table t1 (a int not null);
|
||||
insert into t1 values (1),(1);
|
||||
alter table t1 add primary key (a);
|
||||
Duplicate entry '1' for key 1
|
||||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
d datetime default NULL
|
||||
|
@ -14,7 +14,7 @@ select * from t1;
|
||||
a b c1
|
||||
drop table t1;
|
||||
select count(*) from t1;
|
||||
Table 'test.t1' doesn't exist
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create temporary table t1 (n int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
truncate table t1;
|
||||
@ -22,4 +22,4 @@ select * from t1;
|
||||
n
|
||||
drop table t1;
|
||||
truncate non_existing_table;
|
||||
Table 'test.non_existing_table' doesn't exist
|
||||
ERROR 42S02: Table 'test.non_existing_table' doesn't exist
|
||||
|
@ -27,9 +27,9 @@ t3 CREATE TABLE `t3` (
|
||||
drop table t1,t2,t3
|
||||
#;
|
||||
CREATE TABLE t1 (a char(257) default "hello");
|
||||
Too big column length for column 'a' (max = 255). Use BLOB instead
|
||||
ERROR 42000: Too big column length for column 'a' (max = 255). Use BLOB instead
|
||||
CREATE TABLE t2 (a blob default "hello");
|
||||
BLOB column 'a' can't have a default value
|
||||
ERROR 42000: BLOB column 'a' can't have a default value
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
|
||||
insert into t1 values (null,"a","A");
|
||||
@ -347,7 +347,7 @@ a 1
|
||||
hello 1
|
||||
drop table t1;
|
||||
create table t1 (a text, key (a(300)));
|
||||
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 text, key (a(255)));
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
|
@ -436,8 +436,8 @@ a
|
||||
99999999999
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
|
||||
Too big column length for column 'a_dec' (max = 255). Use BLOB instead
|
||||
ERROR 42000: Too big column length for column 'a_dec' (max = 255). Use BLOB instead
|
||||
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
|
||||
Too big column length for column 'a_dec' (max = 255). Use BLOB instead
|
||||
ERROR 42000: Too big column length for column 'a_dec' (max = 255). Use BLOB instead
|
||||
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
|
||||
Too big column length for column 'a_dec' (max = 255). Use BLOB instead
|
||||
ERROR 42000: Too big column length for column 'a_dec' (max = 255). Use BLOB instead
|
||||
|
@ -100,5 +100,5 @@ min(a)
|
||||
-0.010
|
||||
drop table t1;
|
||||
create table t1 (f float(54));
|
||||
Incorrect column specifier for column 'f'
|
||||
ERROR 42000: Incorrect column specifier for column 'f'
|
||||
drop table if exists t1;
|
||||
|
@ -285,7 +285,7 @@ create table t1 (c int);
|
||||
insert into t1 values(1),(2);
|
||||
create table t2 select * from t1;
|
||||
create table t3 select * from t1, t2;
|
||||
Duplicate column name 'c'
|
||||
ERROR 42S21: Duplicate column name 'c'
|
||||
create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
|
||||
show full columns from t3;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
|
@ -85,7 +85,7 @@ a b
|
||||
2 b
|
||||
1 a
|
||||
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
|
||||
Table 't1' from one of SELECT's can not be used in global ORDER clause
|
||||
ERROR 42000: Table 't1' from one of SELECT's can not be used in global ORDER clause
|
||||
explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
@ -95,7 +95,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 UNION t2 ALL NULL NULL NULL NULL 4
|
||||
explain select xx from t1 union select 1;
|
||||
Unknown column 'xx' in 'field list'
|
||||
ERROR 42S22: Unknown column 'xx' in 'field list'
|
||||
explain select a,b from t1 union select 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
@ -110,38 +110,38 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 UNION NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
select a,b from t1 into outfile 'skr' union select a,b from t2;
|
||||
Wrong usage of UNION and INTO
|
||||
ERROR HY000: Wrong usage of UNION and INTO
|
||||
select a,b from t1 order by a union select a,b from t2;
|
||||
Wrong usage of UNION and ORDER BY
|
||||
ERROR HY000: Wrong usage of UNION and ORDER BY
|
||||
insert into t3 select a from t1 order by a union select a from t2;
|
||||
Wrong usage of UNION and ORDER BY
|
||||
ERROR HY000: Wrong usage of UNION and ORDER BY
|
||||
create table t3 select a,b from t1 union select a from t2;
|
||||
The used SELECT statements have a different number of columns
|
||||
ERROR 21000: The used SELECT statements have a different number of columns
|
||||
select a,b from t1 union select a from t2;
|
||||
The used SELECT statements have a different number of columns
|
||||
ERROR 21000: The used SELECT statements have a different number of columns
|
||||
select * from t1 union select a from t2;
|
||||
The used SELECT statements have a different number of columns
|
||||
ERROR 21000: The used SELECT statements have a different number of columns
|
||||
select a from t1 union select * from t2;
|
||||
The used SELECT statements have a different number of columns
|
||||
ERROR 21000: The used SELECT statements have a different number of columns
|
||||
select * from t1 union select SQL_BUFFER_RESULT * from t2;
|
||||
Wrong usage/placement of 'SQL_BUFFER_RESULT'
|
||||
ERROR 42000: Wrong usage/placement of 'SQL_BUFFER_RESULT'
|
||||
create table t3 select a,b from t1 union all select a,b from t2;
|
||||
insert into t3 select a,b from t1 union all select a,b from t2;
|
||||
replace into t3 select a,b as c from t1 union all select a,b from t2;
|
||||
drop table t1,t2,t3;
|
||||
select * union select 1;
|
||||
No tables used
|
||||
ERROR HY000: No tables used
|
||||
select 1 as a,(select a union select a);
|
||||
a (select a union select a)
|
||||
1 1
|
||||
(select 1) union (select 2) order by 0;
|
||||
Unknown column '0' in 'order clause'
|
||||
ERROR 42S22: Unknown column '0' in 'order clause'
|
||||
SELECT @a:=1 UNION SELECT @a:=@a+1;
|
||||
@a:=1
|
||||
1
|
||||
2
|
||||
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
|
||||
Unknown column 'a' in 'field list'
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
|
||||
1 3
|
||||
1 3
|
||||
|
@ -5,11 +5,11 @@ update t1 set a=a+10 where a > 34;
|
||||
update t1 set a=a+100 where a > 0;
|
||||
update t1 set a=a+100 where a=1 and a=2;
|
||||
update t1 set a=b+100 where a=1 and a=2;
|
||||
Unknown column 'b' in 'field list'
|
||||
ERROR 42S22: Unknown column 'b' in 'field list'
|
||||
update t1 set a=b+100 where c=1 and a=2;
|
||||
Unknown column 'c' in 'where clause'
|
||||
ERROR 42S22: Unknown column 'c' in 'where clause'
|
||||
update t1 set d=a+100 where a=1;
|
||||
Unknown column 'd' in 'field list'
|
||||
ERROR 42S22: Unknown column 'd' in 'field list'
|
||||
select * from t1;
|
||||
a
|
||||
101
|
||||
|
@ -1,6 +1,6 @@
|
||||
drop table if exists t1,t2;
|
||||
set @a := foo;
|
||||
Unknown column 'foo' in 'field list'
|
||||
ERROR 42S22: Unknown column 'foo' in 'field list'
|
||||
set @a := connection_id() + 3;
|
||||
select @a - connection_id();
|
||||
@a - connection_id()
|
||||
|
@ -16,9 +16,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const UNIQ UNIQ 8 const 1
|
||||
drop table t1;
|
||||
select x'hello';
|
||||
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 'x'hello'' 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 'x'hello'' at line 1
|
||||
select 0xfg;
|
||||
Unknown column '0xfg' in 'field list'
|
||||
ERROR 42S22: Unknown column '0xfg' in 'field list'
|
||||
create table t1 select 1 as x, 2 as xx;
|
||||
select x,xx from t1;
|
||||
x xx
|
||||
|
@ -164,42 +164,42 @@ select ROUND(RAND(),5);
|
||||
ROUND(RAND(),5)
|
||||
0.02887
|
||||
set big_tables=OFFF;
|
||||
Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
set big_tables="OFFF";
|
||||
Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
set unknown_variable=1;
|
||||
Unknown system variable 'unknown_variable'
|
||||
ERROR HY000: Unknown system variable 'unknown_variable'
|
||||
set max_join_size="hello";
|
||||
Wrong argument type to variable 'max_join_size'
|
||||
ERROR 42000: Wrong argument type to variable 'max_join_size'
|
||||
set table_type=UNKNOWN_TABLE_TYPE;
|
||||
Variable 'table_type' can't be set to the value of 'UNKNOWN_TABLE_TYPE'
|
||||
ERROR 42000: Variable 'table_type' can't be set to the value of 'UNKNOWN_TABLE_TYPE'
|
||||
set table_type=INNODB, big_tables=2;
|
||||
Variable 'big_tables' can't be set to the value of '2'
|
||||
ERROR 42000: Variable 'big_tables' can't be set to the value of '2'
|
||||
show local variables like 'table_type';
|
||||
Variable_name Value
|
||||
table_type HEAP
|
||||
set SESSION query_cache_size=10000;
|
||||
Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
ERROR HY000: Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set GLOBAL table_type=DEFAULT;
|
||||
Variable 'table_type' doesn't have a default value
|
||||
ERROR 42000: Variable 'table_type' doesn't have a default value
|
||||
set character_set_client=UNKNOWN_CHARACTER_SET;
|
||||
Unknown character set: 'UNKNOWN_CHARACTER_SET'
|
||||
ERROR 42000: Unknown character set: 'UNKNOWN_CHARACTER_SET'
|
||||
set global autocommit=1;
|
||||
Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
ERROR HY000: Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
select @@global.timestamp;
|
||||
Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
ERROR HY000: Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
set @@version='';
|
||||
Unknown system variable 'version'
|
||||
ERROR HY000: Unknown system variable 'version'
|
||||
set @@concurrent_insert=1;
|
||||
Variable 'concurrent_insert' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
ERROR HY000: Variable 'concurrent_insert' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set @@global.sql_auto_is_null=1;
|
||||
Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
select @@global.sql_auto_is_null;
|
||||
Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
|
||||
set myisam_max_sort_file_size=100;
|
||||
Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set myisam_max_extra_sort_file_size=100;
|
||||
Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
ERROR HY000: Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set autocommit=1;
|
||||
set big_tables=1;
|
||||
select @@autocommit, @@big_tables;
|
||||
@ -325,7 +325,7 @@ test.t2 check status OK
|
||||
select max(a) +1, max(a) +2 into @xx,@yy from t1;
|
||||
drop table t1,t2;
|
||||
select @@xxxxxxxxxx;
|
||||
Unknown system variable 'xxxxxxxxxx'
|
||||
ERROR HY000: Unknown system variable 'xxxxxxxxxx'
|
||||
select 1;
|
||||
1
|
||||
1
|
||||
|
@ -17,3 +17,8 @@ SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
|
||||
--error 1055
|
||||
SELECT id FROM t1 GROUP BY id2;
|
||||
drop table t1;
|
||||
|
||||
set sql_mode="MySQL40";
|
||||
select @@sql_mode;
|
||||
set sql_mode="ANSI";
|
||||
select @@sql_mode;
|
||||
|
@ -65,3 +65,12 @@ SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
--error 1054
|
||||
select 1 from (select 2) a order by 0;
|
||||
|
||||
#
|
||||
# Test of explain (bug #251)
|
||||
#
|
||||
|
||||
create table t1 (id int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
describe select * from (select * from t1 group by id) bar;
|
||||
drop table t1;
|
||||
|
@ -18,7 +18,7 @@ select version()>=_utf8"3.23.29";
|
||||
select version()>=_latin1"3.23.29";
|
||||
select charset(version());
|
||||
|
||||
create table t1 select database(), user(), version();
|
||||
create table t1 (version char(40)) select database(), user(), version() as 'version';
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
|
@ -14,4 +14,3 @@ ALTER TABLE T2 ADD new_col int not null;
|
||||
ALTER TABLE T2 RENAME T3;
|
||||
show tables like 't_';
|
||||
drop table t3;
|
||||
|
||||
|
@ -1,31 +1,79 @@
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
|
||||
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);
|
||||
--error 1235
|
||||
select product, country , year, sum(profit) from t1 group by product, country, year with cube;
|
||||
--error 1235
|
||||
explain select product, country , year, sum(profit) from t1 group by product, country, year with cube;
|
||||
--error 1235
|
||||
select product, country , year, sum(profit) from t1 group by product, country, year with rollup;
|
||||
--error 1235
|
||||
explain select product, country , year, sum(profit) from t1 group by product, country, year with rollup;
|
||||
--error 1235
|
||||
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;
|
||||
drop table t1;
|
||||
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');
|
||||
|
||||
# First simple rollups, with just grand total
|
||||
select product, sum(profit) from t1 group by product;
|
||||
select product, sum(profit) from t1 group by product with rollup;
|
||||
select product, sum(profit) from t1 group by 1 with rollup;
|
||||
select product, sum(profit),avg(profit) from t1 group by product with rollup;
|
||||
|
||||
# Sub totals
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year;
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
|
||||
explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
|
||||
select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup;
|
||||
|
||||
# limit
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 5;
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 3,3;
|
||||
|
||||
select product, country_id, count(*), count(distinct year) from t1 group by product, country_id;
|
||||
select product, country_id, count(*), count(distinct year) from t1 group by product, country_id with rollup;
|
||||
|
||||
# Test of having
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having country_id = 1;
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 200;
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 7000;
|
||||
|
||||
# Functions
|
||||
select concat(product,':',country_id) as 'prod', concat(":",year,":") as 'year',1+1, sum(profit)/count(*) from t1 group by 1,2 with rollup;
|
||||
select product, sum(profit)/count(*) from t1 group by product with rollup;
|
||||
select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
|
||||
select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup;
|
||||
|
||||
# Joins
|
||||
select product, country , year, sum(profit) from t1,t2 where t1.country_id=t2.country_id group by product, country, year with rollup;
|
||||
|
||||
# Derived tables and sub selects
|
||||
select product, `sum` from (select product, sum(profit) as 'sum' from t1 group by product with rollup) as tmp where product is null;
|
||||
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);
|
||||
|
||||
# The following doesn't return the expected answer, but this is a limitation
|
||||
# in the implementation so we should just document it
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year having country_id is NULL;
|
||||
select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup;
|
||||
|
||||
# Error handling
|
||||
|
||||
# Cube is not yet implemented
|
||||
--error 1235
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
|
||||
--error 1235
|
||||
explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
|
||||
--error 1235
|
||||
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;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
|
@ -24,7 +24,7 @@ show create table t1;
|
||||
set @@sql_mode="no_field_options,mysql323,mysql40";
|
||||
show variables like 'sql_mode';
|
||||
show create table t1;
|
||||
set @@sql_mode="postgresql,oracle,mssql,db2,sapdb";
|
||||
show variables like 'sql_mode';
|
||||
set sql_mode="postgresql,oracle,mssql,db2,sapdb";
|
||||
select @@sql_mode;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
@ -59,7 +59,7 @@ SELECT 1 as a,(SELECT a+a) b,(SELECT b);
|
||||
create table t1 (a int);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (a int);
|
||||
create table t4 (a int, b int);
|
||||
create table t4 (a int not null, b int not null);
|
||||
insert into t1 values (2);
|
||||
insert into t2 values (1,7),(2,7);
|
||||
insert into t4 values (4,8),(3,8),(5,9);
|
||||
@ -106,11 +106,13 @@ delete from t2 where a=100;
|
||||
select * from t3 where a in (select a,b from t2);
|
||||
-- error 1239
|
||||
select * from t3 where a in (select * from t2);
|
||||
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9);
|
||||
select b,max(a) as ma from t4 group by b having b < (select max(t2.a)
|
||||
from t2 where t2.b=t4.b);
|
||||
select b,max(a) as ma from t4 group by b having b >= (select max(t2.a)
|
||||
from t2 where t2.b=t4.b);
|
||||
insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10);
|
||||
-- empty set
|
||||
select b,max(a) as ma from t4 group by b having b < (select max(t2.a) from t2 where t2.b=t4.b);
|
||||
insert into t2 values (2,10);
|
||||
select b,max(a) as ma from t4 group by b having ma < (select max(t2.a) from t2 where t2.b=t4.b);
|
||||
delete from t2 where a=2 and b=10;
|
||||
select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 where t2.b=t4.b);
|
||||
create table t5 (a int);
|
||||
select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
|
||||
insert into t5 values (5);
|
||||
|
@ -60,7 +60,7 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \
|
||||
mysqlaccess.conf \
|
||||
mysqlbug
|
||||
|
||||
pkgdata_DATA = fill_help_tables.sql
|
||||
pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
|
||||
|
||||
# mysqlbug should be distributed built so that people can report build
|
||||
# failures with it.
|
||||
|
@ -1,212 +1,166 @@
|
||||
#!/bin/sh
|
||||
# This script is a wrapper to pipe the mysql_fix_privilege_tables.sql
|
||||
# through the mysql client program to the mysqld server
|
||||
|
||||
root_password="$1"
|
||||
# Default values (Can be changed in my.cnf)
|
||||
password=""
|
||||
host="localhost"
|
||||
user="root"
|
||||
sql_only=0
|
||||
basedir=""
|
||||
verbose=0
|
||||
args=""
|
||||
|
||||
if test -z $1 ; then
|
||||
cmd="@bindir@/mysql -f --user=$user --host=$host mysql"
|
||||
file=mysql_fix_privilege_tables.sql
|
||||
|
||||
# The following code is almost identical to the code in mysql_install_db.sh
|
||||
|
||||
parse_arguments() {
|
||||
# We only need to pass arguments through to the server if we don't
|
||||
# handle them here. So, we collect unrecognized options (passed on
|
||||
# the command line) into the args variable.
|
||||
pick_args=
|
||||
if test "$1" = PICK-ARGS-FROM-ARGV
|
||||
then
|
||||
pick_args=1
|
||||
shift
|
||||
fi
|
||||
|
||||
for arg do
|
||||
case "$arg" in
|
||||
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
--password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
--host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
--sql|--sql-only) sql_only=1;;
|
||||
--verbose) verbose=1 ;;
|
||||
*)
|
||||
if test -n "$pick_args"
|
||||
then
|
||||
# This sed command makes sure that any special chars are quoted,
|
||||
# so the arg gets passed exactly to the server.
|
||||
args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Get first arguments from the my.cfg file, groups [mysqld] and
|
||||
# [mysql_install_db], and then merge with the command line arguments
|
||||
if test -x ./bin/my_print_defaults
|
||||
then
|
||||
print_defaults="./bin/my_print_defaults"
|
||||
elif test -x @bindr@/my_print_defaults
|
||||
then
|
||||
print_defaults="@bindir@/my_print_defaults"
|
||||
elif test -x @bindir@/mysql_print_defaults
|
||||
then
|
||||
print_defaults="@bindir@/mysql_print_defaults"
|
||||
else
|
||||
root_password="$1"
|
||||
cmd="@bindir@/mysql -f --user=$user --password=$root_password --host=$host mysql"
|
||||
print_defaults="my_print_defaults"
|
||||
fi
|
||||
|
||||
# Debian addition
|
||||
if [ "$1" = "--sql-only" ]; then
|
||||
root_password=""
|
||||
cmd="/usr/share/mysql/echo_stderr"
|
||||
fi
|
||||
parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
|
||||
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
||||
|
||||
echo "This scripts updates the mysql.user, mysql.db, mysql.host and the"
|
||||
echo "mysql.func tables to MySQL 3.22.14 and above."
|
||||
echo ""
|
||||
echo "This is needed if you want to use the new GRANT functions,"
|
||||
echo "CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 3.23"
|
||||
echo ""
|
||||
echo "If you get 'Access denied' errors, you should run this script again"
|
||||
echo "and give the MySQL root user password as an argument!"
|
||||
|
||||
echo "Converting all privilege tables to MyISAM format"
|
||||
$cmd <<END_OF_DATA
|
||||
ALTER TABLE user type=MyISAM;
|
||||
ALTER TABLE db type=MyISAM;
|
||||
ALTER TABLE host type=MyISAM;
|
||||
ALTER TABLE func type=MyISAM;
|
||||
ALTER TABLE columns_priv type=MyISAM;
|
||||
ALTER TABLE tables_priv type=MyISAM;
|
||||
END_OF_DATA
|
||||
|
||||
|
||||
# Fix old password format, add File_priv and func table
|
||||
echo ""
|
||||
echo "If your tables are already up to date or partially up to date you will"
|
||||
echo "get some warnings about 'Duplicated column name'. You can safely ignore these!"
|
||||
|
||||
$cmd <<END_OF_DATA
|
||||
alter table user change password password char(16) NOT NULL;
|
||||
alter table user add File_priv enum('N','Y') NOT NULL;
|
||||
CREATE TABLE if not exists func (
|
||||
name char(64) DEFAULT '' NOT NULL,
|
||||
ret tinyint(1) DEFAULT '0' NOT NULL,
|
||||
dl char(128) DEFAULT '' NOT NULL,
|
||||
type enum ('function','aggregate') NOT NULL,
|
||||
PRIMARY KEY (name)
|
||||
);
|
||||
END_OF_DATA
|
||||
echo ""
|
||||
|
||||
# Add the new grant colums
|
||||
|
||||
echo "Creating Grant Alter and Index privileges if they don't exists"
|
||||
echo "You can ignore any Duplicate column errors"
|
||||
$cmd <<END_OF_DATA
|
||||
alter table user add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
|
||||
alter table host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
|
||||
alter table db add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
|
||||
END_OF_DATA
|
||||
res=$?
|
||||
echo ""
|
||||
|
||||
# If the new grant columns didn't exists, copy File -> Grant
|
||||
# and Create -> Alter, Index, References
|
||||
|
||||
if test $res = 0
|
||||
if test -z "$basedir"
|
||||
then
|
||||
echo "Setting default privileges for the new grant, index and alter privileges"
|
||||
$cmd <<END_OF_DATA
|
||||
UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv;
|
||||
UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv;
|
||||
UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv;
|
||||
END_OF_DATA
|
||||
echo ""
|
||||
basedir=@prefix@
|
||||
bindir=@bindir@
|
||||
execdir=@libexecdir@
|
||||
pkgdatadir=@pkgdatadir@
|
||||
else
|
||||
bindir="$basedir/bin"
|
||||
if test -x "$basedir/libexec/mysqld"
|
||||
then
|
||||
execdir="$basedir/libexec"
|
||||
elif test -x "@libexecdir@/mysqld"
|
||||
then
|
||||
execdir="@libexecdir@"
|
||||
else
|
||||
execdir="$basedir/bin"
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# The second alter changes ssl_type to new 4.0.2 format
|
||||
|
||||
echo "Adding columns needed by GRANT .. REQUIRE (openssl)"
|
||||
echo "You can ignore any Duplicate column errors"
|
||||
$cmd <<END_OF_DATA
|
||||
ALTER TABLE user
|
||||
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL,
|
||||
ADD ssl_cipher BLOB NOT NULL,
|
||||
ADD x509_issuer BLOB NOT NULL,
|
||||
ADD x509_subject BLOB NOT NULL;
|
||||
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
|
||||
END_OF_DATA
|
||||
echo ""
|
||||
|
||||
#
|
||||
# Create tables_priv and columns_priv if they don't exists
|
||||
#
|
||||
|
||||
echo "Creating the new table and column privilege tables"
|
||||
|
||||
$cmd <<END_OF_DATA
|
||||
CREATE TABLE IF NOT EXISTS tables_priv (
|
||||
Host char(60) DEFAULT '' NOT NULL,
|
||||
Db char(60) DEFAULT '' NOT NULL,
|
||||
User char(16) DEFAULT '' NOT NULL,
|
||||
Table_name char(60) DEFAULT '' NOT NULL,
|
||||
Grantor char(77) DEFAULT '' NOT NULL,
|
||||
Timestamp timestamp(14),
|
||||
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,
|
||||
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (Host,Db,User,Table_name)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS columns_priv (
|
||||
Host char(60) DEFAULT '' NOT NULL,
|
||||
Db char(60) DEFAULT '' NOT NULL,
|
||||
User char(16) DEFAULT '' NOT NULL,
|
||||
Table_name char(60) DEFAULT '' NOT NULL,
|
||||
Column_name char(59) DEFAULT '' NOT NULL,
|
||||
Timestamp timestamp(14),
|
||||
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (Host,Db,User,Table_name,Column_name)
|
||||
);
|
||||
END_OF_DATA
|
||||
|
||||
#
|
||||
# Name change of Type -> Column_priv from MySQL 3.22.12
|
||||
#
|
||||
|
||||
echo "Changing name of columns_priv.Type -> columns_priv.Column_priv"
|
||||
echo "You can ignore any Unknown column errors from this"
|
||||
|
||||
$cmd <<END_OF_DATA
|
||||
ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL;
|
||||
END_OF_DATA
|
||||
echo ""
|
||||
|
||||
#
|
||||
# Add the new 'type' column to the func table.
|
||||
#
|
||||
|
||||
echo "Fixing the func table"
|
||||
echo "You can ignore any Duplicate column errors"
|
||||
|
||||
$cmd <<EOF
|
||||
alter table func add type enum ('function','aggregate') NOT NULL;
|
||||
EOF
|
||||
echo ""
|
||||
|
||||
#
|
||||
# Change the user,db and host tables to MySQL 4.0 format
|
||||
#
|
||||
|
||||
echo "Adding new fields used by MySQL 4.0.2 to the privilege tables"
|
||||
echo "You can ignore any Duplicate column errors"
|
||||
|
||||
$cmd <<END_OF_DATA
|
||||
alter table user
|
||||
add Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER alter_priv,
|
||||
add Super_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Show_db_priv,
|
||||
add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Super_priv,
|
||||
add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
|
||||
add Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
|
||||
add Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv,
|
||||
add Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
|
||||
END_OF_DATA
|
||||
|
||||
if test $? -eq "0"
|
||||
# The following test is to make this script compatible with the 4.0 where
|
||||
# the first argument was the password
|
||||
if test -z $password
|
||||
then
|
||||
# Convert privileges so that users have similar privileges as before
|
||||
echo ""
|
||||
echo "Updating new privileges in MySQL 4.0.2 from old ones"
|
||||
$cmd <<END_OF_DATA
|
||||
update user set show_db_priv= select_priv, super_priv=process_priv, execute_priv=process_priv, create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=file_priv where user<>"";
|
||||
END_OF_DATA
|
||||
echo ""
|
||||
password=`echo $args | sed -e 's/ *//g'`
|
||||
fi
|
||||
|
||||
# Add fields that can be used to limit number of questions and connections
|
||||
# for some users.
|
||||
if test -z $password ; then
|
||||
cmd="$bindir/mysql -f --user=$user --host=$host mysql"
|
||||
else
|
||||
cmd="$bindir/mysql -f --user=$user --password=$password --host=$host mysql"
|
||||
fi
|
||||
if test $sql_only = 1
|
||||
then
|
||||
cmd="cat"
|
||||
fi
|
||||
|
||||
$cmd <<END_OF_DATA
|
||||
alter table user
|
||||
add max_questions int(11) NOT NULL AFTER x509_subject,
|
||||
add max_updates int(11) unsigned NOT NULL AFTER max_questions,
|
||||
add max_connections int(11) unsigned NOT NULL AFTER max_updates;
|
||||
END_OF_DATA
|
||||
# Find where mysql_fix_privilege_tables.sql is located
|
||||
for i in $basedir/support-files $basedir/share $basedir/share/mysql \
|
||||
$basedir/scripts @pkgdatadir@ . ./scripts
|
||||
do
|
||||
if test -f $i/$file
|
||||
then
|
||||
pkgdatadir=$i
|
||||
fi
|
||||
done
|
||||
|
||||
# Increase password length to handle new passwords
|
||||
sql_file="$pkgdatadir/$file"
|
||||
if test ! -f $sql_file
|
||||
then
|
||||
echo "Could not find file '$file'."
|
||||
echo "Please use --basedir to specify the directory where MySQL is installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@bindir@/mysql -f --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
|
||||
alter table user
|
||||
change password password char(45) not null;
|
||||
END_OF_DATA
|
||||
s_echo()
|
||||
{
|
||||
if test $sql_only = 0
|
||||
then
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
s_echo "This scripts updates all the mysql privilege tables to be usable by"
|
||||
s_echo "MySQL 4.0 and above."
|
||||
s_echo ""
|
||||
s_echo "This is needed if you want to use the new GRANT functions,"
|
||||
s_echo "CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 4.1"
|
||||
s_echo ""
|
||||
|
||||
if test $verbose = 1
|
||||
then
|
||||
s_echo "You can safely ignore all 'Duplicate column' and 'Unknown column' errors"
|
||||
s_echo "as this just means that your tables where already up to date."
|
||||
s_echo "This script is safe to run even if your tables are already up to date!"
|
||||
s_echo ""
|
||||
fi
|
||||
|
||||
#
|
||||
# Add Create_tmp_table_priv and Lock_tables_priv to db and host
|
||||
#
|
||||
|
||||
$cmd <<END_OF_DATA
|
||||
alter table db
|
||||
add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
|
||||
alter table host
|
||||
add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
|
||||
END_OF_DATA
|
||||
if test $verbose = 0
|
||||
then
|
||||
cat $sql_file | $cmd > /dev/null 2>&1
|
||||
else
|
||||
cat $sql_file | $cmd > /dev/null
|
||||
fi
|
||||
if test $? = 0
|
||||
then
|
||||
s_echo "done"
|
||||
else
|
||||
s_echo "Got a failure from command:"
|
||||
s_echo "$cmd"
|
||||
s_echo "Please check the above output and try again."
|
||||
if test $verbose = 0
|
||||
then
|
||||
s_echo ""
|
||||
s_echo "Running the script with the --verbose option may give you some information"
|
||||
s_echo "of what went wrong."
|
||||
fi
|
||||
s_echo ""
|
||||
s_echo "If you get an 'Access denied' error, you should run this script again and"
|
||||
s_echo "give the MySQL root user password as an argument with the --password= option"
|
||||
fi
|
||||
|
89
scripts/mysql_fix_privilege_tables.sql
Normal file
89
scripts/mysql_fix_privilege_tables.sql
Normal file
@ -0,0 +1,89 @@
|
||||
ALTER TABLE user type=MyISAM;
|
||||
ALTER TABLE db type=MyISAM;
|
||||
ALTER TABLE host type=MyISAM;
|
||||
ALTER TABLE func type=MyISAM;
|
||||
ALTER TABLE columns_priv type=MyISAM;
|
||||
ALTER TABLE tables_priv type=MyISAM;
|
||||
ALTER TABLE user change password password char(45) not null;
|
||||
ALTER TABLE user add File_priv enum('N','Y') NOT NULL;
|
||||
CREATE TABLE IF NOT EXISTS func (
|
||||
name char(64) DEFAULT '' NOT NULL,
|
||||
ret tinyint(1) DEFAULT '0' NOT NULL,
|
||||
dl char(128) DEFAULT '' NOT NULL,
|
||||
type enum ('function','aggregate') NOT NULL,
|
||||
PRIMARY KEY (name)
|
||||
);
|
||||
|
||||
-- Detect whether or not we had the Grant_priv column
|
||||
SET @hadGrantPriv:=0;
|
||||
SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
|
||||
|
||||
ALTER TABLE user add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
|
||||
ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
|
||||
ALTER TABLE db add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
|
||||
|
||||
--- Fix privileges for old tables
|
||||
UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
|
||||
UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
|
||||
UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
|
||||
|
||||
ALTER TABLE user
|
||||
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL,
|
||||
ADD ssl_cipher BLOB NOT NULL,
|
||||
ADD x509_issuer BLOB NOT NULL,
|
||||
ADD x509_subject BLOB NOT NULL;
|
||||
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tables_priv (
|
||||
Host char(60) DEFAULT '' NOT NULL,
|
||||
Db char(60) DEFAULT '' NOT NULL,
|
||||
User char(16) DEFAULT '' NOT NULL,
|
||||
Table_name char(60) DEFAULT '' NOT NULL,
|
||||
Grantor char(77) DEFAULT '' NOT NULL,
|
||||
Timestamp timestamp(14),
|
||||
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,
|
||||
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (Host,Db,User,Table_name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS columns_priv (
|
||||
Host char(60) DEFAULT '' NOT NULL,
|
||||
Db char(60) DEFAULT '' NOT NULL,
|
||||
User char(16) DEFAULT '' NOT NULL,
|
||||
Table_name char(60) DEFAULT '' NOT NULL,
|
||||
Column_name char(59) DEFAULT '' NOT NULL,
|
||||
Timestamp timestamp(14),
|
||||
Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (Host,Db,User,Table_name,Column_name)
|
||||
);
|
||||
|
||||
ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL;
|
||||
|
||||
ALTER TABLE func add type enum ('function','aggregate') NOT NULL;
|
||||
|
||||
# Detect whether we had Show_db_priv
|
||||
SET @hadShowDbPriv:=0;
|
||||
SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';
|
||||
|
||||
ALTER TABLE user
|
||||
ADD Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER alter_priv,
|
||||
ADD Super_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Show_db_priv,
|
||||
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Super_priv,
|
||||
ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
|
||||
ADD Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
|
||||
ADD Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv,
|
||||
ADD Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
|
||||
|
||||
UPDATE user SET show_db_priv= select_priv, super_priv=process_priv, execute_priv=process_priv, create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=file_priv where user<>"" AND @hadShowDbPriv = 0;
|
||||
|
||||
ALTER TABLE user
|
||||
ADD max_questions int(11) NOT NULL AFTER x509_subject,
|
||||
ADD max_updates int(11) unsigned NOT NULL AFTER max_questions,
|
||||
ADD max_connections int(11) unsigned NOT NULL AFTER max_updates;
|
||||
|
||||
ALTER TABLE db
|
||||
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
|
||||
ALTER TABLE host
|
||||
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
||||
ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
|
@ -64,7 +64,8 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
||||
thr_malloc.cc item_create.cc item_subselect.cc \
|
||||
item_row.cc \
|
||||
field.cc key.cc sql_class.cc sql_list.cc \
|
||||
net_serv.cc protocol.cc lock.cc my_lock.c \
|
||||
net_serv.cc protocol.cc sql_state.c \
|
||||
lock.cc my_lock.c \
|
||||
sql_string.cc sql_manager.cc sql_map.cc \
|
||||
mysqld.cc password.c hash_filo.cc hostname.cc \
|
||||
set_var.cc sql_parse.cc sql_yacc.yy \
|
||||
|
34
sql/item.cc
34
sql/item.cc
@ -117,7 +117,9 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
|
||||
|
||||
|
||||
/*
|
||||
This function is only called when comparing items in the WHERE clause
|
||||
This function is called when:
|
||||
- Comparing items in the WHERE clause (when doing where optimization)
|
||||
- When trying to find an ORDER BY/GROUP BY item in the SELECT part
|
||||
*/
|
||||
|
||||
bool Item::eq(const Item *item, bool binary_cmp) const
|
||||
@ -243,6 +245,7 @@ void Item_field::set_field(Field *field_par)
|
||||
decimals= field->decimals();
|
||||
table_name=field_par->table_name;
|
||||
field_name=field_par->field_name;
|
||||
db_name=field_par->table->table_cache_key;
|
||||
unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
|
||||
set_charset(field_par->charset(), COER_IMPLICIT);
|
||||
}
|
||||
@ -344,9 +347,34 @@ longlong Item_field::val_int_result()
|
||||
return result_field->val_int();
|
||||
}
|
||||
|
||||
|
||||
bool Item_field::eq(const Item *item, bool binary_cmp) const
|
||||
{
|
||||
return item->type() == FIELD_ITEM && ((Item_field*) item)->field == field;
|
||||
if (item->type() != FIELD_ITEM)
|
||||
return 0;
|
||||
|
||||
Item_field *item_field= (Item_field*) item;
|
||||
if (item_field->field)
|
||||
return item_field->field == field;
|
||||
/*
|
||||
We may come here when we are trying to find a function in a GROUP BY
|
||||
clause from the select list.
|
||||
In this case the '100 % correct' way to do this would be to first
|
||||
run fix_fields() on the GROUP BY item and then retry this function, but
|
||||
I think it's better to relax the checking a bit as we will in
|
||||
most cases do the correct thing by just checking the field name.
|
||||
(In cases where we would choose wrong we would have to generate a
|
||||
ER_NON_UNIQ_ERROR).
|
||||
*/
|
||||
return (!my_strcasecmp(system_charset_info, item_field->name,
|
||||
field_name) &&
|
||||
(!item_field->table_name ||
|
||||
(!my_strcasecmp(table_alias_charset, item_field->table_name,
|
||||
table_name) &&
|
||||
(!item_field->db_name ||
|
||||
(item_field->db_name && !my_strcasecmp(table_alias_charset,
|
||||
item_field->db_name,
|
||||
db_name))))));
|
||||
}
|
||||
|
||||
table_map Item_field::used_tables() const
|
||||
@ -837,7 +865,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
return rf->fix_fields(thd, tables, ref) || rf->check_cols(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!tmp)
|
||||
return -1;
|
||||
|
||||
|
@ -29,6 +29,8 @@ class Item {
|
||||
void operator=(Item &);
|
||||
public:
|
||||
static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
|
||||
static void *operator new(size_t size, MEM_ROOT *mem_root)
|
||||
{ return (void*) alloc_root(mem_root, (uint) size); }
|
||||
static void operator delete(void *ptr,size_t size) {} /*lint -e715 */
|
||||
|
||||
enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
|
||||
|
160
sql/item_sum.cc
160
sql/item_sum.cc
@ -217,11 +217,19 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
** reset and add of sum_func
|
||||
***********************************************************************/
|
||||
|
||||
void Item_sum_sum::reset()
|
||||
Item *Item_sum_sum::copy_or_same(THD* thd)
|
||||
{
|
||||
null_value=1; sum=0.0; Item_sum_sum::add();
|
||||
return new (&thd->mem_root) Item_sum_sum(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_sum::reset()
|
||||
{
|
||||
null_value=1; sum=0.0;
|
||||
return Item_sum_sum::add();
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_sum::add()
|
||||
{
|
||||
sum+=args[0]->val();
|
||||
@ -230,17 +238,26 @@ bool Item_sum_sum::add()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
double Item_sum_sum::val()
|
||||
{
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
void Item_sum_count::reset()
|
||||
Item *Item_sum_count::copy_or_same(THD* thd)
|
||||
{
|
||||
count=0; add();
|
||||
return new (&thd->mem_root) Item_sum_count(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_count::reset()
|
||||
{
|
||||
count=0;
|
||||
return add();
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_count::add()
|
||||
{
|
||||
if (!args[0]->maybe_null)
|
||||
@ -260,14 +277,22 @@ longlong Item_sum_count::val_int()
|
||||
}
|
||||
|
||||
/*
|
||||
** Avgerage
|
||||
Avgerage
|
||||
*/
|
||||
|
||||
void Item_sum_avg::reset()
|
||||
Item *Item_sum_avg::copy_or_same(THD* thd)
|
||||
{
|
||||
sum=0.0; count=0; Item_sum_avg::add();
|
||||
return new (&thd->mem_root) Item_sum_avg(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_avg::reset()
|
||||
{
|
||||
sum=0.0; count=0;
|
||||
return Item_sum_avg::add();
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_avg::add()
|
||||
{
|
||||
double nr=args[0]->val();
|
||||
@ -292,7 +317,7 @@ double Item_sum_avg::val()
|
||||
|
||||
|
||||
/*
|
||||
** Standard deviation
|
||||
Standard deviation
|
||||
*/
|
||||
|
||||
double Item_sum_std::val()
|
||||
@ -301,15 +326,27 @@ double Item_sum_std::val()
|
||||
return tmp <= 0.0 ? 0.0 : sqrt(tmp);
|
||||
}
|
||||
|
||||
Item *Item_sum_std::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_std(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** variance
|
||||
Variance
|
||||
*/
|
||||
|
||||
void Item_sum_variance::reset()
|
||||
Item *Item_sum_variance::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_variance(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_variance::reset()
|
||||
{
|
||||
sum=sum_sqr=0.0;
|
||||
count=0;
|
||||
(void) Item_sum_variance::add();
|
||||
return Item_sum_variance::add();
|
||||
}
|
||||
|
||||
bool Item_sum_variance::add()
|
||||
@ -440,6 +477,13 @@ Item_sum_hybrid::val_str(String *str)
|
||||
return str; // Keep compiler happy
|
||||
}
|
||||
|
||||
|
||||
Item *Item_sum_min::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_min(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_min::add()
|
||||
{
|
||||
switch (hybrid_type) {
|
||||
@ -487,6 +531,12 @@ bool Item_sum_min::add()
|
||||
}
|
||||
|
||||
|
||||
Item *Item_sum_max::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_max(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_max::add()
|
||||
{
|
||||
switch (hybrid_type) {
|
||||
@ -541,11 +591,19 @@ longlong Item_sum_bit::val_int()
|
||||
return (longlong) bits;
|
||||
}
|
||||
|
||||
void Item_sum_bit::reset()
|
||||
|
||||
bool Item_sum_bit::reset()
|
||||
{
|
||||
bits=reset_bits; add();
|
||||
bits=reset_bits;
|
||||
return add();
|
||||
}
|
||||
|
||||
Item *Item_sum_or::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_or(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_or::add()
|
||||
{
|
||||
ulonglong value= (ulonglong) args[0]->val_int();
|
||||
@ -554,6 +612,12 @@ bool Item_sum_or::add()
|
||||
return 0;
|
||||
}
|
||||
|
||||
Item *Item_sum_and::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_and(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_and::add()
|
||||
{
|
||||
ulonglong value= (ulonglong) args[0]->val_int();
|
||||
@ -1032,12 +1096,21 @@ Item_sum_count_distinct::~Item_sum_count_distinct()
|
||||
bool Item_sum_count_distinct::fix_fields(THD *thd, TABLE_LIST *tables,
|
||||
Item **ref)
|
||||
{
|
||||
if (Item_sum_num::fix_fields(thd, tables, ref) ||
|
||||
!(tmp_table_param= new TMP_TABLE_PARAM))
|
||||
if (Item_sum_num::fix_fields(thd, tables, ref))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is used by rollup to create a separate usable copy of the function */
|
||||
|
||||
void Item_sum_count_distinct::make_unique()
|
||||
{
|
||||
table=0;
|
||||
original= 0;
|
||||
tree= &tree_base;
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_count_distinct::setup(THD *thd)
|
||||
{
|
||||
List<Item> list;
|
||||
@ -1045,6 +1118,9 @@ bool Item_sum_count_distinct::setup(THD *thd)
|
||||
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
|
||||
return 1;
|
||||
|
||||
if (!(tmp_table_param= new TMP_TABLE_PARAM))
|
||||
return 1;
|
||||
|
||||
/* Create a table with an unique key over all parameters */
|
||||
for (uint i=0; i < arg_count ; i++)
|
||||
{
|
||||
@ -1192,7 +1268,14 @@ int Item_sum_count_distinct::tree_to_myisam()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Item_sum_count_distinct::reset()
|
||||
|
||||
Item *Item_sum_count_distinct::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_count_distinct(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_count_distinct::reset()
|
||||
{
|
||||
if (use_tree)
|
||||
reset_tree(tree);
|
||||
@ -1202,7 +1285,7 @@ void Item_sum_count_distinct::reset()
|
||||
table->file->delete_all_rows();
|
||||
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
}
|
||||
(void) add();
|
||||
return add();
|
||||
}
|
||||
|
||||
bool Item_sum_count_distinct::add()
|
||||
@ -1265,11 +1348,11 @@ longlong Item_sum_count_distinct::val_int()
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
|
||||
void Item_udf_sum::reset()
|
||||
bool Item_udf_sum::reset()
|
||||
{
|
||||
DBUG_ENTER("Item_udf_sum::reset");
|
||||
udf.reset(&null_value);
|
||||
DBUG_VOID_RETURN;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
bool Item_udf_sum::add()
|
||||
@ -1279,6 +1362,11 @@ bool Item_udf_sum::add()
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
Item *Item_sum_udf_float::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_udf_float(thd, *this);
|
||||
}
|
||||
|
||||
double Item_sum_udf_float::val()
|
||||
{
|
||||
DBUG_ENTER("Item_sum_udf_float::val");
|
||||
@ -1298,6 +1386,12 @@ String *Item_sum_udf_float::val_str(String *str)
|
||||
}
|
||||
|
||||
|
||||
Item *Item_sum_udf_int::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_udf_int(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
longlong Item_sum_udf_int::val_int()
|
||||
{
|
||||
DBUG_ENTER("Item_sum_udf_int::val_int");
|
||||
@ -1306,6 +1400,7 @@ longlong Item_sum_udf_int::val_int()
|
||||
DBUG_RETURN(udf.val_int(&null_value));
|
||||
}
|
||||
|
||||
|
||||
String *Item_sum_udf_int::val_str(String *str)
|
||||
{
|
||||
longlong nr=val_int();
|
||||
@ -1327,6 +1422,13 @@ void Item_sum_udf_str::fix_length_and_dec()
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
Item *Item_sum_udf_str::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_udf_str(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
String *Item_sum_udf_str::val_str(String *str)
|
||||
{
|
||||
DBUG_ENTER("Item_sum_udf_str::str");
|
||||
@ -1568,7 +1670,13 @@ Item_func_group_concat::~Item_func_group_concat()
|
||||
}
|
||||
|
||||
|
||||
void Item_func_group_concat::reset()
|
||||
Item *Item_func_group_concat::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_func_group_concat(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_func_group_concat::reset()
|
||||
{
|
||||
result.length(0);
|
||||
result.copy();
|
||||
@ -1582,7 +1690,7 @@ void Item_func_group_concat::reset()
|
||||
}
|
||||
if (tree_mode)
|
||||
reset_tree(tree);
|
||||
add();
|
||||
return add();
|
||||
}
|
||||
|
||||
|
||||
@ -1768,6 +1876,16 @@ bool Item_func_group_concat::setup(THD *thd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is used by rollup to create a separate usable copy of the function */
|
||||
|
||||
void Item_func_group_concat::make_unique()
|
||||
{
|
||||
table=0;
|
||||
original= 0;
|
||||
tree= &tree_base;
|
||||
}
|
||||
|
||||
|
||||
String* Item_func_group_concat::val_str(String* str)
|
||||
{
|
||||
if (null_value)
|
||||
|
@ -26,9 +26,11 @@
|
||||
class Item_sum :public Item_result_field
|
||||
{
|
||||
public:
|
||||
enum Sumfunctype {COUNT_FUNC,COUNT_DISTINCT_FUNC,SUM_FUNC,AVG_FUNC,MIN_FUNC,
|
||||
MAX_FUNC, UNIQUE_USERS_FUNC,STD_FUNC,VARIANCE_FUNC,SUM_BIT_FUNC,
|
||||
UDF_SUM_FUNC, GROUP_CONCAT_FUNC };
|
||||
enum Sumfunctype
|
||||
{ COUNT_FUNC,COUNT_DISTINCT_FUNC,SUM_FUNC,AVG_FUNC,MIN_FUNC,
|
||||
MAX_FUNC, UNIQUE_USERS_FUNC,STD_FUNC,VARIANCE_FUNC,SUM_BIT_FUNC,
|
||||
UDF_SUM_FUNC, GROUP_CONCAT_FUNC
|
||||
};
|
||||
|
||||
Item **args,*tmp_args[2];
|
||||
uint arg_count;
|
||||
@ -60,7 +62,7 @@ public:
|
||||
|
||||
enum Type type() const { return SUM_FUNC_ITEM; }
|
||||
virtual enum Sumfunctype sum_func () const=0;
|
||||
virtual void reset()=0;
|
||||
virtual bool reset()=0;
|
||||
virtual bool add()=0;
|
||||
virtual void reset_field()=0;
|
||||
virtual void update_field(int offset)=0;
|
||||
@ -78,6 +80,7 @@ public:
|
||||
void fix_num_length_and_dec();
|
||||
void no_rows_in_result() { reset(); }
|
||||
virtual bool setup(THD *thd) {return 0;}
|
||||
virtual void make_unique() {}
|
||||
Item *get_tmp_table_item(THD *thd);
|
||||
};
|
||||
|
||||
@ -121,14 +124,14 @@ class Item_sum_sum :public Item_sum_num
|
||||
Item_sum_sum(THD *thd, Item_sum_sum &item)
|
||||
:Item_sum_num(thd, item), sum(item.sum) {}
|
||||
enum Sumfunctype sum_func () const {return SUM_FUNC;}
|
||||
void reset();
|
||||
bool reset();
|
||||
bool add();
|
||||
double val();
|
||||
void reset_field();
|
||||
void update_field(int offset);
|
||||
void no_rows_in_result() {}
|
||||
const char *func_name() const { return "sum"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_sum(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -148,7 +151,7 @@ class Item_sum_count :public Item_sum_int
|
||||
table_map used_tables() const { return used_table_cache; }
|
||||
bool const_item() const { return !used_table_cache; }
|
||||
enum Sumfunctype sum_func () const { return COUNT_FUNC; }
|
||||
void reset();
|
||||
bool reset();
|
||||
void no_rows_in_result() { count=0; }
|
||||
bool add();
|
||||
void make_const(longlong count_arg) { count=count_arg; used_table_cache=0; }
|
||||
@ -156,7 +159,7 @@ class Item_sum_count :public Item_sum_int
|
||||
void reset_field();
|
||||
void update_field(int offset);
|
||||
const char *func_name() const { return "count"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_count(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -222,17 +225,15 @@ class Item_sum_count_distinct :public Item_sum_int
|
||||
|
||||
table_map used_tables() const { return used_table_cache; }
|
||||
enum Sumfunctype sum_func () const { return COUNT_DISTINCT_FUNC; }
|
||||
void reset();
|
||||
bool reset();
|
||||
bool add();
|
||||
longlong val_int();
|
||||
void reset_field() { return ;} // Never called
|
||||
void update_field(int offset) { return ; } // Never called
|
||||
const char *func_name() const { return "count_distinct"; }
|
||||
bool setup(THD *thd);
|
||||
Item *copy_or_same(THD* thd)
|
||||
{
|
||||
return new Item_sum_count_distinct(thd, *this);
|
||||
}
|
||||
void make_unique();
|
||||
Item *copy_or_same(THD* thd);
|
||||
void no_rows_in_result() {}
|
||||
};
|
||||
|
||||
@ -268,7 +269,7 @@ class Item_sum_avg :public Item_sum_num
|
||||
Item_sum_avg(THD *thd, Item_sum_avg &item)
|
||||
:Item_sum_num(thd, item), sum(item.sum), count(item.count) {}
|
||||
enum Sumfunctype sum_func () const {return AVG_FUNC;}
|
||||
void reset();
|
||||
bool reset();
|
||||
bool add();
|
||||
double val();
|
||||
void reset_field();
|
||||
@ -276,7 +277,7 @@ class Item_sum_avg :public Item_sum_num
|
||||
Item *result_item(Field *field)
|
||||
{ return new Item_avg_field(this); }
|
||||
const char *func_name() const { return "avg"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_avg(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
class Item_sum_variance;
|
||||
@ -321,7 +322,7 @@ class Item_sum_variance : public Item_sum_num
|
||||
Item_sum_num(thd, item), sum(item.sum), sum_sqr(item.sum_sqr),
|
||||
count(item.count) {}
|
||||
enum Sumfunctype sum_func () const { return VARIANCE_FUNC; }
|
||||
void reset();
|
||||
bool reset();
|
||||
bool add();
|
||||
double val();
|
||||
void reset_field();
|
||||
@ -329,7 +330,7 @@ class Item_sum_variance : public Item_sum_num
|
||||
Item *result_item(Field *field)
|
||||
{ return new Item_variance_field(this); }
|
||||
const char *func_name() const { return "variance"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_variance(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
class Item_sum_std;
|
||||
@ -349,12 +350,16 @@ public:
|
||||
class Item_sum_std :public Item_sum_variance
|
||||
{
|
||||
public:
|
||||
Item_sum_std(Item *item_par) :Item_sum_variance(item_par){}
|
||||
Item_sum_std(Item *item_par) :Item_sum_variance(item_par) {}
|
||||
Item_sum_std(THD *thd, Item_sum_std &item)
|
||||
:Item_sum_variance(thd, item)
|
||||
{}
|
||||
enum Sumfunctype sum_func () const { return STD_FUNC; }
|
||||
double val();
|
||||
Item *result_item(Field *field)
|
||||
{ return new Item_std_field(this); }
|
||||
const char *func_name() const { return "std"; }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
// This class is a string or number function depending on num_func
|
||||
@ -386,13 +391,13 @@ class Item_sum_hybrid :public Item_sum
|
||||
table_map used_tables() const { return used_table_cache; }
|
||||
bool const_item() const { return !used_table_cache; }
|
||||
|
||||
void reset()
|
||||
bool reset()
|
||||
{
|
||||
sum=0.0;
|
||||
sum_int=0;
|
||||
value.length(0);
|
||||
null_value=1;
|
||||
add();
|
||||
return add();
|
||||
}
|
||||
double val();
|
||||
longlong val_int();
|
||||
@ -418,7 +423,7 @@ public:
|
||||
|
||||
bool add();
|
||||
const char *func_name() const { return "min"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_min(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -431,7 +436,7 @@ public:
|
||||
|
||||
bool add();
|
||||
const char *func_name() const { return "max"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_max(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -446,7 +451,7 @@ class Item_sum_bit :public Item_sum_int
|
||||
Item_sum_bit(THD *thd, Item_sum_bit &item):
|
||||
Item_sum_int(thd, item), reset_bits(item.reset_bits), bits(item.bits) {}
|
||||
enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;}
|
||||
void reset();
|
||||
bool reset();
|
||||
longlong val_int();
|
||||
void reset_field();
|
||||
void fix_length_and_dec()
|
||||
@ -462,7 +467,7 @@ class Item_sum_or :public Item_sum_bit
|
||||
bool add();
|
||||
void update_field(int offset);
|
||||
const char *func_name() const { return "bit_or"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_or(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -474,7 +479,7 @@ class Item_sum_and :public Item_sum_bit
|
||||
bool add();
|
||||
void update_field(int offset);
|
||||
const char *func_name() const { return "bit_and"; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_and(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -504,7 +509,7 @@ public:
|
||||
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
|
||||
virtual bool have_field_update(void) const { return 0; }
|
||||
|
||||
void reset();
|
||||
bool reset();
|
||||
bool add();
|
||||
void reset_field() {};
|
||||
void update_field(int offset_arg) {};
|
||||
@ -524,7 +529,7 @@ class Item_sum_udf_float :public Item_udf_sum
|
||||
double val();
|
||||
String *val_str(String*str);
|
||||
void fix_length_and_dec() { fix_num_length_and_dec(); }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_udf_float(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -542,7 +547,7 @@ public:
|
||||
String *val_str(String*str);
|
||||
enum Item_result result_type () const { return INT_RESULT; }
|
||||
void fix_length_and_dec() { decimals=0; max_length=21; }
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_udf_int(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
@ -571,7 +576,7 @@ public:
|
||||
}
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
void fix_length_and_dec();
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_udf_str(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
#else /* Dummy functions to get sql_yacc.cc compiled */
|
||||
@ -586,10 +591,9 @@ class Item_sum_udf_float :public Item_sum_num
|
||||
~Item_sum_udf_float() {}
|
||||
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
|
||||
double val() { return 0.0; }
|
||||
void reset() {}
|
||||
bool reset() { return 0; }
|
||||
bool add() { return 0; }
|
||||
void update_field(int offset) {}
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_udf_float(thd, *this); }
|
||||
};
|
||||
|
||||
|
||||
@ -604,10 +608,9 @@ public:
|
||||
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
|
||||
longlong val_int() { return 0; }
|
||||
double val() { return 0; }
|
||||
void reset() {}
|
||||
bool reset() { return 0; }
|
||||
bool add() { return 0; }
|
||||
void update_field(int offset) {}
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_udf_int(thd, *this); }
|
||||
};
|
||||
|
||||
|
||||
@ -625,10 +628,9 @@ public:
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
void fix_length_and_dec() { maybe_null=1; max_length=0; }
|
||||
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
|
||||
void reset() {}
|
||||
bool reset() { return 0; }
|
||||
bool add() { return 0; }
|
||||
void update_field(int offset) {}
|
||||
Item *copy_or_same(THD* thd) { return new Item_sum_udf_str(thd, *this); }
|
||||
};
|
||||
|
||||
#endif /* HAVE_DLOPEN */
|
||||
@ -676,7 +678,7 @@ class Item_func_group_concat : public Item_sum
|
||||
warning(item.warning),
|
||||
warning_available(item.warning_available),
|
||||
separator(item.separator),
|
||||
tree(item.tree),
|
||||
tree(item.tree),
|
||||
table(item.table),
|
||||
expr(item.expr),
|
||||
order(item.order),
|
||||
@ -700,11 +702,12 @@ class Item_func_group_concat : public Item_sum
|
||||
enum Type type() const { return SUM_FUNC_ITEM; }
|
||||
void fix_length_and_dec() { max_length=group_concat_max_len; }
|
||||
virtual Item_result result_type () const { return STRING_RESULT; }
|
||||
void reset();
|
||||
bool reset();
|
||||
bool add();
|
||||
void reset_field();
|
||||
bool fix_fields(THD *, TABLE_LIST *, Item **);
|
||||
bool setup(THD *thd);
|
||||
void make_unique();
|
||||
virtual void update_field(int offset) {};
|
||||
double val()
|
||||
{
|
||||
@ -717,5 +720,5 @@ class Item_func_group_concat : public Item_sum
|
||||
return res ? strtoll(res->c_ptr(),(char**) 0,10) : (longlong) 0;
|
||||
}
|
||||
String* val_str(String* str);
|
||||
Item *copy_or_same(THD* thd) { return new Item_func_group_concat(thd, *this); }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
:Item_sum_num(thd, item) {}
|
||||
double val() { return 0.0; }
|
||||
enum Sumfunctype sum_func () const {return UNIQUE_USERS_FUNC;}
|
||||
void reset() {}
|
||||
bool reset() { return 0;}
|
||||
bool add() { return 0; }
|
||||
void reset_field() {}
|
||||
void update_field(int offset) {}
|
||||
|
@ -66,9 +66,8 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern CHARSET_INFO *system_charset_info;
|
||||
extern CHARSET_INFO *files_charset_info;
|
||||
extern CHARSET_INFO *national_charset_info;
|
||||
extern CHARSET_INFO *system_charset_info, *files_charset_info ;
|
||||
extern CHARSET_INFO *national_charset_info, *table_alias_charset;
|
||||
|
||||
/***************************************************************************
|
||||
Configuration parameters
|
||||
@ -208,7 +207,7 @@ extern CHARSET_INFO *national_charset_info;
|
||||
#define MODE_PIPES_AS_CONCAT 2
|
||||
#define MODE_ANSI_QUOTES 4
|
||||
#define MODE_IGNORE_SPACE 8
|
||||
#define MODE_SERIALIZABLE 16
|
||||
#define MODE_NOT_USED 16
|
||||
#define MODE_ONLY_FULL_GROUP_BY 32
|
||||
#define MODE_NO_UNSIGNED_SUBTRACTION 64
|
||||
#define MODE_POSTGRESQL 128
|
||||
@ -221,6 +220,7 @@ extern CHARSET_INFO *national_charset_info;
|
||||
#define MODE_NO_FIELD_OPTIONS 16384
|
||||
#define MODE_MYSQL323 32768
|
||||
#define MODE_MYSQL40 65536
|
||||
#define MODE_ANSI (MODE_MYSQL40*2)
|
||||
|
||||
#define RAID_BLOCK_SIZE 1024
|
||||
|
||||
@ -723,7 +723,7 @@ extern ulong ha_read_rnd_count, ha_read_rnd_next_count;
|
||||
extern ulong ha_commit_count, ha_rollback_count,table_cache_size;
|
||||
extern ulong max_connections,max_connect_errors, connect_timeout;
|
||||
extern ulong max_insert_delayed_threads, max_user_connections;
|
||||
extern ulong long_query_count, what_to_log,flush_time,opt_sql_mode;
|
||||
extern ulong long_query_count, what_to_log,flush_time;
|
||||
extern ulong query_buff_size, thread_stack,thread_stack_min;
|
||||
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
|
||||
extern ulong max_binlog_size, rpl_recovery_rank, thread_cache_size;
|
||||
|
@ -208,9 +208,9 @@ const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
|
||||
const char *sql_mode_names[] =
|
||||
{
|
||||
"REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
|
||||
"SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
|
||||
"?", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
|
||||
"POSTGRESQL", "ORACLE", "MSSQL", "DB2", "SAPDB", "NO_KEY_OPTIONS",
|
||||
"NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40",
|
||||
"NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40", "ANSI",
|
||||
NullS
|
||||
};
|
||||
TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
|
||||
@ -324,6 +324,9 @@ MY_TMPDIR mysql_tmpdir_list;
|
||||
DATE_FORMAT dayord;
|
||||
MY_BITMAP temp_pool;
|
||||
|
||||
CHARSET_INFO *system_charset_info, *files_charset_info ;
|
||||
CHARSET_INFO *national_charset_info, *table_alias_charset;
|
||||
|
||||
SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam;
|
||||
SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
|
||||
SHOW_COMP_OPTION have_crypt, have_compress;
|
||||
@ -2281,9 +2284,7 @@ static void handle_connections_methods()
|
||||
#endif /* __NT__ */
|
||||
if (have_tcpip && !opt_disable_networking)
|
||||
{
|
||||
#ifdef __NT__
|
||||
handler_count++;
|
||||
#endif
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_sockets, 0))
|
||||
{
|
||||
@ -2294,9 +2295,7 @@ static void handle_connections_methods()
|
||||
#ifdef HAVE_SMEM
|
||||
if (opt_enable_shared_memory)
|
||||
{
|
||||
#ifdef __NT__
|
||||
handler_count++;
|
||||
#endif
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_shared_memory, 0))
|
||||
{
|
||||
@ -2311,6 +2310,16 @@ static void handle_connections_methods()
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
void decrement_handler_count()
|
||||
{
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
handler_count--;
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
pthread_cond_signal(&COND_handler_count);
|
||||
}
|
||||
#else
|
||||
#define decrement_handler_count()
|
||||
#endif /* defined(__NT__) || defined(HAVE_SMEM) */
|
||||
|
||||
|
||||
@ -2428,7 +2437,7 @@ The server will not act as a slave.");
|
||||
#endif
|
||||
/* init_slave() must be called after the thread keys are created */
|
||||
init_slave();
|
||||
|
||||
|
||||
if (opt_bootstrap)
|
||||
{
|
||||
int error=bootstrap(stdin);
|
||||
@ -3019,13 +3028,7 @@ extern "C" pthread_handler_decl(handle_connections_sockets,
|
||||
// kill server must be invoked from thread 1!
|
||||
kill_server(MYSQL_KILL_SIGNAL);
|
||||
#endif
|
||||
|
||||
#ifdef __NT__
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
handler_count--;
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
pthread_cond_signal(&COND_handler_count);
|
||||
#endif
|
||||
decrement_handler_count();
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@ -3105,10 +3108,7 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg)
|
||||
create_new_thread(thd);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
handler_count--;
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
pthread_cond_signal(&COND_handler_count);
|
||||
decrement_handler_count();
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif /* __NT__ */
|
||||
@ -3322,12 +3322,8 @@ error:
|
||||
if (!handle_connect_file_map) CloseHandle(handle_connect_file_map);
|
||||
if (!event_connect_answer) CloseHandle(event_connect_answer);
|
||||
if (!event_connect_request) CloseHandle(event_connect_request);
|
||||
#ifdef __NT__
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
handler_count--;
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
pthread_cond_signal(&COND_handler_count);
|
||||
#endif
|
||||
|
||||
decrement_handler_count();
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif /* HAVE_SMEM */
|
||||
@ -3921,7 +3917,7 @@ replicating a LOAD DATA INFILE command",
|
||||
(gptr*) &opt_sql_bin_update, (gptr*) &opt_sql_bin_update, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"sql-mode", OPT_SQL_MODE,
|
||||
"Syntax: sql-mode=option[,option[,option...]] where option can be one of: REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, SERIALIZE, ONLY_FULL_GROUP_BY, NO_UNSIGNED_SUBTRACTION.",
|
||||
"Syntax: sql-mode=option[,option[,option...]] where option can be one of: REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, ONLY_FULL_GROUP_BY, NO_UNSIGNED_SUBTRACTION.",
|
||||
(gptr*) &sql_mode_str, (gptr*) &sql_mode_str, 0, GET_STR, REQUIRED_ARG, 0,
|
||||
0, 0, 0, 0, 0},
|
||||
#ifdef HAVE_OPENSSL
|
||||
@ -4634,6 +4630,12 @@ static void mysql_init_variables(void)
|
||||
bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
|
||||
bzero((gptr) &com_stat, sizeof(com_stat));
|
||||
|
||||
/* Character sets */
|
||||
system_charset_info= &my_charset_utf8_general_ci;
|
||||
files_charset_info= &my_charset_utf8_general_ci;
|
||||
national_charset_info= &my_charset_utf8_general_ci;
|
||||
table_alias_charset= &my_charset_bin;
|
||||
|
||||
/* Things with default values that are not zero */
|
||||
delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
|
||||
opt_specialflag= SPECIAL_ENGLISH;
|
||||
@ -4684,6 +4686,7 @@ static void mysql_init_variables(void)
|
||||
sys_charset.value= (char*) MYSQL_CHARSET;
|
||||
sys_charset_system.value= (char*) system_charset_info->csname;
|
||||
|
||||
|
||||
/* Set default values for some option variables */
|
||||
global_system_variables.character_set_results= NULL;
|
||||
global_system_variables.character_set_client= default_charset_info;
|
||||
@ -4789,10 +4792,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
opt_endinfo=1; /* unireg: memory allocation */
|
||||
break;
|
||||
case 'a':
|
||||
global_system_variables.sql_mode=
|
||||
(MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT |
|
||||
MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE |
|
||||
MODE_ONLY_FULL_GROUP_BY);
|
||||
global_system_variables.sql_mode= fix_sql_mode(MODE_ANSI);
|
||||
global_system_variables.tx_isolation= ISO_SERIALIZABLE;
|
||||
break;
|
||||
case 'b':
|
||||
@ -5270,11 +5270,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
fprintf(stderr, "Unknown option to sql-mode: %s\n", argument);
|
||||
exit(1);
|
||||
}
|
||||
global_system_variables.tx_isolation=
|
||||
((global_system_variables.sql_mode & MODE_SERIALIZABLE) ?
|
||||
ISO_SERIALIZABLE :
|
||||
ISO_REPEATABLE_READ);
|
||||
break;
|
||||
global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
|
||||
sql_mode);
|
||||
}
|
||||
case OPT_MASTER_PASSWORD:
|
||||
master_password=argument;
|
||||
@ -5332,6 +5329,9 @@ static void get_options(int argc,char **argv)
|
||||
|
||||
/* Set global variables based on startup options */
|
||||
myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
|
||||
table_alias_charset= (lower_case_table_names ?
|
||||
files_charset_info :
|
||||
&my_charset_bin);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,13 @@
|
||||
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 is the net layer API for the MySQL client/server protocol,
|
||||
which is a tightly coupled, proprietary protocol owned by MySQL AB.
|
||||
Any re-implementations of this protocol must also be under GPL
|
||||
unless one has got an license from MySQL AB stating otherwise.
|
||||
*/
|
||||
|
||||
/*
|
||||
Write and read of logical packets to/from socket
|
||||
|
||||
|
@ -102,7 +102,8 @@ void send_error(THD *thd, uint sql_errno, const char *err)
|
||||
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
|
||||
{
|
||||
/* The first # is to make the protocol backward compatible */
|
||||
strmov(buff+2, "#000000");
|
||||
buff[2]= '#';
|
||||
strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
|
||||
pos= buff + 2 + SQLSTATE_LENGTH +1;
|
||||
}
|
||||
length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
|
||||
@ -222,8 +223,8 @@ net_printf(THD *thd, uint errcode, ...)
|
||||
int2store(pos, errcode);
|
||||
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
|
||||
{
|
||||
/* The first # is to make the protocol backward compatible */
|
||||
memcpy(pos+2, "#000000", SQLSTATE_LENGTH +1);
|
||||
pos[2]= '#'; /* To make the protocol backward compatible */
|
||||
memcpy(pos+3, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH);
|
||||
}
|
||||
}
|
||||
VOID(net_real_write(net,(char*) net->buff,length+head_length+1+offset));
|
||||
|
133
sql/set_var.cc
133
sql/set_var.cc
@ -89,6 +89,7 @@ static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type);
|
||||
static void fix_key_buffer_size(THD *thd, enum_var_type type);
|
||||
static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type);
|
||||
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
|
||||
void fix_sql_mode_var(THD *thd, enum_var_type type);
|
||||
static byte *get_error_count(THD *thd);
|
||||
static byte *get_warning_count(THD *thd);
|
||||
|
||||
@ -1164,40 +1165,6 @@ byte *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type)
|
||||
}
|
||||
|
||||
|
||||
byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type)
|
||||
{
|
||||
ulong val;
|
||||
char buff[256];
|
||||
String tmp(buff, sizeof(buff), &my_charset_latin1);
|
||||
my_bool found= 0;
|
||||
|
||||
tmp.length(0);
|
||||
val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
|
||||
thd->variables.*offset);
|
||||
for (uint i= 0; val; val>>= 1, i++)
|
||||
{
|
||||
if (val & 1)
|
||||
{
|
||||
tmp.append(enum_names->type_names[i]);
|
||||
tmp.append(',');
|
||||
}
|
||||
}
|
||||
if (tmp.length())
|
||||
tmp.length(tmp.length() - 1);
|
||||
return (byte*) thd->strmake(tmp.ptr(), tmp.length());
|
||||
}
|
||||
|
||||
|
||||
void sys_var_thd_sql_mode::set_default(THD *thd, enum_var_type type)
|
||||
{
|
||||
if (type == OPT_GLOBAL)
|
||||
global_system_variables.*offset= 0;
|
||||
else
|
||||
thd->variables.*offset= global_system_variables.*offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool sys_var_thd_bit::update(THD *thd, set_var *var)
|
||||
{
|
||||
int res= (*update_func)(thd, var);
|
||||
@ -1803,7 +1770,105 @@ int set_var_password::update(THD *thd)
|
||||
1 : 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Functions to handle sql_mode
|
||||
****************************************************************************/
|
||||
|
||||
byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type)
|
||||
{
|
||||
ulong val;
|
||||
char buff[256];
|
||||
String tmp(buff, sizeof(buff), &my_charset_latin1);
|
||||
my_bool found= 0;
|
||||
|
||||
tmp.length(0);
|
||||
val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
|
||||
thd->variables.*offset);
|
||||
for (uint i= 0; val; val>>= 1, i++)
|
||||
{
|
||||
if (val & 1)
|
||||
{
|
||||
tmp.append(enum_names->type_names[i]);
|
||||
tmp.append(',');
|
||||
}
|
||||
}
|
||||
if (tmp.length())
|
||||
tmp.length(tmp.length() - 1);
|
||||
return (byte*) thd->strmake(tmp.ptr(), tmp.length());
|
||||
}
|
||||
|
||||
|
||||
void sys_var_thd_sql_mode::set_default(THD *thd, enum_var_type type)
|
||||
{
|
||||
if (type == OPT_GLOBAL)
|
||||
global_system_variables.*offset= 0;
|
||||
else
|
||||
thd->variables.*offset= global_system_variables.*offset;
|
||||
}
|
||||
|
||||
void fix_sql_mode_var(THD *thd, enum_var_type type)
|
||||
{
|
||||
if (type == OPT_GLOBAL)
|
||||
global_system_variables.sql_mode=
|
||||
fix_sql_mode(global_system_variables.sql_mode);
|
||||
else
|
||||
thd->variables.sql_mode= fix_sql_mode(thd->variables.sql_mode);
|
||||
}
|
||||
|
||||
/* Map database specific bits to function bits */
|
||||
|
||||
ulong fix_sql_mode(ulong sql_mode)
|
||||
{
|
||||
/*
|
||||
Note that we dont set
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | MODE_NO_FIELD_OPTIONS
|
||||
to allow one to get full use of MySQL in this mode.
|
||||
*/
|
||||
|
||||
if (sql_mode & MODE_ANSI)
|
||||
sql_mode|= (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE | MODE_ONLY_FULL_GROUP_BY);
|
||||
if (sql_mode & MODE_ORACLE)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_MSSQL)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_MSSQL)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_POSTGRESQL)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_DB2)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_DB2)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_SAPDB)
|
||||
sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
||||
MODE_IGNORE_SPACE |
|
||||
MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS |
|
||||
MODE_NO_FIELD_OPTIONS);
|
||||
if (sql_mode & MODE_MYSQL40)
|
||||
sql_mode|= MODE_NO_FIELD_OPTIONS;
|
||||
if (sql_mode & MODE_MYSQL323)
|
||||
sql_mode|= MODE_NO_FIELD_OPTIONS;
|
||||
return sql_mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -309,11 +309,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
extern void fix_sql_mode_var(THD *thd, enum_var_type type);
|
||||
|
||||
class sys_var_thd_sql_mode :public sys_var_thd_enum
|
||||
{
|
||||
public:
|
||||
sys_var_thd_sql_mode(const char *name_arg, ulong SV::*offset_arg)
|
||||
:sys_var_thd_enum(name_arg, offset_arg, &sql_mode_typelib)
|
||||
:sys_var_thd_enum(name_arg, offset_arg, &sql_mode_typelib,
|
||||
fix_sql_mode_var)
|
||||
{}
|
||||
bool check(THD *thd, set_var *var)
|
||||
{
|
||||
@ -605,6 +608,7 @@ void set_var_free();
|
||||
sys_var *find_sys_var(const char *str, uint length=0);
|
||||
int sql_set_variables(THD *thd, List<set_var_base> *var_list);
|
||||
void fix_delay_key_write(THD *thd, enum_var_type type);
|
||||
ulong fix_sql_mode(ulong sql_mode);
|
||||
|
||||
extern sys_var_str sys_charset;
|
||||
extern sys_var_str sys_charset_system;
|
||||
|
@ -544,7 +544,8 @@ TABLE_LIST * find_table_in_list(TABLE_LIST *table,
|
||||
{
|
||||
for (; table; table= table->next)
|
||||
if ((!db_name || !strcmp(table->db, db_name)) &&
|
||||
(!table_name || !strcmp(table->alias, table_name)))
|
||||
(!table_name || !my_strcasecmp(table_alias_charset,
|
||||
table->alias, table_name)))
|
||||
break;
|
||||
return table;
|
||||
}
|
||||
@ -1739,7 +1740,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
|
||||
bool found_table=0;
|
||||
for (; tables ; tables=tables->next)
|
||||
{
|
||||
if (!strcmp(tables->alias,table_name) &&
|
||||
if (!my_strcasecmp(table_alias_charset, tables->alias, table_name) &&
|
||||
(!db || !tables->db || !tables->db[0] || !strcmp(db,tables->db)))
|
||||
{
|
||||
found_table=1;
|
||||
@ -1868,20 +1869,22 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
|
||||
{
|
||||
List_iterator<Item> li(items);
|
||||
Item **found=0,*item;
|
||||
const char *db_name=0;
|
||||
const char *field_name=0;
|
||||
const char *table_name=0;
|
||||
if (find->type() == Item::FIELD_ITEM || find->type() == Item::REF_ITEM)
|
||||
{
|
||||
field_name= ((Item_ident*) find)->field_name;
|
||||
table_name= ((Item_ident*) find)->table_name;
|
||||
db_name= ((Item_ident*) find)->db_name;
|
||||
}
|
||||
|
||||
for (uint i= 0; (item=li++); i++)
|
||||
{
|
||||
if (field_name && item->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
if (!my_strcasecmp(system_charset_info,
|
||||
((Item_field*) item)->name,field_name))
|
||||
Item_field *item_field= (Item_field*) item;
|
||||
if (!my_strcasecmp(system_charset_info, item_field->name, field_name))
|
||||
{
|
||||
if (!table_name)
|
||||
{
|
||||
@ -1897,11 +1900,16 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
|
||||
found= li.ref();
|
||||
*counter= i;
|
||||
}
|
||||
else if (!strcmp(((Item_field*) item)->table_name,table_name))
|
||||
else
|
||||
{
|
||||
found= li.ref();
|
||||
*counter= i;
|
||||
break;
|
||||
if (!strcmp(item_field->table_name,table_name) &&
|
||||
(!db_name || (db_name && item_field->db_name &&
|
||||
!strcmp(item_field->table_name,table_name))))
|
||||
{
|
||||
found= li.ref();
|
||||
*counter= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2094,7 +2102,8 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
|
||||
for (; tables ; tables=tables->next)
|
||||
{
|
||||
TABLE *table=tables->table;
|
||||
if (!table_name || (!strcmp(table_name,tables->alias) &&
|
||||
if (!table_name || (!my_strcasecmp(table_alias_charset, table_name,
|
||||
tables->alias) &&
|
||||
(!db_name || !strcmp(tables->db,db_name))))
|
||||
{
|
||||
/* Ensure that we have access right to all columns */
|
||||
|
@ -1432,7 +1432,8 @@ ulong Query_cache::init_cache()
|
||||
#else
|
||||
// windows, OS/2 or other case insensitive file names work around
|
||||
VOID(hash_init(&tables,
|
||||
lower_case_table_names ? &my_charset_bin : system_charset_info,
|
||||
lower_case_table_names ? &my_charset_bin :
|
||||
system_charset_info,
|
||||
def_table_hash_size, 0, 0,query_cache_table_get_key, 0, 0));
|
||||
#endif
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user