Merge bk-internal.mysql.com:/data0/bk/mysql-5.1

into  bk-internal.mysql.com:/data0/bk/mysql-5.1-marvel


mysql-test/r/strict.result:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
This commit is contained in:
unknown 2007-04-17 15:45:35 +02:00
commit 9340cb193e
132 changed files with 2524 additions and 1070 deletions

View file

@ -67,5 +67,5 @@ enum options_client
OPT_SLAP_POST_QUERY, OPT_SLAP_POST_QUERY,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_WRITE_BINLOG OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG
}; };

View file

@ -885,14 +885,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_nopager= 1; opt_nopager= 1;
break; break;
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break; break;
}
break; break;
case 'A': case 'A':
opt_rehash= 0; opt_rehash= 0;

View file

@ -287,15 +287,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif #endif
break; break;
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break; break;
} }
}
if (error) if (error)
{ {
usage(); usage();

View file

@ -944,14 +944,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
remote_opt= 1; remote_opt= 1;
break; break;
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break; break;
}
case OPT_START_DATETIME: case OPT_START_DATETIME:
start_datetime= convert_str_to_timestamp(start_datetime_str); start_datetime= convert_str_to_timestamp(start_datetime_str);
break; break;
@ -1167,7 +1162,7 @@ could be out of memory");
} }
if (len < 8 && net->read_pos[0] == 254) if (len < 8 && net->read_pos[0] == 254)
break; // end of data break; // end of data
DBUG_PRINT("info",( "len: %lu, net->read_pos[5]: %d\n", DBUG_PRINT("info",( "len: %lu net->read_pos[5]: %d\n",
len, net->read_pos[5])); len, net->read_pos[5]));
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 , if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error_msg, len - 1, &error_msg,
@ -1222,6 +1217,18 @@ could be out of memory");
len= 1; // fake Rotate, so don't increment old_off len= 1; // fake Rotate, so don't increment old_off
} }
} }
else if (type == FORMAT_DESCRIPTION_EVENT)
{
/*
This could be an fake Format_description_log_event that server
(5.0+) automatically sends to a slave on connect, before sending
a first event at the requested position. If this is the case,
don't increment old_off. Real Format_description_log_event always
starts from BIN_LOG_HEADER_SIZE position.
*/
if (old_off != BIN_LOG_HEADER_SIZE)
len= 1; // fake event, don't increment old_off
}
if ((error= process_event(print_event_info, ev, old_off))) if ((error= process_event(print_event_info, ev, old_off)))
{ {
error= ((error < 0) ? 0 : 1); error= ((error < 0) ? 0 : 1);
@ -1234,16 +1241,16 @@ could be out of memory");
const char *old_fname= le->fname; const char *old_fname= le->fname;
uint old_len= le->fname_len; uint old_len= le->fname_len;
File file; File file;
if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0) if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0)
{ {
error= 1; error= 1;
goto err; goto err;
} }
if ((error= process_event(print_event_info, ev, old_off))) if ((error= process_event(print_event_info, ev, old_off)))
{ {
my_close(file,MYF(MY_WME)); my_close(file,MYF(MY_WME));
error= ((error < 0) ? 0 : 1); error= ((error < 0) ? 0 : 1);
goto err; goto err;
} }
@ -1256,8 +1263,8 @@ could be out of memory");
} }
} }
/* /*
Let's adjust offset for remote log as for local log to produce Let's adjust offset for remote log as for local log to produce
similar text. similar text and to have --stop-position to work identically.
*/ */
old_off+= len-1; old_off+= len-1;
} }

View file

@ -315,15 +315,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case 'V': print_version(); exit(0); case 'V': print_version(); exit(0);
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break; break;
} }
}
return 0; return 0;
} }

View file

@ -109,7 +109,8 @@ static char *opt_password=0,*current_user=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
*where=0, *order_by=0, *where=0, *order_by=0,
*opt_compatible_mode_str= 0, *opt_compatible_mode_str= 0,
*err_ptr= 0; *err_ptr= 0,
*log_error_file= NULL;
static char **defaults_argv= 0; static char **defaults_argv= 0;
static char compatible_mode_normal_str[255]; static char compatible_mode_normal_str[255];
static ulong opt_compatible_mode= 0; static ulong opt_compatible_mode= 0;
@ -120,7 +121,9 @@ static my_string opt_mysql_unix_port=0;
static int first_error=0; static int first_error=0;
static DYNAMIC_STRING extended_row; static DYNAMIC_STRING extended_row;
#include <sslopt-vars.h> #include <sslopt-vars.h>
FILE *md_result_file= 0; FILE *md_result_file= 0;
FILE *stderror_file=0;
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
static char *shared_memory_base_name=0; static char *shared_memory_base_name=0;
#endif #endif
@ -320,6 +323,9 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables, {"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables,
(gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.",
(gptr*) &log_error_file, (gptr*) &log_error_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"master-data", OPT_MASTER_DATA, {"master-data", OPT_MASTER_DATA,
"This causes the binary log position and filename to be appended to the " "This causes the binary log position and filename to be appended to the "
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal" "output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
@ -801,14 +807,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
} }
case (int) OPT_MYSQL_PROTOCOL: case (int) OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{ break;
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break;
}
} }
return 0; return 0;
} }
@ -4210,6 +4211,16 @@ int main(int argc, char **argv)
free_resources(0); free_resources(0);
exit(exit_code); exit(exit_code);
} }
if (log_error_file)
{
if(!(stderror_file= freopen(log_error_file, "a+", stderr)))
{
free_resources(0);
exit(EX_MYSQLERR);
}
}
if (connect_to_db(current_host, current_user, opt_password)) if (connect_to_db(current_host, current_user, opt_password))
{ {
free_resources(0); free_resources(0);
@ -4273,5 +4284,9 @@ err:
if (!path) if (!path)
write_footer(md_result_file); write_footer(md_result_file);
free_resources(); free_resources();
if (stderror_file)
fclose(stderror_file);
return(first_error); return(first_error);
} /* main */ } /* main */

View file

@ -231,14 +231,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
#endif #endif
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break; break;
}
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
break; break;

View file

@ -287,14 +287,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif #endif
break; break;
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break; break;
}
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
break; break;

View file

@ -689,14 +689,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif #endif
break; break;
case OPT_MYSQL_PROTOCOL: case OPT_MYSQL_PROTOCOL:
{ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) opt->name);
{ break;
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break;
}
case '#': case '#':
DBUG_PUSH(argument ? argument : default_dbug_option); DBUG_PUSH(argument ? argument : default_dbug_option);
break; break;

View file

@ -2498,17 +2498,20 @@ wait_for_position:
if (!(res= mysql_store_result(mysql))) if (!(res= mysql_store_result(mysql)))
die("mysql_store_result() returned NULL for '%s'", query_buf); die("mysql_store_result() returned NULL for '%s'", query_buf);
if (!(row= mysql_fetch_row(res))) if (!(row= mysql_fetch_row(res)))
{
mysql_free_result(res);
die("empty result in %s", query_buf); die("empty result in %s", query_buf);
}
if (!row[0]) if (!row[0])
{ {
/* /*
It may be that the slave SQL thread has not started yet, though START It may be that the slave SQL thread has not started yet, though START
SLAVE has been issued ? SLAVE has been issued ?
*/ */
mysql_free_result(res);
if (tries++ == 30) if (tries++ == 30)
die("could not sync with master ('%s' returned NULL)", query_buf); die("could not sync with master ('%s' returned NULL)", query_buf);
sleep(1); /* So at most we will wait 30 seconds and make 31 tries */ sleep(1); /* So at most we will wait 30 seconds and make 31 tries */
mysql_free_result(res);
goto wait_for_position; goto wait_for_position;
} }
mysql_free_result(res); mysql_free_result(res);
@ -2549,6 +2552,7 @@ int do_save_master_pos()
MYSQL *mysql = &cur_con->mysql; MYSQL *mysql = &cur_con->mysql;
const char *query; const char *query;
int rpl_parse; int rpl_parse;
DBUG_ENTER("do_save_master_pos");
rpl_parse = mysql_rpl_parse_enabled(mysql); rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql); mysql_disable_rpl_parse(mysql);
@ -2706,7 +2710,7 @@ int do_save_master_pos()
if (rpl_parse) if (rpl_parse)
mysql_enable_rpl_parse(mysql); mysql_enable_rpl_parse(mysql);
return 0; DBUG_RETURN(0);
} }
@ -3161,7 +3165,7 @@ struct st_connection * find_connection_by_name(const char *name)
int select_connection_name(const char *name) int select_connection_name(const char *name)
{ {
DBUG_ENTER("select_connection2"); DBUG_ENTER("select_connection_name");
DBUG_PRINT("enter",("name: '%s'", name)); DBUG_PRINT("enter",("name: '%s'", name));
if (!(cur_con= find_connection_by_name(name))) if (!(cur_con= find_connection_by_name(name)))
@ -3184,7 +3188,7 @@ int select_connection(struct st_command *command)
if (*p) if (*p)
*p++= 0; *p++= 0;
command->last_argument= p; command->last_argument= p;
return select_connection_name(name); DBUG_RETURN(select_connection_name(name));
} }

View file

@ -95,6 +95,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NO_RESULT_SET 2053 #define CR_NO_RESULT_SET 2053
#define CR_NOT_IMPLEMENTED 2054 #define CR_NOT_IMPLEMENTED 2054
#define CR_SERVER_LOST_EXTENDED 2055 #define CR_SERVER_LOST_EXTENDED 2055
#define CR_ERROR_LAST /*Copy last error nr:*/ 2055 #define CR_STMT_CLOSED 2056
#define CR_ERROR_LAST /*Copy last error nr:*/ 2056
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */ /* Add error numbers before CR_ERROR_LAST and change it accordingly. */

View file

@ -51,8 +51,6 @@ typedef long my_time_t;
/* two-digit years < this are 20..; >= this are 19.. */ /* two-digit years < this are 20..; >= this are 19.. */
#define YY_PART_YEAR 70 #define YY_PART_YEAR 70
/* apply above magic to years < this */
#define YY_MAGIC_BELOW 200
/* Flags to str_to_datetime */ /* Flags to str_to_datetime */
#define TIME_FUZZY_DATE 1 #define TIME_FUZZY_DATE 1
@ -95,6 +93,7 @@ int check_time_range(struct st_mysql_time *, int *warning);
long calc_daynr(uint year,uint month,uint day); long calc_daynr(uint year,uint month,uint day);
uint calc_days_in_year(uint year); uint calc_days_in_year(uint year);
uint year_2000_handling(uint year);
void init_time(void); void init_time(void);

View file

@ -26,8 +26,9 @@ typedef struct st_typelib { /* Different types saved here */
unsigned int *type_lengths; unsigned int *type_lengths;
} TYPELIB; } TYPELIB;
extern int find_type(char *x, const TYPELIB *typelib, extern int find_type_or_exit(const char *x, TYPELIB *typelib,
unsigned int full_name); const char *option);
extern int find_type(char *x, const TYPELIB *typelib, unsigned int full_name);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr); extern const char *get_type(TYPELIB *typelib,unsigned int nr);
extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from); extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);

View file

@ -41,7 +41,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename);
void mysql_read_default_options(struct st_mysql_options *options, void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group); const char *filename,const char *group);
void mysql_detach_stmt_list(LIST **stmt_list); void mysql_detach_stmt_list(LIST **stmt_list, const char *func_name);
MYSQL * MYSQL *
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user, cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db, const char *passwd, const char *db,

View file

@ -83,6 +83,7 @@ const char *client_errors[]=
"Attempt to read a row while there is no result set associated with the statement", "Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet", "This feature is not implemented yet",
"Lost connection to MySQL server at '%s', system error: %d", "Lost connection to MySQL server at '%s', system error: %d",
"Statement closed indirectly because of a preceeding %s() call",
"" ""
}; };
@ -147,6 +148,7 @@ const char *client_errors[]=
"Attempt to read a row while there is no result set associated with the statement", "Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet", "This feature is not implemented yet",
"Lost connection to MySQL server at '%s', system error: %d", "Lost connection to MySQL server at '%s', system error: %d",
"Statement closed indirectly because of a preceeding %s() call",
"" ""
}; };
@ -209,6 +211,7 @@ const char *client_errors[]=
"Attempt to read a row while there is no result set associated with the statement", "Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet", "This feature is not implemented yet",
"Lost connection to MySQL server at '%s', system error: %d", "Lost connection to MySQL server at '%s', system error: %d",
"Statement closed indirectly because of a preceeding %s() call",
"" ""
}; };
#endif #endif

View file

@ -715,7 +715,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
The server will close all statements no matter was the attempt The server will close all statements no matter was the attempt
to change user successful or not. to change user successful or not.
*/ */
mysql_detach_stmt_list(&mysql->stmts); mysql_detach_stmt_list(&mysql->stmts, "mysql_change_user");
if (rc == 0) if (rc == 0)
{ {
/* Free old connect information */ /* Free old connect information */
@ -2872,7 +2872,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
if (!mysql) if (!mysql)
{ {
set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); /* Error is already set in mysql_detatch_stmt_list */
DBUG_RETURN(1); DBUG_RETURN(1);
} }

View file

@ -6,6 +6,9 @@
# Requires statement logging # Requires statement logging
-- source include/master-slave.inc -- source include/master-slave.inc
# We have to sync with master, to ensure slave had time to start properly
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
sync_slave_with_master;
connection slave; connection slave;
stop slave; stop slave;
connection master; connection master;

View file

@ -10,6 +10,10 @@
-- source include/master-slave.inc -- source include/master-slave.inc
# We have to sync with master, to ensure slave had time to start properly
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
connection master;
sync_slave_with_master;
connection slave; connection slave;
stop slave; stop slave;
connection master; connection master;

View file

@ -5,6 +5,11 @@ source ./include/master-slave.inc;
# remote table creation # remote table creation
# We have to sync with master, to ensure slave had time to start properly
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
connection master;
sync_slave_with_master;
connection slave; connection slave;
#--replicate-ignore-db=federated #--replicate-ignore-db=federated
stop slave; stop slave;

View file

@ -2,10 +2,8 @@ connection master;
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
--enable_warnings
connection slave; connection slave;
--disable_warnings
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
--enable_warnings --enable_warnings

View file

@ -1,5 +1,5 @@
-- require r/not_embedded.require -- require r/not_embedded.require
disable_query_log; disable_query_log;
select version() like N'%embedded%' as 'have_embedded'; select version() like '%embedded%' as 'have_embedded';
enable_query_log; enable_query_log;

View file

@ -534,7 +534,7 @@ sub collect_one_test_case($$$$$$$) {
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) ) ! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
{ {
$tinfo->{'skip'}= 1; $tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Not running with binlog format '$tinfo->{'binlog_format'}'"; $tinfo->{'comment'}= "Requiring binlog format '$tinfo->{'binlog_format'}'";
return; return;
} }
@ -599,7 +599,7 @@ our @tags=
( (
["include/have_innodb.inc", "innodb_test", 1], ["include/have_innodb.inc", "innodb_test", 1],
["include/have_binlog_format_row.inc", "binlog_format", "row"], ["include/have_binlog_format_row.inc", "binlog_format", "row"],
["include/have_binlog_format_statement.inc", "binlog_format", "stmt"], ["include/have_binlog_format_statement.inc", "binlog_format", "statement"],
["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"], ["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"],
["include/big_test.inc", "big_test", 1], ["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1], ["include/have_debug.inc", "need_debug", 1],

View file

@ -3278,9 +3278,9 @@ sub do_after_run_mysqltest($)
} }
sub run_testcase_mark_logs($) sub run_testcase_mark_logs($$)
{ {
my ($log_msg)= @_; my ($tinfo, $log_msg)= @_;
# Write a marker to all log files # Write a marker to all log files
@ -3293,6 +3293,12 @@ sub run_testcase_mark_logs($)
mtr_tofile($mysqld->{path_myerr}, $log_msg); mtr_tofile($mysqld->{path_myerr}, $log_msg);
} }
if ( $tinfo->{'component_id'} eq 'im')
{
mtr_tofile($instance_manager->{path_err}, $log_msg);
mtr_tofile($instance_manager->{path_log}, $log_msg);
}
# ndbcluster log file # ndbcluster log file
mtr_tofile($path_ndb_testrun_log, $log_msg); mtr_tofile($path_ndb_testrun_log, $log_msg);
@ -3419,7 +3425,7 @@ sub run_testcase ($) {
} }
# Write to all log files to indicate start of testcase # Write to all log files to indicate start of testcase
run_testcase_mark_logs("CURRENT_TEST: $tinfo->{name}\n"); run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
my $died= mtr_record_dead_children(); my $died= mtr_record_dead_children();
if ($died or $master_restart or $slave_restart) if ($died or $master_restart or $slave_restart)
@ -3493,7 +3499,7 @@ sub run_testcase ($) {
# Stop Instance Manager if we are processing an IM-test case. # Stop Instance Manager if we are processing an IM-test case.
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if ( $tinfo->{'component_id'} eq 'im' and if ( $tinfo->{'component_id'} eq 'im' and
!mtr_im_stop($instance_manager, $tinfo->{'name'}) ) !mtr_im_stop($instance_manager, $tinfo->{'name'}))
{ {
mtr_error("Failed to stop Instance Manager.") mtr_error("Failed to stop Instance Manager.")
} }

View file

@ -3,13 +3,13 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
insert delayed into t1 values (207); insert delayed into t1 values (207);
insert delayed into t1 values (null); insert delayed into t1 values (null);
insert delayed into t1 values (300); insert delayed into t1 values (300);
show binlog events from 102; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (207) master-bin.000001 # Query # # use `test`; insert delayed into t1 values (207)
master-bin.000001 # Intvar 1 # INSERT_ID=208 master-bin.000001 # Intvar # # INSERT_ID=208
master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (null) master-bin.000001 # Query # # use `test`; insert delayed into t1 values (null)
master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (300) master-bin.000001 # Query # # use `test`; insert delayed into t1 values (300)
insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(null),(null);
insert delayed into t1 values (null),(null),(400),(null); insert delayed into t1 values (null),(null),(400),(null);
11 == 11 11 == 11

View file

@ -91,6 +91,8 @@ create table t1 (date char(30), format char(30) not null);
insert into t1 values insert into t1 values
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'), ('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'), ('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'), ('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'), ('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'), ('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
@ -122,6 +124,8 @@ select date,format,str_to_date(date, format) as str_to_date from t1;
date format str_to_date date format str_to_date
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
@ -153,6 +157,8 @@ select date,format,concat('',str_to_date(date, format)) as con from t1;
date format con date format con
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
@ -184,6 +190,8 @@ select date,format,cast(str_to_date(date, format) as datetime) as datetime from
date format datetime date format datetime
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
@ -215,6 +223,8 @@ select date,format,DATE(str_to_date(date, format)) as date2 from t1;
date format date2 date format date2
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02
@ -246,6 +256,8 @@ select date,format,TIME(str_to_date(date, format)) as time from t1;
date format time date format time
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
@ -277,6 +289,8 @@ select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
date format time2 date format time2
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
@ -402,14 +416,14 @@ select date,format,str_to_date(date, format) as str_to_date from t1;
date format str_to_date date format str_to_date
10:20:10AM %h:%i:%s 0000-00-00 10:20:10 10:20:10AM %h:%i:%s 0000-00-00 10:20:10
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12 03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
Warnings: Warnings:
Warning 1292 Incorrect datetime value: '10:20:10AM' Warning 1292 Incorrect datetime value: '10:20:10AM'
select date,format,concat(str_to_date(date, format),'') as con from t1; select date,format,concat(str_to_date(date, format),'') as con from t1;
date format con date format con
10:20:10AM %h:%i:%s 0000-00-00 10:20:10 10:20:10AM %h:%i:%s 0000-00-00 10:20:10
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12 2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12 03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
Warnings: Warnings:
Warning 1292 Incorrect datetime value: '10:20:10AM' Warning 1292 Incorrect datetime value: '10:20:10AM'
drop table t1; drop table t1;

View file

@ -75,6 +75,12 @@ NULL
select weekofyear("1997-11-30 23:59:59.000001"); select weekofyear("1997-11-30 23:59:59.000001");
weekofyear("1997-11-30 23:59:59.000001") weekofyear("1997-11-30 23:59:59.000001")
48 48
select makedate(03,1);
makedate(03,1)
2003-01-01
select makedate('0003',1);
makedate('0003',1)
2003-01-01
select makedate(1997,1); select makedate(1997,1);
makedate(1997,1) makedate(1997,1)
1997-01-01 1997-01-01

View file

@ -1225,13 +1225,13 @@ TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s")
End of 5.0 tests End of 5.0 tests
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND) date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
NULL 0049-12-31 23:59:59
select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND) date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND)
NULL 0198-12-31 23:59:59
select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND); select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND) date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND)
NULL 0200-01-01 00:00:01
select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND) date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
0199-12-31 23:59:59 0199-12-31 23:59:59
@ -1252,8 +1252,8 @@ date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND)
1989-12-31 23:59:59 1989-12-31 23:59:59
select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND) date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND)
NULL 0068-12-31 23:59:59
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND); select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND) date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
NULL 0168-12-31 23:59:59
End of 5.1 tests End of 5.1 tests

View file

@ -1,3 +1,4 @@
SET GLOBAL log_bin_trust_function_creators = 1;
drop table if exists t1; drop table if exists t1;
drop database if exists mysqltest; drop database if exists mysqltest;
SET NAMES binary; SET NAMES binary;
@ -1059,6 +1060,128 @@ DROP DATABASE bug23556;
DROP USER bug23556@localhost; DROP USER bug23556@localhost;
GRANT PROCESS ON * TO user@localhost; GRANT PROCESS ON * TO user@localhost;
ERROR 3D000: No database selected ERROR 3D000: No database selected
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS mysqltest3;
DROP DATABASE IF EXISTS mysqltest4;
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
CREATE DATABASE mysqltest3;
CREATE DATABASE mysqltest4;
CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
SELECT 1;
CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
SELECT 1;
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
RETURN 1;
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
RETURN 1;
GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
---> connection: bug9504_con1
use mysqltest1;
use mysqltest2;
use mysqltest3;
use mysqltest4;
use test;
CALL mysqltest1.p_def();
1
1
CALL mysqltest2.p_inv();
1
1
SELECT mysqltest3.f_def();
mysqltest3.f_def()
1
SELECT mysqltest4.f_inv();
mysqltest4.f_inv()
1
---> connection: default
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP DATABASE mysqltest3;
DROP DATABASE mysqltest4;
DROP USER mysqltest_1@localhost;
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
SELECT 1;
---> connection: bug27337_con1
CREATE TABLE t1(c INT);
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
CALL mysqltest1.p1();
1
1
CREATE TABLE t1(c INT);
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
---> connection: bug27337_con2
CREATE TABLE t1(c INT);
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
SHOW TABLES;
Tables_in_mysqltest2
---> connection: default
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
CREATE TABLE mysqltest1.t1(c INT);
CREATE TABLE mysqltest2.t2(c INT);
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
---> connection: bug27337_con1
SHOW TABLES FROM mysqltest1;
Tables_in_mysqltest1
t1
PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
EXECUTE stmt1;
Tables_in_mysqltest1
t1
---> connection: bug27337_con2
SHOW COLUMNS FROM mysqltest2.t2;
Field Type Null Key Default Extra
c int(11) YES NULL
PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
EXECUTE stmt2;
Field Type Null Key Default Extra
c int(11) YES NULL
---> connection: default
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
---> connection: bug27337_con1
SHOW TABLES FROM mysqltest1;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
EXECUTE stmt1;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
---> connection: bug27337_con2
SHOW COLUMNS FROM mysqltest2.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
EXECUTE stmt2;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
---> connection: default
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
End of 5.0 tests End of 5.0 tests
set names utf8; set names utf8;
grant select on test.* to юзер_юзер@localhost; grant select on test.* to юзер_юзер@localhost;

View file

@ -117,16 +117,82 @@ use testdb_1;
create table t1 (f1 char(4)); create table t1 (f1 char(4));
create view v1 as select f1 from t1; create view v1 as select f1 from t1;
grant insert on v1 to testdb_2@localhost; grant insert on v1 to testdb_2@localhost;
create view v5 as select f1 from t1;
grant show view on v5 to testdb_2@localhost;
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
ERROR 42000: Access denied; you need the SUPER privilege for this operation
use testdb_1;
create view v6 as select f1 from t1;
grant show view on v6 to testdb_2@localhost;
create table t2 (f1 char(4));
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
show fields from testdb_1.v6;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view testdb_1.v6;
View Create View
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1`
show create view testdb_1.v7;
View Create View
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
Warnings:
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
show fields from testdb_1.v7;
Field Type Null Key Default Extra
f1 null YES NULL
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
create table t3 (f1 char(4), f2 char(4)); create table t3 (f1 char(4), f2 char(4));
create view v3 as select f1,f2 from t3; create view v3 as select f1,f2 from t3;
grant insert(f1), insert(f2) on v3 to testdb_2@localhost; grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
create view v2 as select f1 from testdb_1.v1; create view v2 as select f1 from testdb_1.v1;
create view v4 as select f1,f2 from testdb_1.v3; create view v4 as select f1,f2 from testdb_1.v3;
show fields from testdb_1.v5;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view testdb_1.v5;
View Create View
v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
show fields from testdb_1.v6;
Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view testdb_1.v6;
View Create View
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
show fields from testdb_1.v7;
Field Type Null Key Default Extra
f1 null YES NULL
Warnings:
Note 1449 There is no 'no_such_user'@'no_such_host' registered
show create view testdb_1.v7;
View Create View
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
Warnings:
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
revoke insert(f1) on v3 from testdb_2@localhost; revoke insert(f1) on v3 from testdb_2@localhost;
revoke show view on v5 from testdb_2@localhost;
use testdb_1;
revoke show view on v6 from testdb_2@localhost;
show fields from testdb_1.v5;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
show create view testdb_1.v5;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
show fields from testdb_1.v6;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
show create view testdb_1.v6;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
show fields from testdb_1.v7;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
show create view testdb_1.v7;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
show create view v4; show create view v4;
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
show fields from v4; show fields from v4;
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table Field Type Null Key Default Extra
f1 null YES NULL
f2 char(4) YES NULL
show fields from v2; show fields from v2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
f1 char(4) YES NULL f1 char(4) YES NULL
@ -151,7 +217,8 @@ where a.table_name = 'testdb_1.v1';
view_definition view_definition
select * from v2; select * from v2;
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
drop view testdb_1.v1,v2, testdb_1.v3, v4; use test;
drop view testdb_1.v1, v2, testdb_1.v3, v4;
drop database testdb_1; drop database testdb_1;
drop user testdb_1@localhost; drop user testdb_1@localhost;
drop user testdb_2@localhost; drop user testdb_2@localhost;

View file

@ -7,3 +7,4 @@ SOCKET
ERROR 2047 (HY000): Wrong or unknown protocol ERROR 2047 (HY000): Wrong or unknown protocol
ERROR 2047 (HY000): Wrong or unknown protocol ERROR 2047 (HY000): Wrong or unknown protocol
Unknown option to protocol: NullS Unknown option to protocol: NullS
Alternatives are: 'TCP','SOCKET','PIPE','MEMORY'

View file

@ -122,6 +122,23 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */; ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
--- start and stop positions ---
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
SET INSERT_ID=4/*!*/;
use test/*!*/;
SET TIMESTAMP=1579609946/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
insert into t1 values(null, "d")/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
--- start-datetime -- --- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
@ -482,6 +499,23 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */; ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
--- start and stop positions ---
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
SET INSERT_ID=4/*!*/;
use test/*!*/;
SET TIMESTAMP=1579609946/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
insert into t1 values(null, "d")/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
--- start-datetime -- --- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;

View file

@ -2961,20 +2961,26 @@ delete from t9 ;
test_sequence test_sequence
-- insert into date/time columns -- -- insert into date/time columns --
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Note 1265 Data truncated for column 'c13' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1264 Out of range value for column 'c13' at row 1 Warning 1264 Out of range value for column 'c13' at row 1
@ -3005,6 +3011,7 @@ Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1 Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1

View file

@ -2944,20 +2944,26 @@ delete from t9 ;
test_sequence test_sequence
-- insert into date/time columns -- -- insert into date/time columns --
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Note 1265 Data truncated for column 'c13' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1264 Out of range value for column 'c13' at row 1 Warning 1264 Out of range value for column 'c13' at row 1
@ -2988,6 +2994,7 @@ Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1 Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1

View file

@ -2945,20 +2945,26 @@ delete from t9 ;
test_sequence test_sequence
-- insert into date/time columns -- -- insert into date/time columns --
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Note 1265 Data truncated for column 'c13' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1264 Out of range value for column 'c13' at row 1 Warning 1264 Out of range value for column 'c13' at row 1
@ -2989,6 +2995,7 @@ Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1 Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1

View file

@ -2881,20 +2881,26 @@ delete from t9 ;
test_sequence test_sequence
-- insert into date/time columns -- -- insert into date/time columns --
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Note 1265 Data truncated for column 'c13' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1264 Out of range value for column 'c13' at row 1 Warning 1264 Out of range value for column 'c13' at row 1
@ -2925,6 +2931,7 @@ Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1 Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
@ -5895,20 +5902,26 @@ delete from t9 ;
test_sequence test_sequence
-- insert into date/time columns -- -- insert into date/time columns --
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Note 1265 Data truncated for column 'c13' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1264 Out of range value for column 'c13' at row 1 Warning 1264 Out of range value for column 'c13' at row 1
@ -5939,6 +5952,7 @@ Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1 Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1

View file

@ -2944,20 +2944,26 @@ delete from t9 ;
test_sequence test_sequence
-- insert into date/time columns -- -- insert into date/time columns --
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Note 1265 Data truncated for column 'c13' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1 Warning 1265 Data truncated for column 'c17' at row 1
Warnings: Warnings:
Warning 1264 Out of range value for column 'c13' at row 1 Warning 1264 Out of range value for column 'c13' at row 1
@ -2988,6 +2994,7 @@ Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1
Warnings: Warnings:
Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c15' at row 1 Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1 Warning 1264 Out of range value for column 'c17' at row 1

View file

@ -27,7 +27,7 @@ change master to master_log_pos=178;
start slave; start slave;
show slave status; show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 178 # # master-bin.000001 No Yes 0 0 178 # None 0 No # No # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 178 # # master-bin.000001 # Yes 0 0 178 # None 0 No # No
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 106 <Binlog_Ignore_DB> master-bin.000001 106 <Binlog_Ignore_DB>

View file

@ -8,22 +8,29 @@ create procedure db1_secret.dummy() begin end;
drop procedure db1_secret.dummy; drop procedure db1_secret.dummy;
use db1_secret; use db1_secret;
create table t1 ( u varchar(64), i int ); create table t1 ( u varchar(64), i int );
insert into t1 values('test', 0);
create procedure stamp(i int) create procedure stamp(i int)
insert into db1_secret.t1 values (user(), i); insert into db1_secret.t1 values (user(), i);
show procedure status like 'stamp'; show procedure status like 'stamp';
Db Name Type Definer Modified Created Security_type Comment Db Name Type Definer Modified Created Security_type Comment
db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
create function db() returns varchar(64) return database(); create function db() returns varchar(64)
begin
declare v varchar(64);
select u into v from t1 limit 1;
return v;
end|
show function status like 'db'; show function status like 'db';
Db Name Type Definer Modified Created Security_type Comment Db Name Type Definer Modified Created Security_type Comment
db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
call stamp(1); call stamp(1);
select * from t1; select * from t1;
u i u i
test 0
root@localhost 1 root@localhost 1
select db(); select db();
db() db()
db1_secret test
grant execute on procedure db1_secret.stamp to user1@'%'; grant execute on procedure db1_secret.stamp to user1@'%';
grant execute on function db1_secret.db to user1@'%'; grant execute on function db1_secret.db to user1@'%';
grant execute on procedure db1_secret.stamp to ''@'%'; grant execute on procedure db1_secret.stamp to ''@'%';
@ -31,25 +38,34 @@ grant execute on function db1_secret.db to ''@'%';
call db1_secret.stamp(2); call db1_secret.stamp(2);
select db1_secret.db(); select db1_secret.db();
db1_secret.db() db1_secret.db()
db1_secret test
select * from db1_secret.t1; select * from db1_secret.t1;
ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1' ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
create procedure db1_secret.dummy() begin end; create procedure db1_secret.dummy() begin end;
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret' ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
drop procedure db1_secret.dummy; drop procedure db1_secret.dummy;
ERROR 42000: PROCEDURE db1_secret.dummy does not exist ERROR 42000: PROCEDURE db1_secret.dummy does not exist
drop procedure db1_secret.stamp;
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.stamp'
drop function db1_secret.db;
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.db'
call db1_secret.stamp(3); call db1_secret.stamp(3);
select db1_secret.db(); select db1_secret.db();
db1_secret.db() db1_secret.db()
db1_secret test
select * from db1_secret.t1; select * from db1_secret.t1;
ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1' ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
create procedure db1_secret.dummy() begin end; create procedure db1_secret.dummy() begin end;
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret' ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
drop procedure db1_secret.dummy; drop procedure db1_secret.dummy;
ERROR 42000: PROCEDURE db1_secret.dummy does not exist ERROR 42000: PROCEDURE db1_secret.dummy does not exist
drop procedure db1_secret.stamp;
ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.stamp'
drop function db1_secret.db;
ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.db'
select * from t1; select * from t1;
u i u i
test 0
root@localhost 1 root@localhost 1
user1@localhost 2 user1@localhost 2
anon@localhost 3 anon@localhost 3
@ -64,21 +80,22 @@ db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 IN
call stamp(4); call stamp(4);
select * from t1; select * from t1;
u i u i
test 0
root@localhost 1 root@localhost 1
user1@localhost 2 user1@localhost 2
anon@localhost 3 anon@localhost 3
root@localhost 4 root@localhost 4
select db(); select db();
db() db()
db1_secret test
call db1_secret.stamp(5); call db1_secret.stamp(5);
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret' ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 't1'
select db1_secret.db(); select db1_secret.db();
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret' ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
call db1_secret.stamp(6); call db1_secret.stamp(6);
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret' ERROR 42000: INSERT command denied to user ''@'localhost' for table 't1'
select db1_secret.db(); select db1_secret.db();
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret' ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
drop database if exists db2; drop database if exists db2;
create database db2; create database db2;
use db2; use db2;

View file

@ -6061,6 +6061,21 @@ SUM(f2) bug25373(f1)
21.300000071526 NULL 21.300000071526 NULL
DROP FUNCTION bug25373| DROP FUNCTION bug25373|
DROP TABLE t3| DROP TABLE t3|
DROP DATABASE IF EXISTS mysqltest1|
DROP DATABASE IF EXISTS mysqltest2|
CREATE DATABASE mysqltest1|
CREATE DATABASE mysqltest2|
CREATE PROCEDURE mysqltest1.p1()
DROP DATABASE mysqltest2|
use mysqltest2|
CALL mysqltest1.p1()|
Warnings:
Note 1049 Unknown database 'mysqltest2'
SELECT DATABASE()|
DATABASE()
NULL
DROP DATABASE mysqltest1|
use test|
drop function if exists bug20777| drop function if exists bug20777|
drop table if exists examplebug20777| drop table if exists examplebug20777|
create function bug20777(f1 bigint unsigned) returns bigint unsigned create function bug20777(f1 bigint unsigned) returns bigint unsigned
@ -6147,3 +6162,28 @@ bug20777(18446744073709551613)+1
drop function bug20777; drop function bug20777;
End of 5.0 tests. End of 5.0 tests.
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
set @a=0;
CREATE function bug27354() RETURNS int deterministic
begin
insert into t1 values (null);
set @a=@a+1;
return @a;
end|
update t2 set b=1 where a=bug27354();
select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
count(t_1.a) count(t_2.a)
0 0
insert into t2 values (1,1),(2,2),(3,3);
update t2 set b=-b where a=bug27354();
select * from t2 /* must return 1,-1 ... */;
a b
1 -1
2 -2
3 -3
select count(*) from t1 /* must be 3 */;
count(*)
3
drop table t1,t2;
drop function bug27354;

View file

@ -0,0 +1,27 @@
drop function if exists bug23333|
drop table if exists t1,t2|
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
insert into t2 values (1,1)|
create function bug23333()
RETURNS int(11)
DETERMINISTIC
begin
insert into t1 values (null);
select count(*) from t1 into @a;
return @a;
end|
reset master|
insert into t2 values (bug23333(),1)|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
show binlog events from 106 /* with fixes for #23333 will show there is the query */|
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Table_map 1 # #
master-bin.000001 # Table_map 1 # #
master-bin.000001 # Write_rows 1 # #
master-bin.000001 # Query 1 # #
select count(*),@a from t1 /* must be 1,1 */|
count(*) @a
1 1
drop table t1,t2;
drop function if exists bug23333;

View file

@ -206,6 +206,8 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y'));
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
Warnings:
Note 1265 Data truncated for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i')); INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1 ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i')); INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));

View file

@ -110,3 +110,29 @@ select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_dat
1 1
1 1
drop table t1; drop table t1;
select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date);
@d:=1111 year(@d) month(@d) day(@d) cast(@d as date)
1111 2000 11 11 2000-11-11
select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date);
@d:=011111 year(@d) month(@d) day(@d) cast(@d as date)
11111 2001 11 11 2001-11-11
select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date);
@d:=1311 year(@d) month(@d) day(@d) cast(@d as date)
1311 NULL NULL NULL NULL
Warnings:
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'
create table t1 (d date , dt datetime , ts timestamp);
insert into t1 values (9912101,9912101,9912101);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'dt' at row 1
Warning 1265 Data truncated for column 'ts' at row 1
insert into t1 values (11111,11111,11111);
select * from t1;
d dt ts
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00
2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00
drop table t1;

View file

@ -192,3 +192,38 @@ CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMA
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)); SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)) CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
101112.098700 101112.098700
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`da` date DEFAULT '1962-03-03',
`dt` datetime DEFAULT '1962-03-03 00:00:00'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values ();
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
set @@sql_mode='ansi,traditional';
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
insert into t1 set dt='2007-03-23 13:49:38',da=dt;
Warnings:
Note 1265 Data truncated for column 'da' at row 1
insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1
select * from t1;
da dt
1962-03-03 1962-03-03 00:00:00
2007-03-23 2007-03-23 13:49:38
2007-03-23 2007-03-23 13:49:38
2007-03-23 2007-03-23 13:49:38
drop table t1;
create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
ERROR 42000: Invalid default value for 'da'
create table t1 (t time default '916:00:00 a');
ERROR 42000: Invalid default value for 't'
set @@sql_mode= @org_mode;

View file

@ -284,15 +284,6 @@ create view mysqltest.v3 as select b from mysqltest.t2;
grant create view, update on mysqltest.v3 to mysqltest_1@localhost; grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
drop view mysqltest.v3; drop view mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2; create view mysqltest.v3 as select b from mysqltest.t2;
grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost;
drop view mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
create table mysqltest.v3 (b int);
grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
create view v4 as select b+1 from mysqltest.t2; create view v4 as select b+1 from mysqltest.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
grant create view,update,select on test.* to mysqltest_1@localhost; grant create view,update,select on test.* to mysqltest_1@localhost;
@ -796,6 +787,94 @@ View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1`
DROP USER u26813@localhost; DROP USER u26813@localhost;
DROP DATABASE db26813; DROP DATABASE db26813;
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
CREATE TABLE mysqltest1.t1(c1 INT);
CREATE TABLE mysqltest1.t2(c2 INT);
CREATE TABLE mysqltest1.t3(c3 INT);
CREATE TABLE mysqltest1.t4(c4 INT);
INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
---> connection: bug24040_con
SELECT * FROM mysqltest1.t1;
c1
11
12
13
14
INSERT INTO mysqltest1.t2 VALUES(25);
UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
DELETE FROM mysqltest1.t4 WHERE c4 = 44;
CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
SELECT * FROM v1;
c1
11
12
13
14
INSERT INTO v2 VALUES(26);
UPDATE v3 SET c3 = 332 WHERE c3 = 32;
DELETE FROM v4 WHERE c4 = 43;
CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v12'
CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c1' in table 'v21'
CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c3' in table 'v23'
CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c4' in table 'v24'
CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v32'
CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42'
CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
---> connection: default
SELECT * FROM mysqltest1.t1;
c1
11
12
13
14
SELECT * FROM mysqltest1.t2;
c2
21
22
23
24
25
26
SELECT * FROM mysqltest1.t3;
c3
331
332
33
34
SELECT * FROM mysqltest1.t4;
c4
41
42
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
End of 5.0 tests. End of 5.0 tests.
DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;

View file

@ -132,6 +132,8 @@ create table t1 (date char(30), format char(30) not null);
insert into t1 values insert into t1 values
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'), ('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'), ('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'), ('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'), ('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'), ('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),

View file

@ -12,6 +12,7 @@
user_limits : Bug#23921 random failure of user_limits.test user_limits : Bug#23921 random failure of user_limits.test
im_options : Bug#20294 2006-07-24 stewart Instance manager test im_options fails randomly im_options : Bug#20294 2006-07-24 stewart Instance manager test im_options fails randomly
im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance.
concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog

View file

@ -2,7 +2,8 @@
# if federated can utilise the servers table # if federated can utilise the servers table
# should work with embedded server after mysqltest is fixed # should work with embedded server after mysqltest is fixed
-- source include/not_embedded.inc -- source include/not_embedded.inc
source include/federated.inc; -- source include/federated.inc;
-- source include/big_test.inc
connection slave; connection slave;
create database first_db; create database first_db;
@ -299,7 +300,7 @@ begin
DECLARE i INT; DECLARE i INT;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1;
SET i = sleep(5); SET i = sleep(5);
WHILE v < 20000 do WHILE v < 10000 do
CREATE SERVER s CREATE SERVER s
FOREIGN DATA WRAPPER mysql FOREIGN DATA WRAPPER mysql
OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test'); OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');

View file

@ -41,6 +41,8 @@ select datediff("1997-11-30 23:59:59.000001",null);
select weekofyear("1997-11-30 23:59:59.000001"); select weekofyear("1997-11-30 23:59:59.000001");
select makedate(03,1);
select makedate('0003',1);
select makedate(1997,1); select makedate(1997,1);
select makedate(1997,0); select makedate(1997,0);
select makedate(9999,365); select makedate(9999,365);

View file

@ -3,6 +3,8 @@
# Grant tests not performed with embedded server # Grant tests not performed with embedded server
-- source include/not_embedded.inc -- source include/not_embedded.inc
SET GLOBAL log_bin_trust_function_creators = 1;
# Cleanup # Cleanup
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
@ -985,6 +987,233 @@ GRANT PROCESS ON * TO user@localhost;
disconnect con1; disconnect con1;
connection default; connection default;
#
# BUG#9504: Stored procedures: execute privilege doesn't make 'use database'
# okay.
#
# Prepare.
--disable_warnings
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS mysqltest3;
DROP DATABASE IF EXISTS mysqltest4;
--enable_warnings
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
CREATE DATABASE mysqltest3;
CREATE DATABASE mysqltest4;
CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
SELECT 1;
CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
SELECT 1;
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
RETURN 1;
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
RETURN 1;
GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
# Test.
--connect (bug9504_con1,localhost,mysqltest_1,,)
--echo
--echo ---> connection: bug9504_con1
# - Check that we can switch to the db;
use mysqltest1;
use mysqltest2;
use mysqltest3;
use mysqltest4;
# - Check that we can call stored routines;
use test;
CALL mysqltest1.p_def();
CALL mysqltest2.p_inv();
SELECT mysqltest3.f_def();
SELECT mysqltest4.f_inv();
# Cleanup.
--connection default
--echo
--echo ---> connection: default
--disconnect bug9504_con1
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP DATABASE mysqltest3;
DROP DATABASE mysqltest4;
DROP USER mysqltest_1@localhost;
#
# BUG#27337: Privileges are not restored properly.
#
# Actually, the patch for this bugs fixes two problems. So, here are two test
# cases.
# Test case 1: privileges are not restored properly after calling a stored
# routine defined with SQL SECURITY INVOKER clause.
# Prepare.
--disable_warnings
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
--enable_warnings
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
SELECT 1;
# Test.
--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest2)
--echo
--echo ---> connection: bug27337_con1
--error ER_TABLEACCESS_DENIED_ERROR
CREATE TABLE t1(c INT);
CALL mysqltest1.p1();
--error ER_TABLEACCESS_DENIED_ERROR
CREATE TABLE t1(c INT);
--disconnect bug27337_con1
--connect (bug27337_con2,localhost,mysqltest_1,,mysqltest2)
--echo
--echo ---> connection: bug27337_con2
--error ER_TABLEACCESS_DENIED_ERROR
CREATE TABLE t1(c INT);
SHOW TABLES;
# Cleanup.
--connection default
--echo
--echo ---> connection: default
--disconnect bug27337_con2
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
# Test case 2: priveleges are not checked properly for prepared statements.
# Prepare.
--disable_warnings
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
--enable_warnings
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
CREATE TABLE mysqltest1.t1(c INT);
CREATE TABLE mysqltest2.t2(c INT);
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
# Test.
--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest1)
--echo
--echo ---> connection: bug27337_con1
SHOW TABLES FROM mysqltest1;
PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
EXECUTE stmt1;
--connect (bug27337_con2,localhost,mysqltest_2,,mysqltest2)
--echo
--echo ---> connection: bug27337_con2
SHOW COLUMNS FROM mysqltest2.t2;
PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
EXECUTE stmt2;
--connection default
--echo
--echo ---> connection: default
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
--connection bug27337_con1
--echo
--echo ---> connection: bug27337_con1
--error ER_DBACCESS_DENIED_ERROR
SHOW TABLES FROM mysqltest1;
--error ER_DBACCESS_DENIED_ERROR
EXECUTE stmt1;
--connection bug27337_con2
--echo
--echo ---> connection: bug27337_con2
--error ER_TABLEACCESS_DENIED_ERROR
SHOW COLUMNS FROM mysqltest2.t2;
--error ER_TABLEACCESS_DENIED_ERROR
EXECUTE stmt2;
# Cleanup.
--connection default
--echo
--echo ---> connection: default
--disconnect bug27337_con2
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
--echo End of 5.0 tests --echo End of 5.0 tests
# #

View file

@ -121,6 +121,28 @@ create table t1 (f1 char(4));
create view v1 as select f1 from t1; create view v1 as select f1 from t1;
grant insert on v1 to testdb_2@localhost; grant insert on v1 to testdb_2@localhost;
create view v5 as select f1 from t1;
grant show view on v5 to testdb_2@localhost;
--error 1227
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
connection default;
use testdb_1;
create view v6 as select f1 from t1;
grant show view on v6 to testdb_2@localhost;
create table t2 (f1 char(4));
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
show fields from testdb_1.v6;
show create view testdb_1.v6;
show create view testdb_1.v7;
show fields from testdb_1.v7;
connection testdb_1;
create table t3 (f1 char(4), f2 char(4)); create table t3 (f1 char(4), f2 char(4));
create view v3 as select f1,f2 from t3; create view v3 as select f1,f2 from t3;
grant insert(f1), insert(f2) on v3 to testdb_2@localhost; grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
@ -129,13 +151,41 @@ connect (testdb_2,localhost,testdb_2,,test);
create view v2 as select f1 from testdb_1.v1; create view v2 as select f1 from testdb_1.v1;
create view v4 as select f1,f2 from testdb_1.v3; create view v4 as select f1,f2 from testdb_1.v3;
show fields from testdb_1.v5;
show create view testdb_1.v5;
show fields from testdb_1.v6;
show create view testdb_1.v6;
connection testdb_1; connection testdb_1;
show fields from testdb_1.v7;
show create view testdb_1.v7;
revoke insert(f1) on v3 from testdb_2@localhost; revoke insert(f1) on v3 from testdb_2@localhost;
revoke show view on v5 from testdb_2@localhost;
connection default;
use testdb_1;
revoke show view on v6 from testdb_2@localhost;
connection testdb_2; connection testdb_2;
--error 1142
show fields from testdb_1.v5;
--error 1142
show create view testdb_1.v5;
--error 1142
show fields from testdb_1.v6;
--error 1142
show create view testdb_1.v6;
--error 1142
show fields from testdb_1.v7;
--error 1142
show create view testdb_1.v7;
--error 1345 --error 1345
show create view v4; show create view v4;
--error 1345 #--error 1345
show fields from v4; show fields from v4;
show fields from v2; show fields from v2;
@ -155,7 +205,8 @@ where a.table_name = 'testdb_1.v1';
select * from v2; select * from v2;
connection default; connection default;
drop view testdb_1.v1,v2, testdb_1.v3, v4; use test;
drop view testdb_1.v1, v2, testdb_1.v3, v4;
drop database testdb_1; drop database testdb_1;
drop user testdb_1@localhost; drop user testdb_1@localhost;
drop user testdb_2@localhost; drop user testdb_2@localhost;

View file

@ -7,14 +7,14 @@ drop table if exists t1,t2;
--enable_warnings --enable_warnings
create table t1 (a int) engine=myisam; create table t1 (a int) engine=myisam;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI
drop table if exists t1; drop table if exists t1;
create table t1 (a int) engine=myisam; create table t1 (a int) engine=myisam;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI
--error 1051,6 --error 1051,6
drop table t1; drop table t1;
create table t1 (a int) engine=myisam; create table t1 (a int) engine=myisam;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYD ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD
--error 1105,6,29 --error 1105,6,29
drop table t1; drop table t1;
--error 1051 --error 1051

View file

@ -58,6 +58,10 @@ select "--- stop-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLTEST_VARDIR/log/master-bin.000001 --exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLTEST_VARDIR/log/master-bin.000001
--disable_query_log --disable_query_log
select "--- start and stop positions ---" as "";
--enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLTEST_VARDIR/log/master-bin.000001
--disable_query_log
select "--- start-datetime --" as ""; select "--- start-datetime --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 --exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
@ -115,6 +119,10 @@ select "--- stop-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log --disable_query_log
select "--- start and stop positions ---" as "";
--enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- start-datetime --" as ""; select "--- start-datetime --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001

View file

@ -24,7 +24,7 @@ create table t1(
insert into t1 values(1, "Autodiscover"); insert into t1 values(1, "Autodiscover");
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
select * from t1; select * from t1;
show status like 'handler_discover%'; show status like 'handler_discover%';
@ -33,13 +33,13 @@ show status like 'handler_discover%';
# #
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
insert into t1 values (2, "Auto 2"); insert into t1 values (2, "Auto 2");
show status like 'handler_discover%'; show status like 'handler_discover%';
insert into t1 values (3, "Discover 3"); insert into t1 values (3, "Discover 3");
show status like 'handler_discover%'; show status like 'handler_discover%';
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
select * from t1 order by id; select * from t1 order by id;
show status like 'handler_discover%'; show status like 'handler_discover%';
@ -48,7 +48,7 @@ show status like 'handler_discover%';
# #
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
update t1 set name="Autodiscover" where id = 2; update t1 set name="Autodiscover" where id = 2;
show status like 'handler_discover%'; show status like 'handler_discover%';
select * from t1 order by id; select * from t1 order by id;
@ -59,7 +59,7 @@ show status like 'handler_discover%';
# #
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
delete from t1 where id = 3; delete from t1 where id = 3;
select * from t1 order by id; select * from t1 order by id;
show status like 'handler_discover%'; show status like 'handler_discover%';
@ -111,7 +111,7 @@ show status like 'handler_discover%';
flush tables; flush tables;
# Remove the frm file from disk # Remove the frm file from disk
system rm $MYSQLTEST_VARDIR/master-data/test/t3.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm
--error 1050 --error 1050
create table t3( create table t3(
@ -168,14 +168,14 @@ show status like 'handler_discover%';
# Remove the frm file from disk # Remove the frm file from disk
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
show tables from test; show tables from test;
show status like 'handler_discover%'; show status like 'handler_discover%';
# Remove the frm file from disk again # Remove the frm file from disk again
flush tables; flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
--replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 # --replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 #
show table status; show table status;
@ -290,8 +290,8 @@ insert into t9 values (9);
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ; system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ;
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ; system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ;
# Remove t6, t7 from disk # Remove t6, t7 from disk
system rm $MYSQLTEST_VARDIR/master-data/test/t6.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm
system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
SHOW TABLES; SHOW TABLES;
@ -332,8 +332,8 @@ insert into t9 values (9);
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ; system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ;
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ; system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ;
# Remove t6, t7 from disk # Remove t6, t7 from disk
system rm $MYSQLTEST_VARDIR/master-data/test/t6.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm
system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
SHOW TABLES LIKE 't6'; SHOW TABLES LIKE 't6';
@ -375,9 +375,9 @@ insert into t3 values (3, "ndb table 3");
insert into t4 values (4); insert into t4 values (4);
# Remove t1, t2, t3 from disk # Remove t1, t2, t3 from disk
system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
system rm $MYSQLTEST_VARDIR/master-data/test/t2.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t2.frm
system rm $MYSQLTEST_VARDIR/master-data/test/t3.frm > /dev/null ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm
flush tables; flush tables;
# Select from the table which only exists in NDB. # Select from the table which only exists in NDB.
@ -530,7 +530,7 @@ CREATE TABLE t9 (
insert t9 values(1, 2), (2,3), (3, 4), (4, 5); insert t9 values(1, 2), (2,3), (3, 4), (4, 5);
#Don't drop the table, instead remove the frm file #Don't drop the table, instead remove the frm file
system rm $MYSQLTEST_VARDIR/master-data/test/t9.frm ; --remove_file $MYSQLTEST_VARDIR/master-data/test/t9.frm
# Now leave test case, when ndb_autodiscover2 will run, this # Now leave test case, when ndb_autodiscover2 will run, this
# MySQL Server will have been restarted because it has a # MySQL Server will have been restarted because it has a

View file

@ -25,7 +25,7 @@ create table t1(a int) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
select count(*) from t1; select count(*) from t1;
system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile ; --remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
drop table t1; drop table t1;
create table t1(a int) engine=myisam; create table t1(a int) engine=myisam;
@ -37,7 +37,7 @@ drop table t1;
create table t1(a int primary key) engine=ndb; create table t1(a int primary key) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; --remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
select * from t1 order by a; select * from t1 order by a;
drop table t1; drop table t1;
@ -50,7 +50,7 @@ drop table t1;
create table t1(a int primary key) engine=ndb; create table t1(a int primary key) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; --remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
select * from t1 order by a; select * from t1 order by a;
drop table t1; drop table t1;
@ -63,7 +63,7 @@ drop table t1;
create table t1(a int primary key) engine=ndb; create table t1(a int primary key) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; --remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
select * from t1 order by a; select * from t1 order by a;
drop table t1; drop table t1;

View file

@ -5,6 +5,9 @@
# #
# Start replication master -> slave # Start replication master -> slave
# #
# We have to sync with master, to ensure slave had time to start properly
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
sync_slave_with_master;
connection slave; connection slave;
--disable_warnings --disable_warnings
stop slave; stop slave;

View file

@ -25,7 +25,7 @@ eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.sele
truncate table t1; truncate table t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ; --remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
@ -52,7 +52,7 @@ drop table t1;
create table t1(a int primary key); create table t1(a int primary key);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ; --remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
save_master_pos; save_master_pos;
connection slave; connection slave;

View file

@ -37,7 +37,7 @@ change master to master_log_pos=178;
start slave; start slave;
sleep 2; sleep 2;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 # --replace_column 1 # 8 # 9 # 11 # 23 # 33 #
show slave status; show slave status;
connection master; connection master;
--replace_column 3 <Binlog_Ignore_DB> --replace_column 3 <Binlog_Ignore_DB>

View file

@ -99,5 +99,5 @@ DROP TABLE IF EXISTS t1;
--sync_slave_with_master --sync_slave_with_master
# If all is good, when can cleanup our dump files. # If all is good, when can cleanup our dump files.
--system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql --remove_file $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql
--system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql --remove_file $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql

View file

@ -43,5 +43,5 @@ diff_files $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql $MYSQLTEST_VARDIR/tmp
# If all is good, we can remove the files # If all is good, we can remove the files
system rm $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql; --remove_file $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql
system rm $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql; --remove_file $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql

View file

@ -67,8 +67,8 @@ DROP DATABASE mysqltest1;
diff_files $MYSQLTEST_VARDIR/tmp/NOW_master.sql $MYSQLTEST_VARDIR/tmp/NOW_slave.sql; diff_files $MYSQLTEST_VARDIR/tmp/NOW_master.sql $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
# If all is good, when can cleanup our dump files. # If all is good, when can cleanup our dump files.
system rm $MYSQLTEST_VARDIR/tmp/NOW_master.sql; --remove_file $MYSQLTEST_VARDIR/tmp/NOW_master.sql
system rm $MYSQLTEST_VARDIR/tmp/NOW_slave.sql; --remove_file $MYSQLTEST_VARDIR/tmp/NOW_slave.sql
sync_slave_with_master; sync_slave_with_master;
# End of 5.1 test case # End of 5.1 test case

View file

@ -140,7 +140,7 @@ sync_slave_with_master;
diff_files $MYSQLTEST_VARDIR/tmp/sp001_master.sql $MYSQLTEST_VARDIR/tmp/sp001_slave.sql; diff_files $MYSQLTEST_VARDIR/tmp/sp001_master.sql $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
# If all is good, when can cleanup our dump files. # If all is good, when can cleanup our dump files.
system rm $MYSQLTEST_VARDIR/tmp/sp001_master.sql; --remove_file $MYSQLTEST_VARDIR/tmp/sp001_master.sql
system rm $MYSQLTEST_VARDIR/tmp/sp001_slave.sql; --remove_file $MYSQLTEST_VARDIR/tmp/sp001_slave.sql
# End of 5.0 test case # End of 5.0 test case

View file

@ -105,7 +105,7 @@ sync_slave_with_master;
diff_files $MYSQLTEST_VARDIR/tmp/sp011_master.sql $MYSQLTEST_VARDIR/tmp/sp011_slave.sql; diff_files $MYSQLTEST_VARDIR/tmp/sp011_master.sql $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
# If all is good, when can cleanup our dump files. # If all is good, when can cleanup our dump files.
system rm $MYSQLTEST_VARDIR/tmp/sp011_master.sql; --remove_file $MYSQLTEST_VARDIR/tmp/sp011_master.sql
system rm $MYSQLTEST_VARDIR/tmp/sp011_slave.sql; --remove_file $MYSQLTEST_VARDIR/tmp/sp011_slave.sql
# End of 5.0 test case # End of 5.0 test case

View file

@ -392,7 +392,8 @@ SHOW TABLE STATUS like 't1';
--error 1033 --error 1033
show create table t1; show create table t1;
drop table if exists t1; drop table if exists t1;
system rm -f $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --error 1,0
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
# #
# BUG 12183 - SHOW OPEN TABLES behavior doesn't match grammar # BUG 12183 - SHOW OPEN TABLES behavior doesn't match grammar

View file

@ -28,6 +28,7 @@ drop procedure db1_secret.dummy;
use db1_secret; use db1_secret;
create table t1 ( u varchar(64), i int ); create table t1 ( u varchar(64), i int );
insert into t1 values('test', 0);
# A test procedure and function # A test procedure and function
create procedure stamp(i int) create procedure stamp(i int)
@ -35,7 +36,16 @@ create procedure stamp(i int)
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' --replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show procedure status like 'stamp'; show procedure status like 'stamp';
create function db() returns varchar(64) return database(); delimiter |;
create function db() returns varchar(64)
begin
declare v varchar(64);
select u into v from t1 limit 1;
return v;
end|
delimiter ;|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' --replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show function status like 'db'; show function status like 'db';
@ -63,14 +73,18 @@ call db1_secret.stamp(2);
select db1_secret.db(); select db1_secret.db();
# ...but not this # ...but not this
--error 1142 --error ER_TABLEACCESS_DENIED_ERROR
select * from db1_secret.t1; select * from db1_secret.t1;
# ...and not this # ...and not this
--error 1044 --error ER_DBACCESS_DENIED_ERROR
create procedure db1_secret.dummy() begin end; create procedure db1_secret.dummy() begin end;
--error 1305 --error ER_SP_DOES_NOT_EXIST
drop procedure db1_secret.dummy; drop procedure db1_secret.dummy;
--error ER_PROCACCESS_DENIED_ERROR
drop procedure db1_secret.stamp;
--error ER_PROCACCESS_DENIED_ERROR
drop function db1_secret.db;
# #
@ -83,14 +97,18 @@ call db1_secret.stamp(3);
select db1_secret.db(); select db1_secret.db();
# ...but not this # ...but not this
--error 1142 --error ER_TABLEACCESS_DENIED_ERROR
select * from db1_secret.t1; select * from db1_secret.t1;
# ...and not this # ...and not this
--error 1044 --error ER_DBACCESS_DENIED_ERROR
create procedure db1_secret.dummy() begin end; create procedure db1_secret.dummy() begin end;
--error 1305 --error ER_SP_DOES_NOT_EXIST
drop procedure db1_secret.dummy; drop procedure db1_secret.dummy;
--error ER_PROCACCESS_DENIED_ERROR
drop procedure db1_secret.stamp;
--error ER_PROCACCESS_DENIED_ERROR
drop function db1_secret.db;
# #
@ -121,9 +139,9 @@ select db();
connection con2user1; connection con2user1;
# This should not work # This should not work
--error 1044 --error ER_TABLEACCESS_DENIED_ERROR
call db1_secret.stamp(5); call db1_secret.stamp(5);
--error 1044 --error ER_TABLEACCESS_DENIED_ERROR
select db1_secret.db(); select db1_secret.db();
# #
@ -132,9 +150,9 @@ select db1_secret.db();
connection con3anon; connection con3anon;
# This should not work # This should not work
--error 1044 --error ER_TABLEACCESS_DENIED_ERROR
call db1_secret.stamp(6); call db1_secret.stamp(6);
--error 1044 --error ER_TABLEACCESS_DENIED_ERROR
select db1_secret.db(); select db1_secret.db();
# #
@ -165,7 +183,7 @@ use db2;
create procedure p () insert into t2 values (1); create procedure p () insert into t2 values (1);
# Check that this doesn't work. # Check that this doesn't work.
--error 1142 --error ER_TABLEACCESS_DENIED_ERROR
call p(); call p();
connect (con4user2,localhost,user2,,); connect (con4user2,localhost,user2,,);
@ -174,7 +192,7 @@ connection con4user2;
use db2; use db2;
# This should not work, since p is executed with definer's (user1's) rights. # This should not work, since p is executed with definer's (user1's) rights.
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
call p(); call p();
select * from t2; select * from t2;
@ -207,9 +225,9 @@ alter procedure p modifies sql data;
drop procedure p; drop procedure p;
# This should NOT work # This should NOT work
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
alter procedure q modifies sql data; alter procedure q modifies sql data;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
drop procedure q; drop procedure q;
connection con1root; connection con1root;
@ -260,30 +278,30 @@ connect (con4userc,localhost,userc,,);
connection con2usera; connection con2usera;
call sptest.p1(1); call sptest.p1(1);
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
grant execute on procedure sptest.p1 to userb@localhost; grant execute on procedure sptest.p1 to userb@localhost;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1; drop procedure sptest.p1;
connection con3userb; connection con3userb;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
call sptest.p1(2); call sptest.p1(2);
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
grant execute on procedure sptest.p1 to userb@localhost; grant execute on procedure sptest.p1 to userb@localhost;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1; drop procedure sptest.p1;
connection con4userc; connection con4userc;
call sptest.p1(3); call sptest.p1(3);
grant execute on procedure sptest.p1 to userb@localhost; grant execute on procedure sptest.p1 to userb@localhost;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1; drop procedure sptest.p1;
connection con3userb; connection con3userb;
call sptest.p1(4); call sptest.p1(4);
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
grant execute on procedure sptest.p1 to userb@localhost; grant execute on procedure sptest.p1 to userb@localhost;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1; drop procedure sptest.p1;
connection con1root; connection con1root;
@ -332,7 +350,7 @@ delimiter ;//
connect (user1,localhost,user1,,test); connect (user1,localhost,user1,,test);
connection user1; connection user1;
use mysqltest; use mysqltest;
-- error 1370 -- error ER_PROCACCESS_DENIED_ERROR
select bug_9503(); select bug_9503();
connection root; connection root;
@ -401,13 +419,13 @@ grant usage on *.* to mysqltest_1@localhost;
connect (n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK); connect (n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n1; connection n1;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
call mysqltest_1.p1(); call mysqltest_1.p1();
disconnect n1; disconnect n1;
# Test also without a current database # Test also without a current database
connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK); connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n2; connection n2;
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
call mysqltest_1.p1(); call mysqltest_1.p1();
disconnect n2; disconnect n2;
@ -433,9 +451,9 @@ end;
create user user_bug12812@localhost IDENTIFIED BY 'ABC'| create user user_bug12812@localhost IDENTIFIED BY 'ABC'|
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (test_user_12812,localhost,user_bug12812,ABC,test)| connect (test_user_12812,localhost,user_bug12812,ABC,test)|
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
SELECT test.bug12812()| SELECT test.bug12812()|
--error 1370 --error ER_PROCACCESS_DENIED_ERROR
CREATE VIEW v1 AS SELECT test.bug12812()| CREATE VIEW v1 AS SELECT test.bug12812()|
# Cleanup # Cleanup
connection default| connection default|
@ -489,7 +507,8 @@ drop database db_bug14834;
# #
# BUG#14533: 'desc tbl' in stored procedure causes error 1142 # BUG#14533: 'desc tbl' in stored procedure causes error
# ER_TABLEACCESS_DENIED_ERROR
# #
create database db_bug14533; create database db_bug14533;
use db_bug14533; use db_bug14533;

View file

@ -7021,6 +7021,47 @@ INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP| SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
DROP FUNCTION bug25373| DROP FUNCTION bug25373|
DROP TABLE t3| DROP TABLE t3|
#
# BUG#25082: Default database change on trigger execution breaks replication.
#
# As it turned out, this bug has actually two bugs. So, here we have two test
# cases -- one in sp.test, the other in sp-security.test.
#
#
# Test case 1: error on dropping the current database.
#
# Prepare.
--disable_warnings
DROP DATABASE IF EXISTS mysqltest1|
DROP DATABASE IF EXISTS mysqltest2|
--enable_warnings
CREATE DATABASE mysqltest1|
CREATE DATABASE mysqltest2|
# Test.
CREATE PROCEDURE mysqltest1.p1()
DROP DATABASE mysqltest2|
use mysqltest2|
CALL mysqltest1.p1()|
SELECT DATABASE()|
# Cleanup.
DROP DATABASE mysqltest1|
use test|
# #
# Bug#20777: Function w BIGINT UNSIGNED shows diff. behaviour --ps-protocol # Bug#20777: Function w BIGINT UNSIGNED shows diff. behaviour --ps-protocol
--disable_warnings --disable_warnings
@ -7088,3 +7129,26 @@ delimiter |;
delimiter ;| delimiter ;|
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
set @a=0;
delimiter |;
CREATE function bug27354() RETURNS int deterministic
begin
insert into t1 values (null);
set @a=@a+1;
return @a;
end|
delimiter ;|
update t2 set b=1 where a=bug27354();
select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
insert into t2 values (1,1),(2,2),(3,3);
update t2 set b=-b where a=bug27354();
select * from t2 /* must return 1,-1 ... */;
select count(*) from t1 /* must be 3 */;
drop table t1,t2;
drop function bug27354;

View file

@ -0,0 +1,43 @@
# part of sp_trans test that appeared to be sensitive to binlog format
--source include/have_innodb.inc
--source include/have_binlog_format_mixed_or_row.inc
delimiter |;
#
# Bug #13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
# Bug #23333 stored function + non-transac table + transac table =
# breaks stmt-based binlog
# Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
#
--disable_warnings
drop function if exists bug23333|
drop table if exists t1,t2|
--enable_warnings
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
insert into t2 values (1,1)|
create function bug23333()
RETURNS int(11)
DETERMINISTIC
begin
insert into t1 values (null);
select count(*) from t1 into @a;
return @a;
end|
reset master|
--error ER_DUP_ENTRY_WITH_KEY_NAME
insert into t2 values (bug23333(),1)|
--replace_column 2 # 5 # 6 #
show binlog events from 106 /* with fixes for #23333 will show there is the query */|
select count(*),@a from t1 /* must be 1,1 */|
delimiter ;|
# clean-up
drop table t1,t2;
drop function if exists bug23333;

View file

@ -123,3 +123,16 @@ insert into t1 values ('2000-01-01','2000-01-02');
select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date; select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
drop table t1; drop table t1;
# End of 4.1 tests # End of 4.1 tests
#
# Bug #23093: Implicit conversion of 9912101 to date does not match
# cast(9912101 as date)
#
select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date);
select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date);
select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date);
create table t1 (d date , dt datetime , ts timestamp);
insert into t1 values (9912101,9912101,9912101);
insert into t1 values (11111,11111,11111);
select * from t1;
drop table t1;

View file

@ -141,3 +141,25 @@ SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6)); SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)); SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
#
# Test of storing datetime into date fields
#
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
show create table t1;
insert into t1 values ();
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
set @@sql_mode='ansi,traditional';
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
insert into t1 set dt='2007-03-23 13:49:38',da=dt;
# Test error handling
--error 1292
insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
select * from t1;
drop table t1;
--error 1067
create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
--error 1067
create table t1 (t time default '916:00:00 a');
set @@sql_mode= @org_mode;

View file

@ -356,25 +356,6 @@ drop view mysqltest.v3;
connection user1; connection user1;
create view mysqltest.v3 as select b from mysqltest.t2; create view mysqltest.v3 as select b from mysqltest.t2;
# give UPDATE and INSERT privilege (to get more privileges then underlying
# table)
connection root;
grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost;
drop view mysqltest.v3;
connection user1;
-- error 1143
create view mysqltest.v3 as select b from mysqltest.t2;
# If we would get more privileges on VIEW then we have on
# underlying tables => creation prohibited
connection root;
create table mysqltest.v3 (b int);
grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3;
connection user1;
-- error 1143
create view mysqltest.v3 as select b from mysqltest.t2;
# Expression need select privileges # Expression need select privileges
-- error 1143 -- error 1143
@ -1072,6 +1053,97 @@ DROP USER u26813@localhost;
DROP DATABASE db26813; DROP DATABASE db26813;
disconnect u1; disconnect u1;
#
# BUG#24040: Create View don't succed with "all privileges" on a database.
#
# Prepare.
--disable_warnings
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
--enable_warnings
CREATE DATABASE mysqltest1;
CREATE DATABASE mysqltest2;
# Test.
CREATE TABLE mysqltest1.t1(c1 INT);
CREATE TABLE mysqltest1.t2(c2 INT);
CREATE TABLE mysqltest1.t3(c3 INT);
CREATE TABLE mysqltest1.t4(c4 INT);
INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
--connect (bug24040_con,localhost,mysqltest_u1,,mysqltest2)
--echo
--echo ---> connection: bug24040_con
SELECT * FROM mysqltest1.t1;
INSERT INTO mysqltest1.t2 VALUES(25);
UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
DELETE FROM mysqltest1.t4 WHERE c4 = 44;
CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
SELECT * FROM v1;
INSERT INTO v2 VALUES(26);
UPDATE v3 SET c3 = 332 WHERE c3 = 32;
DELETE FROM v4 WHERE c4 = 43;
--error ER_COLUMNACCESS_DENIED_ERROR
CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
--error ER_COLUMNACCESS_DENIED_ERROR
CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
--error ER_COLUMNACCESS_DENIED_ERROR
CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
--error ER_COLUMNACCESS_DENIED_ERROR
CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
--error ER_COLUMNACCESS_DENIED_ERROR
CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
--error ER_COLUMNACCESS_DENIED_ERROR
CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
--connection default
--echo
--echo ---> connection: default
SELECT * FROM mysqltest1.t1;
SELECT * FROM mysqltest1.t2;
SELECT * FROM mysqltest1.t3;
SELECT * FROM mysqltest1.t4;
# Cleanup.
-- disconnect bug24040_con
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
--echo End of 5.0 tests. --echo End of 5.0 tests.

View file

@ -330,8 +330,6 @@ void free_root(MEM_ROOT *root, myf MyFlags)
DBUG_ENTER("free_root"); DBUG_ENTER("free_root");
DBUG_PRINT("enter",("root: 0x%lx flags: %u", (long) root, (uint) MyFlags)); DBUG_PRINT("enter",("root: 0x%lx flags: %u", (long) root, (uint) MyFlags));
if (!root) /* QQ: Should be deleted */
DBUG_VOID_RETURN; /* purecov: inspected */
if (MyFlags & MY_MARK_BLOCKS_FREE) if (MyFlags & MY_MARK_BLOCKS_FREE)
{ {
mark_blocks_free(root); mark_blocks_free(root);

View file

@ -557,4 +557,3 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
} }
return keyseg; return keyseg;
} }

View file

@ -518,7 +518,7 @@ int my_fstat(int Filedes, MY_STAT *stat_area,
myf MyFlags __attribute__((unused))) myf MyFlags __attribute__((unused)))
{ {
DBUG_ENTER("my_fstat"); DBUG_ENTER("my_fstat");
DBUG_PRINT("my",("fd: %d MyFlags: %d",Filedes,MyFlags)); DBUG_PRINT("my",("fd: %d MyFlags: %d", Filedes, MyFlags));
DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area)); DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area));
} }
@ -527,7 +527,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
{ {
int m_used; int m_used;
DBUG_ENTER("my_stat"); DBUG_ENTER("my_stat");
DBUG_PRINT("my", ("path: '%s', stat_area: 0x%lx, MyFlags: %d", path, DBUG_PRINT("my", ("path: '%s' stat_area: 0x%lx MyFlags: %d", path,
(long) stat_area, my_flags)); (long) stat_area, my_flags));
if ((m_used= (stat_area == NULL))) if ((m_used= (stat_area == NULL)))

View file

@ -60,7 +60,7 @@ my_off_t my_seek(File fd, my_off_t pos, int whence,
if (newpos == (os_off_t) -1) if (newpos == (os_off_t) -1)
{ {
my_errno=errno; my_errno=errno;
DBUG_PRINT("error",("lseek: %lu, errno: %d", (ulong) newpos,errno)); DBUG_PRINT("error",("lseek: %lu errno: %d", (ulong) newpos,errno));
DBUG_RETURN(MY_FILEPOS_ERROR); DBUG_RETURN(MY_FILEPOS_ERROR);
} }
if ((my_off_t) newpos != pos) if ((my_off_t) newpos != pos)

View file

@ -76,7 +76,10 @@ void init_thr_alarm(uint max_alarms)
sigfillset(&full_signal_set); /* Neaded to block signals */ sigfillset(&full_signal_set); /* Neaded to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST); pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL); pthread_cond_init(&COND_alarm,NULL);
thr_client_alarm= thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1; if (thd_lib_detected == THD_LIB_LT)
thr_client_alarm= SIGALRM;
else
thr_client_alarm= SIGUSR1;
#ifndef USE_ALARM_THREAD #ifndef USE_ALARM_THREAD
if (thd_lib_detected != THD_LIB_LT) if (thd_lib_detected != THD_LIB_LT)
#endif #endif

View file

@ -20,6 +20,28 @@
#include <m_ctype.h> #include <m_ctype.h>
int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option)
{
int res;
const char **ptr;
if ((res= find_type((my_string) x, typelib, 2)) <= 0)
{
ptr= typelib->type_names;
if (!*x)
fprintf(stderr, "No option given to %s\n", option);
else
fprintf(stderr, "Unknown option to %s: %s\n", option, x);
fprintf(stderr, "Alternatives are: '%s'", *ptr);
while (*++ptr)
fprintf(stderr, ",'%s'", *ptr);
fprintf(stderr, "\n");
exit(1);
}
return res;
}
/* /*
Search after a string in a list of strings. Endspace in x is not compared. Search after a string in a list of strings. Endspace in x is not compared.

View file

@ -134,7 +134,10 @@ void log_init()
/* /*
The function is intended to log error messages. It precedes a message The function is intended to log error messages. It precedes a message
with date, time and [ERROR] tag and print it to the stderr. with date, time and [ERROR] tag and print it to the stderr and stdout.
We want to print it on stdout to be able to know in which context we got the
error
SYNOPSIS SYNOPSIS
log_error() log_error()
@ -146,7 +149,10 @@ void log_error(const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
log(stdout, "ERROR", format, args);
fflush(stdout);
log(stderr, "ERROR", format, args); log(stderr, "ERROR", format, args);
fflush(stderr);
va_end(args); va_end(args);
} }

View file

@ -18,12 +18,9 @@
#endif #endif
#include "thread_registry.h" #include "thread_registry.h"
#include <my_global.h>
#include <thr_alarm.h> #include <thr_alarm.h>
#include <signal.h> #include <signal.h>
#include "log.h"
#ifndef __WIN__ #ifndef __WIN__
/* Kick-off signal handler */ /* Kick-off signal handler */
@ -67,6 +64,8 @@ Thread_registry::~Thread_registry()
/* Check that no one uses the repository. */ /* Check that no one uses the repository. */
pthread_mutex_lock(&LOCK_thread_registry); pthread_mutex_lock(&LOCK_thread_registry);
if (head.next != &head)
log_error("Not all threads died properly\n");
/* All threads must unregister */ /* All threads must unregister */
DBUG_ASSERT(head.next == &head); DBUG_ASSERT(head.next == &head);

View file

@ -2596,24 +2596,32 @@ static void mysql_close_free(MYSQL *mysql)
SYNOPSYS SYNOPSYS
mysql_detach_stmt_list() mysql_detach_stmt_list()
stmt_list pointer to mysql->stmts stmt_list pointer to mysql->stmts
func_name name of calling function
NOTE NOTE
There is similar code in mysql_reconnect(), so changes here There is similar code in mysql_reconnect(), so changes here
should also be reflected there. should also be reflected there.
*/ */
void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused))) void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)),
const char *func_name __attribute__((unused)))
{ {
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
/* Reset connection handle in all prepared statements. */ /* Reset connection handle in all prepared statements. */
LIST *element= *stmt_list; LIST *element= *stmt_list;
char buff[MYSQL_ERRMSG_SIZE];
DBUG_ENTER("mysql_detach_stmt_list");
my_snprintf(buff, sizeof(buff)-1, ER(CR_STMT_CLOSED), func_name);
for (; element; element= element->next) for (; element; element= element->next)
{ {
MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; MYSQL_STMT *stmt= (MYSQL_STMT *) element->data;
set_stmt_errmsg(stmt, buff, CR_STMT_CLOSED, unknown_sqlstate);
stmt->mysql= 0; stmt->mysql= 0;
/* No need to call list_delete for statement here */ /* No need to call list_delete for statement here */
} }
*stmt_list= 0; *stmt_list= 0;
DBUG_VOID_RETURN;
#endif /* MYSQL_CLIENT */ #endif /* MYSQL_CLIENT */
} }
@ -2634,7 +2642,7 @@ void STDCALL mysql_close(MYSQL *mysql)
} }
mysql_close_free_options(mysql); mysql_close_free_options(mysql);
mysql_close_free(mysql); mysql_close_free(mysql);
mysql_detach_stmt_list(&mysql->stmts); mysql_detach_stmt_list(&mysql->stmts, "mysql_close");
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
/* free/close slave list */ /* free/close slave list */
if (mysql->rpl_pivot) if (mysql->rpl_pivot)
@ -2820,6 +2828,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
result->field_count= mysql->field_count; result->field_count= mysql->field_count;
/* The rest of result members is bzeroed in malloc */ /* The rest of result members is bzeroed in malloc */
mysql->fields=0; /* fields is now in result */ mysql->fields=0; /* fields is now in result */
clear_alloc_root(&mysql->field_alloc);
/* just in case this was mistakenly called after mysql_stmt_execute() */ /* just in case this was mistakenly called after mysql_stmt_execute() */
mysql->unbuffered_fetch_owner= 0; mysql->unbuffered_fetch_owner= 0;
DBUG_RETURN(result); /* Data fetched */ DBUG_RETURN(result); /* Data fetched */
@ -2869,6 +2878,7 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql)
result->handle= mysql; result->handle= mysql;
result->current_row= 0; result->current_row= 0;
mysql->fields=0; /* fields is now in result */ mysql->fields=0; /* fields is now in result */
clear_alloc_root(&mysql->field_alloc);
mysql->status=MYSQL_STATUS_USE_RESULT; mysql->status=MYSQL_STATUS_USE_RESULT;
mysql->unbuffered_fetch_owner= &result->unbuffered_fetch_cancelled; mysql->unbuffered_fetch_owner= &result->unbuffered_fetch_cancelled;
DBUG_RETURN(result); /* Data is read to be fetched */ DBUG_RETURN(result); /* Data is read to be fetched */

View file

@ -453,7 +453,7 @@ err:
/* /*
Convert a time string to a TIME struct. Convert a time string to a MYSQL_TIME struct.
SYNOPSIS SYNOPSIS
str_to_time() str_to_time()
@ -639,11 +639,11 @@ fractional:
l_time->second_part= date[4]; l_time->second_part= date[4];
l_time->time_type= MYSQL_TIMESTAMP_TIME; l_time->time_type= MYSQL_TIMESTAMP_TIME;
/* Check if the value is valid and fits into TIME range */ /* Check if the value is valid and fits into MYSQL_TIME range */
if (check_time_range(l_time, warning)) if (check_time_range(l_time, warning))
return 1; return 1;
/* Check if there is garbage at end of the TIME specification */ /* Check if there is garbage at end of the MYSQL_TIME specification */
if (str != end) if (str != end)
{ {
do do
@ -660,11 +660,11 @@ fractional:
/* /*
Check 'time' value to lie in the TIME range Check 'time' value to lie in the MYSQL_TIME range
SYNOPSIS: SYNOPSIS:
check_time_range() check_time_range()
time pointer to TIME value time pointer to MYSQL_TIME value
warning set MYSQL_TIME_WARN_OUT_OF_RANGE flag if the value is out of range warning set MYSQL_TIME_WARN_OUT_OF_RANGE flag if the value is out of range
DESCRIPTION DESCRIPTION
@ -727,7 +727,39 @@ void init_time(void)
} }
/* Calculate nr of day since year 0 in new date-system (from 1615) */ /*
Handle 2 digit year conversions
SYNOPSIS
year_2000_handling()
year 2 digit year
RETURN
Year between 1970-2069
*/
uint year_2000_handling(uint year)
{
if ((year=year+1900) < 1900+YY_PART_YEAR)
year+=100;
return year;
}
/*
Calculate nr of day since year 0 in new date-system (from 1615)
SYNOPSIS
calc_daynr()
year Year (exact 4 digit year, no year conversions)
month Month
day Day
NOTES: 0000-00-00 is a valid date, and will return 0
RETURN
Days since 0000-00-00
*/
long calc_daynr(uint year,uint month,uint day) long calc_daynr(uint year,uint month,uint day)
{ {
@ -737,11 +769,6 @@ long calc_daynr(uint year,uint month,uint day)
if (year == 0 && month == 0 && day == 0) if (year == 0 && month == 0 && day == 0)
DBUG_RETURN(0); /* Skip errors */ DBUG_RETURN(0); /* Skip errors */
if (year < YY_MAGIC_BELOW)
{
if ((year=year+1900) < 1900+YY_PART_YEAR)
year+=100;
}
delsum= (long) (365L * year+ 31*(month-1) +day); delsum= (long) (365L * year+ 31*(month-1) +day);
if (month <= 2) if (month <= 2)
year--; year--;
@ -978,7 +1005,7 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type)
/* /*
Functions to convert time/date/datetime value to a string, Functions to convert time/date/datetime value to a string,
using default format. using default format.
This functions don't check that given TIME structure members are This functions don't check that given MYSQL_TIME structure members are
in valid range. If they are not, return value won't reflect any in valid range. If they are not, return value won't reflect any
valid date either. Additionally, make_time doesn't take into valid date either. Additionally, make_time doesn't take into
account time->day member: it's assumed that days have been converted account time->day member: it's assumed that days have been converted
@ -1064,7 +1091,7 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to)
DESCRIPTION DESCRIPTION
Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS, Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS,
YYYYMMDDHHMMSS to broken-down TIME representation. Return value in YYYYMMDDHHMMSS to broken-down MYSQL_TIME representation. Return value in
YYYYMMDDHHMMSS format as side-effect. YYYYMMDDHHMMSS format as side-effect.
This function also checks if datetime value fits in DATETIME range. This function also checks if datetime value fits in DATETIME range.
@ -1120,6 +1147,7 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
ok: ok:
part1=(long) (nr/LL(1000000)); part1=(long) (nr/LL(1000000));
part2=(long) (nr - (longlong) part1*LL(1000000)); part2=(long) (nr - (longlong) part1*LL(1000000));
time_res->neg= 0;
time_res->year= (int) (part1/10000L); part1%=10000L; time_res->year= (int) (part1/10000L); part1%=10000L;
time_res->month= (int) part1 / 100; time_res->month= (int) part1 / 100;
time_res->day= (int) part1 % 100; time_res->day= (int) part1 % 100;
@ -1156,7 +1184,7 @@ ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time)
} }
/* Convert TIME value to integer in YYYYMMDD format */ /* Convert MYSQL_TIME value to integer in YYYYMMDD format */
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time) ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time)
{ {
@ -1166,7 +1194,7 @@ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time)
/* /*
Convert TIME value to integer in HHMMSS format. Convert MYSQL_TIME value to integer in HHMMSS format.
This function doesn't take into account time->day member: This function doesn't take into account time->day member:
it's assumed that days have been converted to hours already. it's assumed that days have been converted to hours already.
*/ */
@ -1180,7 +1208,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time)
/* /*
Convert struct TIME (date and time split into year/month/day/hour/... Convert struct MYSQL_TIME (date and time split into year/month/day/hour/...
to a number in format YYYYMMDDHHMMSS (DATETIME), to a number in format YYYYMMDDHHMMSS (DATETIME),
YYYYMMDD (DATE) or HHMMSS (TIME). YYYYMMDD (DATE) or HHMMSS (TIME).
@ -1194,7 +1222,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time)
SELECT ?+1; SELECT ?+1;
NOTE NOTE
This function doesn't check that given TIME structure members are This function doesn't check that given MYSQL_TIME structure members are
in valid range. If they are not, return value won't reflect any in valid range. If they are not, return value won't reflect any
valid date either. valid date either.
*/ */

View file

@ -79,7 +79,7 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc
${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc ${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc
${PROJECT_SOURCE_DIR}/sql/lex_hash.h) ${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl
taocrypt strings vio regex wsock32) taocrypt strings vio regex wsock32 ws2_32)
IF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_ARCHIVE_STORAGE_ENGINE)
TARGET_LINK_LIBRARIES(mysqld archive) TARGET_LINK_LIBRARIES(mysqld archive)
ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE)

View file

@ -286,7 +286,7 @@ int
Event_parse_data::init_execute_at(THD *thd) Event_parse_data::init_execute_at(THD *thd)
{ {
my_bool not_used; my_bool not_used;
TIME ltime; MYSQL_TIME ltime;
my_time_t ltime_utc; my_time_t ltime_utc;
DBUG_ENTER("Event_parse_data::init_execute_at"); DBUG_ENTER("Event_parse_data::init_execute_at");
@ -455,7 +455,7 @@ int
Event_parse_data::init_starts(THD *thd) Event_parse_data::init_starts(THD *thd)
{ {
my_bool not_used; my_bool not_used;
TIME ltime; MYSQL_TIME ltime;
my_time_t ltime_utc; my_time_t ltime_utc;
DBUG_ENTER("Event_parse_data::init_starts"); DBUG_ENTER("Event_parse_data::init_starts");
@ -509,7 +509,7 @@ int
Event_parse_data::init_ends(THD *thd) Event_parse_data::init_ends(THD *thd)
{ {
my_bool not_used; my_bool not_used;
TIME ltime; MYSQL_TIME ltime;
my_time_t ltime_utc; my_time_t ltime_utc;
DBUG_ENTER("Event_parse_data::init_ends"); DBUG_ENTER("Event_parse_data::init_ends");
@ -941,7 +941,7 @@ int
Event_queue_element::load_from_row(THD *thd, TABLE *table) Event_queue_element::load_from_row(THD *thd, TABLE *table)
{ {
char *ptr; char *ptr;
TIME time; MYSQL_TIME time;
LEX_STRING tz_name; LEX_STRING tz_name;
DBUG_ENTER("Event_queue_element::load_from_row"); DBUG_ENTER("Event_queue_element::load_from_row");
@ -1136,7 +1136,7 @@ error:
*/ */
static static
my_time_t my_time_t
add_interval(TIME *ltime, const Time_zone *time_zone, add_interval(MYSQL_TIME *ltime, const Time_zone *time_zone,
interval_type scale, INTERVAL interval) interval_type scale, INTERVAL interval)
{ {
if (date_add_interval(ltime, scale, interval)) if (date_add_interval(ltime, scale, interval))
@ -1229,8 +1229,8 @@ bool get_next_time(const Time_zone *time_zone, my_time_t *next,
} }
DBUG_PRINT("info", ("seconds: %ld months: %ld", (long) seconds, (long) months)); DBUG_PRINT("info", ("seconds: %ld months: %ld", (long) seconds, (long) months));
TIME local_start; MYSQL_TIME local_start;
TIME local_now; MYSQL_TIME local_now;
/* Convert times from UTC to local. */ /* Convert times from UTC to local. */
{ {
@ -1473,7 +1473,7 @@ Event_queue_element::compute_next_execution_time()
{ {
/* /*
Both starts and m_ends are set and time_now is between them (incl.) Both starts and m_ends are set and time_now is between them (incl.)
If last_executed is set then increase with m_expression. The new TIME is If last_executed is set then increase with m_expression. The new MYSQL_TIME is
after m_ends set execute_at to 0. And check for on_completion after m_ends set execute_at to 0. And check for on_completion
If not set then schedule for now. If not set then schedule for now.
*/ */
@ -1615,7 +1615,7 @@ err:
/* /*
Set the internal last_executed TIME struct to now. NOW is the Set the internal last_executed MYSQL_TIME struct to now. NOW is the
time according to thd->query_start(), so the THD's clock. time according to thd->query_start(), so the THD's clock.
SYNOPSIS SYNOPSIS
@ -1686,7 +1686,7 @@ append_datetime(String *buf, Time_zone *time_zone, my_time_t secs,
Pass the buffer and the second param tells fills the buffer and Pass the buffer and the second param tells fills the buffer and
returns the number of chars to copy. returns the number of chars to copy.
*/ */
TIME time; MYSQL_TIME time;
time_zone->gmt_sec_to_TIME(&time, secs); time_zone->gmt_sec_to_TIME(&time, secs);
buf->append(dtime_buff, my_datetime_to_str(&time, dtime_buff)); buf->append(dtime_buff, my_datetime_to_str(&time, dtime_buff));
buf->append(STRING_WITH_LEN("'")); buf->append(STRING_WITH_LEN("'"));

View file

@ -218,7 +218,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
if (!et->starts_null) if (!et->starts_null)
{ {
TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->starts); my_tz_UTC->gmt_sec_to_TIME(&time, et->starts);
fields[ET_FIELD_STARTS]->set_notnull(); fields[ET_FIELD_STARTS]->set_notnull();
@ -227,7 +227,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
if (!et->ends_null) if (!et->ends_null)
{ {
TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->ends); my_tz_UTC->gmt_sec_to_TIME(&time, et->ends);
fields[ET_FIELD_ENDS]->set_notnull(); fields[ET_FIELD_ENDS]->set_notnull();
@ -246,7 +246,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
fields[ET_FIELD_STARTS]->set_null(); fields[ET_FIELD_STARTS]->set_null();
fields[ET_FIELD_ENDS]->set_null(); fields[ET_FIELD_ENDS]->set_null();
TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->execute_at); my_tz_UTC->gmt_sec_to_TIME(&time, et->execute_at);
fields[ET_FIELD_EXECUTE_AT]->set_notnull(); fields[ET_FIELD_EXECUTE_AT]->set_notnull();
@ -940,7 +940,7 @@ update_timing_fields_for_event(THD *thd,
if (update_last_executed) if (update_last_executed)
{ {
TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, last_executed); my_tz_UTC->gmt_sec_to_TIME(&time, last_executed);
fields[ET_FIELD_LAST_EXECUTED]->set_notnull(); fields[ET_FIELD_LAST_EXECUTED]->set_notnull();

View file

@ -737,7 +737,7 @@ Event_queue::dump_internal_status()
mutex_last_attempted_lock_at_line); mutex_last_attempted_lock_at_line);
printf("WOC : %s\n", waiting_on_cond? "YES":"NO"); printf("WOC : %s\n", waiting_on_cond? "YES":"NO");
TIME time; MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, next_activation_at); my_tz_UTC->gmt_sec_to_TIME(&time, next_activation_at);
printf("Next activation : %04d-%02d-%02d %02d:%02d:%02d\n", printf("Next activation : %04d-%02d-%02d %02d:%02d:%02d\n",
time.year, time.month, time.day, time.hour, time.minute, time.second); time.year, time.month, time.day, time.hour, time.minute, time.second);

View file

@ -1574,7 +1574,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
} }
bool Field::get_date(TIME *ltime,uint fuzzydate) bool Field::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res; String tmp(buff,sizeof(buff),&my_charset_bin),*res;
@ -1585,7 +1585,7 @@ bool Field::get_date(TIME *ltime,uint fuzzydate)
return 0; return 0;
} }
bool Field::get_time(TIME *ltime) bool Field::get_time(MYSQL_TIME *ltime)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res; String tmp(buff,sizeof(buff),&my_charset_bin),*res;
@ -1602,7 +1602,7 @@ bool Field::get_time(TIME *ltime)
Needs to be changed if/when we want to support different time formats Needs to be changed if/when we want to support different time formats
*/ */
int Field::store_time(TIME *ltime, timestamp_type type_arg) int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
char buff[MAX_DATE_STRING_REP_LENGTH]; char buff[MAX_DATE_STRING_REP_LENGTH];
@ -2550,7 +2550,7 @@ int Field_new_decimal::store_decimal(const my_decimal *decimal_value)
} }
int Field_new_decimal::store_time(TIME *ltime, timestamp_type t_type) int Field_new_decimal::store_time(MYSQL_TIME *ltime, timestamp_type t_type)
{ {
my_decimal decimal_value; my_decimal decimal_value;
return store_value(date2my_decimal(ltime, &decimal_value)); return store_value(date2my_decimal(ltime, &decimal_value));
@ -4457,7 +4457,7 @@ timestamp_auto_set_type Field_timestamp::get_auto_set_type() const
int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME l_time; MYSQL_TIME l_time;
my_time_t tmp= 0; my_time_t tmp= 0;
int error; int error;
bool have_smth_to_conv; bool have_smth_to_conv;
@ -4528,7 +4528,7 @@ int Field_timestamp::store(double nr)
int Field_timestamp::store(longlong nr, bool unsigned_val) int Field_timestamp::store(longlong nr, bool unsigned_val)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME l_time; MYSQL_TIME l_time;
my_time_t timestamp= 0; my_time_t timestamp= 0;
int error; int error;
my_bool in_dst_time_gap; my_bool in_dst_time_gap;
@ -4587,7 +4587,7 @@ longlong Field_timestamp::val_int(void)
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
uint32 temp; uint32 temp;
TIME time_tmp; MYSQL_TIME time_tmp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -4613,7 +4613,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
uint32 temp, temp2; uint32 temp, temp2;
TIME time_tmp; MYSQL_TIME time_tmp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
char *to; char *to;
@ -4682,7 +4682,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
} }
bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate) bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
long temp; long temp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
@ -4706,7 +4706,7 @@ bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate)
return 0; return 0;
} }
bool Field_timestamp::get_time(TIME *ltime) bool Field_timestamp::get_time(MYSQL_TIME *ltime)
{ {
return Field_timestamp::get_date(ltime,0); return Field_timestamp::get_date(ltime,0);
} }
@ -4714,7 +4714,7 @@ bool Field_timestamp::get_time(TIME *ltime)
bool Field_timestamp::send_binary(Protocol *protocol) bool Field_timestamp::send_binary(Protocol *protocol)
{ {
TIME tm; MYSQL_TIME tm;
Field_timestamp::get_date(&tm, 0); Field_timestamp::get_date(&tm, 0);
return protocol->store(&tm); return protocol->store(&tm);
} }
@ -4790,7 +4790,7 @@ void Field_timestamp::set_time()
int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
TIME ltime; MYSQL_TIME ltime;
long tmp; long tmp;
int error= 0; int error= 0;
int warning; int warning;
@ -4805,9 +4805,12 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
else else
{ {
if (warning & MYSQL_TIME_WARN_TRUNCATED) if (warning & MYSQL_TIME_WARN_TRUNCATED)
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, {
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, WARN_DATA_TRUNCATED,
from, len, MYSQL_TIMESTAMP_TIME, 1); from, len, MYSQL_TIMESTAMP_TIME, 1);
error= 1;
}
if (warning & MYSQL_TIME_WARN_OUT_OF_RANGE) if (warning & MYSQL_TIME_WARN_OUT_OF_RANGE)
{ {
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
@ -4818,8 +4821,6 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
if (ltime.month) if (ltime.month)
ltime.day=0; ltime.day=0;
tmp=(ltime.day*24L+ltime.hour)*10000L+(ltime.minute*100+ltime.second); tmp=(ltime.day*24L+ltime.hour)*10000L+(ltime.minute*100+ltime.second);
if (error > 1)
error= 2;
} }
if (ltime.neg) if (ltime.neg)
@ -4829,7 +4830,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
} }
int Field_time::store_time(TIME *ltime, timestamp_type time_type) int Field_time::store_time(MYSQL_TIME *ltime, timestamp_type time_type)
{ {
long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L + long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L +
(ltime->minute * 100 + ltime->second); (ltime->minute * 100 + ltime->second);
@ -4938,7 +4939,7 @@ String *Field_time::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
TIME ltime; MYSQL_TIME ltime;
val_buffer->alloc(19); val_buffer->alloc(19);
long tmp=(long) sint3korr(ptr); long tmp=(long) sint3korr(ptr);
ltime.neg= 0; ltime.neg= 0;
@ -4962,7 +4963,7 @@ String *Field_time::val_str(String *val_buffer,
DATE_FORMAT(time, "%l.%i %p") DATE_FORMAT(time, "%l.%i %p")
*/ */
bool Field_time::get_date(TIME *ltime, uint fuzzydate) bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
long tmp; long tmp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
@ -4990,7 +4991,7 @@ bool Field_time::get_date(TIME *ltime, uint fuzzydate)
} }
bool Field_time::get_time(TIME *ltime) bool Field_time::get_time(MYSQL_TIME *ltime)
{ {
long tmp=(long) sint3korr(ptr); long tmp=(long) sint3korr(ptr);
ltime->neg=0; ltime->neg=0;
@ -5012,7 +5013,7 @@ bool Field_time::get_time(TIME *ltime)
bool Field_time::send_binary(Protocol *protocol) bool Field_time::send_binary(Protocol *protocol)
{ {
TIME tm; MYSQL_TIME tm;
Field_time::get_time(&tm); Field_time::get_time(&tm);
tm.day= tm.hour/24; // Move hours to days tm.day= tm.hour/24; // Move hours to days
tm.hour-= tm.day*24; tm.hour-= tm.day*24;
@ -5170,7 +5171,7 @@ void Field_year::sql_type(String &res) const
int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME l_time; MYSQL_TIME l_time;
uint32 tmp; uint32 tmp;
int error; int error;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
@ -5227,7 +5228,7 @@ int Field_date::store(double nr)
int Field_date::store(longlong nr, bool unsigned_val) int Field_date::store(longlong nr, bool unsigned_val)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME not_used; MYSQL_TIME not_used;
int error; int error;
longlong initial_nr= nr; longlong initial_nr= nr;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
@ -5268,7 +5269,7 @@ int Field_date::store(longlong nr, bool unsigned_val)
bool Field_date::send_binary(Protocol *protocol) bool Field_date::send_binary(Protocol *protocol)
{ {
longlong tmp= Field_date::val_int(); longlong tmp= Field_date::val_int();
TIME tm; MYSQL_TIME tm;
tm.year= (uint32) tmp/10000L % 10000; tm.year= (uint32) tmp/10000L % 10000;
tm.month= (uint32) tmp/100 % 100; tm.month= (uint32) tmp/100 % 100;
tm.day= (uint32) tmp % 100; tm.day= (uint32) tmp % 100;
@ -5308,7 +5309,7 @@ String *Field_date::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
TIME ltime; MYSQL_TIME ltime;
val_buffer->alloc(field_length); val_buffer->alloc(field_length);
int32 tmp; int32 tmp;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -5377,10 +5378,27 @@ void Field_date::sql_type(String &res) const
** In number context: YYYYMMDD ** In number context: YYYYMMDD
****************************************************************************/ ****************************************************************************/
/*
Store string into a date field
SYNOPSIS
Field_newdate::store()
from Date string
len Length of date field
cs Character set (not used)
RETURN
0 ok
1 Value was cut during conversion
2 Wrong date string
3 Datetime value that was cut (warning level NOTE)
*/
int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME l_time; long tmp;
MYSQL_TIME l_time;
int error; int error;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
enum enum_mysql_timestamp_type ret; enum enum_mysql_timestamp_type ret;
@ -5391,20 +5409,23 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
MODE_INVALID_DATES))), MODE_INVALID_DATES))),
&error)) <= MYSQL_TIMESTAMP_ERROR) &error)) <= MYSQL_TIMESTAMP_ERROR)
{ {
int3store(ptr,0L); tmp= 0;
error= 2; error= 2;
} }
else else
{ {
int3store(ptr, l_time.day + l_time.month*32 + l_time.year*16*32); tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
if(!error && (ret != MYSQL_TIMESTAMP_DATE)) if (!error && (ret != MYSQL_TIMESTAMP_DATE))
return 2; error= 3; // Datetime was cut (note)
} }
if (error) if (error)
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE :
MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED,
from, len, MYSQL_TIMESTAMP_DATE, 1); from, len, MYSQL_TIMESTAMP_DATE, 1);
int3store(ptr, tmp);
return error; return error;
} }
@ -5425,7 +5446,7 @@ int Field_newdate::store(double nr)
int Field_newdate::store(longlong nr, bool unsigned_val) int Field_newdate::store(longlong nr, bool unsigned_val)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME l_time; MYSQL_TIME l_time;
longlong tmp; longlong tmp;
int error; int error;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
@ -5452,7 +5473,7 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
} }
int Field_newdate::store_time(TIME *ltime,timestamp_type time_type) int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
long tmp; long tmp;
@ -5487,7 +5508,7 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type time_type)
bool Field_newdate::send_binary(Protocol *protocol) bool Field_newdate::send_binary(Protocol *protocol)
{ {
TIME tm; MYSQL_TIME tm;
Field_newdate::get_date(&tm,0); Field_newdate::get_date(&tm,0);
return protocol->store_date(&tm); return protocol->store_date(&tm);
} }
@ -5538,7 +5559,7 @@ String *Field_newdate::val_str(String *val_buffer,
} }
bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) bool Field_newdate::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
uint32 tmp=(uint32) uint3korr(ptr); uint32 tmp=(uint32) uint3korr(ptr);
ltime->day= tmp & 31; ltime->day= tmp & 31;
@ -5551,7 +5572,7 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate)
} }
bool Field_newdate::get_time(TIME *ltime) bool Field_newdate::get_time(MYSQL_TIME *ltime)
{ {
return Field_newdate::get_date(ltime,0); return Field_newdate::get_date(ltime,0);
} }
@ -5590,7 +5611,7 @@ void Field_newdate::sql_type(String &res) const
int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs) int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME time_tmp; MYSQL_TIME time_tmp;
int error; int error;
ulonglong tmp= 0; ulonglong tmp= 0;
enum enum_mysql_timestamp_type func_res; enum enum_mysql_timestamp_type func_res;
@ -5643,7 +5664,7 @@ int Field_datetime::store(double nr)
int Field_datetime::store(longlong nr, bool unsigned_val) int Field_datetime::store(longlong nr, bool unsigned_val)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
TIME not_used; MYSQL_TIME not_used;
int error; int error;
longlong initial_nr= nr; longlong initial_nr= nr;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
@ -5678,7 +5699,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val)
} }
int Field_datetime::store_time(TIME *ltime,timestamp_type time_type) int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
longlong tmp; longlong tmp;
@ -5724,7 +5745,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type time_type)
bool Field_datetime::send_binary(Protocol *protocol) bool Field_datetime::send_binary(Protocol *protocol)
{ {
TIME tm; MYSQL_TIME tm;
Field_datetime::get_date(&tm, TIME_FUZZY_DATE); Field_datetime::get_date(&tm, TIME_FUZZY_DATE);
return protocol->store(&tm); return protocol->store(&tm);
} }
@ -5798,7 +5819,7 @@ String *Field_datetime::val_str(String *val_buffer,
return val_buffer; return val_buffer;
} }
bool Field_datetime::get_date(TIME *ltime, uint fuzzydate) bool Field_datetime::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
longlong tmp=Field_datetime::val_int(); longlong tmp=Field_datetime::val_int();
uint32 part1,part2; uint32 part1,part2;
@ -5817,7 +5838,7 @@ bool Field_datetime::get_date(TIME *ltime, uint fuzzydate)
return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0; return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0;
} }
bool Field_datetime::get_time(TIME *ltime) bool Field_datetime::get_time(MYSQL_TIME *ltime)
{ {
return Field_datetime::get_date(ltime,0); return Field_datetime::get_date(ltime,0);
} }
@ -9354,10 +9375,13 @@ uint32 Field_blob::max_display_length()
NOTE NOTE
This function won't produce warning and increase cut fields counter This function won't produce warning and increase cut fields counter
if count_cuted_fields == FIELD_CHECK_IGNORE for current thread. if count_cuted_fields == CHECK_FIELD_IGNORE for current thread.
if count_cuted_fields == CHECK_FIELD_IGNORE then we ignore notes.
This allows us to avoid notes in optimisation, like convert_constant_item().
RETURN VALUE RETURN VALUE
1 if count_cuted_fields == FIELD_CHECK_IGNORE 1 if count_cuted_fields == CHECK_FIELD_IGNORE and error level is not NOTE
0 otherwise 0 otherwise
*/ */
@ -9377,7 +9401,7 @@ Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
thd->row_count); thd->row_count);
return 0; return 0;
} }
return 1; return level >= MYSQL_ERROR::WARN_LEVEL_WARN;
} }
@ -9405,9 +9429,10 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
timestamp_type ts_type, int cuted_increment) timestamp_type ts_type, int cuted_increment)
{ {
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
if (thd->really_abort_on_warning() || if ((thd->really_abort_on_warning() &&
level >= MYSQL_ERROR::WARN_LEVEL_WARN) ||
set_warning(level, code, cuted_increment)) set_warning(level, code, cuted_increment))
make_truncated_value_warning(thd, str, str_length, ts_type, make_truncated_value_warning(thd, level, str, str_length, ts_type,
field_name); field_name);
} }
@ -9440,7 +9465,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
{ {
char str_nr[22]; char str_nr[22];
char *str_end= longlong10_to_str(nr, str_nr, -10); char *str_end= longlong10_to_str(nr, str_nr, -10);
make_truncated_value_warning(thd, str_nr, (uint) (str_end - str_nr), make_truncated_value_warning(thd, level, str_nr, (uint) (str_end - str_nr),
ts_type, field_name); ts_type, field_name);
} }
} }
@ -9473,7 +9498,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
/* DBL_DIG is enough to print '-[digits].E+###' */ /* DBL_DIG is enough to print '-[digits].E+###' */
char str_nr[DBL_DIG + 8]; char str_nr[DBL_DIG + 8];
uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr)); uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr));
make_truncated_value_warning(thd, str_nr, str_len, ts_type, make_truncated_value_warning(thd, level, str_nr, str_len, ts_type,
field_name); field_name);
} }
} }

View file

@ -98,7 +98,7 @@ public:
virtual int store(double nr)=0; virtual int store(double nr)=0;
virtual int store(longlong nr, bool unsigned_val)=0; virtual int store(longlong nr, bool unsigned_val)=0;
virtual int store_decimal(const my_decimal *d)=0; virtual int store_decimal(const my_decimal *d)=0;
virtual int store_time(TIME *ltime, timestamp_type t_type); virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
virtual double val_real(void)=0; virtual double val_real(void)=0;
virtual longlong val_int(void)=0; virtual longlong val_int(void)=0;
virtual my_decimal *val_decimal(my_decimal *); virtual my_decimal *val_decimal(my_decimal *);
@ -347,8 +347,8 @@ public:
} }
void copy_from_tmp(int offset); void copy_from_tmp(int offset);
uint fill_cache_field(struct st_cache_field *copy); uint fill_cache_field(struct st_cache_field *copy);
virtual bool get_date(TIME *ltime,uint fuzzydate); virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
virtual bool get_time(TIME *ltime); virtual bool get_time(MYSQL_TIME *ltime);
virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; } virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; }
virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
virtual bool has_charset(void) const { return FALSE; } virtual bool has_charset(void) const { return FALSE; }
@ -567,7 +567,7 @@ public:
int store(const char *to, uint length, CHARSET_INFO *charset); int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr); int store(double nr);
int store(longlong nr, bool unsigned_val); int store(longlong nr, bool unsigned_val);
int store_time(TIME *ltime, timestamp_type t_type); int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
int store_decimal(const my_decimal *); int store_decimal(const my_decimal *);
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
@ -910,8 +910,8 @@ public:
longget(tmp,ptr); longget(tmp,ptr);
return tmp; return tmp;
} }
bool get_date(TIME *ltime,uint fuzzydate); bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime); bool get_time(MYSQL_TIME *ltime);
timestamp_auto_set_type get_auto_set_type() const; timestamp_auto_set_type get_auto_set_type() const;
}; };
@ -984,7 +984,7 @@ public:
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr); int store(double nr);
int store(longlong nr, bool unsigned_val); int store(longlong nr, bool unsigned_val);
int store_time(TIME *ltime, timestamp_type type); int store_time(MYSQL_TIME *ltime, timestamp_type type);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; } int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
@ -996,8 +996,8 @@ public:
void sql_type(String &str) const; void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; } bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; } bool zero_pack() const { return 1; }
bool get_date(TIME *ltime,uint fuzzydate); bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime); bool get_time(MYSQL_TIME *ltime);
}; };
@ -1016,7 +1016,7 @@ public:
enum_field_types type() const { return MYSQL_TYPE_TIME;} enum_field_types type() const { return MYSQL_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
int store_time(TIME *ltime, timestamp_type type); int store_time(MYSQL_TIME *ltime, timestamp_type type);
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr); int store(double nr);
int store(longlong nr, bool unsigned_val); int store(longlong nr, bool unsigned_val);
@ -1024,9 +1024,9 @@ public:
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
bool get_date(TIME *ltime, uint fuzzydate); bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
bool send_binary(Protocol *protocol); bool send_binary(Protocol *protocol);
bool get_time(TIME *ltime); bool get_time(MYSQL_TIME *ltime);
int cmp(const char *,const char*); int cmp(const char *,const char*);
void sort_string(char *buff,uint length); void sort_string(char *buff,uint length);
uint32 pack_length() const { return 3; } uint32 pack_length() const { return 3; }
@ -1057,7 +1057,7 @@ public:
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr); int store(double nr);
int store(longlong nr, bool unsigned_val); int store(longlong nr, bool unsigned_val);
int store_time(TIME *ltime, timestamp_type type); int store_time(MYSQL_TIME *ltime, timestamp_type type);
int reset(void) int reset(void)
{ {
ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
@ -1073,8 +1073,8 @@ public:
void sql_type(String &str) const; void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; } bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; } bool zero_pack() const { return 1; }
bool get_date(TIME *ltime,uint fuzzydate); bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime); bool get_time(MYSQL_TIME *ltime);
}; };

View file

@ -133,7 +133,7 @@ static uint ndbcluster_alter_table_flags(uint flags)
} }
static int ndbcluster_inited= 0; static int ndbcluster_inited= 0;
static int ndbcluster_terminating= 0; int ndbcluster_terminating= 0;
static Ndb* g_ndb= NULL; static Ndb* g_ndb= NULL;
Ndb_cluster_connection* g_ndb_cluster_connection= NULL; Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
@ -4260,8 +4260,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
{ {
m_transaction_on= FALSE; m_transaction_on= FALSE;
/* Would be simpler if has_transactions() didn't always say "yes" */ /* Would be simpler if has_transactions() didn't always say "yes" */
thd->options|= OPTION_STATUS_NO_TRANS_UPDATE; thd->no_trans_update.all= thd->no_trans_update.stmt= TRUE;
thd->no_trans_update= TRUE;
} }
else if (!thd->transaction.on) else if (!thd->transaction.on)
m_transaction_on= FALSE; m_transaction_on= FALSE;
@ -4965,7 +4964,7 @@ int ha_ndbcluster::create(const char *name,
for (i= 0; i < form->s->fields; i++) for (i= 0; i < form->s->fields; i++)
{ {
Field *field= form->field[i]; Field *field= form->field[i];
DBUG_PRINT("info", ("name: %s, type: %u, pack_length: %d", DBUG_PRINT("info", ("name: %s type: %u pack_length: %d",
field->field_name, field->real_type(), field->field_name, field->real_type(),
field->pack_length())); field->pack_length()));
if ((my_errno= create_ndb_column(col, field, create_info))) if ((my_errno= create_ndb_column(col, field, create_info)))

View file

@ -1004,4 +1004,6 @@ void ndbcluster_print_error(int error, const NdbOperation *error_op);
static const char ndbcluster_hton_name[]= "ndbcluster"; static const char ndbcluster_hton_name[]= "ndbcluster";
static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1; static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1;
extern int ndbcluster_terminating;
extern int ndb_util_thread_running;
extern pthread_cond_t COND_ndb_util_ready;

View file

@ -582,10 +582,30 @@ static int ndbcluster_binlog_end(THD *thd)
ndbcluster_binlog_inited= 0; ndbcluster_binlog_inited= 0;
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
if (ndb_util_thread_running > 0)
{
/*
Wait for util thread to die (as this uses the injector mutex)
There is a very small change that ndb_util_thread dies and the
following mutex is freed before it's accessed. This shouldn't
however be a likely case as the ndbcluster_binlog_end is supposed to
be called before ndb_cluster_end().
*/
pthread_mutex_lock(&LOCK_ndb_util_thread);
/* Ensure mutex are not freed if ndb_cluster_end is running at same time */
ndb_util_thread_running++;
ndbcluster_terminating= 1;
pthread_cond_signal(&COND_ndb_util_thread);
while (ndb_util_thread_running > 1)
pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
ndb_util_thread_running--;
pthread_mutex_unlock(&LOCK_ndb_util_thread);
}
/* wait for injector thread to finish */ /* wait for injector thread to finish */
ndbcluster_binlog_terminating= 1; ndbcluster_binlog_terminating= 1;
pthread_cond_signal(&injector_cond);
pthread_mutex_lock(&injector_mutex); pthread_mutex_lock(&injector_mutex);
pthread_cond_signal(&injector_cond);
while (ndb_binlog_thread_running > 0) while (ndb_binlog_thread_running > 0)
pthread_cond_wait(&injector_cond, &injector_mutex); pthread_cond_wait(&injector_cond, &injector_mutex);
pthread_mutex_unlock(&injector_mutex); pthread_mutex_unlock(&injector_mutex);

View file

@ -844,7 +844,7 @@ int ha_rollback_trans(THD *thd, bool all)
the error log; but we don't want users to wonder why they have this the error log; but we don't want users to wonder why they have this
message in the error log, so we don't send it. message in the error log, so we don't send it.
*/ */
if (is_real_trans && (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) && if (is_real_trans && thd->no_trans_update.all &&
!thd->slave_thread && thd->killed != THD::KILL_CONNECTION) !thd->slave_thread && thd->killed != THD::KILL_CONNECTION)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARNING_NOT_COMPLETE_ROLLBACK, ER_WARNING_NOT_COMPLETE_ROLLBACK,

View file

@ -267,7 +267,7 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value)
my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
{ {
my_decimal_set_zero(decimal_value); my_decimal_set_zero(decimal_value);
@ -280,7 +280,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_time(&ltime)) if (get_time(&ltime))
{ {
my_decimal_set_zero(decimal_value); my_decimal_set_zero(decimal_value);
@ -315,7 +315,7 @@ longlong Item::val_int_from_decimal()
int Item::save_time_in_field(Field *field) int Item::save_time_in_field(Field *field)
{ {
TIME ltime; MYSQL_TIME ltime;
if (get_time(&ltime)) if (get_time(&ltime))
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
@ -325,7 +325,7 @@ int Item::save_time_in_field(Field *field)
int Item::save_date_in_field(Field *field) int Item::save_date_in_field(Field *field)
{ {
TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
@ -853,22 +853,40 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const
/* /*
Get the value of the function as a TIME structure. Get the value of the function as a MYSQL_TIME structure.
As a extra convenience the time structure is reset on error! As a extra convenience the time structure is reset on error!
*/ */
bool Item::get_date(TIME *ltime,uint fuzzydate) bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
char buff[40]; if (result_type() == STRING_RESULT)
String tmp(buff,sizeof(buff), &my_charset_bin),*res;
if (!(res=val_str(&tmp)) ||
str_to_datetime_with_warn(res->ptr(), res->length(),
ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
{ {
bzero((char*) ltime,sizeof(*ltime)); char buff[40];
return 1; String tmp(buff,sizeof(buff), &my_charset_bin),*res;
if (!(res=val_str(&tmp)) ||
str_to_datetime_with_warn(res->ptr(), res->length(),
ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
goto err;
}
else
{
longlong value= val_int();
int was_cut;
if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1))
{
char buff[22], *end;
end= longlong10_to_str(value, buff, -10);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE,
NullS);
goto err;
}
} }
return 0; return 0;
err:
bzero((char*) ltime,sizeof(*ltime));
return 1;
} }
/* /*
@ -876,7 +894,7 @@ bool Item::get_date(TIME *ltime,uint fuzzydate)
As a extra convenience the time structure is reset on error! As a extra convenience the time structure is reset on error!
*/ */
bool Item::get_time(TIME *ltime) bool Item::get_time(MYSQL_TIME *ltime)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res; String tmp(buff,sizeof(buff),&my_charset_bin),*res;
@ -1872,7 +1890,7 @@ String *Item_field::str_result(String *str)
return result_field->val_str(str,&str_value); return result_field->val_str(str,&str_value);
} }
bool Item_field::get_date(TIME *ltime,uint fuzzydate) bool Item_field::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate)) if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
{ {
@ -1882,7 +1900,7 @@ bool Item_field::get_date(TIME *ltime,uint fuzzydate)
return 0; return 0;
} }
bool Item_field::get_date_result(TIME *ltime,uint fuzzydate) bool Item_field::get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
{ {
if ((null_value=result_field->is_null()) || if ((null_value=result_field->is_null()) ||
result_field->get_date(ltime,fuzzydate)) result_field->get_date(ltime,fuzzydate))
@ -1893,7 +1911,7 @@ bool Item_field::get_date_result(TIME *ltime,uint fuzzydate)
return 0; return 0;
} }
bool Item_field::get_time(TIME *ltime) bool Item_field::get_time(MYSQL_TIME *ltime)
{ {
if ((null_value=field->is_null()) || field->get_time(ltime)) if ((null_value=field->is_null()) || field->get_time(ltime))
{ {
@ -2420,7 +2438,7 @@ void Item_param::set_decimal(const char *str, ulong length)
/* /*
Set parameter value from TIME value. Set parameter value from MYSQL_TIME value.
SYNOPSIS SYNOPSIS
set_time() set_time()
@ -2434,7 +2452,7 @@ void Item_param::set_decimal(const char *str, ulong length)
the fact that even wrong value sent over binary protocol fits into the fact that even wrong value sent over binary protocol fits into
MAX_DATE_STRING_REP_LENGTH buffer. MAX_DATE_STRING_REP_LENGTH buffer.
*/ */
void Item_param::set_time(TIME *tm, timestamp_type time_type, void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
uint32 max_length_arg) uint32 max_length_arg)
{ {
DBUG_ENTER("Item_param::set_time"); DBUG_ENTER("Item_param::set_time");
@ -2449,7 +2467,8 @@ void Item_param::set_time(TIME *tm, timestamp_type time_type,
{ {
char buff[MAX_DATE_STRING_REP_LENGTH]; char buff[MAX_DATE_STRING_REP_LENGTH];
uint length= my_TIME_to_str(&value.time, buff); uint length= my_TIME_to_str(&value.time, buff);
make_truncated_value_warning(current_thd, buff, length, time_type, 0); make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buff, length, time_type, 0);
set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR); set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR);
} }
@ -2651,7 +2670,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
} }
bool Item_param::get_time(TIME *res) bool Item_param::get_time(MYSQL_TIME *res)
{ {
if (state == TIME_VALUE) if (state == TIME_VALUE)
{ {
@ -2666,7 +2685,7 @@ bool Item_param::get_time(TIME *res)
} }
bool Item_param::get_date(TIME *res, uint fuzzydate) bool Item_param::get_date(MYSQL_TIME *res, uint fuzzydate)
{ {
if (state == TIME_VALUE) if (state == TIME_VALUE)
{ {
@ -3092,7 +3111,7 @@ String* Item_ref_null_helper::val_str(String* s)
} }
bool Item_ref_null_helper::get_date(TIME *ltime, uint fuzzydate) bool Item_ref_null_helper::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate)); return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate));
} }
@ -4923,7 +4942,7 @@ bool Item::send(Protocol *protocol, String *buffer)
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
{ {
TIME tm; MYSQL_TIME tm;
get_date(&tm, TIME_FUZZY_DATE); get_date(&tm, TIME_FUZZY_DATE);
if (!null_value) if (!null_value)
{ {
@ -4936,7 +4955,7 @@ bool Item::send(Protocol *protocol, String *buffer)
} }
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
{ {
TIME tm; MYSQL_TIME tm;
get_time(&tm); get_time(&tm);
if (!null_value) if (!null_value)
result= protocol->store_time(&tm); result= protocol->store_time(&tm);
@ -5488,7 +5507,7 @@ bool Item_ref::is_null()
} }
bool Item_ref::get_date(TIME *ltime,uint fuzzydate) bool Item_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
return (null_value=(*ref)->get_date_result(ltime,fuzzydate)); return (null_value=(*ref)->get_date_result(ltime,fuzzydate));
} }
@ -5587,7 +5606,7 @@ bool Item_direct_ref::is_null()
} }
bool Item_direct_ref::get_date(TIME *ltime,uint fuzzydate) bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
return (null_value=(*ref)->get_date(ltime,fuzzydate)); return (null_value=(*ref)->get_date(ltime,fuzzydate));
} }

View file

@ -730,9 +730,9 @@ public:
/* Called for items that really have to be split */ /* Called for items that really have to be split */
void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields, void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
Item **ref, bool skip_registered); Item **ref, bool skip_registered);
virtual bool get_date(TIME *ltime,uint fuzzydate); virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
virtual bool get_time(TIME *ltime); virtual bool get_time(MYSQL_TIME *ltime);
virtual bool get_date_result(TIME *ltime,uint fuzzydate) virtual bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
{ return get_date(ltime,fuzzydate); } { return get_date(ltime,fuzzydate); }
/* /*
The method allows to determine nullness of a complex expression The method allows to determine nullness of a complex expression
@ -1371,9 +1371,9 @@ public:
} }
Field *get_tmp_table_field() { return result_field; } Field *get_tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) { return result_field; } Field *tmp_table_field(TABLE *t_arg) { return result_field; }
bool get_date(TIME *ltime,uint fuzzydate); bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_date_result(TIME *ltime,uint fuzzydate); bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime); bool get_time(MYSQL_TIME *ltime);
bool is_null() { return field->is_null(); } bool is_null() { return field->is_null(); }
void update_null_value(); void update_null_value();
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
@ -1497,7 +1497,7 @@ public:
*/ */
CHARSET_INFO *final_character_set_of_str_value; CHARSET_INFO *final_character_set_of_str_value;
} cs_info; } cs_info;
TIME time; MYSQL_TIME time;
} value; } value;
/* Cached values for virtual methods to save us one switch. */ /* Cached values for virtual methods to save us one switch. */
@ -1529,8 +1529,8 @@ public:
longlong val_int(); longlong val_int();
my_decimal *val_decimal(my_decimal*); my_decimal *val_decimal(my_decimal*);
String *val_str(String*); String *val_str(String*);
bool get_time(TIME *tm); bool get_time(MYSQL_TIME *tm);
bool get_date(TIME *tm, uint fuzzydate); bool get_date(MYSQL_TIME *tm, uint fuzzydate);
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
void set_null(); void set_null();
@ -1539,7 +1539,7 @@ public:
void set_decimal(const char *str, ulong length); void set_decimal(const char *str, ulong length);
bool set_str(const char *str, ulong length); bool set_str(const char *str, ulong length);
bool set_longdata(const char *str, ulong length); bool set_longdata(const char *str, ulong length);
void set_time(TIME *tm, timestamp_type type, uint32 max_length_arg); void set_time(MYSQL_TIME *tm, timestamp_type type, uint32 max_length_arg);
bool set_from_user_var(THD *thd, const user_var_entry *entry); bool set_from_user_var(THD *thd, const user_var_entry *entry);
void reset(); void reset();
/* /*
@ -1978,7 +1978,7 @@ public:
bool val_bool(); bool val_bool();
String *val_str(String* tmp); String *val_str(String* tmp);
bool is_null(); bool is_null();
bool get_date(TIME *ltime,uint fuzzydate); bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
double val_result(); double val_result();
longlong val_int_result(); longlong val_int_result();
String *str_result(String* tmp); String *str_result(String* tmp);
@ -2055,7 +2055,7 @@ public:
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool val_bool(); bool val_bool();
bool is_null(); bool is_null();
bool get_date(TIME *ltime,uint fuzzydate); bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
virtual Ref_Type ref_type() { return DIRECT_REF; } virtual Ref_Type ref_type() { return DIRECT_REF; }
}; };
@ -2160,7 +2160,7 @@ public:
String* val_str(String* s); String* val_str(String* s);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool val_bool(); bool val_bool();
bool get_date(TIME *ltime, uint fuzzydate); bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
void print(String *str); void print(String *str);
/* /*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE

View file

@ -353,6 +353,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
{ {
TABLE *table= field->table; TABLE *table= field->table;
ulong orig_sql_mode= thd->variables.sql_mode; ulong orig_sql_mode= thd->variables.sql_mode;
enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
my_bitmap_map *old_write_map; my_bitmap_map *old_write_map;
my_bitmap_map *old_read_map; my_bitmap_map *old_read_map;
@ -366,6 +367,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
} }
/* For comparison purposes allow invalid dates like 2000-01-32 */ /* For comparison purposes allow invalid dates like 2000-01-32 */
thd->variables.sql_mode|= MODE_INVALID_DATES; thd->variables.sql_mode|= MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (!(*item)->save_in_field(field, 1) && !((*item)->null_value)) if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
{ {
Item *tmp= new Item_int_with_ref(field->val_int(), *item, Item *tmp= new Item_int_with_ref(field->val_int(), *item,
@ -375,6 +377,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
result= 1; // Item was replaced result= 1; // Item was replaced
} }
thd->variables.sql_mode= orig_sql_mode; thd->variables.sql_mode= orig_sql_mode;
thd->count_cuted_fields= orig_count_cuted_fields;
if (table) if (table)
{ {
dbug_tmp_restore_column_map(table->write_set, old_write_map); dbug_tmp_restore_column_map(table->write_set, old_write_map);
@ -2484,7 +2487,7 @@ byte *in_row::get_value(Item *item)
void in_row::set(uint pos, Item *item) void in_row::set(uint pos, Item *item)
{ {
DBUG_ENTER("in_row::set"); DBUG_ENTER("in_row::set");
DBUG_PRINT("enter", ("pos %u item 0x%lx", pos, (ulong) item)); DBUG_PRINT("enter", ("pos: %u item: 0x%lx", pos, (ulong) item));
((cmp_item_row*) base)[pos].store_value_by_template(&tmp, item); ((cmp_item_row*) base)[pos].store_value_by_template(&tmp, item);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View file

@ -147,11 +147,11 @@ public:
void count_only_length(); void count_only_length();
void count_real_length(); void count_real_length();
void count_decimal_length(); void count_decimal_length();
inline bool get_arg0_date(TIME *ltime, uint fuzzy_date) inline bool get_arg0_date(MYSQL_TIME *ltime, uint fuzzy_date)
{ {
return (null_value=args[0]->get_date(ltime, fuzzy_date)); return (null_value=args[0]->get_date(ltime, fuzzy_date));
} }
inline bool get_arg0_time(TIME *ltime) inline bool get_arg0_time(MYSQL_TIME *ltime)
{ {
return (null_value=args[0]->get_time(ltime)); return (null_value=args[0]->get_time(ltime));
} }
@ -1443,7 +1443,7 @@ private:
bool execute(); bool execute();
bool execute_impl(THD *thd); bool execute_impl(THD *thd);
bool init_result_field(THD *thd); bool init_result_field(THD *thd);
public: public:
Item_func_sp(Name_resolution_context *context_arg, sp_name *name); Item_func_sp(Name_resolution_context *context_arg, sp_name *name);
@ -1454,6 +1454,8 @@ public:
virtual ~Item_func_sp() virtual ~Item_func_sp()
{} {}
table_map used_tables() const { return RAND_TABLE_BIT; }
void cleanup(); void cleanup();
const char *func_name() const; const char *func_name() const;

View file

@ -46,7 +46,7 @@
the microseconds twice. the microseconds twice.
*/ */
static bool make_datetime(date_time_format_types format, TIME *ltime, static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime,
String *str) String *str)
{ {
char *buff; char *buff;
@ -95,7 +95,7 @@ static bool make_datetime(date_time_format_types format, TIME *ltime,
/* /*
Wrapper over make_datetime() with validation of the input TIME value Wrapper over make_datetime() with validation of the input MYSQL_TIME value
NOTE NOTE
see make_datetime() for more information see make_datetime() for more information
@ -105,7 +105,7 @@ static bool make_datetime(date_time_format_types format, TIME *ltime,
0 otherwise 0 otherwise
*/ */
static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime, static bool make_datetime_with_warn(date_time_format_types format, MYSQL_TIME *ltime,
String *str) String *str)
{ {
int warning= 0; int warning= 0;
@ -117,14 +117,15 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime,
if (!warning) if (!warning)
return 0; return 0;
make_truncated_value_warning(current_thd, str->ptr(), str->length(), make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
str->ptr(), str->length(),
MYSQL_TIMESTAMP_TIME, NullS); MYSQL_TIMESTAMP_TIME, NullS);
return make_datetime(format, ltime, str); return make_datetime(format, ltime, str);
} }
/* /*
Wrapper over make_time() with validation of the input TIME value Wrapper over make_time() with validation of the input MYSQL_TIME value
NOTE NOTE
see make_time() for more info see make_time() for more info
@ -135,7 +136,7 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime,
*/ */
static bool make_time_with_warn(const DATE_TIME_FORMAT *format, static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
TIME *l_time, String *str) MYSQL_TIME *l_time, String *str)
{ {
int warning= 0; int warning= 0;
make_time(format, l_time, str); make_time(format, l_time, str);
@ -143,7 +144,8 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
return 1; return 1;
if (warning) if (warning)
{ {
make_truncated_value_warning(current_thd, str->ptr(), str->length(), make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
str->ptr(), str->length(),
MYSQL_TIMESTAMP_TIME, NullS); MYSQL_TIMESTAMP_TIME, NullS);
make_time(format, l_time, str); make_time(format, l_time, str);
} }
@ -153,16 +155,16 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
/* /*
Convert seconds to TIME value with overflow checking Convert seconds to MYSQL_TIME value with overflow checking
SYNOPSIS: SYNOPSIS:
sec_to_time() sec_to_time()
seconds number of seconds seconds number of seconds
unsigned_flag 1, if 'seconds' is unsigned, 0, otherwise unsigned_flag 1, if 'seconds' is unsigned, 0, otherwise
ltime output TIME value ltime output MYSQL_TIME value
DESCRIPTION DESCRIPTION
If the 'seconds' argument is inside TIME data range, convert it to a If the 'seconds' argument is inside MYSQL_TIME data range, convert it to a
corresponding value. corresponding value.
Otherwise, truncate the resulting value to the nearest endpoint, and Otherwise, truncate the resulting value to the nearest endpoint, and
produce a warning message. produce a warning message.
@ -172,7 +174,7 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
0 otherwise 0 otherwise
*/ */
static bool sec_to_time(longlong seconds, bool unsigned_flag, TIME *ltime) static bool sec_to_time(longlong seconds, bool unsigned_flag, MYSQL_TIME *ltime)
{ {
uint sec; uint sec;
@ -205,7 +207,8 @@ overflow:
char buf[22]; char buf[22];
int len= (int)(longlong10_to_str(seconds, buf, unsigned_flag ? 10 : -10) int len= (int)(longlong10_to_str(seconds, buf, unsigned_flag ? 10 : -10)
- buf); - buf);
make_truncated_value_warning(current_thd, buf, len, MYSQL_TIMESTAMP_TIME, make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buf, len, MYSQL_TIMESTAMP_TIME,
NullS); NullS);
return 1; return 1;
@ -224,7 +227,7 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0,
{(char *)"%H:%i:%S", 8}}; {(char *)"%H:%i:%S", 8}};
/* /*
Extract datetime value to TIME struct from string value Extract datetime value to MYSQL_TIME struct from string value
according to format string. according to format string.
SYNOPSIS SYNOPSIS
@ -257,7 +260,7 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0,
*/ */
static bool extract_date_time(DATE_TIME_FORMAT *format, static bool extract_date_time(DATE_TIME_FORMAT *format,
const char *val, uint length, TIME *l_time, const char *val, uint length, MYSQL_TIME *l_time,
timestamp_type cached_timestamp_type, timestamp_type cached_timestamp_type,
const char **sub_pattern_end, const char **sub_pattern_end,
const char *date_time_type) const char *date_time_type)
@ -305,13 +308,15 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
case 'Y': case 'Y':
tmp= (char*) val + min(4, val_len); tmp= (char*) val + min(4, val_len);
l_time->year= (int) my_strtoll10(val, &tmp, &error); l_time->year= (int) my_strtoll10(val, &tmp, &error);
if ((int) (tmp-val) <= 2)
l_time->year= year_2000_handling(l_time->year);
val= tmp; val= tmp;
break; break;
case 'y': case 'y':
tmp= (char*) val + min(2, val_len); tmp= (char*) val + min(2, val_len);
l_time->year= (int) my_strtoll10(val, &tmp, &error); l_time->year= (int) my_strtoll10(val, &tmp, &error);
val= tmp; val= tmp;
l_time->year+= (l_time->year < YY_PART_YEAR ? 2000 : 1900); l_time->year= year_2000_handling(l_time->year);
break; break;
/* Month */ /* Month */
@ -514,7 +519,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
if (yearday > 0) if (yearday > 0)
{ {
uint days= calc_daynr(l_time->year,1,1) + yearday - 1; uint days;
days= calc_daynr(l_time->year,1,1) + yearday - 1;
if (days <= 0 || days > MAX_DAY_NUMBER) if (days <= 0 || days > MAX_DAY_NUMBER)
goto err; goto err;
get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day); get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day);
@ -576,7 +582,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
{ {
if (!my_isspace(&my_charset_latin1,*val)) if (!my_isspace(&my_charset_latin1,*val))
{ {
make_truncated_value_warning(current_thd, val_begin, length, make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
val_begin, length,
cached_timestamp_type, NullS); cached_timestamp_type, NullS);
break; break;
} }
@ -600,7 +607,7 @@ err:
Create a formated date/time value in a string Create a formated date/time value in a string
*/ */
bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
timestamp_type type, String *str) timestamp_type type, String *str)
{ {
char intbuff[15]; char intbuff[15];
@ -921,7 +928,7 @@ longlong Item_func_period_diff::val_int()
longlong Item_func_to_days::val_int() longlong Item_func_to_days::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0; return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day); return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day);
@ -958,7 +965,7 @@ enum_monotonicity_info Item_func_to_days::get_monotonicity_info() const
longlong Item_func_dayofyear::val_int() longlong Item_func_dayofyear::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime,TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime,TIME_NO_ZERO_DATE))
return 0; return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day) - return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day) -
@ -968,7 +975,7 @@ longlong Item_func_dayofyear::val_int()
longlong Item_func_dayofmonth::val_int() longlong Item_func_dayofmonth::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE); (void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.day; return (longlong) ltime.day;
} }
@ -976,7 +983,7 @@ longlong Item_func_dayofmonth::val_int()
longlong Item_func_month::val_int() longlong Item_func_month::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE); (void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.month; return (longlong) ltime.month;
} }
@ -1006,7 +1013,7 @@ String* Item_func_monthname::val_str(String* str)
longlong Item_func_quarter::val_int() longlong Item_func_quarter::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_FUZZY_DATE)) if (get_arg0_date(&ltime, TIME_FUZZY_DATE))
return 0; return 0;
return (longlong) ((ltime.month+2)/3); return (longlong) ((ltime.month+2)/3);
@ -1015,7 +1022,7 @@ longlong Item_func_quarter::val_int()
longlong Item_func_hour::val_int() longlong Item_func_hour::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
(void) get_arg0_time(&ltime); (void) get_arg0_time(&ltime);
return ltime.hour; return ltime.hour;
} }
@ -1023,7 +1030,7 @@ longlong Item_func_hour::val_int()
longlong Item_func_minute::val_int() longlong Item_func_minute::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
(void) get_arg0_time(&ltime); (void) get_arg0_time(&ltime);
return ltime.minute; return ltime.minute;
} }
@ -1032,7 +1039,7 @@ longlong Item_func_minute::val_int()
longlong Item_func_second::val_int() longlong Item_func_second::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
(void) get_arg0_time(&ltime); (void) get_arg0_time(&ltime);
return ltime.second; return ltime.second;
} }
@ -1079,7 +1086,7 @@ longlong Item_func_week::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
uint year; uint year;
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0; return 0;
return (longlong) calc_week(&ltime, return (longlong) calc_week(&ltime,
@ -1092,7 +1099,7 @@ longlong Item_func_yearweek::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
uint year,week; uint year,week;
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0; return 0;
week= calc_week(&ltime, week= calc_week(&ltime,
@ -1105,7 +1112,7 @@ longlong Item_func_yearweek::val_int()
longlong Item_func_weekday::val_int() longlong Item_func_weekday::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0; return 0;
@ -1135,7 +1142,7 @@ String* Item_func_dayname::val_str(String* str)
longlong Item_func_year::val_int() longlong Item_func_year::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE); (void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.year; return (longlong) ltime.year;
} }
@ -1166,7 +1173,7 @@ enum_monotonicity_info Item_func_year::get_monotonicity_info() const
longlong Item_func_unix_timestamp::val_int() longlong Item_func_unix_timestamp::val_int()
{ {
TIME ltime; MYSQL_TIME ltime;
my_bool not_used; my_bool not_used;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
@ -1197,7 +1204,7 @@ longlong Item_func_unix_timestamp::val_int()
longlong Item_func_time_to_sec::val_int() longlong Item_func_time_to_sec::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
longlong seconds; longlong seconds;
(void) get_arg0_time(&ltime); (void) get_arg0_time(&ltime);
seconds=ltime.hour*3600L+ltime.minute*60+ltime.second; seconds=ltime.hour*3600L+ltime.minute*60+ltime.second;
@ -1369,7 +1376,7 @@ bool get_interval_value(Item *args,interval_type int_type,
String *Item_date::val_str(String *str) String *Item_date::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
return (String *) 0; return (String *) 0;
if (str->alloc(11)) if (str->alloc(11))
@ -1385,19 +1392,19 @@ String *Item_date::val_str(String *str)
longlong Item_date::val_int() longlong Item_date::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
return 0; return 0;
return (longlong) (ltime.year*10000L+ltime.month*100+ltime.day); return (longlong) (ltime.year*10000L+ltime.month*100+ltime.day);
} }
bool Item_func_from_days::get_date(TIME *ltime, uint fuzzy_date) bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{ {
longlong value=args[0]->val_int(); longlong value=args[0]->val_int();
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
return 1; return 1;
bzero(ltime, sizeof(TIME)); bzero(ltime, sizeof(MYSQL_TIME));
get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day); get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day);
ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->time_type= MYSQL_TIMESTAMP_DATE;
return 0; return 0;
@ -1431,10 +1438,10 @@ String *Item_func_curdate::val_str(String *str)
} }
/* /*
Converts current time in my_time_t to TIME represenatation for local Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole CURDATE function. time zone. Defines time zone (local) used for whole CURDATE function.
*/ */
void Item_func_curdate_local::store_now_in_TIME(TIME *now_time) void Item_func_curdate_local::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
THD *thd= current_thd; THD *thd= current_thd;
thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->variables.time_zone->gmt_sec_to_TIME(now_time,
@ -1444,10 +1451,10 @@ void Item_func_curdate_local::store_now_in_TIME(TIME *now_time)
/* /*
Converts current time in my_time_t to TIME represenatation for UTC Converts current time in my_time_t to MYSQL_TIME represenatation for UTC
time zone. Defines time zone (UTC) used for whole UTC_DATE function. time zone. Defines time zone (UTC) used for whole UTC_DATE function.
*/ */
void Item_func_curdate_utc::store_now_in_TIME(TIME *now_time) void Item_func_curdate_utc::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
my_tz_UTC->gmt_sec_to_TIME(now_time, my_tz_UTC->gmt_sec_to_TIME(now_time,
(my_time_t)(current_thd->query_start())); (my_time_t)(current_thd->query_start()));
@ -1458,7 +1465,7 @@ void Item_func_curdate_utc::store_now_in_TIME(TIME *now_time)
} }
bool Item_func_curdate::get_date(TIME *res, bool Item_func_curdate::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused))) uint fuzzy_date __attribute__((unused)))
{ {
*res=ltime; *res=ltime;
@ -1476,7 +1483,7 @@ String *Item_func_curtime::val_str(String *str)
void Item_func_curtime::fix_length_and_dec() void Item_func_curtime::fix_length_and_dec()
{ {
TIME ltime; MYSQL_TIME ltime;
decimals= DATETIME_DEC; decimals= DATETIME_DEC;
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
@ -1488,10 +1495,10 @@ void Item_func_curtime::fix_length_and_dec()
/* /*
Converts current time in my_time_t to TIME represenatation for local Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole CURTIME function. time zone. Defines time zone (local) used for whole CURTIME function.
*/ */
void Item_func_curtime_local::store_now_in_TIME(TIME *now_time) void Item_func_curtime_local::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
THD *thd= current_thd; THD *thd= current_thd;
thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->variables.time_zone->gmt_sec_to_TIME(now_time,
@ -1501,10 +1508,10 @@ void Item_func_curtime_local::store_now_in_TIME(TIME *now_time)
/* /*
Converts current time in my_time_t to TIME represenatation for UTC Converts current time in my_time_t to MYSQL_TIME represenatation for UTC
time zone. Defines time zone (UTC) used for whole UTC_TIME function. time zone. Defines time zone (UTC) used for whole UTC_TIME function.
*/ */
void Item_func_curtime_utc::store_now_in_TIME(TIME *now_time) void Item_func_curtime_utc::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
my_tz_UTC->gmt_sec_to_TIME(now_time, my_tz_UTC->gmt_sec_to_TIME(now_time,
(my_time_t)(current_thd->query_start())); (my_time_t)(current_thd->query_start()));
@ -1537,10 +1544,10 @@ void Item_func_now::fix_length_and_dec()
/* /*
Converts current time in my_time_t to TIME represenatation for local Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole NOW function. time zone. Defines time zone (local) used for whole NOW function.
*/ */
void Item_func_now_local::store_now_in_TIME(TIME *now_time) void Item_func_now_local::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
THD *thd= current_thd; THD *thd= current_thd;
thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->variables.time_zone->gmt_sec_to_TIME(now_time,
@ -1550,10 +1557,10 @@ void Item_func_now_local::store_now_in_TIME(TIME *now_time)
/* /*
Converts current time in my_time_t to TIME represenatation for UTC Converts current time in my_time_t to MYSQL_TIME represenatation for UTC
time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function. time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function.
*/ */
void Item_func_now_utc::store_now_in_TIME(TIME *now_time) void Item_func_now_utc::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
my_tz_UTC->gmt_sec_to_TIME(now_time, my_tz_UTC->gmt_sec_to_TIME(now_time,
(my_time_t)(current_thd->query_start())); (my_time_t)(current_thd->query_start()));
@ -1564,7 +1571,7 @@ void Item_func_now_utc::store_now_in_TIME(TIME *now_time)
} }
bool Item_func_now::get_date(TIME *res, bool Item_func_now::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused))) uint fuzzy_date __attribute__((unused)))
{ {
*res= ltime; *res= ltime;
@ -1581,10 +1588,10 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions)
/* /*
Converts current time in my_time_t to TIME represenatation for local Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole SYSDATE function. time zone. Defines time zone (local) used for whole SYSDATE function.
*/ */
void Item_func_sysdate_local::store_now_in_TIME(TIME *now_time) void Item_func_sysdate_local::store_now_in_TIME(MYSQL_TIME *now_time)
{ {
THD *thd= current_thd; THD *thd= current_thd;
thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) time(NULL)); thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) time(NULL));
@ -1626,7 +1633,7 @@ void Item_func_sysdate_local::fix_length_and_dec()
} }
bool Item_func_sysdate_local::get_date(TIME *res, bool Item_func_sysdate_local::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused))) uint fuzzy_date __attribute__((unused)))
{ {
store_now_in_TIME(&ltime); store_now_in_TIME(&ltime);
@ -1647,7 +1654,7 @@ int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions)
String *Item_func_sec_to_time::val_str(String *str) String *Item_func_sec_to_time::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
longlong arg_val= args[0]->val_int(); longlong arg_val= args[0]->val_int();
if ((null_value=args[0]->null_value) || str->alloc(19)) if ((null_value=args[0]->null_value) || str->alloc(19))
@ -1666,7 +1673,7 @@ String *Item_func_sec_to_time::val_str(String *str)
longlong Item_func_sec_to_time::val_int() longlong Item_func_sec_to_time::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
longlong arg_val= args[0]->val_int(); longlong arg_val= args[0]->val_int();
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
@ -1808,7 +1815,7 @@ uint Item_func_date_format::format_length(const String *format)
String *Item_func_date_format::val_str(String *str) String *Item_func_date_format::val_str(String *str)
{ {
String *format; String *format;
TIME l_time; MYSQL_TIME l_time;
uint size; uint size;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
@ -1871,7 +1878,7 @@ void Item_func_from_unixtime::fix_length_and_dec()
String *Item_func_from_unixtime::val_str(String *str) String *Item_func_from_unixtime::val_str(String *str)
{ {
TIME time_tmp; MYSQL_TIME time_tmp;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
@ -1891,7 +1898,7 @@ String *Item_func_from_unixtime::val_str(String *str)
longlong Item_func_from_unixtime::val_int() longlong Item_func_from_unixtime::val_int()
{ {
TIME time_tmp; MYSQL_TIME time_tmp;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
@ -1901,7 +1908,7 @@ longlong Item_func_from_unixtime::val_int()
return (longlong) TIME_to_ulonglong_datetime(&time_tmp); return (longlong) TIME_to_ulonglong_datetime(&time_tmp);
} }
bool Item_func_from_unixtime::get_date(TIME *ltime, bool Item_func_from_unixtime::get_date(MYSQL_TIME *ltime,
uint fuzzy_date __attribute__((unused))) uint fuzzy_date __attribute__((unused)))
{ {
ulonglong tmp= (ulonglong)(args[0]->val_int()); ulonglong tmp= (ulonglong)(args[0]->val_int());
@ -1929,7 +1936,7 @@ void Item_func_convert_tz::fix_length_and_dec()
String *Item_func_convert_tz::val_str(String *str) String *Item_func_convert_tz::val_str(String *str)
{ {
TIME time_tmp; MYSQL_TIME time_tmp;
if (get_date(&time_tmp, 0)) if (get_date(&time_tmp, 0))
return 0; return 0;
@ -1947,7 +1954,7 @@ String *Item_func_convert_tz::val_str(String *str)
longlong Item_func_convert_tz::val_int() longlong Item_func_convert_tz::val_int()
{ {
TIME time_tmp; MYSQL_TIME time_tmp;
if (get_date(&time_tmp, 0)) if (get_date(&time_tmp, 0))
return 0; return 0;
@ -1956,7 +1963,7 @@ longlong Item_func_convert_tz::val_int()
} }
bool Item_func_convert_tz::get_date(TIME *ltime, bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime,
uint fuzzy_date __attribute__((unused))) uint fuzzy_date __attribute__((unused)))
{ {
my_time_t my_time_tmp; my_time_t my_time_tmp;
@ -2018,7 +2025,7 @@ void Item_date_add_interval::fix_length_and_dec()
- If first arg is a MYSQL_TYPE_DATE and the interval type uses hours, - If first arg is a MYSQL_TYPE_DATE and the interval type uses hours,
minutes or seconds then type is MYSQL_TYPE_DATETIME. minutes or seconds then type is MYSQL_TYPE_DATETIME.
- Otherwise the result is MYSQL_TYPE_STRING - Otherwise the result is MYSQL_TYPE_STRING
(This is because you can't know if the string contains a DATE, TIME or (This is because you can't know if the string contains a DATE, MYSQL_TIME or
DATETIME argument) DATETIME argument)
*/ */
cached_field_type= MYSQL_TYPE_STRING; cached_field_type= MYSQL_TYPE_STRING;
@ -2038,7 +2045,7 @@ void Item_date_add_interval::fix_length_and_dec()
/* Here arg[1] is a Item_interval object */ /* Here arg[1] is a Item_interval object */
bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date) bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{ {
INTERVAL interval; INTERVAL interval;
@ -2048,8 +2055,6 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
if (date_sub_interval) if (date_sub_interval)
interval.neg = !interval.neg; interval.neg = !interval.neg;
if (ltime->year < YY_MAGIC_BELOW)
return (null_value=1);
return (null_value= date_add_interval(ltime, int_type, interval)); return (null_value= date_add_interval(ltime, int_type, interval));
} }
@ -2058,7 +2063,7 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
String *Item_date_add_interval::val_str(String *str) String *Item_date_add_interval::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
enum date_time_format_types format; enum date_time_format_types format;
if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE)) if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
@ -2082,7 +2087,7 @@ String *Item_date_add_interval::val_str(String *str)
longlong Item_date_add_interval::val_int() longlong Item_date_add_interval::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
longlong date; longlong date;
if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE)) if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
return (longlong) 0; return (longlong) 0;
@ -2172,7 +2177,7 @@ void Item_extract::fix_length_and_dec()
longlong Item_extract::val_int() longlong Item_extract::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
uint year; uint year;
ulong week_format; ulong week_format;
long neg; long neg;
@ -2425,7 +2430,7 @@ void Item_char_typecast::fix_length_and_dec()
String *Item_datetime_typecast::val_str(String *str) String *Item_datetime_typecast::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
!make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME,
&ltime, str)) &ltime, str))
@ -2439,7 +2444,7 @@ String *Item_datetime_typecast::val_str(String *str)
longlong Item_datetime_typecast::val_int() longlong Item_datetime_typecast::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime,1)) if (get_arg0_date(&ltime,1))
{ {
null_value= 1; null_value= 1;
@ -2450,7 +2455,7 @@ longlong Item_datetime_typecast::val_int()
} }
bool Item_time_typecast::get_time(TIME *ltime) bool Item_time_typecast::get_time(MYSQL_TIME *ltime)
{ {
bool res= get_arg0_time(ltime); bool res= get_arg0_time(ltime);
/* /*
@ -2466,7 +2471,7 @@ bool Item_time_typecast::get_time(TIME *ltime)
longlong Item_time_typecast::val_int() longlong Item_time_typecast::val_int()
{ {
TIME ltime; MYSQL_TIME ltime;
if (get_time(&ltime)) if (get_time(&ltime))
{ {
null_value= 1; null_value= 1;
@ -2478,7 +2483,7 @@ longlong Item_time_typecast::val_int()
String *Item_time_typecast::val_str(String *str) String *Item_time_typecast::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_time(&ltime) && if (!get_arg0_time(&ltime) &&
!make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY, !make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY,
@ -2490,7 +2495,7 @@ String *Item_time_typecast::val_str(String *str)
} }
bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date) bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{ {
bool res= get_arg0_date(ltime, TIME_FUZZY_DATE); bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
@ -2502,7 +2507,7 @@ bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date)
String *Item_date_typecast::val_str(String *str) String *Item_date_typecast::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && !str->alloc(11)) if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && !str->alloc(11))
{ {
@ -2517,7 +2522,7 @@ String *Item_date_typecast::val_str(String *str)
longlong Item_date_typecast::val_int() longlong Item_date_typecast::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (args[0]->get_date(&ltime, TIME_FUZZY_DATE)) if (args[0]->get_date(&ltime, TIME_FUZZY_DATE))
{ {
null_value= 1; null_value= 1;
@ -2529,21 +2534,29 @@ longlong Item_date_typecast::val_int()
/* /*
MAKEDATE(a,b) is a date function that creates a date value MAKEDATE(a,b) is a date function that creates a date value
from a year and day value. from a year and day value.
NOTES:
As arguments are integers, we can't know if the year is a 2 digit or 4 digit year.
In this case we treat all years < 100 as 2 digit years. Ie, this is not safe
for dates between 0000-01-01 and 0099-12-31
*/ */
String *Item_func_makedate::val_str(String *str) String *Item_func_makedate::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME l_time; MYSQL_TIME l_time;
long daynr= (long) args[1]->val_int(); long daynr= (long) args[1]->val_int();
long yearnr= (long) args[0]->val_int(); long year= (long) args[0]->val_int();
long days; long days;
if (args[0]->null_value || args[1]->null_value || if (args[0]->null_value || args[1]->null_value ||
yearnr < 0 || daynr <= 0) year < 0 || daynr <= 0)
goto err; goto err;
days= calc_daynr(yearnr,1,1) + daynr - 1; if (year < 100)
year= year_2000_handling(year);
days= calc_daynr(year,1,1) + daynr - 1;
/* Day number from year 0 to 9999-12-31 */ /* Day number from year 0 to 9999-12-31 */
if (days >= 0 && days <= MAX_DAY_NUMBER) if (days >= 0 && days <= MAX_DAY_NUMBER)
{ {
@ -2561,19 +2574,32 @@ err:
} }
/*
MAKEDATE(a,b) is a date function that creates a date value
from a year and day value.
NOTES:
As arguments are integers, we can't know if the year is a 2 digit or 4 digit year.
In this case we treat all years < 100 as 2 digit years. Ie, this is not safe
for dates between 0000-01-01 and 0099-12-31
*/
longlong Item_func_makedate::val_int() longlong Item_func_makedate::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME l_time; MYSQL_TIME l_time;
long daynr= (long) args[1]->val_int(); long daynr= (long) args[1]->val_int();
long yearnr= (long) args[0]->val_int(); long year= (long) args[0]->val_int();
long days; long days;
if (args[0]->null_value || args[1]->null_value || if (args[0]->null_value || args[1]->null_value ||
yearnr < 0 || daynr <= 0) year < 0 || daynr <= 0)
goto err; goto err;
days= calc_daynr(yearnr,1,1) + daynr - 1; if (year < 100)
year= year_2000_handling(year);
days= calc_daynr(year,1,1) + daynr - 1;
/* Day number from year 0 to 9999-12-31 */ /* Day number from year 0 to 9999-12-31 */
if (days >= 0 && days < MAX_DAY_NUMBER) if (days >= 0 && days < MAX_DAY_NUMBER)
{ {
@ -2628,7 +2654,7 @@ void Item_func_add_time::fix_length_and_dec()
String *Item_func_add_time::val_str(String *str) String *Item_func_add_time::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME l_time1, l_time2, l_time3; MYSQL_TIME l_time1, l_time2, l_time3;
bool is_time= 0; bool is_time= 0;
long days, microseconds; long days, microseconds;
longlong seconds; longlong seconds;
@ -2730,7 +2756,7 @@ String *Item_func_timediff::val_str(String *str)
longlong seconds; longlong seconds;
long microseconds; long microseconds;
int l_sign= 1; int l_sign= 1;
TIME l_time1 ,l_time2, l_time3; MYSQL_TIME l_time1 ,l_time2, l_time3;
null_value= 0; null_value= 0;
if (args[0]->get_time(&l_time1) || if (args[0]->get_time(&l_time1) ||
@ -2775,7 +2801,7 @@ null_date:
String *Item_func_maketime::val_str(String *str) String *Item_func_maketime::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
bool overflow= 0; bool overflow= 0;
longlong hour= args[0]->val_int(); longlong hour= args[0]->val_int();
@ -2819,7 +2845,8 @@ String *Item_func_maketime::val_str(String *str)
char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10); char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
int len = (int)(ptr - buf) + int len = (int)(ptr - buf) +
my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second)); my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second));
make_truncated_value_warning(current_thd, buf, len, MYSQL_TIMESTAMP_TIME, make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buf, len, MYSQL_TIMESTAMP_TIME,
NullS); NullS);
} }
@ -2843,7 +2870,7 @@ String *Item_func_maketime::val_str(String *str)
longlong Item_func_microsecond::val_int() longlong Item_func_microsecond::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_time(&ltime)) if (!get_arg0_time(&ltime))
return ltime.second_part; return ltime.second_part;
return 0; return 0;
@ -2852,7 +2879,7 @@ longlong Item_func_microsecond::val_int()
longlong Item_func_timestamp_diff::val_int() longlong Item_func_timestamp_diff::val_int()
{ {
TIME ltime1, ltime2; MYSQL_TIME ltime1, ltime2;
longlong seconds; longlong seconds;
long microseconds; long microseconds;
long months= 0; long months= 0;
@ -3158,7 +3185,7 @@ void Item_func_str_to_date::fix_length_and_dec()
} }
} }
bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date) bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{ {
DATE_TIME_FORMAT date_time_format; DATE_TIME_FORMAT date_time_format;
char val_buff[64], format_buff[64]; char val_buff[64], format_buff[64];
@ -3199,7 +3226,7 @@ null_date:
String *Item_func_str_to_date::val_str(String *str) String *Item_func_str_to_date::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; MYSQL_TIME ltime;
if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE)) if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE))
return 0; return 0;
@ -3212,7 +3239,7 @@ String *Item_func_str_to_date::val_str(String *str)
} }
bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date) bool Item_func_last_day::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{ {
if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) || if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
(ltime->month == 0)) (ltime->month == 0))

View file

@ -449,9 +449,9 @@ public:
/* /*
Abstract method that defines which time zone is used for conversion. Abstract method that defines which time zone is used for conversion.
Converts time current time in my_time_t representation to broken-down Converts time current time in my_time_t representation to broken-down
TIME representation using UTC-SYSTEM or per-thread time zone. MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
*/ */
virtual void store_now_in_TIME(TIME *now_time)=0; virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
bool result_as_longlong() { return TRUE; } bool result_as_longlong() { return TRUE; }
}; };
@ -462,7 +462,7 @@ public:
Item_func_curtime_local() :Item_func_curtime() {} Item_func_curtime_local() :Item_func_curtime() {}
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {} Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
const char *func_name() const { return "curtime"; } const char *func_name() const { return "curtime"; }
virtual void store_now_in_TIME(TIME *now_time); virtual void store_now_in_TIME(MYSQL_TIME *now_time);
}; };
@ -472,7 +472,7 @@ public:
Item_func_curtime_utc() :Item_func_curtime() {} Item_func_curtime_utc() :Item_func_curtime() {}
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {} Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
const char *func_name() const { return "utc_time"; } const char *func_name() const { return "utc_time"; }
virtual void store_now_in_TIME(TIME *now_time); virtual void store_now_in_TIME(MYSQL_TIME *now_time);
}; };
@ -481,14 +481,14 @@ public:
class Item_func_curdate :public Item_date class Item_func_curdate :public Item_date
{ {
longlong value; longlong value;
TIME ltime; MYSQL_TIME ltime;
public: public:
Item_func_curdate() :Item_date() {} Item_func_curdate() :Item_date() {}
longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; } longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
String *val_str(String *str); String *val_str(String *str);
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
virtual void store_now_in_TIME(TIME *now_time)=0; virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
}; };
@ -497,7 +497,7 @@ class Item_func_curdate_local :public Item_func_curdate
public: public:
Item_func_curdate_local() :Item_func_curdate() {} Item_func_curdate_local() :Item_func_curdate() {}
const char *func_name() const { return "curdate"; } const char *func_name() const { return "curdate"; }
void store_now_in_TIME(TIME *now_time); void store_now_in_TIME(MYSQL_TIME *now_time);
}; };
@ -506,7 +506,7 @@ class Item_func_curdate_utc :public Item_func_curdate
public: public:
Item_func_curdate_utc() :Item_func_curdate() {} Item_func_curdate_utc() :Item_func_curdate() {}
const char *func_name() const { return "utc_date"; } const char *func_name() const { return "utc_date"; }
void store_now_in_TIME(TIME *now_time); void store_now_in_TIME(MYSQL_TIME *now_time);
}; };
@ -518,7 +518,7 @@ protected:
longlong value; longlong value;
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
uint buff_length; uint buff_length;
TIME ltime; MYSQL_TIME ltime;
public: public:
Item_func_now() :Item_date_func() {} Item_func_now() :Item_date_func() {}
Item_func_now(Item *a) :Item_date_func(a) {} Item_func_now(Item *a) :Item_date_func(a) {}
@ -527,8 +527,8 @@ public:
int save_in_field(Field *to, bool no_conversions); int save_in_field(Field *to, bool no_conversions);
String *val_str(String *str); String *val_str(String *str);
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
virtual void store_now_in_TIME(TIME *now_time)=0; virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
}; };
@ -538,7 +538,7 @@ public:
Item_func_now_local() :Item_func_now() {} Item_func_now_local() :Item_func_now() {}
Item_func_now_local(Item *a) :Item_func_now(a) {} Item_func_now_local(Item *a) :Item_func_now(a) {}
const char *func_name() const { return "now"; } const char *func_name() const { return "now"; }
virtual void store_now_in_TIME(TIME *now_time); virtual void store_now_in_TIME(MYSQL_TIME *now_time);
virtual enum Functype functype() const { return NOW_FUNC; } virtual enum Functype functype() const { return NOW_FUNC; }
}; };
@ -549,7 +549,7 @@ public:
Item_func_now_utc() :Item_func_now() {} Item_func_now_utc() :Item_func_now() {}
Item_func_now_utc(Item *a) :Item_func_now(a) {} Item_func_now_utc(Item *a) :Item_func_now(a) {}
const char *func_name() const { return "utc_timestamp"; } const char *func_name() const { return "utc_timestamp"; }
virtual void store_now_in_TIME(TIME *now_time); virtual void store_now_in_TIME(MYSQL_TIME *now_time);
}; };
@ -564,13 +564,13 @@ public:
Item_func_sysdate_local(Item *a) :Item_func_now(a) {} Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
bool const_item() const { return 0; } bool const_item() const { return 0; }
const char *func_name() const { return "sysdate"; } const char *func_name() const { return "sysdate"; }
void store_now_in_TIME(TIME *now_time); void store_now_in_TIME(MYSQL_TIME *now_time);
double val_real(); double val_real();
longlong val_int(); longlong val_int();
int save_in_field(Field *to, bool no_conversions); int save_in_field(Field *to, bool no_conversions);
String *val_str(String *str); String *val_str(String *str);
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void update_used_tables() void update_used_tables()
{ {
Item_func_now::update_used_tables(); Item_func_now::update_used_tables();
@ -584,7 +584,7 @@ class Item_func_from_days :public Item_date
public: public:
Item_func_from_days(Item *a) :Item_date(a) {} Item_func_from_days(Item *a) :Item_date(a) {}
const char *func_name() const { return "from_days"; } const char *func_name() const { return "from_days"; }
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool check_partition_func_processor(byte *int_arg) {return FALSE;} bool check_partition_func_processor(byte *int_arg) {return FALSE;}
}; };
@ -616,7 +616,7 @@ class Item_func_from_unixtime :public Item_date_func
String *val_str(String *str); String *val_str(String *str);
const char *func_name() const { return "from_unixtime"; } const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool check_partition_func_processor(byte *int_arg) {return FALSE;} bool check_partition_func_processor(byte *int_arg) {return FALSE;}
}; };
@ -652,7 +652,7 @@ class Item_func_convert_tz :public Item_date_func
String *val_str(String *str); String *val_str(String *str);
const char *func_name() const { return "convert_tz"; } const char *func_name() const { return "convert_tz"; }
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void cleanup(); void cleanup();
}; };
@ -695,7 +695,7 @@ public:
void fix_length_and_dec(); void fix_length_and_dec();
enum_field_types field_type() const { return cached_field_type; } enum_field_types field_type() const { return cached_field_type; }
longlong val_int(); longlong val_int();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void print(String *str); void print(String *str);
bool check_partition_func_processor(byte *int_arg) {return FALSE;} bool check_partition_func_processor(byte *int_arg) {return FALSE;}
@ -783,7 +783,7 @@ public:
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {} Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
const char *func_name() const { return "cast_as_date"; } const char *func_name() const { return "cast_as_date"; }
String *val_str(String *str); String *val_str(String *str);
bool get_date(TIME *ltime, uint fuzzy_date); bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
const char *cast_type() const { return "date"; } const char *cast_type() const { return "date"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
Field *tmp_table_field(TABLE *table) Field *tmp_table_field(TABLE *table)
@ -817,7 +817,7 @@ public:
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {} Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
const char *func_name() const { return "cast_as_time"; } const char *func_name() const { return "cast_as_time"; }
String *val_str(String *str); String *val_str(String *str);
bool get_time(TIME *ltime); bool get_time(MYSQL_TIME *ltime);
const char *cast_type() const { return "time"; } const char *cast_type() const { return "time"; }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
Field *tmp_table_field(TABLE *table) Field *tmp_table_field(TABLE *table)
@ -1020,7 +1020,7 @@ public:
:Item_str_func(a, b) :Item_str_func(a, b)
{} {}
String *val_str(String *str); String *val_str(String *str);
bool get_date(TIME *ltime, uint fuzzy_date); bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
const char *func_name() const { return "str_to_date"; } const char *func_name() const { return "str_to_date"; }
enum_field_types field_type() const { return cached_field_type; } enum_field_types field_type() const { return cached_field_type; }
void fix_length_and_dec(); void fix_length_and_dec();
@ -1037,5 +1037,5 @@ class Item_func_last_day :public Item_date
public: public:
Item_func_last_day(Item *a) :Item_date(a) {} Item_func_last_day(Item *a) :Item_date(a) {}
const char *func_name() const { return "last_day"; } const char *func_name() const { return "last_day"; }
bool get_date(TIME *res, uint fuzzy_date); bool get_date(MYSQL_TIME *res, uint fuzzy_date);
}; };

View file

@ -574,7 +574,7 @@ bool Log_to_csv_event_handler::
lock_time may be truncated without warning here, if greater than lock_time may be truncated without warning here, if greater than
839 hours (~35 days) 839 hours (~35 days)
*/ */
TIME t; MYSQL_TIME t;
t.neg= 0; t.neg= 0;
/* fill in query_time field */ /* fill in query_time field */
@ -1597,8 +1597,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
table. Such cases should be rare (updating a table. Such cases should be rare (updating a
non-transactional table inside a transaction...) non-transactional table inside a transaction...)
*/ */
if (unlikely(thd->options & (OPTION_STATUS_NO_TRANS_UPDATE | if (unlikely(thd->no_trans_update.all || (thd->options & OPTION_KEEP_LOG)))
OPTION_KEEP_LOG)))
{ {
Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE); Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE);
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
@ -1653,8 +1652,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
non-transactional table. Otherwise, truncate the binlog cache starting non-transactional table. Otherwise, truncate the binlog cache starting
from the SAVEPOINT command. from the SAVEPOINT command.
*/ */
if (unlikely(thd->options & if (unlikely(thd->no_trans_update.all || (thd->options & OPTION_KEEP_LOG)))
(OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG)))
{ {
int error= int error=
thd->binlog_query(THD::STMT_QUERY_TYPE, thd->binlog_query(THD::STMT_QUERY_TYPE,

View file

@ -191,7 +191,7 @@ int str2my_decimal(uint mask, const char *from, uint length,
} }
my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec) my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec)
{ {
longlong date; longlong date;
date = (ltime->year*100L + ltime->month)*100L + ltime->day; date = (ltime->year*100L + ltime->month)*100L + ltime->day;

View file

@ -296,7 +296,7 @@ int string2my_decimal(uint mask, const String *str, my_decimal *d)
} }
my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec); my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec);
#endif /*defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) */ #endif /*defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) */

View file

@ -340,9 +340,6 @@ MY_LOCALE *my_locale_by_number(uint number);
/* The following is used to detect a conflict with DISTINCT */ /* The following is used to detect a conflict with DISTINCT */
#define SELECT_ALL (ULL(1) << 24) // SELECT, user, parser #define SELECT_ALL (ULL(1) << 24) // SELECT, user, parser
/* Set if we are updating a non-transaction safe table */
#define OPTION_STATUS_NO_TRANS_UPDATE (ULL(1) << 25) // THD, intern
/* The following can be set when importing tables in a 'wrong order' /* The following can be set when importing tables in a 'wrong order'
to suppress foreign key checks */ to suppress foreign key checks */
#define OPTION_NO_FOREIGN_KEY_CHECKS (ULL(1) << 26) // THD, user, binlog #define OPTION_NO_FOREIGN_KEY_CHECKS (ULL(1) << 26) // THD, user, binlog
@ -838,7 +835,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
char *new_table_name, char *new_table_alias, char *new_table_name, char *new_table_alias,
bool skip_error); bool skip_error);
bool mysql_change_db(THD *thd,const char *name,bool no_access_check); bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
bool force_switch);
void mysql_parse(THD *thd,char *inBuf,uint length); void mysql_parse(THD *thd,char *inBuf,uint length);
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
bool is_update_query(enum enum_sql_command command); bool is_update_query(enum enum_sql_command command);
@ -1118,7 +1116,7 @@ void init_status_vars();
void free_status_vars(); void free_status_vars();
/* information schema */ /* information schema */
extern LEX_STRING information_schema_name; extern LEX_STRING INFORMATION_SCHEMA_NAME;
extern const LEX_STRING partition_keywords[]; extern const LEX_STRING partition_keywords[];
LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str, LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
const char* str, uint length, const char* str, uint length,
@ -1136,8 +1134,10 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond); int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
bool get_schema_tables_result(JOIN *join, bool get_schema_tables_result(JOIN *join,
enum enum_schema_table_state executed_place); enum enum_schema_table_state executed_place);
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
#define is_schema_db(X) \ #define is_schema_db(X) \
!my_strcasecmp(system_charset_info, information_schema_name.str, (X)) !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
/* sql_prepare.cc */ /* sql_prepare.cc */
@ -1842,19 +1842,20 @@ ulong convert_period_to_month(ulong period);
ulong convert_month_to_period(ulong month); ulong convert_month_to_period(ulong month);
void get_date_from_daynr(long daynr,uint *year, uint *month, void get_date_from_daynr(long daynr,uint *year, uint *month,
uint *day); uint *day);
my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *not_exist); my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist);
bool str_to_time_with_warn(const char *str,uint length,TIME *l_time); bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time);
timestamp_type str_to_datetime_with_warn(const char *str, uint length, timestamp_type str_to_datetime_with_warn(const char *str, uint length,
TIME *l_time, uint flags); MYSQL_TIME *l_time, uint flags);
void localtime_to_TIME(TIME *to, struct tm *from); void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
void calc_time_from_sec(TIME *to, long seconds, long microseconds); void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
void make_truncated_value_warning(THD *thd, const char *str_val, void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
const char *str_val,
uint str_length, timestamp_type time_type, uint str_length, timestamp_type time_type,
const char *field_name); const char *field_name);
bool date_add_interval(TIME *ltime, interval_type int_type, INTERVAL interval); bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
longlong *seconds_out, long *microseconds_out); longlong *seconds_out, long *microseconds_out);
extern LEX_STRING interval_type_to_name[]; extern LEX_STRING interval_type_to_name[];
@ -1866,15 +1867,15 @@ extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
DATE_TIME_FORMAT *format); DATE_TIME_FORMAT *format);
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
timestamp_type type); timestamp_type type);
extern bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
timestamp_type type, String *str); timestamp_type type, String *str);
void make_datetime(const DATE_TIME_FORMAT *format, const TIME *l_time, void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str); String *str);
void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time, void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str); String *str);
void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time, void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str); String *str);
int my_time_compare(TIME *a, TIME *b); int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
int test_if_number(char *str,int *res,bool allow_wildcards); int test_if_number(char *str,int *res,bool allow_wildcards);
void change_byte(byte *,uint,char,char); void change_byte(byte *,uint,char,char);
@ -1894,7 +1895,7 @@ double my_double_round(double value, int dec, bool truncate);
int get_quick_record(SQL_SELECT *select); int get_quick_record(SQL_SELECT *select);
int calc_weekday(long daynr,bool sunday_first_day_of_week); int calc_weekday(long daynr,bool sunday_first_day_of_week);
uint calc_week(TIME *l_time, uint week_behaviour, uint *year); uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
void find_date(char *pos,uint *vek,uint flag); void find_date(char *pos,uint *vek,uint flag);
TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end); TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end);
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings); TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);

View file

@ -274,7 +274,11 @@ static TYPELIB tc_heuristic_recover_typelib=
}; };
static const char *thread_handling_names[]= static const char *thread_handling_names[]=
{ "one-thread-per-connection", "no-threads", "pool-of-threads", NullS}; { "one-thread-per-connection", "no-threads",
#if HAVE_POOL_OF_THREADS == 1
"pool-of-threads",
#endif
NullS};
TYPELIB thread_handling_typelib= TYPELIB thread_handling_typelib=
{ {
@ -732,6 +736,8 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
#endif #endif
pthread_handler_t handle_slave(void *arg); pthread_handler_t handle_slave(void *arg);
static ulong find_bit_type(const char *x, TYPELIB *bit_lib); static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
const char *option);
static void clean_up(bool print_message); static void clean_up(bool print_message);
static int test_if_case_insensitive(const char *dir_name); static int test_if_case_insensitive(const char *dir_name);
@ -783,7 +789,6 @@ static void close_connections(void)
DBUG_PRINT("info",("Waiting for select thread")); DBUG_PRINT("info",("Waiting for select thread"));
#ifndef DONT_USE_THR_ALARM #ifndef DONT_USE_THR_ALARM
if (pthread_kill(select_thread, thr_client_alarm))
break; // allready dead break; // allready dead
#endif #endif
set_timespec(abstime, 2); set_timespec(abstime, 2);
@ -7451,11 +7456,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_INIT_RPL_ROLE: case (int) OPT_INIT_RPL_ROLE:
{ {
int role; int role;
if ((role=find_type(argument, &rpl_role_typelib, 2)) <= 0) role= find_type_or_exit(argument, &rpl_role_typelib, opt->name);
{
fprintf(stderr, "Unknown replication role: %s\n", argument);
exit(1);
}
rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE; rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE;
break; break;
} }
@ -7511,17 +7512,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BINLOG_FORMAT: case OPT_BINLOG_FORMAT:
{ {
int id; int id;
if ((id= find_type(argument, &binlog_format_typelib, 2)) <= 0) id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
{
fprintf(stderr,
"Unknown binary log format: '%s' "
"(should be one of '%s', '%s', '%s')\n",
argument,
binlog_format_names[BINLOG_FORMAT_STMT],
binlog_format_names[BINLOG_FORMAT_ROW],
binlog_format_names[BINLOG_FORMAT_MIXED]);
exit(1);
}
global_system_variables.binlog_format= opt_binlog_format_id= id - 1; global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
break; break;
} }
@ -7581,13 +7572,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else else
{ {
log_output_str= argument; log_output_str= argument;
if ((log_output_options= log_output_options=
find_bit_type(argument, &log_output_typelib)) == ~(ulong) 0) find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
{ }
fprintf(stderr, "Unknown option to log-output: %s\n", argument);
exit(1);
}
}
break; break;
} }
#endif #endif
@ -7730,11 +7717,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else else
{ {
int type; int type;
if ((type=find_type(argument, &delay_key_write_typelib, 2)) <= 0) type= find_type_or_exit(argument, &delay_key_write_typelib, opt->name);
{
fprintf(stderr,"Unknown delay_key_write type: %s\n",argument);
exit(1);
}
delay_key_write_options= (uint) type-1; delay_key_write_options= (uint) type-1;
} }
break; break;
@ -7745,11 +7728,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_TX_ISOLATION: case OPT_TX_ISOLATION:
{ {
int type; int type;
if ((type=find_type(argument, &tx_isolation_typelib, 2)) <= 0) type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
{
fprintf(stderr,"Unknown transaction isolation type: %s\n",argument);
exit(1);
}
global_system_variables.tx_isolation= (type-1); global_system_variables.tx_isolation= (type-1);
break; break;
} }
@ -7790,16 +7769,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case OPT_NDB_DISTRIBUTION: case OPT_NDB_DISTRIBUTION:
int id; int id;
if ((id= find_type(argument, &ndb_distribution_typelib, 2)) <= 0) id= find_type_or_exit(argument, &ndb_distribution_typelib, opt->name);
{
fprintf(stderr,
"Unknown ndb distribution type: '%s' "
"(should be '%s' or '%s')\n",
argument,
ndb_distribution_names[ND_KEYHASH],
ndb_distribution_names[ND_LINHASH]);
exit(1);
}
opt_ndb_distribution_id= (enum ndb_distribution)(id-1); opt_ndb_distribution_id= (enum ndb_distribution)(id-1);
break; break;
case OPT_NDB_EXTRA_LOGGING: case OPT_NDB_EXTRA_LOGGING:
@ -7839,12 +7809,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else else
{ {
myisam_recover_options_str=argument; myisam_recover_options_str=argument;
if ((myisam_recover_options= myisam_recover_options=
find_bit_type(argument, &myisam_recover_typelib)) == ~(ulong) 0) find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
{
fprintf(stderr, "Unknown option to myisam-recover: %s\n",argument);
exit(1);
}
} }
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
break; break;
@ -7857,14 +7823,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
myisam_concurrent_insert= 0; /* --skip-concurrent-insert */ myisam_concurrent_insert= 0; /* --skip-concurrent-insert */
break; break;
case OPT_TC_HEURISTIC_RECOVER: case OPT_TC_HEURISTIC_RECOVER:
{ tc_heuristic_recover= find_type_or_exit(argument,
if ((tc_heuristic_recover=find_type(argument, &tc_heuristic_recover_typelib,
&tc_heuristic_recover_typelib, 2)) <=0) opt->name);
{ break;
fprintf(stderr, "Unknown option to tc-heuristic-recover: %s\n",argument);
exit(1);
}
}
case OPT_MYISAM_STATS_METHOD: case OPT_MYISAM_STATS_METHOD:
{ {
ulong method_conv; ulong method_conv;
@ -7872,11 +7834,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
LINT_INIT(method_conv); LINT_INIT(method_conv);
myisam_stats_method_str= argument; myisam_stats_method_str= argument;
if ((method=find_type(argument, &myisam_stats_method_typelib, 2)) <= 0) method= find_type_or_exit(argument, &myisam_stats_method_typelib,
{ opt->name);
fprintf(stderr, "Invalid value of myisam_stats_method: %s.\n", argument);
exit(1);
}
switch (method-1) { switch (method-1) {
case 2: case 2:
method_conv= MI_STATS_METHOD_IGNORE_NULLS; method_conv= MI_STATS_METHOD_IGNORE_NULLS;
@ -7895,12 +7854,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_SQL_MODE: case OPT_SQL_MODE:
{ {
sql_mode_str= argument; sql_mode_str= argument;
if ((global_system_variables.sql_mode= global_system_variables.sql_mode=
find_bit_type(argument, &sql_mode_typelib)) == ~(ulong) 0) find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name);
{
fprintf(stderr, "Unknown option to sql-mode: %s\n", argument);
exit(1);
}
global_system_variables.sql_mode= fix_sql_mode(global_system_variables. global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
sql_mode); sql_mode);
break; break;
@ -7910,16 +7865,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case OPT_THREAD_HANDLING: case OPT_THREAD_HANDLING:
{ {
if ((global_system_variables.thread_handling= global_system_variables.thread_handling=
find_type(argument, &thread_handling_typelib, 2)) <= 0 || find_type_or_exit(argument, &thread_handling_typelib, opt->name);
(global_system_variables.thread_handling == SCHEDULER_POOL_OF_THREADS
&& !HAVE_POOL_OF_THREADS))
{
/* purecov: begin tested */
fprintf(stderr,"Unknown/unsupported thread-handling: %s\n",argument);
exit(1);
/* purecov: end */
}
break; break;
} }
case OPT_FT_BOOLEAN_SYNTAX: case OPT_FT_BOOLEAN_SYNTAX:
@ -8208,6 +8155,30 @@ static void fix_paths(void)
} }
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
const char *option)
{
ulong res;
const char **ptr;
if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
{
ptr= bit_lib->type_names;
if (!*x)
fprintf(stderr, "No option given to %s\n", option);
else
fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x);
fprintf(stderr, "Alternatives are: '%s'", *ptr);
while (*++ptr)
fprintf(stderr, ",'%s'", *ptr);
fprintf(stderr, "\n");
exit(1);
}
return res;
}
/* /*
Return a bitfield from a string of substrings separated by ',' Return a bitfield from a string of substrings separated by ','
returns ~(ulong) 0 on error. returns ~(ulong) 0 on error.

Some files were not shown because too many files have changed in this diff Show more