Commit c15ffb8f authored by unknown's avatar unknown

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

into sinisa.nasamreza.org:/mnt/work/mysql-4.1


mysql-test/t/union.test:
  Auto merged
parents 3ba5b2c5 0fa94f2e
......@@ -575,6 +575,7 @@ typedef struct st_mysql_methods
void (*free_embedded_thd)(MYSQL *mysql);
const char *(*read_statistic)(MYSQL *mysql);
int (*next_result)(MYSQL *mysql);
int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
#endif
} MYSQL_METHODS;
......
......@@ -58,6 +58,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt);
int cli_unbuffered_fetch(MYSQL *mysql, char **row);
const char * cli_read_statistic(MYSQL *mysql);
int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd);
#ifdef EMBEDDED_LIBRARY
int init_embedded_server(int argc, char **argv, char **groups);
......
......@@ -606,13 +606,42 @@ mysql_connect(MYSQL *mysql,const char *host,
/**************************************************************************
Change user and database
**************************************************************************/
int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd)
{
NET *net= &mysql->net;
ulong pkt_length;
pkt_length= net_safe_read(mysql);
if (pkt_length == packet_error)
return 1;
if (pkt_length == 1 && net->read_pos[0] == 254 &&
mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
{
/*
By sending this very specific reply server asks us to send scrambled
password in old format. The reply contains scramble_323.
*/
scramble_323(buff, mysql->scramble, passwd);
if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net))
{
net->last_errno= CR_SERVER_LOST;
strmov(net->sqlstate, unknown_sqlstate);
strmov(net->last_error,ER(net->last_errno));
return 1;
}
/* Read what server thinks about out new auth message report */
if (net_safe_read(mysql) == packet_error)
return 1;
}
return 0;
}
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
const char *passwd, const char *db)
{
char buff[512],*end=buff;
NET *net= &mysql->net;
ulong pkt_length;
DBUG_ENTER("mysql_change_user");
if (!user)
......@@ -646,31 +675,8 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
/* Write authentication package */
simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (end-buff),1);
pkt_length= net_safe_read(mysql);
if (pkt_length == packet_error)
goto error;
if (pkt_length == 1 && net->read_pos[0] == 254 &&
mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
{
/*
By sending this very specific reply server asks us to send scrambled
password in old format. The reply contains scramble_323.
*/
scramble_323(buff, mysql->scramble, passwd);
if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net))
{
net->last_errno= CR_SERVER_LOST;
strmov(net->sqlstate, unknown_sqlstate);
strmov(net->last_error,ER(net->last_errno));
goto error;
}
/* Read what server thinks about out new auth message report */
if (net_safe_read(mysql) == packet_error)
goto error;
}
if ((*mysql->methods->read_change_user_result)(mysql, buff, passwd))
DBUG_RETURN(1);
/* Free old connect information */
my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
......@@ -681,9 +687,6 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
mysql->passwd=my_strdup(passwd,MYF(MY_WME));
mysql->db= db ? my_strdup(db,MYF(MY_WME)) : 0;
DBUG_RETURN(0);
error:
DBUG_RETURN(1);
}
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
......
......@@ -258,6 +258,13 @@ int emb_next_result(MYSQL *mysql)
DBUG_RETURN(0); /* No more results */
}
int emb_read_change_user_result(MYSQL *mysql,
char *buff __attribute__((unused)),
const char *passwd __attribute__((unused)))
{
return mysql_errno(mysql);
}
MYSQL_METHODS embedded_methods=
{
emb_mysql_read_query_result,
......@@ -272,7 +279,8 @@ MYSQL_METHODS embedded_methods=
emb_unbuffered_fetch,
emb_free_embedded_thd,
emb_read_statistic,
emb_next_result
emb_next_result,
emb_read_change_user_result
};
C_MODE_END
......@@ -612,8 +620,8 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
}
else
{
client_field->def= strdup_root(field_alloc, tmp.ptr());
client_field->def_length= tmp.length();
client_field->def= strdup_root(field_alloc, res->ptr());
client_field->def_length= res->length();
}
}
else
......
......@@ -522,7 +522,7 @@ set @a:=(SELECT a from t1);
CREATE TABLE t1 (a int, KEY(a));
HANDLER t1 OPEN;
-- error 1149
-- error 1064
HANDLER t1 READ a=((SELECT 1));
HANDLER t1 CLOSE;
drop table t1;
......
......@@ -213,7 +213,7 @@ select found_rows();
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
select found_rows();
# This used to work in 4.0 but not anymore in 4.1
--error 1149
--error 1064
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
#select found_rows();
......
......@@ -1421,7 +1421,8 @@ static MYSQL_METHODS client_methods=
cli_unbuffered_fetch,
NULL,
cli_read_statistic,
cli_read_query_result
cli_read_query_result,
cli_read_change_user_result
#endif
};
......
......@@ -206,7 +206,21 @@ int check_user(THD *thd, enum enum_server_command command,
#ifdef NO_EMBEDDED_ACCESS_CHECKS
thd->master_access= GLOBAL_ACLS; // Full rights
return 0;
/* Change database if necessary: OK or FAIL is sent in mysql_change_db */
if (db && db[0])
{
thd->db= 0;
thd->db_length= 0;
if (mysql_change_db(thd, db))
{
if (thd->user_connect)
decrease_user_connections(thd->user_connect);
DBUG_RETURN(-1);
}
}
else
send_ok(thd);
DBUG_RETURN(0);
#else
my_bool opt_secure_auth_local;
......@@ -1282,7 +1296,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
send_error(thd); // dump to NET
break;
}
#ifndef EMBEDDED_LIBRARY
case COM_CHANGE_USER:
{
thd->change_user();
......@@ -1301,13 +1314,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
*passwd++ : strlen(passwd);
db+= passwd_len + 1;
#ifndef EMBEDDED_LIBRARY
/* Small check for incomming packet */
if ((uint) ((uchar*) db - net->read_pos) > packet_length)
{
send_error(thd, ER_UNKNOWN_COM_ERROR);
break;
}
#endif
/* Convert database name to utf8 */
db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1,
system_charset_info, db, strlen(db),
......@@ -1358,7 +1372,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
break;
}
#endif /* EMBEDDED_LIBRARY */
case COM_EXECUTE:
{
mysql_stmt_execute(thd, packet);
......
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