summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2002-12-04 10:48:21 +0100
committerunknown <serg@serg.mysql.com>2002-12-04 10:48:21 +0100
commitb1582a0bd2078608283600ee12246d89f5d7417f (patch)
treeef332a918f74be6b6d75d61b7fc79fe95022510b
parent9b515ad043bd06015ab626e04c56fdf52ffcade2 (diff)
parent2d2e834ce1be474b3b09dd60a1c4a9f2f67fc6e0 (diff)
downloadmariadb-git-b1582a0bd2078608283600ee12246d89f5d7417f.tar.gz
Merge work:/home/bk/mysql-4.0
into serg.mysql.com:/usr/home/serg/Abk/mysql-4.0
-rw-r--r--libmysql/libmysql.c12
-rw-r--r--myisam/mi_rnext_same.c5
-rw-r--r--mysql-test/r/group_by.result15
-rw-r--r--mysql-test/t/group_by.test3
-rw-r--r--sql/item_cmpfunc.cc18
-rw-r--r--sql/item_cmpfunc.h5
-rw-r--r--sql/mysqld.cc20
-rw-r--r--sql/sql_parse.cc4
8 files changed, 64 insertions, 18 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index c9a46eaf9ad..da6c445d161 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -348,7 +348,7 @@ net_safe_read(MYSQL *mysql)
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len));
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_SERVER_LOST);
strmov(net->last_error,ER(net->last_errno));
@@ -934,7 +934,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
ulong pkt_len;
ulong len;
uchar *cp;
- char *to;
+ char *to, *end_to;
MYSQL_DATA *result;
MYSQL_ROWS **prev_ptr,*cur;
NET *net = &mysql->net;
@@ -972,6 +972,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
*prev_ptr=cur;
prev_ptr= &cur->next;
to= (char*) (cur->data+fields+1);
+ end_to=to+pkt_len-1;
for (field=0 ; field < fields ; field++)
{
if ((len=(ulong) net_field_length(&cp)) == NULL_LENGTH)
@@ -981,6 +982,13 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
else
{
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;
to+=len+1;
cp+=len;
diff --git a/myisam/mi_rnext_same.c b/myisam/mi_rnext_same.c
index 662bdb154b3..a9d1953323c 100644
--- a/myisam/mi_rnext_same.c
+++ b/myisam/mi_rnext_same.c
@@ -27,14 +27,13 @@
int mi_rnext_same(MI_INFO *info, byte *buf)
{
int error;
- uint inx,flag,not_used;
+ uint inx,not_used;
MI_KEYDEF *keyinfo;
DBUG_ENTER("mi_rnext_same");
if ((int) (inx=info->lastinx) < 0 || info->lastpos == HA_OFFSET_ERROR)
DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
keyinfo=info->s->keyinfo+inx;
- flag=SEARCH_BIGGER; /* Read next */
if (fast_mi_readinfo(info))
DBUG_RETURN(my_errno);
@@ -44,7 +43,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
for (;;)
{
if ((error=_mi_search_next(info,keyinfo,info->lastkey,
- info->lastkey_length,flag,
+ info->lastkey_length,SEARCH_BIGGER,
info->s->state.key_root[inx])))
break;
if (_mi_key_cmp(keyinfo->seg,info->lastkey2,info->lastkey,
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 0e8c6520d5c..ddddb3fa07d 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -205,6 +205,14 @@ Documentation 0
Host communication 0
kkkkkkkkkkk lllllllllll 3
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;
create table t1 (foo int);
insert into t1 values (1);
@@ -232,6 +240,13 @@ userid count(*)
3 3
2 1
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;
table type possible_keys key key_len ref rows Extra
t1 range spID spID 5 NULL 2 Using where; Using index
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 2f2f50c4085..328b696ac05 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -206,6 +206,7 @@ INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','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,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;
@@ -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);
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 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;
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 0dc1e91d372..0e7d38ecda8 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1073,6 +1073,18 @@ void Item_func_in::update_used_tables()
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()
{
@@ -1289,15 +1301,15 @@ longlong Item_cond_or::val_int()
Item *and_expressions(Item *a, Item *b, Item **org_item)
{
if (!a)
- return (*org_item= b);
+ return (*org_item= (Item*) b);
if (a == *org_item)
{
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();
return res;
}
- if (((Item_cond_and*) a)->add(b))
+ if (((Item_cond_and*) a)->add((Item*) b))
return 0;
((Item_cond_and*) a)->used_tables_cache|= b->used_tables();
return a;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index e163bc40a6e..d9068e0e024 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -425,7 +425,9 @@ class Item_func_in :public Item_int_func
longlong val_int();
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();
~Item_func_in() { delete item; delete array; delete in_item; }
@@ -436,6 +438,7 @@ class Item_func_in :public Item_int_func
enum Functype functype() const { return IN_FUNC; }
const char *func_name() const { return " IN "; }
void update_used_tables();
+ void split_sum_func(List<Item> &fields);
unsigned int size_of() { return sizeof(*this);}
};
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e8132ae7f81..a65cbd1139d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -433,7 +433,7 @@ pthread_attr_t connection_attrib;
#include <process.h>
#if !defined(EMBEDDED_LIBRARY)
HANDLE hEventShutdown;
-static char *event_name;
+static char shutdown_event_name[40];
#include "nt_servc.h"
static NTService Service; // Service object for WinNT
#endif
@@ -998,6 +998,7 @@ static void set_root(const char *path)
sql_perror("chroot");
unireg_abort(1);
}
+ my_setwd("/", MYF(0));
#endif
}
@@ -2316,6 +2317,14 @@ bool default_service_handling(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 */
{
char file_path[FN_REFLEN];
@@ -2330,10 +2339,9 @@ int main(int argc, char **argv)
if (Service.IsService(argv[1]))
{
/* start an optional service */
- event_name= argv[1];
- load_default_groups[0]= argv[1];
+ load_default_groups[0]= argv[1];
start_mode= 1;
- Service.Init(event_name, mysql_service);
+ Service.Init(argv[1], mysql_service);
return 0;
}
}
@@ -2352,9 +2360,8 @@ int main(int argc, char **argv)
use_opt_args=1;
opt_argc=argc;
opt_argv=argv;
- event_name= argv[2];
start_mode= 1;
- Service.Init(event_name, mysql_service);
+ Service.Init(argv[2], mysql_service);
return 0;
}
}
@@ -2374,7 +2381,6 @@ int main(int argc, char **argv)
{
/* start the default service */
start_mode= 1;
- event_name= "MySqlShutdown";
Service.Init(MYSQL_SERVICENAME, mysql_service);
return 0;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6b918d3565b..8f1e9c37eae 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -196,6 +196,8 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
thd->db_length=0;
USER_RESOURCES ur;
+ if (passwd[0] && strlen(passwd) != SCRAMBLE_LENGTH)
+ return 1;
if (!(thd->user = my_strdup(user, MYF(0))))
{
send_error(net,ER_OUT_OF_RESOURCES);
@@ -596,8 +598,6 @@ check_connections(THD *thd)
char *user= (char*) net->read_pos+5;
char *passwd= strend(user)+1;
char *db=0;
- if (passwd[0] && strlen(passwd) != SCRAMBLE_LENGTH)
- return ER_HANDSHAKE_ERROR;
if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB)
db=strend(passwd)+1;
if (thd->client_capabilities & CLIENT_INTERACTIVE)