Commit 8e6a2e98 authored by dlenev@mysql.com's avatar dlenev@mysql.com

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/dlenev/src/mysql-4.1-bg2248
parents d38c4fca 7d361a6c
......@@ -572,6 +572,7 @@ typedef struct st_mysql_methods
int (*unbuffered_fetch)(MYSQL *mysql, char **row);
void (*free_embedded_thd)(MYSQL *mysql);
const char *(*read_statistic)(MYSQL *mysql);
int (*next_result)(MYSQL *mysql);
#endif
} MYSQL_METHODS;
......
......@@ -3460,7 +3460,6 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql)
/*
Reads and returns the next query results
*/
int STDCALL mysql_next_result(MYSQL *mysql)
{
DBUG_ENTER("mysql_next_result");
......@@ -3479,7 +3478,7 @@ int STDCALL mysql_next_result(MYSQL *mysql)
mysql->affected_rows= ~(my_ulonglong) 0;
if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)
DBUG_RETURN((*mysql->methods->read_query_result)(mysql));
DBUG_RETURN((*mysql->methods->next_result)(mysql));
DBUG_RETURN(-1); /* No more results */
}
......
......@@ -245,6 +245,18 @@ static MYSQL_RES * emb_mysql_store_result(MYSQL *mysql)
return mysql_store_result(mysql);
}
int emb_next_result(MYSQL *mysql)
{
THD *thd= (THD*)mysql->thd;
DBUG_ENTER("emb_next_result");
if (emb_advanced_command(mysql, COM_QUERY,0,0,
thd->query_rest,thd->query_rest_length,1)
|| emb_mysql_read_query_result(mysql))
DBUG_RETURN(1);
DBUG_RETURN(0); /* No more results */
}
MYSQL_METHODS embedded_methods=
{
......@@ -259,7 +271,8 @@ MYSQL_METHODS embedded_methods=
emb_read_binary_rows,
emb_unbuffered_fetch,
emb_free_embedded_thd,
emb_read_statistic
emb_read_statistic,
emb_next_result
};
C_MODE_END
......@@ -749,6 +762,11 @@ bool Protocol::net_store_data(const char *from, uint length)
return false;
}
char *memdup_mysql(struct st_mysql *mysql, const char*data, int length)
{
return memdup_root(&mysql->field_alloc, data, length);
}
#if 0
/* The same as Protocol::net_store_data but does the converstion
*/
......
......@@ -64,12 +64,6 @@ test
select cast(_koi8r'' as char character set cp1251);
cast(_koi8r'' as char character set cp1251)
select convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci");
convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci")
test
select convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci");
convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci")
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
Table Create Table
......
......@@ -51,6 +51,20 @@ t1 CREATE TABLE `t1` (
`version` char(40) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
charset(charset(_utf8'a')) charset(collation(_utf8'a'))
utf8 utf8
select collation(charset(_utf8'a')), collation(collation(_utf8'a'));
collation(charset(_utf8'a')) collation(collation(_utf8'a'))
utf8_general_ci utf8_general_ci
create table t1 select charset(_utf8'a'), collation(_utf8'a');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`charset(_utf8'a')` char(64) character set utf8 NOT NULL default '',
`collation(_utf8'a')` char(64) character set utf8 NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select TRUE,FALSE,NULL;
TRUE FALSE NULL
1 0 NULL
......@@ -28,8 +28,6 @@ select CAST(DATE "2004-01-22 21:45:33" AS CHAR(4) BINARY);
set names binary;
select cast(_latin1'test' as char character set latin2);
select cast(_koi8r'' as char character set cp1251);
select convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci");
select convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci");
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
drop table t1;
......
......@@ -147,11 +147,6 @@ UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
SET CHARACTER SET koi8r;
SELECT * FROM t1;
#
# codecovarage for Item_func_conv_charset3
#
select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
explain extended select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
UPDATE t1 SET bin_f=koi8_ru_f;
......
......@@ -23,4 +23,10 @@ create table t1 (version char(40)) select database(), user(), version() as 'vers
show create table t1;
drop table t1;
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
select collation(charset(_utf8'a')), collation(collation(_utf8'a'));
create table t1 select charset(_utf8'a'), collation(_utf8'a');
show create table t1;
drop table t1;
select TRUE,FALSE,NULL;
......@@ -2124,42 +2124,6 @@ void Item_func_conv_charset::print(String *str)
str->append(')');
}
String *Item_func_conv_charset3::val_str(String *str)
{
char cs1[30], cs2[30];
String to_cs_buff(cs1, sizeof(cs1), default_charset_info);
String from_cs_buff(cs2, sizeof(cs2), default_charset_info);
String *arg= args[0]->val_str(str);
String *to_cs= args[1]->val_str(&to_cs_buff);
String *from_cs= args[2]->val_str(&from_cs_buff);
CHARSET_INFO *from_charset;
CHARSET_INFO *to_charset;
if (!arg || args[0]->null_value ||
!to_cs || args[1]->null_value ||
!from_cs || args[2]->null_value ||
!(from_charset=get_charset_by_name(from_cs->ptr(), MYF(MY_WME))) ||
!(to_charset=get_charset_by_name(to_cs->ptr(), MYF(MY_WME))))
{
null_value= 1;
return 0;
}
if (str_value.copy(arg->ptr(), arg->length(), from_charset, to_charset))
{
null_value= 1;
return 0;
}
null_value= 0;
return &str_value;
}
void Item_func_conv_charset3::fix_length_and_dec()
{
max_length = args[0]->max_length;
}
String *Item_func_set_collation::val_str(String *str)
{
str=args[0]->val_str(str);
......@@ -2226,7 +2190,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->csname,strlen(res->charset()->csname),
&my_charset_latin1, default_charset());
&my_charset_latin1, collation.collation);
return str;
}
......@@ -2237,7 +2201,7 @@ String *Item_func_collation::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name),
&my_charset_latin1, default_charset());
&my_charset_latin1, collation.collation);
return str;
}
......
......@@ -619,16 +619,6 @@ class Item_func_set_collation :public Item_str_func
void print(String *str) { print_op(str); }
};
class Item_func_conv_charset3 :public Item_str_func
{
public:
Item_func_conv_charset3(Item *arg1,Item *arg2,Item *arg3)
:Item_str_func(arg1,arg2,arg3) {}
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "convert"; }
};
class Item_func_charset :public Item_str_func
{
public:
......@@ -637,8 +627,8 @@ class Item_func_charset :public Item_str_func
const char *func_name() const { return "charset"; }
void fix_length_and_dec()
{
max_length=40; // should be enough
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
};
};
......@@ -650,8 +640,8 @@ class Item_func_collation :public Item_str_func
const char *func_name() const { return "collation"; }
void fix_length_and_dec()
{
max_length=40; // should be enough
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
};
};
......
......@@ -565,6 +565,8 @@ class THD :public ilink,
struct st_mysql_bind *client_params;
char *extra_data;
ulong extra_length;
char *query_rest;
uint32 query_rest_length;
#endif
NET net; // client connection descriptor
MEM_ROOT warn_root; // For warnings and errors
......
......@@ -48,6 +48,7 @@
extern "C" int gethostname(char *name, int namelen);
#endif
char *memdup_mysql(struct st_mysql *mysql, const char*data, int length);
static int check_for_max_user_connections(THD *thd, USER_CONN *uc);
static void decrease_user_connections(USER_CONN *uc);
static bool check_db_used(THD *thd,TABLE_LIST *tables);
......@@ -1397,11 +1398,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *packet= thd->lex->found_colon;
/*
Multiple queries exits, execute them individually
in embedded server - just store them to be executed later
*/
#ifndef EMBEDDED_LIBRARY
if (thd->lock || thd->open_tables || thd->derived_tables)
close_thread_tables(thd);
ulong length= thd->query_length-(ulong)(thd->lex->found_colon-thd->query);
#endif
ulong length= thd->query_length-(ulong)(packet-thd->query);
/* Remove garbage at start of query */
while (my_isspace(thd->charset(), *packet) && length > 0)
......@@ -1414,7 +1417,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id= query_id++;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
#ifndef EMBEDDED_LIBRARY
mysql_parse(thd, packet, length);
#else
thd->query_rest= (char*)memdup_mysql(thd->mysql, packet, length);
thd->query_rest_length= length;
break;
#endif /*EMBEDDED_LIBRARY*/
}
if (!(specialflag & SPECIAL_NO_PRIOR))
......
......@@ -2574,8 +2574,6 @@ simple_expr:
}
| CONVERT_SYM '(' expr USING charset_name ')'
{ $$= new Item_func_conv_charset($3,$5); }
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_conv_charset3($3,$7,$5); }
| DEFAULT '(' simple_ident ')'
{ $$= new Item_default_value($3); }
| VALUES '(' simple_ident ')'
......
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