Commit 5a0f1c74 authored by unknown's avatar unknown

merged


libmysql/libmysql.c:
  Auto merged
sql/opt_sum.cc:
  Auto merged
support-files/mysql.server.sh:
  Auto merged
parents 80b143c1 faefac30
...@@ -348,7 +348,7 @@ net_safe_read(MYSQL *mysql) ...@@ -348,7 +348,7 @@ net_safe_read(MYSQL *mysql)
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len)); vio_description(net->vio),len));
end_server(mysql); end_server(mysql);
net->last_errno=(net->last_errno == ER_NET_PACKET_TOO_LARGE ? net->last_errno=(net->last_errno == ER_NET_PACKET_TOO_LARGE ?
CR_NET_PACKET_TOO_LARGE: CR_NET_PACKET_TOO_LARGE:
CR_SERVER_LOST); CR_SERVER_LOST);
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
...@@ -934,7 +934,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, ...@@ -934,7 +934,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
ulong pkt_len; ulong pkt_len;
ulong len; ulong len;
uchar *cp; uchar *cp;
char *to; char *to, *end_to;
MYSQL_DATA *result; MYSQL_DATA *result;
MYSQL_ROWS **prev_ptr,*cur; MYSQL_ROWS **prev_ptr,*cur;
NET *net = &mysql->net; NET *net = &mysql->net;
...@@ -972,6 +972,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, ...@@ -972,6 +972,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
*prev_ptr=cur; *prev_ptr=cur;
prev_ptr= &cur->next; prev_ptr= &cur->next;
to= (char*) (cur->data+fields+1); to= (char*) (cur->data+fields+1);
end_to=to+pkt_len-1;
for (field=0 ; field < fields ; field++) for (field=0 ; field < fields ; field++)
{ {
if ((len=(ulong) net_field_length(&cp)) == NULL_LENGTH) if ((len=(ulong) net_field_length(&cp)) == NULL_LENGTH)
...@@ -981,6 +982,13 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, ...@@ -981,6 +982,13 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
else else
{ {
cur->data[field] = to; cur->data[field] = to;
if (to+len > end_to)
{
free_rows(result);
net->last_errno=CR_UNKNOWN_ERROR;
strmov(net->last_error,ER(net->last_errno));
DBUG_RETURN(0);
}
memcpy(to,(char*) cp,len); to[len]=0; memcpy(to,(char*) cp,len); to[len]=0;
to+=len+1; to+=len+1;
cp+=len; cp+=len;
......
...@@ -206,6 +206,7 @@ INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','',''); ...@@ -206,6 +206,7 @@ INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','',''); INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA"; select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value; select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2);
drop table t1,t2; drop table t1,t2;
...@@ -234,6 +235,8 @@ CREATE TABLE t1 ( ...@@ -234,6 +235,8 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3); INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3);
explain select userid,count(*) from t1 group by userid desc; explain select userid,count(*) from t1 group by userid desc;
select userid,count(*) from t1 group by userid desc; select userid,count(*) from t1 group by userid desc;
select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3);
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
select spid,count(*) from t1 where spid between 1 and 2 group by spid; select spid,count(*) from t1 where spid between 1 and 2 group by spid;
......
...@@ -1073,6 +1073,18 @@ void Item_func_in::update_used_tables() ...@@ -1073,6 +1073,18 @@ void Item_func_in::update_used_tables()
const_item_cache&=item->const_item(); const_item_cache&=item->const_item();
} }
void Item_func_in::split_sum_func(List<Item> &fields)
{
if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
item->split_sum_func(fields);
else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
{
fields.push_front(item);
item=new Item_ref((Item**) fields.head_ref(),0,item->name);
}
Item_func::split_sum_func(fields);
}
longlong Item_func_bit_or::val_int() longlong Item_func_bit_or::val_int()
{ {
...@@ -1289,15 +1301,15 @@ longlong Item_cond_or::val_int() ...@@ -1289,15 +1301,15 @@ longlong Item_cond_or::val_int()
Item *and_expressions(Item *a, Item *b, Item **org_item) Item *and_expressions(Item *a, Item *b, Item **org_item)
{ {
if (!a) if (!a)
return (*org_item= b); return (*org_item= (Item*) b);
if (a == *org_item) if (a == *org_item)
{ {
Item_cond *res; Item_cond *res;
if ((res= new Item_cond_and(a, b))) if ((res= new Item_cond_and(a, (Item*) b)))
res->used_tables_cache= a->used_tables() | b->used_tables(); res->used_tables_cache= a->used_tables() | b->used_tables();
return res; return res;
} }
if (((Item_cond_and*) a)->add(b)) if (((Item_cond_and*) a)->add((Item*) b))
return 0; return 0;
((Item_cond_and*) a)->used_tables_cache|= b->used_tables(); ((Item_cond_and*) a)->used_tables_cache|= b->used_tables();
return a; return a;
......
...@@ -425,7 +425,9 @@ class Item_func_in :public Item_int_func ...@@ -425,7 +425,9 @@ class Item_func_in :public Item_int_func
longlong val_int(); longlong val_int();
bool fix_fields(THD *thd,struct st_table_list *tlist) bool fix_fields(THD *thd,struct st_table_list *tlist)
{ {
return (item->fix_fields(thd,tlist) || Item_func::fix_fields(thd,tlist)); bool res= (item->fix_fields(thd,tlist) || Item_func::fix_fields(thd,tlist));
with_sum_func= with_sum_func || item->with_sum_func;
return res;
} }
void fix_length_and_dec(); void fix_length_and_dec();
~Item_func_in() { delete item; delete array; delete in_item; } ~Item_func_in() { delete item; delete array; delete in_item; }
...@@ -436,6 +438,7 @@ class Item_func_in :public Item_int_func ...@@ -436,6 +438,7 @@ class Item_func_in :public Item_int_func
enum Functype functype() const { return IN_FUNC; } enum Functype functype() const { return IN_FUNC; }
const char *func_name() const { return " IN "; } const char *func_name() const { return " IN "; }
void update_used_tables(); void update_used_tables();
void split_sum_func(List<Item> &fields);
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
......
...@@ -433,7 +433,7 @@ pthread_attr_t connection_attrib; ...@@ -433,7 +433,7 @@ pthread_attr_t connection_attrib;
#include <process.h> #include <process.h>
#if !defined(EMBEDDED_LIBRARY) #if !defined(EMBEDDED_LIBRARY)
HANDLE hEventShutdown; HANDLE hEventShutdown;
static char *event_name; static char shutdown_event_name[40];
#include "nt_servc.h" #include "nt_servc.h"
static NTService Service; // Service object for WinNT static NTService Service; // Service object for WinNT
#endif #endif
...@@ -998,6 +998,7 @@ static void set_root(const char *path) ...@@ -998,6 +998,7 @@ static void set_root(const char *path)
sql_perror("chroot"); sql_perror("chroot");
unireg_abort(1); unireg_abort(1);
} }
my_setwd("/", MYF(0));
#endif #endif
} }
...@@ -2316,6 +2317,14 @@ bool default_service_handling(char **argv, ...@@ -2316,6 +2317,14 @@ bool default_service_handling(char **argv,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
/* When several instances are running on the same machine, we
need to have an unique named hEventShudown through the
application PID e.g.: MySQLShutdown1890; MySQLShutdown2342
*/
int2str((int) GetCurrentProcessId(),strmov(shutdown_event_name,
"MySQLShutdown"), 10);
if (Service.GetOS()) /* true NT family */ if (Service.GetOS()) /* true NT family */
{ {
char file_path[FN_REFLEN]; char file_path[FN_REFLEN];
...@@ -2330,10 +2339,9 @@ int main(int argc, char **argv) ...@@ -2330,10 +2339,9 @@ int main(int argc, char **argv)
if (Service.IsService(argv[1])) if (Service.IsService(argv[1]))
{ {
/* start an optional service */ /* start an optional service */
event_name= argv[1]; load_default_groups[0]= argv[1];
load_default_groups[0]= argv[1];
start_mode= 1; start_mode= 1;
Service.Init(event_name, mysql_service); Service.Init(argv[1], mysql_service);
return 0; return 0;
} }
} }
...@@ -2352,9 +2360,8 @@ int main(int argc, char **argv) ...@@ -2352,9 +2360,8 @@ int main(int argc, char **argv)
use_opt_args=1; use_opt_args=1;
opt_argc=argc; opt_argc=argc;
opt_argv=argv; opt_argv=argv;
event_name= argv[2];
start_mode= 1; start_mode= 1;
Service.Init(event_name, mysql_service); Service.Init(argv[2], mysql_service);
return 0; return 0;
} }
} }
...@@ -2374,7 +2381,6 @@ int main(int argc, char **argv) ...@@ -2374,7 +2381,6 @@ int main(int argc, char **argv)
{ {
/* start the default service */ /* start the default service */
start_mode= 1; start_mode= 1;
event_name= "MySqlShutdown";
Service.Init(MYSQL_SERVICENAME, mysql_service); Service.Init(MYSQL_SERVICENAME, mysql_service);
return 0; return 0;
} }
......
...@@ -196,6 +196,8 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, ...@@ -196,6 +196,8 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
thd->db_length=0; thd->db_length=0;
USER_RESOURCES ur; USER_RESOURCES ur;
if (passwd[0] && strlen(passwd) != SCRAMBLE_LENGTH)
return 1;
if (!(thd->user = my_strdup(user, MYF(0)))) if (!(thd->user = my_strdup(user, MYF(0))))
{ {
send_error(net,ER_OUT_OF_RESOURCES); send_error(net,ER_OUT_OF_RESOURCES);
...@@ -596,8 +598,6 @@ check_connections(THD *thd) ...@@ -596,8 +598,6 @@ check_connections(THD *thd)
char *user= (char*) net->read_pos+5; char *user= (char*) net->read_pos+5;
char *passwd= strend(user)+1; char *passwd= strend(user)+1;
char *db=0; char *db=0;
if (passwd[0] && strlen(passwd) != SCRAMBLE_LENGTH)
return ER_HANDSHAKE_ERROR;
if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB) if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB)
db=strend(passwd)+1; db=strend(passwd)+1;
if (thd->client_capabilities & CLIENT_INTERACTIVE) if (thd->client_capabilities & CLIENT_INTERACTIVE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment