summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2004-02-14 20:26:21 +0400
committerunknown <hf@deer.(none)>2004-02-14 20:26:21 +0400
commitb012018b7a126eec08867b0726b7fad5b31a153f (patch)
tree4dd52b37d447d33fe6e01db093004f501c36c60a /sql/sql_parse.cc
parenta02bf29344f3ac58a49866e4be73dfbc9100b162 (diff)
downloadmariadb-git-b012018b7a126eec08867b0726b7fad5b31a153f.tar.gz
Fix for #2212 (mysql_change_user doesn't work in embedded library)
now it's working include/mysql.h: read_change_user_result 'virtual' method added libmysql/client_settings.h: cli_read_change_user_result interface libmysql/libmysql.c: cli_read_change_user_result implementation libmysqld/lib_sql.cc: emb_read_change_user_result implementation sql-common/client.c: cli_read_change_user_result added to the method's table sql/sql_parse.cc: fixes to make mysql_change_user working in embedded library
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e2884b73444..caa9528298c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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);