wl#173 - temporal types with sub-second resolution
and collateral changes. * introduce my_hrtime_t, my_timediff_t, and conversion macros * inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(), never from Item::result_type() * pack_time/unpack_time function for "packed" representation of MYSQL_TIME in a longlong that can be compared * ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values * numbers aren't quoted in EXPLAIN EXTENDED * new column I_S.COLUMNS.DATETIME_PRECISION * date/time values are compares to anything as date/time, not as strings or numbers. * old timestamp(X) is no longer supported * MYSQL_TIME to string conversion functions take precision as an argument * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods * Field_timestamp_hires, Field_datetime_hires, Field_time_hires * Field_temporal * Lazy_string class to pass a value (string, number, time) polymorphically down the stack * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants * removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead * introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() * in many cases date/time types are treated like other types, not as special cases * greatly simplified Arg_comparator (regarding date/time/year code) * SEC_TO_TIME is real function, not integer. * microsecond precision in NOW, CURTIME, etc * Item_temporal. All items derived from it only provide get_date, but no val* methods * replication of NOW(6) * Protocol::store(time) now takes the precision as an argument * @@TIMESTAMP is a double client/mysqlbinlog.cc: remove unneded casts include/my_sys.h: introduce my_hrtime_t, my_timediff_t, and conversion macros include/my_time.h: pack_time/unpack_time, etc. convenience functions to work with MYSQL_TIME::second_part libmysql/libmysql.c: str_to_time() is gone. str_to_datetime() does it now. my_TIME_to_str() takes the precision as an argument mysql-test/include/ps_conv.inc: time is not equal to datetime anymore mysql-test/r/distinct.result: a test for an old MySQL bug mysql-test/r/explain.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/func_default.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/func_sapdb.result: when decimals=NOT_FIXED_DEC it means "not fixed" indeed mysql-test/r/func_test.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/func_time.result: ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values mysql-test/r/having.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/information_schema.result: new column I_S.COLUMNS.DATETIME_PRECISION mysql-test/r/join_outer.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/metadata.result: TIMESTAMP no longer has zerofill flag mysql-test/r/range.result: invalid datetime is not compared with as a string mysql-test/r/select.result: NO_ZERO_IN_DATE, etc only affect storage - according to the manual numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/subselect.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/sysdate_is_now.result: when decimals=NOT_FIXED_DEC it means "not fixed" indeed mysql-test/r/type_blob.result: TIMESTAMP(N) is not deprecated mysql-test/r/type_timestamp.result: old TIMESTAMP(X) semantics is not supported anymore mysql-test/r/union.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/varbinary.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/t/distinct.test: test for an old MySQL bug mysql-test/t/func_time.test: +- INTERVAL now works with TIME values mysql-test/t/select.test: typo mysql-test/t/subselect.test: only one error per statement, please mysql-test/t/system_mysql_db_fix40123.test: old timestamp(X) is no longer supported mysql-test/t/system_mysql_db_fix50030.test: old timestamp(X) is no longer supported mysql-test/t/system_mysql_db_fix50117.test: old timestamp(X) is no longer supported mysql-test/t/type_blob.test: old timestamp(X) is no longer supported mysql-test/t/type_timestamp.test: old timestamp(X) is no longer supported mysys/my_getsystime.c: functions to get the time with microsecond precision mysys/my_init.c: move the my_getsystime.c initialization code to my_getsystime.c mysys/my_static.c: no need to make these variables extern mysys/my_static.h: no need to make these variables extern scripts/mysql_system_tables.sql: old timestamp(X) is no longer supported scripts/mysql_system_tables_fix.sql: old timestamp(X) is no longer supported scripts/mysqlhotcopy.sh: old timestamp(X) is no longer supported sql-common/my_time.c: * call str_to_time from str_to_datetime, as appropriate * date/time to string conversions take precision as an argument * number_to_time() * TIME_to_double() * pack_time() and unpack_time() sql/event_data_objects.cc: cast is not needed my_datetime_to_str() takes precision as an argument sql/event_db_repository.cc: avoid dangerous downcast (because the pointer is not always Field_timestamp, see events_1.test) sql/event_queue.cc: avoid silly double-work for cond_wait (having an endpoint of wait, subtract the current time to get the timeout, and use set_timespec() macro to fill in struct timespec, by adding the current time to the timeout) sql/field.cc: * remove virtual Field::get_time(), everyone should use only Field::get_date() * remove lots of #ifdef WORDS_BIGENDIAN * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods * Field_timestamp_hires, Field_datetime_hires, Field_time_hires * Field_temporal * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants sql/field.h: * remove virtual Field::get_time(), everyone should use only Field::get_date() * remove lots of #ifdef WORDS_BIGENDIAN * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods * Field_timestamp_hires, Field_datetime_hires, Field_time_hires * Field_temporal * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants * removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead sql/filesort.cc: TIME_RESULT, cmp_time() sql/item.cc: * numbers aren't quoted in EXPLAIN EXTENDED * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() * virtual Item::get_time() is gone * Item_param::field_type() is set correctly * Item_datetime, for a datetime constant * time to anything is compared as a time * Item_cache::print() prints the value is available * bug fixed in Item_cache_int::val_str() sql/item.h: * Item::print_value(), to be used from Item_xxx::print() when needed * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() * virtual Item::get_time() is gone * Item_datetime, for a datetime constant * better default for cast_to_int_type() * Item_cache objects now *always* have the field_type() set sql/item_cmpfunc.cc: * get_year_value, get_time_value are gone. get_datetime_value does it all * get_value_a_func, get_value_b_func are gone * can_compare_as_dates() is gone too, TIME_RESULT is used instead * cmp_type() instead or result_type() when doing a comparison * compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() sql/item_cmpfunc.h: greatly simplified Arg_comparator sql/item_create.cc: * fix a bug in error messages in CAST sql/item_func.cc: Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() mention all possibitiles in switch over Item_result values, or use default: sql/item_row.h: overwrite the default cmp_type() for Item_row, as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT sql/item_timefunc.cc: rewrite make_datetime to support precision argument SEC_TO_TIME is real function, not integer. many functions that returned temporal values had duplicate code in val_* methods, some of them did not have get_date() which resulted in unnecessary date->str->date conversions. Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods. many fixes to set decimals (datetime precision) correctly. sql/item_timefunc.h: SEC_TO_TIME is real function, not integer. many functions that returned temporal values had duplicate code in val_* methods, some of them did not have get_date() which resulted in unnecessary date->str->date conversions. Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods. many fixes to set decimals (datetime precision) correctly. sql/log_event.cc: replication of NOW(6) sql/log_event.h: replication of NOW(6) sql/mysql_priv.h: Lazy_string class to pass a value (string, number, time) polymorphically down the stack. make_truncated_value_warning() that uses it. sql/mysqld.cc: datetime in Arg_comparator::comparator_matrix sql/opt_range.cc: cleanup: don't disable warnings before calling save_in_field_no_warnings() sql/protocol.cc: Protocol::store(time) now takes the precision as an argument sql/protocol.h: Protocol::store(time) now takes the precision as an argument sql/rpl_rli.cc: small cleanup sql/set_var.cc: SET TIMESTAMP=double sql/set_var.h: @@TIMESTAMP is a double sql/share/errmsg.txt: precision and scale are unsigned sql/slave.cc: replication of NOW(6) sql/sp_head.cc: cleanup sql/sql_class.cc: support for NOW(6) sql/sql_class.h: support for NOW(6) sql/sql_insert.cc: support for NOW(6) sql/sql_select.cc: use item->cmp_type(). move a comment where it belongs sql/sql_show.cc: new column I_S.COLUMNS.DATETIME_PRECISION sql/sql_yacc.yy: TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc sql/time.cc: fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument storage/myisam/ha_myisam.cc: TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible. strings/my_vsnprintf.c: warnings tests/mysql_client_test.c: old timestamp(X) does not work anymore datetime is no longer equal to time
This commit is contained in:
parent
7e0e4b00c9
commit
a8a757c6bb
@ -693,7 +693,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
||||
read them to be able to process the wanted events.
|
||||
*/
|
||||
if (((rec_count >= offset) &&
|
||||
((my_time_t)(ev->when) >= start_datetime)) ||
|
||||
(ev->when >= start_datetime)) ||
|
||||
(ev_type == FORMAT_DESCRIPTION_EVENT))
|
||||
{
|
||||
if (ev_type != FORMAT_DESCRIPTION_EVENT)
|
||||
@ -709,7 +709,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
||||
if (server_id && (server_id != ev->server_id))
|
||||
/* skip just this event, continue processing the log. */
|
||||
goto end;
|
||||
if (((my_time_t)(ev->when) >= stop_datetime)
|
||||
if ((ev->when >= stop_datetime)
|
||||
|| (pos >= stop_position_mot))
|
||||
{
|
||||
/* end the program */
|
||||
|
@ -894,11 +894,21 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len);
|
||||
extern uint my_set_max_open_files(uint files);
|
||||
void my_free_open_file_info(void);
|
||||
|
||||
extern time_t my_time(myf flags);
|
||||
typedef struct {ulonglong val;} my_hrtime_t;
|
||||
typedef struct {ulonglong val;} my_timediff_t;
|
||||
void my_time_init();
|
||||
extern my_hrtime_t my_hrtime();
|
||||
void my_diff_and_hrtime(my_timediff_t *interval, my_hrtime_t *timestamp);
|
||||
extern ulonglong my_getsystime(void);
|
||||
extern ulonglong my_micro_time();
|
||||
extern ulonglong my_micro_time_and_time(time_t *time_arg);
|
||||
time_t my_time_possible_from_micro(ulonglong microtime);
|
||||
|
||||
#define my_micro_time() (my_getsystime()/10)
|
||||
#define hrtime_to_time(X) ((time_t)((X).val/1000000))
|
||||
#define hrtime_from_time(X) ((ulonglong)((X)*1000000ULL))
|
||||
#define hrtime_to_double(X) ((X).val/1e6)
|
||||
#define hrtime_sec_part(X) ((X).val%1000000)
|
||||
#define my_time(X) hrtime_to_time(my_hrtime())
|
||||
#define my_micro_and_hrtime(X,Y) my_diff_and_hrtime(X,Y)
|
||||
|
||||
extern my_bool my_gethwaddr(uchar *to);
|
||||
extern int my_getncpus();
|
||||
|
||||
|
@ -55,6 +55,7 @@ typedef long my_time_t;
|
||||
/* Flags to str_to_datetime */
|
||||
#define TIME_FUZZY_DATE 1
|
||||
#define TIME_DATETIME_ONLY 2
|
||||
#define TIME_TIME_ONLY 4
|
||||
/* Must be same as MODE_NO_ZERO_IN_DATE */
|
||||
#define TIME_NO_ZERO_IN_DATE (65536L*2*2*2*2*2*2*2)
|
||||
/* Must be same as MODE_NO_ZERO_DATE */
|
||||
@ -68,8 +69,9 @@ typedef long my_time_t;
|
||||
#define TIME_MAX_HOUR 838
|
||||
#define TIME_MAX_MINUTE 59
|
||||
#define TIME_MAX_SECOND 59
|
||||
#define TIME_MAX_SECOND_PART 999999
|
||||
#define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + \
|
||||
TIME_MAX_SECOND)
|
||||
TIME_MAX_SECOND + TIME_MAX_SECOND_PART/1e6)
|
||||
#define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \
|
||||
TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND)
|
||||
|
||||
@ -80,14 +82,15 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
|
||||
uint flags, int *was_cut);
|
||||
longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
|
||||
uint flags, int *was_cut);
|
||||
int number_to_time(double nr, MYSQL_TIME *ltime, int *was_cut);
|
||||
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *);
|
||||
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *);
|
||||
ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *);
|
||||
ulonglong TIME_to_ulonglong(const MYSQL_TIME *);
|
||||
double TIME_to_double(const MYSQL_TIME *my_time);
|
||||
|
||||
|
||||
my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time,
|
||||
int *warning);
|
||||
longlong pack_time(MYSQL_TIME *my_time);
|
||||
MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time);
|
||||
|
||||
int check_time_range(struct st_mysql_time *, int *warning);
|
||||
|
||||
@ -136,11 +139,27 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type);
|
||||
sent using binary protocol fit in this buffer.
|
||||
*/
|
||||
#define MAX_DATE_STRING_REP_LENGTH 30
|
||||
#define MAX_SEC_PART_VALUE 999999
|
||||
#define MAX_SEC_PART_DIGITS 6
|
||||
#define AUTO_SEC_PART_DIGITS 31 /* same as NOT_FIXED_DEC */
|
||||
|
||||
int my_time_to_str(const MYSQL_TIME *l_time, char *to);
|
||||
int my_time_to_str(const MYSQL_TIME *l_time, char *to, int digits);
|
||||
int my_date_to_str(const MYSQL_TIME *l_time, char *to);
|
||||
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
|
||||
int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
|
||||
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, int digits);
|
||||
int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, int digits);
|
||||
|
||||
static inline longlong sec_part_shift(longlong second_part, int digits)
|
||||
{
|
||||
return second_part / log_10_int[MAX_SEC_PART_DIGITS - digits];
|
||||
}
|
||||
static inline longlong sec_part_unshift(longlong second_part, int digits)
|
||||
{
|
||||
return second_part * log_10_int[MAX_SEC_PART_DIGITS - digits];
|
||||
}
|
||||
static inline ulong sec_part_truncate(ulong second_part, int digits)
|
||||
{
|
||||
return second_part - second_part % log_10_int[MAX_SEC_PART_DIGITS - digits];
|
||||
}
|
||||
|
||||
/*
|
||||
Available interval types used in any statement.
|
||||
|
@ -102,7 +102,7 @@ struct rand_struct {
|
||||
double max_value_dbl;
|
||||
};
|
||||
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
|
||||
DECIMAL_RESULT};
|
||||
DECIMAL_RESULT, TIME_RESULT};
|
||||
typedef struct st_udf_args
|
||||
{
|
||||
unsigned int arg_count;
|
||||
|
@ -439,7 +439,7 @@ struct rand_struct {
|
||||
/* The following is for user defined functions */
|
||||
|
||||
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
|
||||
DECIMAL_RESULT};
|
||||
DECIMAL_RESULT, TIME_RESULT};
|
||||
|
||||
typedef struct st_udf_args
|
||||
{
|
||||
|
@ -3588,7 +3588,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
|
||||
case MYSQL_TYPE_TIME:
|
||||
{
|
||||
MYSQL_TIME *tm= (MYSQL_TIME *)buffer;
|
||||
str_to_time(value, length, tm, &err);
|
||||
str_to_datetime(value, length, tm, TIME_TIME_ONLY, &err);
|
||||
*param->error= test(err);
|
||||
break;
|
||||
}
|
||||
@ -3943,7 +3943,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param,
|
||||
fetch_string_with_conversion:
|
||||
*/
|
||||
char buff[MAX_DATE_STRING_REP_LENGTH];
|
||||
uint length= my_TIME_to_str(my_time, buff);
|
||||
uint length= my_TIME_to_str(my_time, buff, field->decimals);
|
||||
/* Resort to string conversion */
|
||||
fetch_string_with_conversion(param, (char *)buff, length);
|
||||
break;
|
||||
|
@ -103,7 +103,7 @@ drop table t5 ;
|
||||
# c1 tinyint, c2 smallint, c3 mediumint, c4 int,
|
||||
# c5 integer, c6 bigint, c7 float, c8 double,
|
||||
# c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4),
|
||||
# c13 date, c14 datetime, c15 timestamp(14), c16 time,
|
||||
# c13 date, c14 datetime, c15 timestamp, c16 time,
|
||||
# c17 year, c18 tinyint, c19 bool, c20 char,
|
||||
# c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext,
|
||||
# c25 blob, c26 text, c27 mediumblob, c28 mediumtext,
|
||||
@ -669,7 +669,6 @@ select '-- insert into string columns --' as test_sequence ;
|
||||
--enable_query_log
|
||||
|
||||
######## INSERT into .. string columns values(CHAR(n),LONGTEXT) ########
|
||||
--disable_query_log
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
@ -857,8 +856,6 @@ values
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
|
||||
--enable_query_log
|
||||
|
||||
######## SELECT of all inserted records ########
|
||||
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
|
||||
from t9 where c1 >= 20
|
||||
@ -977,14 +974,13 @@ delete from t9 ;
|
||||
|
||||
######################### test of date/time columns ########################
|
||||
# #
|
||||
# c13 date, c14 datetime, c15 timestamp(14), c16 time, c17 year #
|
||||
# c13 date, c14 datetime, c15 timestamp, c16 time, c17 year #
|
||||
# #
|
||||
############################################################################
|
||||
--disable_query_log
|
||||
select '-- insert into date/time columns --' as test_sequence ;
|
||||
--enable_query_log
|
||||
######## INSERT into .. date/time columns values(VARCHAR(19),LONGTEXT) ########
|
||||
--disable_query_log
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
@ -1140,12 +1136,9 @@ values
|
||||
( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
|
||||
--enable_query_log
|
||||
|
||||
######## SELECT of all inserted records ########
|
||||
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
|
||||
|
||||
|
||||
--disable_query_log
|
||||
select '-- select .. where date/time column = .. --' as test_sequence ;
|
||||
--enable_query_log
|
||||
@ -1153,19 +1146,19 @@ select '-- select .. where date/time column = .. --' as test_sequence ;
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01' ;
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
|
||||
|
||||
######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ########
|
||||
@ -1174,21 +1167,39 @@ select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
|
||||
|
||||
######## SELECT .. WHERE column(date/time/..)=value(CHAR(n)/LONGTEXT) ########
|
||||
set @arg00= '01:01:01' ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
|
||||
|
||||
######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ########
|
||||
set @arg00= CAST('01:01:01' as time) ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
|
||||
|
||||
######## SELECT .. WHERE column(year)=value(INT(10)/BIGINT) ########
|
||||
|
94
mysql-test/include/type_hrtime.inc
Normal file
94
mysql-test/include/type_hrtime.inc
Normal file
@ -0,0 +1,94 @@
|
||||
|
||||
--source include/have_innodb.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t3;
|
||||
--enable_warnings
|
||||
|
||||
--error ER_TOO_BIG_PRECISION
|
||||
eval create table t1 (a $type(7));
|
||||
|
||||
eval create table t1 (a $type(3));
|
||||
insert t1 values ('2010-12-11 01:02:03.4567');
|
||||
insert t1 values (20101211010203.45678);
|
||||
insert t1 values (20101211030405.789e0);
|
||||
insert t1 values (99991231235959e1);
|
||||
select * from t1;
|
||||
select truncate(a, 6) from t1; # Field::val_real()
|
||||
select a DIV 1 from t1; # Field::val_int()
|
||||
select group_concat(distinct a) from t1; # Field::cmp()
|
||||
alter table t1 engine=innodb;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
eval create table t1 (a $type(4)) engine=innodb;
|
||||
insert t1 values ('2010-12-11 01:02:03.456789');
|
||||
select * from t1;
|
||||
select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
|
||||
select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
|
||||
|
||||
#
|
||||
# metadata
|
||||
#
|
||||
show create table t1;
|
||||
show columns from t1;
|
||||
--query_vertical select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1'
|
||||
|
||||
#
|
||||
# update/delete
|
||||
#
|
||||
select a, a+interval 9876543 microsecond from t1;
|
||||
update t1 set a=a+interval 9876543 microsecond;
|
||||
select * from t1;
|
||||
insert t1 select a + interval 2 year from t1;
|
||||
select * from t1;
|
||||
delete from t1 where a < 20110101;
|
||||
select * from t1;
|
||||
|
||||
#
|
||||
# create ... select
|
||||
#
|
||||
create table t2 select * from t1;
|
||||
create table t3 like t1;
|
||||
|
||||
show create table t2;
|
||||
show create table t3;
|
||||
|
||||
drop table t1, t2, t3;
|
||||
|
||||
#
|
||||
# SP
|
||||
#
|
||||
eval create table t1 (a $type(6), b $type(6));
|
||||
eval create procedure foo(x $type, y $type(4)) insert into t1 values (x, y);
|
||||
call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
|
||||
select * from t1;
|
||||
delimiter |;
|
||||
eval create procedure bar(a int, c $type(5))
|
||||
begin
|
||||
declare b $type(4);
|
||||
set b = c + interval a microsecond;
|
||||
insert t1 values (b, c + interval a microsecond);
|
||||
end|
|
||||
delimiter ;|
|
||||
call bar(1111111, '2011-01-02 3:4:5.123456');
|
||||
select * from t1;
|
||||
drop procedure foo;
|
||||
drop procedure bar;
|
||||
eval create function xyz(s char(20)) returns $type(4)
|
||||
return addtime('2010-10-10 10:10:10.101010', s);
|
||||
select xyz('1:1:1.010101');
|
||||
drop function xyz;
|
||||
|
||||
#
|
||||
# Views
|
||||
#
|
||||
|
||||
create view v1 as select * from t1 group by a,b;
|
||||
select * from v1;
|
||||
show columns from v1;
|
||||
create table t2 select * from v1;
|
||||
show create table t2;
|
||||
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
@ -254,7 +254,7 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
|
||||
1
|
||||
select cast("1:2:3" as TIME) = "1:02:03";
|
||||
cast("1:2:3" as TIME) = "1:02:03"
|
||||
0
|
||||
1
|
||||
select cast(NULL as DATE);
|
||||
cast(NULL as DATE)
|
||||
NULL
|
||||
|
@ -421,14 +421,14 @@ date format str_to_date
|
||||
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 2003-01-02 22:11:12
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '10:20:10AM'
|
||||
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
|
||||
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
||||
date format con
|
||||
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
|
||||
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '10:20:10AM'
|
||||
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
|
||||
drop table t1;
|
||||
select get_format(DATE, 'USA') as a;
|
||||
a
|
||||
@ -471,14 +471,14 @@ str_to_date("2003-01-02", "%Y-%m-%d") as f3,
|
||||
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
f1 datetime YES NULL
|
||||
f2 time YES NULL
|
||||
f1 datetime(6) YES NULL
|
||||
f2 time(6) YES NULL
|
||||
f3 date YES NULL
|
||||
f4 date YES NULL
|
||||
f5 time YES NULL
|
||||
select * from t1;
|
||||
f1 f2 f3 f4 f5
|
||||
2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00
|
||||
2003-01-02 10:11:12.001200 10:11:12.001200 2003-01-02 0000-00-02 58:00:00
|
||||
drop table t1;
|
||||
create table t1 select "02 10" as a, "%d %H" as b;
|
||||
select str_to_date(a,b) from t1;
|
||||
@ -495,7 +495,7 @@ str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
|
||||
str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
|
||||
str_to_date("02 10", "%d %f") as f6;
|
||||
f1 f2 f3 f4 f5 f6
|
||||
2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12 58:11:12 48:00:00.100000
|
||||
2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12.000000 58:11:12 48:00:00.100000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012'
|
||||
drop table t1, t2;
|
||||
|
@ -794,3 +794,14 @@ DROP TABLE t1;
|
||||
SET @@sort_buffer_size = @old_sort_buffer_size;
|
||||
SET @@max_heap_table_size = @old_max_heap_table_size;
|
||||
End of 5.1 tests
|
||||
create table t1 (a varchar(100));
|
||||
insert t1 values ('2010-10-10'), ('20101010');
|
||||
select * from t1 where a = DATE('2010-10-10');
|
||||
a
|
||||
2010-10-10
|
||||
20101010
|
||||
select distinct a from t1 where a = DATE('2010-10-10');
|
||||
a
|
||||
2010-10-10
|
||||
20101010
|
||||
drop table t1;
|
||||
|
@ -309,7 +309,7 @@ ERROR HY000: Unknown event 'intact_check'
|
||||
DROP EVENT no_such_event;
|
||||
ERROR HY000: Unknown event 'no_such_event'
|
||||
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
|
||||
ERROR HY000: Failed to store event name. Error code 2 from storage engine.
|
||||
ERROR HY000: Failed to store event name. Error code 1 from storage engine.
|
||||
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
|
||||
ERROR HY000: Unknown event 'intact_check_1'
|
||||
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
|
||||
|
@ -64,7 +64,7 @@ explain extended select * from v1 where f2=1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `f1`,1 AS `f2` from `test`.`t1` where 1
|
||||
explain extended select * from t1 where 0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
@ -74,7 +74,7 @@ explain extended select * from t1 where 1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `f1`,1 AS `f2` from `test`.`t1` where 1
|
||||
explain extended select * from t1 having 0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
@ -84,7 +84,7 @@ explain extended select * from t1 having 1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` having 1
|
||||
Note 1003 select 1 AS `f1`,1 AS `f2` from `test`.`t1` having 1
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
CREATE TABLE t1(c INT);
|
||||
|
@ -8,7 +8,7 @@ explain extended select default(str), default(strnull), default(intg), default(r
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default('0') AS `default(intg)`,default('0') AS `default(rel)` from `test`.`t1`
|
||||
Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default(0) AS `default(intg)`,default(0) AS `default(rel)` from `test`.`t1`
|
||||
select * from t1 where str <> default(str);
|
||||
str strnull intg rel
|
||||
0 0
|
||||
|
@ -544,15 +544,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
select f2 from t2 where f2 in ('a','b');
|
||||
f2
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f2 from t2 where f2 in ('a','b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
select f2 from t2 where f2 in (1,'b');
|
||||
f2
|
||||
0
|
||||
|
@ -113,10 +113,10 @@ subtime("01:00:00.999999", "02:00:00.999998")
|
||||
-00:59:59.999999
|
||||
select subtime("02:01:01.999999", "01:01:01.999999");
|
||||
subtime("02:01:01.999999", "01:01:01.999999")
|
||||
01:00:00.000000
|
||||
01:00:00
|
||||
select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
|
||||
timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
|
||||
838:59:59
|
||||
838:59:59.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '8807:59:59.999999'
|
||||
select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
|
||||
@ -230,8 +230,8 @@ SELECT TIMEDIFF(t1, t4) As ttt, TIMEDIFF(t2, t3) As qqq,
|
||||
TIMEDIFF(t3, t2) As eee, TIMEDIFF(t2, t4) As rrr from test;
|
||||
ttt qqq eee rrr
|
||||
-744:00:00 NULL NULL NULL
|
||||
838:59:59 22:58:58 -22:58:58 NULL
|
||||
-838:59:59 -22:58:58 22:58:58 NULL
|
||||
838:59:59.999999 22:58:58 -22:58:58 NULL
|
||||
-838:59:59.999999 -22:58:58 22:58:58 NULL
|
||||
NULL 26:02:02 -26:02:02 NULL
|
||||
00:00:00 -26:02:02 26:02:02 NULL
|
||||
NULL NULL NULL NULL
|
||||
|
@ -87,7 +87,7 @@ explain extended select - a from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select -('1') AS `- a` from `test`.`t1`
|
||||
Note 1003 select -(1) AS `- a` from `test`.`t1`
|
||||
drop table t1;
|
||||
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
|
||||
5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1
|
||||
|
@ -8,20 +8,20 @@ period_add("9602",-12) period_diff(199505,"9404")
|
||||
199502 13
|
||||
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
|
||||
now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(now())
|
||||
0.000000 0 0
|
||||
0 0 0
|
||||
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
|
||||
from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
|
||||
1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112.000000
|
||||
1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112
|
||||
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
|
||||
sec_to_time(time_to_sec("0:30:47")/6.21);
|
||||
sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21)
|
||||
02:30:01 23001.000000 54742 00:04:57
|
||||
02:30:01 23001 54742 00:04:57.423510
|
||||
select sec_to_time(time_to_sec('-838:59:59'));
|
||||
sec_to_time(time_to_sec('-838:59:59'))
|
||||
-838:59:59
|
||||
select now()-curdate()*1000000-curtime();
|
||||
now()-curdate()*1000000-curtime()
|
||||
0.000000
|
||||
0
|
||||
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
|
||||
strcmp(current_timestamp(),concat(current_date()," ",current_time()))
|
||||
0
|
||||
@ -798,9 +798,7 @@ TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
|
||||
2
|
||||
select date_add(time,INTERVAL 1 SECOND) from t1;
|
||||
date_add(time,INTERVAL 1 SECOND)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'time' at row 1
|
||||
06:07:09
|
||||
drop table t1;
|
||||
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
|
||||
last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
|
||||
@ -941,10 +939,10 @@ sec_to_time(1) + 0, from_unixtime(1) + 0;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`now() - now()` double(23,6) NOT NULL DEFAULT '0.000000',
|
||||
`curtime() - curtime()` double(23,6) NOT NULL DEFAULT '0.000000',
|
||||
`sec_to_time(1) + 0` double(23,6) DEFAULT NULL,
|
||||
`from_unixtime(1) + 0` double(23,6) DEFAULT NULL
|
||||
`now() - now()` double(17,0) NOT NULL DEFAULT '0',
|
||||
`curtime() - curtime()` double(17,0) NOT NULL DEFAULT '0',
|
||||
`sec_to_time(1) + 0` double(17,0) DEFAULT NULL,
|
||||
`from_unixtime(1) + 0` double(17,0) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
SELECT SEC_TO_TIME(3300000);
|
||||
@ -954,7 +952,7 @@ Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '3300000'
|
||||
SELECT SEC_TO_TIME(3300000)+0;
|
||||
SEC_TO_TIME(3300000)+0
|
||||
8385959.000000
|
||||
8385959
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '3300000'
|
||||
SELECT SEC_TO_TIME(3600 * 4294967296);
|
||||
@ -964,31 +962,31 @@ Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '15461882265600'
|
||||
SELECT TIME_TO_SEC('916:40:00');
|
||||
TIME_TO_SEC('916:40:00')
|
||||
3020399
|
||||
3020399.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '916:40:00'
|
||||
SELECT ADDTIME('500:00:00', '416:40:00');
|
||||
ADDTIME('500:00:00', '416:40:00')
|
||||
838:59:59
|
||||
838:59:59.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '916:40:00'
|
||||
SELECT ADDTIME('916:40:00', '416:40:00');
|
||||
ADDTIME('916:40:00', '416:40:00')
|
||||
838:59:59
|
||||
838:59:59.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '916:40:00'
|
||||
Warning 1292 Truncated incorrect time value: '1255:39:59'
|
||||
Warning 1292 Truncated incorrect time value: '1255:39:59.999999'
|
||||
SELECT SUBTIME('916:40:00', '416:40:00');
|
||||
SUBTIME('916:40:00', '416:40:00')
|
||||
422:19:59
|
||||
422:19:59.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '916:40:00'
|
||||
SELECT SUBTIME('-916:40:00', '416:40:00');
|
||||
SUBTIME('-916:40:00', '416:40:00')
|
||||
-838:59:59
|
||||
-838:59:59.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '-916:40:00'
|
||||
Warning 1292 Truncated incorrect time value: '-1255:39:59'
|
||||
Warning 1292 Truncated incorrect time value: '-1255:39:59.999999'
|
||||
SELECT MAKETIME(916,0,0);
|
||||
MAKETIME(916,0,0)
|
||||
838:59:59
|
||||
@ -1033,7 +1031,7 @@ SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
|
||||
SEC_TO_TIME(CAST(-1 AS UNSIGNED))
|
||||
838:59:59
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '18446744073709551615'
|
||||
Warning 1292 Truncated incorrect time value: '18446744073709551616'
|
||||
SET NAMES latin1;
|
||||
SET character_set_results = NULL;
|
||||
SHOW VARIABLES LIKE 'character_set_results';
|
||||
@ -1218,6 +1216,8 @@ set time_zone= @@global.time_zone;
|
||||
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
|
||||
str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
|
||||
create table t1 (field DATE);
|
||||
insert into t1 values ('2006-11-06');
|
||||
select * from t1 where field < '2006-11-06 04:08:36.0';
|
||||
@ -1358,3 +1358,72 @@ Warning 1292 Truncated incorrect time value: ''
|
||||
Warning 1292 Truncated incorrect time value: ''
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests
|
||||
select time(' 1 02:03:04') + interval 9 microsecond;
|
||||
time(' 1 02:03:04') + interval 9 microsecond
|
||||
26:03:04.000009
|
||||
select time(' 1 02:03:04') - interval 9 microsecond;
|
||||
time(' 1 02:03:04') - interval 9 microsecond
|
||||
26:03:03.999991
|
||||
select time('-1 02:03:04') + interval 9 microsecond;
|
||||
time('-1 02:03:04') + interval 9 microsecond
|
||||
-26:03:03.999991
|
||||
select time('-1 02:03:04') - interval 9 microsecond;
|
||||
time('-1 02:03:04') - interval 9 microsecond
|
||||
-26:03:04.000009
|
||||
select time(' 1 02:03:04') + interval '4:4:4' hour_second;
|
||||
time(' 1 02:03:04') + interval '4:4:4' hour_second
|
||||
30:07:08
|
||||
select time(' 1 02:03:04') - interval '4:4:4' hour_second;
|
||||
time(' 1 02:03:04') - interval '4:4:4' hour_second
|
||||
21:59:00
|
||||
select time('-1 02:03:04') + interval '4:4:4' hour_second;
|
||||
time('-1 02:03:04') + interval '4:4:4' hour_second
|
||||
-21:59:00
|
||||
select time('-1 02:03:04') - interval '4:4:4' hour_second;
|
||||
time('-1 02:03:04') - interval '4:4:4' hour_second
|
||||
-30:07:08
|
||||
select time(' 1 02:03:04') + interval 2 day;
|
||||
time(' 1 02:03:04') + interval 2 day
|
||||
74:03:04
|
||||
select time(' 1 02:03:04') - interval 2 day;
|
||||
time(' 1 02:03:04') - interval 2 day
|
||||
-21:56:56
|
||||
select time('-1 02:03:04') + interval 2 day;
|
||||
time('-1 02:03:04') + interval 2 day
|
||||
21:56:56
|
||||
select time('-1 02:03:04') - interval 2 day;
|
||||
time('-1 02:03:04') - interval 2 day
|
||||
-74:03:04
|
||||
select cast('131415.123e0' as time);
|
||||
cast('131415.123e0' as time)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '131415.123e0'
|
||||
select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
|
||||
cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04'
|
||||
0
|
||||
select least(time('1:2:3'), '01:02:04', null) div 1;
|
||||
least(time('1:2:3'), '01:02:04', null) div 1
|
||||
NULL
|
||||
select truncate(least(time('1:2:3'), '01:02:04', null), 6);
|
||||
truncate(least(time('1:2:3'), '01:02:04', null), 6)
|
||||
NULL
|
||||
select cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1));
|
||||
cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1))
|
||||
NULL
|
||||
select unix_timestamp(null);
|
||||
unix_timestamp(null)
|
||||
NULL
|
||||
select truncate(date('2010-40-10'), 6);
|
||||
truncate(date('2010-40-10'), 6)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2010-40-10'
|
||||
select extract(month from '2010-40-50');
|
||||
extract(month from '2010-40-50')
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2010-40-50'
|
||||
select subtime('0000-00-10 10:10:10', '30 10:00:00');
|
||||
subtime('0000-00-10 10:10:10', '30 10:00:00')
|
||||
NULL
|
||||
|
151
mysql-test/r/func_time_hires.result
Normal file
151
mysql-test/r/func_time_hires.result
Normal file
@ -0,0 +1,151 @@
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456, time_zone='+03:00';
|
||||
select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
|
||||
sec_to_time(12345) 03:25:45
|
||||
sec_to_time(12345.6789) 03:25:45.6789
|
||||
sec_to_time(1234567e-2) 03:25:45.670000
|
||||
select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
|
||||
current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
|
||||
time_to_sec('12:34:56.789');
|
||||
now() 2011-01-01 01:01:01
|
||||
curtime(0) 01:01:01
|
||||
utc_timestamp(1) 2010-12-31 22:01:01.1
|
||||
utc_time(2) 22:01:01.12
|
||||
current_time(3) 01:01:01.123
|
||||
current_timestamp(4) 2011-01-01 01:01:01.1234
|
||||
localtime(5) 2011-01-01 01:01:01.12345
|
||||
localtimestamp(6) 2011-01-01 01:01:01.123456
|
||||
time_to_sec('12:34:56') 45296
|
||||
time_to_sec('12:34:56.789') 45296.789
|
||||
select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
|
||||
sec_to_time(time_to_sec('1:2:3')) 01:02:03
|
||||
sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.567890
|
||||
select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
|
||||
time_to_sec(sec_to_time(11111)) 11111
|
||||
time_to_sec(sec_to_time(11111.22222)) 11111.22222
|
||||
select current_timestamp(7);
|
||||
ERROR HY000: Incorrect arguments to now
|
||||
select curtime(7);
|
||||
ERROR HY000: Incorrect arguments to curtime
|
||||
drop table if exists t1;
|
||||
create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
|
||||
sec_to_time(1234567e-2), now(), curtime(0),
|
||||
utc_timestamp(1), utc_time(2), current_time(3),
|
||||
current_timestamp(4), localtime(5), localtimestamp(6),
|
||||
time_to_sec('12:34:56'), time_to_sec('12:34:56.789');
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`sec_to_time(12345)` time DEFAULT NULL,
|
||||
`sec_to_time(12345.6789)` time(4) DEFAULT NULL,
|
||||
`sec_to_time(1234567e-2)` time DEFAULT NULL,
|
||||
`now()` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`curtime(0)` time NOT NULL DEFAULT '00:00:00',
|
||||
`utc_timestamp(1)` datetime(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0',
|
||||
`utc_time(2)` time(2) NOT NULL DEFAULT '00:00:00.00',
|
||||
`current_time(3)` time(3) NOT NULL DEFAULT '00:00:00.000',
|
||||
`current_timestamp(4)` datetime(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000',
|
||||
`localtime(5)` datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000',
|
||||
`localtimestamp(6)` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
|
||||
`time_to_sec('12:34:56')` double DEFAULT NULL,
|
||||
`time_to_sec('12:34:56.789')` double DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
sec_to_time(12345) 03:25:45
|
||||
sec_to_time(12345.6789) 03:25:45.6789
|
||||
sec_to_time(1234567e-2) 03:25:45
|
||||
now() 2011-01-01 01:01:01
|
||||
curtime(0) 01:01:01
|
||||
utc_timestamp(1) 2010-12-31 22:01:01.1
|
||||
utc_time(2) 22:01:01.12
|
||||
current_time(3) 01:01:01.123
|
||||
current_timestamp(4) 2011-01-01 01:01:01.1234
|
||||
localtime(5) 2011-01-01 01:01:01.12345
|
||||
localtimestamp(6) 2011-01-01 01:01:01.123456
|
||||
time_to_sec('12:34:56') 45296
|
||||
time_to_sec('12:34:56.789') 45296.789
|
||||
drop table t1;
|
||||
set @a=cast('2011-01-02 12:13:14' as datetime);
|
||||
select @a + interval 1 minute;
|
||||
@a + interval 1 minute
|
||||
2011-01-02 12:14:14
|
||||
select @a + interval 10 microsecond;
|
||||
@a + interval 10 microsecond
|
||||
2011-01-02 12:13:14.000010
|
||||
select @a + interval 10 microsecond + interval 999990 microsecond;
|
||||
@a + interval 10 microsecond + interval 999990 microsecond
|
||||
2011-01-02 12:13:15.000000
|
||||
set @a='2011-01-02 12:13:14.123456';
|
||||
create table t1 select CAST(@a AS DATETIME) as dauto,
|
||||
CAST(@a AS DATETIME(0)) as d0,
|
||||
CAST(@a AS DATETIME(1)) as d1,
|
||||
CAST(@a AS DATETIME(2)) as d2,
|
||||
CAST(@a AS DATETIME(3)) as d3,
|
||||
CAST(@a AS DATETIME(4)) as d4,
|
||||
CAST(@a AS DATETIME(5)) as d5,
|
||||
CAST(@a AS DATETIME(6)) as d6,
|
||||
CAST(@a AS TIME) as tauto,
|
||||
CAST(@a AS TIME(0)) as t0,
|
||||
CAST(@a AS TIME(1)) as t1,
|
||||
CAST(@a AS TIME(2)) as t2,
|
||||
CAST(@a AS TIME(3)) as t3,
|
||||
CAST(@a AS TIME(4)) as t4,
|
||||
CAST(@a AS TIME(5)) as t5,
|
||||
CAST(@a AS TIME(6)) as t6;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`dauto` datetime DEFAULT NULL,
|
||||
`d0` datetime DEFAULT NULL,
|
||||
`d1` datetime(1) DEFAULT NULL,
|
||||
`d2` datetime(2) DEFAULT NULL,
|
||||
`d3` datetime(3) DEFAULT NULL,
|
||||
`d4` datetime(4) DEFAULT NULL,
|
||||
`d5` datetime(5) DEFAULT NULL,
|
||||
`d6` datetime(6) DEFAULT NULL,
|
||||
`tauto` time DEFAULT NULL,
|
||||
`t0` time DEFAULT NULL,
|
||||
`t1` time(1) DEFAULT NULL,
|
||||
`t2` time(2) DEFAULT NULL,
|
||||
`t3` time(3) DEFAULT NULL,
|
||||
`t4` time(4) DEFAULT NULL,
|
||||
`t5` time(5) DEFAULT NULL,
|
||||
`t6` time(6) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
dauto 2011-01-02 12:13:14
|
||||
d0 2011-01-02 12:13:14
|
||||
d1 2011-01-02 12:13:14.1
|
||||
d2 2011-01-02 12:13:14.12
|
||||
d3 2011-01-02 12:13:14.123
|
||||
d4 2011-01-02 12:13:14.1234
|
||||
d5 2011-01-02 12:13:14.12345
|
||||
d6 2011-01-02 12:13:14.123456
|
||||
tauto 12:13:14
|
||||
t0 12:13:14
|
||||
t1 12:13:14.1
|
||||
t2 12:13:14.12
|
||||
t3 12:13:14.123
|
||||
t4 12:13:14.1234
|
||||
t5 12:13:14.12345
|
||||
t6 12:13:14.123456
|
||||
drop table t1;
|
||||
select CAST(@a AS DATETIME(7));
|
||||
ERROR 42000: Too big precision 7 specified for column '(@a)'. Maximum is 6.
|
||||
SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
|
||||
CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00')
|
||||
2011-01-02 15:00:00
|
||||
SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
|
||||
CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00')
|
||||
2011-01-02 15:00:00.123000
|
||||
SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
|
||||
CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00')
|
||||
2011-01-02 15:00:00.123456
|
||||
SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
|
||||
CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00')
|
||||
2010-10-10 13:10:10.1234
|
||||
create table t1 (a varchar(200));
|
||||
insert t1 values (now(6));
|
||||
select * from t1;
|
||||
a
|
||||
2011-01-01 01:01:01.123456
|
||||
drop table t1;
|
@ -472,7 +472,7 @@ HAVING (table2.f2 = 8 AND table1.f1 >= 6);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having 0
|
||||
Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = 9)) group by `test`.`table1`.`f1`,7 having 0
|
||||
EXPLAIN EXTENDED
|
||||
SELECT table1.f1, table2.f2
|
||||
FROM t1 AS table1
|
||||
@ -483,7 +483,7 @@ HAVING (table2.f2 = 8);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having 0
|
||||
Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = 9)) group by `test`.`table1`.`f1`,7 having 0
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355
|
||||
|
@ -189,8 +189,8 @@ Field Type Collation Null Key Default Extra Privileges Comment
|
||||
c varchar(64) utf8_general_ci NO select,insert,update,references
|
||||
select * from information_schema.COLUMNS where table_name="t1"
|
||||
and column_name= "a";
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
|
||||
show columns from mysqltest.t1 where field like "%a%";
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
@ -1581,9 +1581,9 @@ WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
|
||||
TABLE_COLLATION
|
||||
utf8_bin
|
||||
select * from information_schema.columns where table_schema = NULL;
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
|
||||
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
|
||||
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
|
||||
|
@ -1302,7 +1302,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select '1' AS `f1`,NULL AS `f2`,'3' AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL)) where ((coalesce('1',NULL),'3') in ((1,3),(2,2)))
|
||||
Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL)) where ((coalesce(1,NULL),3) in ((1,3),(2,2)))
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
|
||||
WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
|
||||
f1 f2 f3 f1 f2
|
||||
|
@ -5,8 +5,8 @@ Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
Warning 1265 Data truncated for column 'a' at row 2
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1264 Out of range value for column 'a' at row 2
|
||||
Warning 1264 Out of range value for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'd' at row 2
|
||||
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
|
||||
SELECT * from t1;
|
||||
@ -20,7 +20,7 @@ load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1264 Out of range value for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'd' at row 2
|
||||
SELECT * from t1;
|
||||
a b c d
|
||||
|
@ -21,7 +21,7 @@ def test t1 t1 g g 5 4 0 Y 32768 3 63
|
||||
def test t1 t1 h h 246 7 0 Y 0 4 63
|
||||
def test t1 t1 i i 13 4 0 Y 32864 0 63
|
||||
def test t1 t1 j j 10 10 0 Y 128 0 63
|
||||
def test t1 t1 k k 7 19 0 N 9441 0 63
|
||||
def test t1 t1 k k 7 19 0 N 9377 0 63
|
||||
def test t1 t1 l l 12 19 0 Y 128 0 63
|
||||
def test t1 t1 m m 254 1 0 Y 256 0 8
|
||||
def test t1 t1 n n 254 3 0 Y 2048 0 8
|
||||
|
@ -556,9 +556,13 @@ DROP TABLE IF EXISTS t1;
|
||||
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
|
||||
STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
|
||||
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE;
|
||||
STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE
|
||||
NULL
|
||||
Warnings:
|
||||
Error 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
|
||||
SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
|
||||
"1997-12-31 23:59:59" + INTERVAL 1 SECOND
|
||||
1998-01-01 00:00:00
|
||||
|
@ -3040,3 +3040,18 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
prepare stmt from "select date('2010-10-10') between '2010-09-09' and ?";
|
||||
set @a='2010-11-11';
|
||||
execute stmt using @a;
|
||||
date('2010-10-10') between '2010-09-09' and ?
|
||||
1
|
||||
execute stmt using @a;
|
||||
date('2010-10-10') between '2010-09-09' and ?
|
||||
1
|
||||
set @a='2010-08-08';
|
||||
execute stmt using @a;
|
||||
date('2010-10-10') between '2010-09-09' and ?
|
||||
0
|
||||
execute stmt using @a;
|
||||
date('2010-10-10') between '2010-09-09' and ?
|
||||
0
|
||||
|
@ -63,8 +63,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
|
||||
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
|
||||
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
|
||||
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
|
||||
def test t9 t9 c15 c15 7 19 19 N 9441 0 63
|
||||
def test t9 t9 c16 c16 11 8 8 Y 128 0 63
|
||||
def test t9 t9 c15 c15 7 19 19 N 9377 0 63
|
||||
def test t9 t9 c16 c16 11 9 8 Y 128 0 63
|
||||
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
|
||||
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
|
||||
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
|
||||
@ -2762,46 +2762,212 @@ c12 -9999.9999
|
||||
execute my_delete ;
|
||||
test_sequence
|
||||
-- insert into string columns --
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '21' ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '23';
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary) ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '31' ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary) )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= CAST('33' as binary);
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 41 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 43;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 51.0 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 53.0;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
|
||||
5.4e+1, 5.4e+1, 5.4e+1 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 5.5e+1 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
|
||||
5.6e+1, 5.6e+1, 5.6e+1 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 5.7e+1;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 'abc' ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 2 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
|
||||
from t9 where c1 >= 20
|
||||
order by c1 ;
|
||||
@ -2960,70 +3126,200 @@ true
|
||||
delete from t9 ;
|
||||
test_sequence
|
||||
-- insert into date/time columns --
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
|
||||
'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
|
||||
'1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 23, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 30, CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime)) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 32, CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime))" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 33, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
set @arg00= 2000000000 ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 43, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
set @arg00= 1.0e+10 ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 53, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
set @arg00= 'abc' ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 60, NULL, NULL, '1991-01-01 01:01:01',
|
||||
NULL, NULL) ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 62, NULL, NULL, '1991-01-01 01:01:01',
|
||||
NULL, NULL)" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8.0 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
|
||||
c1 c13 c14 c15 c16 c17
|
||||
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
|
||||
@ -3055,25 +3351,25 @@ test_sequence
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01' ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
@ -3081,12 +3377,11 @@ select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
found
|
||||
true
|
||||
@ -3094,14 +3389,43 @@ prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= '01:01:01' ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= CAST('01:01:01' as time) ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= 1991 ;
|
||||
|
@ -63,8 +63,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
|
||||
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
|
||||
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
|
||||
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
|
||||
def test t9 t9 c15 c15 7 19 19 N 9441 0 63
|
||||
def test t9 t9 c16 c16 11 8 8 Y 128 0 63
|
||||
def test t9 t9 c15 c15 7 19 19 N 9377 0 63
|
||||
def test t9 t9 c16 c16 11 9 8 Y 128 0 63
|
||||
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
|
||||
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
|
||||
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
|
||||
@ -2745,46 +2745,212 @@ c12 -9999.9999
|
||||
execute my_delete ;
|
||||
test_sequence
|
||||
-- insert into string columns --
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '21' ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '23';
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary) ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '31' ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary) )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= CAST('33' as binary);
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 41 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 43;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 51.0 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 53.0;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
|
||||
5.4e+1, 5.4e+1, 5.4e+1 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 5.5e+1 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
|
||||
5.6e+1, 5.6e+1, 5.6e+1 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 5.7e+1;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 'abc' ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 2 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
|
||||
from t9 where c1 >= 20
|
||||
order by c1 ;
|
||||
@ -2943,70 +3109,200 @@ true
|
||||
delete from t9 ;
|
||||
test_sequence
|
||||
-- insert into date/time columns --
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
|
||||
'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
|
||||
'1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 23, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 30, CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime)) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 32, CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime))" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 33, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
set @arg00= 2000000000 ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 43, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
set @arg00= 1.0e+10 ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 53, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
set @arg00= 'abc' ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 60, NULL, NULL, '1991-01-01 01:01:01',
|
||||
NULL, NULL) ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 62, NULL, NULL, '1991-01-01 01:01:01',
|
||||
NULL, NULL)" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8.0 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
|
||||
c1 c13 c14 c15 c16 c17
|
||||
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
|
||||
@ -3038,25 +3334,25 @@ test_sequence
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01' ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
@ -3064,12 +3360,11 @@ select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
found
|
||||
true
|
||||
@ -3077,14 +3372,43 @@ prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= '01:01:01' ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= CAST('01:01:01' as time) ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= 1991 ;
|
||||
|
@ -64,8 +64,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
|
||||
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
|
||||
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
|
||||
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
|
||||
def test t9 t9 c15 c15 7 19 19 N 9441 0 63
|
||||
def test t9 t9 c16 c16 11 8 8 Y 128 0 63
|
||||
def test t9 t9 c15 c15 7 19 19 N 9377 0 63
|
||||
def test t9 t9 c16 c16 11 9 8 Y 128 0 63
|
||||
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
|
||||
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
|
||||
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
|
||||
@ -2746,46 +2746,212 @@ c12 -9999.9999
|
||||
execute my_delete ;
|
||||
test_sequence
|
||||
-- insert into string columns --
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '21' ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '23';
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
|
||||
CAST('30' as binary), CAST('30' as binary) ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= '31' ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
|
||||
CAST('32' as binary), CAST('32' as binary) )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= CAST('33' as binary);
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 41 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 43;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 51.0 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 53.0;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
|
||||
5.4e+1, 5.4e+1, 5.4e+1 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 5.5e+1 ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
|
||||
5.6e+1, 5.6e+1, 5.6e+1 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 5.7e+1;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c20' at row 1
|
||||
set @arg00= 'abc' ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 2 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00 ) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
|
||||
values
|
||||
( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
|
||||
@arg00, @arg00, @arg00, @arg00 ;
|
||||
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
|
||||
from t9 where c1 >= 20
|
||||
order by c1 ;
|
||||
@ -2944,70 +3110,200 @@ true
|
||||
delete from t9 ;
|
||||
test_sequence
|
||||
-- insert into date/time columns --
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
|
||||
'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
|
||||
'1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 23, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 30, CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime)) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 32, CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime),
|
||||
CAST('1991-01-01 01:01:01' as datetime))" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 33, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c17' at row 1
|
||||
set @arg00= 2000000000 ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 43, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c13' at row 1
|
||||
Warning 1264 Out of range value for column 'c14' at row 1
|
||||
Warning 1265 Data truncated for column 'c13' at row 1
|
||||
Warning 1265 Data truncated for column 'c14' 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 'c17' at row 1
|
||||
set @arg00= 1.0e+10 ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
|
||||
execute stmt1 ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 53, ?, ?, ?, ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
Warnings:
|
||||
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 'c17' at row 1
|
||||
set @arg00= 'abc' ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 60, NULL, NULL, '1991-01-01 01:01:01',
|
||||
NULL, NULL) ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt1 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 62, NULL, NULL, '1991-01-01 01:01:01',
|
||||
NULL, NULL)" ;
|
||||
execute stmt1 ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
set @arg00= 8.0 ;
|
||||
set @arg00= NULL ;
|
||||
insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
|
||||
prepare stmt2 from "insert into t9
|
||||
( c1, c13, c14, c15, c16, c17 )
|
||||
values
|
||||
( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
|
||||
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
|
||||
c1 c13 c14 c15 c16 c17
|
||||
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
|
||||
@ -3039,25 +3335,25 @@ test_sequence
|
||||
set @arg00= '1991-01-01 01:01:01' ;
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01' ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
|
||||
c15= '1991-01-01 01:01:01' and
|
||||
c17= '1991-01-01 01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
@ -3065,12 +3361,11 @@ select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime) ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
|
||||
where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
|
||||
and c17= @arg00 ;
|
||||
found
|
||||
true
|
||||
@ -3078,14 +3373,43 @@ prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
|
||||
c14= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c15= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c16= CAST('1991-01-01 01:01:01' as datetime) and
|
||||
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
|
||||
where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
|
||||
execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= '01:01:01' ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= CAST('01:01:01' as time) ;
|
||||
select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
|
||||
found
|
||||
true
|
||||
select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
|
||||
execute stmt1 ;
|
||||
found
|
||||
true
|
||||
prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
|
||||
execute stmt1 using @arg00 ;
|
||||
found
|
||||
true
|
||||
set @arg00= 1991 ;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1106,14 +1106,11 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using where
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
|
||||
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
item started price
|
||||
A1 2005-11-01 08:00:00 1000.000
|
||||
A1 2005-11-15 00:00:00 2000.000
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 0
|
||||
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
|
||||
item started price
|
||||
A1 2005-11-01 08:00:00 1000.000
|
||||
@ -1122,14 +1119,10 @@ DROP INDEX `PRIMARY` ON t1;
|
||||
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
|
||||
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
|
||||
item started price
|
||||
A1 2005-11-01 08:00:00 1000.000
|
||||
A1 2005-11-15 00:00:00 2000.000
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 0
|
||||
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
|
||||
item started price
|
||||
A1 2005-11-01 08:00:00 1000.000
|
||||
@ -1586,14 +1579,13 @@ str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
|
||||
str_to_date('2007-20-00', '%Y-%m-%d') <= ''
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: ''
|
||||
Error 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
|
||||
Error 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
|
||||
SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
|
||||
str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: ''
|
||||
Warning 1292 Truncated incorrect date value: ''
|
||||
SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '';
|
||||
str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''
|
||||
NULL
|
||||
|
@ -2115,8 +2115,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
|
||||
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
|
||||
gvid the_success the_fail the_size the_time
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
|
||||
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
|
||||
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 0
|
||||
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 0
|
||||
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
|
||||
gvid the_success the_fail the_size the_time
|
||||
DROP TABLE t1,t2;
|
||||
@ -4093,18 +4093,18 @@ str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
|
||||
and '2007/10/20 00:00:00 GMT'
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT'
|
||||
Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT'
|
||||
Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT'
|
||||
Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT'
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
|
||||
str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6'
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
|
||||
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6';
|
||||
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6'
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6'
|
||||
Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT-6'
|
||||
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
|
||||
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
|
||||
1
|
||||
@ -4179,22 +4179,17 @@ Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
|
||||
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
|
||||
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00'
|
||||
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
|
||||
and '2007/10/20';
|
||||
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
|
||||
and '2007/10/20'
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
|
||||
1
|
||||
set SQL_MODE=DEFAULT;
|
||||
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
|
||||
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: ''
|
||||
Warning 1292 Truncated incorrect date value: ''
|
||||
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
|
||||
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
|
||||
0
|
||||
@ -4221,18 +4216,18 @@ Warnings:
|
||||
Warning 1292 Truncated incorrect date value: '1'
|
||||
select str_to_date('','%Y-%m-%d') = '';
|
||||
str_to_date('','%Y-%m-%d') = ''
|
||||
0
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: ''
|
||||
select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
|
||||
str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL
|
||||
0
|
||||
NULL
|
||||
select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
|
||||
str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'
|
||||
0
|
||||
NULL
|
||||
select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
|
||||
str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL
|
||||
0
|
||||
NULL
|
||||
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
||||
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
|
||||
c22 INT DEFAULT NULL,
|
||||
@ -4629,8 +4624,6 @@ WHERE int_key IN (SELECT 1 FROM A)
|
||||
HAVING date_nokey = '10:41:7'
|
||||
ORDER BY date_key;
|
||||
date_nokey
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
|
||||
DROP TABLE A,C;
|
||||
CREATE TABLE t1 (a INT NOT NULL, b INT);
|
||||
INSERT INTO t1 VALUES (1, 1);
|
||||
@ -4638,7 +4631,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1
|
||||
Note 1003 select 1 AS `a`,1 AS `b` from `test`.`t1` where 1
|
||||
SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
|
||||
a b
|
||||
1 1
|
||||
|
@ -698,7 +698,7 @@ t1 CREATE TABLE "t1" (
|
||||
"x" datetime DEFAULT NULL
|
||||
)
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'x' at row 1
|
||||
Warning 1265 Data truncated for column 'x' at row 1
|
||||
DROP PROCEDURE p1;
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
@ -6484,7 +6484,7 @@ DROP TABLE t1;
|
||||
|
||||
CALL p1('text');
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'v' at row 1
|
||||
Warning 1265 Data truncated for column 'v' at row 1
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
|
@ -41,7 +41,7 @@ INSERT INTO t1 VALUES('0000-00-00');
|
||||
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
|
||||
INSERT IGNORE INTO t1 VALUES('0000-00-00');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'col1' at row 1
|
||||
Warning 1264 Out of range value for column 'col1' at row 1
|
||||
INSERT INTO t1 VALUES ('2004-0-30');
|
||||
INSERT INTO t1 VALUES ('2004-2-30');
|
||||
ERROR 22007: Incorrect date value: '2004-2-30' for column 'col1' at row 1
|
||||
@ -51,7 +51,7 @@ set @@sql_mode='ansi,traditional';
|
||||
INSERT IGNORE INTO t1 VALUES('2004-02-29'),('2004-13-15'),('0000-00-00');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'col1' at row 2
|
||||
Warning 1265 Data truncated for column 'col1' at row 3
|
||||
Warning 1264 Out of range value for column 'col1' at row 3
|
||||
select * from t1;
|
||||
col1
|
||||
2004-01-01
|
||||
@ -1155,12 +1155,12 @@ set sql_mode='traditional';
|
||||
create table t1 (col1 date);
|
||||
insert ignore into t1 values ('0000-00-00');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'col1' at row 1
|
||||
Warning 1264 Out of range value for column 'col1' at row 1
|
||||
insert into t1 select * from t1;
|
||||
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
|
||||
insert ignore into t1 values ('0000-00-00');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'col1' at row 1
|
||||
Warning 1264 Out of range value for column 'col1' at row 1
|
||||
insert ignore into t1 (col1) values (cast('0000-00-00' as date));
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '0000-00-00'
|
||||
|
@ -50,7 +50,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having ((select '1') = 1)
|
||||
Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having ((select 1) = 1)
|
||||
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
1
|
||||
1
|
||||
@ -203,7 +203,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
|
||||
Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,2 AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
|
||||
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
|
||||
a
|
||||
2
|
||||
@ -314,7 +314,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1003 select (select '2' from `test`.`t1` where ('2' = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
|
||||
Note 1003 select (select 2 from `test`.`t1` where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
|
||||
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
|
||||
@ -540,13 +540,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
|
||||
Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)
|
||||
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
Warnings:
|
||||
Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
|
||||
Note 1003 select 3 AS `numreponse` from `test`.`t1` where 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int(1));
|
||||
INSERT INTO t1 VALUES (1);
|
||||
@ -586,7 +586,7 @@ a b
|
||||
select * from t1 where b = (select b from t2 where t1.a = t2.a);
|
||||
a b
|
||||
2 12
|
||||
delete from t1 where b = (select b from t1);
|
||||
delete from t1 where b in (select b from t1);
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
delete from t1 where b = (select b from t2);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
@ -735,7 +735,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
Warnings:
|
||||
Note 1249 Select 3 was reduced during optimization
|
||||
Note 1249 Select 2 was reduced during optimization
|
||||
Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = (1 + 1))
|
||||
Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = 2)
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index
|
||||
@ -4353,13 +4353,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#45061: Incorrectly market field caused wrong result.
|
||||
|
@ -1,4 +1,4 @@
|
||||
set timestamp=1;
|
||||
SELECT sleep(1),NOW()-SYSDATE() as zero;
|
||||
sleep(1) zero
|
||||
0 0.000000
|
||||
0 0
|
||||
|
@ -890,13 +890,9 @@ DROP TABLE b15776;
|
||||
CREATE TABLE b15776 (a year(-2));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
|
||||
CREATE TABLE b15776 (a timestamp(4294967294));
|
||||
Warnings:
|
||||
Warning 1287 'TIMESTAMP(4294967294)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
DROP TABLE b15776;
|
||||
ERROR 42000: Too big precision 4294967294 specified for column 'a'. Maximum is 6.
|
||||
CREATE TABLE b15776 (a timestamp(4294967295));
|
||||
Warnings:
|
||||
Warning 1287 'TIMESTAMP(4294967295)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
DROP TABLE b15776;
|
||||
ERROR 42000: Too big precision 4294967295 specified for column 'a'. Maximum is 6.
|
||||
CREATE TABLE b15776 (a timestamp(4294967296));
|
||||
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
|
||||
CREATE TABLE b15776 (a timestamp(-1));
|
||||
|
@ -139,8 +139,8 @@ 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 'd' at row 1
|
||||
Warning 1265 Data truncated 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;
|
||||
@ -204,23 +204,18 @@ SET SQL_MODE=TRADITIONAL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
SELECT * FROM t1 WHERE a = '0000-00-00';
|
||||
a
|
||||
0000-00-00
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 0
|
||||
SELECT * FROM t2 WHERE a = '0000-00-00';
|
||||
a
|
||||
0000-00-00
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 0
|
||||
INSERT INTO t1 VALUES ('0000-00-00');
|
||||
ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
SET SQL_MODE=DEFAULT;
|
||||
@ -242,23 +237,14 @@ SET SQL_MODE=TRADITIONAL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
a
|
||||
1000-00-00
|
||||
1000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 0
|
||||
SELECT * FROM t2 WHERE a = '1000-00-00';
|
||||
a
|
||||
1000-00-00
|
||||
1000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 0
|
||||
INSERT INTO t1 VALUES ('1000-00-00');
|
||||
ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
SET SQL_MODE=DEFAULT;
|
||||
|
@ -52,7 +52,7 @@ t
|
||||
truncate table t1;
|
||||
insert into t1 values("2003-0303 12:13:14");
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 't' at row 1
|
||||
Warning 1265 Data truncated for column 't' at row 1
|
||||
select * from t1;
|
||||
t
|
||||
0000-00-00 00:00:00
|
||||
@ -115,12 +115,12 @@ create table t1 (t datetime);
|
||||
insert into t1 values (20030102030460),(20030102036301),(20030102240401),
|
||||
(20030132030401),(20031302030401),(100001202030401);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 't' at row 1
|
||||
Warning 1264 Out of range value for column 't' at row 2
|
||||
Warning 1264 Out of range value for column 't' at row 3
|
||||
Warning 1264 Out of range value for column 't' at row 4
|
||||
Warning 1264 Out of range value for column 't' at row 5
|
||||
Warning 1264 Out of range value for column 't' at row 6
|
||||
Warning 1265 Data truncated for column 't' at row 1
|
||||
Warning 1265 Data truncated for column 't' at row 2
|
||||
Warning 1265 Data truncated for column 't' at row 3
|
||||
Warning 1265 Data truncated for column 't' at row 4
|
||||
Warning 1265 Data truncated for column 't' at row 5
|
||||
Warning 1265 Data truncated for column 't' at row 6
|
||||
select * from t1;
|
||||
t
|
||||
0000-00-00 00:00:00
|
||||
@ -134,12 +134,12 @@ insert into t1 values
|
||||
("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"),
|
||||
("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00");
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 't' at row 1
|
||||
Warning 1264 Out of range value for column 't' at row 2
|
||||
Warning 1264 Out of range value for column 't' at row 3
|
||||
Warning 1264 Out of range value for column 't' at row 4
|
||||
Warning 1264 Out of range value for column 't' at row 5
|
||||
Warning 1264 Out of range value for column 't' at row 6
|
||||
Warning 1265 Data truncated for column 't' at row 1
|
||||
Warning 1265 Data truncated for column 't' at row 2
|
||||
Warning 1265 Data truncated for column 't' at row 3
|
||||
Warning 1265 Data truncated for column 't' at row 4
|
||||
Warning 1265 Data truncated for column 't' at row 5
|
||||
Warning 1265 Data truncated for column 't' at row 6
|
||||
select * from t1;
|
||||
t
|
||||
0000-00-00 00:00:00
|
||||
@ -151,8 +151,8 @@ t
|
||||
delete from t1;
|
||||
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 't' at row 1
|
||||
Warning 1264 Out of range value for column 't' at row 2
|
||||
Warning 1265 Data truncated for column 't' at row 1
|
||||
Warning 1265 Data truncated for column 't' at row 2
|
||||
select * from t1 order by t;
|
||||
t
|
||||
0000-00-00 00:00:00
|
||||
@ -170,7 +170,7 @@ dt
|
||||
drop table t1;
|
||||
select cast('2006-12-05 22:10:10' as datetime) + 0;
|
||||
cast('2006-12-05 22:10:10' as datetime) + 0
|
||||
20061205221010.000000
|
||||
20061205221010
|
||||
CREATE TABLE t1(a DATETIME NOT NULL);
|
||||
INSERT INTO t1 VALUES ('20060606155555');
|
||||
SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
|
||||
@ -352,7 +352,7 @@ least(cast('01-01-01' as date), '01-01-02')
|
||||
2001-01-01
|
||||
select greatest(cast('01-01-01' as date), '01-01-02');
|
||||
greatest(cast('01-01-01' as date), '01-01-02')
|
||||
01-01-02
|
||||
2001-01-02
|
||||
select least(cast('01-01-01' as date), '01-01-02') + 0;
|
||||
least(cast('01-01-01' as date), '01-01-02') + 0
|
||||
20010101
|
||||
@ -423,11 +423,11 @@ f1
|
||||
2001-01-01 00:00:00
|
||||
2002-02-02 00:00:00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 0
|
||||
select * from t1 where f1 between 20020101 and 2007010100000;
|
||||
f1
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1
|
||||
Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 0
|
||||
drop table t1;
|
||||
#
|
||||
# Bug#27216: functions with parameters of different date types may
|
||||
@ -497,7 +497,8 @@ select * from t1 where (convert(f1,datetime)) != 1;
|
||||
f1
|
||||
15:44:44
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '0000-00-00 45:44:44'
|
||||
Warning 1292 Truncated incorrect datetime value: '45:44:44'
|
||||
Warning 1292 Truncated incorrect datetime value: '1'
|
||||
drop table t1;
|
||||
create table t1 (a tinyint);
|
||||
insert into t1 values (), (), ();
|
||||
@ -517,7 +518,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select '1' AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` where <in_optimizer>('1',<exists>(select 1 from `test`.`t1` `x1` where 0))
|
||||
Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` `x1` where 0))
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id cur_date
|
||||
@ -529,7 +530,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select '1' AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` where <in_optimizer>('1',<exists>(select 1 from `test`.`t2` `x1` where 0))
|
||||
Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` where <in_optimizer>(1,<exists>(select 1 from `test`.`t2` `x1` where 0))
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id cur_date
|
||||
|
211
mysql-test/r/type_datetime_hires.result
Normal file
211
mysql-test/r/type_datetime_hires.result
Normal file
@ -0,0 +1,211 @@
|
||||
drop table if exists t1, t2, t3;
|
||||
create table t1 (a datetime(7));
|
||||
ERROR 42000: Too big precision 7 specified for column 'a'. Maximum is 6.
|
||||
create table t1 (a datetime(3));
|
||||
insert t1 values ('2010-12-11 01:02:03.4567');
|
||||
insert t1 values (20101211010203.45678);
|
||||
insert t1 values (20101211030405.789e0);
|
||||
insert t1 values (99991231235959e1);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 03:04:05.789
|
||||
0000-00-00 00:00:00.000
|
||||
select truncate(a, 6) from t1;
|
||||
truncate(a, 6)
|
||||
20101211010203.457031
|
||||
20101211010203.457031
|
||||
20101211030405.789062
|
||||
0.000000
|
||||
select a DIV 1 from t1;
|
||||
a DIV 1
|
||||
20101211010203
|
||||
20101211010203
|
||||
20101211030405
|
||||
0
|
||||
select group_concat(distinct a) from t1;
|
||||
group_concat(distinct a)
|
||||
2010-12-11 01:02:03.456,2010-12-11 03:04:05.789,0000-00-00 00:00:00.000
|
||||
alter table t1 engine=innodb;
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 03:04:05.789
|
||||
0000-00-00 00:00:00.000
|
||||
drop table t1;
|
||||
create table t1 (a datetime(4)) engine=innodb;
|
||||
insert t1 values ('2010-12-11 01:02:03.456789');
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:03.4567
|
||||
select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
|
||||
extract(microsecond from a + interval 100 microsecond)
|
||||
456800
|
||||
select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
|
||||
a
|
||||
2010-12-11 01:02:03.4567
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` datetime(4) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
a datetime(4) YES NULL
|
||||
select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1';
|
||||
table_name t1
|
||||
column_name a
|
||||
column_default NULL
|
||||
is_nullable YES
|
||||
data_type datetime
|
||||
character_maximum_length NULL
|
||||
character_octet_length NULL
|
||||
numeric_precision NULL
|
||||
numeric_scale NULL
|
||||
datetime_precision 4
|
||||
character_set_name NULL
|
||||
collation_name NULL
|
||||
column_type datetime(4)
|
||||
column_key
|
||||
extra
|
||||
select a, a+interval 9876543 microsecond from t1;
|
||||
a a+interval 9876543 microsecond
|
||||
2010-12-11 01:02:03.4567 2010-12-11 01:02:13.333243
|
||||
update t1 set a=a+interval 9876543 microsecond;
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:13.3332
|
||||
insert t1 select a + interval 2 year from t1;
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:13.3332
|
||||
2012-12-11 01:02:13.3332
|
||||
delete from t1 where a < 20110101;
|
||||
select * from t1;
|
||||
a
|
||||
2012-12-11 01:02:13.3332
|
||||
create table t2 select * from t1;
|
||||
create table t3 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` datetime(4) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` datetime(4) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a datetime(6), b datetime(6));
|
||||
create procedure foo(x datetime, y datetime(4)) insert into t1 values (x, y);
|
||||
call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
|
||||
select * from t1;
|
||||
a b
|
||||
2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
|
||||
create procedure bar(a int, c datetime(5))
|
||||
begin
|
||||
declare b datetime(4);
|
||||
set b = c + interval a microsecond;
|
||||
insert t1 values (b, c + interval a microsecond);
|
||||
end|
|
||||
call bar(1111111, '2011-01-02 3:4:5.123456');
|
||||
select * from t1;
|
||||
a b
|
||||
2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
|
||||
2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
|
||||
drop procedure foo;
|
||||
drop procedure bar;
|
||||
create function xyz(s char(20)) returns datetime(4)
|
||||
return addtime('2010-10-10 10:10:10.101010', s);
|
||||
select xyz('1:1:1.010101');
|
||||
xyz('1:1:1.010101')
|
||||
2010-10-10 11:11:11.1111
|
||||
drop function xyz;
|
||||
create view v1 as select * from t1 group by a,b;
|
||||
select * from v1;
|
||||
a b
|
||||
2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
|
||||
2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
|
||||
show columns from v1;
|
||||
Field Type Null Key Default Extra
|
||||
a datetime(6) YES NULL
|
||||
b datetime(6) YES NULL
|
||||
create table t2 select * from v1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` datetime(6) DEFAULT NULL,
|
||||
`b` datetime(6) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (
|
||||
taken datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
id int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (id,taken),
|
||||
KEY taken (taken)
|
||||
)
|
||||
PARTITION BY RANGE (to_days(taken))
|
||||
(
|
||||
PARTITION p01 VALUES LESS THAN (732920),
|
||||
PARTITION p02 VALUES LESS THAN (732950),
|
||||
PARTITION p03 VALUES LESS THAN MAXVALUE);
|
||||
INSERT INTO t1 VALUES
|
||||
('2006-09-27 21:50:01.123456',0),
|
||||
('2006-09-27 21:50:01.123456',1),
|
||||
('2006-09-27 21:50:01.123456',2),
|
||||
('2006-09-28 21:50:01.123456',3),
|
||||
('2006-09-29 21:50:01.123456',4),
|
||||
('2006-09-29 21:50:01.123456',5),
|
||||
('2006-09-30 21:50:01.123456',6),
|
||||
('2006-10-01 21:50:01.123456',7),
|
||||
('2006-10-02 21:50:01.123456',8),
|
||||
('2006-10-02 21:50:01.123456',9);
|
||||
SELECT id,to_days(taken) FROM t1 order by 2;
|
||||
id to_days(taken)
|
||||
0 732946
|
||||
1 732946
|
||||
2 732946
|
||||
3 732947
|
||||
5 732948
|
||||
4 732948
|
||||
6 732949
|
||||
7 732950
|
||||
8 732951
|
||||
9 732951
|
||||
CREATE TABLE t2 (
|
||||
taken datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
id int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (id,taken),
|
||||
KEY taken (taken)
|
||||
)
|
||||
PARTITION BY RANGE (extract(microsecond from taken))
|
||||
(
|
||||
PARTITION p01 VALUES LESS THAN (123000),
|
||||
PARTITION p02 VALUES LESS THAN (500000),
|
||||
PARTITION p03 VALUES LESS THAN MAXVALUE);
|
||||
INSERT INTO t2 VALUES
|
||||
('2006-09-27 21:50:01',0),
|
||||
('2006-09-27 21:50:01.1',1),
|
||||
('2006-09-27 21:50:01.12',2),
|
||||
('2006-09-28 21:50:01.123',3),
|
||||
('2006-09-29 21:50:01.1234',4),
|
||||
('2006-09-29 21:50:01.12345',5),
|
||||
('2006-09-30 21:50:01.123456',6),
|
||||
('2006-10-01 21:50:01.56',7),
|
||||
('2006-10-02 21:50:01.567',8),
|
||||
('2006-10-02 21:50:01.5678',9);
|
||||
select table_name,partition_name,partition_method,partition_expression,partition_description,table_rows from information_schema.partitions where table_name in ('t1', 't2');
|
||||
table_name partition_name partition_method partition_expression partition_description table_rows
|
||||
t1 p01 RANGE to_days(taken) 732920 0
|
||||
t1 p02 RANGE to_days(taken) 732950 7
|
||||
t1 p03 RANGE to_days(taken) MAXVALUE 3
|
||||
t2 p01 RANGE extract(microsecond from taken) 123000 3
|
||||
t2 p02 RANGE extract(microsecond from taken) 500000 4
|
||||
t2 p03 RANGE extract(microsecond from taken) MAXVALUE 3
|
||||
drop table t1, t2;
|
@ -26,7 +26,7 @@ t
|
||||
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 't' at row 1
|
||||
Warning 1264 Out of range value for column 't' at row 2
|
||||
Warning 1265 Data truncated for column 't' at row 2
|
||||
Warning 1264 Out of range value for column 't' at row 3
|
||||
Warning 1264 Out of range value for column 't' at row 4
|
||||
Warning 1265 Data truncated for column 't' at row 6
|
||||
@ -148,3 +148,9 @@ TIMESTAMP(f1,'1')
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests
|
||||
create table t1 (a time);
|
||||
insert t1 values (-131415);
|
||||
select * from t1;
|
||||
a
|
||||
-13:14:15
|
||||
drop table t1;
|
||||
|
147
mysql-test/r/type_time_hires.result
Normal file
147
mysql-test/r/type_time_hires.result
Normal file
@ -0,0 +1,147 @@
|
||||
drop table if exists t1, t2, t3;
|
||||
create table t1 (a time(7));
|
||||
ERROR 42000: Too big precision 7 specified for column 'a'. Maximum is 6.
|
||||
create table t1 (a time(3));
|
||||
insert t1 values ('2010-12-11 01:02:03.4567');
|
||||
insert t1 values (20101211010203.45678);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
insert t1 values (20101211030405.789e0);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
insert t1 values (99991231235959e1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
01:02:03.456
|
||||
838:59:59.999
|
||||
838:59:59.999
|
||||
838:59:59.999
|
||||
select truncate(a, 6) from t1;
|
||||
truncate(a, 6)
|
||||
10203.456000
|
||||
8385959.999000
|
||||
8385959.999000
|
||||
8385959.999000
|
||||
select a DIV 1 from t1;
|
||||
a DIV 1
|
||||
10203
|
||||
8385959
|
||||
8385959
|
||||
8385959
|
||||
select group_concat(distinct a) from t1;
|
||||
group_concat(distinct a)
|
||||
01:02:03.456,838:59:59.999
|
||||
alter table t1 engine=innodb;
|
||||
select * from t1;
|
||||
a
|
||||
01:02:03.456
|
||||
838:59:59.999
|
||||
838:59:59.999
|
||||
838:59:59.999
|
||||
drop table t1;
|
||||
create table t1 (a time(4)) engine=innodb;
|
||||
insert t1 values ('2010-12-11 01:02:03.456789');
|
||||
select * from t1;
|
||||
a
|
||||
01:02:03.4567
|
||||
select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
|
||||
extract(microsecond from a + interval 100 microsecond)
|
||||
select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
|
||||
a
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` time(4) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
a time(4) YES NULL
|
||||
select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1';
|
||||
table_name t1
|
||||
column_name a
|
||||
column_default NULL
|
||||
is_nullable YES
|
||||
data_type time
|
||||
character_maximum_length NULL
|
||||
character_octet_length NULL
|
||||
numeric_precision NULL
|
||||
numeric_scale NULL
|
||||
datetime_precision 4
|
||||
character_set_name NULL
|
||||
collation_name NULL
|
||||
column_type time(4)
|
||||
column_key
|
||||
extra
|
||||
select a, a+interval 9876543 microsecond from t1;
|
||||
a a+interval 9876543 microsecond
|
||||
01:02:03.4567 01:02:13.333243
|
||||
update t1 set a=a+interval 9876543 microsecond;
|
||||
select * from t1;
|
||||
a
|
||||
01:02:13.3332
|
||||
insert t1 select a + interval 2 year from t1;
|
||||
select * from t1;
|
||||
a
|
||||
01:02:13.3332
|
||||
01:02:13.3332
|
||||
delete from t1 where a < 20110101;
|
||||
select * from t1;
|
||||
a
|
||||
create table t2 select * from t1;
|
||||
create table t3 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` time(4) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` time(4) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a time(6), b time(6));
|
||||
create procedure foo(x time, y time(4)) insert into t1 values (x, y);
|
||||
call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
|
||||
select * from t1;
|
||||
a b
|
||||
04:05:06.000000 04:05:06.789100
|
||||
create procedure bar(a int, c time(5))
|
||||
begin
|
||||
declare b time(4);
|
||||
set b = c + interval a microsecond;
|
||||
insert t1 values (b, c + interval a microsecond);
|
||||
end|
|
||||
call bar(1111111, '2011-01-02 3:4:5.123456');
|
||||
select * from t1;
|
||||
a b
|
||||
04:05:06.000000 04:05:06.789100
|
||||
03:04:06.234500 03:04:06.234561
|
||||
drop procedure foo;
|
||||
drop procedure bar;
|
||||
create function xyz(s char(20)) returns time(4)
|
||||
return addtime('2010-10-10 10:10:10.101010', s);
|
||||
select xyz('1:1:1.010101');
|
||||
xyz('1:1:1.010101')
|
||||
11:11:11.1111
|
||||
drop function xyz;
|
||||
create view v1 as select * from t1 group by a,b;
|
||||
select * from v1;
|
||||
a b
|
||||
03:04:06.234500 03:04:06.234561
|
||||
04:05:06.000000 04:05:06.789100
|
||||
show columns from v1;
|
||||
Field Type Null Key Default Extra
|
||||
a time(6) YES NULL
|
||||
b time(6) YES NULL
|
||||
create table t2 select * from v1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` time(6) DEFAULT NULL,
|
||||
`b` time(6) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
@ -97,30 +97,6 @@ date date_time time_stamp
|
||||
2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00
|
||||
2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00
|
||||
drop table t1;
|
||||
create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
|
||||
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
|
||||
t14 timestamp(14));
|
||||
Warnings:
|
||||
Warning 1287 'TIMESTAMP(2)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
Warning 1287 'TIMESTAMP(4)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
Warning 1287 'TIMESTAMP(6)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
Warning 1287 'TIMESTAMP(8)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
Warning 1287 'TIMESTAMP(10)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
Warning 1287 'TIMESTAMP(12)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
Warning 1287 'TIMESTAMP(14)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
|
||||
insert t1 values (0,0,0,0,0,0,0),
|
||||
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
|
||||
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
|
||||
"1997-12-31 23:47:59");
|
||||
select * from t1;
|
||||
t2 t4 t6 t8 t10 t12 t14
|
||||
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
|
||||
select * from t1;
|
||||
t2 t4 t6 t8 t10 t12 t14
|
||||
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
|
||||
drop table t1;
|
||||
create table t1 (ix timestamp);
|
||||
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
|
||||
Warnings:
|
||||
@ -436,12 +412,12 @@ max(t)
|
||||
2004-02-01 00:00:00
|
||||
drop table t1;
|
||||
set sql_mode='maxdb';
|
||||
create table t1 (a timestamp, b timestamp(19));
|
||||
create table t1 (a timestamp, b timestamp(5));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE "t1" (
|
||||
"a" datetime DEFAULT NULL,
|
||||
"b" datetime DEFAULT NULL
|
||||
"b" datetime(5) DEFAULT NULL
|
||||
)
|
||||
set sql_mode='';
|
||||
drop table t1;
|
||||
|
153
mysql-test/r/type_timestamp_hires.result
Normal file
153
mysql-test/r/type_timestamp_hires.result
Normal file
@ -0,0 +1,153 @@
|
||||
drop table if exists t1, t2, t3;
|
||||
create table t1 (a timestamp(7));
|
||||
ERROR 42000: Too big precision 7 specified for column 'a'. Maximum is 6.
|
||||
create table t1 (a timestamp(3));
|
||||
insert t1 values ('2010-12-11 01:02:03.4567');
|
||||
insert t1 values (20101211010203.45678);
|
||||
insert t1 values (20101211030405.789e0);
|
||||
insert t1 values (99991231235959e1);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 03:04:05.789
|
||||
0000-00-00 00:00:00.000
|
||||
select truncate(a, 6) from t1;
|
||||
truncate(a, 6)
|
||||
20101211010203.457031
|
||||
20101211010203.457031
|
||||
20101211030405.789062
|
||||
0.000000
|
||||
select a DIV 1 from t1;
|
||||
a DIV 1
|
||||
20101211010203
|
||||
20101211010203
|
||||
20101211030405
|
||||
0
|
||||
select group_concat(distinct a) from t1;
|
||||
group_concat(distinct a)
|
||||
2010-12-11 01:02:03.456,2010-12-11 03:04:05.789,0000-00-00 00:00:00.000
|
||||
alter table t1 engine=innodb;
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 03:04:05.789
|
||||
0000-00-00 00:00:00.000
|
||||
drop table t1;
|
||||
create table t1 (a timestamp(4)) engine=innodb;
|
||||
insert t1 values ('2010-12-11 01:02:03.456789');
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:03.4567
|
||||
select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
|
||||
extract(microsecond from a + interval 100 microsecond)
|
||||
456800
|
||||
select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
|
||||
a
|
||||
2010-12-11 01:02:03.4567
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
a timestamp(4) NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
|
||||
select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1';
|
||||
table_name t1
|
||||
column_name a
|
||||
column_default CURRENT_TIMESTAMP
|
||||
is_nullable NO
|
||||
data_type timestamp
|
||||
character_maximum_length NULL
|
||||
character_octet_length NULL
|
||||
numeric_precision NULL
|
||||
numeric_scale NULL
|
||||
datetime_precision 4
|
||||
character_set_name NULL
|
||||
collation_name NULL
|
||||
column_type timestamp(4)
|
||||
column_key
|
||||
extra on update CURRENT_TIMESTAMP
|
||||
select a, a+interval 9876543 microsecond from t1;
|
||||
a a+interval 9876543 microsecond
|
||||
2010-12-11 01:02:03.4567 2010-12-11 01:02:13.333243
|
||||
update t1 set a=a+interval 9876543 microsecond;
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:13.3332
|
||||
insert t1 select a + interval 2 year from t1;
|
||||
select * from t1;
|
||||
a
|
||||
2010-12-11 01:02:13.3332
|
||||
2012-12-11 01:02:13.3332
|
||||
delete from t1 where a < 20110101;
|
||||
select * from t1;
|
||||
a
|
||||
2012-12-11 01:02:13.3332
|
||||
create table t2 select * from t1;
|
||||
create table t3 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a timestamp(6), b timestamp(6));
|
||||
create procedure foo(x timestamp, y timestamp(4)) insert into t1 values (x, y);
|
||||
call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
|
||||
select * from t1;
|
||||
a b
|
||||
2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
|
||||
create procedure bar(a int, c timestamp(5))
|
||||
begin
|
||||
declare b timestamp(4);
|
||||
set b = c + interval a microsecond;
|
||||
insert t1 values (b, c + interval a microsecond);
|
||||
end|
|
||||
call bar(1111111, '2011-01-02 3:4:5.123456');
|
||||
select * from t1;
|
||||
a b
|
||||
2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
|
||||
2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
|
||||
drop procedure foo;
|
||||
drop procedure bar;
|
||||
create function xyz(s char(20)) returns timestamp(4)
|
||||
return addtime('2010-10-10 10:10:10.101010', s);
|
||||
select xyz('1:1:1.010101');
|
||||
xyz('1:1:1.010101')
|
||||
2010-10-10 11:11:11.1111
|
||||
drop function xyz;
|
||||
create view v1 as select * from t1 group by a,b;
|
||||
select * from v1;
|
||||
a b
|
||||
2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
|
||||
2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
|
||||
show columns from v1;
|
||||
Field Type Null Key Default Extra
|
||||
a timestamp(6) NO 0000-00-00 00:00:00.000000
|
||||
b timestamp(6) NO 0000-00-00 00:00:00.000000
|
||||
create table t2 select * from v1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
|
||||
`b` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456, time_zone='+03:00';
|
||||
create table t1 (a timestamp(5));
|
||||
insert t1 values ();
|
||||
select * from t1;
|
||||
a
|
||||
2011-01-01 01:01:01.12345
|
||||
drop table t1;
|
@ -522,7 +522,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 (select '1' AS `a`,'1' AS `b` from `test`.`t1` where ('1' = 1)) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where ('1' = 1))
|
||||
Note 1003 (select 1 AS `a`,1 AS `b` from `test`.`t1` where (1 = 1)) union (select 1 AS `a`,10 AS `b` from `test`.`t2` where (1 = 1))
|
||||
(select * from t1 where a=5) union (select * from t2 where a=1);
|
||||
a b
|
||||
1 10
|
||||
|
@ -15,7 +15,7 @@ explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 const UNIQ UNIQ 8 const 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select '00000001' AS `ID`,'004084688022709641610' AS `UNIQ` from `test`.`t1` where 1
|
||||
Note 1003 select 00000001 AS `ID`,004084688022709641610 AS `UNIQ` from `test`.`t1` where 1
|
||||
drop table t1;
|
||||
select x'hello';
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1
|
||||
|
24
mysql-test/suite/rpl/include/hrtime.inc
Normal file
24
mysql-test/suite/rpl/include/hrtime.inc
Normal file
@ -0,0 +1,24 @@
|
||||
--source include/master-slave.inc
|
||||
|
||||
set time_zone='+03:00';
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
|
||||
|
||||
create table t1 (a timestamp(4), b varchar(100), c datetime(2));
|
||||
|
||||
insert t1 (b,c) values (now(6), now(6));
|
||||
|
||||
insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010');
|
||||
|
||||
set timestamp=unix_timestamp('2022-02-02 02:02:02') + 0.654321;
|
||||
insert t1 (b,c) values (now(), now());
|
||||
insert t1 (b,c) values (0,0);
|
||||
insert t1 (a,b,c) values (0,0,now(6));
|
||||
|
||||
select * from t1;
|
||||
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
select * from t1;
|
||||
connection master;
|
||||
drop table t1;
|
||||
|
69
mysql-test/suite/rpl/r/rpl_hrtime.result
Normal file
69
mysql-test/suite/rpl/r/rpl_hrtime.result
Normal file
@ -0,0 +1,69 @@
|
||||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
set time_zone='+03:00';
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
|
||||
create table t1 (a timestamp(4), b varchar(100), c datetime(2));
|
||||
insert t1 (b,c) values (now(6), now(6));
|
||||
insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010');
|
||||
set timestamp=unix_timestamp('2022-02-02 02:02:02') + 0.654321;
|
||||
insert t1 (b,c) values (now(), now());
|
||||
insert t1 (b,c) values (0,0);
|
||||
insert t1 (a,b,c) values (0,0,now(6));
|
||||
select * from t1;
|
||||
a b c
|
||||
2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
|
||||
2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
|
||||
2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
|
||||
2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
|
||||
0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
|
||||
select * from t1;
|
||||
a b c
|
||||
2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
|
||||
2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
|
||||
2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
|
||||
2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
|
||||
0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
|
||||
drop table t1;
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
DELIMITER /*!*/;
|
||||
ROLLBACK/*!*/;
|
||||
use test/*!*/;
|
||||
SET TIMESTAMP=1293832861/*!*/;
|
||||
SET @@session.pseudo_thread_id=999999999/*!*/;
|
||||
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
|
||||
SET @@session.sql_mode=0/*!*/;
|
||||
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
|
||||
/*!\C latin1 *//*!*/;
|
||||
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
|
||||
SET @@session.lc_time_names=0/*!*/;
|
||||
SET @@session.collation_database=DEFAULT/*!*/;
|
||||
create table t1 (a timestamp(4), b varchar(100), c datetime(2))
|
||||
/*!*/;
|
||||
SET TIMESTAMP=1293832861.123456/*!*/;
|
||||
SET @@session.time_zone='+03:00'/*!*/;
|
||||
insert t1 (b,c) values (now(6), now(6))
|
||||
/*!*/;
|
||||
SET TIMESTAMP=1293832861/*!*/;
|
||||
insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010')
|
||||
/*!*/;
|
||||
SET TIMESTAMP=1643756522.654321/*!*/;
|
||||
insert t1 (b,c) values (now(), now())
|
||||
/*!*/;
|
||||
SET TIMESTAMP=1643756522.654321/*!*/;
|
||||
insert t1 (b,c) values (0,0)
|
||||
/*!*/;
|
||||
SET TIMESTAMP=1643756522.654321/*!*/;
|
||||
insert t1 (a,b,c) values (0,0,now(6))
|
||||
/*!*/;
|
||||
SET TIMESTAMP=1643756522/*!*/;
|
||||
drop table t1
|
||||
/*!*/;
|
||||
DELIMITER ;
|
||||
# End of log file
|
||||
ROLLBACK /* added by mysqlbinlog */;
|
||||
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
30
mysql-test/suite/rpl/r/rpl_hrtime_row.result
Normal file
30
mysql-test/suite/rpl/r/rpl_hrtime_row.result
Normal file
@ -0,0 +1,30 @@
|
||||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
set time_zone='+03:00';
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
|
||||
create table t1 (a timestamp(4), b varchar(100), c datetime(2));
|
||||
insert t1 (b,c) values (now(6), now(6));
|
||||
insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010');
|
||||
set timestamp=unix_timestamp('2022-02-02 02:02:02') + 0.654321;
|
||||
insert t1 (b,c) values (now(), now());
|
||||
insert t1 (b,c) values (0,0);
|
||||
insert t1 (a,b,c) values (0,0,now(6));
|
||||
select * from t1;
|
||||
a b c
|
||||
2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
|
||||
2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
|
||||
2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
|
||||
2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
|
||||
0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
|
||||
select * from t1;
|
||||
a b c
|
||||
2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
|
||||
2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
|
||||
2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
|
||||
2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
|
||||
0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
|
||||
drop table t1;
|
@ -29,8 +29,8 @@ Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
Warning 1265 Data truncated for column 'a' at row 2
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1264 Out of range value for column 'a' at row 2
|
||||
Warning 1264 Out of range value for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'd' at row 2
|
||||
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
|
||||
select * from rewrite.t1;
|
||||
@ -44,7 +44,7 @@ load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1264 Out of range value for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'd' at row 2
|
||||
select * from rewrite.t1;
|
||||
a b c d
|
||||
|
@ -139,6 +139,8 @@ create table t2 select rpad(UUID(),100,' ');
|
||||
create table t3 select 1 union select UUID();
|
||||
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
|
||||
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '3' for column '<result>' at row 1
|
||||
insert into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
|
||||
create procedure foo()
|
||||
begin
|
||||
|
@ -486,8 +486,8 @@ id num text
|
||||
52 NULL latin7
|
||||
53 NULL latin7_estonian_cs
|
||||
54 NULL latin7
|
||||
55 NULL 47114711
|
||||
56 NULL 47124712
|
||||
55 NULL 47114711.000000
|
||||
56 NULL 47124712.000000
|
||||
57 NULL 1616
|
||||
58 NULL 1717
|
||||
Comparing tables master:test.tstmt and master:test.tproc
|
||||
|
7
mysql-test/suite/rpl/t/rpl_hrtime.test
Normal file
7
mysql-test/suite/rpl/t/rpl_hrtime.test
Normal file
@ -0,0 +1,7 @@
|
||||
--source include/have_binlog_format_mixed_or_statement.inc
|
||||
|
||||
--source suite/rpl/include/hrtime.inc
|
||||
|
||||
let $MYSQLD_DATADIR= `select @@datadir`;
|
||||
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001
|
||||
|
3
mysql-test/suite/rpl/t/rpl_hrtime_row.test
Normal file
3
mysql-test/suite/rpl/t/rpl_hrtime_row.test
Normal file
@ -0,0 +1,3 @@
|
||||
--source include/have_binlog_format_row.inc
|
||||
--source suite/rpl/include/hrtime.inc
|
||||
|
@ -614,3 +614,13 @@ SET @@sort_buffer_size = @old_sort_buffer_size;
|
||||
SET @@max_heap_table_size = @old_max_heap_table_size;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
#
|
||||
# test_if_equality_guarantees_uniqueness() and dates
|
||||
#
|
||||
create table t1 (a varchar(100));
|
||||
insert t1 values ('2010-10-10'), ('20101010');
|
||||
select * from t1 where a = DATE('2010-10-10');
|
||||
select distinct a from t1 where a = DATE('2010-10-10');
|
||||
drop table t1;
|
||||
|
||||
|
@ -860,3 +860,29 @@ SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
select time(' 1 02:03:04') + interval 9 microsecond;
|
||||
select time(' 1 02:03:04') - interval 9 microsecond;
|
||||
select time('-1 02:03:04') + interval 9 microsecond;
|
||||
select time('-1 02:03:04') - interval 9 microsecond;
|
||||
select time(' 1 02:03:04') + interval '4:4:4' hour_second;
|
||||
select time(' 1 02:03:04') - interval '4:4:4' hour_second;
|
||||
select time('-1 02:03:04') + interval '4:4:4' hour_second;
|
||||
select time('-1 02:03:04') - interval '4:4:4' hour_second;
|
||||
select time(' 1 02:03:04') + interval 2 day;
|
||||
select time(' 1 02:03:04') - interval 2 day;
|
||||
select time('-1 02:03:04') + interval 2 day;
|
||||
select time('-1 02:03:04') - interval 2 day;
|
||||
|
||||
# specially constructed queries to reach obscure places in the code
|
||||
# not touched by the more "normal" queries (and to increase the coverage)
|
||||
select cast('131415.123e0' as time);
|
||||
select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
|
||||
select least(time('1:2:3'), '01:02:04', null) div 1;
|
||||
select truncate(least(time('1:2:3'), '01:02:04', null), 6);
|
||||
select cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1));
|
||||
select unix_timestamp(null);
|
||||
select truncate(date('2010-40-10'), 6);
|
||||
select extract(month from '2010-40-50');
|
||||
select subtime('0000-00-10 10:10:10', '30 10:00:00');
|
||||
|
||||
|
80
mysql-test/t/func_time_hires.test
Normal file
80
mysql-test/t/func_time_hires.test
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456, time_zone='+03:00';
|
||||
|
||||
--vertical_results
|
||||
select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
|
||||
select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
|
||||
current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
|
||||
time_to_sec('12:34:56.789');
|
||||
select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
|
||||
select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
|
||||
--horizontal_results
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
select current_timestamp(7);
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
select curtime(7);
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
|
||||
sec_to_time(1234567e-2), now(), curtime(0),
|
||||
utc_timestamp(1), utc_time(2), current_time(3),
|
||||
current_timestamp(4), localtime(5), localtimestamp(6),
|
||||
time_to_sec('12:34:56'), time_to_sec('12:34:56.789');
|
||||
show create table t1;
|
||||
--query_vertical select * from t1
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# precision of expressions
|
||||
#
|
||||
set @a=cast('2011-01-02 12:13:14' as datetime);
|
||||
select @a + interval 1 minute;
|
||||
select @a + interval 10 microsecond;
|
||||
select @a + interval 10 microsecond + interval 999990 microsecond;
|
||||
|
||||
#
|
||||
# CAST
|
||||
#
|
||||
set @a='2011-01-02 12:13:14.123456';
|
||||
create table t1 select CAST(@a AS DATETIME) as dauto,
|
||||
CAST(@a AS DATETIME(0)) as d0,
|
||||
CAST(@a AS DATETIME(1)) as d1,
|
||||
CAST(@a AS DATETIME(2)) as d2,
|
||||
CAST(@a AS DATETIME(3)) as d3,
|
||||
CAST(@a AS DATETIME(4)) as d4,
|
||||
CAST(@a AS DATETIME(5)) as d5,
|
||||
CAST(@a AS DATETIME(6)) as d6,
|
||||
CAST(@a AS TIME) as tauto,
|
||||
CAST(@a AS TIME(0)) as t0,
|
||||
CAST(@a AS TIME(1)) as t1,
|
||||
CAST(@a AS TIME(2)) as t2,
|
||||
CAST(@a AS TIME(3)) as t3,
|
||||
CAST(@a AS TIME(4)) as t4,
|
||||
CAST(@a AS TIME(5)) as t5,
|
||||
CAST(@a AS TIME(6)) as t6;
|
||||
show create table t1;
|
||||
--query_vertical select * from t1
|
||||
drop table t1;
|
||||
|
||||
--error ER_TOO_BIG_PRECISION
|
||||
select CAST(@a AS DATETIME(7));
|
||||
|
||||
#
|
||||
# CONVERT_TZ
|
||||
#
|
||||
SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
|
||||
SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
|
||||
SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
|
||||
SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
|
||||
|
||||
#
|
||||
# Field::store_time()
|
||||
#
|
||||
create table t1 (a varchar(200));
|
||||
insert t1 values (now(6));
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
@ -3102,3 +3102,15 @@ DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.1 tests.
|
||||
|
||||
#
|
||||
# restoring of the Item tree in BETWEEN with dates
|
||||
#
|
||||
prepare stmt from "select date('2010-10-10') between '2010-09-09' and ?";
|
||||
set @a='2010-11-11';
|
||||
execute stmt using @a;
|
||||
execute stmt using @a;
|
||||
set @a='2010-08-08';
|
||||
execute stmt using @a;
|
||||
execute stmt using @a;
|
||||
|
||||
|
@ -3513,7 +3513,7 @@ DROP VIEW v1;
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
|
||||
and '2007/10/20 00:00:00 GMT';
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
|
||||
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6';
|
||||
|
||||
# We have all we need -- and trailing garbage:
|
||||
# (leaving out a leading zero in first example to prove it's a
|
||||
|
@ -310,7 +310,7 @@ insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t1;
|
||||
select * from t1 where b = (select b from t2 where t1.a = t2.a);
|
||||
-- error ER_UPDATE_TABLE_USED
|
||||
delete from t1 where b = (select b from t1);
|
||||
delete from t1 where b in (select b from t1);
|
||||
-- error ER_SUBQUERY_NO_1_ROW
|
||||
delete from t1 where b = (select b from t2);
|
||||
delete from t1 where b = (select b from t2 where t1.a = t2.a);
|
||||
|
@ -41,8 +41,8 @@ INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','
|
||||
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
|
||||
|
||||
|
||||
CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
|
||||
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name varchar(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url varchar(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
|
||||
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name varchar(64) not null, parent_category_id smallint unsigned null, url varchar(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
|
||||
|
@ -39,9 +39,9 @@ INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','
|
||||
|
||||
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
|
||||
|
||||
CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
|
||||
CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
|
||||
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
|
||||
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
|
||||
@ -60,7 +60,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL,
|
||||
|
||||
CREATE TABLE proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
|
||||
|
||||
CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
|
||||
CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
|
||||
|
||||
CREATE TABLE servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
|
||||
|
||||
|
@ -44,9 +44,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl
|
||||
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
|
||||
@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
|
||||
CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
|
||||
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
|
||||
|
||||
|
@ -535,10 +535,10 @@ DROP TABLE b15776;
|
||||
CREATE TABLE b15776 (a year(-2));
|
||||
|
||||
## For timestamp, we silently rewrite widths to 14 or 19.
|
||||
--error ER_TOO_BIG_PRECISION
|
||||
CREATE TABLE b15776 (a timestamp(4294967294));
|
||||
DROP TABLE b15776;
|
||||
--error ER_TOO_BIG_PRECISION
|
||||
CREATE TABLE b15776 (a timestamp(4294967295));
|
||||
DROP TABLE b15776;
|
||||
--error ER_TOO_BIG_DISPLAYWIDTH
|
||||
CREATE TABLE b15776 (a timestamp(4294967296));
|
||||
--error ER_PARSE_ERROR
|
||||
|
63
mysql-test/t/type_datetime_hires.test
Normal file
63
mysql-test/t/type_datetime_hires.test
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
--source include/have_partition.inc
|
||||
|
||||
let type=datetime;
|
||||
--source include/type_hrtime.inc
|
||||
|
||||
#
|
||||
# partitioning
|
||||
#
|
||||
eval CREATE TABLE t1 (
|
||||
taken $type(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
id int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (id,taken),
|
||||
KEY taken (taken)
|
||||
)
|
||||
PARTITION BY RANGE (to_days(taken))
|
||||
(
|
||||
PARTITION p01 VALUES LESS THAN (732920),
|
||||
PARTITION p02 VALUES LESS THAN (732950),
|
||||
PARTITION p03 VALUES LESS THAN MAXVALUE);
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
('2006-09-27 21:50:01.123456',0),
|
||||
('2006-09-27 21:50:01.123456',1),
|
||||
('2006-09-27 21:50:01.123456',2),
|
||||
('2006-09-28 21:50:01.123456',3),
|
||||
('2006-09-29 21:50:01.123456',4),
|
||||
('2006-09-29 21:50:01.123456',5),
|
||||
('2006-09-30 21:50:01.123456',6),
|
||||
('2006-10-01 21:50:01.123456',7),
|
||||
('2006-10-02 21:50:01.123456',8),
|
||||
('2006-10-02 21:50:01.123456',9);
|
||||
|
||||
SELECT id,to_days(taken) FROM t1 order by 2;
|
||||
|
||||
eval CREATE TABLE t2 (
|
||||
taken $type(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
id int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (id,taken),
|
||||
KEY taken (taken)
|
||||
)
|
||||
PARTITION BY RANGE (extract(microsecond from taken))
|
||||
(
|
||||
PARTITION p01 VALUES LESS THAN (123000),
|
||||
PARTITION p02 VALUES LESS THAN (500000),
|
||||
PARTITION p03 VALUES LESS THAN MAXVALUE);
|
||||
|
||||
INSERT INTO t2 VALUES
|
||||
('2006-09-27 21:50:01',0),
|
||||
('2006-09-27 21:50:01.1',1),
|
||||
('2006-09-27 21:50:01.12',2),
|
||||
('2006-09-28 21:50:01.123',3),
|
||||
('2006-09-29 21:50:01.1234',4),
|
||||
('2006-09-29 21:50:01.12345',5),
|
||||
('2006-09-30 21:50:01.123456',6),
|
||||
('2006-10-01 21:50:01.56',7),
|
||||
('2006-10-02 21:50:01.567',8),
|
||||
('2006-10-02 21:50:01.5678',9);
|
||||
|
||||
select table_name,partition_name,partition_method,partition_expression,partition_description,table_rows from information_schema.partitions where table_name in ('t1', 't2');
|
||||
|
||||
drop table t1, t2;
|
||||
|
@ -100,3 +100,9 @@ SELECT TIMESTAMP(f1,'1') FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
create table t1 (a time);
|
||||
insert t1 values (-131415);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
|
4
mysql-test/t/type_time_hires.test
Normal file
4
mysql-test/t/type_time_hires.test
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
let type=time;
|
||||
--source include/type_hrtime.inc
|
||||
|
@ -67,17 +67,6 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
|
||||
SELECT * FROM t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
|
||||
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
|
||||
t14 timestamp(14));
|
||||
insert t1 values (0,0,0,0,0,0,0),
|
||||
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
|
||||
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
|
||||
"1997-12-31 23:47:59");
|
||||
select * from t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Let us check if we properly treat wrong datetimes and produce proper warnings
|
||||
# (for both strings and numbers)
|
||||
@ -298,7 +287,7 @@ drop table t1;
|
||||
# mode regardless of whether a display width is given.
|
||||
#
|
||||
set sql_mode='maxdb';
|
||||
create table t1 (a timestamp, b timestamp(19));
|
||||
create table t1 (a timestamp, b timestamp(5));
|
||||
show create table t1;
|
||||
# restore default mode
|
||||
set sql_mode='';
|
||||
|
15
mysql-test/t/type_timestamp_hires.test
Normal file
15
mysql-test/t/type_timestamp_hires.test
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
let type=timestamp;
|
||||
--source include/type_hrtime.inc
|
||||
|
||||
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456, time_zone='+03:00';
|
||||
|
||||
create table t1 (a timestamp(5));
|
||||
#
|
||||
# CREATE ... DEFAULT NOW(X)
|
||||
#
|
||||
|
||||
insert t1 values ();
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
@ -13,9 +13,6 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/* get time since epoc in 100 nanosec units */
|
||||
/* thus to get the current time we should use the system function
|
||||
with the highest possible resolution */
|
||||
|
||||
/*
|
||||
TODO: in functions my_micro_time() and my_micro_time_and_time() there
|
||||
@ -27,14 +24,33 @@
|
||||
|
||||
#ifdef __NETWARE__
|
||||
#include <nks/time.h>
|
||||
#elif defined(__WIN__)
|
||||
static ulonglong query_performance_frequency, query_performance_offset;
|
||||
#elif defined(HAVE_GETHRTIME)
|
||||
static ulonglong gethrtime_offset;
|
||||
#endif
|
||||
|
||||
/*
|
||||
get time since epoc in 100 nanosec units
|
||||
|
||||
NOTE:
|
||||
Thus to get the current time we should use the system function
|
||||
with the highest possible resolution
|
||||
|
||||
The value is not subject to resetting or drifting by way of adjtime() or
|
||||
settimeofday(), and thus it is *NOT* appropriate for getting the current
|
||||
timestamp. It can be used for calculating time intervals, though.
|
||||
And it's good enough for UUID.
|
||||
*/
|
||||
|
||||
ulonglong my_getsystime()
|
||||
{
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec tp;
|
||||
clock_gettime(CLOCK_REALTIME, &tp);
|
||||
return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100;
|
||||
#elif defined(HAVE_GETHRTIME)
|
||||
return gethrtime()/100-gethrtime_offset;
|
||||
#elif defined(__WIN__)
|
||||
LARGE_INTEGER t_cnt;
|
||||
if (query_performance_frequency)
|
||||
@ -57,169 +73,70 @@ ulonglong my_getsystime()
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return current time in microseconds since epoch */
|
||||
|
||||
my_hrtime_t my_hrtime()
|
||||
{
|
||||
my_hrtime_t hrtime;
|
||||
#if defined(__WIN__)
|
||||
ulonglong newtime;
|
||||
GetSystemTimeAsFileTime((FILETIME*)&newtime);
|
||||
hrtime.val= newtime/10;
|
||||
#elif defined(HAVE_GETHRTIME)
|
||||
struct timeval t;
|
||||
/*
|
||||
The following loop is here because gettimeofday may fail on some systems
|
||||
*/
|
||||
while (gettimeofday(&t, NULL) != 0)
|
||||
{}
|
||||
hrtime.val= t.tv_sec*1000000 + t.tv_usec;
|
||||
#else
|
||||
hrtime.val= my_getsystime()/10;
|
||||
#endif
|
||||
return hrtime;
|
||||
}
|
||||
|
||||
/*
|
||||
Return current time
|
||||
This function is basically equivalent to
|
||||
|
||||
SYNOPSIS
|
||||
my_time()
|
||||
flags If MY_WME is set, write error if time call fails
|
||||
*interval= my_getsystime()/10;
|
||||
*timestamp= my_time();
|
||||
|
||||
but it avoids calling OS time functions twice, if possible.
|
||||
*/
|
||||
|
||||
time_t my_time(myf flags __attribute__((unused)))
|
||||
void my_diff_and_hrtime(my_timediff_t *interval, my_hrtime_t *timestamp)
|
||||
{
|
||||
time_t t;
|
||||
#ifdef HAVE_GETHRTIME
|
||||
(void) my_micro_time_and_time(&t);
|
||||
return t;
|
||||
interval->val= my_getsystime() / 10;
|
||||
#if defined(__WIN__) || defined(HAVE_GETHRTIME)
|
||||
timestamp->val= my_hrtime();
|
||||
#else
|
||||
/* The following loop is here beacuse time() may fail on some systems */
|
||||
while ((t= time(0)) == (time_t) -1)
|
||||
{
|
||||
if (flags & MY_WME)
|
||||
fprintf(stderr, "%s: Warning: time() call failed\n", my_progname);
|
||||
}
|
||||
return t;
|
||||
timestamp->val= interval->val;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Return time in micro seconds
|
||||
|
||||
SYNOPSIS
|
||||
my_micro_time()
|
||||
|
||||
NOTES
|
||||
This function is to be used to measure performance in micro seconds.
|
||||
As it's not defined whats the start time for the clock, this function
|
||||
us only useful to measure time between two moments.
|
||||
|
||||
For windows platforms we need the frequency value of the CUP. This is
|
||||
initalized in my_init.c through QueryPerformanceFrequency().
|
||||
|
||||
If Windows platform doesn't support QueryPerformanceFrequency() we will
|
||||
obtain the time via GetClockCount, which only supports milliseconds.
|
||||
|
||||
RETURN
|
||||
Value in microseconds from some undefined point in time
|
||||
*/
|
||||
|
||||
ulonglong my_micro_time()
|
||||
void my_time_init()
|
||||
{
|
||||
#if defined(__WIN__)
|
||||
ulonglong newtime;
|
||||
GetSystemTimeAsFileTime((FILETIME*)&newtime);
|
||||
return (newtime/10);
|
||||
#elif defined(HAVE_GETHRTIME)
|
||||
return gethrtime()/1000;
|
||||
#else
|
||||
ulonglong newtime;
|
||||
struct timeval t;
|
||||
/*
|
||||
The following loop is here because gettimeofday may fail on some systems
|
||||
*/
|
||||
while (gettimeofday(&t, NULL) != 0)
|
||||
{}
|
||||
newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
|
||||
return newtime;
|
||||
#endif /* defined(__WIN__) */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Return time in seconds and timer in microseconds (not different start!)
|
||||
|
||||
SYNOPSIS
|
||||
my_micro_time_and_time()
|
||||
time_arg Will be set to seconds since epoch (00:00:00 UTC,
|
||||
January 1, 1970)
|
||||
|
||||
NOTES
|
||||
This function is to be useful when we need both the time and microtime.
|
||||
For example in MySQL this is used to get the query time start of a query
|
||||
and to measure the time of a query (for the slow query log)
|
||||
|
||||
IMPLEMENTATION
|
||||
Value of time is as in time() call.
|
||||
Value of microtime is same as my_micro_time(), which may be totally
|
||||
unrealated to time()
|
||||
|
||||
RETURN
|
||||
Value in microseconds from some undefined point in time
|
||||
*/
|
||||
|
||||
#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */
|
||||
|
||||
ulonglong my_micro_time_and_time(time_t *time_arg)
|
||||
{
|
||||
#if defined(__WIN__)
|
||||
ulonglong newtime;
|
||||
GetSystemTimeAsFileTime((FILETIME*)&newtime);
|
||||
*time_arg= (time_t) ((newtime - OFFSET_TO_EPOCH) / 10000000);
|
||||
return (newtime/10);
|
||||
#elif defined(HAVE_GETHRTIME)
|
||||
/*
|
||||
Solaris has a very slow time() call. We optimize this by using the very
|
||||
fast gethrtime() call and only calling time() every 1/2 second
|
||||
*/
|
||||
static hrtime_t prev_gethrtime= 0;
|
||||
static time_t cur_time= 0;
|
||||
hrtime_t cur_gethrtime;
|
||||
|
||||
pthread_mutex_lock(&THR_LOCK_time);
|
||||
cur_gethrtime= gethrtime();
|
||||
if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)
|
||||
#ifdef __WIN__
|
||||
#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li, t_cnt;
|
||||
DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
|
||||
if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
|
||||
query_performance_frequency= 0;
|
||||
else
|
||||
{
|
||||
cur_time= time(0);
|
||||
prev_gethrtime= cur_gethrtime;
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
li.LowPart= ft.dwLowDateTime;
|
||||
li.HighPart= ft.dwHighDateTime;
|
||||
query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
|
||||
QueryPerformanceCounter(&t_cnt);
|
||||
query_performance_offset-= (t_cnt.QuadPart /
|
||||
query_performance_frequency * 10000000 +
|
||||
t_cnt.QuadPart %
|
||||
query_performance_frequency * 10000000 /
|
||||
query_performance_frequency);
|
||||
}
|
||||
*time_arg= cur_time;
|
||||
pthread_mutex_unlock(&THR_LOCK_time);
|
||||
return cur_gethrtime/1000;
|
||||
#else
|
||||
ulonglong newtime;
|
||||
struct timeval t;
|
||||
/*
|
||||
The following loop is here because gettimeofday may fail on some systems
|
||||
*/
|
||||
while (gettimeofday(&t, NULL) != 0)
|
||||
{}
|
||||
*time_arg= t.tv_sec;
|
||||
newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
|
||||
return newtime;
|
||||
#endif /* defined(__WIN__) */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Returns current time
|
||||
|
||||
SYNOPSIS
|
||||
my_time_possible_from_micro()
|
||||
microtime Value from very recent my_micro_time()
|
||||
|
||||
NOTES
|
||||
This function returns the current time. The microtime argument is only used
|
||||
if my_micro_time() uses a function that can safely be converted to the
|
||||
current time.
|
||||
|
||||
RETURN
|
||||
current time
|
||||
*/
|
||||
|
||||
time_t my_time_possible_from_micro(ulonglong microtime __attribute__((unused)))
|
||||
{
|
||||
#if defined(__WIN__)
|
||||
time_t t;
|
||||
while ((t= time(0)) == (time_t) -1)
|
||||
{}
|
||||
return t;
|
||||
#elif defined(HAVE_GETHRTIME)
|
||||
return my_time(0); /* Cached time */
|
||||
#else
|
||||
return (time_t) (microtime / 1000000);
|
||||
#endif /* defined(__WIN__) */
|
||||
gethrtime_offset= gethrtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,7 @@ my_bool my_init(void)
|
||||
DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
|
||||
if (!home_dir)
|
||||
{ /* Don't initialize twice */
|
||||
my_time_init();
|
||||
my_win_init();
|
||||
if ((home_dir=getenv("HOME")) != 0)
|
||||
home_dir=intern_filename(home_dir_buff,home_dir);
|
||||
@ -242,7 +243,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
|
||||
|
||||
#ifdef __WIN__
|
||||
|
||||
|
||||
/*
|
||||
my_parameter_handler
|
||||
|
||||
@ -316,54 +316,6 @@ static void my_win_init(void)
|
||||
|
||||
_tzset();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* The following is used by time functions */
|
||||
#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
|
||||
#define MS 10000000
|
||||
{
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li, t_cnt;
|
||||
DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
|
||||
if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
|
||||
query_performance_frequency= 0;
|
||||
else
|
||||
{
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
li.LowPart= ft.dwLowDateTime;
|
||||
li.HighPart= ft.dwHighDateTime;
|
||||
query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
|
||||
QueryPerformanceCounter(&t_cnt);
|
||||
query_performance_offset-= (t_cnt.QuadPart /
|
||||
query_performance_frequency * MS +
|
||||
t_cnt.QuadPart %
|
||||
query_performance_frequency * MS /
|
||||
query_performance_frequency);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
|
||||
|
@ -100,11 +100,6 @@ int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
|
||||
void (*debug_sync_C_callback_ptr)(const char *, size_t);
|
||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||
|
||||
#ifdef __WIN__
|
||||
/* from my_getsystime.c */
|
||||
ulonglong query_performance_frequency, query_performance_offset;
|
||||
#endif
|
||||
|
||||
/* How to disable options */
|
||||
my_bool NEAR my_disable_locking=0;
|
||||
my_bool NEAR my_disable_async_io=0;
|
||||
|
@ -66,8 +66,6 @@ extern struct st_irem *sf_malloc_root;
|
||||
|
||||
extern struct st_my_file_info my_file_info_default[MY_NFILE];
|
||||
|
||||
extern ulonglong query_performance_frequency, query_performance_offset;
|
||||
|
||||
#if defined(THREAD) && !defined(__WIN__)
|
||||
extern sigset_t my_signals; /* signals blocked by mf_brkhant */
|
||||
#endif
|
||||
|
@ -28,9 +28,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl
|
||||
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
|
||||
@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
|
||||
|
||||
CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
|
||||
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
|
||||
|
||||
-- Create general_log if CSV is enabled.
|
||||
|
||||
|
@ -363,7 +363,7 @@ ALTER TABLE procs_priv
|
||||
COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
|
||||
|
||||
ALTER TABLE procs_priv
|
||||
MODIFY Timestamp timestamp(14) AFTER Proc_priv;
|
||||
MODIFY Timestamp timestamp AFTER Proc_priv;
|
||||
|
||||
#
|
||||
# proc
|
||||
|
@ -856,7 +856,7 @@ A sample log-pos table definition:
|
||||
|
||||
CREATE TABLE log_pos (
|
||||
host varchar(60) NOT null,
|
||||
time_stamp timestamp(14) NOT NULL,
|
||||
time_stamp timestamp NOT NULL,
|
||||
log_file varchar(32) default NULL,
|
||||
log_pos int(11) default NULL,
|
||||
master_host varchar(60) NULL,
|
||||
|
@ -19,6 +19,9 @@
|
||||
/* Windows version of localtime_r() is declared in my_ptrhead.h */
|
||||
#include <my_pthread.h>
|
||||
|
||||
static enum enum_mysql_timestamp_type str_to_time(const char *, uint,
|
||||
MYSQL_TIME *, int *);
|
||||
|
||||
ulonglong log_10_int[20]=
|
||||
{
|
||||
1, 10, 100, 1000, 10000UL, 100000UL, 1000000UL, 10000000UL,
|
||||
@ -175,6 +178,13 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
|
||||
|
||||
LINT_INIT(field_length);
|
||||
|
||||
if (flags & TIME_TIME_ONLY)
|
||||
{
|
||||
enum enum_mysql_timestamp_type ret=
|
||||
str_to_time(str, length, l_time, was_cut);
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
*was_cut= 0;
|
||||
|
||||
/* Skip space at start */
|
||||
@ -477,12 +487,12 @@ err:
|
||||
work with times where the time arguments are in the above order.
|
||||
|
||||
RETURN
|
||||
0 ok
|
||||
1 error
|
||||
MYSQL_TIMESTAMP_TIME
|
||||
MYSQL_TIMESTAMP_ERROR
|
||||
*/
|
||||
|
||||
my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
|
||||
int *warning)
|
||||
static enum enum_mysql_timestamp_type
|
||||
str_to_time(const char *str, uint length, MYSQL_TIME *l_time, int *warning)
|
||||
{
|
||||
ulong date[5];
|
||||
ulonglong value;
|
||||
@ -501,7 +511,7 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
|
||||
length--;
|
||||
}
|
||||
if (str == end)
|
||||
return 1;
|
||||
return MYSQL_TIMESTAMP_ERROR;
|
||||
|
||||
/* Check first if this is a full TIMESTAMP */
|
||||
if (length >= 12)
|
||||
@ -514,7 +524,7 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
|
||||
{
|
||||
if (was_cut)
|
||||
*warning|= MYSQL_TIME_WARN_TRUNCATED;
|
||||
return res == MYSQL_TIMESTAMP_ERROR;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,7 +619,7 @@ fractional:
|
||||
((str[1] == '-' || str[1] == '+') &&
|
||||
(end - str) > 2 &&
|
||||
my_isdigit(&my_charset_latin1, str[2]))))
|
||||
return 1;
|
||||
return MYSQL_TIMESTAMP_ERROR;
|
||||
|
||||
if (internal_format_positions[7] != 255)
|
||||
{
|
||||
@ -632,7 +642,7 @@ fractional:
|
||||
if (date[0] > UINT_MAX || date[1] > UINT_MAX ||
|
||||
date[2] > UINT_MAX || date[3] > UINT_MAX ||
|
||||
date[4] > UINT_MAX)
|
||||
return 1;
|
||||
return MYSQL_TIMESTAMP_ERROR;
|
||||
|
||||
l_time->year= 0; /* For protocol::store_time */
|
||||
l_time->month= 0;
|
||||
@ -645,7 +655,7 @@ fractional:
|
||||
|
||||
/* Check if the value is valid and fits into MYSQL_TIME range */
|
||||
if (check_time_range(l_time, warning))
|
||||
return 1;
|
||||
return MYSQL_TIMESTAMP_ERROR;
|
||||
|
||||
/* Check if there is garbage at end of the MYSQL_TIME specification */
|
||||
if (str != end)
|
||||
@ -659,7 +669,7 @@ fractional:
|
||||
}
|
||||
} while (++str != end);
|
||||
}
|
||||
return 0;
|
||||
return MYSQL_TIMESTAMP_TIME;
|
||||
}
|
||||
|
||||
|
||||
@ -698,7 +708,7 @@ int check_time_range(struct st_mysql_time *my_time, int *warning)
|
||||
my_time->hour= TIME_MAX_HOUR;
|
||||
my_time->minute= TIME_MAX_MINUTE;
|
||||
my_time->second= TIME_MAX_SECOND;
|
||||
my_time->second_part= 0;
|
||||
my_time->second_part= TIME_MAX_SECOND_PART;
|
||||
*warning|= MYSQL_TIME_WARN_OUT_OF_RANGE;
|
||||
return 0;
|
||||
}
|
||||
@ -1013,19 +1023,27 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type)
|
||||
using default format.
|
||||
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
|
||||
valid date either. Additionally, make_time doesn't take into
|
||||
account time->day member: it's assumed that days have been converted
|
||||
to hours already.
|
||||
valid date either.
|
||||
|
||||
RETURN
|
||||
number of characters written to 'to'
|
||||
*/
|
||||
|
||||
int my_time_to_str(const MYSQL_TIME *l_time, char *to)
|
||||
int my_time_to_str(const MYSQL_TIME *l_time, char *to, int digits)
|
||||
{
|
||||
uint extra_hours= 0;
|
||||
return sprintf(to, "%s%02u:%02u:%02u", (l_time->neg ? "-" : ""),
|
||||
extra_hours+ l_time->hour, l_time->minute, l_time->second);
|
||||
ulong day= (l_time->year || l_time->month) ? 0 : l_time->day;
|
||||
|
||||
if (digits == AUTO_SEC_PART_DIGITS)
|
||||
digits= l_time->second_part ? MAX_SEC_PART_DIGITS : 0;
|
||||
|
||||
DBUG_ASSERT(digits >= 0 && digits <= MAX_SEC_PART_DIGITS);
|
||||
|
||||
return sprintf(to,
|
||||
digits ? "%s%02lu:%02u:%02u.%0*lu"
|
||||
: "%s%02lu:%02u:%02u",
|
||||
(l_time->neg ? "-" : ""),
|
||||
day * 24L + l_time->hour, l_time->minute, l_time->second,
|
||||
digits, (ulong)sec_part_shift(l_time->second_part, digits));
|
||||
}
|
||||
|
||||
int my_date_to_str(const MYSQL_TIME *l_time, char *to)
|
||||
@ -1034,11 +1052,19 @@ int my_date_to_str(const MYSQL_TIME *l_time, char *to)
|
||||
l_time->year, l_time->month, l_time->day);
|
||||
}
|
||||
|
||||
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to)
|
||||
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, int digits)
|
||||
{
|
||||
return sprintf(to, "%04u-%02u-%02u %02u:%02u:%02u",
|
||||
if (digits == AUTO_SEC_PART_DIGITS)
|
||||
digits= l_time->second_part ? MAX_SEC_PART_DIGITS : 0;
|
||||
|
||||
DBUG_ASSERT(digits >= 0 && digits <= MAX_SEC_PART_DIGITS);
|
||||
|
||||
return sprintf(to,
|
||||
digits ? "%04u-%02u-%02u %02u:%02u:%02u.%0*lu"
|
||||
: "%04u-%02u-%02u %02u:%02u:%02u",
|
||||
l_time->year, l_time->month, l_time->day,
|
||||
l_time->hour, l_time->minute, l_time->second);
|
||||
l_time->hour, l_time->minute, l_time->second,
|
||||
digits, (ulong)sec_part_shift(l_time->second_part, digits));
|
||||
}
|
||||
|
||||
|
||||
@ -1053,15 +1079,15 @@ int my_datetime_to_str(const MYSQL_TIME *l_time, char *to)
|
||||
The string must have at least MAX_DATE_STRING_REP_LENGTH bytes reserved.
|
||||
*/
|
||||
|
||||
int my_TIME_to_str(const MYSQL_TIME *l_time, char *to)
|
||||
int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, int digits)
|
||||
{
|
||||
switch (l_time->time_type) {
|
||||
case MYSQL_TIMESTAMP_DATETIME:
|
||||
return my_datetime_to_str(l_time, to);
|
||||
return my_datetime_to_str(l_time, to, digits);
|
||||
case MYSQL_TIMESTAMP_DATE:
|
||||
return my_date_to_str(l_time, to);
|
||||
case MYSQL_TIMESTAMP_TIME:
|
||||
return my_time_to_str(l_time, to);
|
||||
return my_time_to_str(l_time, to, digits);
|
||||
case MYSQL_TIMESTAMP_NONE:
|
||||
case MYSQL_TIMESTAMP_ERROR:
|
||||
to[0]='\0';
|
||||
@ -1174,6 +1200,52 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
|
||||
return LL(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
Convert a double to a MYSQL_TIME struct.
|
||||
|
||||
@param[in] nr a number to convert
|
||||
@param[out] ltime Date to check.
|
||||
@param[out] was_cut MYSQL_TIME_WARN_OUT_OF_RANGE if the value was
|
||||
modified to fit in the valid range. Otherwise 0.
|
||||
|
||||
@details
|
||||
Takes a number in the [-]HHHMMSS.uuuuuu format.
|
||||
|
||||
number_to_datetime() cannot take a double, because double precision is not
|
||||
enough for YYYYMMDDHHMMSS.uuuuuu
|
||||
|
||||
@return
|
||||
0 time value is valid, but was possibly truncated
|
||||
1 time value is invalid
|
||||
*/
|
||||
int number_to_time(double nr, MYSQL_TIME *ltime, int *was_cut)
|
||||
{
|
||||
ulong tmp;
|
||||
*was_cut= 0;
|
||||
ltime->year= ltime->month= ltime->day= 0;
|
||||
ltime->time_type= MYSQL_TIMESTAMP_TIME;
|
||||
|
||||
if ((ltime->neg= nr < 0))
|
||||
nr= -nr;
|
||||
|
||||
if (nr > TIME_MAX_VALUE)
|
||||
{
|
||||
nr= TIME_MAX_VALUE;
|
||||
*was_cut= MYSQL_TIME_WARN_OUT_OF_RANGE;
|
||||
}
|
||||
tmp=(ulong)floor(nr);
|
||||
ltime->hour = tmp/100/100;
|
||||
ltime->minute= tmp/100%100;
|
||||
ltime->second= tmp%100;
|
||||
ltime->second_part= (nr-tmp)*1e6;
|
||||
|
||||
if (ltime->minute < 60 && ltime->second < 60)
|
||||
return 0;
|
||||
|
||||
*was_cut= MYSQL_TIME_WARN_TRUNCATED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Convert time value to integer in YYYYMMDDHHMMSS format */
|
||||
|
||||
@ -1222,7 +1294,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time)
|
||||
DESCRIPTION
|
||||
The function is used when we need to convert value of time item
|
||||
to a number if it's used in numeric context, i. e.:
|
||||
SELECT NOW()+1, CURDATE()+0, CURTIMIE()+0;
|
||||
SELECT NOW()+1, CURDATE()+0, CURTIME()+0;
|
||||
SELECT ?+1;
|
||||
|
||||
NOTE
|
||||
@ -1249,3 +1321,41 @@ ulonglong TIME_to_ulonglong(const MYSQL_TIME *my_time)
|
||||
return 0;
|
||||
}
|
||||
|
||||
double TIME_to_double(const MYSQL_TIME *my_time)
|
||||
{
|
||||
double d= (double)TIME_to_ulonglong(my_time);
|
||||
|
||||
if (my_time->time_type == MYSQL_TIMESTAMP_DATE)
|
||||
return d;
|
||||
|
||||
d+= my_time->second_part/1e6;
|
||||
return my_time->neg ? -d : d;
|
||||
}
|
||||
|
||||
longlong pack_time(MYSQL_TIME *my_time)
|
||||
{
|
||||
return ((((((my_time->year * 13ULL +
|
||||
my_time->month) * 32ULL +
|
||||
my_time->day) * 24ULL +
|
||||
my_time->hour) * 60ULL +
|
||||
my_time->minute) * 60ULL +
|
||||
my_time->second) * 1000000ULL +
|
||||
my_time->second_part) * (my_time->neg ? -1 : 1);
|
||||
}
|
||||
|
||||
#define get_one(WHERE, FACTOR) WHERE= packed % FACTOR; packed/= FACTOR
|
||||
|
||||
MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time)
|
||||
{
|
||||
if ((my_time->neg= packed < 0))
|
||||
packed= -packed;
|
||||
get_one(my_time->second_part, 1000000ULL);
|
||||
get_one(my_time->second, 60ULL);
|
||||
get_one(my_time->minute, 60ULL);
|
||||
get_one(my_time->hour, 24ULL);
|
||||
get_one(my_time->day, 32ULL);
|
||||
get_one(my_time->month, 13ULL);
|
||||
my_time->year= packed;
|
||||
my_time->time_type= MYSQL_TIMESTAMP_DATETIME;
|
||||
return my_time;
|
||||
}
|
||||
|
@ -928,7 +928,7 @@ Event_queue_element::compute_next_execution_time()
|
||||
goto ret;
|
||||
}
|
||||
|
||||
time_now= (my_time_t) current_thd->query_start();
|
||||
time_now= current_thd->query_start();
|
||||
|
||||
DBUG_PRINT("info",("NOW: [%lu]", (ulong) time_now));
|
||||
|
||||
@ -1131,7 +1131,7 @@ err:
|
||||
void
|
||||
Event_queue_element::mark_last_executed(THD *thd)
|
||||
{
|
||||
last_executed= (my_time_t) thd->query_start();
|
||||
last_executed= thd->query_start();
|
||||
last_executed_changed= TRUE;
|
||||
|
||||
execution_count++;
|
||||
@ -1191,7 +1191,7 @@ append_datetime(String *buf, Time_zone *time_zone, my_time_t secs,
|
||||
*/
|
||||
MYSQL_TIME time;
|
||||
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, 0));
|
||||
buf->append(STRING_WITH_LEN("'"));
|
||||
}
|
||||
|
||||
|
@ -231,6 +231,9 @@ mysql_event_fill_row(THD *thd,
|
||||
rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
|
||||
rs|= fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE);
|
||||
|
||||
if (!is_update)
|
||||
rs|= fields[ET_FIELD_CREATED]->set_time();
|
||||
|
||||
/*
|
||||
Change the SQL_MODE only if body was present in an ALTER EVENT and of course
|
||||
always during CREATE EVENT.
|
||||
@ -317,7 +320,7 @@ mysql_event_fill_row(THD *thd,
|
||||
*/
|
||||
}
|
||||
|
||||
((Field_timestamp *)fields[ET_FIELD_MODIFIED])->set_time();
|
||||
rs|= fields[ET_FIELD_MODIFIED]->set_time();
|
||||
|
||||
if (et->comment.str)
|
||||
{
|
||||
@ -671,8 +674,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
|
||||
goto end;
|
||||
}
|
||||
|
||||
((Field_timestamp *)table->field[ET_FIELD_CREATED])->set_time();
|
||||
|
||||
/*
|
||||
mysql_event_fill_row() calls my_error() in case of error so no need to
|
||||
handle it here
|
||||
|
@ -111,7 +111,7 @@ Event_parse_data::init_name(THD *thd, sp_name *spn)
|
||||
void
|
||||
Event_parse_data::check_if_in_the_past(THD *thd, my_time_t ltime_utc)
|
||||
{
|
||||
if (ltime_utc >= (my_time_t) thd->query_start())
|
||||
if (ltime_utc >= thd->query_start())
|
||||
return;
|
||||
|
||||
/*
|
||||
|
@ -513,9 +513,10 @@ Event_queue::empty_queue()
|
||||
*/
|
||||
|
||||
void
|
||||
Event_queue::dbug_dump_queue(time_t now)
|
||||
Event_queue::dbug_dump_queue(my_time_t when)
|
||||
{
|
||||
#ifndef DBUG_OFF
|
||||
my_time_t now= when;
|
||||
Event_queue_element *et;
|
||||
uint i;
|
||||
DBUG_ENTER("Event_queue::dbug_dump_queue");
|
||||
@ -592,14 +593,13 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
|
||||
thd->set_current_time(); /* Get current time */
|
||||
|
||||
next_activation_at= top->execute_at;
|
||||
if (next_activation_at > thd->query_start())
|
||||
if (next_activation_at >thd->query_start())
|
||||
{
|
||||
/*
|
||||
Not yet time for top event, wait on condition with
|
||||
time or until signaled. Release LOCK_queue while waiting.
|
||||
*/
|
||||
struct timespec top_time;
|
||||
set_timespec(top_time, next_activation_at - thd->query_start());
|
||||
struct timespec top_time= { next_activation_at, 0 };
|
||||
cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__);
|
||||
|
||||
continue;
|
||||
|
@ -98,7 +98,7 @@ private:
|
||||
|
||||
|
||||
void
|
||||
dbug_dump_queue(time_t now);
|
||||
dbug_dump_queue(my_time_t now);
|
||||
|
||||
/* LOCK_event_queue is the mutex which protects the access to the queue. */
|
||||
pthread_mutex_t LOCK_event_queue;
|
||||
|
1890
sql/field.cc
1890
sql/field.cc
File diff suppressed because it is too large
Load Diff
360
sql/field.h
360
sql/field.h
@ -22,8 +22,13 @@
|
||||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define BIGENDIAN 1
|
||||
#else
|
||||
#define BIGENDIAN 0
|
||||
#endif
|
||||
|
||||
#define NOT_FIXED_DEC 31
|
||||
#define DATETIME_DEC 6
|
||||
const uint32 max_field_size= (uint32) 4294967295U;
|
||||
|
||||
class Send_field;
|
||||
@ -299,14 +304,6 @@ public:
|
||||
virtual void make_field(Send_field *);
|
||||
virtual void sort_string(uchar *buff,uint length)=0;
|
||||
virtual bool optimize_range(uint idx, uint part);
|
||||
/*
|
||||
This should be true for fields which, when compared with constant
|
||||
items, can be casted to longlong. In this case we will at 'fix_fields'
|
||||
stage cast the constant items to longlongs and at the execution stage
|
||||
use field->val_int() for comparison. Used to optimize clauses like
|
||||
'a_column BETWEEN date_const, date_const'.
|
||||
*/
|
||||
virtual bool can_be_compared_as_longlong() const { return FALSE; }
|
||||
virtual void free() {}
|
||||
virtual Field *new_field(MEM_ROOT *root, struct st_table *new_table,
|
||||
bool keep_type);
|
||||
@ -447,7 +444,7 @@ public:
|
||||
void copy_from_tmp(int offset);
|
||||
uint fill_cache_field(struct st_cache_field *copy);
|
||||
virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
virtual bool get_time(MYSQL_TIME *ltime);
|
||||
bool get_time(MYSQL_TIME *ltime) { return get_date(ltime, TIME_TIME_ONLY); }
|
||||
virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; }
|
||||
virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
|
||||
virtual bool has_charset(void) const { return FALSE; }
|
||||
@ -455,16 +452,12 @@ public:
|
||||
virtual enum Derivation derivation(void) const
|
||||
{ return DERIVATION_IMPLICIT; }
|
||||
virtual void set_derivation(enum Derivation derivation_arg) { }
|
||||
virtual int set_time() { return 1; }
|
||||
bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
|
||||
int cuted_increment);
|
||||
void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
|
||||
const char *str, uint str_len,
|
||||
timestamp_type ts_type, int cuted_increment);
|
||||
void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
|
||||
longlong nr, timestamp_type ts_type,
|
||||
const Lazy_string *str, timestamp_type ts_type,
|
||||
int cuted_increment);
|
||||
void set_datetime_warning(MYSQL_ERROR::enum_warning_level, const uint code,
|
||||
double nr, timestamp_type ts_type);
|
||||
inline bool check_overflow(int op_result)
|
||||
{
|
||||
return (op_result == E_DEC_OVERFLOW);
|
||||
@ -555,18 +548,14 @@ protected:
|
||||
bool low_byte_first_from, bool low_byte_first_to)
|
||||
{
|
||||
int32 val;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (low_byte_first_from)
|
||||
if (BIGENDIAN && low_byte_first_from)
|
||||
val = sint4korr(from);
|
||||
else
|
||||
#endif
|
||||
longget(val, from);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (low_byte_first_to)
|
||||
if (BIGENDIAN && low_byte_first_to)
|
||||
int4store(to, val);
|
||||
else
|
||||
#endif
|
||||
longstore(to, val);
|
||||
}
|
||||
|
||||
@ -577,18 +566,14 @@ protected:
|
||||
bool low_byte_first_from, bool low_byte_first_to)
|
||||
{
|
||||
int64 val;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (low_byte_first_from)
|
||||
if (BIGENDIAN && low_byte_first_from)
|
||||
val = sint8korr(from);
|
||||
else
|
||||
#endif
|
||||
longlongget(val, from);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (low_byte_first_to)
|
||||
if (BIGENDIAN && low_byte_first_to)
|
||||
int8store(to, val);
|
||||
else
|
||||
#endif
|
||||
longlongstore(to, val);
|
||||
}
|
||||
|
||||
@ -681,7 +666,6 @@ public:
|
||||
uint is_equal(Create_field *new_field);
|
||||
};
|
||||
|
||||
|
||||
/* base class for Field_string, Field_varstring and Field_blob */
|
||||
|
||||
class Field_longstr :public Field_str
|
||||
@ -899,18 +883,14 @@ public:
|
||||
uint max_length, bool low_byte_first)
|
||||
{
|
||||
int16 val;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (table->s->db_low_byte_first)
|
||||
if (BIGENDIAN && table->s->db_low_byte_first)
|
||||
val = sint2korr(from);
|
||||
else
|
||||
#endif
|
||||
shortget(val, from);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (low_byte_first)
|
||||
if (BIGENDIAN && low_byte_first)
|
||||
int2store(to, val);
|
||||
else
|
||||
#endif
|
||||
shortstore(to, val);
|
||||
return to + sizeof(val);
|
||||
}
|
||||
@ -919,18 +899,14 @@ public:
|
||||
uint param_data, bool low_byte_first)
|
||||
{
|
||||
int16 val;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (low_byte_first)
|
||||
if (BIGENDIAN && low_byte_first)
|
||||
val = sint2korr(from);
|
||||
else
|
||||
#endif
|
||||
shortget(val, from);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (table->s->db_low_byte_first)
|
||||
if (BIGENDIAN && table->s->db_low_byte_first)
|
||||
int2store(to, val);
|
||||
else
|
||||
#endif
|
||||
shortstore(to, val);
|
||||
return from + sizeof(val);
|
||||
}
|
||||
@ -1025,7 +1001,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
class Field_longlong :public Field_num {
|
||||
public:
|
||||
Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||
@ -1062,7 +1037,6 @@ public:
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const { return 8; }
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
uint32 max_display_length() { return 20; }
|
||||
virtual uchar *pack(uchar* to, const uchar *from,
|
||||
uint max_length __attribute__((unused)),
|
||||
@ -1077,7 +1051,6 @@ public:
|
||||
return unpack_int64(to, from, low_byte_first);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class Field_float :public Field_real {
|
||||
@ -1188,6 +1161,8 @@ public:
|
||||
|
||||
|
||||
class Field_timestamp :public Field_str {
|
||||
int store_TIME_with_warning(THD *, MYSQL_TIME *, const Lazy_string *,
|
||||
bool, bool);
|
||||
public:
|
||||
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
|
||||
uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
@ -1197,11 +1172,11 @@ public:
|
||||
CHARSET_INFO *cs);
|
||||
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
enum Item_result cmp_type () const { return TIME_RESULT; }
|
||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
|
||||
int store_time(MYSQL_TIME *ltime, timestamp_type type);
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
String *val_str(String*,String *);
|
||||
@ -1210,9 +1185,9 @@ public:
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const { return 4; }
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
bool zero_pack() const { return 0; }
|
||||
void set_time();
|
||||
uint decimals() const { return 0; }
|
||||
virtual int set_time();
|
||||
virtual void set_default()
|
||||
{
|
||||
if (table->timestamp_field == this &&
|
||||
@ -1222,31 +1197,15 @@ public:
|
||||
Field::set_default();
|
||||
}
|
||||
/* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
|
||||
inline long get_timestamp(my_bool *null_value)
|
||||
virtual long get_timestamp(ulong *sec_part) const;
|
||||
virtual void store_TIME(my_time_t timestamp, ulong sec_part)
|
||||
{
|
||||
if ((*null_value= is_null()))
|
||||
return 0;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (table && table->s->db_low_byte_first)
|
||||
return sint4korr(ptr);
|
||||
#endif
|
||||
long tmp;
|
||||
longget(tmp,ptr);
|
||||
return tmp;
|
||||
}
|
||||
inline void store_timestamp(my_time_t timestamp)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (table && table->s->db_low_byte_first)
|
||||
{
|
||||
if (BIGENDIAN && table && table->s->db_low_byte_first)
|
||||
int4store(ptr,timestamp);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
longstore(ptr,(uint32) timestamp);
|
||||
}
|
||||
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
timestamp_auto_set_type get_auto_set_type() const;
|
||||
uchar *pack(uchar *to, const uchar *from,
|
||||
uint max_length __attribute__((unused)), bool low_byte_first)
|
||||
@ -1262,6 +1221,43 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Field_timestamp_hires :public Field_timestamp {
|
||||
uint dec;
|
||||
public:
|
||||
Field_timestamp_hires(uchar *ptr_arg,
|
||||
uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
TABLE_SHARE *share, uint dec_arg, CHARSET_INFO *cs) :
|
||||
Field_timestamp(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1, null_ptr_arg,
|
||||
null_bit_arg, unireg_check_arg, field_name_arg, share, cs),
|
||||
dec(dec_arg)
|
||||
{
|
||||
DBUG_ASSERT(dec);
|
||||
DBUG_ASSERT(dec <= MAX_SEC_PART_DIGITS);
|
||||
}
|
||||
void sql_type(String &str) const;
|
||||
long get_timestamp(ulong *sec_part) const;
|
||||
void store_TIME(my_time_t timestamp, ulong sec_part);
|
||||
int store_decimal(const my_decimal *d);
|
||||
double val_real(void);
|
||||
String *val_str(String*,String *);
|
||||
bool send_binary(Protocol *protocol);
|
||||
int cmp(const uchar *,const uchar *);
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint decimals() const { return dec; }
|
||||
int set_time();
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
|
||||
void make_field(Send_field *field);
|
||||
uint32 pack_length() const;
|
||||
uchar *pack(uchar *to, const uchar *from,
|
||||
uint max_length, bool low_byte_first)
|
||||
{ return Field::pack(to, from, max_length, low_byte_first); }
|
||||
const uchar *unpack(uchar* to, const uchar *from, uint param_data,
|
||||
bool low_byte_first)
|
||||
{ return Field::unpack(to, from, param_data, low_byte_first); }
|
||||
};
|
||||
|
||||
|
||||
class Field_year :public Field_tiny {
|
||||
public:
|
||||
Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||
@ -1279,39 +1275,51 @@ public:
|
||||
String *val_str(String*,String *);
|
||||
bool send_binary(Protocol *protocol);
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
};
|
||||
|
||||
|
||||
class Field_date :public Field_str {
|
||||
class Field_temporal: public Field_str {
|
||||
protected:
|
||||
int store_TIME_with_warning(MYSQL_TIME *ltime, const Lazy_string *str,
|
||||
int was_cut, int have_smth_to_conv);
|
||||
virtual void store_TIME(MYSQL_TIME *ltime) = 0;
|
||||
virtual timestamp_type temporal_type() = 0;
|
||||
public:
|
||||
Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
|
||||
uchar null_bit_arg, utype unireg_check_arg,
|
||||
const char *field_name_arg, CHARSET_INFO *charset_arg)
|
||||
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
|
||||
field_name_arg, charset_arg) { }
|
||||
enum Item_result cmp_type () const { return TIME_RESULT; }
|
||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int store_time(MYSQL_TIME *ltime, timestamp_type type);
|
||||
};
|
||||
|
||||
class Field_date :public Field_temporal {
|
||||
void store_TIME(MYSQL_TIME *ltime);
|
||||
timestamp_type temporal_type()
|
||||
{ return MYSQL_TIMESTAMP_DATE; }
|
||||
public:
|
||||
Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
:Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
{}
|
||||
Field_date(bool maybe_null_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str((uchar*) 0, MAX_DATE_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
|
||||
NONE, field_name_arg, cs) {}
|
||||
enum_field_types type() const { return MYSQL_TYPE_DATE;}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
String *val_str(String*,String *);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
uint decimals() const { return 0; }
|
||||
bool send_binary(Protocol *protocol);
|
||||
int cmp(const uchar *,const uchar *);
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const { return 4; }
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
bool zero_pack() const { return 1; }
|
||||
uchar *pack(uchar* to, const uchar *from,
|
||||
uint max_length __attribute__((unused)), bool low_byte_first)
|
||||
@ -1327,27 +1335,21 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Field_newdate :public Field_str {
|
||||
class Field_newdate :public Field_temporal {
|
||||
void store_TIME(MYSQL_TIME *ltime);
|
||||
timestamp_type temporal_type() { return MYSQL_TIMESTAMP_DATE; }
|
||||
public:
|
||||
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
:Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
{}
|
||||
Field_newdate(bool maybe_null_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
|
||||
NONE, field_name_arg, cs) {}
|
||||
enum_field_types type() const { return MYSQL_TYPE_DATE;}
|
||||
enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; }
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int store_time(MYSQL_TIME *ltime, timestamp_type type);
|
||||
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
|
||||
uint decimals() const { return 0; }
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
String *val_str(String*,String *);
|
||||
@ -1356,75 +1358,84 @@ public:
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const { return 3; }
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
bool zero_pack() const { return 1; }
|
||||
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
};
|
||||
|
||||
|
||||
class Field_time :public Field_str {
|
||||
class Field_time :public Field_temporal {
|
||||
void store_TIME(MYSQL_TIME *ltime);
|
||||
timestamp_type temporal_type()
|
||||
{ return MYSQL_TIMESTAMP_TIME; }
|
||||
public:
|
||||
Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
|
||||
uchar null_bit_arg, enum utype unireg_check_arg,
|
||||
const char *field_name_arg, CHARSET_INFO *cs)
|
||||
:Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
{}
|
||||
Field_time(bool maybe_null_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
|
||||
NONE, field_name_arg, cs) {}
|
||||
enum_field_types type() const { return MYSQL_TYPE_TIME;}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
int store_time(MYSQL_TIME *ltime, timestamp_type type);
|
||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
|
||||
uint decimals() const { return 0; }
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
String *val_str(String*,String *);
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
|
||||
bool send_binary(Protocol *protocol);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
int cmp(const uchar *,const uchar *);
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const { return 3; }
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
bool zero_pack() const { return 1; }
|
||||
};
|
||||
|
||||
|
||||
class Field_datetime :public Field_str {
|
||||
class Field_time_hires :public Field_time {
|
||||
uint dec;
|
||||
void store_TIME(MYSQL_TIME *ltime);
|
||||
public:
|
||||
Field_datetime(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
{}
|
||||
Field_datetime(bool maybe_null_arg, const char *field_name_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_str((uchar*) 0, MAX_DATETIME_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
|
||||
NONE, field_name_arg, cs) {}
|
||||
enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
|
||||
#ifdef HAVE_LONG_LONG
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
|
||||
#endif
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
uint decimals() const { return DATETIME_DEC; }
|
||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int store_time(MYSQL_TIME *ltime, timestamp_type type);
|
||||
int reset(void)
|
||||
Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
uint dec_arg, CHARSET_INFO *cs)
|
||||
:Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + 1, null_ptr_arg,
|
||||
null_bit_arg, unireg_check_arg, field_name_arg, cs),
|
||||
dec(dec_arg)
|
||||
{
|
||||
ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
|
||||
return 0;
|
||||
DBUG_ASSERT(dec);
|
||||
DBUG_ASSERT(dec <= MAX_SEC_PART_DIGITS);
|
||||
}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
|
||||
uint decimals() const { return dec; }
|
||||
longlong val_int(void) { return (longlong)floor(val_real()); }
|
||||
double val_real(void);
|
||||
String *val_str(String*,String *);
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
|
||||
bool send_binary(Protocol *protocol);
|
||||
int cmp(const uchar *,const uchar *);
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const;
|
||||
void sql_type(String &str) const;
|
||||
void make_field(Send_field *);
|
||||
};
|
||||
|
||||
class Field_datetime :public Field_temporal {
|
||||
void store_TIME(MYSQL_TIME *ltime);
|
||||
timestamp_type temporal_type()
|
||||
{ return MYSQL_TIMESTAMP_DATETIME; }
|
||||
public:
|
||||
Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
|
||||
uchar null_bit_arg, enum utype unireg_check_arg,
|
||||
const char *field_name_arg, CHARSET_INFO *cs)
|
||||
:Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
|
||||
unireg_check_arg, field_name_arg, cs)
|
||||
{}
|
||||
enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
|
||||
enum Item_result cmp_type () const { return TIME_RESULT; }
|
||||
uint decimals() const { return 0; }
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
String *val_str(String*,String *);
|
||||
@ -1433,10 +1444,8 @@ public:
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const { return 8; }
|
||||
void sql_type(String &str) const;
|
||||
bool can_be_compared_as_longlong() const { return TRUE; }
|
||||
bool zero_pack() const { return 1; }
|
||||
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
uchar *pack(uchar* to, const uchar *from,
|
||||
uint max_length __attribute__((unused)), bool low_byte_first)
|
||||
{
|
||||
@ -1451,6 +1460,81 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Field_datetime_hires :public Field_datetime {
|
||||
void store_TIME(MYSQL_TIME *ltime);
|
||||
uint dec;
|
||||
public:
|
||||
Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg,
|
||||
uchar null_bit_arg, enum utype unireg_check_arg,
|
||||
const char *field_name_arg, uint dec_arg,
|
||||
CHARSET_INFO *cs)
|
||||
:Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1,
|
||||
null_ptr_arg, null_bit_arg, unireg_check_arg,
|
||||
field_name_arg, cs), dec(dec_arg)
|
||||
{
|
||||
DBUG_ASSERT(dec);
|
||||
DBUG_ASSERT(dec <= MAX_SEC_PART_DIGITS);
|
||||
}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
|
||||
int store_decimal(const my_decimal *d);
|
||||
uint decimals() const { return dec; }
|
||||
void make_field(Send_field *field);
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
String *val_str(String*,String *);
|
||||
bool send_binary(Protocol *protocol);
|
||||
int cmp(const uchar *,const uchar *);
|
||||
void sort_string(uchar *buff,uint length);
|
||||
uint32 pack_length() const;
|
||||
void sql_type(String &str) const;
|
||||
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
uchar *pack(uchar *to, const uchar *from,
|
||||
uint max_length, bool low_byte_first)
|
||||
{ return Field::pack(to, from, max_length, low_byte_first); }
|
||||
const uchar *unpack(uchar* to, const uchar *from, uint param_data,
|
||||
bool low_byte_first)
|
||||
{ return Field::unpack(to, from, param_data, low_byte_first); }
|
||||
};
|
||||
|
||||
static inline Field_timestamp *
|
||||
new_Field_timestamp(uchar *ptr, uchar *null_ptr, uchar null_bit,
|
||||
enum Field::utype unireg_check, const char *field_name,
|
||||
TABLE_SHARE *share, uint dec, CHARSET_INFO *cs)
|
||||
{
|
||||
if (dec==0 || dec == NOT_FIXED_DEC)
|
||||
return new Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
|
||||
unireg_check, field_name, share, cs);
|
||||
else
|
||||
return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check,
|
||||
field_name, share, dec, cs);
|
||||
}
|
||||
|
||||
static inline Field_time *
|
||||
new_Field_time(uchar *ptr, uchar *null_ptr, uchar null_bit,
|
||||
enum Field::utype unireg_check, const char *field_name,
|
||||
uint dec, CHARSET_INFO *cs)
|
||||
{
|
||||
if (dec == 0 || dec == NOT_FIXED_DEC)
|
||||
return new Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit,
|
||||
unireg_check, field_name, cs);
|
||||
else
|
||||
return new Field_time_hires(ptr, null_ptr, null_bit,
|
||||
unireg_check, field_name, dec, cs);
|
||||
}
|
||||
|
||||
static inline Field_datetime *
|
||||
new_Field_datetime(uchar *ptr, uchar *null_ptr, uchar null_bit,
|
||||
enum Field::utype unireg_check,
|
||||
const char *field_name, uint dec, CHARSET_INFO *cs)
|
||||
{
|
||||
if (dec == 0 || dec == NOT_FIXED_DEC)
|
||||
return new Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
|
||||
unireg_check, field_name, cs);
|
||||
else
|
||||
return new Field_datetime_hires(ptr, null_ptr, null_bit,
|
||||
unireg_check, field_name, dec, cs);
|
||||
}
|
||||
|
||||
class Field_string :public Field_longstr {
|
||||
public:
|
||||
bool can_alter_field_type;
|
||||
@ -1698,9 +1782,6 @@ public:
|
||||
int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; }
|
||||
void reset_fields() { bzero((uchar*) &value,sizeof(value)); }
|
||||
uint32 get_field_buffer_size(void) { return value.alloced_length(); }
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
static
|
||||
#endif
|
||||
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number, bool low_byte_first);
|
||||
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
|
||||
{
|
||||
@ -1727,7 +1808,6 @@ public:
|
||||
uint32 get_length(const uchar *ptr, uint packlength, bool low_byte_first);
|
||||
uint32 get_length(const uchar *ptr_arg)
|
||||
{ return get_length(ptr_arg, this->packlength, table->s->db_low_byte_first); }
|
||||
void put_length(uchar *pos, uint32 length);
|
||||
inline void get_ptr(uchar **str)
|
||||
{
|
||||
memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));
|
||||
|
@ -842,25 +842,26 @@ static void make_sortkey(register SORTPARAM *param,
|
||||
break;
|
||||
}
|
||||
case INT_RESULT:
|
||||
case TIME_RESULT:
|
||||
{
|
||||
longlong value= item->val_int_result();
|
||||
longlong value;
|
||||
if (sort_field->result_type == INT_RESULT)
|
||||
value= item->val_int_result();
|
||||
else
|
||||
{
|
||||
MYSQL_TIME buf;
|
||||
item->get_date_result(&buf, TIME_FUZZY_DATE | TIME_INVALID_DATES);
|
||||
value= pack_time(&buf);
|
||||
}
|
||||
if (maybe_null)
|
||||
{
|
||||
*to++=1; /* purecov: inspected */
|
||||
if (item->null_value)
|
||||
{
|
||||
if (maybe_null)
|
||||
bzero((char*) to-1,sort_field->length+1);
|
||||
else
|
||||
{
|
||||
DBUG_PRINT("warning",
|
||||
("Got null on something that shouldn't be null"));
|
||||
bzero((char*) to,sort_field->length);
|
||||
}
|
||||
bzero((char*) to++, sort_field->length+1);
|
||||
break;
|
||||
}
|
||||
*to++=1; /* purecov: inspected */
|
||||
}
|
||||
#if SIZEOF_LONG_LONG > 4
|
||||
to[7]= (uchar) value;
|
||||
to[6]= (uchar) (value >> 8);
|
||||
to[5]= (uchar) (value >> 16);
|
||||
@ -872,15 +873,6 @@ static void make_sortkey(register SORTPARAM *param,
|
||||
to[0]= (uchar) (value >> 56);
|
||||
else
|
||||
to[0]= (uchar) (value >> 56) ^ 128; /* Reverse signbit */
|
||||
#else
|
||||
to[3]= (uchar) value;
|
||||
to[2]= (uchar) (value >> 8);
|
||||
to[1]= (uchar) (value >> 16);
|
||||
if (item->unsigned_flag) /* Fix sign */
|
||||
to[0]= (uchar) (value >> 24);
|
||||
else
|
||||
to[0]= (uchar) (value >> 24) ^ 128; /* Reverse signbit */
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case DECIMAL_RESULT:
|
||||
@ -890,8 +882,7 @@ static void make_sortkey(register SORTPARAM *param,
|
||||
{
|
||||
if (item->null_value)
|
||||
{
|
||||
bzero((char*)to, sort_field->length+1);
|
||||
to++;
|
||||
bzero((char*) to++, sort_field->length+1);
|
||||
break;
|
||||
}
|
||||
*to++=1;
|
||||
@ -1462,9 +1453,7 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
|
||||
}
|
||||
else
|
||||
{
|
||||
sortorder->result_type= sortorder->item->result_type();
|
||||
if (sortorder->item->result_as_longlong())
|
||||
sortorder->result_type= INT_RESULT;
|
||||
sortorder->result_type= sortorder->item->cmp_type();
|
||||
switch (sortorder->result_type) {
|
||||
case STRING_RESULT:
|
||||
sortorder->length=sortorder->item->max_length;
|
||||
@ -1482,12 +1471,9 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
|
||||
sortorder->length+= sortorder->suffix_length;
|
||||
}
|
||||
break;
|
||||
case TIME_RESULT:
|
||||
case INT_RESULT:
|
||||
#if SIZEOF_LONG_LONG > 4
|
||||
sortorder->length=8; // Size of intern longlong
|
||||
#else
|
||||
sortorder->length=4;
|
||||
#endif
|
||||
break;
|
||||
case DECIMAL_RESULT:
|
||||
sortorder->length=
|
||||
@ -1562,6 +1548,7 @@ get_addon_fields(THD *thd, Field **ptabfield, uint sortlength, uint *plength)
|
||||
Actually we need only the fields referred in the
|
||||
result set. And for some of them it makes sense to use
|
||||
the values directly from sorted fields.
|
||||
But beware the case when item->cmp_type() != item->result_type()
|
||||
*/
|
||||
*plength= 0;
|
||||
|
||||
|
235
sql/item.cc
235
sql/item.cc
@ -461,6 +461,34 @@ void Item::print_item_w_name(String *str, enum_query_type query_type)
|
||||
}
|
||||
|
||||
|
||||
void Item::print_value(String *str)
|
||||
{
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String *ptr, tmp(buff,sizeof(buff),str->charset());
|
||||
ptr= val_str(&tmp);
|
||||
if (!ptr)
|
||||
str->append("NULL");
|
||||
else
|
||||
{
|
||||
switch (result_type())
|
||||
{
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
case STRING_RESULT:
|
||||
str->append('\'');
|
||||
str->append(*ptr);
|
||||
str->append('\'');
|
||||
break;
|
||||
case DECIMAL_RESULT:
|
||||
case REAL_RESULT:
|
||||
case INT_RESULT:
|
||||
str->append(*ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Item::cleanup()
|
||||
{
|
||||
DBUG_ENTER("Item::cleanup");
|
||||
@ -503,6 +531,45 @@ void Item::rename(char *new_name)
|
||||
name= new_name;
|
||||
}
|
||||
|
||||
Item_result Item::cmp_type() const
|
||||
{
|
||||
switch(field_type()) {
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
return DECIMAL_RESULT;
|
||||
case MYSQL_TYPE_TINY:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
case MYSQL_TYPE_LONG:
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_YEAR:
|
||||
case MYSQL_TYPE_BIT:
|
||||
case MYSQL_TYPE_ENUM:
|
||||
case MYSQL_TYPE_SET:
|
||||
return INT_RESULT;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
return REAL_RESULT;
|
||||
case MYSQL_TYPE_NULL:
|
||||
case MYSQL_TYPE_VARCHAR:
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_GEOMETRY:
|
||||
return STRING_RESULT;
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_TIME:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_NEWDATE:
|
||||
return TIME_RESULT;
|
||||
};
|
||||
DBUG_ASSERT(0);
|
||||
return (Item_result)-1;
|
||||
}
|
||||
|
||||
/**
|
||||
Traverse item tree possibly transforming it (replacing items).
|
||||
@ -915,13 +982,15 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const
|
||||
|
||||
bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
|
||||
{
|
||||
if (result_type() == STRING_RESULT)
|
||||
if (field_type() == MYSQL_TYPE_TIME)
|
||||
fuzzydate|= TIME_TIME_ONLY;
|
||||
if (result_type() == STRING_RESULT || fuzzydate & TIME_TIME_ONLY)
|
||||
{
|
||||
char buff[40];
|
||||
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)
|
||||
str_to_datetime_with_warn(res->ptr(), res->length(), ltime,
|
||||
fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
@ -946,22 +1015,14 @@ err:
|
||||
}
|
||||
|
||||
/**
|
||||
Get time of first argument.\
|
||||
Get time of first argument.
|
||||
|
||||
As a extra convenience the time structure is reset on error!
|
||||
*/
|
||||
|
||||
bool Item::get_time(MYSQL_TIME *ltime)
|
||||
{
|
||||
char buff[40];
|
||||
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
|
||||
if (!(res=val_str(&tmp)) ||
|
||||
str_to_time_with_warn(res->ptr(), res->length(), ltime))
|
||||
{
|
||||
bzero((char*) ltime,sizeof(*ltime));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return get_date(ltime, TIME_TIME_ONLY);
|
||||
}
|
||||
|
||||
CHARSET_INFO *Item::default_charset()
|
||||
@ -987,6 +1048,7 @@ int Item::save_in_field_no_warnings(Field *field, bool no_conversions)
|
||||
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
|
||||
ulong sql_mode= thd->variables.sql_mode;
|
||||
thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
|
||||
thd->variables.sql_mode|= MODE_INVALID_DATES;
|
||||
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||
res= save_in_field(field, no_conversions);
|
||||
thd->count_cuted_fields= tmp;
|
||||
@ -2085,16 +2147,6 @@ bool Item_field::get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Item_field::get_time(MYSQL_TIME *ltime)
|
||||
{
|
||||
if ((null_value=field->is_null()) || field->get_time(ltime))
|
||||
{
|
||||
bzero((char*) ltime,sizeof(*ltime));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Item_field::val_result()
|
||||
{
|
||||
if ((null_value=result_field->is_null()))
|
||||
@ -2698,13 +2750,16 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
|
||||
value.time= *tm;
|
||||
value.time.time_type= time_type;
|
||||
|
||||
decimals= value.time.second_part > 0 ? MAX_SEC_PART_DIGITS : 0;
|
||||
|
||||
if (value.time.year > 9999 || value.time.month > 12 ||
|
||||
value.time.day > 31 ||
|
||||
(time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23) ||
|
||||
value.time.minute > 59 || value.time.second > 59)
|
||||
value.time.minute > 59 || value.time.second > 59 ||
|
||||
value.time.second_part >= MAX_SEC_PART_VALUE)
|
||||
{
|
||||
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, decimals);
|
||||
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
buff, length, time_type, 0);
|
||||
set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR);
|
||||
@ -2713,7 +2768,6 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
|
||||
state= TIME_VALUE;
|
||||
maybe_null= 0;
|
||||
max_length= max_length_arg;
|
||||
decimals= 0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -2790,10 +2844,12 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
|
||||
case REAL_RESULT:
|
||||
set_double(*(double*)entry->value);
|
||||
item_type= Item::REAL_ITEM;
|
||||
param_type= MYSQL_TYPE_DOUBLE;
|
||||
break;
|
||||
case INT_RESULT:
|
||||
set_int(*(longlong*)entry->value, MY_INT64_NUM_DECIMAL_DIGITS);
|
||||
item_type= Item::INT_ITEM;
|
||||
param_type= MYSQL_TYPE_LONGLONG;
|
||||
break;
|
||||
case STRING_RESULT:
|
||||
{
|
||||
@ -2816,6 +2872,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
|
||||
charset of connection, so we have to set it later.
|
||||
*/
|
||||
item_type= Item::STRING_ITEM;
|
||||
param_type= MYSQL_TYPE_VARCHAR;
|
||||
|
||||
if (set_str((const char *)entry->value, entry->length))
|
||||
DBUG_RETURN(1);
|
||||
@ -2831,6 +2888,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
|
||||
my_decimal_precision_to_length_no_truncation(ent_value->precision(),
|
||||
decimals, unsigned_flag);
|
||||
item_type= Item::DECIMAL_ITEM;
|
||||
param_type= MYSQL_TYPE_NEWDECIMAL;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -2911,21 +2969,6 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
|
||||
}
|
||||
|
||||
|
||||
bool Item_param::get_time(MYSQL_TIME *res)
|
||||
{
|
||||
if (state == TIME_VALUE)
|
||||
{
|
||||
*res= value.time;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
If parameter value isn't supplied assertion will fire in val_str()
|
||||
which is called from Item::get_time().
|
||||
*/
|
||||
return Item::get_time(res);
|
||||
}
|
||||
|
||||
|
||||
bool Item_param::get_date(MYSQL_TIME *res, uint fuzzydate)
|
||||
{
|
||||
if (state == TIME_VALUE)
|
||||
@ -3055,7 +3098,8 @@ String *Item_param::val_str(String* str)
|
||||
{
|
||||
if (str->reserve(MAX_DATE_STRING_REP_LENGTH))
|
||||
break;
|
||||
str->length((uint) my_TIME_to_str(&value.time, (char*) str->ptr()));
|
||||
str->length((uint) my_TIME_to_str(&value.time, (char*) str->ptr(),
|
||||
decimals));
|
||||
str->set_charset(&my_charset_bin);
|
||||
return str;
|
||||
}
|
||||
@ -3107,7 +3151,7 @@ const String *Item_param::query_val_str(String* str) const
|
||||
buf= str->c_ptr_quick();
|
||||
ptr= buf;
|
||||
*ptr++= '\'';
|
||||
ptr+= (uint) my_TIME_to_str(&value.time, ptr);
|
||||
ptr+= (uint) my_TIME_to_str(&value.time, ptr, decimals);
|
||||
*ptr++= '\'';
|
||||
str->length((uint32) (ptr - buf));
|
||||
break;
|
||||
@ -3387,8 +3431,7 @@ void Item_copy_int::copy()
|
||||
null_value=item->null_value;
|
||||
}
|
||||
|
||||
static int save_int_value_in_field (Field *field, longlong nr,
|
||||
bool null_value, bool unsigned_flag);
|
||||
static int save_int_value_in_field (Field *, longlong, bool, bool);
|
||||
|
||||
int Item_copy_int::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
@ -4651,12 +4694,7 @@ Item *Item_field::equal_fields_propagator(uchar *arg)
|
||||
item= this;
|
||||
else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()))
|
||||
{
|
||||
/*
|
||||
We don't need to zero-fill timestamp columns here because they will be
|
||||
first converted to a string (in date/time format) and compared as such if
|
||||
compared with another string.
|
||||
*/
|
||||
if (item && field->type() != FIELD_TYPE_TIMESTAMP && cmp_context != INT_RESULT)
|
||||
if (item && (cmp_context == STRING_RESULT || cmp_context == (Item_result)-1))
|
||||
convert_zerofill_number_to_string(&item, (Field_num *)field);
|
||||
else
|
||||
item= this;
|
||||
@ -4782,21 +4820,6 @@ enum_field_types Item::field_type() const
|
||||
}
|
||||
|
||||
|
||||
bool Item::is_datetime()
|
||||
{
|
||||
switch (field_type())
|
||||
{
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
String *Item::check_well_formed_result(String *str, bool send_error)
|
||||
{
|
||||
/* Check whether we got a well-formed string */
|
||||
@ -4973,16 +4996,19 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
|
||||
break;
|
||||
case MYSQL_TYPE_NEWDATE:
|
||||
case MYSQL_TYPE_DATE:
|
||||
field= new Field_newdate(maybe_null, name, &my_charset_bin);
|
||||
field= new Field_newdate(0, null_ptr, 0, Field::NONE, name, &my_charset_bin);
|
||||
break;
|
||||
case MYSQL_TYPE_TIME:
|
||||
field= new Field_time(maybe_null, name, &my_charset_bin);
|
||||
field= new_Field_time(0, null_ptr, 0, Field::NONE, name,
|
||||
decimals, &my_charset_bin);
|
||||
break;
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
field= new Field_timestamp(maybe_null, name, &my_charset_bin);
|
||||
field= new_Field_timestamp(0, null_ptr, 0,
|
||||
Field::NONE, name, 0, decimals, &my_charset_bin);
|
||||
break;
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
field= new Field_datetime(maybe_null, name, &my_charset_bin);
|
||||
field= new_Field_datetime(0, null_ptr, 0, Field::NONE, name,
|
||||
decimals, &my_charset_bin);
|
||||
break;
|
||||
case MYSQL_TYPE_YEAR:
|
||||
field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
|
||||
@ -5197,12 +5223,6 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
|
||||
}
|
||||
|
||||
|
||||
int Item_uint::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
/* Item_int::save_in_field handles both signed and unsigned. */
|
||||
return Item_int::save_in_field(field, no_conversions);
|
||||
}
|
||||
|
||||
static int save_int_value_in_field (Field *field, longlong nr,
|
||||
bool null_value, bool unsigned_flag)
|
||||
{
|
||||
@ -5219,6 +5239,22 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
|
||||
}
|
||||
|
||||
|
||||
void Item_datetime::set(longlong packed)
|
||||
{
|
||||
unpack_time(packed, <ime);
|
||||
}
|
||||
|
||||
int Item_datetime::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
field->set_notnull();
|
||||
return field->store_time(<ime, ltime.time_type);
|
||||
}
|
||||
|
||||
longlong Item_datetime::val_int()
|
||||
{
|
||||
return TIME_to_ulonglong(<ime);
|
||||
}
|
||||
|
||||
int Item_decimal::save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
field->set_notnull();
|
||||
@ -5643,7 +5679,7 @@ bool Item::send(Protocol *protocol, String *buffer)
|
||||
if (f_type == MYSQL_TYPE_DATE)
|
||||
return protocol->store_date(&tm);
|
||||
else
|
||||
result= protocol->store(&tm);
|
||||
result= protocol->store(&tm, decimals);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -5652,7 +5688,7 @@ bool Item::send(Protocol *protocol, String *buffer)
|
||||
MYSQL_TIME tm;
|
||||
get_time(&tm);
|
||||
if (!null_value)
|
||||
result= protocol->store_time(&tm);
|
||||
result= protocol->store_time(&tm, decimals);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -5733,17 +5769,7 @@ void Item_field::print(String *str, enum_query_type query_type)
|
||||
{
|
||||
if (field && field->table->const_table)
|
||||
{
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String tmp(buff,sizeof(buff),str->charset());
|
||||
field->val_str(&tmp);
|
||||
if (field->is_null())
|
||||
str->append("NULL");
|
||||
else
|
||||
{
|
||||
str->append('\'');
|
||||
str->append(tmp);
|
||||
str->append('\'');
|
||||
}
|
||||
print_value(str);
|
||||
return;
|
||||
}
|
||||
Item_ident::print(str, query_type);
|
||||
@ -6839,6 +6865,8 @@ Item_result item_cmp_type(Item_result a,Item_result b)
|
||||
return INT_RESULT;
|
||||
else if (a == ROW_RESULT || b == ROW_RESULT)
|
||||
return ROW_RESULT;
|
||||
else if (a == TIME_RESULT || b == TIME_RESULT)
|
||||
return TIME_RESULT;
|
||||
if ((a == INT_RESULT || a == DECIMAL_RESULT) &&
|
||||
(b == INT_RESULT || b == DECIMAL_RESULT))
|
||||
return DECIMAL_RESULT;
|
||||
@ -6952,6 +6980,9 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
|
||||
@note We only use this on the range optimizer/partition pruning,
|
||||
because in some cases we can't store the value in the field
|
||||
without some precision/character loss.
|
||||
|
||||
@todo rewrite it to use Arg_comparator (currently it's a simplified and
|
||||
incomplete version of it)
|
||||
*/
|
||||
|
||||
int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
|
||||
@ -7009,6 +7040,21 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
|
||||
field_val= field->val_decimal(&field_buf);
|
||||
return my_decimal_cmp(item_val, field_val);
|
||||
}
|
||||
if (field->cmp_type() == TIME_RESULT)
|
||||
{
|
||||
MYSQL_TIME field_time, item_time;
|
||||
if (field->type() == MYSQL_TYPE_TIME)
|
||||
{
|
||||
field->get_time(&field_time);
|
||||
item->get_time(&item_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
field->get_date(&field_time, TIME_FUZZY_DATE | TIME_INVALID_DATES);
|
||||
item->get_date(&item_time, TIME_FUZZY_DATE | TIME_INVALID_DATES);
|
||||
}
|
||||
return my_time_compare(&field_time, &item_time);
|
||||
}
|
||||
double result= item->val_real();
|
||||
if (item->null_value)
|
||||
return 0;
|
||||
@ -7048,6 +7094,8 @@ Item_cache* Item_cache::get_cache(const Item *item, const Item_result type)
|
||||
return new Item_cache_str(item);
|
||||
case ROW_RESULT:
|
||||
return new Item_cache_row();
|
||||
case TIME_RESULT:
|
||||
return new Item_cache_int(MYSQL_TYPE_DATETIME);
|
||||
default:
|
||||
// should never be in real life
|
||||
DBUG_ASSERT(0);
|
||||
@ -7065,6 +7113,11 @@ void Item_cache::store(Item *item)
|
||||
|
||||
void Item_cache::print(String *str, enum_query_type query_type)
|
||||
{
|
||||
if (value_cached)
|
||||
{
|
||||
print_value(str);
|
||||
return;
|
||||
}
|
||||
str->append(STRING_WITH_LEN("<cache>("));
|
||||
if (example)
|
||||
example->print(str, query_type);
|
||||
@ -7100,7 +7153,7 @@ String *Item_cache_int::val_str(String *str)
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (!value_cached && !cache_value())
|
||||
return NULL;
|
||||
str->set(value, default_charset());
|
||||
str->set_int(value, unsigned_flag, default_charset());
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -7466,7 +7519,7 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
|
||||
case FIELD_ITEM:
|
||||
{
|
||||
/*
|
||||
Item_fields::field_type ask Field_type() but sometimes field return
|
||||
Item_field::field_type ask Field_type() but sometimes field return
|
||||
a different type, like for enum/set, so we need to ask real type.
|
||||
*/
|
||||
Field *field= ((Item_field *) item)->field;
|
||||
|
60
sql/item.h
60
sql/item.h
@ -569,7 +569,8 @@ public:
|
||||
virtual bool send(Protocol *protocol, String *str);
|
||||
virtual bool eq(const Item *, bool binary_cmp) const;
|
||||
virtual Item_result result_type() const { return REAL_RESULT; }
|
||||
virtual Item_result cast_to_int_type() const { return result_type(); }
|
||||
virtual Item_result cmp_type() const;
|
||||
virtual Item_result cast_to_int_type() const { return cmp_type(); }
|
||||
virtual enum_field_types string_field_type() const;
|
||||
virtual enum_field_types field_type() const;
|
||||
virtual enum Type type() const =0;
|
||||
@ -801,6 +802,7 @@ public:
|
||||
}
|
||||
|
||||
void print_item_w_name(String *, enum_query_type query_type);
|
||||
void print_value(String *);
|
||||
virtual void update_used_tables() {}
|
||||
virtual void split_sum_func(THD *thd, Item **ref_pointer_array,
|
||||
List<Item> &fields) {}
|
||||
@ -808,7 +810,7 @@ public:
|
||||
void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
|
||||
Item **ref, bool skip_registered);
|
||||
virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
virtual bool get_time(MYSQL_TIME *ltime);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
virtual bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
|
||||
{ return get_date(ltime,fuzzydate); }
|
||||
/*
|
||||
@ -1037,15 +1039,6 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
result_as_longlong() must return TRUE for Items representing DATE/TIME
|
||||
functions and DATE/TIME table fields.
|
||||
Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
|
||||
their values should be compared as integers (because the integer
|
||||
representation is more precise than the string one).
|
||||
*/
|
||||
virtual bool result_as_longlong() { return FALSE; }
|
||||
bool is_datetime();
|
||||
virtual Field::geometry_type get_geometry_type() const
|
||||
{ return Field::GEOM_GEOMETRY; };
|
||||
String *check_well_formed_result(String *str, bool send_error= 0);
|
||||
@ -1514,7 +1507,6 @@ public:
|
||||
Field *tmp_table_field(TABLE *t_arg) { return result_field; }
|
||||
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
bool is_null() { return field->is_null(); }
|
||||
void update_null_value();
|
||||
Item *get_tmp_table_item(THD *thd);
|
||||
@ -1523,10 +1515,6 @@ public:
|
||||
bool register_field_in_read_map(uchar *arg);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
void cleanup();
|
||||
bool result_as_longlong()
|
||||
{
|
||||
return field->can_be_compared_as_longlong();
|
||||
}
|
||||
Item_equal *find_item_equal(COND_EQUAL *cond_equal);
|
||||
bool subst_argument_checker(uchar **arg);
|
||||
Item *equal_fields_propagator(uchar *arg);
|
||||
@ -1671,6 +1659,7 @@ public:
|
||||
Item_param(uint pos_in_query_arg);
|
||||
|
||||
enum Item_result result_type () const { return item_result_type; }
|
||||
enum Item_result cast_to_int_type() const { return item_result_type; }
|
||||
enum Type type() const { return item_type; }
|
||||
enum_field_types field_type() const { return param_type; }
|
||||
|
||||
@ -1678,7 +1667,6 @@ public:
|
||||
longlong val_int();
|
||||
my_decimal *val_decimal(my_decimal*);
|
||||
String *val_str(String*);
|
||||
bool get_time(MYSQL_TIME *tm);
|
||||
bool get_date(MYSQL_TIME *tm, uint fuzzydate);
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
|
||||
@ -1777,13 +1765,12 @@ class Item_uint :public Item_int
|
||||
{
|
||||
public:
|
||||
Item_uint(const char *str_arg, uint length);
|
||||
Item_uint(ulonglong i) :Item_int((ulonglong) i, 10) {}
|
||||
Item_uint(ulonglong i) :Item_int(i, 10) {}
|
||||
Item_uint(const char *str_arg, longlong i, uint length);
|
||||
double val_real()
|
||||
{ DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); }
|
||||
String *val_str(String*);
|
||||
Item *clone_item() { return new Item_uint(name, value, max_length); }
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
Item_num *neg ();
|
||||
uint decimal_precision() const { return max_length; }
|
||||
@ -1791,6 +1778,19 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Item_datetime :public Item_int
|
||||
{
|
||||
protected:
|
||||
MYSQL_TIME ltime;
|
||||
public:
|
||||
Item_datetime() :Item_int(0) { unsigned_flag=0; }
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
longlong val_int();
|
||||
double val_real() { return val_int(); }
|
||||
void set(longlong packed);
|
||||
};
|
||||
|
||||
|
||||
/* decimal (fixed point) constant */
|
||||
class Item_decimal :public Item_num
|
||||
{
|
||||
@ -2071,8 +2071,9 @@ class Item_return_date_time :public Item_partition_func_safe_string
|
||||
{
|
||||
enum_field_types date_time_field_type;
|
||||
public:
|
||||
Item_return_date_time(const char *name_arg, enum_field_types field_type_arg)
|
||||
:Item_partition_func_safe_string(name_arg, 0, &my_charset_bin),
|
||||
Item_return_date_time(const char *name_arg, uint length_arg,
|
||||
enum_field_types field_type_arg)
|
||||
:Item_partition_func_safe_string(name_arg, length_arg, &my_charset_bin),
|
||||
date_time_field_type(field_type_arg)
|
||||
{ }
|
||||
enum_field_types field_type() const { return date_time_field_type; }
|
||||
@ -2286,10 +2287,6 @@ public:
|
||||
(this->*processor)(arg);
|
||||
}
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
bool result_as_longlong()
|
||||
{
|
||||
return (*ref)->result_as_longlong();
|
||||
}
|
||||
void cleanup();
|
||||
Item_field *filed_for_view_update()
|
||||
{ return (*ref)->filed_for_view_update(); }
|
||||
@ -2322,12 +2319,6 @@ public:
|
||||
if (ref && result_type() == ROW_RESULT)
|
||||
(*ref)->bring_value();
|
||||
}
|
||||
bool get_time(MYSQL_TIME *ltime)
|
||||
{
|
||||
DBUG_ASSERT(fixed);
|
||||
return (*ref)->get_time(ltime);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -3031,7 +3022,7 @@ class Item_cache_int: public Item_cache
|
||||
protected:
|
||||
longlong value;
|
||||
public:
|
||||
Item_cache_int(): Item_cache(),
|
||||
Item_cache_int(): Item_cache(MYSQL_TYPE_LONGLONG),
|
||||
value(0) {}
|
||||
Item_cache_int(enum_field_types field_type_arg):
|
||||
Item_cache(field_type_arg), value(0) {}
|
||||
@ -3043,7 +3034,6 @@ public:
|
||||
String* val_str(String *str);
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
enum Item_result result_type() const { return INT_RESULT; }
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
bool cache_value();
|
||||
};
|
||||
|
||||
@ -3052,7 +3042,7 @@ class Item_cache_real: public Item_cache
|
||||
{
|
||||
double value;
|
||||
public:
|
||||
Item_cache_real(): Item_cache(),
|
||||
Item_cache_real(): Item_cache(MYSQL_TYPE_DOUBLE),
|
||||
value(0) {}
|
||||
|
||||
double val_real();
|
||||
@ -3069,7 +3059,7 @@ class Item_cache_decimal: public Item_cache
|
||||
protected:
|
||||
my_decimal decimal_value;
|
||||
public:
|
||||
Item_cache_decimal(): Item_cache() {}
|
||||
Item_cache_decimal(): Item_cache(MYSQL_TYPE_NEWDECIMAL) {}
|
||||
|
||||
double val_real();
|
||||
longlong val_int();
|
||||
|
@ -30,9 +30,6 @@
|
||||
#include "sql_select.h"
|
||||
|
||||
static bool convert_constant_item(THD *, Item_field *, Item **);
|
||||
static longlong
|
||||
get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
Item *warn_item, bool *is_null);
|
||||
|
||||
static Item_result item_store_type(Item_result a, Item *item,
|
||||
my_bool unsigned_flag)
|
||||
@ -138,10 +135,10 @@ static int cmp_row_type(Item* item1, Item* item2)
|
||||
static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
|
||||
{
|
||||
uint i;
|
||||
type[0]= items[0]->result_type();
|
||||
type[0]= items[0]->cmp_type();
|
||||
for (i= 1 ; i < nitems ; i++)
|
||||
{
|
||||
type[0]= item_cmp_type(type[0], items[i]->result_type());
|
||||
type[0]= item_cmp_type(type[0], items[i]->cmp_type());
|
||||
/*
|
||||
When aggregating types of two row expressions we have to check
|
||||
that they have the same cardinality and that each component
|
||||
@ -488,48 +485,27 @@ void Item_bool_func2::fix_length_and_dec()
|
||||
|
||||
args[0]->cmp_context= args[1]->cmp_context=
|
||||
item_cmp_type(args[0]->result_type(), args[1]->result_type());
|
||||
// Make a special case of compare with fields to get nicer DATE comparisons
|
||||
|
||||
if (functype() == LIKE_FUNC) // Disable conversion in case of LIKE function.
|
||||
{
|
||||
set_cmp_func();
|
||||
return;
|
||||
}
|
||||
/*
|
||||
Make a special case of compare with fields to get nicer comparisons
|
||||
of numbers with constant string.
|
||||
This directly contradicts the manual (number and a string should
|
||||
be compared as doubles), but seems to provide more
|
||||
"intuitive" behavior in some cases (but less intuitive in others).
|
||||
|
||||
But disable conversion in case of LIKE function.
|
||||
*/
|
||||
thd= current_thd;
|
||||
if (!thd->is_context_analysis_only())
|
||||
if (functype() != LIKE_FUNC && !thd->is_context_analysis_only())
|
||||
{
|
||||
if (args[0]->real_item()->type() == FIELD_ITEM)
|
||||
int field;
|
||||
if (args[field= 0]->real_item()->type() == FIELD_ITEM ||
|
||||
args[field= 1]->real_item()->type() == FIELD_ITEM)
|
||||
{
|
||||
Item_field *field_item= (Item_field*) (args[0]->real_item());
|
||||
if (field_item->field->can_be_compared_as_longlong() &&
|
||||
!(field_item->is_datetime() &&
|
||||
args[1]->result_type() == STRING_RESULT))
|
||||
{
|
||||
if (convert_constant_item(thd, field_item, &args[1]))
|
||||
{
|
||||
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
|
||||
INT_RESULT); // Works for all types.
|
||||
args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args[1]->real_item()->type() == FIELD_ITEM)
|
||||
{
|
||||
Item_field *field_item= (Item_field*) (args[1]->real_item());
|
||||
if (field_item->field->can_be_compared_as_longlong() &&
|
||||
!(field_item->is_datetime() &&
|
||||
args[0]->result_type() == STRING_RESULT))
|
||||
{
|
||||
if (convert_constant_item(thd, field_item, &args[0]))
|
||||
{
|
||||
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
|
||||
INT_RESULT); // Works for all types.
|
||||
args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Item_field *field_item= (Item_field*) (args[field]->real_item());
|
||||
if (field_item->cmp_type() == INT_RESULT &&
|
||||
convert_constant_item(thd, field_item, &args[!field]))
|
||||
args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
|
||||
}
|
||||
}
|
||||
set_cmp_func();
|
||||
@ -543,6 +519,8 @@ int Arg_comparator::set_compare_func(Item_result_field *item, Item_result type)
|
||||
[is_owner_equal_func()];
|
||||
|
||||
switch (type) {
|
||||
case TIME_RESULT:
|
||||
break;
|
||||
case ROW_RESULT:
|
||||
{
|
||||
uint n= (*a)->cols();
|
||||
@ -669,16 +647,17 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
|
||||
bool value;
|
||||
int error;
|
||||
enum_mysql_timestamp_type timestamp_type;
|
||||
int flags= TIME_FUZZY_DATE | MODE_INVALID_DATES;
|
||||
|
||||
flags|= thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
|
||||
|
||||
if (warn_type == MYSQL_TIMESTAMP_TIME)
|
||||
flags|= TIME_TIME_ONLY;
|
||||
|
||||
timestamp_type=
|
||||
str_to_datetime(str->ptr(), str->length(), l_time,
|
||||
(TIME_FUZZY_DATE | MODE_INVALID_DATES |
|
||||
(thd->variables.sql_mode &
|
||||
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE))),
|
||||
&error);
|
||||
str_to_datetime(str->ptr(), str->length(), l_time, flags, &error);
|
||||
|
||||
if (timestamp_type == MYSQL_TIMESTAMP_DATETIME ||
|
||||
timestamp_type == MYSQL_TIMESTAMP_DATE)
|
||||
if (timestamp_type > MYSQL_TIMESTAMP_ERROR)
|
||||
/*
|
||||
Do not return yet, we may still want to throw a "trailing garbage"
|
||||
warning.
|
||||
@ -726,164 +705,7 @@ static ulonglong get_date_from_str(THD *thd, String *str,
|
||||
|
||||
if (*error_arg)
|
||||
return 0;
|
||||
return TIME_to_ulonglong_datetime(&l_time);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check whether compare_datetime() can be used to compare items.
|
||||
|
||||
SYNOPSIS
|
||||
Arg_comparator::can_compare_as_dates()
|
||||
a, b [in] items to be compared
|
||||
const_value [out] converted value of the string constant, if any
|
||||
|
||||
DESCRIPTION
|
||||
Check several cases when the DATE/DATETIME comparator should be used.
|
||||
The following cases are checked:
|
||||
1. Both a and b is a DATE/DATETIME field/function returning string or
|
||||
int result.
|
||||
2. Only a or b is a DATE/DATETIME field/function returning string or
|
||||
int result and the other item (b or a) is an item with string result.
|
||||
If the second item is a constant one then it's checked to be
|
||||
convertible to the DATE/DATETIME type. If the constant can't be
|
||||
converted to a DATE/DATETIME then the compare_datetime() comparator
|
||||
isn't used and the warning about wrong DATE/DATETIME value is issued.
|
||||
In all other cases (date-[int|real|decimal]/[int|real|decimal]-date)
|
||||
the comparison is handled by other comparators.
|
||||
If the datetime comparator can be used and one the operands of the
|
||||
comparison is a string constant that was successfully converted to a
|
||||
DATE/DATETIME type then the result of the conversion is returned in the
|
||||
const_value if it is provided. If there is no constant or
|
||||
compare_datetime() isn't applicable then the *const_value remains
|
||||
unchanged.
|
||||
|
||||
RETURN
|
||||
the found type of date comparison
|
||||
*/
|
||||
|
||||
enum Arg_comparator::enum_date_cmp_type
|
||||
Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
|
||||
{
|
||||
enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
|
||||
Item *str_arg= 0, *date_arg= 0;
|
||||
|
||||
if (a->type() == Item::ROW_ITEM || b->type() == Item::ROW_ITEM)
|
||||
return CMP_DATE_DFLT;
|
||||
|
||||
if (a->is_datetime())
|
||||
{
|
||||
if (b->is_datetime())
|
||||
cmp_type= CMP_DATE_WITH_DATE;
|
||||
else if (b->result_type() == STRING_RESULT)
|
||||
{
|
||||
cmp_type= CMP_DATE_WITH_STR;
|
||||
date_arg= a;
|
||||
str_arg= b;
|
||||
}
|
||||
}
|
||||
else if (b->is_datetime() && a->result_type() == STRING_RESULT)
|
||||
{
|
||||
cmp_type= CMP_STR_WITH_DATE;
|
||||
date_arg= b;
|
||||
str_arg= a;
|
||||
}
|
||||
|
||||
if (cmp_type != CMP_DATE_DFLT)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
/*
|
||||
Do not cache GET_USER_VAR() function as its const_item() may return TRUE
|
||||
for the current thread but it still may change during the execution.
|
||||
Don't use cache while in the context analysis mode only (i.e. for
|
||||
EXPLAIN/CREATE VIEW and similar queries). Cache is useless in such
|
||||
cases and can cause problems. For example evaluating subqueries can
|
||||
confuse storage engines since in context analysis mode tables
|
||||
aren't locked.
|
||||
*/
|
||||
if (!thd->is_context_analysis_only() &&
|
||||
cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() &&
|
||||
(str_arg->type() != Item::FUNC_ITEM ||
|
||||
((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
|
||||
{
|
||||
ulonglong value;
|
||||
bool error;
|
||||
String tmp, *str_val= 0;
|
||||
timestamp_type t_type= (date_arg->field_type() == MYSQL_TYPE_DATE ?
|
||||
MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME);
|
||||
|
||||
str_val= str_arg->val_str(&tmp);
|
||||
if (str_arg->null_value)
|
||||
return CMP_DATE_DFLT;
|
||||
value= get_date_from_str(thd, str_val, t_type, date_arg->name, &error);
|
||||
if (error)
|
||||
return CMP_DATE_DFLT;
|
||||
if (const_value)
|
||||
*const_value= value;
|
||||
}
|
||||
}
|
||||
return cmp_type;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Retrieves correct TIME value from the given item.
|
||||
|
||||
SYNOPSIS
|
||||
get_time_value()
|
||||
thd thread handle
|
||||
item_arg [in/out] item to retrieve TIME value from
|
||||
cache_arg [in/out] pointer to place to store the cache item to
|
||||
warn_item [in] unused
|
||||
is_null [out] TRUE <=> the item_arg is null
|
||||
|
||||
DESCRIPTION
|
||||
Retrieves the correct TIME value from given item for comparison by the
|
||||
compare_datetime() function.
|
||||
If item's result can be compared as longlong then its int value is used
|
||||
and a value returned by get_time function is used otherwise.
|
||||
If an item is a constant one then its value is cached and it isn't
|
||||
get parsed again. An Item_cache_int object is used for for cached values.
|
||||
It seamlessly substitutes the original item. The cache item is marked as
|
||||
non-constant to prevent re-caching it again.
|
||||
|
||||
RETURN
|
||||
obtained value
|
||||
*/
|
||||
|
||||
longlong
|
||||
get_time_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
Item *warn_item, bool *is_null)
|
||||
{
|
||||
longlong value;
|
||||
Item *item= **item_arg;
|
||||
MYSQL_TIME ltime;
|
||||
|
||||
if (item->result_as_longlong())
|
||||
{
|
||||
value= item->val_int();
|
||||
*is_null= item->null_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
*is_null= item->get_time(<ime);
|
||||
value= !*is_null ? (longlong) TIME_to_ulonglong_datetime(<ime) : 0;
|
||||
}
|
||||
/*
|
||||
Do not cache GET_USER_VAR() function as its const_item() may return TRUE
|
||||
for the current thread but it still may change during the execution.
|
||||
*/
|
||||
if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
|
||||
((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
|
||||
{
|
||||
Item_cache_int *cache= new Item_cache_int();
|
||||
/* Mark the cache as non-const to prevent re-caching. */
|
||||
cache->set_used_tables(1);
|
||||
cache->store(item, value);
|
||||
*cache_arg= cache;
|
||||
*item_arg= cache_arg;
|
||||
}
|
||||
return value;
|
||||
return pack_time(&l_time);
|
||||
}
|
||||
|
||||
|
||||
@ -891,65 +713,15 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
|
||||
Item **a1, Item **a2,
|
||||
Item_result type)
|
||||
{
|
||||
enum enum_date_cmp_type cmp_type;
|
||||
ulonglong const_value= (ulonglong)-1;
|
||||
thd= current_thd;
|
||||
owner= owner_arg;
|
||||
set_null= set_null && owner_arg;
|
||||
a= a1;
|
||||
b= a2;
|
||||
thd= current_thd;
|
||||
|
||||
if ((cmp_type= can_compare_as_dates(*a, *b, &const_value)))
|
||||
{
|
||||
a_type= (*a)->field_type();
|
||||
b_type= (*b)->field_type();
|
||||
a_cache= 0;
|
||||
b_cache= 0;
|
||||
|
||||
if (const_value != (ulonglong)-1)
|
||||
{
|
||||
/*
|
||||
cache_converted_constant can't be used here because it can't
|
||||
correctly convert a DATETIME value from string to int representation.
|
||||
*/
|
||||
Item_cache_int *cache= new Item_cache_int();
|
||||
/* Mark the cache as non-const to prevent re-caching. */
|
||||
cache->set_used_tables(1);
|
||||
if (!(*a)->is_datetime())
|
||||
{
|
||||
cache->store((*a), const_value);
|
||||
a_cache= cache;
|
||||
a= (Item **)&a_cache;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache->store((*b), const_value);
|
||||
b_cache= cache;
|
||||
b= (Item **)&b_cache;
|
||||
}
|
||||
}
|
||||
is_nulls_eq= is_owner_equal_func();
|
||||
func= &Arg_comparator::compare_datetime;
|
||||
get_value_a_func= &get_datetime_value;
|
||||
get_value_b_func= &get_datetime_value;
|
||||
return 0;
|
||||
}
|
||||
else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME &&
|
||||
(*b)->field_type() == MYSQL_TYPE_TIME)
|
||||
{
|
||||
/* Compare TIME values as integers. */
|
||||
a_cache= 0;
|
||||
b_cache= 0;
|
||||
is_nulls_eq= is_owner_equal_func();
|
||||
func= &Arg_comparator::compare_datetime;
|
||||
get_value_a_func= &get_time_value;
|
||||
get_value_b_func= &get_time_value;
|
||||
return 0;
|
||||
}
|
||||
else if (type == STRING_RESULT &&
|
||||
(*a)->result_type() == STRING_RESULT &&
|
||||
(*b)->result_type() == STRING_RESULT)
|
||||
if (type == STRING_RESULT &&
|
||||
(*a)->result_type() == STRING_RESULT &&
|
||||
(*b)->result_type() == STRING_RESULT)
|
||||
{
|
||||
DTCollation coll;
|
||||
coll.set((*a)->collation.collation);
|
||||
@ -957,8 +729,10 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
|
||||
b, 1, MY_COLL_CMP_CONV, 1))
|
||||
return 1;
|
||||
}
|
||||
else if (try_year_cmp_func(type))
|
||||
return 0;
|
||||
if (type == INT_RESULT &&
|
||||
(*a)->field_type() == MYSQL_TYPE_YEAR &&
|
||||
(*b)->field_type() == MYSQL_TYPE_YEAR)
|
||||
type= TIME_RESULT;
|
||||
|
||||
a= cache_converted_constant(thd, a, &a_cache, type);
|
||||
b= cache_converted_constant(thd, b, &b_cache, type);
|
||||
@ -966,45 +740,6 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Helper function to call from Arg_comparator::set_cmp_func()
|
||||
*/
|
||||
|
||||
bool Arg_comparator::try_year_cmp_func(Item_result type)
|
||||
{
|
||||
if (type == ROW_RESULT)
|
||||
return FALSE;
|
||||
|
||||
bool a_is_year= (*a)->field_type() == MYSQL_TYPE_YEAR;
|
||||
bool b_is_year= (*b)->field_type() == MYSQL_TYPE_YEAR;
|
||||
|
||||
if (!a_is_year && !b_is_year)
|
||||
return FALSE;
|
||||
|
||||
if (a_is_year && b_is_year)
|
||||
{
|
||||
get_value_a_func= &get_year_value;
|
||||
get_value_b_func= &get_year_value;
|
||||
}
|
||||
else if (a_is_year && (*b)->is_datetime())
|
||||
{
|
||||
get_value_a_func= &get_year_value;
|
||||
get_value_b_func= &get_datetime_value;
|
||||
}
|
||||
else if (b_is_year && (*a)->is_datetime())
|
||||
{
|
||||
get_value_b_func= &get_year_value;
|
||||
get_value_a_func= &get_datetime_value;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
is_nulls_eq= is_owner_equal_func();
|
||||
func= &Arg_comparator::compare_datetime;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert and cache a constant.
|
||||
|
||||
@ -1026,9 +761,14 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
|
||||
Item **cache_item,
|
||||
Item_result type)
|
||||
{
|
||||
/* Don't need cache if doing context analysis only. */
|
||||
/*
|
||||
Don't need cache if doing context analysis only.
|
||||
Also, get_datetime_value creates Item_cache internally.
|
||||
Unless fixed, we should not do it here.
|
||||
*/
|
||||
if (!thd_arg->is_context_analysis_only() &&
|
||||
(*value)->const_item() && type != (*value)->result_type())
|
||||
(*value)->const_item() && type != (*value)->result_type() &&
|
||||
type != TIME_RESULT)
|
||||
{
|
||||
Item_cache *cache= Item_cache::get_cache(*value, type);
|
||||
cache->setup(*value);
|
||||
@ -1046,14 +786,9 @@ void Arg_comparator::set_datetime_cmp_func(Item_result_field *owner_arg,
|
||||
owner= owner_arg;
|
||||
a= a1;
|
||||
b= b1;
|
||||
a_type= (*a)->field_type();
|
||||
b_type= (*b)->field_type();
|
||||
a_cache= 0;
|
||||
b_cache= 0;
|
||||
is_nulls_eq= FALSE;
|
||||
func= &Arg_comparator::compare_datetime;
|
||||
get_value_a_func= &get_datetime_value;
|
||||
get_value_b_func= &get_datetime_value;
|
||||
func= comparator_matrix[TIME_RESULT][is_owner_equal_func()];
|
||||
}
|
||||
|
||||
|
||||
@ -1071,81 +806,113 @@ void Arg_comparator::set_datetime_cmp_func(Item_result_field *owner_arg,
|
||||
DESCRIPTION
|
||||
Retrieves the correct DATETIME value from given item for comparison by the
|
||||
compare_datetime() function.
|
||||
If item's result can be compared as longlong then its int value is used
|
||||
and its string value is used otherwise. Strings are always parsed and
|
||||
converted to int values by the get_date_from_str() function.
|
||||
This allows us to compare correctly string dates with missed insignificant
|
||||
zeros. If an item is a constant one then its value is cached and it isn't
|
||||
get parsed again. An Item_cache_int object is used for caching values. It
|
||||
seamlessly substitutes the original item. The cache item is marked as
|
||||
non-constant to prevent re-caching it again. In order to compare
|
||||
correctly DATE and DATETIME items the result of the former are treated as
|
||||
a DATETIME with zero time (00:00:00).
|
||||
|
||||
If the value should be compared as time (TIME_RESULT), it's retrieved as
|
||||
MYSQL_TIME. Otherwise it's read as a number/string and converted to time.
|
||||
Constant items are cached, so the convertion is only done once for them.
|
||||
|
||||
Note the f_type behavior: if the item can be compared as time, then
|
||||
f_type is this item's field_type(). Otherwise it's field_type() of
|
||||
warn_item (which is the other operand of the comparison operator).
|
||||
This logic provides correct string/number to date/time conversion
|
||||
depending on the other operand (when comparing a string with a date, it's
|
||||
parsed as a date, when comparing a string with a time it's parsed as a time)
|
||||
|
||||
RETURN
|
||||
obtained value
|
||||
MYSQL_TIME value, packed in a longlong, suitable for comparison.
|
||||
*/
|
||||
|
||||
longlong
|
||||
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
Item *warn_item, bool *is_null)
|
||||
{
|
||||
longlong value= 0;
|
||||
String buf, *str= 0;
|
||||
longlong UNINIT_VAR(value);
|
||||
Item *item= **item_arg;
|
||||
enum_field_types f_type= warn_item->field_type();
|
||||
timestamp_type t_type=
|
||||
f_type == MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE :
|
||||
f_type == MYSQL_TYPE_TIME ? MYSQL_TIMESTAMP_TIME :
|
||||
MYSQL_TIMESTAMP_DATETIME;
|
||||
|
||||
if (item->result_as_longlong())
|
||||
{
|
||||
switch (item->cmp_type()) {
|
||||
case TIME_RESULT:
|
||||
/* if it's our Item_cache_int, as created below, we simply use the value */
|
||||
if (item->result_type() == INT_RESULT)
|
||||
value= item->val_int();
|
||||
else
|
||||
{
|
||||
MYSQL_TIME buf;
|
||||
item->get_date_result(&buf, TIME_FUZZY_DATE | TIME_INVALID_DATES);
|
||||
value= pack_time(&buf);
|
||||
f_type= item->field_type(); // for Item_cache_int below.
|
||||
}
|
||||
break;
|
||||
case INT_RESULT:
|
||||
value= item->val_int();
|
||||
*is_null= item->null_value;
|
||||
enum_field_types f_type= item->field_type();
|
||||
/*
|
||||
Item_date_add_interval may return MYSQL_TYPE_STRING as the result
|
||||
field type. To detect that the DATE value has been returned we
|
||||
compare it with 100000000L - any DATE value should be less than it.
|
||||
Don't shift cached DATETIME values up for the second time.
|
||||
*/
|
||||
if (f_type == MYSQL_TYPE_DATE ||
|
||||
(f_type != MYSQL_TYPE_DATETIME && value < 100000000L))
|
||||
value*= 1000000L;
|
||||
|
||||
if (item->field_type() == MYSQL_TYPE_YEAR)
|
||||
{
|
||||
Item *real_item= item->real_item();
|
||||
if (!(real_item->type() == Item::FIELD_ITEM &&
|
||||
((Item_field *)real_item)->field->type() == MYSQL_TYPE_YEAR &&
|
||||
((Item_field *)real_item)->field->field_length == 4))
|
||||
{
|
||||
if (value < 70)
|
||||
value+= 100;
|
||||
if (value <= 1900)
|
||||
value+= 1900;
|
||||
}
|
||||
value*= 13ULL * 32ULL * 24ULL * 60ULL * 60ULL * 1000000ULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
MYSQL_TIME buf;
|
||||
int was_cut;
|
||||
|
||||
if (number_to_datetime(value, &buf, TIME_INVALID_DATES|TIME_FUZZY_DATE,
|
||||
&was_cut) == -1)
|
||||
{
|
||||
const Lazy_string_num str(value);
|
||||
make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
&str, t_type, warn_item->name);
|
||||
value= 0;
|
||||
}
|
||||
else
|
||||
value= pack_time(&buf);
|
||||
}
|
||||
break;
|
||||
case STRING_RESULT:
|
||||
case DECIMAL_RESULT:
|
||||
case REAL_RESULT:
|
||||
{
|
||||
char strbuf[MAX_DATETIME_FULL_WIDTH];
|
||||
String buf(strbuf, sizeof(strbuf), &my_charset_bin), *str;
|
||||
if ((str= item->val_str(&buf)))
|
||||
{
|
||||
/*
|
||||
Convert strings to the integer DATE/DATETIME representation.
|
||||
Even if both dates provided in strings we can't compare them directly as
|
||||
strings as there is no warranty that they are correct and do not miss
|
||||
some insignificant zeros.
|
||||
*/
|
||||
bool error;
|
||||
value= (longlong) get_date_from_str(thd, str, t_type, warn_item->name, &error);
|
||||
/*
|
||||
If str did not contain a valid date according to the current
|
||||
SQL_MODE, get_date_from_str() has already thrown a warning,
|
||||
and we don't want to throw NULL on invalid date (see 5.2.6
|
||||
"SQL modes" in the manual), so we're done here.
|
||||
*/
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: DBUG_ASSERT(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
str= item->val_str(&buf);
|
||||
*is_null= item->null_value;
|
||||
}
|
||||
if (*is_null)
|
||||
if ((*is_null= item->null_value))
|
||||
return ~(ulonglong) 0;
|
||||
/*
|
||||
Convert strings to the integer DATE/DATETIME representation.
|
||||
Even if both dates provided in strings we can't compare them directly as
|
||||
strings as there is no warranty that they are correct and do not miss
|
||||
some insignificant zeros.
|
||||
*/
|
||||
if (str)
|
||||
if (cache_arg && item->const_item() && item->type() != Item::CACHE_ITEM)
|
||||
{
|
||||
bool error;
|
||||
enum_field_types f_type= warn_item->field_type();
|
||||
timestamp_type t_type= f_type ==
|
||||
MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
|
||||
value= (longlong) get_date_from_str(thd, str, t_type, warn_item->name, &error);
|
||||
/*
|
||||
If str did not contain a valid date according to the current
|
||||
SQL_MODE, get_date_from_str() has already thrown a warning,
|
||||
and we don't want to throw NULL on invalid date (see 5.2.6
|
||||
"SQL modes" in the manual), so we're done here.
|
||||
*/
|
||||
}
|
||||
/*
|
||||
Do not cache GET_USER_VAR() function as its const_item() may return TRUE
|
||||
for the current thread but it still may change during the execution.
|
||||
*/
|
||||
if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
|
||||
((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
|
||||
{
|
||||
Item_cache_int *cache= new Item_cache_int(MYSQL_TYPE_DATETIME);
|
||||
/* Mark the cache as non-const to prevent re-caching. */
|
||||
cache->set_used_tables(1);
|
||||
Item_cache_int *cache= new Item_cache_int(f_type);
|
||||
cache->store(item, value);
|
||||
*cache_arg= cache;
|
||||
*item_arg= cache_arg;
|
||||
@ -1154,64 +921,6 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Retrieves YEAR value of 19XX-00-00 00:00:00 form from given item.
|
||||
|
||||
SYNOPSIS
|
||||
get_year_value()
|
||||
thd thread handle
|
||||
item_arg [in/out] item to retrieve YEAR value from
|
||||
cache_arg [in/out] pointer to place to store the caching item to
|
||||
warn_item [in] item for issuing the conversion warning
|
||||
is_null [out] TRUE <=> the item_arg is null
|
||||
|
||||
DESCRIPTION
|
||||
Retrieves the YEAR value of 19XX form from given item for comparison by the
|
||||
compare_datetime() function.
|
||||
Converts year to DATETIME of form YYYY-00-00 00:00:00 for the compatibility
|
||||
with the get_datetime_value function result.
|
||||
|
||||
RETURN
|
||||
obtained value
|
||||
*/
|
||||
|
||||
static longlong
|
||||
get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
Item *warn_item, bool *is_null)
|
||||
{
|
||||
longlong value= 0;
|
||||
Item *item= **item_arg;
|
||||
|
||||
value= item->val_int();
|
||||
*is_null= item->null_value;
|
||||
if (*is_null)
|
||||
return ~(ulonglong) 0;
|
||||
|
||||
/*
|
||||
Coerce value to the 19XX form in order to correctly compare
|
||||
YEAR(2) & YEAR(4) types.
|
||||
Here we are converting all item values but YEAR(4) fields since
|
||||
1) YEAR(4) already has a regular YYYY form and
|
||||
2) we don't want to convert zero/bad YEAR(4) values to the
|
||||
value of 2000.
|
||||
*/
|
||||
Item *real_item= item->real_item();
|
||||
if (!(real_item->type() == Item::FIELD_ITEM &&
|
||||
((Item_field *)real_item)->field->type() == MYSQL_TYPE_YEAR &&
|
||||
((Item_field *)real_item)->field->field_length == 4))
|
||||
{
|
||||
if (value < 70)
|
||||
value+= 100;
|
||||
if (value <= 1900)
|
||||
value+= 1900;
|
||||
}
|
||||
/* Convert year to DATETIME of form YYYY-00-00 00:00:00 (YYYY0000000000). */
|
||||
value*= 10000000000LL;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Compare items values as dates.
|
||||
|
||||
@ -1224,18 +933,9 @@ get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
with help of the get_datetime_value() function.
|
||||
|
||||
RETURN
|
||||
If is_nulls_eq is TRUE:
|
||||
1 if items are equal or both are null
|
||||
0 otherwise
|
||||
If is_nulls_eq is FALSE:
|
||||
-1 a < b or at least one item is null
|
||||
0 a == b
|
||||
1 a > b
|
||||
See the table:
|
||||
is_nulls_eq | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
|
||||
a_is_null | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
|
||||
b_is_null | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
|
||||
result | 1 | 0 | 0 |0/1|-1 |-1 |-1 |-1/0/1|
|
||||
*/
|
||||
|
||||
int Arg_comparator::compare_datetime()
|
||||
@ -1243,34 +943,43 @@ int Arg_comparator::compare_datetime()
|
||||
bool a_is_null, b_is_null;
|
||||
longlong a_value, b_value;
|
||||
|
||||
if (set_null)
|
||||
owner->null_value= 1;
|
||||
|
||||
/* Get DATE/DATETIME/TIME value of the 'a' item. */
|
||||
a_value= (*get_value_a_func)(thd, &a, &a_cache, *b, &a_is_null);
|
||||
if (!is_nulls_eq && a_is_null)
|
||||
{
|
||||
if (set_null)
|
||||
owner->null_value= 1;
|
||||
a_value= get_datetime_value(thd, &a, &a_cache, *b, &a_is_null);
|
||||
if (a_is_null)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get DATE/DATETIME/TIME value of the 'b' item. */
|
||||
b_value= (*get_value_b_func)(thd, &b, &b_cache, *a, &b_is_null);
|
||||
if (a_is_null || b_is_null)
|
||||
{
|
||||
if (set_null)
|
||||
owner->null_value= is_nulls_eq ? 0 : 1;
|
||||
return is_nulls_eq ? (a_is_null == b_is_null) : -1;
|
||||
}
|
||||
b_value= get_datetime_value(thd, &b, &b_cache, *a, &b_is_null);
|
||||
if (b_is_null)
|
||||
return -1;
|
||||
|
||||
/* Here we have two not-NULL values. */
|
||||
if (set_null)
|
||||
owner->null_value= 0;
|
||||
|
||||
/* Compare values. */
|
||||
if (is_nulls_eq)
|
||||
return (a_value == b_value);
|
||||
return a_value < b_value ? -1 : (a_value > b_value ? 1 : 0);
|
||||
return a_value < b_value ? -1 : a_value > b_value ? 1 : 0;
|
||||
}
|
||||
|
||||
int Arg_comparator::compare_e_datetime()
|
||||
{
|
||||
bool a_is_null, b_is_null;
|
||||
longlong a_value, b_value;
|
||||
|
||||
if (set_null)
|
||||
owner->null_value= 0;
|
||||
|
||||
/* Get DATE/DATETIME/TIME value of the 'a' item. */
|
||||
a_value= get_datetime_value(thd, &a, &a_cache, *b, &a_is_null);
|
||||
|
||||
/* Get DATE/DATETIME/TIME value of the 'b' item. */
|
||||
b_value= get_datetime_value(thd, &b, &b_cache, *a, &b_is_null);
|
||||
return a_is_null || b_is_null ? a_is_null == b_is_null
|
||||
: a_value == b_value;
|
||||
}
|
||||
|
||||
int Arg_comparator::compare_string()
|
||||
{
|
||||
@ -2247,9 +1956,7 @@ void Item_func_between::fix_length_and_dec()
|
||||
{
|
||||
max_length= 1;
|
||||
int i;
|
||||
bool datetime_found= FALSE;
|
||||
int time_items_found= 0;
|
||||
compare_as_dates= TRUE;
|
||||
compare_as_dates= 0;
|
||||
THD *thd= current_thd;
|
||||
|
||||
/*
|
||||
@ -2265,43 +1972,33 @@ void Item_func_between::fix_length_and_dec()
|
||||
return;
|
||||
|
||||
/*
|
||||
Detect the comparison of DATE/DATETIME items.
|
||||
At least one of items should be a DATE/DATETIME item and other items
|
||||
should return the STRING result.
|
||||
When comparing as date/time, we need to convert non-temporal values
|
||||
(e.g. strings) to MYSQL_TIME. get_datetime_value() doees it
|
||||
automatically when one of the operands is a date/time. But here we
|
||||
may need to compare two strings as dates (str1 BETWEEN str2 AND date).
|
||||
For this to work, we need to know what date/time type we compare
|
||||
strings as.
|
||||
*/
|
||||
if (cmp_type == STRING_RESULT)
|
||||
if (cmp_type == TIME_RESULT)
|
||||
{
|
||||
for (i= 0; i < 3; i++)
|
||||
{
|
||||
if (args[i]->is_datetime())
|
||||
if (args[i]->cmp_type() == TIME_RESULT)
|
||||
{
|
||||
datetime_found= TRUE;
|
||||
if (args[i]->field_type() != MYSQL_TYPE_TIME ||
|
||||
(args[i]->field_type() == MYSQL_TYPE_TIME && compare_as_dates==0))
|
||||
compare_as_dates= args[i];
|
||||
continue;
|
||||
}
|
||||
if (args[i]->field_type() == MYSQL_TYPE_TIME &&
|
||||
args[i]->result_as_longlong())
|
||||
time_items_found++;
|
||||
}
|
||||
}
|
||||
if (!datetime_found)
|
||||
compare_as_dates= FALSE;
|
||||
|
||||
if (compare_as_dates)
|
||||
{
|
||||
ge_cmp.set_datetime_cmp_func(this, args, args + 1);
|
||||
le_cmp.set_datetime_cmp_func(this, args, args + 2);
|
||||
}
|
||||
else if (time_items_found == 3)
|
||||
{
|
||||
/* Compare TIME items as integers. */
|
||||
cmp_type= INT_RESULT;
|
||||
}
|
||||
else if (args[0]->real_item()->type() == FIELD_ITEM &&
|
||||
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
|
||||
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
|
||||
/* See the comment about the similar block in Item_bool_func2 */
|
||||
if (args[0]->real_item()->type() == FIELD_ITEM &&
|
||||
!thd->is_context_analysis_only())
|
||||
{
|
||||
Item_field *field_item= (Item_field*) (args[0]->real_item());
|
||||
if (field_item->field->can_be_compared_as_longlong())
|
||||
if (field_item->cmp_type() == INT_RESULT)
|
||||
{
|
||||
/*
|
||||
The following can't be recoded with || as convert_constant_item
|
||||
@ -2319,27 +2016,46 @@ void Item_func_between::fix_length_and_dec()
|
||||
longlong Item_func_between::val_int()
|
||||
{ // ANSI BETWEEN
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (compare_as_dates)
|
||||
|
||||
switch (cmp_type) {
|
||||
case TIME_RESULT:
|
||||
{
|
||||
int ge_res, le_res;
|
||||
THD *thd= current_thd;
|
||||
longlong value, a, b;
|
||||
Item *cache, **ptr;
|
||||
bool value_is_null, a_is_null, b_is_null;
|
||||
|
||||
ge_res= ge_cmp.compare();
|
||||
if ((null_value= args[0]->null_value))
|
||||
ptr= &args[0];
|
||||
value= get_datetime_value(thd, &ptr, &cache, compare_as_dates,
|
||||
&value_is_null);
|
||||
if (ptr != &args[0])
|
||||
thd->change_item_tree(&args[0], *ptr);
|
||||
|
||||
if ((null_value= value_is_null))
|
||||
return 0;
|
||||
le_res= le_cmp.compare();
|
||||
|
||||
if (!args[1]->null_value && !args[2]->null_value)
|
||||
return (longlong) ((ge_res >= 0 && le_res <=0) != negated);
|
||||
else if (args[1]->null_value)
|
||||
{
|
||||
null_value= le_res > 0; // not null if false range.
|
||||
}
|
||||
ptr= &args[1];
|
||||
a= get_datetime_value(thd, &ptr, &cache, compare_as_dates, &a_is_null);
|
||||
if (ptr != &args[1])
|
||||
thd->change_item_tree(&args[1], *ptr);
|
||||
|
||||
ptr= &args[2];
|
||||
b= get_datetime_value(thd, &ptr, &cache, compare_as_dates, &b_is_null);
|
||||
if (ptr != &args[2])
|
||||
thd->change_item_tree(&args[2], *ptr);
|
||||
|
||||
if (!a_is_null && !b_is_null)
|
||||
return (longlong) ((value >= a && value <= b) != negated);
|
||||
if (a_is_null && b_is_null)
|
||||
null_value=1;
|
||||
else if (a_is_null)
|
||||
null_value= value <= b; // not null if false range.
|
||||
else
|
||||
{
|
||||
null_value= ge_res < 0;
|
||||
}
|
||||
null_value= value >= a;
|
||||
break;
|
||||
}
|
||||
else if (cmp_type == STRING_RESULT)
|
||||
|
||||
case STRING_RESULT:
|
||||
{
|
||||
String *value,*a,*b;
|
||||
value=args[0]->val_str(&value0);
|
||||
@ -2363,8 +2079,9 @@ longlong Item_func_between::val_int()
|
||||
// Set to not null if false range.
|
||||
null_value= sortcmp(value,a,cmp_collation.collation) >= 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmp_type == INT_RESULT)
|
||||
case INT_RESULT:
|
||||
{
|
||||
longlong value=args[0]->val_int(), a, b;
|
||||
if ((null_value=args[0]->null_value))
|
||||
@ -2383,8 +2100,9 @@ longlong Item_func_between::val_int()
|
||||
{
|
||||
null_value= value >= a;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (cmp_type == DECIMAL_RESULT)
|
||||
case DECIMAL_RESULT:
|
||||
{
|
||||
my_decimal dec_buf, *dec= args[0]->val_decimal(&dec_buf),
|
||||
a_buf, *a_dec, b_buf, *b_dec;
|
||||
@ -2401,8 +2119,9 @@ longlong Item_func_between::val_int()
|
||||
null_value= (my_decimal_cmp(dec, b_dec) <= 0);
|
||||
else
|
||||
null_value= (my_decimal_cmp(dec, a_dec) >= 0);
|
||||
break;
|
||||
}
|
||||
else
|
||||
case REAL_RESULT:
|
||||
{
|
||||
double value= args[0]->val_real(),a,b;
|
||||
if ((null_value=args[0]->null_value))
|
||||
@ -2421,6 +2140,12 @@ longlong Item_func_between::val_int()
|
||||
{
|
||||
null_value= value >= a;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
return (longlong) (!null_value && negated);
|
||||
}
|
||||
@ -3890,7 +3615,7 @@ void Item_func_in::fix_length_and_dec()
|
||||
skip_column= TRUE;
|
||||
break;
|
||||
}
|
||||
else if (itm->is_datetime())
|
||||
else if (itm->cmp_type() == TIME_RESULT)
|
||||
{
|
||||
datetime_found= TRUE;
|
||||
/*
|
||||
@ -3946,14 +3671,14 @@ void Item_func_in::fix_length_and_dec()
|
||||
So we must check here if the column on the left and all the constant
|
||||
values on the right can be compared as integers and adjust the
|
||||
comparison type accordingly.
|
||||
|
||||
See the comment about the similar block in Item_bool_func2
|
||||
*/
|
||||
if (args[0]->real_item()->type() == FIELD_ITEM &&
|
||||
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
|
||||
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
|
||||
cmp_type != INT_RESULT)
|
||||
!thd->is_context_analysis_only() && cmp_type != INT_RESULT)
|
||||
{
|
||||
Item_field *field_item= (Item_field*) (args[0]->real_item());
|
||||
if (field_item->field->can_be_compared_as_longlong())
|
||||
if (field_item->cmp_type() == INT_RESULT)
|
||||
{
|
||||
bool all_converted= TRUE;
|
||||
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
|
||||
@ -5359,7 +5084,7 @@ Item_equal::Item_equal(Item *c, Item_field *f)
|
||||
const_item_cache= 0;
|
||||
fields.push_back(f);
|
||||
const_item= c;
|
||||
compare_as_dates= f->is_datetime();
|
||||
compare_as_dates= f->cmp_type() == TIME_RESULT;
|
||||
}
|
||||
|
||||
|
||||
@ -5406,7 +5131,7 @@ void Item_equal::add(Item *c, Item_field *f)
|
||||
{
|
||||
DBUG_ASSERT(f);
|
||||
const_item= c;
|
||||
compare_as_dates= f->is_datetime();
|
||||
compare_as_dates= f->cmp_type() == TIME_RESULT;
|
||||
return;
|
||||
}
|
||||
compare_const(c);
|
||||
|
@ -33,32 +33,22 @@ class Arg_comparator: public Sql_alloc
|
||||
Item **a, **b;
|
||||
arg_cmp_func func;
|
||||
Item_result_field *owner;
|
||||
bool set_null; // TRUE <=> set owner->null_value
|
||||
Arg_comparator *comparators; // used only for compare_row()
|
||||
double precision;
|
||||
/* Fields used in DATE/DATETIME comparison. */
|
||||
THD *thd;
|
||||
enum_field_types a_type, b_type; // Types of a and b items
|
||||
Item *a_cache, *b_cache; // Cached values of a and b items
|
||||
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
|
||||
bool set_null; // TRUE <=> set owner->null_value
|
||||
// when one of arguments is NULL.
|
||||
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
|
||||
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
|
||||
longlong (*get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
Item *warn_item, bool *is_null);
|
||||
longlong (*get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
Item *warn_item, bool *is_null);
|
||||
bool try_year_cmp_func(Item_result type);
|
||||
public:
|
||||
DTCollation cmp_collation;
|
||||
/* Allow owner function to use string buffers. */
|
||||
String value1, value2;
|
||||
|
||||
Arg_comparator(): comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE),
|
||||
get_value_a_func(0), get_value_b_func(0) {};
|
||||
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), comparators(0), thd(0),
|
||||
a_cache(0), b_cache(0), set_null(TRUE),
|
||||
get_value_a_func(0), get_value_b_func(0) {};
|
||||
Arg_comparator(): set_null(TRUE), comparators(0), thd(0),
|
||||
a_cache(0), b_cache(0) {};
|
||||
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), set_null(TRUE),
|
||||
comparators(0), thd(0), a_cache(0), b_cache(0) {};
|
||||
|
||||
int set_compare_func(Item_result_field *owner, Item_result type);
|
||||
inline int set_compare_func(Item_result_field *owner_arg)
|
||||
@ -75,8 +65,8 @@ public:
|
||||
{
|
||||
set_null= set_null_arg;
|
||||
return set_cmp_func(owner_arg, a1, a2,
|
||||
item_cmp_type((*a1)->result_type(),
|
||||
(*a2)->result_type()));
|
||||
item_cmp_type((*a1)->cmp_type(),
|
||||
(*a2)->cmp_type()));
|
||||
}
|
||||
inline int compare() { return (this->*func)(); }
|
||||
|
||||
@ -99,14 +89,12 @@ public:
|
||||
int compare_real_fixed();
|
||||
int compare_e_real_fixed();
|
||||
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
|
||||
|
||||
static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
|
||||
ulonglong *const_val_arg);
|
||||
int compare_e_datetime();
|
||||
|
||||
Item** cache_converted_constant(THD *thd, Item **value, Item **cache,
|
||||
Item_result type);
|
||||
void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1, Item **b1);
|
||||
static arg_cmp_func comparator_matrix [5][2];
|
||||
static arg_cmp_func comparator_matrix [6][2];
|
||||
inline bool is_owner_equal_func()
|
||||
{
|
||||
return (owner->type() == Item::FUNC_ITEM &&
|
||||
@ -614,9 +602,7 @@ public:
|
||||
Item_result cmp_type;
|
||||
String value0,value1,value2;
|
||||
/* TRUE <=> arguments will be compared as dates. */
|
||||
bool compare_as_dates;
|
||||
/* Comparators used for DATE/DATETIME comparison. */
|
||||
Arg_comparator ge_cmp, le_cmp;
|
||||
Item *compare_as_dates;
|
||||
Item_func_between(Item *a, Item *b, Item *c)
|
||||
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {}
|
||||
longlong val_int();
|
||||
@ -894,6 +880,16 @@ public:
|
||||
lval_cache(0) {};
|
||||
void set(uint pos,Item *item);
|
||||
uchar *get_value(Item *item);
|
||||
Item* create_item()
|
||||
{
|
||||
return new Item_datetime();
|
||||
}
|
||||
void value_to_item(uint pos, Item *item)
|
||||
{
|
||||
packed_longlong *val= reinterpret_cast<packed_longlong*>(base)+pos;
|
||||
Item_datetime *dt= reinterpret_cast<Item_datetime*>(item);
|
||||
dt->set(val->val);
|
||||
}
|
||||
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
|
||||
};
|
||||
|
||||
|
@ -5044,6 +5044,14 @@ find_qualified_function_builder(THD *thd)
|
||||
return & Create_sp_func::s_singleton;
|
||||
}
|
||||
|
||||
static inline const char* item_name(Item *a, String *str)
|
||||
{
|
||||
if (a->name)
|
||||
return a->name;
|
||||
str->length(0);
|
||||
a->print(str, QT_ORDINARY);
|
||||
return str->c_ptr_safe();
|
||||
}
|
||||
|
||||
Item *
|
||||
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
@ -5051,6 +5059,8 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
CHARSET_INFO *cs)
|
||||
{
|
||||
Item *UNINIT_VAR(res);
|
||||
char buff[1024];
|
||||
String buf(buff, sizeof(buff), system_charset_info);
|
||||
|
||||
switch (cast_type) {
|
||||
case ITEM_CAST_BINARY:
|
||||
@ -5066,11 +5076,29 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
res= new (thd->mem_root) Item_date_typecast(a);
|
||||
break;
|
||||
case ITEM_CAST_TIME:
|
||||
res= new (thd->mem_root) Item_time_typecast(a);
|
||||
break;
|
||||
case ITEM_CAST_DATETIME:
|
||||
res= new (thd->mem_root) Item_datetime_typecast(a);
|
||||
{
|
||||
uint len;
|
||||
if (c_len)
|
||||
{
|
||||
errno= 0;
|
||||
len= strtoul(c_len, NULL, 10);
|
||||
if (errno != 0 || len > MAX_DATETIME_PRECISION)
|
||||
{
|
||||
my_error(ER_TOO_BIG_PRECISION, MYF(0), len,
|
||||
item_name(a, &buf), MAX_DATETIME_PRECISION);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
len= NOT_FIXED_DEC;
|
||||
|
||||
if (cast_type == ITEM_CAST_TIME)
|
||||
res= new (thd->mem_root) Item_time_typecast(a, len);
|
||||
else
|
||||
res= new (thd->mem_root) Item_datetime_typecast(a, len);
|
||||
break;
|
||||
}
|
||||
case ITEM_CAST_DECIMAL:
|
||||
{
|
||||
ulong len= 0;
|
||||
@ -5083,8 +5111,8 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
decoded_size= strtoul(c_len, NULL, 10);
|
||||
if (errno != 0)
|
||||
{
|
||||
my_error(ER_TOO_BIG_PRECISION, MYF(0), c_len, a->name,
|
||||
DECIMAL_MAX_PRECISION);
|
||||
my_error(ER_TOO_BIG_PRECISION, MYF(0), decoded_size,
|
||||
item_name(a, &buf), DECIMAL_MAX_PRECISION);
|
||||
return NULL;
|
||||
}
|
||||
len= decoded_size;
|
||||
@ -5097,8 +5125,8 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
decoded_size= strtoul(c_dec, NULL, 10);
|
||||
if ((errno != 0) || (decoded_size > UINT_MAX))
|
||||
{
|
||||
my_error(ER_TOO_BIG_SCALE, MYF(0), c_dec, a->name,
|
||||
DECIMAL_MAX_SCALE);
|
||||
my_error(ER_TOO_BIG_SCALE, MYF(0), decoded_size,
|
||||
item_name(a, &buf), DECIMAL_MAX_SCALE);
|
||||
return NULL;
|
||||
}
|
||||
dec= decoded_size;
|
||||
@ -5111,13 +5139,13 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
}
|
||||
if (len > DECIMAL_MAX_PRECISION)
|
||||
{
|
||||
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
|
||||
DECIMAL_MAX_PRECISION);
|
||||
my_error(ER_TOO_BIG_PRECISION, MYF(0), len,
|
||||
item_name(a, &buf), DECIMAL_MAX_PRECISION);
|
||||
return 0;
|
||||
}
|
||||
if (dec > DECIMAL_MAX_SCALE)
|
||||
{
|
||||
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
|
||||
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, item_name(a, &buf),
|
||||
DECIMAL_MAX_SCALE);
|
||||
return 0;
|
||||
}
|
||||
@ -5135,7 +5163,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
||||
decoded_size= strtoul(c_len, NULL, 10);
|
||||
if ((errno != 0) || (decoded_size > MAX_FIELD_BLOBLENGTH))
|
||||
{
|
||||
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH);
|
||||
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH);
|
||||
return NULL;
|
||||
}
|
||||
len= (int) decoded_size;
|
||||
|
108
sql/item_func.cc
108
sql/item_func.cc
@ -940,8 +940,7 @@ longlong Item_func_signed::val_int()
|
||||
longlong value;
|
||||
int error;
|
||||
|
||||
if (args[0]->cast_to_int_type() != STRING_RESULT ||
|
||||
args[0]->result_as_longlong())
|
||||
if (args[0]->cast_to_int_type() != STRING_RESULT)
|
||||
{
|
||||
value= args[0]->val_int();
|
||||
null_value= args[0]->null_value;
|
||||
@ -982,8 +981,7 @@ longlong Item_func_unsigned::val_int()
|
||||
value= 0;
|
||||
return value;
|
||||
}
|
||||
else if (args[0]->cast_to_int_type() != STRING_RESULT ||
|
||||
args[0]->result_as_longlong())
|
||||
else if (args[0]->cast_to_int_type() != STRING_RESULT)
|
||||
{
|
||||
value= args[0]->val_int();
|
||||
null_value= args[0]->null_value;
|
||||
@ -2220,7 +2218,6 @@ double Item_func_units::val_real()
|
||||
void Item_func_min_max::fix_length_and_dec()
|
||||
{
|
||||
int max_int_part=0;
|
||||
bool datetime_found= FALSE;
|
||||
decimals=0;
|
||||
max_length=0;
|
||||
maybe_null=0;
|
||||
@ -2234,21 +2231,17 @@ void Item_func_min_max::fix_length_and_dec()
|
||||
if (args[i]->maybe_null)
|
||||
maybe_null=1;
|
||||
cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
|
||||
if (args[i]->result_type() != ROW_RESULT && args[i]->is_datetime())
|
||||
if (args[i]->cmp_type() == TIME_RESULT)
|
||||
{
|
||||
datetime_found= TRUE;
|
||||
if (!datetime_item || args[i]->field_type() == MYSQL_TYPE_DATETIME)
|
||||
datetime_item= args[i];
|
||||
if (!compare_as_dates || args[i]->field_type() == MYSQL_TYPE_DATETIME)
|
||||
compare_as_dates= args[i];
|
||||
}
|
||||
}
|
||||
if (cmp_type == STRING_RESULT)
|
||||
{
|
||||
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1);
|
||||
if (datetime_found)
|
||||
{
|
||||
if (compare_as_dates)
|
||||
thd= current_thd;
|
||||
compare_as_dates= TRUE;
|
||||
}
|
||||
}
|
||||
else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT))
|
||||
max_length= my_decimal_precision_to_length_no_truncation(max_int_part +
|
||||
@ -2256,7 +2249,11 @@ void Item_func_min_max::fix_length_and_dec()
|
||||
unsigned_flag);
|
||||
else if (cmp_type == REAL_RESULT)
|
||||
max_length= float_length(decimals);
|
||||
cached_field_type= agg_field_type(args, arg_count);
|
||||
|
||||
if (compare_as_dates)
|
||||
cached_field_type= compare_as_dates->field_type();
|
||||
else
|
||||
cached_field_type= agg_field_type(args, arg_count);
|
||||
}
|
||||
|
||||
|
||||
@ -2265,52 +2262,45 @@ void Item_func_min_max::fix_length_and_dec()
|
||||
|
||||
SYNOPSIS
|
||||
cmp_datetimes()
|
||||
value [out] found least/greatest DATE/DATETIME value
|
||||
|
||||
DESCRIPTION
|
||||
Compare item arguments as DATETIME values and return the index of the
|
||||
least/greatest argument in the arguments array.
|
||||
The correct integer DATE/DATETIME value of the found argument is
|
||||
The correct DATE/DATETIME value of the found argument is
|
||||
stored to the value pointer, if latter is provided.
|
||||
|
||||
RETURN
|
||||
0 If one of arguments is NULL or there was a execution error
|
||||
# index of the least/greatest argument
|
||||
1 If one of arguments is NULL or there was a execution error
|
||||
0 Otherwise
|
||||
*/
|
||||
|
||||
uint Item_func_min_max::cmp_datetimes(ulonglong *value)
|
||||
bool Item_func_min_max::cmp_datetimes(MYSQL_TIME *ltime)
|
||||
{
|
||||
longlong UNINIT_VAR(min_max);
|
||||
uint min_max_idx= 0;
|
||||
|
||||
for (uint i=0; i < arg_count ; i++)
|
||||
{
|
||||
Item **arg= args + i;
|
||||
bool is_null;
|
||||
longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
|
||||
longlong res= get_datetime_value(thd, &arg, 0, compare_as_dates, &is_null);
|
||||
|
||||
/* Check if we need to stop (because of error or KILL) and stop the loop */
|
||||
if (thd->is_error())
|
||||
{
|
||||
null_value= 1;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((null_value= args[i]->null_value))
|
||||
return 0;
|
||||
return 1;
|
||||
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
|
||||
{
|
||||
min_max= res;
|
||||
min_max_idx= i;
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
{
|
||||
*value= min_max;
|
||||
if (datetime_item->field_type() == MYSQL_TYPE_DATE)
|
||||
*value/= 1000000L;
|
||||
}
|
||||
return min_max_idx;
|
||||
unpack_time(min_max, ltime);
|
||||
if (compare_as_dates->field_type() == MYSQL_TYPE_DATE)
|
||||
ltime->time_type= MYSQL_TIMESTAMP_DATE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -2319,19 +2309,14 @@ String *Item_func_min_max::val_str(String *str)
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (compare_as_dates)
|
||||
{
|
||||
String *str_res;
|
||||
uint min_max_idx= cmp_datetimes(NULL);
|
||||
if (null_value)
|
||||
MYSQL_TIME ltime;
|
||||
if (cmp_datetimes(<ime))
|
||||
return 0;
|
||||
str_res= args[min_max_idx]->val_str(str);
|
||||
if (args[min_max_idx]->null_value)
|
||||
{
|
||||
// check if the call to val_str() above returns a NULL value
|
||||
null_value= 1;
|
||||
return NULL;
|
||||
}
|
||||
str_res->set_charset(collation.collation);
|
||||
return str_res;
|
||||
|
||||
char buf[MAX_DATE_STRING_REP_LENGTH];
|
||||
int len= my_TIME_to_str(<ime, buf, decimals);
|
||||
str->copy(buf, len, collation.collation);
|
||||
return str;
|
||||
}
|
||||
switch (cmp_type) {
|
||||
case INT_RESULT:
|
||||
@ -2398,9 +2383,11 @@ double Item_func_min_max::val_real()
|
||||
double value=0.0;
|
||||
if (compare_as_dates)
|
||||
{
|
||||
ulonglong result= 0;
|
||||
(void)cmp_datetimes(&result);
|
||||
return (double)result;
|
||||
MYSQL_TIME ltime;
|
||||
if (cmp_datetimes(<ime))
|
||||
return 0;
|
||||
|
||||
return TIME_to_double(<ime);
|
||||
}
|
||||
for (uint i=0; i < arg_count ; i++)
|
||||
{
|
||||
@ -2425,9 +2412,11 @@ longlong Item_func_min_max::val_int()
|
||||
longlong value=0;
|
||||
if (compare_as_dates)
|
||||
{
|
||||
ulonglong result= 0;
|
||||
(void)cmp_datetimes(&result);
|
||||
return (longlong)result;
|
||||
MYSQL_TIME ltime;
|
||||
if (cmp_datetimes(<ime))
|
||||
return 0;
|
||||
|
||||
return TIME_to_ulonglong(<ime);
|
||||
}
|
||||
for (uint i=0; i < arg_count ; i++)
|
||||
{
|
||||
@ -2453,10 +2442,11 @@ my_decimal *Item_func_min_max::val_decimal(my_decimal *dec)
|
||||
|
||||
if (compare_as_dates)
|
||||
{
|
||||
ulonglong value= 0;
|
||||
(void)cmp_datetimes(&value);
|
||||
ulonglong2decimal(value, dec);
|
||||
return dec;
|
||||
MYSQL_TIME ltime;
|
||||
if (cmp_datetimes(<ime))
|
||||
return 0;
|
||||
|
||||
return date2my_decimal(<ime, dec);
|
||||
}
|
||||
for (uint i=0; i < arg_count ; i++)
|
||||
{
|
||||
@ -3979,7 +3969,7 @@ double user_var_entry::val_real(my_bool *null_value)
|
||||
}
|
||||
case STRING_RESULT:
|
||||
return my_atof(value); // This is null terminated
|
||||
case ROW_RESULT:
|
||||
default:
|
||||
DBUG_ASSERT(1); // Impossible
|
||||
break;
|
||||
}
|
||||
@ -4010,7 +4000,7 @@ longlong user_var_entry::val_int(my_bool *null_value) const
|
||||
int error;
|
||||
return my_strtoll10(value, (char**) 0, &error);// String is null terminated
|
||||
}
|
||||
case ROW_RESULT:
|
||||
default:
|
||||
DBUG_ASSERT(1); // Impossible
|
||||
break;
|
||||
}
|
||||
@ -4042,7 +4032,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str,
|
||||
case STRING_RESULT:
|
||||
if (str->copy(value, length, collation.collation))
|
||||
str= 0; // EOM error
|
||||
case ROW_RESULT:
|
||||
default:
|
||||
DBUG_ASSERT(1); // Impossible
|
||||
break;
|
||||
}
|
||||
@ -4069,7 +4059,7 @@ my_decimal *user_var_entry::val_decimal(my_bool *null_value, my_decimal *val)
|
||||
case STRING_RESULT:
|
||||
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
|
||||
break;
|
||||
case ROW_RESULT:
|
||||
default:
|
||||
DBUG_ASSERT(1); // Impossible
|
||||
break;
|
||||
}
|
||||
|
@ -757,25 +757,21 @@ class Item_func_min_max :public Item_func
|
||||
Item_result cmp_type;
|
||||
String tmp_value;
|
||||
int cmp_sign;
|
||||
/* TRUE <=> arguments should be compared in the DATETIME context. */
|
||||
bool compare_as_dates;
|
||||
/* An item used for issuing warnings while string to DATETIME conversion. */
|
||||
Item *datetime_item;
|
||||
Item *compare_as_dates;
|
||||
THD *thd;
|
||||
protected:
|
||||
enum_field_types cached_field_type;
|
||||
public:
|
||||
Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list),
|
||||
cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE),
|
||||
datetime_item(0) {}
|
||||
cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE) {}
|
||||
double val_real();
|
||||
longlong val_int();
|
||||
String *val_str(String *);
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
void fix_length_and_dec();
|
||||
enum Item_result result_type () const { return cmp_type; }
|
||||
bool result_as_longlong() { return compare_as_dates; };
|
||||
uint cmp_datetimes(ulonglong *value);
|
||||
bool cmp_datetimes(MYSQL_TIME *ltime);
|
||||
enum_field_types field_type() const { return cached_field_type; }
|
||||
};
|
||||
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
table_map used_tables() const { return used_tables_cache; };
|
||||
bool const_item() const { return const_item_cache; };
|
||||
enum Item_result result_type() const { return ROW_RESULT; }
|
||||
Item_result cmp_type() const { return ROW_RESULT; }
|
||||
void update_used_tables();
|
||||
table_map not_null_tables() const { return not_null_tables_cache; }
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
|
@ -692,14 +692,17 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table,
|
||||
*/
|
||||
switch (args[0]->field_type()) {
|
||||
case MYSQL_TYPE_DATE:
|
||||
field= new Field_newdate(maybe_null, name, collation.collation);
|
||||
field= new Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
|
||||
name, collation.collation);
|
||||
break;
|
||||
case MYSQL_TYPE_TIME:
|
||||
field= new Field_time(maybe_null, name, collation.collation);
|
||||
field= new_Field_time(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
|
||||
name, decimals, collation.collation);
|
||||
break;
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
field= new Field_datetime(maybe_null, name, collation.collation);
|
||||
field= new_Field_datetime(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
|
||||
name, decimals, collation.collation);
|
||||
break;
|
||||
default:
|
||||
return Item_sum::create_tmp_field(group, table, convert_blob_length);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -323,147 +323,100 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Item_func_time_to_sec :public Item_int_func
|
||||
class Item_func_time_to_sec :public Item_real_func
|
||||
{
|
||||
public:
|
||||
Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
|
||||
longlong val_int();
|
||||
Item_func_time_to_sec(Item *item) :Item_real_func(item) {}
|
||||
const char *func_name() const { return "time_to_sec"; }
|
||||
double val_real();
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
maybe_null= TRUE;
|
||||
decimals=0;
|
||||
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
|
||||
decimals=args[0]->decimals;
|
||||
max_length=17;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
This can't be a Item_str_func, because the val_real() functions are special
|
||||
*/
|
||||
|
||||
class Item_date :public Item_func
|
||||
class Item_temporal_func: public Item_func
|
||||
{
|
||||
public:
|
||||
Item_date() :Item_func() {}
|
||||
Item_date(Item *a) :Item_func(a) {}
|
||||
Item_temporal_func() :Item_func() {}
|
||||
Item_temporal_func(Item *a) :Item_func(a) {}
|
||||
Item_temporal_func(Item *a, Item *b) :Item_func(a,b) {}
|
||||
Item_temporal_func(Item *a, Item *b, Item *c) :Item_func(a,b,c) {}
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
|
||||
String *val_str(String *str);
|
||||
longlong val_int();
|
||||
double val_real() { return val_real_from_decimal(); }
|
||||
double val_real();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date) { DBUG_ASSERT(0); return 1; }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{ return val_decimal_from_date(decimal_value); }
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{ return tmp_table_field_from_field_type(table, 0); }
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{ return save_date_in_field(field); }
|
||||
};
|
||||
|
||||
class Item_datefunc :public Item_temporal_func
|
||||
{
|
||||
public:
|
||||
Item_datefunc() :Item_temporal_func() {}
|
||||
Item_datefunc(Item *a) :Item_temporal_func(a) {}
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
|
||||
const char *func_name() const { return "date"; }
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date)
|
||||
{ return get_arg0_date(res, fuzzy_date); }
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
decimals=0;
|
||||
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
|
||||
}
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return val_decimal_from_date(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
return save_date_in_field(field);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_date_func :public Item_str_func
|
||||
class Item_timefunc :public Item_temporal_func
|
||||
{
|
||||
public:
|
||||
Item_date_func() :Item_str_func() {}
|
||||
Item_date_func(Item *a) :Item_str_func(a) {}
|
||||
Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
|
||||
Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
double val_real() { return (double) val_int(); }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return val_decimal_from_date(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
return save_date_in_field(field);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_str_timefunc :public Item_str_func
|
||||
{
|
||||
public:
|
||||
Item_str_timefunc() :Item_str_func() {}
|
||||
Item_str_timefunc(Item *a) :Item_str_func(a) {}
|
||||
Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
|
||||
Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
|
||||
Item_timefunc() :Item_temporal_func() {}
|
||||
Item_timefunc(Item *a) :Item_temporal_func(a) {}
|
||||
Item_timefunc(Item *a,Item *b) :Item_temporal_func(a,b) {}
|
||||
Item_timefunc(Item *a, Item *b, Item *c) :Item_temporal_func(a, b ,c) {}
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
decimals= DATETIME_DEC;
|
||||
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
|
||||
max_length= MAX_TIME_WIDTH +
|
||||
(decimals ? min(decimals, MAX_SEC_PART_DIGITS)+1 : 0);
|
||||
}
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
double val_real() { return val_real_from_decimal(); }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return val_decimal_from_time(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
return save_time_in_field(field);
|
||||
}
|
||||
longlong val_int() { return val_int_from_decimal(); }
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
};
|
||||
|
||||
|
||||
/* Abstract CURTIME function. Children should define what time zone is used */
|
||||
|
||||
class Item_func_curtime :public Item_str_timefunc
|
||||
class Item_func_curtime :public Item_timefunc
|
||||
{
|
||||
longlong value;
|
||||
char buff[9*2+32];
|
||||
uint buff_length;
|
||||
MYSQL_TIME ltime;
|
||||
public:
|
||||
Item_func_curtime() :Item_str_timefunc() {}
|
||||
Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
|
||||
double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
|
||||
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
|
||||
String *val_str(String *str);
|
||||
Item_func_curtime(uint dec) :Item_timefunc() { decimals= dec; }
|
||||
bool fix_fields(THD *, Item **);
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
/*
|
||||
Abstract method that defines which time zone is used for conversion.
|
||||
Converts time current time in my_time_t representation to broken-down
|
||||
MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
|
||||
*/
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
};
|
||||
|
||||
|
||||
class Item_func_curtime_local :public Item_func_curtime
|
||||
{
|
||||
public:
|
||||
Item_func_curtime_local() :Item_func_curtime() {}
|
||||
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
|
||||
Item_func_curtime_local(uint dec) :Item_func_curtime(dec) {}
|
||||
const char *func_name() const { return "curtime"; }
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
|
||||
};
|
||||
@ -472,8 +425,7 @@ public:
|
||||
class Item_func_curtime_utc :public Item_func_curtime
|
||||
{
|
||||
public:
|
||||
Item_func_curtime_utc() :Item_func_curtime() {}
|
||||
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
|
||||
Item_func_curtime_utc(uint dec) :Item_func_curtime(dec) {}
|
||||
const char *func_name() const { return "utc_time"; }
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
|
||||
};
|
||||
@ -481,14 +433,11 @@ public:
|
||||
|
||||
/* Abstract CURDATE function. See also Item_func_curtime. */
|
||||
|
||||
class Item_func_curdate :public Item_date
|
||||
class Item_func_curdate :public Item_datefunc
|
||||
{
|
||||
longlong value;
|
||||
MYSQL_TIME ltime;
|
||||
public:
|
||||
Item_func_curdate() :Item_date() {}
|
||||
longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
|
||||
String *val_str(String *str);
|
||||
Item_func_curdate() :Item_datefunc() {}
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
|
||||
@ -515,20 +464,12 @@ public:
|
||||
|
||||
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
|
||||
|
||||
class Item_func_now :public Item_date_func
|
||||
class Item_func_now :public Item_temporal_func
|
||||
{
|
||||
protected:
|
||||
longlong value;
|
||||
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
|
||||
uint buff_length;
|
||||
MYSQL_TIME ltime;
|
||||
public:
|
||||
Item_func_now() :Item_date_func() {}
|
||||
Item_func_now(Item *a) :Item_date_func(a) {}
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
|
||||
int save_in_field(Field *to, bool no_conversions);
|
||||
String *val_str(String *str);
|
||||
Item_func_now(uint dec) :Item_temporal_func() { decimals= dec; }
|
||||
bool fix_fields(THD *, Item **);
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
|
||||
@ -538,8 +479,7 @@ public:
|
||||
class Item_func_now_local :public Item_func_now
|
||||
{
|
||||
public:
|
||||
Item_func_now_local() :Item_func_now() {}
|
||||
Item_func_now_local(Item *a) :Item_func_now(a) {}
|
||||
Item_func_now_local(uint dec) :Item_func_now(dec) {}
|
||||
const char *func_name() const { return "now"; }
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
|
||||
virtual enum Functype functype() const { return NOW_FUNC; }
|
||||
@ -549,8 +489,7 @@ public:
|
||||
class Item_func_now_utc :public Item_func_now
|
||||
{
|
||||
public:
|
||||
Item_func_now_utc() :Item_func_now() {}
|
||||
Item_func_now_utc(Item *a) :Item_func_now(a) {}
|
||||
Item_func_now_utc(uint dec) :Item_func_now(dec) {}
|
||||
const char *func_name() const { return "utc_timestamp"; }
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
|
||||
};
|
||||
@ -563,16 +502,10 @@ public:
|
||||
class Item_func_sysdate_local :public Item_func_now
|
||||
{
|
||||
public:
|
||||
Item_func_sysdate_local() :Item_func_now() {}
|
||||
Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
|
||||
Item_func_sysdate_local(uint dec) :Item_func_now(dec) {}
|
||||
bool const_item() const { return 0; }
|
||||
const char *func_name() const { return "sysdate"; }
|
||||
void store_now_in_TIME(MYSQL_TIME *now_time);
|
||||
double val_real();
|
||||
longlong val_int();
|
||||
int save_in_field(Field *to, bool no_conversions);
|
||||
String *val_str(String *str);
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
void update_used_tables()
|
||||
{
|
||||
@ -582,10 +515,10 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Item_func_from_days :public Item_date
|
||||
class Item_func_from_days :public Item_datefunc
|
||||
{
|
||||
public:
|
||||
Item_func_from_days(Item *a) :Item_date(a) {}
|
||||
Item_func_from_days(Item *a) :Item_datefunc(a) {}
|
||||
const char *func_name() const { return "from_days"; }
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
@ -609,13 +542,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Item_func_from_unixtime :public Item_date_func
|
||||
class Item_func_from_unixtime :public Item_temporal_func
|
||||
{
|
||||
THD *thd;
|
||||
public:
|
||||
Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
|
||||
longlong val_int();
|
||||
String *val_str(String *str);
|
||||
Item_func_from_unixtime(Item *a) :Item_temporal_func(a) {}
|
||||
const char *func_name() const { return "from_unixtime"; }
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
@ -636,7 +567,7 @@ class Time_zone;
|
||||
tables can be used during this function calculation for loading time zone
|
||||
descriptions.
|
||||
*/
|
||||
class Item_func_convert_tz :public Item_date_func
|
||||
class Item_func_convert_tz :public Item_temporal_func
|
||||
{
|
||||
/*
|
||||
If time zone parameters are constants we are caching objects that
|
||||
@ -648,9 +579,7 @@ class Item_func_convert_tz :public Item_date_func
|
||||
Time_zone *from_tz, *to_tz;
|
||||
public:
|
||||
Item_func_convert_tz(Item *a, Item *b, Item *c):
|
||||
Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
|
||||
longlong val_int();
|
||||
String *val_str(String *str);
|
||||
Item_temporal_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
|
||||
const char *func_name() const { return "convert_tz"; }
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
@ -658,29 +587,25 @@ class Item_func_convert_tz :public Item_date_func
|
||||
};
|
||||
|
||||
|
||||
class Item_func_sec_to_time :public Item_str_timefunc
|
||||
class Item_func_sec_to_time :public Item_timefunc
|
||||
{
|
||||
public:
|
||||
Item_func_sec_to_time(Item *item) :Item_str_timefunc(item) {}
|
||||
double val_real()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return (double) Item_func_sec_to_time::val_int();
|
||||
}
|
||||
longlong val_int();
|
||||
String *val_str(String *);
|
||||
Item_func_sec_to_time(Item *item) :Item_timefunc(item) {}
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
Item_str_timefunc::fix_length_and_dec();
|
||||
collation.set(&my_charset_bin);
|
||||
maybe_null=1;
|
||||
decimals= args[0]->decimals;
|
||||
if (decimals != NOT_FIXED_DEC && decimals > MAX_SEC_PART_DIGITS)
|
||||
decimals= MAX_SEC_PART_DIGITS;
|
||||
Item_timefunc::fix_length_and_dec();
|
||||
}
|
||||
const char *func_name() const { return "sec_to_time"; }
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
};
|
||||
|
||||
|
||||
class Item_date_add_interval :public Item_date_func
|
||||
class Item_date_add_interval :public Item_temporal_func
|
||||
{
|
||||
String value;
|
||||
enum_field_types cached_field_type;
|
||||
@ -689,12 +614,10 @@ public:
|
||||
const interval_type int_type; // keep it public
|
||||
const bool date_sub_interval; // keep it public
|
||||
Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
|
||||
:Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
|
||||
String *val_str(String *);
|
||||
:Item_temporal_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
|
||||
const char *func_name() const { return "date_add_interval"; }
|
||||
void fix_length_and_dec();
|
||||
enum_field_types field_type() const { return cached_field_type; }
|
||||
longlong val_int();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
bool eq(const Item *item, bool binary_cmp) const;
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
@ -718,43 +641,7 @@ class Item_extract :public Item_int_func
|
||||
};
|
||||
|
||||
|
||||
class Item_typecast :public Item_str_func
|
||||
{
|
||||
public:
|
||||
Item_typecast(Item *a) :Item_str_func(a) {}
|
||||
String *val_str(String *a)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
String *tmp=args[0]->val_str(a);
|
||||
null_value=args[0]->null_value;
|
||||
if (tmp)
|
||||
tmp->set_charset(collation.collation);
|
||||
return tmp;
|
||||
}
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
max_length=args[0]->max_length;
|
||||
}
|
||||
virtual const char* cast_type() const= 0;
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
};
|
||||
|
||||
|
||||
class Item_typecast_maybe_null :public Item_typecast
|
||||
{
|
||||
public:
|
||||
Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
max_length=args[0]->max_length;
|
||||
maybe_null= 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_char_typecast :public Item_typecast
|
||||
class Item_char_typecast :public Item_str_func
|
||||
{
|
||||
int cast_length;
|
||||
CHARSET_INFO *cast_cs, *from_cs;
|
||||
@ -762,119 +649,85 @@ class Item_char_typecast :public Item_typecast
|
||||
String tmp_value;
|
||||
public:
|
||||
Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg)
|
||||
:Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
|
||||
:Item_str_func(a), cast_length(length_arg), cast_cs(cs_arg) {}
|
||||
enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
|
||||
bool eq(const Item *item, bool binary_cmp) const;
|
||||
const char *func_name() const { return "cast_as_char"; }
|
||||
const char* cast_type() const { return "char"; };
|
||||
String *val_str(String *a);
|
||||
void fix_length_and_dec();
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
void print(String *str, enum_query_type query_type);
|
||||
};
|
||||
|
||||
|
||||
class Item_date_typecast :public Item_typecast_maybe_null
|
||||
class Item_temporal_typecast: public Item_temporal_func
|
||||
{
|
||||
public:
|
||||
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
|
||||
Item_temporal_typecast(Item *a) :Item_temporal_func(a) {}
|
||||
virtual const char *cast_type() const = 0;
|
||||
void print(String *str, enum_query_type query_type);
|
||||
};
|
||||
|
||||
class Item_date_typecast :public Item_temporal_typecast
|
||||
{
|
||||
public:
|
||||
Item_date_typecast(Item *a) :Item_temporal_typecast(a) {}
|
||||
const char *func_name() const { return "cast_as_date"; }
|
||||
String *val_str(String *str);
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
const char *cast_type() const { return "date"; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
max_length= 10;
|
||||
decimals= 0;
|
||||
max_length= MAX_DATE_WIDTH;
|
||||
maybe_null= 1;
|
||||
}
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
longlong val_int();
|
||||
double val_real() { return (double) val_int(); }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return val_decimal_from_date(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
return save_date_in_field(field);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_time_typecast :public Item_typecast_maybe_null
|
||||
class Item_time_typecast :public Item_temporal_typecast
|
||||
{
|
||||
public:
|
||||
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
|
||||
Item_time_typecast(Item *a, uint dec_arg)
|
||||
:Item_temporal_typecast(a) { decimals= dec_arg; }
|
||||
const char *func_name() const { return "cast_as_time"; }
|
||||
String *val_str(String *str);
|
||||
bool get_time(MYSQL_TIME *ltime);
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
const char *cast_type() const { return "time"; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
longlong val_int();
|
||||
double val_real() { return val_real_from_decimal(); }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return val_decimal_from_time(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
return save_time_in_field(field);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_datetime_typecast :public Item_typecast_maybe_null
|
||||
{
|
||||
public:
|
||||
Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
|
||||
const char *func_name() const { return "cast_as_datetime"; }
|
||||
String *val_str(String *str);
|
||||
const char *cast_type() const { return "datetime"; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
maybe_null= 1;
|
||||
max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
|
||||
decimals= DATETIME_DEC;
|
||||
}
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
longlong val_int();
|
||||
double val_real() { return val_real_from_decimal(); }
|
||||
double val() { return (double) val_int(); }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
return val_decimal_from_date(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
return save_date_in_field(field);
|
||||
max_length= MAX_TIME_WIDTH;
|
||||
if (decimals && decimals != NOT_FIXED_DEC)
|
||||
max_length+= min(decimals, MAX_SEC_PART_DIGITS) + 1;
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_makedate :public Item_date_func
|
||||
|
||||
class Item_datetime_typecast :public Item_temporal_typecast
|
||||
{
|
||||
public:
|
||||
Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
|
||||
String *val_str(String *str);
|
||||
Item_datetime_typecast(Item *a, uint dec_arg)
|
||||
:Item_temporal_typecast(a) { decimals= dec_arg; }
|
||||
const char *func_name() const { return "cast_as_datetime"; }
|
||||
const char *cast_type() const { return "datetime"; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(&my_charset_bin);
|
||||
maybe_null= 1;
|
||||
max_length= MAX_DATETIME_WIDTH;
|
||||
if (decimals && decimals != NOT_FIXED_DEC)
|
||||
max_length+= min(decimals, MAX_SEC_PART_DIGITS) + 1;
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_makedate :public Item_temporal_func
|
||||
{
|
||||
public:
|
||||
Item_func_makedate(Item *a,Item *b) :Item_temporal_func(a,b) {}
|
||||
const char *func_name() const { return "makedate"; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
|
||||
void fix_length_and_dec()
|
||||
@ -884,11 +737,11 @@ public:
|
||||
/* It returns NULL when the second argument is less or equal to 0 */
|
||||
maybe_null= 1;
|
||||
}
|
||||
longlong val_int();
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
};
|
||||
|
||||
|
||||
class Item_func_add_time :public Item_str_func
|
||||
class Item_func_add_time :public Item_temporal_func
|
||||
{
|
||||
const bool is_date;
|
||||
int sign;
|
||||
@ -896,61 +749,39 @@ class Item_func_add_time :public Item_str_func
|
||||
|
||||
public:
|
||||
Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
|
||||
:Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
|
||||
String *val_str(String *str);
|
||||
:Item_temporal_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
|
||||
enum_field_types field_type() const { return cached_field_type; }
|
||||
void fix_length_and_dec();
|
||||
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 0);
|
||||
}
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
const char *func_name() const { return "add_time"; }
|
||||
double val_real() { return val_real_from_decimal(); }
|
||||
my_decimal *val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (cached_field_type == MYSQL_TYPE_TIME)
|
||||
return val_decimal_from_time(decimal_value);
|
||||
if (cached_field_type == MYSQL_TYPE_DATETIME)
|
||||
return val_decimal_from_date(decimal_value);
|
||||
return Item_str_func::val_decimal(decimal_value);
|
||||
}
|
||||
int save_in_field(Field *field, bool no_conversions)
|
||||
{
|
||||
if (cached_field_type == MYSQL_TYPE_TIME)
|
||||
return save_time_in_field(field);
|
||||
if (cached_field_type == MYSQL_TYPE_DATETIME)
|
||||
return save_date_in_field(field);
|
||||
return Item_str_func::save_in_field(field, no_conversions);
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_timediff :public Item_str_timefunc
|
||||
class Item_func_timediff :public Item_timefunc
|
||||
{
|
||||
public:
|
||||
Item_func_timediff(Item *a, Item *b)
|
||||
:Item_str_timefunc(a, b) {}
|
||||
String *val_str(String *str);
|
||||
:Item_timefunc(a, b) {}
|
||||
const char *func_name() const { return "timediff"; }
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
Item_str_timefunc::fix_length_and_dec();
|
||||
decimals= NOT_FIXED_DEC;
|
||||
Item_timefunc::fix_length_and_dec();
|
||||
maybe_null= 1;
|
||||
}
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
};
|
||||
|
||||
class Item_func_maketime :public Item_str_timefunc
|
||||
class Item_func_maketime :public Item_timefunc
|
||||
{
|
||||
public:
|
||||
Item_func_maketime(Item *a, Item *b, Item *c)
|
||||
:Item_str_timefunc(a, b, c)
|
||||
:Item_timefunc(a, b, c)
|
||||
{
|
||||
maybe_null= TRUE;
|
||||
}
|
||||
String *val_str(String *str);
|
||||
const char *func_name() const { return "maketime"; }
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
};
|
||||
|
||||
class Item_func_microsecond :public Item_int_func
|
||||
@ -1009,32 +840,26 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Item_func_str_to_date :public Item_str_func
|
||||
class Item_func_str_to_date :public Item_temporal_func
|
||||
{
|
||||
enum_field_types cached_field_type;
|
||||
date_time_format_types cached_format_type;
|
||||
timestamp_type cached_timestamp_type;
|
||||
bool const_item;
|
||||
public:
|
||||
Item_func_str_to_date(Item *a, Item *b)
|
||||
:Item_str_func(a, b), const_item(false)
|
||||
:Item_temporal_func(a, b), const_item(false)
|
||||
{}
|
||||
String *val_str(String *str);
|
||||
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
|
||||
const char *func_name() const { return "str_to_date"; }
|
||||
enum_field_types field_type() const { return cached_field_type; }
|
||||
void fix_length_and_dec();
|
||||
Field *tmp_table_field(TABLE *table)
|
||||
{
|
||||
return tmp_table_field_from_field_type(table, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_func_last_day :public Item_date
|
||||
class Item_func_last_day :public Item_datefunc
|
||||
{
|
||||
public:
|
||||
Item_func_last_day(Item *a) :Item_date(a) {}
|
||||
Item_func_last_day(Item *a) :Item_datefunc(a) {}
|
||||
const char *func_name() const { return "last_day"; }
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
};
|
||||
|
12
sql/log.cc
12
sql/log.cc
@ -436,8 +436,7 @@ bool Log_to_csv_event_handler::
|
||||
|
||||
DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP);
|
||||
|
||||
((Field_timestamp*) table->field[0])->store_timestamp((my_time_t)
|
||||
event_time);
|
||||
((Field_timestamp*) table->field[0])->store_TIME((my_time_t) event_time, 0);
|
||||
|
||||
/* do a write */
|
||||
if (table->field[1]->store(user_host, user_host_len, client_cs) ||
|
||||
@ -579,8 +578,7 @@ bool Log_to_csv_event_handler::
|
||||
|
||||
/* store the time and user values */
|
||||
DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP);
|
||||
((Field_timestamp*) table->field[0])->store_timestamp((my_time_t)
|
||||
current_time);
|
||||
((Field_timestamp*) table->field[0])->store_TIME((my_time_t) current_time, 0);
|
||||
if (table->field[1]->store(user_host, user_host_len, client_cs))
|
||||
goto err;
|
||||
|
||||
@ -992,15 +990,16 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
|
||||
sctx->ip ? sctx->ip : "", "]", NullS) -
|
||||
user_host_buff);
|
||||
|
||||
current_time= my_time_possible_from_micro(current_utime);
|
||||
if (thd->start_utime)
|
||||
{
|
||||
query_utime= (current_utime - thd->start_utime);
|
||||
lock_utime= (thd->utime_after_lock - thd->start_utime);
|
||||
current_time= thd->start_time + query_utime/1000000;
|
||||
}
|
||||
else
|
||||
{
|
||||
query_utime= lock_utime= 0;
|
||||
current_time= my_time(0);
|
||||
}
|
||||
|
||||
if (!query)
|
||||
@ -1011,7 +1010,8 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
|
||||
}
|
||||
|
||||
for (current_handler= slow_log_handler_list; *current_handler ;)
|
||||
error= (*current_handler++)->log_slow(thd, current_time, thd->start_time,
|
||||
error= (*current_handler++)->log_slow(thd, current_time,
|
||||
thd->start_time,
|
||||
user_host_buff, user_host_len,
|
||||
query_utime, lock_utime, is_command,
|
||||
query, query_length) || error;
|
||||
|
@ -668,7 +668,8 @@ Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
|
||||
:log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg), thd(thd_arg)
|
||||
{
|
||||
server_id= thd->server_id;
|
||||
when= thd->start_time;
|
||||
when= thd->start_time;
|
||||
when_sec_part=thd->start_time_sec_part;
|
||||
cache_stmt= using_trans;
|
||||
}
|
||||
|
||||
@ -689,7 +690,8 @@ Log_event::Log_event()
|
||||
We can't call my_time() here as this would cause a call before
|
||||
my_init() is called
|
||||
*/
|
||||
when= 0;
|
||||
when= 0;
|
||||
when_sec_part=0;
|
||||
log_pos= 0;
|
||||
}
|
||||
#endif /* !MYSQL_CLIENT */
|
||||
@ -707,6 +709,7 @@ Log_event::Log_event(const char* buf,
|
||||
thd = 0;
|
||||
#endif
|
||||
when = uint4korr(buf);
|
||||
when_sec_part= 0;
|
||||
server_id = uint4korr(buf + SERVER_ID_OFFSET);
|
||||
data_written= uint4korr(buf + EVENT_LEN_OFFSET);
|
||||
if (description_event->binlog_version==1)
|
||||
@ -795,21 +798,13 @@ int Log_event::do_update_pos(Relay_log_info *rli)
|
||||
DBUG_EXECUTE_IF("let_first_flush_log_change_timestamp",
|
||||
if (debug_not_change_ts_if_art_event == 1
|
||||
&& is_artificial_event())
|
||||
{
|
||||
debug_not_change_ts_if_art_event= 0;
|
||||
});
|
||||
#ifndef DBUG_OFF
|
||||
rli->stmt_done(log_pos,
|
||||
is_artificial_event() &&
|
||||
debug_not_change_ts_if_art_event > 0 ? 0 : when);
|
||||
#else
|
||||
rli->stmt_done(log_pos, is_artificial_event()? 0 : when);
|
||||
#endif
|
||||
debug_not_change_ts_if_art_event= 0; );
|
||||
rli->stmt_done(log_pos, is_artificial_event()
|
||||
IF_DBUG(&& debug_not_change_ts_if_art_event > 0) ?
|
||||
0 : when);
|
||||
DBUG_EXECUTE_IF("let_first_flush_log_change_timestamp",
|
||||
if (debug_not_change_ts_if_art_event == 0)
|
||||
{
|
||||
debug_not_change_ts_if_art_event= 2;
|
||||
});
|
||||
debug_not_change_ts_if_art_event= 2; );
|
||||
}
|
||||
return 0; // Cannot fail currently
|
||||
}
|
||||
@ -945,7 +940,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
|
||||
log_pos= my_b_safe_tell(file)+data_written;
|
||||
}
|
||||
|
||||
now= (ulong) get_time(); // Query start time
|
||||
now= get_time(); // Query start time
|
||||
|
||||
/*
|
||||
Header will be of size LOG_EVENT_HEADER_LEN for all events, except for
|
||||
@ -2070,13 +2065,10 @@ void Log_event::print_timestamp(IO_CACHE* file, time_t* ts)
|
||||
struct tm *res;
|
||||
DBUG_ENTER("Log_event::print_timestamp");
|
||||
if (!ts)
|
||||
{
|
||||
ts = &when;
|
||||
#ifdef MYSQL_SERVER // This is always false
|
||||
struct tm tm_tmp;
|
||||
localtime_r(ts,(res= &tm_tmp));
|
||||
#else
|
||||
}
|
||||
res=localtime(ts);
|
||||
#endif
|
||||
|
||||
my_b_printf(file,"%02d%02d%02d %2d:%02d:%02d",
|
||||
res->tm_year % 100,
|
||||
@ -2360,6 +2352,15 @@ bool Query_log_event::write(IO_CACHE* file)
|
||||
memcpy(start, host.str, host.length);
|
||||
start+= host.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (thd && thd->query_start_sec_part_used)
|
||||
{
|
||||
*start++= Q_HRNOW;
|
||||
get_time();
|
||||
int3store(start, when_sec_part);
|
||||
start+= 3;
|
||||
}
|
||||
/*
|
||||
NOTE: When adding new status vars, please don't forget to update
|
||||
@ -2452,7 +2453,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
|
||||
|
||||
error_code= errcode;
|
||||
|
||||
time(&end_time);
|
||||
end_time= my_time(0);
|
||||
exec_time = (ulong) (end_time - thd_arg->start_time);
|
||||
/**
|
||||
@todo this means that if we have no catalog, then it is replicated
|
||||
@ -2587,6 +2588,7 @@ code_name(int code)
|
||||
case Q_CHARSET_DATABASE_CODE: return "Q_CHARSET_DATABASE_CODE";
|
||||
case Q_TABLE_MAP_FOR_UPDATE_CODE: return "Q_TABLE_MAP_FOR_UPDATE_CODE";
|
||||
case Q_MASTER_DATA_WRITTEN_CODE: return "Q_MASTER_DATA_WRITTEN_CODE";
|
||||
case Q_HRNOW: return "Q_HRNOW";
|
||||
}
|
||||
sprintf(buf, "CODE#%d", code);
|
||||
return buf;
|
||||
@ -2803,6 +2805,14 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
|
||||
CHECK_SPACE(pos, end, host.length);
|
||||
host.str= (char *)pos;
|
||||
pos+= host.length;
|
||||
break;
|
||||
}
|
||||
case Q_HRNOW:
|
||||
{
|
||||
CHECK_SPACE(pos, end, 3);
|
||||
when_sec_part= uint3korr(pos);
|
||||
pos+= 3;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* That's why you must write status vars in growing order of code */
|
||||
@ -2882,7 +2892,7 @@ void Query_log_event::print_query_header(IO_CACHE* file,
|
||||
PRINT_EVENT_INFO* print_event_info)
|
||||
{
|
||||
// TODO: print the catalog ??
|
||||
char buff[40],*end; // Enough for SET TIMESTAMP
|
||||
char buff[64], *end; // Enough for SET TIMESTAMP
|
||||
bool different_db= 1;
|
||||
uint32 tmp;
|
||||
|
||||
@ -2904,6 +2914,11 @@ void Query_log_event::print_query_header(IO_CACHE* file,
|
||||
}
|
||||
|
||||
end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
|
||||
if (when_sec_part)
|
||||
{
|
||||
*end++= '.';
|
||||
end=int10_to_str(when_sec_part, end, 10);
|
||||
}
|
||||
end= strmov(end, print_event_info->delimiter);
|
||||
*end++='\n';
|
||||
my_b_write(file, (uchar*) buff, (uint) (end-buff));
|
||||
@ -3165,7 +3180,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
|
||||
*/
|
||||
if (is_trans_keyword() || rpl_filter->db_ok(thd->db))
|
||||
{
|
||||
thd->set_time((time_t)when);
|
||||
thd->set_time(when, when_sec_part);
|
||||
thd->set_query((char*)query_arg, q_len_arg);
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
thd->query_id = next_query_id();
|
||||
@ -3598,7 +3613,7 @@ bool Start_log_event_v3::write(IO_CACHE* file)
|
||||
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
|
||||
memcpy(buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
|
||||
if (!dont_set_created)
|
||||
created= when= get_time();
|
||||
created= get_time();
|
||||
int4store(buff + ST_CREATED_OFFSET,created);
|
||||
return (write_header(file, sizeof(buff)) ||
|
||||
my_b_safe_write(file, (uchar*) buff, sizeof(buff)));
|
||||
@ -3997,7 +4012,7 @@ bool Format_description_log_event::write(IO_CACHE* file)
|
||||
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
|
||||
memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
|
||||
if (!dont_set_created)
|
||||
created= when= get_time();
|
||||
created= get_time();
|
||||
int4store(buff + ST_CREATED_OFFSET,created);
|
||||
buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN;
|
||||
memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len,
|
||||
@ -4703,7 +4718,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
|
||||
*/
|
||||
if (rpl_filter->db_ok(thd->db))
|
||||
{
|
||||
thd->set_time((time_t)when);
|
||||
thd->set_time(when, when_sec_part);
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
thd->query_id = next_query_id();
|
||||
VOID(pthread_mutex_unlock(&LOCK_thread_count));
|
||||
@ -7531,7 +7546,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
|
||||
TIMESTAMP column to a table with one.
|
||||
So we call set_time(), like in SBR. Presently it changes nothing.
|
||||
*/
|
||||
thd->set_time((time_t)when);
|
||||
thd->set_time(when, when_sec_part);
|
||||
|
||||
/*
|
||||
Now we are in a statement and will stay in a statement until we
|
||||
|
@ -265,6 +265,7 @@ struct sql_ex_info
|
||||
1 + 2 /* type, charset_database_number */ + \
|
||||
1 + 8 /* type, table_map_for_update */ + \
|
||||
1 + 4 /* type, master_data_written */ + \
|
||||
1 + 3 /* type, sec_part of NOW() */ + \
|
||||
1 + 16 + 1 + 60/* type, user_len, user, host_len, host */)
|
||||
#define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \
|
||||
LOG_EVENT_HEADER_LEN + /* write_header */ \
|
||||
@ -336,6 +337,8 @@ struct sql_ex_info
|
||||
|
||||
#define Q_INVOKER 11
|
||||
|
||||
#define Q_HRNOW 128
|
||||
|
||||
/* Intvar event post-header */
|
||||
|
||||
/* Intvar event data */
|
||||
@ -889,7 +892,8 @@ public:
|
||||
execution time, which guarantees good replication (otherwise, we
|
||||
could have a query and its event with different timestamps).
|
||||
*/
|
||||
time_t when;
|
||||
my_time_t when;
|
||||
ulong when_sec_part;
|
||||
/* The number of seconds the query took to run on the master. */
|
||||
ulong exec_time;
|
||||
/* Number of bytes written by write() function */
|
||||
@ -1000,16 +1004,27 @@ public:
|
||||
{ return 0; }
|
||||
virtual bool write_data_body(IO_CACHE* file __attribute__((unused)))
|
||||
{ return 0; }
|
||||
inline time_t get_time()
|
||||
inline my_time_t get_time()
|
||||
{
|
||||
THD *tmp_thd;
|
||||
if (when)
|
||||
return when;
|
||||
if (thd)
|
||||
return thd->start_time;
|
||||
{
|
||||
when= thd->start_time;
|
||||
when_sec_part= thd->start_time_sec_part;
|
||||
return when;
|
||||
}
|
||||
if ((tmp_thd= current_thd))
|
||||
return tmp_thd->start_time;
|
||||
return my_time(0);
|
||||
{
|
||||
when= tmp_thd->start_time;
|
||||
when_sec_part= tmp_thd->start_time_sec_part;
|
||||
return when;
|
||||
}
|
||||
my_hrtime_t hrtime= my_hrtime();
|
||||
when= hrtime_to_time(hrtime);
|
||||
when_sec_part= hrtime_sec_part(hrtime);
|
||||
return when;
|
||||
}
|
||||
#endif
|
||||
virtual Log_event_type get_type_code() = 0;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user