Merge abotchkov@work.mysql.com:/home/bk/mysql-4.1
into deer.mysql.r18.ru:/home/hf/work/mysql-default sql/item.cc: Auto merged sql/item.h: Auto merged sql/sql_yacc.yy: Auto merged
This commit is contained in:
commit
a831430e62
@ -26,6 +26,7 @@ hf@bison.(none)
|
||||
hf@bisonxp.(none)
|
||||
hf@deer.mysql.r18.ru
|
||||
hf@genie.(none)
|
||||
igor@hundin.mysql.fi
|
||||
jani@dsl-jkl1657.dial.inet.fi
|
||||
jani@dsl-kpogw4gb5.dial.inet.fi
|
||||
jani@hynda.(none)
|
||||
@ -95,6 +96,7 @@ tonu@hundin.mysql.fi
|
||||
tonu@volk.internalnet
|
||||
tonu@x153.internalnet
|
||||
tonu@x3.internalnet
|
||||
venu@hundin.mysql.fi
|
||||
venu@myvenu.com
|
||||
venu@work.mysql.com
|
||||
vva@eagle.mysql.r18.ru
|
||||
|
@ -30,7 +30,7 @@ extern const char *client_errors[]; /* Error messages */
|
||||
#define CR_MAX_ERROR 2999
|
||||
#if defined(OS2) && defined(MYSQL_SERVER)
|
||||
#define CER(X) client_errors[(X)-CR_MIN_ERROR]
|
||||
#else
|
||||
#elif !defined(ER)
|
||||
#define ER(X) client_errors[(X)-CR_MIN_ERROR]
|
||||
#endif
|
||||
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -587,7 +588,7 @@ extern int pthread_dummy(int);
|
||||
*/
|
||||
#define DEFAULT_THREAD_STACK (192*1024L)
|
||||
#else
|
||||
#define DEFAULT_THREAD_STACK (192*1024L)
|
||||
#define DEFAULT_THREAD_STACK (192*1024)
|
||||
#endif
|
||||
|
||||
struct st_my_thread_var
|
||||
@ -601,6 +602,8 @@ struct st_my_thread_var
|
||||
long id;
|
||||
int cmp_length;
|
||||
int volatile abort;
|
||||
struct st_my_thread_var *next,**prev;
|
||||
void *opt_info;
|
||||
#ifndef DBUG_OFF
|
||||
gptr dbug;
|
||||
char name[THREAD_NAME_SIZE+1];
|
||||
|
@ -470,6 +470,24 @@ int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
|
||||
/* statement state */
|
||||
enum PREP_STMT_STATE { MY_ST_UNKNOWN, MY_ST_PREPARE, MY_ST_EXECUTE };
|
||||
|
||||
/*
|
||||
client TIME structure to handle TIME, DATE and TIMESTAMP directly in
|
||||
binary protocol
|
||||
*/
|
||||
enum mysql_st_timestamp_type { MYSQL_TIMESTAMP_NONE, MYSQL_TIMESTAMP_DATE,
|
||||
MYSQL_TIMESTAMP_FULL, MYSQL_TIMESTAMP_TIME };
|
||||
|
||||
typedef struct mysql_st_time
|
||||
{
|
||||
unsigned int year,month,day,hour,minute,second;
|
||||
unsigned long second_part;
|
||||
my_bool neg;
|
||||
|
||||
enum mysql_st_timestamp_type time_type;
|
||||
|
||||
} MYSQL_TIME;
|
||||
|
||||
|
||||
/* bind structure */
|
||||
typedef struct st_mysql_bind
|
||||
{
|
||||
@ -481,7 +499,6 @@ typedef struct st_mysql_bind
|
||||
unsigned long buffer_length; /* buffer length */
|
||||
|
||||
/* The following are for internal use. Set by mysql_bind_param */
|
||||
unsigned long bind_length; /* Default length of data */
|
||||
unsigned int param_number; /* For null count and error messages */
|
||||
my_bool long_data_used; /* If used with mysql_send_long_data */
|
||||
void (*store_param_func)(NET *net, struct st_mysql_bind *param);
|
||||
@ -499,12 +516,9 @@ typedef struct st_mysql_stmt
|
||||
MYSQL_FIELD *fields; /* prepare meta info */
|
||||
LIST list; /* list to keep track of all stmts */
|
||||
char *query; /* query buffer */
|
||||
char *buffer; /* buffer to hold results */
|
||||
MEM_ROOT mem_root; /* root allocations */
|
||||
MYSQL_RES tmp_result; /* Used by mysql_prepare_result */
|
||||
unsigned long param_count; /* parameters count */
|
||||
unsigned long field_count; /* fields count */
|
||||
unsigned long buffer_length; /* long buffer alloced length */
|
||||
unsigned long stmt_id; /* Id for prepared statement */
|
||||
unsigned int last_errno; /* error code */
|
||||
enum PREP_STMT_STATE state; /* statement state */
|
||||
@ -535,6 +549,7 @@ my_bool STDCALL mysql_send_long_data(MYSQL_STMT *stmt,
|
||||
const char *data,
|
||||
unsigned long length);
|
||||
MYSQL_RES *STDCALL mysql_prepare_result(MYSQL_STMT *stmt);
|
||||
MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt);
|
||||
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
|
||||
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
|
||||
my_bool STDCALL mysql_more_results(MYSQL *mysql);
|
||||
|
@ -115,7 +115,6 @@ static sig_handler pipe_sig_handler(int sig);
|
||||
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
||||
const char *from, ulong length);
|
||||
static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
|
||||
static unsigned int get_binary_length(uint type);
|
||||
|
||||
static my_bool org_my_init_done=0;
|
||||
|
||||
@ -3952,6 +3951,27 @@ mysql_prepare_result(MYSQL_STMT *stmt)
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Returns parameter columns meta information in the form of
|
||||
resultset.
|
||||
*/
|
||||
|
||||
MYSQL_RES * STDCALL
|
||||
mysql_param_result(MYSQL_STMT *stmt)
|
||||
{
|
||||
DBUG_ENTER("mysql_param_result");
|
||||
|
||||
if (!stmt->param_count)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
/*
|
||||
TODO: Fix this when server sends the information.
|
||||
Till then keep a dummy prototype
|
||||
*/
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************
|
||||
Prepare-execute, and param handling
|
||||
@ -4056,9 +4076,74 @@ static void store_param_double(NET *net, MYSQL_BIND *param)
|
||||
net->write_pos+= 8;
|
||||
}
|
||||
|
||||
static void store_param_time(NET *net, MYSQL_BIND *param)
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *) param->buffer;
|
||||
char buff[15], *pos;
|
||||
uint length;
|
||||
|
||||
pos= buff+1;
|
||||
pos[0]= tm->neg ? 1: 0;
|
||||
int4store(pos+1, tm->day);
|
||||
pos[5]= (uchar) tm->hour;
|
||||
pos[6]= (uchar) tm->minute;
|
||||
pos[7]= (uchar) tm->second;
|
||||
int4store(pos+8, tm->second_part);
|
||||
if (tm->second_part)
|
||||
length= 11;
|
||||
else if (tm->hour || tm->minute || tm->second || tm->day)
|
||||
length= 8;
|
||||
else
|
||||
length= 0;
|
||||
buff[0]= (char) length++;
|
||||
memcpy((char *)net->write_pos, buff, length);
|
||||
net->write_pos+= length;
|
||||
}
|
||||
|
||||
static void net_store_datetime(NET *net, MYSQL_TIME *tm)
|
||||
{
|
||||
char buff[12], *pos;
|
||||
uint length;
|
||||
|
||||
pos= buff+1;
|
||||
|
||||
int2store(pos, tm->year);
|
||||
pos[2]= (uchar) tm->month;
|
||||
pos[3]= (uchar) tm->day;
|
||||
pos[4]= (uchar) tm->hour;
|
||||
pos[5]= (uchar) tm->minute;
|
||||
pos[6]= (uchar) tm->second;
|
||||
int4store(pos+7, tm->second_part);
|
||||
if (tm->second_part)
|
||||
length= 11;
|
||||
else if (tm->hour || tm->minute || tm->second)
|
||||
length= 7;
|
||||
else if (tm->year || tm->month || tm->day)
|
||||
length= 4;
|
||||
else
|
||||
length= 0;
|
||||
buff[0]= (char) length++;
|
||||
memcpy((char *)net->write_pos, buff, length);
|
||||
net->write_pos+= length;
|
||||
}
|
||||
|
||||
static void store_param_date(NET *net, MYSQL_BIND *param)
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *) param->buffer;
|
||||
tm->hour= tm->minute= tm->second= 0;
|
||||
tm->second_part= 0;
|
||||
net_store_datetime(net, tm);
|
||||
}
|
||||
|
||||
static void store_param_datetime(NET *net, MYSQL_BIND *param)
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *) param->buffer;
|
||||
net_store_datetime(net, tm);
|
||||
}
|
||||
|
||||
static void store_param_str(NET *net, MYSQL_BIND *param)
|
||||
{
|
||||
ulong length= *param->length;
|
||||
ulong length= min(*param->length, param->buffer_length);
|
||||
char *to= (char *) net_store_length((char *) net->write_pos, length);
|
||||
memcpy(to, param->buffer, length);
|
||||
net->write_pos= (uchar*) to+length;
|
||||
@ -4107,10 +4192,13 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param)
|
||||
{
|
||||
/*
|
||||
Param->length should ALWAYS point to the correct length for the type
|
||||
Either to the length pointer given by the user or param->bind_length
|
||||
Either to the length pointer given by the user or param->buffer_length
|
||||
*/
|
||||
if ((my_realloc_str(net, 9 + *param->length)))
|
||||
{
|
||||
set_stmt_error(stmt, CR_OUT_OF_MEMORY);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
(*param->store_param_func)(net, param);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
@ -4277,12 +4365,14 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
|
||||
param++)
|
||||
{
|
||||
param->param_number= count++;
|
||||
param->long_data_used= 0;
|
||||
|
||||
/*
|
||||
If param->length is not given, change it to point to bind_length.
|
||||
If param->length is not given, change it to point to buffer_length.
|
||||
This way we can always use *param->length to get the length of data
|
||||
*/
|
||||
if (!param->length)
|
||||
param->length= ¶m->bind_length;
|
||||
param->length= ¶m->buffer_length;
|
||||
|
||||
/* If param->is_null is not set, then the value can never be NULL */
|
||||
if (!param->is_null)
|
||||
@ -4295,42 +4385,52 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
|
||||
break;
|
||||
case MYSQL_TYPE_TINY:
|
||||
/* Force param->length as this is fixed for this type */
|
||||
param->length= ¶m->bind_length;
|
||||
param->bind_length= param->buffer_length= 1;
|
||||
param->length= ¶m->buffer_length;
|
||||
param->buffer_length= 1;
|
||||
param->store_param_func= store_param_tinyint;
|
||||
break;
|
||||
case MYSQL_TYPE_SHORT:
|
||||
param->length= ¶m->bind_length;
|
||||
param->bind_length= param->buffer_length= 2;
|
||||
param->length= ¶m->buffer_length;
|
||||
param->buffer_length= 2;
|
||||
param->store_param_func= store_param_short;
|
||||
break;
|
||||
case MYSQL_TYPE_LONG:
|
||||
param->length= ¶m->bind_length;
|
||||
param->bind_length= param->buffer_length= 4;
|
||||
param->length= ¶m->buffer_length;
|
||||
param->buffer_length= 4;
|
||||
param->store_param_func= store_param_int32;
|
||||
break;
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
param->length= ¶m->bind_length;
|
||||
param->bind_length= param->buffer_length= 8;
|
||||
param->length= ¶m->buffer_length;
|
||||
param->buffer_length= 8;
|
||||
param->store_param_func= store_param_int64;
|
||||
break;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
param->length= ¶m->bind_length;
|
||||
param->bind_length= param->buffer_length= 4;
|
||||
param->length= ¶m->buffer_length;
|
||||
param->buffer_length= 4;
|
||||
param->store_param_func= store_param_float;
|
||||
break;
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
param->length= ¶m->bind_length;
|
||||
param->bind_length= param->buffer_length= 8;
|
||||
param->length= ¶m->buffer_length;
|
||||
param->buffer_length= 8;
|
||||
param->store_param_func= store_param_double;
|
||||
break;
|
||||
case MYSQL_TYPE_TIME:
|
||||
/* Buffer length ignored for DATE, TIME and DATETIME */
|
||||
param->store_param_func= store_param_time;
|
||||
break;
|
||||
case MYSQL_TYPE_DATE:
|
||||
param->store_param_func= store_param_date;
|
||||
break;
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
param->store_param_func= store_param_datetime;
|
||||
break;
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
case MYSQL_TYPE_STRING:
|
||||
param->bind_length= param->buffer_length;
|
||||
param->store_param_func= store_param_str;
|
||||
break;
|
||||
default:
|
||||
@ -4440,24 +4540,91 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number,
|
||||
1 Error (Can't alloc net->buffer)
|
||||
****************************************************************************/
|
||||
|
||||
/* Return the default binary data length for the common types */
|
||||
static unsigned int get_binary_length(uint type)
|
||||
static void set_zero_time(MYSQL_TIME *tm)
|
||||
{
|
||||
switch(type) {
|
||||
case MYSQL_TYPE_TINY:
|
||||
return 1;
|
||||
case MYSQL_TYPE_SHORT:
|
||||
case MYSQL_TYPE_YEAR:
|
||||
return 2;
|
||||
case MYSQL_TYPE_LONG:
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
return 4;
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
return 8;
|
||||
default:
|
||||
tm->year= tm->month= tm->day= 0;
|
||||
tm->hour= tm->minute= tm->second= 0;
|
||||
tm->second_part= 0;
|
||||
tm->neg= (bool)0;
|
||||
}
|
||||
|
||||
/* Read TIME from binary packet and return it to MYSQL_TIME */
|
||||
static uint read_binary_time(MYSQL_TIME *tm, uchar **pos)
|
||||
{
|
||||
uchar *to;
|
||||
uint length;
|
||||
|
||||
if (!(length= net_field_length(pos)))
|
||||
{
|
||||
set_zero_time(tm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
to= *pos;
|
||||
tm->second_part= (length > 8 ) ? (ulong) sint4korr(to+7): 0;
|
||||
|
||||
tm->day= (ulong) sint4korr(to+1);
|
||||
tm->hour= (uint) to[5];
|
||||
tm->minute= (uint) to[6];
|
||||
tm->second= (uint) to[7];
|
||||
|
||||
tm->year= tm->month= 0;
|
||||
tm->neg= (bool)to[0];
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Read DATETIME from binary packet and return it to MYSQL_TIME */
|
||||
static uint read_binary_datetime(MYSQL_TIME *tm, uchar **pos)
|
||||
{
|
||||
uchar *to;
|
||||
uint length;
|
||||
|
||||
if (!(length= net_field_length(pos)))
|
||||
{
|
||||
set_zero_time(tm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
to= *pos;
|
||||
tm->second_part= (length > 7 ) ? (ulong) sint4korr(to+7): 0;
|
||||
|
||||
if (length > 4)
|
||||
{
|
||||
tm->hour= (uint) to[4];
|
||||
tm->minute= (uint) to[5];
|
||||
tm->second= (uint) to[6];
|
||||
}
|
||||
else
|
||||
tm->hour= tm->minute= tm->second= 0;
|
||||
|
||||
tm->year= (uint) sint2korr(to);
|
||||
tm->month= (uint) to[2];
|
||||
tm->day= (uint) to[3];
|
||||
tm->neg= 0;
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Read DATE from binary packet and return it to MYSQL_TIME */
|
||||
static uint read_binary_date(MYSQL_TIME *tm, uchar **pos)
|
||||
{
|
||||
uchar *to;
|
||||
uint length;
|
||||
|
||||
if (!(length= net_field_length(pos)))
|
||||
{
|
||||
set_zero_time(tm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
to= *pos;
|
||||
tm->year = (uint) sint2korr(to);
|
||||
tm->month= (uint) to[2];
|
||||
tm->day= (uint) to[3];
|
||||
|
||||
tm->hour= tm->minute= tm->second= 0;
|
||||
tm->second_part= 0;
|
||||
tm->neg= 0;
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Convert Numeric to buffer types */
|
||||
@ -4492,13 +4659,14 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
|
||||
}
|
||||
default:
|
||||
{
|
||||
uint length= sprintf(buffer,"%lld",value);
|
||||
uint length= (uint)(longlong10_to_str(value,buffer,10)-buffer);
|
||||
*param->length= length;
|
||||
buffer[length]='\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Convert Double to buffer types */
|
||||
static void send_data_double(MYSQL_BIND *param, double value)
|
||||
{
|
||||
@ -4531,7 +4699,7 @@ static void send_data_double(MYSQL_BIND *param, double value)
|
||||
}
|
||||
default:
|
||||
{
|
||||
uint length= sprintf(buffer,"%g",value);
|
||||
uint length= my_sprintf(buffer,(buffer,"%g",value));
|
||||
*param->length= length;
|
||||
buffer[length]='\0';
|
||||
}
|
||||
@ -4586,25 +4754,79 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length)
|
||||
}
|
||||
default:
|
||||
*param->length= length;
|
||||
length= min(length, param->buffer_length);
|
||||
memcpy(buffer, value, length);
|
||||
buffer[length]='\0';
|
||||
if (length != param->buffer_length)
|
||||
buffer[length]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime,
|
||||
uint length)
|
||||
{
|
||||
switch (param->buffer_type) {
|
||||
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_TIME:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer;
|
||||
|
||||
tm->year= ltime.year;
|
||||
tm->month= ltime.month;
|
||||
tm->day= ltime.day;
|
||||
|
||||
tm->hour= ltime.hour;
|
||||
tm->minute= ltime.minute;
|
||||
tm->second= ltime.second;
|
||||
|
||||
tm->second_part= ltime.second_part;
|
||||
tm->neg= ltime.neg;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
char buff[25];
|
||||
|
||||
if (!length)
|
||||
ltime.time_type= MYSQL_TIMESTAMP_NONE;
|
||||
switch (ltime.time_type) {
|
||||
case MYSQL_TIMESTAMP_DATE:
|
||||
length= my_sprintf(buff,(buff, "%04d-%02d-%02d", ltime.year,
|
||||
ltime.month,ltime.day));
|
||||
break;
|
||||
case MYSQL_TIMESTAMP_FULL:
|
||||
length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
ltime.year,ltime.month,ltime.day,
|
||||
ltime.hour,ltime.minute,ltime.second));
|
||||
break;
|
||||
case MYSQL_TIMESTAMP_TIME:
|
||||
length= my_sprintf(buff, (buff, "%02d:%02d:%02d",
|
||||
ltime.hour,ltime.minute,ltime.second));
|
||||
break;
|
||||
default:
|
||||
length= 0;
|
||||
buff[0]='\0';
|
||||
}
|
||||
send_data_str(param, (char *)buff, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Fetch data to buffers */
|
||||
static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
|
||||
uint field_type, uchar **row)
|
||||
static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row)
|
||||
{
|
||||
ulong length;
|
||||
|
||||
length= (ulong)get_binary_length(field_type);
|
||||
|
||||
switch (field_type) {
|
||||
case MYSQL_TYPE_TINY:
|
||||
{
|
||||
uchar value= (uchar) **row;
|
||||
send_data_long(param,(longlong)value);
|
||||
length= 1;
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_SHORT:
|
||||
@ -4612,18 +4834,21 @@ static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
|
||||
{
|
||||
short value= (short)sint2korr(*row);
|
||||
send_data_long(param,(longlong)value);
|
||||
length= 2;
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_LONG:
|
||||
{
|
||||
int32 value= (int32)sint4korr(*row);
|
||||
send_data_long(param,(int32)value);
|
||||
length= 4;
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
{
|
||||
longlong value= (longlong)sint8korr(*row);
|
||||
send_data_long(param,value);
|
||||
length= 8;
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
@ -4631,6 +4856,7 @@ static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
|
||||
float value;
|
||||
float4get(value,*row);
|
||||
send_data_double(param,(double)value);
|
||||
length= 4;
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
@ -4638,115 +4864,35 @@ static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
|
||||
double value;
|
||||
float8get(value,*row);
|
||||
send_data_double(param,(double)value);
|
||||
length= 8;
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
{
|
||||
uchar month,day;
|
||||
short year;
|
||||
int arg_length;
|
||||
char ts[50],frac[10],time[20],date[20];
|
||||
|
||||
if (!(length= net_field_length(row)))
|
||||
{
|
||||
*param->length= 0;
|
||||
break;
|
||||
}
|
||||
if (param->buffer_type < MYSQL_TYPE_VAR_STRING ||
|
||||
param->buffer_type > MYSQL_TYPE_STRING)
|
||||
{
|
||||
/*
|
||||
Don't allow fetching of date/time/ts to non-string types
|
||||
TODO: Allow fetching of date or time to long types.
|
||||
*/
|
||||
sprintf(stmt->last_error,
|
||||
ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE),
|
||||
param->buffer_type, param->param_number);
|
||||
return 1;
|
||||
}
|
||||
|
||||
arg_length= 0;
|
||||
if (length > 7)
|
||||
{
|
||||
int sec_part= sint4korr(*row+7);
|
||||
sprintf(frac,".%04d", sec_part);
|
||||
arg_length+= 5;
|
||||
}
|
||||
if (length == 7)
|
||||
{
|
||||
uchar hour, minute, sec;
|
||||
hour= *(*row+4);
|
||||
minute= *(*row+5);
|
||||
sec= *(*row+6);
|
||||
sprintf((char *)time," %02d:%02d:%02d",hour,minute,sec);
|
||||
arg_length+= 9;
|
||||
}
|
||||
|
||||
year= sint2korr(*row);
|
||||
month= *(*row+2);
|
||||
day= *(*row+3);
|
||||
sprintf((char*) date,"%04d-%02d-%02d",year,month,day);
|
||||
arg_length+= 10;
|
||||
|
||||
if (arg_length != 19)
|
||||
time[0]='\0';
|
||||
if (arg_length != 24)
|
||||
frac[0]='\0';
|
||||
|
||||
strxmov(ts,date,time,frac,NullS);
|
||||
send_data_str(param,ts,arg_length);
|
||||
MYSQL_TIME tm;
|
||||
|
||||
length= read_binary_date(&tm,row);
|
||||
tm.time_type= MYSQL_TIMESTAMP_DATE;
|
||||
send_data_time(param, tm, length);
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_TIME:
|
||||
{
|
||||
int day, arg_length;
|
||||
uchar hour, minute, sec;
|
||||
char ts[255], frac[20], time[20];
|
||||
const char *sign= "";
|
||||
|
||||
if (!(length= net_field_length(row)))
|
||||
{
|
||||
*param->length= 0;
|
||||
break;
|
||||
}
|
||||
if (param->buffer_type < MYSQL_TYPE_VAR_STRING ||
|
||||
param->buffer_type > MYSQL_TYPE_STRING)
|
||||
{
|
||||
/*
|
||||
Don't allow fetching of date/time/ts to non-string types
|
||||
|
||||
TODO: Allow fetching of time to long types without
|
||||
any conversion.
|
||||
*/
|
||||
sprintf(stmt->last_error,
|
||||
ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE),
|
||||
param->buffer_type, param->param_number);
|
||||
return 1;
|
||||
}
|
||||
arg_length= 0;
|
||||
if (length > 8)
|
||||
{
|
||||
int sec_part= sint4korr(*row+8);
|
||||
sprintf(frac,".%04d", sec_part);
|
||||
arg_length+= 5;
|
||||
}
|
||||
|
||||
if (**row)
|
||||
sign="-";
|
||||
|
||||
day= sint4korr(*row); /* TODO: how to handle this case */
|
||||
hour= *(*row+5);
|
||||
minute= *(*row+6);
|
||||
sec= *(*row+7);
|
||||
arg_length+= sprintf((char *)time,"%s%02d:%02d:%02d",sign,hour,minute,sec);
|
||||
|
||||
if (arg_length <= 9)
|
||||
frac[0]='\0';
|
||||
|
||||
strxmov(ts,time,frac,NullS);
|
||||
send_data_str(param,ts,arg_length);
|
||||
MYSQL_TIME tm;
|
||||
|
||||
length= read_binary_time(&tm, row);
|
||||
tm.time_type= MYSQL_TIMESTAMP_TIME;
|
||||
send_data_time(param, tm, length);
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
{
|
||||
MYSQL_TIME tm;
|
||||
|
||||
length= read_binary_datetime(&tm, row);
|
||||
tm.time_type= MYSQL_TIMESTAMP_FULL;
|
||||
send_data_time(param, tm, length);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -4755,7 +4901,6 @@ static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
|
||||
break;
|
||||
}
|
||||
*row+= length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fetch_result_tinyint(MYSQL_BIND *param, uchar **row)
|
||||
@ -4801,12 +4946,33 @@ static void fetch_result_double(MYSQL_BIND *param, uchar **row)
|
||||
*row+= 8;
|
||||
}
|
||||
|
||||
static void fetch_result_time(MYSQL_BIND *param, uchar **row)
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer;
|
||||
*row+= read_binary_time(tm, row);
|
||||
}
|
||||
|
||||
static void fetch_result_date(MYSQL_BIND *param, uchar **row)
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer;
|
||||
*row+= read_binary_date(tm, row);
|
||||
}
|
||||
|
||||
static void fetch_result_datetime(MYSQL_BIND *param, uchar **row)
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer;
|
||||
*row+= read_binary_datetime(tm, row);
|
||||
}
|
||||
|
||||
static void fetch_result_str(MYSQL_BIND *param, uchar **row)
|
||||
{
|
||||
ulong length= net_field_length(row);
|
||||
memcpy(param->buffer, (char *)*row, length);
|
||||
*(param->buffer+length)= '\0';
|
||||
*param->length= length;
|
||||
ulong copy_length= min(length, param->buffer_length);
|
||||
memcpy(param->buffer, (char *)*row, copy_length);
|
||||
/* Add an end null if there is room in the buffer */
|
||||
if (copy_length != param->buffer_length)
|
||||
*(param->buffer+copy_length)= '\0';
|
||||
*param->length= length; // return total length
|
||||
*row+= length;
|
||||
}
|
||||
|
||||
@ -4846,25 +5012,47 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
|
||||
if (!param->is_null)
|
||||
param->is_null= &int_is_null_dummy;
|
||||
|
||||
if (!param->length)
|
||||
param->length= ¶m->buffer_length;
|
||||
|
||||
/* Setup data copy functions for the different supported types */
|
||||
switch (param->buffer_type) {
|
||||
case MYSQL_TYPE_TINY:
|
||||
param->fetch_result= fetch_result_tinyint;
|
||||
*param->length= 1;
|
||||
break;
|
||||
case MYSQL_TYPE_SHORT:
|
||||
param->fetch_result= fetch_result_short;
|
||||
*param->length= 2;
|
||||
break;
|
||||
case MYSQL_TYPE_LONG:
|
||||
param->fetch_result= fetch_result_int32;
|
||||
*param->length= 4;
|
||||
break;
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
param->fetch_result= fetch_result_int64;
|
||||
*param->length= 8;
|
||||
break;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
param->fetch_result= fetch_result_float;
|
||||
*param->length= 4;
|
||||
break;
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
param->fetch_result= fetch_result_double;
|
||||
*param->length= 8;
|
||||
break;
|
||||
case MYSQL_TYPE_TIME:
|
||||
param->fetch_result= fetch_result_time;
|
||||
*param->length= sizeof(MYSQL_TIME);
|
||||
break;
|
||||
case MYSQL_TYPE_DATE:
|
||||
param->fetch_result= fetch_result_date;
|
||||
*param->length= sizeof(MYSQL_TIME);
|
||||
break;
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
param->fetch_result= fetch_result_datetime;
|
||||
*param->length= sizeof(MYSQL_TIME);
|
||||
break;
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
@ -4881,9 +5069,6 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
|
||||
param->buffer_type, param->param_number);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (!param->length)
|
||||
param->length= ¶m->bind_length;
|
||||
*param->length= (long)get_binary_length(param->buffer_type);
|
||||
}
|
||||
stmt->res_buffers= 1;
|
||||
DBUG_RETURN(0);
|
||||
@ -4920,8 +5105,8 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
|
||||
*bind->is_null= 0;
|
||||
if (field->type == bind->buffer_type)
|
||||
(*bind->fetch_result)(bind, &row);
|
||||
else if (fetch_results(stmt, bind, field->type, &row))
|
||||
return 1;
|
||||
else
|
||||
fetch_results(bind, field->type, &row);
|
||||
}
|
||||
if (! ((bit<<=1) & 255))
|
||||
{
|
||||
@ -5052,7 +5237,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL *mysql= stmt->mysql;
|
||||
MYSQL_RES *result;
|
||||
DBUG_ENTER("mysql_stmt_tore_result");
|
||||
DBUG_ENTER("mysql_stmt_store_result");
|
||||
|
||||
mysql= mysql->last_used_con;
|
||||
|
||||
@ -5060,9 +5245,8 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
||||
DBUG_RETURN(0);
|
||||
if (mysql->status != MYSQL_STATUS_GET_RESULT)
|
||||
{
|
||||
strmov(mysql->net.last_error,
|
||||
ER(mysql->net.last_errno= CR_COMMANDS_OUT_OF_SYNC));
|
||||
DBUG_RETURN(0);
|
||||
set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
mysql->status= MYSQL_STATUS_READY; /* server is ready */
|
||||
if (!(result= (MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+
|
||||
@ -5070,8 +5254,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
||||
stmt->field_count),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
{
|
||||
mysql->net.last_errno= CR_OUT_OF_MEMORY;
|
||||
strmov(mysql->net.last_error, ER(mysql->net.last_errno));
|
||||
set_stmt_error(stmt, CR_OUT_OF_MEMORY);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
stmt->result_buffered= 1;
|
||||
@ -5106,7 +5289,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
||||
*/
|
||||
static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
||||
{
|
||||
my_bool error=0;
|
||||
my_bool error= 0;
|
||||
DBUG_ENTER("mysql_stmt_close");
|
||||
|
||||
DBUG_ASSERT(stmt != 0);
|
||||
@ -5116,12 +5299,14 @@ static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
|
||||
int4store(buff, stmt->stmt_id);
|
||||
error= simple_command(stmt->mysql, COM_CLOSE_STMT, buff, 4, 1);
|
||||
}
|
||||
mysql_free_result(stmt->result);
|
||||
free_root(&stmt->mem_root, MYF(0));
|
||||
my_free((gptr) stmt->query, MYF(MY_WME | MY_ALLOW_ZERO_PTR));
|
||||
if (!skip_list)
|
||||
stmt->mysql->stmts= list_delete(stmt->mysql->stmts, &stmt->list);
|
||||
my_free((gptr) stmt, MYF(MY_WME));
|
||||
if (!error)
|
||||
{
|
||||
mysql_free_result(stmt->result);
|
||||
free_root(&stmt->mem_root, MYF(0));
|
||||
if (!skip_list)
|
||||
stmt->mysql->stmts= list_delete(stmt->mysql->stmts, &stmt->list);
|
||||
my_free((gptr) stmt, MYF(MY_WME));
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,9 @@ static bool check_user(THD *thd, enum_server_command command,
|
||||
char * get_mysql_home(){ return mysql_home;};
|
||||
char * get_mysql_real_data_home(){ return mysql_real_data_home;};
|
||||
|
||||
my_bool simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
|
||||
ulong length, my_bool skipp_check)
|
||||
my_bool simple_command(MYSQL *mysql,enum enum_server_command command,
|
||||
const char *arg,
|
||||
ulong length, my_bool skipp_check)
|
||||
{
|
||||
my_bool result= 1;
|
||||
THD *thd=(THD *) mysql->thd;
|
||||
@ -56,7 +57,8 @@ my_bool simple_command(MYSQL *mysql,enum enum_server_command command, const char
|
||||
/* Check that we are calling the client functions in right order */
|
||||
if (mysql->status != MYSQL_STATUS_READY)
|
||||
{
|
||||
strmov(thd->net.last_error,ER(thd->net.last_errno=CR_COMMANDS_OUT_OF_SYNC));
|
||||
strmov(thd->net.last_error,
|
||||
ER(thd->net.last_errno=CR_COMMANDS_OUT_OF_SYNC));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -199,7 +201,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
|
||||
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
|
||||
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
|
||||
|
||||
if (init_thread_environement())
|
||||
if (init_thread_environment())
|
||||
{
|
||||
mysql_server_end();
|
||||
return 1;
|
||||
|
@ -329,7 +329,11 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
|
||||
{
|
||||
*pos=ft_keysegs[j];
|
||||
pos[0].language= pos[-1].language;
|
||||
pos[0].charset= pos[-1].charset;
|
||||
if (!(pos[0].charset= pos[-1].charset))
|
||||
{
|
||||
my_errno=HA_ERR_CRASHED;
|
||||
goto err;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ create table t1 (i int, j int);
|
||||
insert into t1 values (1,2), (3,4), (5,6), (7,8);
|
||||
select count(*) 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
|
||||
-6510615555426900571 -6510615555426900571 -6510615555426900571 -6510615555426900571
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
drop table if exists t1;
|
||||
select row(1,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
|
||||
row(1,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3))
|
||||
select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3));
|
||||
(1,2,3) IN ((3,2,3), (1,2,3), (1,3,3))
|
||||
1
|
||||
select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
|
||||
row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3))
|
||||
@ -32,14 +32,23 @@ NULL
|
||||
select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
|
||||
row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3))
|
||||
0
|
||||
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,4)));
|
||||
row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,4)))
|
||||
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)
|
||||
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
|
||||
SELECT (1,2,3)=(0,NULL,3);
|
||||
(1,2,3)=(0,NULL,3)
|
||||
0
|
||||
SELECT (1,2,3)=(1,NULL,3);
|
||||
(1,2,3)=(1,NULL,3)
|
||||
NULL
|
||||
SELECT (1,2,3)=(1,NULL,0);
|
||||
(1,2,3)=(1,NULL,0)
|
||||
NULL
|
||||
SELECT ROW(1,2,3)=ROW(1,2,3);
|
||||
ROW(1,2,3)=ROW(1,2,3)
|
||||
1
|
||||
@ -132,4 +141,6 @@ select 1 from t1 where ROW(1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
select count(*) from t1 order by ROW(1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
select count(*) from t1 having (1,1) order by i;
|
||||
Cardinality error (more/less than 1 columns)
|
||||
drop table t1;
|
||||
|
@ -3,7 +3,7 @@
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
select row(1,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
|
||||
select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3));
|
||||
select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
|
||||
select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
|
||||
select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
|
||||
@ -14,11 +14,16 @@ select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
|
||||
select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
|
||||
select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3));
|
||||
select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
|
||||
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,4)));
|
||||
select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)));
|
||||
-- error 1239
|
||||
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
|
||||
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
|
||||
|
||||
SELECT (1,2,3)=(0,NULL,3);
|
||||
SELECT (1,2,3)=(1,NULL,3);
|
||||
# here's something for Sanja to fix :)
|
||||
SELECT (1,2,3)=(1,NULL,0);
|
||||
|
||||
SELECT ROW(1,2,3)=ROW(1,2,3);
|
||||
SELECT ROW(2,2,3)=ROW(1+1,2,3);
|
||||
SELECT ROW(1,2,3)=ROW(1+1,2,3);
|
||||
@ -58,9 +63,7 @@ create table t1 (i int);
|
||||
select 1 from t1 where ROW(1,1);
|
||||
-- error 1239
|
||||
select count(*) from t1 order by ROW(1,1);
|
||||
#TODO remove comments after parser fixing
|
||||
#-- error 1239
|
||||
#select count(*) from t1 order by i having (1,1);
|
||||
#-- error 1239
|
||||
#select 1 from t1 limit (1,1), (1,1);
|
||||
-- error 1239
|
||||
select count(*) from t1 having (1,1) order by i;
|
||||
drop table t1;
|
||||
|
||||
|
2359
mysys/mf_keycache.c
2359
mysys/mf_keycache.c
File diff suppressed because it is too large
Load Diff
51
sql/field.cc
51
sql/field.cc
@ -1652,11 +1652,10 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
long tmp;
|
||||
int error= 0;
|
||||
char *end;
|
||||
/* TODO: Make multi-byte-character safe */
|
||||
while (len && my_isspace(cs,*from))
|
||||
{
|
||||
len--; from++;
|
||||
}
|
||||
|
||||
tmp= cs->scan(cs, from, from+len, MY_SEQ_SPACES);
|
||||
len-= tmp;
|
||||
from+= tmp;
|
||||
my_errno=0;
|
||||
if (unsigned_flag)
|
||||
{
|
||||
@ -1910,11 +1909,10 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
longlong tmp;
|
||||
int error= 0;
|
||||
char *end;
|
||||
/* TODO: Make multi byte safe */
|
||||
while (len && my_isspace(cs,*from))
|
||||
{ // For easy error check
|
||||
len--; from++;
|
||||
}
|
||||
|
||||
tmp= cs->scan(cs, from, from+len, MY_SEQ_SPACES);
|
||||
len-= tmp;
|
||||
from+= tmp;
|
||||
my_errno=0;
|
||||
if (unsigned_flag)
|
||||
{
|
||||
@ -3878,14 +3876,6 @@ void Field_datetime::sql_type(String &res) const
|
||||
int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
int error= 0;
|
||||
#ifdef USE_TIS620
|
||||
if (!binary()) {
|
||||
ThNormalize((uchar *)ptr, field_length, (uchar *)from, length);
|
||||
if (length < field_length) {
|
||||
bfill(ptr + length, field_length - length, ' ');
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (length <= field_length)
|
||||
{
|
||||
memcpy(ptr,from,length);
|
||||
@ -3909,7 +3899,6 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* USE_TIS620 */
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -4062,12 +4051,6 @@ uint Field_string::max_packed_col_length(uint max_length)
|
||||
int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
int error= 0;
|
||||
#ifdef USE_TIS620
|
||||
if (!binary())
|
||||
{
|
||||
ThNormalize((uchar *) ptr+2, field_length, (uchar *) from, length);
|
||||
}
|
||||
#else
|
||||
if (length > field_length)
|
||||
{
|
||||
length=field_length;
|
||||
@ -4075,7 +4058,6 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
error= 1;
|
||||
}
|
||||
memcpy(ptr+2,from,length);
|
||||
#endif /* USE_TIS620 */
|
||||
int2store(ptr, length);
|
||||
return error;
|
||||
}
|
||||
@ -4376,28 +4358,11 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_TIS620
|
||||
char *th_ptr=0;
|
||||
#endif
|
||||
Field_blob::store_length(len);
|
||||
if (table->copy_blobs || len <= MAX_FIELD_WIDTH)
|
||||
{ // Must make a copy
|
||||
#ifdef USE_TIS620
|
||||
if (!binary())
|
||||
{
|
||||
/* If there isn't enough memory, use original string */
|
||||
if ((th_ptr=(char * ) my_malloc(sizeof(char) * len,MYF(0))))
|
||||
{
|
||||
ThNormalize((uchar *) th_ptr, len, (uchar *) from, len);
|
||||
from= (const char*) th_ptr;
|
||||
}
|
||||
}
|
||||
#endif /* USE_TIS620 */
|
||||
value.copy(from,len,charset());
|
||||
from=value.ptr();
|
||||
#ifdef USE_TIS620
|
||||
my_free(th_ptr,MYF(MY_ALLOW_ZERO_PTR));
|
||||
#endif
|
||||
}
|
||||
bmove(ptr+packlength,(char*) &from,sizeof(char*));
|
||||
}
|
||||
|
@ -1671,19 +1671,32 @@ build_template(
|
||||
templ = prebuilt->mysql_template + n_requested_fields;
|
||||
field = table->field[i];
|
||||
|
||||
if (templ_type == ROW_MYSQL_REC_FIELDS
|
||||
&& prebuilt->read_just_key
|
||||
&& dict_index_get_nth_col_pos(index, i)
|
||||
== ULINT_UNDEFINED) {
|
||||
/* Skip a column which is not in the index */
|
||||
|
||||
goto skip_field;
|
||||
}
|
||||
|
||||
|
||||
/* TODO: we have removed temporarily the test of which columns
|
||||
to fetch, until the new client/server protocol of 4.1
|
||||
is fixed!!!!!!!!!!!!!!!!!
|
||||
|
||||
if (templ_type == ROW_MYSQL_REC_FIELDS
|
||||
&& !(fetch_all_in_key &&
|
||||
ULINT_UNDEFINED != dict_index_get_nth_col_pos(
|
||||
index, i))
|
||||
ULINT_UNDEFINED != dict_index_get_nth_col_pos(
|
||||
index, i))
|
||||
&& thd->query_id != field->query_id
|
||||
&& thd->query_id != (field->query_id ^ MAX_ULONG_BIT)
|
||||
&& thd->query_id !=
|
||||
(field->query_id ^ (MAX_ULONG_BIT >> 1))) {
|
||||
|
||||
/* This field is not needed in the query, skip it */
|
||||
|
||||
goto skip_field;
|
||||
}
|
||||
*/
|
||||
|
||||
n_requested_fields++;
|
||||
|
||||
|
29
sql/item.cc
29
sql/item.cc
@ -347,6 +347,25 @@ void Item_param::set_value(const char *str, uint length)
|
||||
}
|
||||
|
||||
|
||||
void Item_param::set_time(TIME *tm, timestamp_type type)
|
||||
{
|
||||
ltime.year= tm->year;
|
||||
ltime.month= tm->month;
|
||||
ltime.day= tm->day;
|
||||
|
||||
ltime.hour= tm->hour;
|
||||
ltime.minute= tm->minute;
|
||||
ltime.second= tm->second;
|
||||
|
||||
ltime.second_part= tm->second_part;
|
||||
|
||||
ltime.time_type= type;
|
||||
|
||||
item_is_time= true;
|
||||
item_type= STRING_ITEM;
|
||||
}
|
||||
|
||||
|
||||
void Item_param::set_longdata(const char *str, ulong length)
|
||||
{
|
||||
str_value.append(str,length);
|
||||
@ -369,11 +388,21 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
double nr=val();
|
||||
return (field->store(nr)) ? -1 : 0;
|
||||
}
|
||||
if (item_is_time)
|
||||
{
|
||||
field->store_time(<ime, ltime.time_type);
|
||||
return 0;
|
||||
}
|
||||
String *result=val_str(&str_value);
|
||||
return (field->store(result->ptr(),result->length(),field->charset())) ? -1 : 0;
|
||||
}
|
||||
|
||||
bool Item_param::get_time(TIME *res)
|
||||
{
|
||||
*res=ltime;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Item_param::val()
|
||||
{
|
||||
|
@ -202,9 +202,11 @@ class Item_param :public Item
|
||||
public:
|
||||
longlong int_value;
|
||||
double real_value;
|
||||
TIME ltime;
|
||||
enum Item_result item_result_type;
|
||||
enum Type item_type;
|
||||
enum enum_field_types buffer_type;
|
||||
bool item_is_time;
|
||||
my_bool long_data_supplied;
|
||||
|
||||
Item_param(char *name_par=0)
|
||||
@ -213,6 +215,7 @@ public:
|
||||
long_data_supplied= false;
|
||||
item_type= STRING_ITEM;
|
||||
item_result_type = STRING_RESULT;
|
||||
item_is_time= false;
|
||||
}
|
||||
enum Type type() const { return item_type; }
|
||||
double val();
|
||||
@ -227,6 +230,8 @@ public:
|
||||
void set_long_binary(const char *str, ulong length);
|
||||
void set_longdata(const char *str, ulong length);
|
||||
void set_long_end();
|
||||
void set_time(TIME *tm, timestamp_type type);
|
||||
bool get_time(TIME *tm);
|
||||
void reset() {}
|
||||
void (*setup_param_func)(Item_param *param, uchar **pos);
|
||||
enum Item_result result_type () const
|
||||
@ -556,12 +561,12 @@ public:
|
||||
#include "spatial.h"
|
||||
#include "item_sum.h"
|
||||
#include "item_func.h"
|
||||
#include "item_row.h"
|
||||
#include "item_cmpfunc.h"
|
||||
#include "item_strfunc.h"
|
||||
#include "item_timefunc.h"
|
||||
#include "item_uniq.h"
|
||||
#include "item_subselect.h"
|
||||
#include "item_row.h"
|
||||
|
||||
class Item_copy_string :public Item
|
||||
{
|
||||
|
@ -392,51 +392,44 @@ longlong Item_func_strcmp::val_int()
|
||||
return !value ? 0 : (value < 0 ? (longlong) -1 : (longlong) 1);
|
||||
}
|
||||
|
||||
|
||||
void Item_func_interval::fix_length_and_dec()
|
||||
{
|
||||
bool nums=1;
|
||||
uint i;
|
||||
for (i=0 ; i < arg_count ; i++)
|
||||
if (row->cols() > 8)
|
||||
{
|
||||
if (!args[i])
|
||||
return; // End of memory
|
||||
if (args[i]->type() != Item::INT_ITEM &&
|
||||
args[i]->type() != Item::REAL_ITEM)
|
||||
bool consts=1;
|
||||
|
||||
for (uint i=1 ; consts && i < row->cols() ; i++)
|
||||
{
|
||||
nums=0;
|
||||
break;
|
||||
consts&= row->el(i)->const_item();
|
||||
}
|
||||
}
|
||||
if (nums && arg_count >= 8)
|
||||
{
|
||||
if ((intervals=(double*) sql_alloc(sizeof(double)*arg_count)))
|
||||
|
||||
if (consts &&
|
||||
(intervals=(double*) sql_alloc(sizeof(double)*(row->cols()-1))))
|
||||
{
|
||||
for (i=0 ; i < arg_count ; i++)
|
||||
intervals[i]=args[i]->val();
|
||||
for (uint i=1 ; i < row->cols(); i++)
|
||||
intervals[i-1]=row->el(i)->val();
|
||||
}
|
||||
}
|
||||
maybe_null= 0;
|
||||
max_length= 2;
|
||||
used_tables_cache|=item->used_tables();
|
||||
}
|
||||
|
||||
/*
|
||||
return -1 if null value,
|
||||
0 if lower than lowest
|
||||
1 - arg_count if between args[n] and args[n+1]
|
||||
arg_count+1 if higher than biggest argument
|
||||
1 - arg_count-1 if between args[n] and args[n+1]
|
||||
arg_count if higher than biggest argument
|
||||
*/
|
||||
|
||||
longlong Item_func_interval::val_int()
|
||||
{
|
||||
double value=item->val();
|
||||
if (item->null_value)
|
||||
return -1; // -1 if null /* purecov: inspected */
|
||||
double value=row->el(0)->val();
|
||||
if (row->el(0)->null_value)
|
||||
return -1; // -1 if null
|
||||
if (intervals)
|
||||
{ // Use binary search to find interval
|
||||
uint start,end;
|
||||
start=0; end=arg_count-1;
|
||||
start=1; end=row->cols()-2;
|
||||
while (start != end)
|
||||
{
|
||||
uint mid=(start+end+1)/2;
|
||||
@ -447,31 +440,14 @@ longlong Item_func_interval::val_int()
|
||||
}
|
||||
return (value < intervals[start]) ? 0 : start+1;
|
||||
}
|
||||
if (args[0]->val() > value)
|
||||
return 0;
|
||||
for (uint i=1 ; i < arg_count ; i++)
|
||||
|
||||
uint i;
|
||||
for (i=1 ; i < row->cols() ; i++)
|
||||
{
|
||||
if (args[i]->val() > value)
|
||||
return i;
|
||||
if (row->el(i)->val() > value)
|
||||
return i-1;
|
||||
}
|
||||
return (longlong) arg_count;
|
||||
}
|
||||
|
||||
|
||||
void Item_func_interval::update_used_tables()
|
||||
{
|
||||
Item_func::update_used_tables();
|
||||
item->update_used_tables();
|
||||
used_tables_cache|=item->used_tables();
|
||||
const_item_cache&=item->const_item();
|
||||
}
|
||||
|
||||
bool Item_func_interval::check_loop(uint id)
|
||||
{
|
||||
DBUG_ENTER("Item_func_interval::check_loop");
|
||||
if (Item_func::check_loop(id))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(item->check_loop(id));
|
||||
return i-1;
|
||||
}
|
||||
|
||||
void Item_func_between::fix_length_and_dec()
|
||||
|
@ -267,27 +267,14 @@ public:
|
||||
|
||||
class Item_func_interval :public Item_int_func
|
||||
{
|
||||
Item *item;
|
||||
Item_row *row;
|
||||
double *intervals;
|
||||
public:
|
||||
Item_func_interval(Item *a,List<Item> &list)
|
||||
:Item_int_func(list),item(a),intervals(0) {}
|
||||
Item_func_interval(Item_row *a)
|
||||
:Item_int_func(a),row(a),intervals(0) { allowed_arg_cols= a->cols(); }
|
||||
longlong val_int();
|
||||
bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref)
|
||||
{
|
||||
return (item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
|
||||
Item_func::fix_fields(thd, tlist, ref));
|
||||
}
|
||||
void fix_length_and_dec();
|
||||
~Item_func_interval() { delete item; }
|
||||
const char *func_name() const { return "interval"; }
|
||||
void update_used_tables();
|
||||
bool check_loop(uint id);
|
||||
void set_outer_resolving()
|
||||
{
|
||||
item->set_outer_resolving();
|
||||
Item_func::set_outer_resolving();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -2014,9 +2014,8 @@ String *Item_func_conv_charset::val_str(String *str)
|
||||
d0=d=(unsigned char*)str->ptr();
|
||||
de=d+dmaxlen;
|
||||
|
||||
while (s < se && d < de)
|
||||
while (1)
|
||||
{
|
||||
|
||||
cnvres=from->mb_wc(from,&wc,s,se);
|
||||
if (cnvres>0)
|
||||
{
|
||||
@ -2089,8 +2088,8 @@ String *Item_func_conv_charset3::val_str(String *str)
|
||||
d0=d=(unsigned char*)str->ptr();
|
||||
de=d+dmaxlen;
|
||||
|
||||
while (s < se && d < de){
|
||||
|
||||
while (1)
|
||||
{
|
||||
cnvres=from_charset->mb_wc(from_charset,&wc,s,se);
|
||||
if (cnvres>0)
|
||||
{
|
||||
|
282
sql/mysqld.cc
282
sql/mysqld.cc
@ -670,6 +670,7 @@ static void close_connections(void)
|
||||
}
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
|
||||
static void close_server_sock()
|
||||
{
|
||||
#ifdef HAVE_CLOSE_SERVER_SOCK
|
||||
@ -760,8 +761,6 @@ void kill_mysql(void)
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
/* Force server down. kill all connections and threads and exit */
|
||||
|
||||
#if defined(OS2)
|
||||
@ -777,7 +776,7 @@ static void __cdecl kill_server(int sig_ptr)
|
||||
{
|
||||
int sig=(int) (long) sig_ptr; // This is passed a int
|
||||
DBUG_ENTER("kill_server");
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
// if there is a signal during the kill in progress, ignore the other
|
||||
if (kill_in_progress) // Safety
|
||||
RETURN_FROM_KILL_SERVER;
|
||||
@ -798,19 +797,17 @@ static void __cdecl kill_server(int sig_ptr)
|
||||
else
|
||||
unireg_end();
|
||||
pthread_exit(0); /* purecov: deadcode */
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
RETURN_FROM_KILL_SERVER;
|
||||
}
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
#ifdef USE_ONE_SIGNAL_HAND
|
||||
extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
|
||||
{
|
||||
SHUTDOWN_THD;
|
||||
my_thread_init(); // Initialize new thread
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
kill_server(0);
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
my_thread_end(); // Normally never reached
|
||||
return 0;
|
||||
}
|
||||
@ -1047,6 +1044,7 @@ static void set_root(const char *path)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void server_init(void)
|
||||
{
|
||||
struct sockaddr_in IPaddr;
|
||||
@ -1158,7 +1156,7 @@ static void server_init(void)
|
||||
{
|
||||
DBUG_PRINT("general",("UNIX Socket is %s",mysql_unix_port));
|
||||
|
||||
if ((unix_sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
sql_perror("Can't start server : UNIX Socket "); /* purecov: inspected */
|
||||
unireg_abort(1); /* purecov: inspected */
|
||||
@ -1201,6 +1199,7 @@ void yyerror(const char *s)
|
||||
thd->lex.yylineno);
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
void close_connection(NET *net,uint errcode,bool lock)
|
||||
{
|
||||
@ -1221,7 +1220,8 @@ void close_connection(NET *net,uint errcode,bool lock)
|
||||
(void) pthread_mutex_unlock(&LOCK_thread_count);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#endif
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
/* Called when a thread is aborted */
|
||||
/* ARGSUSED */
|
||||
@ -1772,7 +1772,7 @@ extern "C" pthread_handler_decl(handle_shutdown,arg)
|
||||
PeekMessage(&msg, NULL, 1, 65534,PM_NOREMOVE);
|
||||
#if !defined(EMBEDDED_LIBRARY)
|
||||
if (WaitForSingleObject(hEventShutdown,INFINITE)==WAIT_OBJECT_0)
|
||||
#endif
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
kill_server(MYSQL_KILL_SIGNAL);
|
||||
return 0;
|
||||
}
|
||||
@ -1789,6 +1789,7 @@ int __stdcall handle_kill(ulong ctrl_type)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef OS2
|
||||
extern "C" pthread_handler_decl(handle_shutdown,arg)
|
||||
{
|
||||
@ -1856,8 +1857,8 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
|
||||
}
|
||||
|
||||
|
||||
static int init_common_variables(const char *conf_file_name, int argc, char **argv,
|
||||
const char **groups)
|
||||
static int init_common_variables(const char *conf_file_name, int argc,
|
||||
char **argv, const char **groups)
|
||||
{
|
||||
my_umask=0660; // Default umask for new files
|
||||
my_umask_dir=0700; // Default umask for new directories
|
||||
@ -1943,12 +1944,12 @@ static int init_common_variables(const char *conf_file_name, int argc, char **ar
|
||||
charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
|
||||
|
||||
if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_thread_environement()
|
||||
|
||||
static int init_thread_environment()
|
||||
{
|
||||
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
|
||||
(void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
|
||||
@ -1966,9 +1967,6 @@ static int init_thread_environement()
|
||||
(void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
|
||||
#ifdef HAVE_REPLICATION
|
||||
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
|
||||
#endif
|
||||
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
|
||||
(void) my_rwlock_init(&LOCK_grant, NULL);
|
||||
@ -1978,14 +1976,16 @@ static int init_thread_environement()
|
||||
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
|
||||
(void) pthread_cond_init(&COND_manager,NULL);
|
||||
#ifdef HAVE_REPLICATION
|
||||
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
|
||||
(void) pthread_cond_init(&COND_rpl_status, NULL);
|
||||
#endif
|
||||
/* Parameter for threads created for connections */
|
||||
(void) pthread_attr_init(&connection_attrib);
|
||||
(void) pthread_attr_setdetachstate(&connection_attrib,
|
||||
PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setstacksize(&connection_attrib,thread_stack);
|
||||
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
|
||||
|
||||
if (pthread_key_create(&THR_THD,NULL) ||
|
||||
pthread_key_create(&THR_MALLOC,NULL))
|
||||
@ -1993,12 +1993,10 @@ static int init_thread_environement()
|
||||
sql_print_error("Can't create thread-keys");
|
||||
return 1;
|
||||
}
|
||||
|
||||
(void) thr_setconcurrency(concurrency); // 10 by default
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void init_ssl()
|
||||
{
|
||||
#ifdef HAVE_OPENSSL
|
||||
@ -2017,6 +2015,7 @@ static void init_ssl()
|
||||
#endif /* HAVE_OPENSSL */
|
||||
}
|
||||
|
||||
|
||||
static int init_server_components()
|
||||
{
|
||||
table_cache_init();
|
||||
@ -2039,15 +2038,24 @@ static int init_server_components()
|
||||
NullS, LOG_NEW);
|
||||
using_update_log=1;
|
||||
}
|
||||
|
||||
if (opt_slow_log)
|
||||
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
|
||||
NullS, LOG_NORMAL);
|
||||
|
||||
if (opt_bin_log)
|
||||
{
|
||||
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
|
||||
opt_binlog_index_name,LOG_BIN);
|
||||
using_update_log=1;
|
||||
}
|
||||
|
||||
if (ha_init())
|
||||
{
|
||||
sql_print_error("Can't init databases");
|
||||
return 1;
|
||||
}
|
||||
if (opt_myisam_log)
|
||||
(void) mi_log(1);
|
||||
ha_key_cache();
|
||||
|
||||
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
|
||||
@ -2064,23 +2072,14 @@ static int init_server_components()
|
||||
locked_in_memory=0;
|
||||
#endif
|
||||
|
||||
if (opt_myisam_log)
|
||||
(void) mi_log( 1 );
|
||||
ft_init_stopwords(ft_precompiled_stopwords);
|
||||
|
||||
init_max_user_conn();
|
||||
init_update_queries();
|
||||
|
||||
if (opt_bin_log)
|
||||
{
|
||||
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
|
||||
opt_binlog_index_name,LOG_BIN);
|
||||
using_update_log=1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void create_maintenance_thread()
|
||||
{
|
||||
if (
|
||||
@ -2095,74 +2094,88 @@ static void create_maintenance_thread()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void create_shutdown_thread()
|
||||
{
|
||||
|
||||
#ifdef __WIN__
|
||||
{
|
||||
hEventShutdown=CreateEvent(0, FALSE, FALSE, event_name);
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
|
||||
sql_print_error("Warning: Can't create thread to handle shutdown requests");
|
||||
hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name);
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
|
||||
sql_print_error("Warning: Can't create thread to handle shutdown requests");
|
||||
|
||||
// On "Stop Service" we have to do regular shutdown
|
||||
Service.SetShutdownEvent(hEventShutdown);
|
||||
}
|
||||
// On "Stop Service" we have to do regular shutdown
|
||||
Service.SetShutdownEvent(hEventShutdown);
|
||||
#endif
|
||||
#ifdef OS2
|
||||
{
|
||||
pthread_cond_init( &eventShutdown, NULL);
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
|
||||
sql_print_error("Warning: Can't create thread to handle shutdown requests");
|
||||
}
|
||||
pthread_cond_init(&eventShutdown, NULL);
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
|
||||
sql_print_error("Warning: Can't create thread to handle shutdown requests");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __NT__
|
||||
void create_named_pipe_thread()
|
||||
|
||||
#if defined(__NT__) || defined(HAVE_SMEM)
|
||||
static void handle_connections_methods()
|
||||
{
|
||||
pthread_t hThread;
|
||||
DBUG_ENTER("handle_connections_methods");
|
||||
#ifdef __NT__
|
||||
if (hPipe == INVALID_HANDLE_VALUE &&
|
||||
(!have_tcpip || opt_disable_networking))
|
||||
(!have_tcpip || opt_disable_networking) &&
|
||||
!opt_enable_shared_memory)
|
||||
{
|
||||
sql_print_error("TCP/IP or --enable-named-pipe should be configured on NT OS");
|
||||
unireg_abort(1);
|
||||
sql_print_error("TCP/IP,--shared-memory or --named-pipe should be configured on NT OS");
|
||||
unireg_abort(1); // Will not return
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
(void) pthread_cond_init(&COND_handler_count,NULL);
|
||||
{
|
||||
pthread_t hThread;
|
||||
handler_count=0;
|
||||
if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_namedpipes, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle named pipes");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
if (have_tcpip && !opt_disable_networking)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_sockets, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle named pipes");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
while (handler_count > 0)
|
||||
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
|
||||
}
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
(void) pthread_cond_init(&COND_handler_count,NULL);
|
||||
handler_count=0;
|
||||
#ifdef __NT__
|
||||
if (hPipe != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_namedpipes, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle named pipes");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
#endif /* __NT__ */
|
||||
if (have_tcpip && !opt_disable_networking)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_sockets, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle TCP/IP");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_SMEM
|
||||
if (opt_enable_shared_memory)
|
||||
{
|
||||
handler_count++;
|
||||
if (pthread_create(&hThread,&connection_attrib,
|
||||
handle_connections_shared_memory, 0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to handle shared memory");
|
||||
handler_count--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while (handler_count > 0)
|
||||
pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#endif /* defined(__NT__) || defined(HAVE_SMEM) */
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
#ifdef __WIN__
|
||||
int win_main(int argc, char **argv)
|
||||
@ -2170,10 +2183,10 @@ int win_main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
int init_error;
|
||||
|
||||
DEBUGGER_OFF;
|
||||
|
||||
MY_INIT(argv[0]); // init my_sys library & pthreads
|
||||
|
||||
#ifdef _CUSTOMSTARTUPCONFIG_
|
||||
if (_cust_check_startup())
|
||||
{
|
||||
@ -2182,26 +2195,20 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
MY_INIT(argv[0]); // init my_sys library & pthreads
|
||||
|
||||
if ((init_error=init_common_variables(MYSQL_CONFIG_NAME,
|
||||
argc, argv, load_default_groups)))
|
||||
if (init_error == 2)
|
||||
unireg_abort(1);
|
||||
else
|
||||
exit(1);
|
||||
if (init_common_variables(MYSQL_CONFIG_NAME,
|
||||
argc, argv, load_default_groups))
|
||||
unireg_abort(1); // Will do exit
|
||||
|
||||
init_signals();
|
||||
if (init_thread_environement())
|
||||
exit(1);
|
||||
select_thread=pthread_self();
|
||||
select_thread_in_use=1;
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
|
||||
if (init_thread_environment())
|
||||
unireg_abort(1);
|
||||
pthread_attr_setstacksize(&connection_attrib,thread_stack);
|
||||
(void) thr_setconcurrency(concurrency); // 10 by default
|
||||
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
|
||||
|
||||
select_thread=pthread_self();
|
||||
select_thread_in_use=1;
|
||||
init_ssl();
|
||||
|
||||
#ifdef HAVE_LIBWRAP
|
||||
@ -2224,21 +2231,21 @@ int main(int argc, char **argv)
|
||||
if (opt_bin_log && !server_id)
|
||||
{
|
||||
server_id= !master_host ? 1 : 2;
|
||||
switch (server_id) {
|
||||
#ifdef EXTRA_DEBUG
|
||||
switch (server_id) {
|
||||
case 1:
|
||||
sql_print_error("\
|
||||
Warning: You have enabled the binary log, but you haven't set server-id:\n\
|
||||
Updates will be logged to the binary log, but connections to slaves will\n\
|
||||
not be accepted.");
|
||||
break;
|
||||
#endif
|
||||
case 2:
|
||||
sql_print_error("\
|
||||
Warning: You should set server-id to a non-0 value if master_host is set.\n\
|
||||
The server will not act as a slave.");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (init_server_components())
|
||||
@ -2250,12 +2257,8 @@ The server will not act as a slave.");
|
||||
{
|
||||
freopen(MYSQL_ERR_FILE,"a+",stdout);
|
||||
freopen(MYSQL_ERR_FILE,"a+",stderr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WIN__
|
||||
if (!opt_console)
|
||||
FreeConsole(); // Remove window
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -2273,6 +2276,8 @@ The server will not act as a slave.");
|
||||
if (!opt_bootstrap)
|
||||
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
|
||||
#endif
|
||||
if (unix_sock != INVALID_SOCKET)
|
||||
unlink(mysql_unix_port);
|
||||
exit(1);
|
||||
}
|
||||
if (!opt_noacl)
|
||||
@ -2306,13 +2311,10 @@ The server will not act as a slave.");
|
||||
printf(ER(ER_READY),my_progname,server_version,"");
|
||||
fflush(stdout);
|
||||
|
||||
#ifdef __NT__
|
||||
create_named_pipe_thread();
|
||||
#if defined(__NT__) || defined(HAVE_SMEM)
|
||||
handle_connections_methods();
|
||||
#else
|
||||
handle_connections_sockets(0);
|
||||
#ifdef EXTRA_DEBUG2
|
||||
sql_print_error("Exiting main thread");
|
||||
#endif
|
||||
#endif /* __NT__ */
|
||||
|
||||
/* (void) pthread_attr_destroy(&connection_attrib); */
|
||||
@ -2494,13 +2496,14 @@ int main(int argc, char **argv)
|
||||
Execute all commands from a file. Used by the mysql_install_db script to
|
||||
create MySQL privilege tables without having to start a full MySQL server.
|
||||
*/
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
static int bootstrap(FILE *file)
|
||||
{
|
||||
THD *thd= new THD;
|
||||
int error;
|
||||
THD *thd;
|
||||
int error= 0;
|
||||
DBUG_ENTER("bootstrap");
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY // TODO: Enable this
|
||||
thd= new THD;
|
||||
thd->bootstrap=1;
|
||||
thd->client_capabilities=0;
|
||||
my_net_init(&thd->net,(st_vio*) 0);
|
||||
@ -2528,10 +2531,10 @@ static int bootstrap(FILE *file)
|
||||
net_end(&thd->net);
|
||||
thd->cleanup();
|
||||
delete thd;
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static bool read_init_file(char *file_name)
|
||||
{
|
||||
@ -2540,15 +2543,13 @@ static bool read_init_file(char *file_name)
|
||||
DBUG_PRINT("enter",("name: %s",file_name));
|
||||
if (!(file=my_fopen(file_name,O_RDONLY,MYF(MY_WME))))
|
||||
return(1);
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
bootstrap(file); /* Ignore errors from this */
|
||||
#endif
|
||||
(void) my_fclose(file,MYF(MY_WME));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static void create_new_thread(THD *thd)
|
||||
{
|
||||
DBUG_ENTER("create_new_thread");
|
||||
@ -2629,7 +2630,8 @@ static void create_new_thread(THD *thd)
|
||||
DBUG_PRINT("info",("Thread created"));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#endif
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
#ifdef SIGNALS_DONT_BREAK_READ
|
||||
inline void kill_broken_server()
|
||||
@ -2647,10 +2649,11 @@ inline void kill_broken_server()
|
||||
#define MAYBE_BROKEN_SYSCALL
|
||||
#endif
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
/* Handle new connections and spawn new process to handle them */
|
||||
|
||||
extern "C" pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
extern "C" pthread_handler_decl(handle_connections_sockets,
|
||||
arg __attribute__((unused)))
|
||||
{
|
||||
my_socket sock,new_sock;
|
||||
uint error_count=0;
|
||||
@ -2939,6 +2942,7 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg)
|
||||
}
|
||||
#endif /* __NT__ */
|
||||
|
||||
|
||||
/*
|
||||
Thread of shared memory's service
|
||||
|
||||
@ -2947,6 +2951,7 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg)
|
||||
handle_connections_shared_memory Thread handle
|
||||
arg Arguments of thread
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
pthread_handler_decl(handle_connections_shared_memory,arg)
|
||||
{
|
||||
@ -2979,13 +2984,13 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
|
||||
DBUG_PRINT("general",("Waiting for allocated shared memory."));
|
||||
|
||||
|
||||
/*
|
||||
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 unique value for each object (events and file-mapping)
|
||||
*/
|
||||
/*
|
||||
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 unique 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 = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0)
|
||||
@ -3151,14 +3156,15 @@ error:
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif /* HAVE_SMEM */
|
||||
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
/******************************************************************************
|
||||
** handle start options
|
||||
|
||||
/****************************************************************************
|
||||
Handle start options
|
||||
******************************************************************************/
|
||||
|
||||
enum options {
|
||||
enum options
|
||||
{
|
||||
OPT_ISAM_LOG=256, OPT_SKIP_NEW,
|
||||
OPT_SKIP_GRANT, OPT_SKIP_LOCK,
|
||||
OPT_ENABLE_LOCK, OPT_USE_LOCKING,
|
||||
@ -4039,7 +4045,7 @@ struct my_option my_long_options[] =
|
||||
"Number of seconds to wait for more data from a master/slave connection before aborting the read.",
|
||||
(gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0,
|
||||
GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
|
||||
#endif
|
||||
#endif /* HAVE_REPLICATION */
|
||||
{"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
|
||||
"If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.",
|
||||
(gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG,
|
||||
@ -4941,7 +4947,7 @@ static void fix_paths(void)
|
||||
if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_REPLICATION */
|
||||
}
|
||||
|
||||
|
||||
|
@ -923,6 +923,7 @@ bool Protocol_prep::store_long(longlong from)
|
||||
{
|
||||
#ifndef DEBUG_OFF
|
||||
DBUG_ASSERT(field_types == 0 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_INT24 ||
|
||||
field_types[field_pos] == MYSQL_TYPE_LONG);
|
||||
#endif
|
||||
field_pos++;
|
||||
|
@ -1208,23 +1208,26 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
|
||||
while (!thd->fatal_error && thd->lex.found_colon)
|
||||
{
|
||||
char *packet= thd->lex.found_colon;
|
||||
/*
|
||||
Multiple queries exits, execute them individually
|
||||
*/
|
||||
if (thd->lock || thd->open_tables || thd->derived_tables)
|
||||
close_thread_tables(thd);
|
||||
|
||||
uint length= thd->query_length-(uint)(thd->lex.found_colon-thd->query);
|
||||
ulong length= thd->query_length-(ulong)(thd->lex.found_colon-thd->query);
|
||||
|
||||
/* Remove garbage at start of query */
|
||||
char *packet= thd->lex.found_colon;
|
||||
while (my_isspace(system_charset_info,packet[0]) && length > 0)
|
||||
while (my_isspace(system_charset_info, *packet) && length > 0)
|
||||
{
|
||||
packet++;
|
||||
length--;
|
||||
}
|
||||
thd->query= packet;
|
||||
thd->query_length= length;
|
||||
thd->query= packet;
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
thd->query_id= query_id++;
|
||||
VOID(pthread_mutex_unlock(&LOCK_thread_count));
|
||||
mysql_parse(thd, packet, length);
|
||||
}
|
||||
|
||||
|
@ -256,11 +256,87 @@ static void setup_param_double(Item_param *param, uchar **pos)
|
||||
*pos+= 8;
|
||||
}
|
||||
|
||||
static void setup_param_time(Item_param *param, uchar **pos)
|
||||
{
|
||||
ulong length;
|
||||
|
||||
if ((length= get_param_length(pos)))
|
||||
{
|
||||
uchar *to= *pos;
|
||||
TIME tm;
|
||||
|
||||
tm.second_part= (length > 8 ) ? (ulong) sint4korr(to+7): 0;
|
||||
|
||||
tm.day= (ulong) sint4korr(to+1);
|
||||
tm.hour= (uint) to[5];
|
||||
tm.minute= (uint) to[6];
|
||||
tm.second= (uint) to[7];
|
||||
|
||||
tm.year= tm.month= 0;
|
||||
tm.neg= (bool)to[0];
|
||||
|
||||
param->set_time(&tm, TIMESTAMP_TIME);
|
||||
}
|
||||
*pos+= length;
|
||||
}
|
||||
|
||||
static void setup_param_datetime(Item_param *param, uchar **pos)
|
||||
{
|
||||
uint length= get_param_length(pos);
|
||||
|
||||
if (length)
|
||||
{
|
||||
uchar *to= *pos;
|
||||
TIME tm;
|
||||
|
||||
tm.second_part= (length > 7 ) ? (ulong) sint4korr(to+7): 0;
|
||||
|
||||
if (length > 4)
|
||||
{
|
||||
tm.hour= (uint) to[4];
|
||||
tm.minute= (uint) to[5];
|
||||
tm.second= (uint) to[6];
|
||||
}
|
||||
else
|
||||
tm.hour= tm.minute= tm.second= 0;
|
||||
|
||||
tm.year= (uint) sint2korr(to);
|
||||
tm.month= (uint) to[2];
|
||||
tm.day= (uint) to[3];
|
||||
tm.neg= 0;
|
||||
|
||||
param->set_time(&tm, TIMESTAMP_FULL);
|
||||
}
|
||||
*pos+= length;
|
||||
}
|
||||
|
||||
static void setup_param_date(Item_param *param, uchar **pos)
|
||||
{
|
||||
ulong length;
|
||||
|
||||
if ((length= get_param_length(pos)))
|
||||
{
|
||||
uchar *to= *pos;
|
||||
TIME tm;
|
||||
|
||||
tm.year = (uint) sint2korr(to);
|
||||
tm.month= (uint) to[2];
|
||||
tm.day= (uint) to[3];
|
||||
|
||||
tm.hour= tm.minute= tm.second= 0;
|
||||
tm.second_part= 0;
|
||||
tm.neg= 0;
|
||||
|
||||
param->set_time(&tm, TIMESTAMP_DATE);
|
||||
}
|
||||
*pos+= length;
|
||||
}
|
||||
|
||||
static void setup_param_str(Item_param *param, uchar **pos)
|
||||
{
|
||||
ulong len=get_param_length(pos);
|
||||
ulong len= get_param_length(pos);
|
||||
param->set_value((const char *)*pos, len);
|
||||
*pos+=len;
|
||||
*pos+= len;
|
||||
}
|
||||
|
||||
static void setup_param_functions(Item_param *param, uchar param_type)
|
||||
@ -290,6 +366,19 @@ static void setup_param_functions(Item_param *param, uchar param_type)
|
||||
param->setup_param_func= setup_param_double;
|
||||
param->item_result_type = REAL_RESULT;
|
||||
break;
|
||||
case FIELD_TYPE_TIME:
|
||||
param->setup_param_func= setup_param_time;
|
||||
param->item_result_type = STRING_RESULT;
|
||||
break;
|
||||
case FIELD_TYPE_DATE:
|
||||
param->setup_param_func= setup_param_date;
|
||||
param->item_result_type = STRING_RESULT;
|
||||
break;
|
||||
case FIELD_TYPE_DATETIME:
|
||||
case FIELD_TYPE_TIMESTAMP:
|
||||
param->setup_param_func= setup_param_datetime;
|
||||
param->item_result_type = STRING_RESULT;
|
||||
break;
|
||||
default:
|
||||
param->setup_param_func= setup_param_str;
|
||||
param->item_result_type = STRING_RESULT;
|
||||
|
@ -732,7 +732,9 @@ JOIN::exec()
|
||||
result->send_fields(fields_list,1);
|
||||
if (!having || having->val_int())
|
||||
{
|
||||
if (do_send_rows && result->send_data(fields_list))
|
||||
if (do_send_rows && (procedure ? (procedure->send_row(fields_list) ||
|
||||
procedure->end_of_records())
|
||||
: result->send_data(fields_list)))
|
||||
error= 1;
|
||||
else
|
||||
{
|
||||
@ -743,7 +745,6 @@ JOIN::exec()
|
||||
else
|
||||
error=(int) result->send_eof();
|
||||
}
|
||||
delete procedure;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -706,7 +706,7 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
|
||||
char *to_start= to;
|
||||
uchar *to_end= (uchar*) to+to_length;
|
||||
|
||||
while ((uchar*) from < from_end)
|
||||
while (1)
|
||||
{
|
||||
if ((cnvres=from_cs->mb_wc(from_cs, &wc, (uchar*) from, from_end)) > 0)
|
||||
from+= cnvres;
|
||||
|
@ -587,7 +587,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
|
||||
literal text_literal insert_ident order_ident
|
||||
simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
|
||||
table_wild opt_pad no_in_expr expr_expr simple_expr no_and_expr
|
||||
using_list expr_or_default set_expr_or_default
|
||||
using_list expr_or_default set_expr_or_default interval_expr
|
||||
param_marker singlerow_subselect singlerow_subselect_init
|
||||
exists_subselect exists_subselect_init
|
||||
|
||||
@ -1930,10 +1930,10 @@ expr_expr:
|
||||
| expr '^' expr { $$= new Item_func_bit_xor($1,$3); }
|
||||
| expr '&' expr { $$= new Item_func_bit_and($1,$3); }
|
||||
| expr '%' expr { $$= new Item_func_mod($1,$3); }
|
||||
| expr '+' INTERVAL_SYM expr interval
|
||||
{ $$= new Item_date_add_interval($1,$4,$5,0); }
|
||||
| expr '-' INTERVAL_SYM expr interval
|
||||
{ $$= new Item_date_add_interval($1,$4,$5,1); }
|
||||
| expr '+' interval_expr interval
|
||||
{ $$= new Item_date_add_interval($1,$3,$4,0); }
|
||||
| expr '-' interval_expr interval
|
||||
{ $$= new Item_date_add_interval($1,$3,$4,1); }
|
||||
| expr COLLATE_SYM collation_name
|
||||
{ $$= new Item_func_set_collation($1,$3); };
|
||||
|
||||
@ -1977,10 +1977,10 @@ no_in_expr:
|
||||
| no_in_expr '&' expr { $$= new Item_func_bit_and($1,$3); }
|
||||
| no_in_expr '%' expr { $$= new Item_func_mod($1,$3); }
|
||||
| no_in_expr MOD_SYM expr { $$= new Item_func_mod($1,$3); }
|
||||
| no_in_expr '+' INTERVAL_SYM expr interval
|
||||
{ $$= new Item_date_add_interval($1,$4,$5,0); }
|
||||
| no_in_expr '-' INTERVAL_SYM expr interval
|
||||
{ $$= new Item_date_add_interval($1,$4,$5,1); }
|
||||
| no_in_expr '+' interval_expr interval
|
||||
{ $$= new Item_date_add_interval($1,$3,$4,0); }
|
||||
| no_in_expr '-' interval_expr interval
|
||||
{ $$= new Item_date_add_interval($1,$3,$4,1); }
|
||||
| simple_expr;
|
||||
|
||||
/* expressions that begin with 'expr' that does NOT follow AND */
|
||||
@ -2032,12 +2032,16 @@ no_and_expr:
|
||||
| no_and_expr '&' expr { $$= new Item_func_bit_and($1,$3); }
|
||||
| no_and_expr '%' expr { $$= new Item_func_mod($1,$3); }
|
||||
| no_and_expr MOD_SYM expr { $$= new Item_func_mod($1,$3); }
|
||||
| no_and_expr '+' INTERVAL_SYM expr interval
|
||||
{ $$= new Item_date_add_interval($1,$4,$5,0); }
|
||||
| no_and_expr '-' INTERVAL_SYM expr interval
|
||||
{ $$= new Item_date_add_interval($1,$4,$5,1); }
|
||||
| no_and_expr '+' interval_expr interval
|
||||
{ $$= new Item_date_add_interval($1,$3,$4,0); }
|
||||
| no_and_expr '-' interval_expr interval
|
||||
{ $$= new Item_date_add_interval($1,$3,$4,1); }
|
||||
| simple_expr;
|
||||
|
||||
interval_expr:
|
||||
INTERVAL_SYM expr { $$=$2; }
|
||||
;
|
||||
|
||||
simple_expr:
|
||||
simple_ident
|
||||
| literal
|
||||
@ -2063,8 +2067,11 @@ simple_expr:
|
||||
| NOT expr %prec NEG { $$= new Item_func_not($2); }
|
||||
| '!' expr %prec NEG { $$= new Item_func_not($2); }
|
||||
| '(' expr ')' { $$= $2; }
|
||||
/* Note: In SQL-99 "ROW" is optional, but not having it mandatory
|
||||
causes conflicts with the INTERVAL syntax. */
|
||||
| '(' expr ',' expr_list ')'
|
||||
{
|
||||
$4->push_front($2);
|
||||
$$= new Item_row(*$4);
|
||||
}
|
||||
| ROW_SYM '(' expr ',' expr_list ')'
|
||||
{
|
||||
$5->push_front($3);
|
||||
@ -2122,10 +2129,10 @@ simple_expr:
|
||||
$$= new Item_func_curtime($3);
|
||||
Lex->safe_to_cache_query=0;
|
||||
}
|
||||
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
|
||||
{ $$= new Item_date_add_interval($3,$6,$7,0); }
|
||||
| DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
|
||||
{ $$= new Item_date_add_interval($3,$6,$7,1); }
|
||||
| DATE_ADD_INTERVAL '(' expr ',' interval_expr interval ')'
|
||||
{ $$= new Item_date_add_interval($3,$5,$6,0); }
|
||||
| DATE_SUB_INTERVAL '(' expr ',' interval_expr interval ')'
|
||||
{ $$= new Item_date_add_interval($3,$5,$6,1); }
|
||||
| DATABASE '(' ')'
|
||||
{
|
||||
$$= new Item_func_database();
|
||||
@ -2185,14 +2192,21 @@ simple_expr:
|
||||
{ $$= new Item_func_if($3,$5,$7); }
|
||||
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
|
||||
{ $$= new Item_func_insert($3,$5,$7,$9); }
|
||||
| INTERVAL_SYM expr interval '+' expr
|
||||
| interval_expr interval '+' expr
|
||||
/* we cannot put interval before - */
|
||||
{ $$= new Item_date_add_interval($5,$2,$3,0); }
|
||||
| INTERVAL_SYM '(' expr ',' expr_list ')'
|
||||
{ $$= new Item_func_interval($3,* $5); }
|
||||
{ $$= new Item_date_add_interval($4,$1,$2,0); }
|
||||
| interval_expr
|
||||
{
|
||||
if ($1->type() != Item::ROW_ITEM)
|
||||
{
|
||||
send_error(Lex->thd, ER_SYNTAX_ERROR);
|
||||
YYABORT;
|
||||
}
|
||||
$$= new Item_func_interval((Item_row *)$1);
|
||||
}
|
||||
| LAST_INSERT_ID '(' ')'
|
||||
{
|
||||
$$= get_system_var(OPT_SESSION, "last_insert_id", 14,
|
||||
$$= get_system_var(OPT_SESSION, "last_insert_id", 14,
|
||||
"last_insert_id()");
|
||||
}
|
||||
| LAST_INSERT_ID '(' expr ')'
|
||||
@ -2247,10 +2261,10 @@ simple_expr:
|
||||
| MPOLYFROMTEXT '(' expr ',' expr ')'
|
||||
{ $$= new Item_func_geometry_from_text($3); }
|
||||
| MULTIPOINT '(' expr_list ')'
|
||||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
Geometry::wkbMultiPoint, Geometry::wkbPoint); }
|
||||
| MULTIPOLYGON '(' expr_list ')'
|
||||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
Geometry::wkbMultiPolygon, Geometry::wkbPolygon ); }
|
||||
| NOW_SYM optional_braces
|
||||
{ $$= new Item_func_now(); Lex->safe_to_cache_query=0;}
|
||||
@ -2269,7 +2283,7 @@ simple_expr:
|
||||
| POLYFROMTEXT '(' expr ',' expr ')'
|
||||
{ $$= new Item_func_geometry_from_text($3); }
|
||||
| POLYGON '(' expr_list ')'
|
||||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
Geometry::wkbPolygon, Geometry::wkbLineString); }
|
||||
| POSITION_SYM '(' no_in_expr IN_SYM expr ')'
|
||||
{ $$ = new Item_func_locate($5,$3); }
|
||||
@ -2429,7 +2443,7 @@ in_sum_expr:
|
||||
};
|
||||
|
||||
cast_type:
|
||||
BINARY { $$=ITEM_CAST_BINARY; }
|
||||
BINARY { $$=ITEM_CAST_BINARY; }
|
||||
| CHAR_SYM { $$=ITEM_CAST_CHAR; }
|
||||
| SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; }
|
||||
| SIGNED_SYM INT_SYM { $$=ITEM_CAST_SIGNED_INT; }
|
||||
@ -4651,7 +4665,7 @@ subselect_start:
|
||||
'(' SELECT_SYM
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (((int)lex->sql_command >= (int)SQLCOM_HA_OPEN &&
|
||||
if (((int)lex->sql_command >= (int)SQLCOM_HA_OPEN &&
|
||||
lex->sql_command <= (int)SQLCOM_HA_READ) || lex->sql_command == (int)SQLCOM_KILL) {
|
||||
send_error(lex->thd, ER_SYNTAX_ERROR);
|
||||
YYABORT;
|
||||
|
@ -6175,6 +6175,9 @@ my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if(wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -6200,6 +6203,9 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
int hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if(hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -96,6 +96,9 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)),
|
||||
const unsigned char *str,
|
||||
const unsigned char *end __attribute__((unused)))
|
||||
{
|
||||
if (str >= end)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
*wc=str[0];
|
||||
return 1;
|
||||
}
|
||||
@ -105,6 +108,9 @@ static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
|
||||
unsigned char *s,
|
||||
unsigned char *e __attribute__((unused)))
|
||||
{
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc < 256)
|
||||
{
|
||||
s[0]= (char) wc;
|
||||
|
@ -8593,6 +8593,9 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -8618,6 +8621,9 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
int hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if (hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -5643,6 +5643,9 @@ my_wc_mb_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -5668,6 +5671,9 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if(hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -9829,6 +9829,9 @@ my_wc_mb_gbk(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -9852,6 +9855,9 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int hi;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
hi=s[0];
|
||||
|
||||
if (hi<0x80)
|
||||
|
@ -106,6 +106,9 @@ int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc,
|
||||
const unsigned char *str,
|
||||
const unsigned char *end __attribute__((unused)))
|
||||
{
|
||||
if (str >= end)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
*wc=cs->tab_to_uni[*str];
|
||||
return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
|
||||
}
|
||||
@ -116,6 +119,9 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
|
||||
{
|
||||
MY_UNI_IDX *idx;
|
||||
|
||||
if (str >= end)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
for (idx=cs->tab_from_uni; idx->tab ; idx++)
|
||||
{
|
||||
if (idx->from <= wc && idx->to >= wc)
|
||||
@ -994,7 +1000,7 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq)
|
||||
return 0;
|
||||
|
||||
case MY_SEQ_SPACES:
|
||||
for (str++ ; str != end ; str++)
|
||||
for (; str != end ; str++)
|
||||
{
|
||||
if (!my_isspace(cs,*str))
|
||||
break;
|
||||
|
@ -4420,6 +4420,9 @@ my_wc_mb_sjis(CHARSET_INFO *cs __attribute__((unused)),
|
||||
{
|
||||
int code;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if(wc<0x80)
|
||||
{
|
||||
s[0]=wc;
|
||||
@ -4442,6 +4445,9 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)),
|
||||
my_wc_t *pwc, const uchar *s, const uchar *e){
|
||||
int hi=s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if(hi<0x80)
|
||||
{
|
||||
pwc[0]=hi;
|
||||
|
@ -8350,6 +8350,9 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
|
||||
unsigned char buf[2];
|
||||
unsigned char c1;
|
||||
int ret,jp;
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc<0x80)
|
||||
{
|
||||
|
@ -1586,6 +1586,9 @@ static int my_utf8_uni (CHARSET_INFO *cs __attribute__((unused)) ,
|
||||
{
|
||||
unsigned char c = s[0];
|
||||
|
||||
if (s >= e)
|
||||
return MY_CS_TOOFEW(0);
|
||||
|
||||
if (c < 0x80)
|
||||
{
|
||||
*pwc = c;
|
||||
@ -1688,6 +1691,9 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) ,
|
||||
{
|
||||
int count;
|
||||
|
||||
if (r >= e)
|
||||
return MY_CS_TOOSMALL;
|
||||
|
||||
if (wc < 0x80)
|
||||
count = 1;
|
||||
else if (wc < 0x800)
|
||||
|
1686
tests/client_test.c
1686
tests/client_test.c
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user