summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysql.h1
-rw-r--r--libmysql/libmysql.c5
-rw-r--r--libmysqld/lib_sql.cc20
-rw-r--r--mysql-test/r/cast.result6
-rw-r--r--mysql-test/r/ctype_many.result123
-rw-r--r--mysql-test/r/func_system.result14
-rw-r--r--mysql-test/t/cast.test2
-rw-r--r--mysql-test/t/ctype_many.test5
-rw-r--r--mysql-test/t/func_system.test6
-rw-r--r--sql/item_strfunc.cc40
-rw-r--r--sql/item_strfunc.h14
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_parse.cc13
-rw-r--r--sql/sql_yacc.yy2
14 files changed, 59 insertions, 194 deletions
diff --git a/include/mysql.h b/include/mysql.h
index ebf3928ce9c..0bb42c7f5eb 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -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;
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 829ee09090e..5c5898dfd7d 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -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,8 +3478,8 @@ 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 */
}
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index e36e878d4b1..81235ce0c22 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -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
*/
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index c60d8e19fb4..877a349d188 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -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
diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result
index 173d41ecdd1..8bfc6e98226 100644
--- a/mysql-test/r/ctype_many.result
+++ b/mysql-test/r/ctype_many.result
@@ -340,129 +340,6 @@ CYR CAPIT SOFT SIGN ø ø
CYR CAPIT E ü ü
CYR CAPIT YU à à
CYR CAPIT YA ñ ñ
-select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
-CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci') comment
-a LAT SMALL A
-b LAT SMALL B
-c LAT SMALL C
-d LAT SMALL D
-e LAT SMALL E
-f LAT SMALL F
-g LAT SMALL G
-h LAT SMALL H
-i LAT SMALL I
-j LAT SMALL J
-k LAT SMALL K
-l LAT SMALL L
-m LAT SMALL M
-n LAT SMALL N
-o LAT SMALL O
-p LAT SMALL P
-q LAT SMALL Q
-r LAT SMALL R
-s LAT SMALL S
-t LAT SMALL T
-u LAT SMALL U
-v LAT SMALL V
-w LAT SMALL W
-x LAT SMALL X
-y LAT SMALL Y
-z LAT SMALL Z
-A LAT CAPIT A
-B LAT CAPIT B
-C LAT CAPIT C
-D LAT CAPIT D
-E LAT CAPIT E
-F LAT CAPIT F
-G LAT CAPIT G
-H LAT CAPIT H
-I LAT CAPIT I
-J LAT CAPIT J
-K LAT CAPIT K
-L LAT CAPIT L
-M LAT CAPIT M
-N LAT CAPIT N
-O LAT CAPIT O
-P LAT CAPIT P
-Q LAT CAPIT Q
-R LAT CAPIT R
-S LAT CAPIT S
-T LAT CAPIT T
-U LAT CAPIT U
-V LAT CAPIT V
-W LAT CAPIT W
-X LAT CAPIT X
-Y LAT CAPIT Y
-Z LAT CAPIT Z
-â CYR SMALL A
-÷ CYR SMALL BE
-þ CYR SMALL VE
-ú CYR SMALL GE
-ä CYR SMALL DE
-å CYR SMALL IE
-? CYR SMALL IO
-ã CYR SMALL ZHE
-ÿ CYR SMALL ZE
-ê CYR SMALL I
-ì CYR SMALL KA
-í CYR SMALL EL
-î CYR SMALL EM
-ï CYR SMALL EN
-ð CYR SMALL O
-ò CYR SMALL PE
-ô CYR SMALL ER
-õ CYR SMALL ES
-æ CYR SMALL TE
-è CYR SMALL U
-ö CYR SMALL EF
-é CYR SMALL HA
-ç CYR SMALL TSE
-à CYR SMALL CHE
-ù CYR SMALL SHA
-ü CYR SMALL SCHA
-ñ CYR SMALL HARD SIGN
-ý CYR SMALL YERU
-û CYR SMALL SOFT SIGN
-ø CYR SMALL E
-á CYR SMALL YU
-ó CYR SMALL YA
-Â CYR CAPIT A
-× CYR CAPIT BE
-Þ CYR CAPIT VE
-Ú CYR CAPIT GE
-Ä CYR CAPIT DE
-Å CYR CAPIT IE
-? CYR CAPIT IO
-Ã CYR CAPIT ZHE
-ß CYR CAPIT ZE
-Ê CYR CAPIT I
-Ì CYR CAPIT KA
-Í CYR CAPIT EL
-Î CYR CAPIT EM
-Ï CYR CAPIT EN
-Ð CYR CAPIT O
-Ò CYR CAPIT PE
-Ô CYR CAPIT ER
-Õ CYR CAPIT ES
-Æ CYR CAPIT TE
-È CYR CAPIT U
-Ö CYR CAPIT EF
-É CYR CAPIT HA
-Ç CYR CAPIT TSE
-À CYR CAPIT CHE
-Ù CYR CAPIT SHA
-Ü CYR CAPIT SCHA
-Ñ CYR CAPIT HARD SIGN
-Ý CYR CAPIT YERU
-Û CYR CAPIT SOFT SIGN
-Ø CYR CAPIT E
-Á CYR CAPIT YU
-Ó CYR CAPIT YA
-explain extended select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 116
-Warnings:
-Note 1003 select high_priority convert(test.t1.koi8_ru_f,_latin1'utf8_general_ci',_latin1'cp1251_general_ci') AS `CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci')`,test.t1.comment AS `comment` from test.t1
ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
UPDATE t1 SET bin_f=koi8_ru_f;
SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1;
diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result
index a0437ca1c56..338902e3f3a 100644
--- a/mysql-test/r/func_system.result
+++ b/mysql-test/r/func_system.result
@@ -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
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index ab0242990fc..fab35bb334a 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -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;
diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test
index 7b44439aa50..26057e7c997 100644
--- a/mysql-test/t/ctype_many.test
+++ b/mysql-test/t/ctype_many.test
@@ -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;
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index f3b9b4ffc3f..a05b80ca56b 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -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;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index fd1222d5f1a..ed6e44262c7 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -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;
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 465300e721e..4832ddbd1b1 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -619,16 +619,6 @@ public:
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 @@ public:
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 @@ public:
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
};
};
diff --git a/sql/sql_class.h b/sql/sql_class.h
index b3135202ad6..5034007cd4d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -565,6 +565,8 @@ public:
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
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 80aa575265b..81d6b80678d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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))
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 0dbe8981466..bdeaf5a0b86 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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 ')'