Commit 871d021a authored by unknown's avatar unknown

Merge sinisa@work.mysql.com:/home/bk/mysql-4.0

into sinisa.nasamreza.org:/mnt/work/mysql-4.0
parents 01c7b3c8 be1347cb
...@@ -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;
......
...@@ -27,14 +27,13 @@ ...@@ -27,14 +27,13 @@
int mi_rnext_same(MI_INFO *info, byte *buf) int mi_rnext_same(MI_INFO *info, byte *buf)
{ {
int error; int error;
uint inx,flag,not_used; uint inx,not_used;
MI_KEYDEF *keyinfo; MI_KEYDEF *keyinfo;
DBUG_ENTER("mi_rnext_same"); DBUG_ENTER("mi_rnext_same");
if ((int) (inx=info->lastinx) < 0 || info->lastpos == HA_OFFSET_ERROR) if ((int) (inx=info->lastinx) < 0 || info->lastpos == HA_OFFSET_ERROR)
DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
keyinfo=info->s->keyinfo+inx; keyinfo=info->s->keyinfo+inx;
flag=SEARCH_BIGGER; /* Read next */
if (fast_mi_readinfo(info)) if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
...@@ -44,7 +43,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf) ...@@ -44,7 +43,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
for (;;) for (;;)
{ {
if ((error=_mi_search_next(info,keyinfo,info->lastkey, if ((error=_mi_search_next(info,keyinfo,info->lastkey,
info->lastkey_length,flag, info->lastkey_length,SEARCH_BIGGER,
info->s->state.key_root[inx]))) info->s->state.key_root[inx])))
break; break;
if (_mi_key_cmp(keyinfo->seg,info->lastkey2,info->lastkey, if (_mi_key_cmp(keyinfo->seg,info->lastkey2,info->lastkey,
......
...@@ -205,6 +205,14 @@ Documentation 0 ...@@ -205,6 +205,14 @@ Documentation 0
Host communication 0 Host communication 0
kkkkkkkkkkk lllllllllll 3 kkkkkkkkkkk lllllllllll 3
Test Procedures 0 Test Procedures 0
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);
value description COUNT(bug_id)
BBBBBBBBBBBBB - conversion 2
BBBBBBBBBBBBB - eeeeeeeee 0
BBBBBBBBBBBBB - generic 2
Documentation 0
Host communication 0
Test Procedures 0
drop table t1,t2; drop table t1,t2;
create table t1 (foo int); create table t1 (foo int);
insert into t1 values (1); insert into t1 values (1);
...@@ -232,6 +240,13 @@ userid count(*) ...@@ -232,6 +240,13 @@ userid count(*)
3 3 3 3
2 1 2 1
1 2 1 2
select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3);
userid count(*)
3 3
1 2
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
userid count(*)
3 3
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;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range spID spID 5 NULL 2 Using where; Using index t1 range spID spID 5 NULL 2 Using where; Using index
......
...@@ -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