Commit 1c1f26d5 authored by monty@mishka.local's avatar monty@mishka.local

Fixes during review of new pushed code

Fixed new bug when running a SP without a default database
parent c726451a
......@@ -966,4 +966,8 @@ column_name column_default
a NULL
b NULL
use test;
show columns from t1;
Field Type Null Key Default Extra
a int(11) NO
b int(11) YES NULL
drop table t1;
......@@ -245,6 +245,8 @@ end//
grant usage on *.* to mysqltest_1@localhost;
call mysqltest_1.p1();
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
call mysqltest_1.p1();
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
drop procedure mysqltest_1.p1;
drop database mysqltest_1;
revoke usage on *.* from mysqltest_1@localhost;
......
......@@ -649,4 +649,5 @@ use information_schema;
select column_name, column_default from columns
where table_schema='test' and table_name='t1';
use test;
show columns from t1;
drop table t1;
......@@ -397,6 +397,12 @@ connection n1;
--error 1370
call mysqltest_1.p1();
disconnect n1;
# Test also without a current database
connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n2;
--error 1370
call mysqltest_1.p1();
disconnect n2;
connection default;
......
......@@ -2176,9 +2176,6 @@ void Item_func_lpad::fix_length_and_dec()
{
ulonglong length= ((ulonglong) args[1]->val_int() *
collation.collation->mbmaxlen);
/*a comment before (merged) */
length= max((ulonglong)args[0]->max_length, length);
/*a comment after */
if (length >= MAX_BLOB_WIDTH)
{
length= MAX_BLOB_WIDTH;
......
......@@ -730,7 +730,8 @@ static void close_connections(void)
DBUG_PRINT("quit",("Informing thread %ld that it's time to die",
tmp->thread_id));
/* We skip slave threads on this first loop through. */
if (tmp->slave_thread) continue;
if (tmp->slave_thread)
continue;
tmp->killed= THD::KILL_CONNECTION;
if (tmp->mysys_var)
......
......@@ -150,14 +150,10 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
DBUG_ASSERT(share->table_name != 0);
if ((!share->table_name)) // To be removed
continue; // Shouldn't happen
if (db && my_strcasecmp(system_charset_info, db, share->table_cache_key))
if (db && my_strcasecmp(system_charset_info, db, share->db))
continue;
if (wild && wild_compare(share->table_name,wild,0))
continue;
if (wild)
{
if (wild_compare(share->table_name,wild,0))
continue;
}
/* Check if user has SELECT privilege for any column in the table */
table_list.db= (char*) share->db;
......@@ -3803,7 +3799,6 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
if (cur_left_neighbor &&
cur_table_ref->outer_join & JOIN_TYPE_RIGHT)
{
DBUG_ASSERT(cur_table_ref);
/* This can happen only for JOIN ... ON. */
DBUG_ASSERT(table_ref->nested_join->join_list.elements == 2);
swap_variables(TABLE_LIST*, cur_left_neighbor, cur_table_ref);
......@@ -3813,7 +3808,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
store_top_level_join_columns(thd, cur_table_ref,
cur_left_neighbor, cur_right_neighbor))
DBUG_RETURN(TRUE);
cur_right_neighbor= cur_table_ref;
cur_right_neighbor= cur_table_ref;
}
}
......
......@@ -998,7 +998,7 @@ static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp,
mysql_change_db()
thd Thread handler
name Databasename
no_access_check True= don't do access check
no_access_check True don't do access check. In this case name may be ""
DESCRIPTION
Becasue the database name may have been given directly from the
......@@ -1025,14 +1025,22 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
char *dbname=my_strdup((char*) name,MYF(MY_WME));
char path[FN_REFLEN];
HA_CREATE_INFO create;
bool schema_db= 0;
bool system_db= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access;
#endif
DBUG_ENTER("mysql_change_db");
DBUG_PRINT("enter",("name: '%s'",name));
/* dbname can only be NULL if malloc failed */
if (!dbname || !(db_length= strlen(dbname)))
{
if (no_access_check && dbname)
{
/* Called from SP when orignal database was not set */
system_db= 1;
goto end;
}
x_free(dbname); /* purecov: inspected */
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR),
MYF(0)); /* purecov: inspected */
......@@ -1047,7 +1055,7 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
DBUG_PRINT("info",("Use database: %s", dbname));
if (!my_strcasecmp(system_charset_info, dbname, information_schema_name.str))
{
schema_db= 1;
system_db= 1;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
db_access= SELECT_ACL;
#endif
......@@ -1055,13 +1063,15 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!no_access_check) {
if (!no_access_check)
{
if (test_all_bits(thd->master_access,DB_ACLS))
db_access=DB_ACLS;
else
db_access= (acl_get(thd->host,thd->ip, thd->priv_user,dbname,0) |
thd->master_access);
if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
if (!(db_access & DB_ACLS) && (!grant_option ||
check_grant_db(thd,dbname)))
{
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
thd->priv_user,
......@@ -1094,7 +1104,7 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
if (!no_access_check)
thd->db_access=db_access;
#endif
if (schema_db)
if (system_db)
{
thd->db_charset= system_charset_info;
thd->variables.collation_database= system_charset_info;
......
......@@ -238,7 +238,8 @@ static int get_or_create_user_conn(THD *thd, const char *user,
/*
Check if user exist and password supplied is correct.
Check if user exist and password supplied is correct.
SYNOPSIS
check_user()
thd thread handle, thd->{host,user,ip} are used
......@@ -273,6 +274,10 @@ int check_user(THD *thd, enum enum_server_command command,
/* Change database if necessary */
if (db && db[0])
{
/*
thd->db is saved in caller and needs to be freed by caller if this
function returns 0
*/
thd->db= 0;
thd->db_length= 0;
if (mysql_change_db(thd, db, FALSE))
......
This diff is collapsed.
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