Commit ca6532af authored by iggy@rolltop.ignatz42.dyndns.org's avatar iggy@rolltop.ignatz42.dyndns.org

Merge rolltop.ignatz42.dyndns.org:/mnt/storeage/mysql-4.1-maint_20328

into  rolltop.ignatz42.dyndns.org:/mnt/storeage/mysql-5.0-maint_20328
parents da60a519 a86f035a
...@@ -891,6 +891,27 @@ t1 CREATE TABLE `t1` ( ...@@ -891,6 +891,27 @@ t1 CREATE TABLE `t1` (
`from_unixtime(1) + 0` double(23,6) default NULL `from_unixtime(1) + 0` double(23,6) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
H
120
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
H
120
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
H
05
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
H
5
End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -446,7 +446,25 @@ create table t1 select now() - now(), curtime() - curtime(), ...@@ -446,7 +446,25 @@ create table t1 select now() - now(), curtime() - curtime(),
show create table t1; show create table t1;
drop table t1; drop table t1;
# End of 4.1 tests #
# Bug #19844 time_format in Union truncates values
#
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
--echo End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
......
...@@ -1704,14 +1704,12 @@ uint Item_func_date_format::format_length(const String *format) ...@@ -1704,14 +1704,12 @@ uint Item_func_date_format::format_length(const String *format)
case 'u': /* week (00..52), where week starts with Monday */ case 'u': /* week (00..52), where week starts with Monday */
case 'V': /* week 1..53 used with 'x' */ case 'V': /* week 1..53 used with 'x' */
case 'v': /* week 1..53 used with 'x', where week starts with Monday */ case 'v': /* week 1..53 used with 'x', where week starts with Monday */
case 'H': /* hour (00..23) */
case 'y': /* year, numeric, 2 digits */ case 'y': /* year, numeric, 2 digits */
case 'm': /* month, numeric */ case 'm': /* month, numeric */
case 'd': /* day (of the month), numeric */ case 'd': /* day (of the month), numeric */
case 'h': /* hour (01..12) */ case 'h': /* hour (01..12) */
case 'I': /* --||-- */ case 'I': /* --||-- */
case 'i': /* minutes, numeric */ case 'i': /* minutes, numeric */
case 'k': /* hour ( 0..23) */
case 'l': /* hour ( 1..12) */ case 'l': /* hour ( 1..12) */
case 'p': /* locale's AM or PM */ case 'p': /* locale's AM or PM */
case 'S': /* second (00..61) */ case 'S': /* second (00..61) */
...@@ -1720,6 +1718,10 @@ uint Item_func_date_format::format_length(const String *format) ...@@ -1720,6 +1718,10 @@ uint Item_func_date_format::format_length(const String *format)
case 'e': /* day (0..31) */ case 'e': /* day (0..31) */
size += 2; size += 2;
break; break;
case 'k': /* hour ( 0..23) */
case 'H': /* hour (00..23; value > 23 OK, padding always 2-digit) */
size += 7; /* docs allow > 23, range depends on sizeof(unsigned int) */
break;
case 'r': /* time, 12-hour (hh:mm:ss [AP]M) */ case 'r': /* time, 12-hour (hh:mm:ss [AP]M) */
size += 11; size += 11;
break; break;
......
...@@ -3226,7 +3226,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -3226,7 +3226,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
rli->is_until_satisfied()) rli->is_until_satisfied())
{ {
char buf[22]; char buf[22];
sql_print_error("Slave SQL thread stopped because it reached its" sql_print_information("Slave SQL thread stopped because it reached its"
" UNTIL position %s", llstr(rli->until_pos(), buf)); " UNTIL position %s", llstr(rli->until_pos(), buf));
/* /*
Setting abort_slave flag because we do not want additional message about Setting abort_slave flag because we do not want additional message about
......
...@@ -4678,6 +4678,32 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables) ...@@ -4678,6 +4678,32 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
ACL_USER *check_acl_user(LEX_USER *user_name,
uint *acl_acl_userdx)
{
ACL_USER *acl_user= 0;
uint counter;
safe_mutex_assert_owner(&acl_cache->lock);
for (counter= 0 ; counter < acl_users.elements ; counter++)
{
const char *user,*host;
acl_user= dynamic_element(&acl_users, counter, ACL_USER*);
if (!(user=acl_user->user))
user= "";
if (!(host=acl_user->host.hostname))
host= "";
if (!strcmp(user_name->user.str,user) &&
!my_strcasecmp(system_charset_info, user_name->host.str, host))
break;
}
if (counter == acl_users.elements)
return 0;
*acl_acl_userdx= counter;
return acl_user;
}
/* /*
Modify a privilege table. Modify a privilege table.
...@@ -4701,7 +4727,6 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables) ...@@ -4701,7 +4727,6 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
static int modify_grant_table(TABLE *table, Field *host_field, static int modify_grant_table(TABLE *table, Field *host_field,
Field *user_field, LEX_USER *user_to) Field *user_field, LEX_USER *user_to)
{
int error; int error;
DBUG_ENTER("modify_grant_table"); DBUG_ENTER("modify_grant_table");
...@@ -4722,11 +4747,8 @@ static int modify_grant_table(TABLE *table, Field *host_field, ...@@ -4722,11 +4747,8 @@ static int modify_grant_table(TABLE *table, Field *host_field,
if ((error=table->file->delete_row(table->record[0]))) if ((error=table->file->delete_row(table->record[0])))
table->file->print_error(error, MYF(0)); table->file->print_error(error, MYF(0));
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} }
/* /*
Handle a privilege table. Handle a privilege table.
...@@ -4815,14 +4837,12 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, ...@@ -4815,14 +4837,12 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop,
DBUG_PRINT("info",("read result: %d", result)); DBUG_PRINT("info",("read result: %d", result));
} }
else else
{
/* /*
The non-'user' table do not have indexes on (host, user). The non-'user' table do not have indexes on (host, user).
And their host- and user fields are not consecutive. And their host- and user fields are not consecutive.
Thus, we need to do a table scan to find all matching records. Thus, we need to do a table scan to find all matching records.
*/ */
if ((error= table->file->ha_rnd_init(1))) if ((error= table->file->ha_rnd_init(1)))
{
table->file->print_error(error, MYF(0)); table->file->print_error(error, MYF(0));
result= -1; result= -1;
} }
...@@ -5026,7 +5046,6 @@ static int handle_grant_struct(uint struct_no, bool drop, ...@@ -5026,7 +5046,6 @@ static int handle_grant_struct(uint struct_no, bool drop,
acl_db->user= strdup_root(&mem, user_to->user.str); acl_db->user= strdup_root(&mem, user_to->user.str);
acl_db->host.hostname= strdup_root(&mem, user_to->host.str); acl_db->host.hostname= strdup_root(&mem, user_to->host.str);
break; break;
case 2: case 2:
case 3: case 3:
grant_name->user= strdup_root(&mem, user_to->user.str); grant_name->user= strdup_root(&mem, user_to->user.str);
...@@ -5036,7 +5055,6 @@ static int handle_grant_struct(uint struct_no, bool drop, ...@@ -5036,7 +5055,6 @@ static int handle_grant_struct(uint struct_no, bool drop,
} }
} }
else else
{
/* If search is requested, we do not need to search further. */ /* If search is requested, we do not need to search further. */
break; break;
} }
...@@ -5044,7 +5062,6 @@ static int handle_grant_struct(uint struct_no, bool drop, ...@@ -5044,7 +5062,6 @@ static int handle_grant_struct(uint struct_no, bool drop,
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan struct: %u result %d", struct_no, result)); DBUG_PRINT("loop",("scan struct: %u result %d", struct_no, result));
#endif #endif
DBUG_RETURN(result); DBUG_RETURN(result);
} }
...@@ -5097,7 +5114,6 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, ...@@ -5097,7 +5114,6 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
if (! drop && ! user_to) if (! drop && ! user_to)
goto end; goto end;
} }
}
/* Handle db table. */ /* Handle db table. */
if ((found= handle_grant_table(tables, 1, drop, user_from, user_to)) < 0) if ((found= handle_grant_table(tables, 1, drop, user_from, user_to)) < 0)
...@@ -5155,10 +5171,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, ...@@ -5155,10 +5171,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
/* Handle columns table. */ /* Handle columns table. */
if ((found= handle_grant_table(tables, 3, drop, user_from, user_to)) < 0) if ((found= handle_grant_table(tables, 3, drop, user_from, user_to)) < 0)
{
/* Handle of table failed, don't touch the in-memory array. */ /* Handle of table failed, don't touch the in-memory array. */
result= -1; result= -1;
}
else else
{ {
/* Handle columns hash. */ /* Handle columns hash. */
...@@ -5206,7 +5220,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) ...@@ -5206,7 +5220,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
List_iterator <LEX_USER> user_list(list); List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES]; TABLE_LIST tables[GRANT_TABLES];
DBUG_ENTER("mysql_create_user"); DBUG_ENTER("mysql_create_user");
/* CREATE USER may be skipped on replication client. */ /* CREATE USER may be skipped on replication client. */
if ((result= open_grant_tables(thd, tables))) if ((result= open_grant_tables(thd, tables)))
DBUG_RETURN(result != 1); DBUG_RETURN(result != 1);
...@@ -5235,19 +5248,16 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) ...@@ -5235,19 +5248,16 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
for a mention of the new user name. for a mention of the new user name.
*/ */
if (handle_grant_data(tables, 0, user_name, NULL)) if (handle_grant_data(tables, 0, user_name, NULL))
{
append_user(&wrong_users, user_name); append_user(&wrong_users, user_name);
result= TRUE; result= TRUE;
continue; continue;
} }
sql_mode= thd->variables.sql_mode; sql_mode= thd->variables.sql_mode;
if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0)) if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
{ {
append_user(&wrong_users, user_name); append_user(&wrong_users, user_name);
result= TRUE; result= TRUE;
} }
}
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
...@@ -5296,12 +5306,9 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) ...@@ -5296,12 +5306,9 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
continue; continue;
} }
if (handle_grant_data(tables, 1, user_name, NULL) <= 0) if (handle_grant_data(tables, 1, user_name, NULL) <= 0)
{
append_user(&wrong_users, user_name); append_user(&wrong_users, user_name);
result= TRUE; result= TRUE;
} }
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */ /* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host(); rebuild_check_host();
...@@ -5369,14 +5376,16 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list) ...@@ -5369,14 +5376,16 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
append_user(&wrong_users, user_from); append_user(&wrong_users, user_from);
result= TRUE; result= TRUE;
} }
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */ /* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
rebuild_check_host(); rebuild_check_host();
VOID(pthread_mutex_unlock(&acl_cache->lock)); VOID(pthread_mutex_unlock(&acl_cache->lock));
rw_unlock(&LOCK_grant); rw_unlock(&LOCK_grant);
close_thread_tables(thd); close_thread_tables(thd);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
if (result) if (result)
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe()); my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result); DBUG_RETURN(result);
......
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