Adding support for Dynamic columns (WL#34):

- COLUMN_CREATE(column_nr, value, [column_nr,value]...)
- COLUMN_ADD(blob,column_nr, value, column_nr,value]...)
- COLUMN_DELETE(blob, column_nr, column_nr...)
- COLUMN_EXISTS(blob, column_nr)
- COLUMN_LIST(blob, column_nr)
- COLUMN_GET(string, column_nr AS type)

Added cast(X as DOUBLE) and cast(x as INT)
Better warning and error messages for wrong cast's
Created some sub functions to simplify and reuse code.
Added a lot of conversation functions with error/warnings for what went wrong.
Fixed some issues when casting time to datetime.
Added functions to dynamic strings and Strings to allow one to move a string buffer from dynamic strings to String (to save malloc+ copy)
Added dynamic columns library to libmysqlclient


include/Makefile.am:
  Added ma_dyncol.h
include/decimal.h:
  Added 'const' to arguments for some functions.
include/my_sys.h:
  Added dynstr_reassociate()
include/my_time.h:
  Added TIME_SUBSECOND_RANGE
  Added double_to_datetime()
  Added flag argument to str_to_time()
libmysql/CMakeLists.txt:
  Added mysys/ma_dyncol.c
libmysql/Makefile.shared:
  Added ma_dyncol
libmysql/libmysql.c:
  Added argument to str_to_time()
mysql-test/r/bigint.result:
  Better error messages
mysql-test/r/cast.result:
  Better warning and error messages
  A lot of new cast() tests
mysql-test/r/func_math.result:
  Better warning messages
mysql-test/r/func_str.result:
  Better warning messages
mysql-test/r/func_time.result:
  Better warning messages
mysql-test/r/sp-vars.result:
  Better warning messages
mysql-test/r/strict.result:
  Better warning messages
  New test result
mysql-test/r/type_newdecimal.result:
  Better warning messages
mysql-test/r/warnings.result:
  Better warning messages
mysql-test/suite/funcs_1/r/innodb_func_view.result:
  Updated results after better cast warnings
mysql-test/suite/funcs_1/r/memory_func_view.result:
  Updated results after better cast warnings
mysql-test/suite/funcs_1/r/myisam_func_view.result:
  Updated results after better cast warnings
mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test:
  Added begin...commit to speed up test.
mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc:
  Added begin...commit to speed up test.
mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc:
  Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_innodb.result:
  Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_myisam.result:
  Added begin...commit to speed up test.
mysql-test/suite/parts/r/rpl_partition.result:
  Added begin...commit to speed up test.
mysql-test/suite/parts/t/part_supported_sql_func_innodb.test:
  Removed duplicated --big_test
mysql-test/suite/parts/t/rpl_partition.test:
  Added begin...commit to speed up test.
mysql-test/suite/pbxt/r/cast.result:
  Updated results after better cast warnings
mysql-test/suite/pbxt/r/func_str.result:
  Updated results after better cast warnings
mysql-test/suite/pbxt/r/type_newdecimal.result:
  Updated results after better cast warnings
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
  Added begin...commit to speed up test.
mysql-test/suite/rpl/t/rpl_innodb_bug28430.test:
  Added begin...commit to speed up test.
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result:
  More warnings
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result:
  More warnings
mysql-test/t/cast.test:
  A lot of new cast() tests
mysql-test/t/strict.test:
  Added new test
mysys/CMakeLists.txt:
  Added ma_dyncol.c
mysys/Makefile.am:
  Added ma_dyncol.c
mysys/string.c:
  Added dynstr_reassociate() to move a buffer from dynamic_strings to some other allocator
sql-common/my_time.c:
  Added 'fuzzydate' flag to str_to_time()
  Added support for microseconds to my_time_to_str() and my_datetime_to_str()
  Reset second_parts in number_to_datetime()
  Added double_to_datetime()
sql/field.cc:
  Added double_to_longlong() and truncate_double() to simplify and reuse code
sql/field.h:
  New prototypes
sql/item.cc:
  Changed Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) to be aware of type of argument.
  (Needed to make it microsecond safe and get better warnings).
  Updated call to str_to_time_with_warn()
sql/item.h:
  Added struct st_dyncall_create_def used by dynamic columns
  Added virtual bool dynamic_result() to tell if type of argument may change over calls.
sql/item_cmpfunc.cc:
  Added Item_func_dyncol_exists()
sql/item_cmpfunc.h:
  Added class Item_func_dyncol_exists
sql/item_create.cc:
  Added get_length_and_scale() to simplify other functions
  Simplified and extended create_func_cast()
  Added support for cast(X as double(X,Y))
  Added functions to create dynamic column functions.
sql/item_create.h:
  Added prototypes
sql/item_func.cc:
  Extended cast functions Item_func_signed() and Item_func_unsigned() to work with dynamic types
  Added Item_double_typecast()
sql/item_func.h:
  Added class Item_double_typecast()
sql/item_strfunc.cc:
  Added functions for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_strfunc.h:
  Added classes for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_timefunc.cc:
  Added flag argument to str_to_time_with_warn()
  Updated Item_char_typecast() to handle result type that may change between calls (for dynamic columns)
  Added Item_time_typecast::get_date() to ensure that we cast a datetime to time properly.
sql/item_timefunc.h:
  Added get_date() to Item_time_typecast() to allow proper results for casting time to datetime
sql/lex.h:
  Added new SQL function names
sql/my_decimal.cc:
  Added 'const' to some arguments.
  Better error message in case of errors (we now print out the wrong value)
  Added my_decimal2int()
sql/my_decimal.h:
  Moved some constants to my_decimal_limits.h
  Updated prototypes.
  Made my_decimal2int() a function as it's rather long (no reason to have it inline)
  Added decimal2my_decimal() function.
sql/mysql_priv.h:
  Prototypes for new functions
sql/share/errmsg.txt:
  New error messages for wrong casts and dynamic columns
sql/sql_acl.cc:
  Fixed indentation
sql/sql_base.cc:
  Added dynamic_column_error_message()
sql/sql_string.h:
  Added reassociate() to move a buffer to be owned by String object.
sql/sql_yacc.yy:
  Added syntax for COLUMN_ functions.
sql/time.cc:
  Updated str_to_datetime_with_warn() flag argument to same type as other functions
  Added conversion flag to str_to_time_with_warn() (Similar to all datetime functions)
  Added conversion functions with warnings: double_to_datetime_with_warn() and decimal_to_datetime_with_warn()
strings/decimal.c:
  Added 'const' to arguments for some functions.
unittest/mysys/Makefile.am:
  Added test for dynamic columns code
This commit is contained in:
Michael Widenius 2011-05-08 13:24:06 +03:00
commit 5ab92b1f85
72 changed files with 7778 additions and 720 deletions

View file

@ -30,6 +30,7 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
my_getopt.h sslopt-longopts.h my_dir.h \ my_getopt.h sslopt-longopts.h my_dir.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
m_ctype.h my_attribute.h my_compiler.h \ m_ctype.h my_attribute.h my_compiler.h \
my_decimal_limits.h ma_dyncol.h \
$(HEADERS_GEN_CONFIGURE) \ $(HEADERS_GEN_CONFIGURE) \
$(HEADERS_GEN_MAKE) $(HEADERS_GEN_MAKE)

View file

@ -29,17 +29,17 @@ typedef struct st_decimal_t {
int internal_str2dec(const char *from, decimal_t *to, char **end, int internal_str2dec(const char *from, decimal_t *to, char **end,
my_bool fixed); my_bool fixed);
int decimal2string(decimal_t *from, char *to, int *to_len, int decimal2string(const decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals, int fixed_precision, int fixed_decimals,
char filler); char filler);
int decimal2ulonglong(decimal_t *from, ulonglong *to); int decimal2ulonglong(const decimal_t *from, ulonglong *to);
int ulonglong2decimal(ulonglong from, decimal_t *to); int ulonglong2decimal(ulonglong from, decimal_t *to);
int decimal2longlong(decimal_t *from, longlong *to); int decimal2longlong(const decimal_t *from, longlong *to);
int longlong2decimal(longlong from, decimal_t *to); int longlong2decimal(longlong from, decimal_t *to);
int decimal2double(decimal_t *from, double *to); int decimal2double(const decimal_t *from, double *to);
int double2decimal(double from, decimal_t *to); int double2decimal(double from, decimal_t *to);
int decimal_actual_fraction(decimal_t *from); int decimal_actual_fraction(decimal_t *from);
int decimal2bin(decimal_t *from, uchar *to, int precision, int scale); int decimal2bin(const decimal_t *from, uchar *to, int precision, int scale);
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale); int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
int decimal_size(int precision, int scale); int decimal_size(int precision, int scale);
@ -55,7 +55,7 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to, int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to,
int scale_incr); int scale_incr);
int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to); int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_round(decimal_t *from, decimal_t *to, int new_scale, int decimal_round(const decimal_t *from, decimal_t *to, int new_scale,
decimal_round_mode mode); decimal_round_mode mode);
int decimal_is_zero(decimal_t *from); int decimal_is_zero(decimal_t *from);
void max_decimal(int precision, int frac, decimal_t *to); void max_decimal(int precision, int frac, decimal_t *to);

141
include/ma_dyncol.h Normal file
View file

@ -0,0 +1,141 @@
/* Copyright (c) 2011, Monty Program Ab
Copyright (c) 2011, Oleksandr Byelkin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef ma_dyncol_h
#define ma_dyncol_h
#include <decimal.h>
#include <my_decimal_limits.h>
#include <mysql_time.h>
/* NO and OK is the same used just to show semantics */
#define ER_DYNCOL_NO ER_DYNCOL_OK
enum enum_dyncol_func_result
{
ER_DYNCOL_OK= 0,
ER_DYNCOL_YES= 1, /* For functions returning 0/1 */
ER_DYNCOL_FORMAT= -1, /* Wrong format of the encoded string */
ER_DYNCOL_LIMIT= -2, /* Some limit reached */
ER_DYNCOL_RESOURCE= -3, /* Out of resourses */
ER_DYNCOL_DATA= -4, /* Incorrect input data */
ER_DYNCOL_UNKNOWN_CHARSET= -5 /* Unknown character set */
};
typedef DYNAMIC_STRING DYNAMIC_COLUMN;
enum enum_dynamic_column_type
{
DYN_COL_NULL= 0,
DYN_COL_INT,
DYN_COL_UINT,
DYN_COL_DOUBLE,
DYN_COL_STRING,
DYN_COL_DECIMAL,
DYN_COL_DATETIME,
DYN_COL_DATE,
DYN_COL_TIME
};
typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE;
struct st_dynamic_column_value
{
DYNAMIC_COLUMN_TYPE type;
union
{
long long long_value;
unsigned long long ulong_value;
double double_value;
struct {
LEX_STRING string_value;
CHARSET_INFO *charset;
};
struct {
decimal_digit_t decimal_buffer[DECIMAL_BUFF_LENGTH];
decimal_t decimal_value;
};
MYSQL_TIME time_value;
};
};
typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE;
enum enum_dyncol_func_result
dynamic_column_create(DYNAMIC_COLUMN *str,
uint column_nr, DYNAMIC_COLUMN_VALUE *value);
enum enum_dyncol_func_result
dynamic_column_create_many(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *value);
enum enum_dyncol_func_result
dynamic_column_update_many(DYNAMIC_COLUMN *str,
uint add_column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr);
enum enum_dyncol_func_result
dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr);
/* List of not NULL columns */
enum enum_dyncol_func_result
dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
/*
if the column do not exists it is NULL
*/
enum enum_dyncol_func_result
dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here);
#define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A)))
#define dynamic_column_column_free(V) dynstr_free(V)
/***************************************************************************
Internal functions, don't use if you don't know what you are doing...
***************************************************************************/
#define dynamic_column_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A))
#define dynamic_column_value_init(V) (V)->type= DYN_COL_NULL
/*
Prepare value for using as decimal
*/
void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value);
#endif

View file

@ -0,0 +1,31 @@
#ifndef my_decimal_limits_h
#define my_decimal_limits_h
#define DECIMAL_LONGLONG_DIGITS 22
#define DECIMAL_LONG_DIGITS 10
#define DECIMAL_LONG3_DIGITS 8
/** maximum length of buffer in our big digits (uint32). */
#define DECIMAL_BUFF_LENGTH 9
/* the number of digits that my_decimal can possibly contain */
#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
/**
maximum guaranteed precision of number in decimal digits (number of our
digits * number of decimal digits in one our big digit - number of decimal
digits in one our big digit decreased by 1 (because we always put decimal
point on the border of our big digits))
*/
#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
#define DECIMAL_MAX_SCALE 30
#define DECIMAL_NOT_SPECIFIED 31
/**
maximum length of string representation (number of maximum decimal
digits + 1 position for sign + 1 position for decimal point)
*/
#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
#endif

View file

@ -863,6 +863,8 @@ extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n); extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
extern void dynstr_free(DYNAMIC_STRING *str); extern void dynstr_free(DYNAMIC_STRING *str);
extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length,
size_t *alloc_length);
#ifdef HAVE_MLOCK #ifdef HAVE_MLOCK
extern void *my_malloc_lock(size_t length,myf flags); extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(void *ptr,myf flags); extern void my_free_lock(void *ptr,myf flags);

View file

@ -72,6 +72,7 @@ typedef long my_time_t;
TIME_MAX_SECOND) TIME_MAX_SECOND)
#define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \ #define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \
TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND) TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND)
#define TIME_SUBSECOND_RANGE 1000000
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulong flags, int *was_cut); ulong flags, int *was_cut);
@ -80,6 +81,8 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
uint flags, int *was_cut); uint flags, int *was_cut);
longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
uint flags, int *was_cut); uint flags, int *was_cut);
my_bool double_to_datetime(double nr, MYSQL_TIME *time_res,
uint flags);
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *); ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *); ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *); ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *);
@ -87,7 +90,7 @@ ulonglong TIME_to_ulonglong(const MYSQL_TIME *);
my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time, my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time,
int *warning); ulong flag,int *warning);
int check_time_range(struct st_mysql_time *, int *warning); int check_time_range(struct st_mysql_time *, int *warning);

View file

@ -68,6 +68,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c
../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c
../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
../strings/decimal.c
../mysys/default.c errmsg.c ../mysys/errors.c ../mysys/my_sync.c ../mysys/default.c errmsg.c ../mysys/errors.c ../mysys/my_sync.c
../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c ../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c
get_password.c ../strings/int2str.c ../strings/is_prefix.c get_password.c ../strings/int2str.c ../strings/is_prefix.c
@ -85,6 +86,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c
../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c
../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c
../mysys/ma_dyncol.c
../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c
../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c
../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c

View file

@ -48,7 +48,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
ctype-ucs2.lo ctype-gb2312.lo ctype-gbk.lo \ ctype-ucs2.lo ctype-gb2312.lo ctype-gbk.lo \
ctype-sjis.lo ctype-tis620.lo ctype-ujis.lo \ ctype-sjis.lo ctype-tis620.lo ctype-ujis.lo \
ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo \ ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo \
strmov_overlapp.lo strmov_overlapp.lo decimal.lo
mystringsextra= strto.c mystringsextra= strto.c
mystringsheaders= strings_def.h mystringsheaders= strings_def.h
@ -65,7 +65,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_symlink.lo my_fstream.lo mf_arr_appstr.lo \ my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \ mf_loadpath.lo my_pthread.lo my_thr_init.lo \
thr_mutex.lo mulalloc.lo string.lo \ thr_mutex.lo mulalloc.lo string.lo \
default.lo default_modify.lo \ default.lo default_modify.lo ma_dyncol.lo \
my_compress.lo array.lo my_once.lo list.lo my_net.lo \ my_compress.lo array.lo my_once.lo list.lo my_net.lo \
charset.lo charset-def.lo hash.lo mf_iocache.lo \ charset.lo charset-def.lo hash.lo mf_iocache.lo \
mf_iocache2.lo my_seek.lo my_sleep.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \

View file

@ -3549,7 +3549,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
{ {
MYSQL_TIME *tm= (MYSQL_TIME *)buffer; MYSQL_TIME *tm= (MYSQL_TIME *)buffer;
str_to_time(value, length, tm, &err); str_to_time(value, length, tm, TIME_FUZZY_DATE, &err);
*param->error= test(err); *param->error= test(err);
break; break;
} }

View file

@ -362,12 +362,12 @@ select cast(19999999999999999999 as signed);
cast(19999999999999999999 as signed) cast(19999999999999999999 as signed)
9223372036854775807 9223372036854775807
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '19999999999999999999' to INT. Value truncated.
select cast(-19999999999999999999 as signed); select cast(-19999999999999999999 as signed);
cast(-19999999999999999999 as signed) cast(-19999999999999999999 as signed)
-9223372036854775808 -9223372036854775808
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-19999999999999999999' to INT. Value truncated.
select -9223372036854775808; select -9223372036854775808;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def -9223372036854775808 8 20 20 N 32897 0 63 def -9223372036854775808 8 20 20 N 32897 0 63

View file

@ -1,9 +1,13 @@
select CAST(1-2 AS UNSIGNED); select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED) CAST(1-2 AS UNSIGNED)
18446744073709551615 18446744073709551615
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER); select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER) CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1 -1
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST('10 ' as unsigned integer); select CAST('10 ' as unsigned integer);
CAST('10 ' as unsigned integer) CAST('10 ' as unsigned integer)
10 10
@ -12,9 +16,15 @@ Warning 1292 Truncated incorrect INTEGER value: '10 '
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1 cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
18446744073709551611 18446744073709551611 18446744073709551611 18446744073709551611
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1; select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1 cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
18446744073709551610 18446744073709551612 18446744073709551610 18446744073709551612
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select ~5, cast(~5 as signed); select ~5, cast(~5 as signed);
~5 cast(~5 as signed) ~5 cast(~5 as signed)
18446744073709551610 -6 18446744073709551610 -6
@ -29,6 +39,51 @@ cast(5 as unsigned) -6.0
select cast(NULL as signed), cast(1/0 as signed); select cast(NULL as signed), cast(1/0 as signed);
cast(NULL as signed) cast(1/0 as signed) cast(NULL as signed) cast(1/0 as signed)
NULL NULL NULL NULL
select cast(1 as double(5,2));
cast(1 as double(5,2))
1.00
select cast("5.2222" as double(5,2));
cast("5.2222" as double(5,2))
5.22
select cast(12.444 as double(5,2));
cast(12.444 as double(5,2))
12.44
select cast(cast(12.444 as decimal(10,3)) as double(5,2));
cast(cast(12.444 as decimal(10,3)) as double(5,2))
12.44
select cast(null as double(5,2));
cast(null as double(5,2))
NULL
select cast(12.444 as double);
cast(12.444 as double)
12.444
select cast(cast("20:01:01" as time) as datetime);
cast(cast("20:01:01" as time) as datetime)
0000-00-00 20:01:01
select cast(cast("8:46:06.23434" AS time) as decimal(32,10));
cast(cast("8:46:06.23434" AS time) as decimal(32,10))
84606.2343400000
select cast(cast(20010203101112.121314 as double) as datetime);
cast(cast(20010203101112.121314 as double) as datetime)
2001-02-03 10:11:12.125000
select cast(cast(010203101112.12 as double) as datetime);
cast(cast(010203101112.12 as double) as datetime)
2001-02-03 10:11:12.120000
select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime);
cast(cast(20010203101112.121314 as decimal(32,6)) as datetime)
2001-02-03 10:11:12.121314
select cast(20010203101112.121314 as datetime);
cast(20010203101112.121314 as datetime)
2001-02-03 10:11:12.121314
select cast(110203101112.121314 as datetime);
cast(110203101112.121314 as datetime)
2011-02-03 10:11:12.121314
select cast(cast(010203101112.12 as double) as datetime);
cast(cast(010203101112.12 as double) as datetime)
2001-02-03 10:11:12.120000
select cast(cast("2011-04-05 8:46:06.23434" AS datetime) as time);
cast(cast("2011-04-05 8:46:06.23434" AS datetime) as time)
08:46:06.234340
select cast(NULL as unsigned), cast(1/0 as unsigned); select cast(NULL as unsigned), cast(1/0 as unsigned);
cast(NULL as unsigned) cast(1/0 as unsigned) cast(NULL as unsigned) cast(1/0 as unsigned)
NULL NULL NULL NULL
@ -111,6 +166,115 @@ select 10E+0+'a';
10 10
Warnings: Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a' Warning 1292 Truncated incorrect DOUBLE value: 'a'
select cast("a" as double(5,2));
cast("a" as double(5,2))
0.00
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
select cast(1000 as decimal(5,2));
cast(1000 as decimal(5,2))
999.99
Warnings:
Error 1264 Out of range value for column 'cast(1000 as decimal(5,2))' at row 1
select cast(-1000 as decimal(5,2));
cast(-1000 as decimal(5,2))
-999.99
Warnings:
Error 1264 Out of range value for column 'cast(-1000 as decimal(5,2))' at row 1
select cast(1000 as double(5,2));
cast(1000 as double(5,2))
999.99
Warnings:
Warning 1264 Out of range value for column 'cast(1000 as double(5,2))' at row 1
select cast(-1000 as double(5,2));
cast(-1000 as double(5,2))
-999.99
Warnings:
Warning 1264 Out of range value for column 'cast(-1000 as double(5,2))' at row 1
select cast(010203101112.121314 as datetime);
cast(010203101112.121314 as datetime)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '10203101112.121314'
select cast(120010203101112.121314 as datetime);
cast(120010203101112.121314 as datetime)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '120010203101112.121314'
select cast(cast(1.1 as decimal) as datetime);
cast(cast(1.1 as decimal) as datetime)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '1'
select cast(cast(-1.1 as decimal) as datetime);
cast(cast(-1.1 as decimal) as datetime)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '-1'
select cast('0' as date);
cast('0' as date)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '0'
select cast('' as date);
cast('' as date)
NULL
Warnings:
Warning 1292 Incorrect datetime value: ''
select cast('0' as datetime);
cast('0' as datetime)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '0'
select cast('' as datetime);
cast('' as datetime)
NULL
Warnings:
Warning 1292 Incorrect datetime value: ''
select cast('0' as time);
cast('0' as time)
00:00:00
select cast('' as time);
cast('' as time)
NULL
Warnings:
Warning 1292 Truncated incorrect time value: ''
select cast(NULL as DATE);
cast(NULL as DATE)
NULL
select cast(NULL as DATETIME);
cast(NULL as DATETIME)
NULL
select cast(NULL as TIME);
cast(NULL as TIME)
NULL
select cast(NULL as BINARY);
cast(NULL as BINARY)
NULL
select cast(cast(120010203101112.121314 as double) as datetime);
cast(cast(120010203101112.121314 as double) as datetime)
NULL
select cast(cast(1.1 as double) as datetime);
cast(cast(1.1 as double) as datetime)
NULL
select cast(cast(-1.1 as double) as datetime);
cast(cast(-1.1 as double) as datetime)
NULL
explain extended select cast(10 as double(5,2));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(10 as double(5,2)) AS `cast(10 as double(5,2))`
explain extended select cast(10 as double);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(10 as double) AS `cast(10 as double)`
explain extended select cast(10 as decimal(5,2));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(10 as decimal(5,2)) AS `cast(10 as decimal(5,2))`
select cast('18446744073709551616' as unsigned); select cast('18446744073709551616' as unsigned);
cast('18446744073709551616' as unsigned) cast('18446744073709551616' as unsigned)
18446744073709551615 18446744073709551615
@ -146,6 +310,18 @@ cast('' as signed)
0 0
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '' Warning 1292 Truncated incorrect INTEGER value: ''
select cast(1 as double(5,6));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
select cast(1 as decimal(5,6));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
select cast(1 as double(66,6));
ERROR 42000: Too big precision 66 specified for column '1'. Maximum is 65.
select cast(1 as decimal(66,6));
ERROR 42000: Too big precision 66 specified for column '1'. Maximum is 65.
select cast(1 as decimal(64,63));
ERROR 42000: Too big scale 63 specified for column '1'. Maximum is 30.
select cast(1 as double(64,63));
ERROR 42000: Too big scale 63 specified for column '1'. Maximum is 30.
set names binary; set names binary;
select cast(_latin1'test' as char character set latin2); select cast(_latin1'test' as char character set latin2);
cast(_latin1'test' as char character set latin2) cast(_latin1'test' as char character set latin2)
@ -255,12 +431,6 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
select cast("1:2:3" as TIME) = "1:02:03"; select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03" cast("1:2:3" as TIME) = "1:02:03"
0 0
select cast(NULL as DATE);
cast(NULL as DATE)
NULL
select cast(NULL as BINARY);
cast(NULL as BINARY)
NULL
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ; SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
@ -337,6 +507,21 @@ Warning 1105 Cast to signed converted positive out-of-range integer to it's nega
select cast(1.0e+300 as signed int); select cast(1.0e+300 as signed int);
cast(1.0e+300 as signed int) cast(1.0e+300 as signed int)
9223372036854775807 9223372036854775807
create table t1 select cast(1 as unsigned), cast(1 as signed), cast(1 as double(5,2)), cast(1 as decimal(5,3)), cast("A" as binary), cast("A" as char(100)), cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME), cast("1:2:3" as TIME);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`cast(1 as unsigned)` int(1) unsigned NOT NULL DEFAULT '0',
`cast(1 as signed)` int(1) NOT NULL DEFAULT '0',
`cast(1 as double(5,2))` double(5,2) DEFAULT NULL,
`cast(1 as decimal(5,3))` decimal(5,3) NOT NULL DEFAULT '0.000',
`cast("A" as binary)` varbinary(1) NOT NULL DEFAULT '',
`cast("A" as char(100))` varbinary(100) NOT NULL DEFAULT '',
`cast("2001-1-1" as DATE)` date DEFAULT NULL,
`cast("2001-1-1" as DATETIME)` datetime DEFAULT NULL,
`cast("1:2:3" as TIME)` time DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t1 (f1 double); CREATE TABLE t1 (f1 double);
INSERT INTO t1 SET f1 = -1.0e+30 ; INSERT INTO t1 SET f1 = -1.0e+30 ;
INSERT INTO t1 SET f1 = +1.0e+30 ; INSERT INTO t1 SET f1 = +1.0e+30 ;

1187
mysql-test/r/dyncol.result Normal file

File diff suppressed because it is too large Load diff

View file

@ -285,33 +285,55 @@ set names default;
select cast(-2 as unsigned), 18446744073709551614, -2; select cast(-2 as unsigned), 18446744073709551614, -2;
cast(-2 as unsigned) 18446744073709551614 -2 cast(-2 as unsigned) 18446744073709551614 -2
18446744073709551614 18446744073709551614 -2 18446744073709551614 18446744073709551614 -2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2); select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2) abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2)
18446744073709551614 18446744073709551614 2 18446744073709551614 18446744073709551614 2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2); select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2) ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2)
18446744073709551614 18446744073709551614 -2 18446744073709551614 18446744073709551614 -2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2); select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2) floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2)
18446744073709551614 18446744073709551614 -2 18446744073709551614 18446744073709551614 -2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2); select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2) format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2)
18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00 18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2); select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2) sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2)
4294967296 4294967296 NULL 4294967296 4294967296 NULL
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1); select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1) round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1)
18446744073709551614 18446744073709551614 -2 18446744073709551614 18446744073709551614 -2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2); select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2) round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2)
4 4 0 4 4 0
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1); select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1) truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1)
18446744073709551614 18446744073709551614 -2 18446744073709551614 18446744073709551614 -2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2); select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2) truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2)
4 4 0 4 4 0
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select round(10000000000000000000, -19), truncate(10000000000000000000, -19); select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
round(10000000000000000000, -19) truncate(10000000000000000000, -19) round(10000000000000000000, -19) truncate(10000000000000000000, -19)
10000000000000000000 10000000000000000000 10000000000000000000 10000000000000000000
@ -363,12 +385,18 @@ round(4, -4294967200) truncate(4, -4294967200)
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3); select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3) mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3)
2 2 -2 2 2 -2
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2); select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2) mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
5 5 1 5 5 1
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5) pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
2.13598703592091e+96 2.13598703592091e+96 -32 2.13598703592091e+96 2.13598703592091e+96 -32
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
SELECT a DIV 900 y FROM t1 GROUP BY y; SELECT a DIV 900 y FROM t1 GROUP BY y;
@ -488,7 +516,7 @@ SELECT -9999999999999999991 DIV -1;
-9999999999999999991 DIV -1 -9999999999999999991 DIV -1
-9223372036854775808 -9223372036854775808
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999991' to INT. Value truncated.
SELECT -9223372036854775808 DIV -1; SELECT -9223372036854775808 DIV -1;
-9223372036854775808 DIV -1 -9223372036854775808 DIV -1
-9223372036854775808 -9223372036854775808

View file

@ -1533,7 +1533,7 @@ select locate('lo','hello',-18446744073709551615);
locate('lo','hello',-18446744073709551615) locate('lo','hello',-18446744073709551615)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select locate('lo','hello',18446744073709551615); select locate('lo','hello',18446744073709551615);
locate('lo','hello',18446744073709551615) locate('lo','hello',18446744073709551615)
0 0
@ -1541,22 +1541,22 @@ select locate('lo','hello',-18446744073709551616);
locate('lo','hello',-18446744073709551616) locate('lo','hello',-18446744073709551616)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select locate('lo','hello',18446744073709551616); select locate('lo','hello',18446744073709551616);
locate('lo','hello',18446744073709551616) locate('lo','hello',18446744073709551616)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select locate('lo','hello',-18446744073709551617); select locate('lo','hello',-18446744073709551617);
locate('lo','hello',-18446744073709551617) locate('lo','hello',-18446744073709551617)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select locate('lo','hello',18446744073709551617); select locate('lo','hello',18446744073709551617);
locate('lo','hello',18446744073709551617) locate('lo','hello',18446744073709551617)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select left('hello', 10); select left('hello', 10);
left('hello', 10) left('hello', 10)
hello hello
@ -1588,8 +1588,8 @@ select left('hello', -18446744073709551615);
left('hello', -18446744073709551615) left('hello', -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select left('hello', 18446744073709551615); select left('hello', 18446744073709551615);
left('hello', 18446744073709551615) left('hello', 18446744073709551615)
hello hello
@ -1597,26 +1597,26 @@ select left('hello', -18446744073709551616);
left('hello', -18446744073709551616) left('hello', -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select left('hello', 18446744073709551616); select left('hello', 18446744073709551616);
left('hello', 18446744073709551616) left('hello', 18446744073709551616)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select left('hello', -18446744073709551617); select left('hello', -18446744073709551617);
left('hello', -18446744073709551617) left('hello', -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select left('hello', 18446744073709551617); select left('hello', 18446744073709551617);
left('hello', 18446744073709551617) left('hello', 18446744073709551617)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select right('hello', 10); select right('hello', 10);
right('hello', 10) right('hello', 10)
hello hello
@ -1648,8 +1648,8 @@ select right('hello', -18446744073709551615);
right('hello', -18446744073709551615) right('hello', -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select right('hello', 18446744073709551615); select right('hello', 18446744073709551615);
right('hello', 18446744073709551615) right('hello', 18446744073709551615)
hello hello
@ -1657,26 +1657,26 @@ select right('hello', -18446744073709551616);
right('hello', -18446744073709551616) right('hello', -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select right('hello', 18446744073709551616); select right('hello', 18446744073709551616);
right('hello', 18446744073709551616) right('hello', 18446744073709551616)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select right('hello', -18446744073709551617); select right('hello', -18446744073709551617);
right('hello', -18446744073709551617) right('hello', -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select right('hello', 18446744073709551617); select right('hello', 18446744073709551617);
right('hello', 18446744073709551617) right('hello', 18446744073709551617)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 2, -1); select substring('hello', 2, -1);
substring('hello', 2, -1) substring('hello', 2, -1)
@ -1708,8 +1708,8 @@ select substring('hello', -18446744073709551615, 1);
substring('hello', -18446744073709551615, 1) substring('hello', -18446744073709551615, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 1); select substring('hello', 18446744073709551615, 1);
substring('hello', 18446744073709551615, 1) substring('hello', 18446744073709551615, 1)
@ -1717,26 +1717,26 @@ select substring('hello', -18446744073709551616, 1);
substring('hello', -18446744073709551616, 1) substring('hello', -18446744073709551616, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 1); select substring('hello', 18446744073709551616, 1);
substring('hello', 18446744073709551616, 1) substring('hello', 18446744073709551616, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, 1); select substring('hello', -18446744073709551617, 1);
substring('hello', -18446744073709551617, 1) substring('hello', -18446744073709551617, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 1); select substring('hello', 18446744073709551617, 1);
substring('hello', 18446744073709551617, 1) substring('hello', 18446744073709551617, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 1, -1); select substring('hello', 1, -1);
substring('hello', 1, -1) substring('hello', 1, -1)
@ -1762,8 +1762,8 @@ select substring('hello', 1, -18446744073709551615);
substring('hello', 1, -18446744073709551615) substring('hello', 1, -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 1, 18446744073709551615); select substring('hello', 1, 18446744073709551615);
substring('hello', 1, 18446744073709551615) substring('hello', 1, 18446744073709551615)
hello hello
@ -1771,26 +1771,26 @@ select substring('hello', 1, -18446744073709551616);
substring('hello', 1, -18446744073709551616) substring('hello', 1, -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 1, 18446744073709551616); select substring('hello', 1, 18446744073709551616);
substring('hello', 1, 18446744073709551616) substring('hello', 1, 18446744073709551616)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', 1, -18446744073709551617); select substring('hello', 1, -18446744073709551617);
substring('hello', 1, -18446744073709551617) substring('hello', 1, -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 1, 18446744073709551617); select substring('hello', 1, 18446744073709551617);
substring('hello', 1, 18446744073709551617) substring('hello', 1, 18446744073709551617)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', -1, -1); select substring('hello', -1, -1);
substring('hello', -1, -1) substring('hello', -1, -1)
@ -1816,10 +1816,10 @@ select substring('hello', -18446744073709551615, -18446744073709551615);
substring('hello', -18446744073709551615, -18446744073709551615) substring('hello', -18446744073709551615, -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 18446744073709551615); select substring('hello', 18446744073709551615, 18446744073709551615);
substring('hello', 18446744073709551615, 18446744073709551615) substring('hello', 18446744073709551615, 18446744073709551615)
@ -1827,34 +1827,34 @@ select substring('hello', -18446744073709551616, -18446744073709551616);
substring('hello', -18446744073709551616, -18446744073709551616) substring('hello', -18446744073709551616, -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 18446744073709551616); select substring('hello', 18446744073709551616, 18446744073709551616);
substring('hello', 18446744073709551616, 18446744073709551616) substring('hello', 18446744073709551616, 18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, -18446744073709551617); select substring('hello', -18446744073709551617, -18446744073709551617);
substring('hello', -18446744073709551617, -18446744073709551617) substring('hello', -18446744073709551617, -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 18446744073709551617); select substring('hello', 18446744073709551617, 18446744073709551617);
substring('hello', 18446744073709551617, 18446744073709551617) substring('hello', 18446744073709551617, 18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, 1, 'hi'); select insert('hello', -1, 1, 'hi');
insert('hello', -1, 1, 'hi') insert('hello', -1, 1, 'hi')
hello hello
@ -1880,7 +1880,7 @@ select insert('hello', -18446744073709551615, 1, 'hi');
insert('hello', -18446744073709551615, 1, 'hi') insert('hello', -18446744073709551615, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 1, 'hi'); select insert('hello', 18446744073709551615, 1, 'hi');
insert('hello', 18446744073709551615, 1, 'hi') insert('hello', 18446744073709551615, 1, 'hi')
hello hello
@ -1888,22 +1888,22 @@ select insert('hello', -18446744073709551616, 1, 'hi');
insert('hello', -18446744073709551616, 1, 'hi') insert('hello', -18446744073709551616, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 1, 'hi'); select insert('hello', 18446744073709551616, 1, 'hi');
insert('hello', 18446744073709551616, 1, 'hi') insert('hello', 18446744073709551616, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, 1, 'hi'); select insert('hello', -18446744073709551617, 1, 'hi');
insert('hello', -18446744073709551617, 1, 'hi') insert('hello', -18446744073709551617, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 1, 'hi'); select insert('hello', 18446744073709551617, 1, 'hi');
insert('hello', 18446744073709551617, 1, 'hi') insert('hello', 18446744073709551617, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', 1, -1, 'hi'); select insert('hello', 1, -1, 'hi');
insert('hello', 1, -1, 'hi') insert('hello', 1, -1, 'hi')
hi hi
@ -1929,7 +1929,7 @@ select insert('hello', 1, -18446744073709551615, 'hi');
insert('hello', 1, -18446744073709551615, 'hi') insert('hello', 1, -18446744073709551615, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 1, 18446744073709551615, 'hi'); select insert('hello', 1, 18446744073709551615, 'hi');
insert('hello', 1, 18446744073709551615, 'hi') insert('hello', 1, 18446744073709551615, 'hi')
hi hi
@ -1937,22 +1937,22 @@ select insert('hello', 1, -18446744073709551616, 'hi');
insert('hello', 1, -18446744073709551616, 'hi') insert('hello', 1, -18446744073709551616, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 1, 18446744073709551616, 'hi'); select insert('hello', 1, 18446744073709551616, 'hi');
insert('hello', 1, 18446744073709551616, 'hi') insert('hello', 1, 18446744073709551616, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', 1, -18446744073709551617, 'hi'); select insert('hello', 1, -18446744073709551617, 'hi');
insert('hello', 1, -18446744073709551617, 'hi') insert('hello', 1, -18446744073709551617, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 1, 18446744073709551617, 'hi'); select insert('hello', 1, 18446744073709551617, 'hi');
insert('hello', 1, 18446744073709551617, 'hi') insert('hello', 1, 18446744073709551617, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, -1, 'hi'); select insert('hello', -1, -1, 'hi');
insert('hello', -1, -1, 'hi') insert('hello', -1, -1, 'hi')
hello hello
@ -1978,8 +1978,8 @@ select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
insert('hello', -18446744073709551615, -18446744073709551615, 'hi') insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi'); select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
insert('hello', 18446744073709551615, 18446744073709551615, 'hi') insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
hello hello
@ -1987,26 +1987,26 @@ select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
insert('hello', -18446744073709551616, -18446744073709551616, 'hi') insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi'); select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
insert('hello', 18446744073709551616, 18446744073709551616, 'hi') insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi'); select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
insert('hello', -18446744073709551617, -18446744073709551617, 'hi') insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi'); select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
insert('hello', 18446744073709551617, 18446744073709551617, 'hi') insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select repeat('hello', -1); select repeat('hello', -1);
repeat('hello', -1) repeat('hello', -1)
@ -2038,8 +2038,8 @@ select repeat('hello', -18446744073709551615);
repeat('hello', -18446744073709551615) repeat('hello', -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select repeat('hello', 18446744073709551615); select repeat('hello', 18446744073709551615);
repeat('hello', 18446744073709551615) repeat('hello', 18446744073709551615)
NULL NULL
@ -2049,27 +2049,27 @@ select repeat('hello', -18446744073709551616);
repeat('hello', -18446744073709551616) repeat('hello', -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select repeat('hello', 18446744073709551616); select repeat('hello', 18446744073709551616);
repeat('hello', 18446744073709551616) repeat('hello', 18446744073709551616)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select repeat('hello', -18446744073709551617); select repeat('hello', -18446744073709551617);
repeat('hello', -18446744073709551617) repeat('hello', -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select repeat('hello', 18446744073709551617); select repeat('hello', 18446744073709551617);
repeat('hello', 18446744073709551617) repeat('hello', 18446744073709551617)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-1); select space(-1);
space(-1) space(-1)
@ -2102,8 +2102,8 @@ select space(-18446744073709551615);
space(-18446744073709551615) space(-18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select space(18446744073709551615); select space(18446744073709551615);
space(18446744073709551615) space(18446744073709551615)
NULL NULL
@ -2113,27 +2113,27 @@ select space(-18446744073709551616);
space(-18446744073709551616) space(-18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select space(18446744073709551616); select space(18446744073709551616);
space(18446744073709551616) space(18446744073709551616)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-18446744073709551617); select space(-18446744073709551617);
space(-18446744073709551617) space(-18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select space(18446744073709551617); select space(18446744073709551617);
space(18446744073709551617) space(18446744073709551617)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -1, '1'); select rpad('hello', -1, '1');
rpad('hello', -1, '1') rpad('hello', -1, '1')
@ -2166,8 +2166,8 @@ select rpad('hello', -18446744073709551615, '1');
rpad('hello', -18446744073709551615, '1') rpad('hello', -18446744073709551615, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select rpad('hello', 18446744073709551615, '1'); select rpad('hello', 18446744073709551615, '1');
rpad('hello', 18446744073709551615, '1') rpad('hello', 18446744073709551615, '1')
NULL NULL
@ -2177,27 +2177,27 @@ select rpad('hello', -18446744073709551616, '1');
rpad('hello', -18446744073709551616, '1') rpad('hello', -18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select rpad('hello', 18446744073709551616, '1'); select rpad('hello', 18446744073709551616, '1');
rpad('hello', 18446744073709551616, '1') rpad('hello', 18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551617, '1'); select rpad('hello', -18446744073709551617, '1');
rpad('hello', -18446744073709551617, '1') rpad('hello', -18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select rpad('hello', 18446744073709551617, '1'); select rpad('hello', 18446744073709551617, '1');
rpad('hello', 18446744073709551617, '1') rpad('hello', 18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -1, '1'); select lpad('hello', -1, '1');
lpad('hello', -1, '1') lpad('hello', -1, '1')
@ -2230,8 +2230,8 @@ select lpad('hello', -18446744073709551615, '1');
lpad('hello', -18446744073709551615, '1') lpad('hello', -18446744073709551615, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select lpad('hello', 18446744073709551615, '1'); select lpad('hello', 18446744073709551615, '1');
lpad('hello', 18446744073709551615, '1') lpad('hello', 18446744073709551615, '1')
NULL NULL
@ -2241,27 +2241,27 @@ select lpad('hello', -18446744073709551616, '1');
lpad('hello', -18446744073709551616, '1') lpad('hello', -18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select lpad('hello', 18446744073709551616, '1'); select lpad('hello', 18446744073709551616, '1');
lpad('hello', 18446744073709551616, '1') lpad('hello', 18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551617, '1'); select lpad('hello', -18446744073709551617, '1');
lpad('hello', -18446744073709551617, '1') lpad('hello', -18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select lpad('hello', 18446744073709551617, '1'); select lpad('hello', 18446744073709551617, '1');
lpad('hello', 18446744073709551617, '1') lpad('hello', 18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
SET @orig_sql_mode = @@SQL_MODE; SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional; SET SQL_MODE=traditional;

View file

@ -1014,6 +1014,7 @@ SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
MAKETIME(CAST(-1 AS UNSIGNED), 0, 0) MAKETIME(CAST(-1 AS UNSIGNED), 0, 0)
838:59:59 838:59:59
Warnings: Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect time value: '18446744073709551615:00:00' Warning 1292 Truncated incorrect time value: '18446744073709551615:00:00'
SELECT EXTRACT(HOUR FROM '100000:02:03'); SELECT EXTRACT(HOUR FROM '100000:02:03');
EXTRACT(HOUR FROM '100000:02:03') EXTRACT(HOUR FROM '100000:02:03')
@ -1033,6 +1034,7 @@ SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
SEC_TO_TIME(CAST(-1 AS UNSIGNED)) SEC_TO_TIME(CAST(-1 AS UNSIGNED))
838:59:59 838:59:59
Warnings: Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect time value: '18446744073709551615' Warning 1292 Truncated incorrect time value: '18446744073709551615'
SET NAMES latin1; SET NAMES latin1;
SET character_set_results = NULL; SET character_set_results = NULL;

View file

@ -380,7 +380,7 @@ ERROR 22003: Out of range value for column 'sp_vars_check_ret1()' at row 1
SELECT sp_vars_check_ret2(); SELECT sp_vars_check_ret2();
ERROR 22003: Out of range value for column 'sp_vars_check_ret2()' at row 1 ERROR 22003: Out of range value for column 'sp_vars_check_ret2()' at row 1
SELECT sp_vars_check_ret3(); SELECT sp_vars_check_ret3();
ERROR HY000: Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1 ERROR 22007: Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1
SELECT sp_vars_check_ret4(); SELECT sp_vars_check_ret4();
sp_vars_check_ret4() sp_vars_check_ret4()
154.12 154.12

View file

@ -260,24 +260,24 @@ INSERT INTO t1 (col2) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE)); INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE)); INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE));
ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 ERROR 22007: Incorrect datetime value: '2004-10-0'
INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE)); INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 ERROR 22007: Incorrect datetime value: '2004-0-10'
INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE)); INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
ERROR 22007: Incorrect datetime value: '0000-00-00' ERROR 22007: Incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 ERROR 22007: Incorrect datetime value: '2004-10-0 15:30'
INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' at row 1 ERROR 22007: Incorrect datetime value: '2004-0-10 15:30'
INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME)); INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME));
ERROR 22007: Incorrect datetime value: '0000-00-00' ERROR 22007: Incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 ERROR 22007: Incorrect datetime value: '2004-10-0 15:30'
INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col3' at row 1 ERROR 22007: Incorrect datetime value: '2004-0-10 15:30'
INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME)); INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME));
ERROR 22007: Incorrect datetime value: '0000-00-00' ERROR 22007: Incorrect datetime value: '0000-00-00'
drop table t1; drop table t1;
@ -287,24 +287,26 @@ INSERT INTO t1 (col2) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE)); INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE)); INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 ERROR 22007: Incorrect datetime value: '2004-10-0'
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE)); INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 ERROR 22007: Incorrect datetime value: '2004-0-10'
INSERT INTO t1 (col1) VALUES('2004-0-10');
ERROR 22007: Incorrect date value: '2004-0-10' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE)); INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
ERROR 22007: Incorrect datetime value: '0000-00-00' ERROR 22007: Incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 ERROR 22007: Incorrect datetime value: '2004-10-0 15:30'
INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' at row 1 ERROR 22007: Incorrect datetime value: '2004-0-10 15:30'
INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME)); INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));
ERROR 22007: Incorrect datetime value: '0000-00-00' ERROR 22007: Incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 ERROR 22007: Incorrect datetime value: '2004-10-0 15:30'
INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col3' at row 1 ERROR 22007: Incorrect datetime value: '2004-0-10 15:30'
INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME)); INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME));
ERROR 22007: Incorrect datetime value: '0000-00-00' ERROR 22007: Incorrect datetime value: '0000-00-00'
drop table t1; drop table t1;
@ -364,9 +366,9 @@ Warnings:
Error 1365 Division by 0 Error 1365 Division by 0
Error 1365 Division by 0 Error 1365 Division by 0
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1 ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@ -447,9 +449,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0 ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1 ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@ -531,9 +533,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0 ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1 ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@ -615,9 +617,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0 ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1 ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@ -697,9 +699,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0 ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1 ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@ -776,7 +778,7 @@ ERROR 22003: Out of range value for column 'col1' at row 1
INSERT INTO t1 VALUES ('-100E+1'); INSERT INTO t1 VALUES ('-100E+1');
ERROR 22003: Out of range value for column 'col1' at row 1 ERROR 22003: Out of range value for column 'col1' at row 1
INSERT INTO t1 VALUES ('-100E'); INSERT INTO t1 VALUES ('-100E');
ERROR HY000: Incorrect decimal value: '-100E' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: '-100E' for column 'col1' at row 1
UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11; UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
ERROR 22003: Out of range value for column 'col1' at row 6 ERROR 22003: Out of range value for column 'col1' at row 6
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0; UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
@ -784,11 +786,11 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0 ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect decimal value: '' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
ERROR HY000: Incorrect decimal value: '1a' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: '1a' for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
Warnings: Warnings:
Note 1265 Data truncated for column 'col1' at row 1 Note 1265 Data truncated for column 'col1' at row 1
@ -1361,34 +1363,34 @@ col5 mediumint, col6 mediumint unsigned,
col7 int, col8 int unsigned, col7 int, col8 int unsigned,
col9 bigint, col10 bigint unsigned); col9 bigint, col10 bigint unsigned);
insert into t1(col1) values('-'); insert into t1(col1) values('-');
ERROR HY000: Incorrect integer value: '-' for column 'col1' at row 1 ERROR 22007: Incorrect integer value: '-' for column 'col1' at row 1
insert into t1(col2) values('+'); insert into t1(col2) values('+');
ERROR HY000: Incorrect integer value: '+' for column 'col2' at row 1 ERROR 22007: Incorrect integer value: '+' for column 'col2' at row 1
insert into t1(col3) values('-'); insert into t1(col3) values('-');
ERROR HY000: Incorrect integer value: '-' for column 'col3' at row 1 ERROR 22007: Incorrect integer value: '-' for column 'col3' at row 1
insert into t1(col4) values('+'); insert into t1(col4) values('+');
ERROR HY000: Incorrect integer value: '+' for column 'col4' at row 1 ERROR 22007: Incorrect integer value: '+' for column 'col4' at row 1
insert into t1(col5) values('-'); insert into t1(col5) values('-');
ERROR HY000: Incorrect integer value: '-' for column 'col5' at row 1 ERROR 22007: Incorrect integer value: '-' for column 'col5' at row 1
insert into t1(col6) values('+'); insert into t1(col6) values('+');
ERROR HY000: Incorrect integer value: '+' for column 'col6' at row 1 ERROR 22007: Incorrect integer value: '+' for column 'col6' at row 1
insert into t1(col7) values('-'); insert into t1(col7) values('-');
ERROR HY000: Incorrect integer value: '-' for column 'col7' at row 1 ERROR 22007: Incorrect integer value: '-' for column 'col7' at row 1
insert into t1(col8) values('+'); insert into t1(col8) values('+');
ERROR HY000: Incorrect integer value: '+' for column 'col8' at row 1 ERROR 22007: Incorrect integer value: '+' for column 'col8' at row 1
insert into t1(col9) values('-'); insert into t1(col9) values('-');
ERROR HY000: Incorrect integer value: '-' for column 'col9' at row 1 ERROR 22007: Incorrect integer value: '-' for column 'col9' at row 1
insert into t1(col10) values('+'); insert into t1(col10) values('+');
ERROR HY000: Incorrect integer value: '+' for column 'col10' at row 1 ERROR 22007: Incorrect integer value: '+' for column 'col10' at row 1
drop table t1; drop table t1;
set sql_mode='traditional'; set sql_mode='traditional';
create table t1(a year); create table t1(a year);
insert into t1 values ('-'); insert into t1 values ('-');
ERROR HY000: Incorrect integer value: '-' for column 'a' at row 1 ERROR 22007: Incorrect integer value: '-' for column 'a' at row 1
insert into t1 values ('+'); insert into t1 values ('+');
ERROR HY000: Incorrect integer value: '+' for column 'a' at row 1 ERROR 22007: Incorrect integer value: '+' for column 'a' at row 1
insert into t1 values (''); insert into t1 values ('');
ERROR HY000: Incorrect integer value: '' for column 'a' at row 1 ERROR 22007: Incorrect integer value: '' for column 'a' at row 1
insert into t1 values ('2000a'); insert into t1 values ('2000a');
ERROR 01000: Data truncated for column 'a' at row 1 ERROR 01000: Data truncated for column 'a' at row 1
insert into t1 values ('2E3x'); insert into t1 values ('2E3x');

View file

@ -825,7 +825,7 @@ Error 1365 Division by 0
Error 1365 Division by 0 Error 1365 Division by 0
Error 1365 Division by 0 Error 1365 Division by 0
INSERT INTO Sow6_2f VALUES ('a59b'); INSERT INTO Sow6_2f VALUES ('a59b');
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f; drop table Sow6_2f;
select 10.3330000000000/12.34500000; select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000 10.3330000000000/12.34500000
@ -838,12 +838,12 @@ select 9999999999999999999999999999999999999999999999999999999999999999999999999
x x
99999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999999999999999999
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x; select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
x x
100000000000000000000000000000000000000000000000000000000000000000 100000000000000000000000000000000000000000000000000000000000000000
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
select 0.190287977636363637 + 0.040372670 * 0 - 0; select 0.190287977636363637 + 0.040372670 * 0 - 0;
0.190287977636363637 + 0.040372670 * 0 - 0 0.190287977636363637 + 0.040372670 * 0 - 0
0.190287977636363637 0.190287977636363637
@ -1380,15 +1380,15 @@ create table t1 (c1 decimal(64));
insert into t1 values( insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); 89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1 Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values( insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1 Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(1e100); insert into t1 values(1e100);
Warnings: Warnings:
@ -1432,7 +1432,7 @@ select cast(19999999999999999999 as unsigned);
cast(19999999999999999999 as unsigned) cast(19999999999999999999 as unsigned)
18446744073709551615 18446744073709551615
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '19999999999999999999' to UNSIGNED INT. Value truncated.
create table t1(a decimal(18)); create table t1(a decimal(18));
insert into t1 values(123456789012345678); insert into t1 values(123456789012345678);
alter table t1 modify column a decimal(19); alter table t1 modify column a decimal(19);
@ -1674,7 +1674,7 @@ CREATE TABLE t1 SELECT
/* 82 */ 1000000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 82 */ 1000000000000000000000000000000000000000000000000000000000000000000000000000000001
AS c1; AS c1;
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
DESC t1; DESC t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
c1 decimal(65,0) NO 0 c1 decimal(65,0) NO 0

View file

@ -324,7 +324,7 @@ select CAST(a AS DECIMAL(13,5)) FROM (SELECT '' as a) t;
CAST(a AS DECIMAL(13,5)) CAST(a AS DECIMAL(13,5))
0.00000 0.00000
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
create table t1 (a integer unsigned); create table t1 (a integer unsigned);
insert into t1 values (1),(-1),(0),(-2); insert into t1 values (1),(-1),(0),(-2);

View file

@ -945,8 +945,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4 0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -960,8 +960,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4 0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -2450,6 +2450,8 @@ NULL NULL 1
8385959 838:59:59 3 8385959 838:59:59 3
130000 13:00:00 4 130000 13:00:00 4
100000 10:00:00 5 100000 10:00:00 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2462,6 +2464,8 @@ NULL NULL 1
8385959 838:59:59 3 8385959 838:59:59 3
130000 13:00:00 4 130000 13:00:00 4
100000 10:00:00 5 100000 10:00:00 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2556,7 +2560,9 @@ NULL NULL 1
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2571,7 +2577,9 @@ NULL NULL 1
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2587,9 +2595,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5 0 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2603,9 +2611,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5 0 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -2620,6 +2628,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3 9223372036854775807 9223372036854775807 3
0 0 4 0 0 4
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2632,6 +2643,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3 9223372036854775807 9223372036854775807 3
0 0 4 0 0 4
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2955,8 +2969,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5 -1 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2970,8 +2984,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5 -1 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -3282,9 +3296,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
@ -3300,9 +3314,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
DROP VIEW v1; DROP VIEW v1;
@ -3372,9 +3386,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 29 -3333.33 -3333.3333 29
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3389,9 +3403,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 29 -3333.33 -3333.3333 29
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1; DROP VIEW v1;
@ -3408,11 +3422,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 28 -3333.33 -3333.3333 28
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1' Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333' Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@ -3430,11 +3444,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 28 -3333.33 -3333.3333 28
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1' Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333' Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@ -3454,9 +3468,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 27 -3333.33 -3333.3333 27
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3471,9 +3485,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 27 -3333.33 -3333.3333 27
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1; DROP VIEW v1;
@ -3490,11 +3504,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 26 -3333.33 -3333.3333 26
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ' Warning 1292 Truncated incorrect DECIMAL value: ' '
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
@ -3510,11 +3524,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 26 -3333.33 -3333.3333 26
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ' Warning 1292 Truncated incorrect DECIMAL value: ' '
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
DROP VIEW v1; DROP VIEW v1;
@ -3908,8 +3922,8 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id; WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id CAST(my_time AS DATETIME) my_time id
NULL NULL 1 NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2 NULL -838:59:59 2
0000-00-00 00:00:00 838:59:59 3 NULL 838:59:59 3
0000-00-00 13:00:00 13:00:00 4 0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5 0000-00-00 10:00:00 10:00:00 5
Warnings: Warnings:
@ -3923,8 +3937,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id; WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id CAST(my_time AS DATETIME) my_time id
NULL NULL 1 NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2 NULL -838:59:59 2
0000-00-00 00:00:00 838:59:59 3 NULL 838:59:59 3
0000-00-00 13:00:00 13:00:00 4 0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5 0000-00-00 10:00:00 10:00:00 5
Warnings: Warnings:

View file

@ -946,8 +946,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4 0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -961,8 +961,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4 0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -2451,6 +2451,8 @@ NULL NULL 1
8385959 838:59:59 3 8385959 838:59:59 3
130000 13:00:00 4 130000 13:00:00 4
100000 10:00:00 5 100000 10:00:00 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2463,6 +2465,8 @@ NULL NULL 1
8385959 838:59:59 3 8385959 838:59:59 3
130000 13:00:00 4 130000 13:00:00 4
100000 10:00:00 5 100000 10:00:00 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2557,7 +2561,9 @@ NULL NULL 1
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2572,7 +2578,9 @@ NULL NULL 1
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2588,9 +2596,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5 0 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2604,9 +2612,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5 0 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -2621,6 +2629,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3 9223372036854775807 9223372036854775807 3
0 0 4 0 0 4
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2633,6 +2644,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3 9223372036854775807 9223372036854775807 3
0 0 4 0 0 4
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2956,8 +2970,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5 -1 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2971,8 +2985,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5 -1 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -3283,9 +3297,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
@ -3301,9 +3315,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
DROP VIEW v1; DROP VIEW v1;
@ -3373,9 +3387,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 29 -3333.33 -3333.3333 29
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3390,9 +3404,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 29 -3333.33 -3333.3333 29
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1; DROP VIEW v1;
@ -3409,11 +3423,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 28 -3333.33 -3333.3333 28
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1' Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333' Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@ -3431,11 +3445,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 28 -3333.33 -3333.3333 28
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1' Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333' Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@ -3455,9 +3469,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 27 -3333.33 -3333.3333 27
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3472,9 +3486,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 27 -3333.33 -3333.3333 27
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1; DROP VIEW v1;
@ -3491,11 +3505,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 26 -3333.33 -3333.3333 26
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ' Warning 1292 Truncated incorrect DECIMAL value: ' '
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
@ -3511,11 +3525,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 26 -3333.33 -3333.3333 26
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ' Warning 1292 Truncated incorrect DECIMAL value: ' '
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
DROP VIEW v1; DROP VIEW v1;
@ -3909,8 +3923,8 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id; WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id CAST(my_time AS DATETIME) my_time id
NULL NULL 1 NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2 NULL -838:59:59 2
0000-00-00 00:00:00 838:59:59 3 NULL 838:59:59 3
0000-00-00 13:00:00 13:00:00 4 0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5 0000-00-00 10:00:00 10:00:00 5
Warnings: Warnings:
@ -3924,8 +3938,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id; WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id CAST(my_time AS DATETIME) my_time id
NULL NULL 1 NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2 NULL -838:59:59 2
0000-00-00 00:00:00 838:59:59 3 NULL 838:59:59 3
0000-00-00 13:00:00 13:00:00 4 0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5 0000-00-00 10:00:00 10:00:00 5
Warnings: Warnings:

View file

@ -946,8 +946,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4 0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÃö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -961,8 +961,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4 0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -2451,6 +2451,8 @@ NULL NULL 1
8385959 838:59:59 3 8385959 838:59:59 3
130000 13:00:00 4 130000 13:00:00 4
100000 10:00:00 5 100000 10:00:00 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2463,6 +2465,8 @@ NULL NULL 1
8385959 838:59:59 3 8385959 838:59:59 3
130000 13:00:00 4 130000 13:00:00 4
100000 10:00:00 5 100000 10:00:00 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2557,7 +2561,9 @@ NULL NULL 1
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2572,7 +2578,9 @@ NULL NULL 1
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings: Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308' Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2588,9 +2596,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5 0 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2604,9 +2612,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5 0 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -2621,6 +2629,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3 9223372036854775807 9223372036854775807 3
0 0 4 0 0 4
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2633,6 +2644,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3 9223372036854775807 9223372036854775807 3
0 0 4 0 0 4
18446744073709551615 -1 5 18446744073709551615 -1 5
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1; DROP VIEW v1;
@ -2956,8 +2970,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5 -1 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -2971,8 +2985,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4 0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5 -1 -1.000000000000000000000000000000 5
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1; DROP VIEW v1;
@ -3283,9 +3297,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
@ -3301,9 +3315,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 30 -3333.33 -3333.3333 30
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1 Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
DROP VIEW v1; DROP VIEW v1;
@ -3373,9 +3387,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 29 -3333.33 -3333.3333 29
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3390,9 +3404,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 29 -3333.33 -3333.3333 29
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1; DROP VIEW v1;
@ -3409,11 +3423,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 28 -3333.33 -3333.3333 28
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1' Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333' Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@ -3431,11 +3445,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 28 -3333.33 -3333.3333 28
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '' Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1' Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333' Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@ -3455,9 +3469,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 27 -3333.33 -3333.3333 27
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3472,9 +3486,9 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 27 -3333.33 -3333.3333 27
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1; DROP VIEW v1;
@ -3491,11 +3505,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 26 -3333.33 -3333.3333 26
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ' Warning 1292 Truncated incorrect DECIMAL value: ' '
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
@ -3511,11 +3525,11 @@ NULL NULL 1
-1.00 -1 5 -1.00 -1 5
-3333.33 -3333.3333 26 -3333.33 -3333.3333 26
Warnings: Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ' Warning 1292 Truncated incorrect DECIMAL value: ' '
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->' Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
Error 1366 Incorrect decimal value: '' for column '' at row 0 Error 1657 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- ' Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
DROP VIEW v1; DROP VIEW v1;
@ -3909,8 +3923,8 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id; WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id CAST(my_time AS DATETIME) my_time id
NULL NULL 1 NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2 NULL -838:59:59 2
0000-00-00 00:00:00 838:59:59 3 NULL 838:59:59 3
0000-00-00 13:00:00 13:00:00 4 0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5 0000-00-00 10:00:00 10:00:00 5
Warnings: Warnings:
@ -3924,8 +3938,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id; WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id CAST(my_time AS DATETIME) my_time id
NULL NULL 1 NULL NULL 1
0000-00-00 00:00:00 -838:59:59 2 NULL -838:59:59 2
0000-00-00 00:00:00 838:59:59 3 NULL 838:59:59 3
0000-00-00 13:00:00 13:00:00 4 0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5 0000-00-00 10:00:00 10:00:00 5
Warnings: Warnings:

View file

@ -26,6 +26,7 @@ CREATE TABLE t3(
disable_query_log; disable_query_log;
begin;
let $1 = 100; let $1 = 100;
while ($1) while ($1)
{ {
@ -44,6 +45,7 @@ while ($1)
} }
dec $1; dec $1;
} }
commit;
enable_query_log; enable_query_log;

View file

@ -16,12 +16,14 @@
--echo --- Delete rows and partitions of tables with $sqlfunc --echo --- Delete rows and partitions of tables with $sqlfunc
--echo ------------------------------------------------------------------------- --echo -------------------------------------------------------------------------
begin;
eval delete from $t1 where col1=$val2; eval delete from $t1 where col1=$val2;
eval delete from $t2 where col1=$val2; eval delete from $t2 where col1=$val2;
eval delete from $t3 where col1=$val2; eval delete from $t3 where col1=$val2;
eval delete from $t4 where col1=$val2; eval delete from $t4 where col1=$val2;
eval delete from $t5 where col1=$val2; eval delete from $t5 where col1=$val2;
eval delete from $t6 where col1=$val2; eval delete from $t6 where col1=$val2;
commit;
eval select * from $t1 order by col1; eval select * from $t1 order by col1;
eval select * from $t2 order by col1; eval select * from $t2 order by col1;
@ -29,12 +31,14 @@ eval select * from $t3 order by col1;
eval select * from $t4 order by colint; eval select * from $t4 order by colint;
eval select * from $t5 order by colint; eval select * from $t5 order by colint;
begin;
eval insert into $t1 values ($val2); eval insert into $t1 values ($val2);
eval insert into $t2 values ($val2); eval insert into $t2 values ($val2);
eval insert into $t3 values ($val2); eval insert into $t3 values ($val2);
eval insert into $t4 values (60,$val2); eval insert into $t4 values (60,$val2);
eval insert into $t5 values (60,$val2); eval insert into $t5 values (60,$val2);
eval insert into $t6 values (60,$val2); eval insert into $t6 values (60,$val2);
commit;
eval select * from $t1 order by col1; eval select * from $t1 order by col1;
eval select * from $t2 order by col1; eval select * from $t2 order by col1;

View file

@ -113,6 +113,7 @@ $part_t6;
--echo --- Access tables with $sqlfunc --echo --- Access tables with $sqlfunc
--echo ------------------------------------------------------------------------- --echo -------------------------------------------------------------------------
begin;
eval insert into t1 values ($val1); eval insert into t1 values ($val1);
eval insert into t1 values ($val2); eval insert into t1 values ($val2);
@ -123,6 +124,7 @@ eval insert into t2 values ($val3);
eval insert into t3 values ($val1); eval insert into t3 values ($val1);
eval insert into t3 values ($val2); eval insert into t3 values ($val2);
eval insert into t3 values ($val3); eval insert into t3 values ($val3);
commit;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data infile '$MYSQLTEST_VARDIR/std_data/parts/$infile' into table t4; eval load data infile '$MYSQLTEST_VARDIR/std_data/parts/$infile' into table t4;
@ -142,12 +144,14 @@ select * from t6 order by colint;
if ($do_long_tests) if ($do_long_tests)
{ {
begin;
eval update t1 set col1=$val4 where col1=$val1; eval update t1 set col1=$val4 where col1=$val1;
eval update t2 set col1=$val4 where col1=$val1; eval update t2 set col1=$val4 where col1=$val1;
eval update t3 set col1=$val4 where col1=$val1; eval update t3 set col1=$val4 where col1=$val1;
eval update t4 set col1=$val4 where col1=$val1; eval update t4 set col1=$val4 where col1=$val1;
eval update t5 set col1=$val4 where col1=$val1; eval update t5 set col1=$val4 where col1=$val1;
eval update t6 set col1=$val4 where col1=$val1; eval update t6 set col1=$val4 where col1=$val1;
commit;
select * from t1 order by col1; select * from t1 order by col1;
select * from t2 order by col1; select * from t2 order by col1;

View file

@ -96,13 +96,19 @@ DELETE FROM t3 WHERE id = del_count;
SET del_count = del_count - 2; SET del_count = del_count - 2;
END WHILE; END WHILE;
END| END|
begin;
CALL p1(); CALL p1();
commit;
SELECT count(*) as "Master regular" FROM t1; SELECT count(*) as "Master regular" FROM t1;
Master regular 500 Master regular 500
begin;
CALL p2(); CALL p2();
commit;
SELECT count(*) as "Master bykey" FROM t2; SELECT count(*) as "Master bykey" FROM t2;
Master bykey 500 Master bykey 500
begin;
CALL p3(); CALL p3();
commit;
SELECT count(*) as "Master byrange" FROM t3; SELECT count(*) as "Master byrange" FROM t3;
Master byrange 500 Master byrange 500
show create table t3; show create table t3;

View file

@ -26,13 +26,11 @@ let $debug= 0;
let $do_long_tests= 1; let $do_long_tests= 1;
# #
# This test takes long time, so only run it with the --big mtr-flag.
--source include/big_test.inc --source include/big_test.inc
# The server must support partitioning. # The server must support partitioning.
--source include/have_partition.inc --source include/have_partition.inc
# This test takes long time, so only run it with the --big mtr-flag.
--source include/big_test.inc
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
# Engine specific settings and requirements # Engine specific settings and requirements

View file

@ -127,11 +127,17 @@ delimiter ;|
############ Test Section ################### ############ Test Section ###################
begin;
CALL p1(); CALL p1();
commit;
SELECT count(*) as "Master regular" FROM t1; SELECT count(*) as "Master regular" FROM t1;
begin;
CALL p2(); CALL p2();
commit;
SELECT count(*) as "Master bykey" FROM t2; SELECT count(*) as "Master bykey" FROM t2;
begin;
CALL p3(); CALL p3();
commit;
SELECT count(*) as "Master byrange" FROM t3; SELECT count(*) as "Master byrange" FROM t3;
--sync_slave_with_master --sync_slave_with_master

View file

@ -1,9 +1,13 @@
select CAST(1-2 AS UNSIGNED); select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED) CAST(1-2 AS UNSIGNED)
18446744073709551615 18446744073709551615
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER); select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER) CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1 -1
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST('10 ' as unsigned integer); select CAST('10 ' as unsigned integer);
CAST('10 ' as unsigned integer) CAST('10 ' as unsigned integer)
10 10
@ -12,9 +16,15 @@ Warning 1292 Truncated incorrect INTEGER value: '10 '
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1 cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
18446744073709551611 18446744073709551611 18446744073709551611 18446744073709551611
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1; select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1 cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
18446744073709551610 18446744073709551612 18446744073709551610 18446744073709551612
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select ~5, cast(~5 as signed); select ~5, cast(~5 as signed);
~5 cast(~5 as signed) ~5 cast(~5 as signed)
18446744073709551610 -6 18446744073709551610 -6

View file

@ -1504,7 +1504,7 @@ select locate('lo','hello',-18446744073709551615);
locate('lo','hello',-18446744073709551615) locate('lo','hello',-18446744073709551615)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select locate('lo','hello',18446744073709551615); select locate('lo','hello',18446744073709551615);
locate('lo','hello',18446744073709551615) locate('lo','hello',18446744073709551615)
0 0
@ -1512,22 +1512,22 @@ select locate('lo','hello',-18446744073709551616);
locate('lo','hello',-18446744073709551616) locate('lo','hello',-18446744073709551616)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select locate('lo','hello',18446744073709551616); select locate('lo','hello',18446744073709551616);
locate('lo','hello',18446744073709551616) locate('lo','hello',18446744073709551616)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select locate('lo','hello',-18446744073709551617); select locate('lo','hello',-18446744073709551617);
locate('lo','hello',-18446744073709551617) locate('lo','hello',-18446744073709551617)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select locate('lo','hello',18446744073709551617); select locate('lo','hello',18446744073709551617);
locate('lo','hello',18446744073709551617) locate('lo','hello',18446744073709551617)
0 0
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select left('hello', 10); select left('hello', 10);
left('hello', 10) left('hello', 10)
hello hello
@ -1559,8 +1559,8 @@ select left('hello', -18446744073709551615);
left('hello', -18446744073709551615) left('hello', -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select left('hello', 18446744073709551615); select left('hello', 18446744073709551615);
left('hello', 18446744073709551615) left('hello', 18446744073709551615)
hello hello
@ -1568,26 +1568,26 @@ select left('hello', -18446744073709551616);
left('hello', -18446744073709551616) left('hello', -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select left('hello', 18446744073709551616); select left('hello', 18446744073709551616);
left('hello', 18446744073709551616) left('hello', 18446744073709551616)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select left('hello', -18446744073709551617); select left('hello', -18446744073709551617);
left('hello', -18446744073709551617) left('hello', -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select left('hello', 18446744073709551617); select left('hello', 18446744073709551617);
left('hello', 18446744073709551617) left('hello', 18446744073709551617)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select right('hello', 10); select right('hello', 10);
right('hello', 10) right('hello', 10)
hello hello
@ -1619,8 +1619,8 @@ select right('hello', -18446744073709551615);
right('hello', -18446744073709551615) right('hello', -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select right('hello', 18446744073709551615); select right('hello', 18446744073709551615);
right('hello', 18446744073709551615) right('hello', 18446744073709551615)
hello hello
@ -1628,26 +1628,26 @@ select right('hello', -18446744073709551616);
right('hello', -18446744073709551616) right('hello', -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select right('hello', 18446744073709551616); select right('hello', 18446744073709551616);
right('hello', 18446744073709551616) right('hello', 18446744073709551616)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select right('hello', -18446744073709551617); select right('hello', -18446744073709551617);
right('hello', -18446744073709551617) right('hello', -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select right('hello', 18446744073709551617); select right('hello', 18446744073709551617);
right('hello', 18446744073709551617) right('hello', 18446744073709551617)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 2, -1); select substring('hello', 2, -1);
substring('hello', 2, -1) substring('hello', 2, -1)
@ -1679,8 +1679,8 @@ select substring('hello', -18446744073709551615, 1);
substring('hello', -18446744073709551615, 1) substring('hello', -18446744073709551615, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 1); select substring('hello', 18446744073709551615, 1);
substring('hello', 18446744073709551615, 1) substring('hello', 18446744073709551615, 1)
@ -1688,26 +1688,26 @@ select substring('hello', -18446744073709551616, 1);
substring('hello', -18446744073709551616, 1) substring('hello', -18446744073709551616, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 1); select substring('hello', 18446744073709551616, 1);
substring('hello', 18446744073709551616, 1) substring('hello', 18446744073709551616, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, 1); select substring('hello', -18446744073709551617, 1);
substring('hello', -18446744073709551617, 1) substring('hello', -18446744073709551617, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 1); select substring('hello', 18446744073709551617, 1);
substring('hello', 18446744073709551617, 1) substring('hello', 18446744073709551617, 1)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 1, -1); select substring('hello', 1, -1);
substring('hello', 1, -1) substring('hello', 1, -1)
@ -1733,8 +1733,8 @@ select substring('hello', 1, -18446744073709551615);
substring('hello', 1, -18446744073709551615) substring('hello', 1, -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 1, 18446744073709551615); select substring('hello', 1, 18446744073709551615);
substring('hello', 1, 18446744073709551615) substring('hello', 1, 18446744073709551615)
hello hello
@ -1742,26 +1742,26 @@ select substring('hello', 1, -18446744073709551616);
substring('hello', 1, -18446744073709551616) substring('hello', 1, -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 1, 18446744073709551616); select substring('hello', 1, 18446744073709551616);
substring('hello', 1, 18446744073709551616) substring('hello', 1, 18446744073709551616)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', 1, -18446744073709551617); select substring('hello', 1, -18446744073709551617);
substring('hello', 1, -18446744073709551617) substring('hello', 1, -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 1, 18446744073709551617); select substring('hello', 1, 18446744073709551617);
substring('hello', 1, 18446744073709551617) substring('hello', 1, 18446744073709551617)
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', -1, -1); select substring('hello', -1, -1);
substring('hello', -1, -1) substring('hello', -1, -1)
@ -1787,10 +1787,10 @@ select substring('hello', -18446744073709551615, -18446744073709551615);
substring('hello', -18446744073709551615, -18446744073709551615) substring('hello', -18446744073709551615, -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 18446744073709551615); select substring('hello', 18446744073709551615, 18446744073709551615);
substring('hello', 18446744073709551615, 18446744073709551615) substring('hello', 18446744073709551615, 18446744073709551615)
@ -1798,34 +1798,34 @@ select substring('hello', -18446744073709551616, -18446744073709551616);
substring('hello', -18446744073709551616, -18446744073709551616) substring('hello', -18446744073709551616, -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 18446744073709551616); select substring('hello', 18446744073709551616, 18446744073709551616);
substring('hello', 18446744073709551616, 18446744073709551616) substring('hello', 18446744073709551616, 18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, -18446744073709551617); select substring('hello', -18446744073709551617, -18446744073709551617);
substring('hello', -18446744073709551617, -18446744073709551617) substring('hello', -18446744073709551617, -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 18446744073709551617); select substring('hello', 18446744073709551617, 18446744073709551617);
substring('hello', 18446744073709551617, 18446744073709551617) substring('hello', 18446744073709551617, 18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, 1, 'hi'); select insert('hello', -1, 1, 'hi');
insert('hello', -1, 1, 'hi') insert('hello', -1, 1, 'hi')
hello hello
@ -1851,7 +1851,7 @@ select insert('hello', -18446744073709551615, 1, 'hi');
insert('hello', -18446744073709551615, 1, 'hi') insert('hello', -18446744073709551615, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 1, 'hi'); select insert('hello', 18446744073709551615, 1, 'hi');
insert('hello', 18446744073709551615, 1, 'hi') insert('hello', 18446744073709551615, 1, 'hi')
hello hello
@ -1859,22 +1859,22 @@ select insert('hello', -18446744073709551616, 1, 'hi');
insert('hello', -18446744073709551616, 1, 'hi') insert('hello', -18446744073709551616, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 1, 'hi'); select insert('hello', 18446744073709551616, 1, 'hi');
insert('hello', 18446744073709551616, 1, 'hi') insert('hello', 18446744073709551616, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, 1, 'hi'); select insert('hello', -18446744073709551617, 1, 'hi');
insert('hello', -18446744073709551617, 1, 'hi') insert('hello', -18446744073709551617, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 1, 'hi'); select insert('hello', 18446744073709551617, 1, 'hi');
insert('hello', 18446744073709551617, 1, 'hi') insert('hello', 18446744073709551617, 1, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', 1, -1, 'hi'); select insert('hello', 1, -1, 'hi');
insert('hello', 1, -1, 'hi') insert('hello', 1, -1, 'hi')
hi hi
@ -1900,7 +1900,7 @@ select insert('hello', 1, -18446744073709551615, 'hi');
insert('hello', 1, -18446744073709551615, 'hi') insert('hello', 1, -18446744073709551615, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 1, 18446744073709551615, 'hi'); select insert('hello', 1, 18446744073709551615, 'hi');
insert('hello', 1, 18446744073709551615, 'hi') insert('hello', 1, 18446744073709551615, 'hi')
hi hi
@ -1908,22 +1908,22 @@ select insert('hello', 1, -18446744073709551616, 'hi');
insert('hello', 1, -18446744073709551616, 'hi') insert('hello', 1, -18446744073709551616, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 1, 18446744073709551616, 'hi'); select insert('hello', 1, 18446744073709551616, 'hi');
insert('hello', 1, 18446744073709551616, 'hi') insert('hello', 1, 18446744073709551616, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', 1, -18446744073709551617, 'hi'); select insert('hello', 1, -18446744073709551617, 'hi');
insert('hello', 1, -18446744073709551617, 'hi') insert('hello', 1, -18446744073709551617, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 1, 18446744073709551617, 'hi'); select insert('hello', 1, 18446744073709551617, 'hi');
insert('hello', 1, 18446744073709551617, 'hi') insert('hello', 1, 18446744073709551617, 'hi')
hi hi
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, -1, 'hi'); select insert('hello', -1, -1, 'hi');
insert('hello', -1, -1, 'hi') insert('hello', -1, -1, 'hi')
hello hello
@ -1949,8 +1949,8 @@ select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
insert('hello', -18446744073709551615, -18446744073709551615, 'hi') insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi'); select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
insert('hello', 18446744073709551615, 18446744073709551615, 'hi') insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
hello hello
@ -1958,26 +1958,26 @@ select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
insert('hello', -18446744073709551616, -18446744073709551616, 'hi') insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi'); select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
insert('hello', 18446744073709551616, 18446744073709551616, 'hi') insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi'); select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
insert('hello', -18446744073709551617, -18446744073709551617, 'hi') insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi'); select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
insert('hello', 18446744073709551617, 18446744073709551617, 'hi') insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
hello hello
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select repeat('hello', -1); select repeat('hello', -1);
repeat('hello', -1) repeat('hello', -1)
@ -2009,8 +2009,8 @@ select repeat('hello', -18446744073709551615);
repeat('hello', -18446744073709551615) repeat('hello', -18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select repeat('hello', 18446744073709551615); select repeat('hello', 18446744073709551615);
repeat('hello', 18446744073709551615) repeat('hello', 18446744073709551615)
NULL NULL
@ -2020,27 +2020,27 @@ select repeat('hello', -18446744073709551616);
repeat('hello', -18446744073709551616) repeat('hello', -18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select repeat('hello', 18446744073709551616); select repeat('hello', 18446744073709551616);
repeat('hello', 18446744073709551616) repeat('hello', 18446744073709551616)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select repeat('hello', -18446744073709551617); select repeat('hello', -18446744073709551617);
repeat('hello', -18446744073709551617) repeat('hello', -18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select repeat('hello', 18446744073709551617); select repeat('hello', 18446744073709551617);
repeat('hello', 18446744073709551617) repeat('hello', 18446744073709551617)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-1); select space(-1);
space(-1) space(-1)
@ -2073,8 +2073,8 @@ select space(-18446744073709551615);
space(-18446744073709551615) space(-18446744073709551615)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select space(18446744073709551615); select space(18446744073709551615);
space(18446744073709551615) space(18446744073709551615)
NULL NULL
@ -2084,27 +2084,27 @@ select space(-18446744073709551616);
space(-18446744073709551616) space(-18446744073709551616)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select space(18446744073709551616); select space(18446744073709551616);
space(18446744073709551616) space(18446744073709551616)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-18446744073709551617); select space(-18446744073709551617);
space(-18446744073709551617) space(-18446744073709551617)
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select space(18446744073709551617); select space(18446744073709551617);
space(18446744073709551617) space(18446744073709551617)
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -1, '1'); select rpad('hello', -1, '1');
rpad('hello', -1, '1') rpad('hello', -1, '1')
@ -2137,8 +2137,8 @@ select rpad('hello', -18446744073709551615, '1');
rpad('hello', -18446744073709551615, '1') rpad('hello', -18446744073709551615, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select rpad('hello', 18446744073709551615, '1'); select rpad('hello', 18446744073709551615, '1');
rpad('hello', 18446744073709551615, '1') rpad('hello', 18446744073709551615, '1')
NULL NULL
@ -2148,27 +2148,27 @@ select rpad('hello', -18446744073709551616, '1');
rpad('hello', -18446744073709551616, '1') rpad('hello', -18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select rpad('hello', 18446744073709551616, '1'); select rpad('hello', 18446744073709551616, '1');
rpad('hello', 18446744073709551616, '1') rpad('hello', 18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551617, '1'); select rpad('hello', -18446744073709551617, '1');
rpad('hello', -18446744073709551617, '1') rpad('hello', -18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select rpad('hello', 18446744073709551617, '1'); select rpad('hello', 18446744073709551617, '1');
rpad('hello', 18446744073709551617, '1') rpad('hello', 18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -1, '1'); select lpad('hello', -1, '1');
lpad('hello', -1, '1') lpad('hello', -1, '1')
@ -2201,8 +2201,8 @@ select lpad('hello', -18446744073709551615, '1');
lpad('hello', -18446744073709551615, '1') lpad('hello', -18446744073709551615, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select lpad('hello', 18446744073709551615, '1'); select lpad('hello', 18446744073709551615, '1');
lpad('hello', 18446744073709551615, '1') lpad('hello', 18446744073709551615, '1')
NULL NULL
@ -2212,27 +2212,27 @@ select lpad('hello', -18446744073709551616, '1');
lpad('hello', -18446744073709551616, '1') lpad('hello', -18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select lpad('hello', 18446744073709551616, '1'); select lpad('hello', 18446744073709551616, '1');
lpad('hello', 18446744073709551616, '1') lpad('hello', 18446744073709551616, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551617, '1'); select lpad('hello', -18446744073709551617, '1');
lpad('hello', -18446744073709551617, '1') lpad('hello', -18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select lpad('hello', 18446744073709551617, '1'); select lpad('hello', 18446744073709551617, '1');
lpad('hello', 18446744073709551617, '1') lpad('hello', 18446744073709551617, '1')
NULL NULL
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
SET @orig_sql_mode = @@SQL_MODE; SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional; SET SQL_MODE=traditional;

View file

@ -825,7 +825,7 @@ Error 1365 Division by 0
Error 1365 Division by 0 Error 1365 Division by 0
Error 1365 Division by 0 Error 1365 Division by 0
INSERT INTO Sow6_2f VALUES ('a59b'); INSERT INTO Sow6_2f VALUES ('a59b');
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f; drop table Sow6_2f;
select 10.3330000000000/12.34500000; select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000 10.3330000000000/12.34500000
@ -838,12 +838,12 @@ select 9999999999999999999999999999999999999999999999999999999999999999999999999
x x
99999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999999999999999999
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x; select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
x x
100000000000000000000000000000000000000000000000000000000000000000 100000000000000000000000000000000000000000000000000000000000000000
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
select 0.190287977636363637 + 0.040372670 * 0 - 0; select 0.190287977636363637 + 0.040372670 * 0 - 0;
0.190287977636363637 + 0.040372670 * 0 - 0 0.190287977636363637 + 0.040372670 * 0 - 0
0.190287977636363637 0.190287977636363637
@ -1368,15 +1368,15 @@ create table t1 (c1 decimal(64));
insert into t1 values( insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); 89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1 Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values( insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1 Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(1e100); insert into t1 values(1e100);
Warnings: Warnings:
@ -1447,4 +1447,4 @@ select cast(19999999999999999999 as unsigned);
cast(19999999999999999999 as unsigned) cast(19999999999999999999 as unsigned)
18446744073709551615 18446744073709551615
Warnings: Warnings:
Error 1292 Truncated incorrect DECIMAL value: '' Error 1655 Got overflow when converting '19999999999999999999' to UNSIGNED INT. Value truncated.

View file

@ -90,13 +90,19 @@ DELETE FROM test.byrange_tbl WHERE id = del_count;
SET del_count = del_count - 2; SET del_count = del_count - 2;
END WHILE; END WHILE;
END| END|
begin;
CALL test.proc_norm(); CALL test.proc_norm();
commit;
SELECT count(*) as "Master regular" FROM test.regular_tbl; SELECT count(*) as "Master regular" FROM test.regular_tbl;
Master regular 500 Master regular 500
begin;
CALL test.proc_bykey(); CALL test.proc_bykey();
commit;
SELECT count(*) as "Master bykey" FROM test.bykey_tbl; SELECT count(*) as "Master bykey" FROM test.bykey_tbl;
Master bykey 500 Master bykey 500
begin;
CALL test.proc_byrange(); CALL test.proc_byrange();
commit;
SELECT count(*) as "Master byrange" FROM test.byrange_tbl; SELECT count(*) as "Master byrange" FROM test.byrange_tbl;
Master byrange 500 Master byrange 500
show create table test.byrange_tbl; show create table test.byrange_tbl;

View file

@ -127,11 +127,17 @@ delimiter ;|
############ Test Section ################### ############ Test Section ###################
begin;
CALL test.proc_norm(); CALL test.proc_norm();
commit;
SELECT count(*) as "Master regular" FROM test.regular_tbl; SELECT count(*) as "Master regular" FROM test.regular_tbl;
begin;
CALL test.proc_bykey(); CALL test.proc_bykey();
commit;
SELECT count(*) as "Master bykey" FROM test.bykey_tbl; SELECT count(*) as "Master bykey" FROM test.bykey_tbl;
begin;
CALL test.proc_byrange(); CALL test.proc_byrange();
commit;
SELECT count(*) as "Master byrange" FROM test.byrange_tbl; SELECT count(*) as "Master byrange" FROM test.byrange_tbl;
--sync_slave_with_master --sync_slave_with_master

View file

@ -2686,10 +2686,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t1 values (-1,default); insert into t1 values (-1,default);
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1; select * from t1;
a b a b
1 1 1 1
-1 18446744073709551615 -1 18446744073709551615
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1; drop table t1;
set sql_warnings = 0; set sql_warnings = 0;
# Convert() # Convert()
@ -2703,10 +2708,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t1 values (-1,default); insert into t1 values (-1,default);
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1; select * from t1;
a b a b
1 1 1 1
-1 18446744073709551615 -1 18446744073709551615
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1; drop table t1;
set sql_warnings = 0; set sql_warnings = 0;
# #

View file

@ -2686,10 +2686,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t1 values (-1,default); insert into t1 values (-1,default);
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1; select * from t1;
a b a b
1 1 1 1
-1 18446744073709551615 -1 18446744073709551615
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1; drop table t1;
set sql_warnings = 0; set sql_warnings = 0;
# Convert() # Convert()
@ -2703,10 +2708,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t1 values (-1,default); insert into t1 values (-1,default);
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1; select * from t1;
a b a b
1 1 1 1
-1 18446744073709551615 -1 18446744073709551615
Warnings:
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1; drop table t1;
set sql_warnings = 0; set sql_warnings = 0;
# #

View file

@ -11,6 +11,21 @@ select ~5, cast(~5 as signed);
explain extended select ~5, cast(~5 as signed); explain extended select ~5, cast(~5 as signed);
select cast(5 as unsigned) -6.0; select cast(5 as unsigned) -6.0;
select cast(NULL as signed), cast(1/0 as signed); select cast(NULL as signed), cast(1/0 as signed);
select cast(1 as double(5,2));
select cast("5.2222" as double(5,2));
select cast(12.444 as double(5,2));
select cast(cast(12.444 as decimal(10,3)) as double(5,2));
select cast(null as double(5,2));
select cast(12.444 as double);
select cast(cast("20:01:01" as time) as datetime);
select cast(cast("8:46:06.23434" AS time) as decimal(32,10));
select cast(cast(20010203101112.121314 as double) as datetime);
select cast(cast(010203101112.12 as double) as datetime);
select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime);
select cast(20010203101112.121314 as datetime);
select cast(110203101112.121314 as datetime);
select cast(cast(010203101112.12 as double) as datetime);
select cast(cast("2011-04-05 8:46:06.23434" AS datetime) as time);
# #
# Bug #28250: Run-Time Check Failure #3 - The variable 'value' is being used # Bug #28250: Run-Time Check Failure #3 - The variable 'value' is being used
# without being def # without being def
@ -42,6 +57,44 @@ select cast('a10' as unsigned integer);
select 10+'a'; select 10+'a';
select 10.0+cast('a' as decimal); select 10.0+cast('a' as decimal);
select 10E+0+'a'; select 10E+0+'a';
select cast("a" as double(5,2));
select cast(1000 as decimal(5,2));
select cast(-1000 as decimal(5,2));
select cast(1000 as double(5,2));
select cast(-1000 as double(5,2));
select cast(010203101112.121314 as datetime);
select cast(120010203101112.121314 as datetime);
select cast(cast(1.1 as decimal) as datetime);
select cast(cast(-1.1 as decimal) as datetime);
select cast('0' as date);
select cast('' as date);
select cast('0' as datetime);
select cast('' as datetime);
select cast('0' as time);
select cast('' as time);
select cast(NULL as DATE);
select cast(NULL as DATETIME);
select cast(NULL as TIME);
select cast(NULL as BINARY);
#
# We have to disable warnings for these as the printed double value is
# not portable
#
--disable_warnings
select cast(cast(120010203101112.121314 as double) as datetime);
select cast(cast(1.1 as double) as datetime);
select cast(cast(-1.1 as double) as datetime);
--enable_warnings
#
# Some EXPLAIN EXTENDED to ensure the print functions are correct
#
explain extended select cast(10 as double(5,2));
explain extended select cast(10 as double);
explain extended select cast(10 as decimal(5,2));
# out-of-range cases # out-of-range cases
select cast('18446744073709551616' as unsigned); select cast('18446744073709551616' as unsigned);
@ -52,6 +105,20 @@ select cast('abc' as signed);
select cast('1a' as signed); select cast('1a' as signed);
select cast('' as signed); select cast('' as signed);
--error ER_M_BIGGER_THAN_D
select cast(1 as double(5,6));
--error ER_M_BIGGER_THAN_D
select cast(1 as decimal(5,6));
--error ER_TOO_BIG_PRECISION
select cast(1 as double(66,6));
--error ER_TOO_BIG_PRECISION
select cast(1 as decimal(66,6));
--error ER_TOO_BIG_SCALE
select cast(1 as decimal(64,63));
--error ER_TOO_BIG_SCALE
select cast(1 as double(64,63));
# #
# Character set conversion # Character set conversion
# #
@ -124,8 +191,6 @@ set names binary;
select cast("2001-1-1" as date) = "2001-01-01"; select cast("2001-1-1" as date) = "2001-01-01";
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"; select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
select cast("1:2:3" as TIME) = "1:02:03"; select cast("1:2:3" as TIME) = "1:02:03";
select cast(NULL as DATE);
select cast(NULL as BINARY);
# #
# Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions # Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions
@ -171,6 +236,14 @@ select cast(repeat('1',20) as signed);
# #
select cast(1.0e+300 as signed int); select cast(1.0e+300 as signed int);
#
# Test that we create the correct types with create ... select cast()
#
create table t1 select cast(1 as unsigned), cast(1 as signed), cast(1 as double(5,2)), cast(1 as decimal(5,3)), cast("A" as binary), cast("A" as char(100)), cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME), cast("1:2:3" as TIME);
show create table t1;
drop table t1;
# #
# Bugs: #15098: CAST(column double TO signed int), wrong result # Bugs: #15098: CAST(column double TO signed int), wrong result
# #

462
mysql-test/t/dyncol.test Normal file
View file

@ -0,0 +1,462 @@
#
# Dynamic column function test
#
--echo #
--echo # column create
--echo #
select hex(COLUMN_CREATE(1, NULL AS char character set utf8));
select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8));
select hex(COLUMN_CREATE(1, 1212 AS char character set utf8));
select hex(COLUMN_CREATE(1, 12.12 AS char character set utf8));
select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS char character set utf8));
select hex(COLUMN_CREATE(1, NULL AS unsigned int));
select hex(COLUMN_CREATE(1, 1212 AS unsigned int));
select hex(COLUMN_CREATE(1, 7 AS unsigned int));
select hex(COLUMN_CREATE(1, 8 AS unsigned int));
select hex(COLUMN_CREATE(1, 127 AS unsigned int));
select hex(COLUMN_CREATE(1, 128 AS unsigned int));
select hex(COLUMN_CREATE(1, 12.12 AS unsigned int));
select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int));
select hex(COLUMN_CREATE(1, NULL AS int));
select hex(COLUMN_CREATE(1, 1212 AS int));
select hex(COLUMN_CREATE(1, 7 AS int));
select hex(COLUMN_CREATE(1, 8 AS int));
select hex(COLUMN_CREATE(1, 127 AS int));
select hex(COLUMN_CREATE(1, 128 AS int));
select hex(COLUMN_CREATE(1, 12.12 AS int));
select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS int));
select hex(COLUMN_CREATE(1, NULL AS double));
select hex(COLUMN_CREATE(1, 1212 AS double));
select hex(COLUMN_CREATE(1, 12.12 AS double));
select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS double));
select hex(COLUMN_CREATE(1, NULL AS decimal));
select hex(COLUMN_CREATE(1, 1212 AS decimal));
select hex(COLUMN_CREATE(1, 7 AS decimal));
select hex(COLUMN_CREATE(1, 8 AS decimal));
select hex(COLUMN_CREATE(1, 127 AS decimal));
select hex(COLUMN_CREATE(1, 128 AS decimal));
select hex(COLUMN_CREATE(1, 12.12 AS decimal));
select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS decimal));
select hex(COLUMN_CREATE(1, NULL AS date));
select hex(COLUMN_CREATE(1, "2011-04-05" AS date));
select hex(COLUMN_CREATE(1, NULL AS time));
select hex(COLUMN_CREATE(1, "0:45:49.000001" AS time));
select hex(COLUMN_CREATE(1, NULL AS datetime));
select hex(COLUMN_CREATE(1, "2011-04-05 0:45:49.000001" AS datetime));
select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
2, 1212 AS unsigned int,
3, 1212 AS int,
4, 12.12 AS double,
4+1, 12.12 AS decimal,
6, "2011-04-05" AS date,
7, "- 0:45:49.000001" AS time,
8, "2011-04-05 0:45:49.000001" AS datetime));
explain extended
select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
2, 1212 AS unsigned int,
3, 1212 AS int,
4, 12.12 AS double,
4+1, 12.12 AS decimal,
6, "2011-04-05" AS date,
7, "- 0:45:49.000001" AS time,
8, "2011-04-05 0:45:49.000001" AS datetime));
--echo #
--echo # column get uint
--echo #
select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
explain extended
select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
explain extended
select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned);
select column_get(column_create(1, 1212 AS decimal), 1 as unsigned int);
select column_get(column_create(1, 1212 AS double), 1 as unsigned int);
select column_get(column_create(1, 1212 AS int), 1 as unsigned int);
select column_get(column_create(1, "1212" AS char), 1 as unsigned int);
select column_get(column_create(1, "2011-04-05" AS date), 1 as unsigned int);
select column_get(column_create(1, "8:46:06.23434" AS time), 1 as unsigned int);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as unsigned int);
select column_get(column_create(1, NULL AS unsigned int), 1 as unsigned int);
--echo # column geint truncation & warnings
select column_get(column_create(1, -1212 AS int), 1 as unsigned int);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as unsigned int);
select column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as unsigned int);
select column_get(column_create(1, -1 AS decimal), 1 as unsigned int);
select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as unsigned int);
select column_get(column_create(1, 999.9 AS double), 1 as unsigned int);
select column_get(column_create(1, -1 AS double), 1 as unsigned int);
select column_get(column_create(1, "1212III" AS char), 1 as unsigned int);
--echo #
--echo # column get int
--echo #
select column_get(column_create(1, 1212 AS int), 1 as int);
explain extended
select column_get(column_create(1, 1212 AS int), 1 as int);
explain extended
select column_get(column_create(1, 1212 AS int), 1 as signed int);
select column_get(column_create(1, -1212 AS int), 1 as int);
select column_get(column_create(1, 1212 AS decimal), 1 as int);
select column_get(column_create(1, 1212 AS double), 1 as int);
select column_get(column_create(1, 1212 AS unsigned int), 1 as int);
select column_get(column_create(1, "1212" AS char), 1 as int);
select column_get(column_create(1, "-1212" AS char), 1 as int);
select column_get(column_create(1, "2011-04-05" AS date), 1 as int);
select column_get(column_create(1, "8:46:06.23434" AS time), 1 as int);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as int);
select column_get(column_create(1, NULL AS int), 1 as int);
--echo #column gett truncation & warnings
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as int);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as int);
select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as int);
select column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as int);
select column_get(column_create(1, 999.9 AS double), 1 as int);
select column_get(column_create(1, -99999999999999999999999999999 AS double), 1 as int);
select column_get(column_create(1, "-1212III" AS char), 1 as int);
select column_get(column_create(1, "1212III" AS char), 1 as int);
--echo #
--echo #column get char
--echo #
select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8);
explain extended
select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8);
select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8);
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as char charset utf8);
select column_get(column_create(1, 1212 AS int), 1 as char charset utf8);
select column_get(column_create(1, -1212 AS int), 1 as char charset utf8);
select column_get(column_create(1, 9223372036854775807 AS int), 1 as char charset utf8);
select column_get(column_create(1, -9223372036854775808 AS int), 1 as char charset utf8);
select column_get(column_create(1, 1212.12 AS decimal), 1 as char charset utf8);
select column_get(column_create(1, 1212.12 AS double), 1 as char charset utf8);
select column_get(column_create(1, "2011-04-05" AS date), 1 as char charset utf8);
select column_get(column_create(1, "8:46:06.23434" AS time), 1 as char charset utf8);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as char charset utf8);
select column_get(column_create(1, NULL AS char charset utf8), 1 as char charset utf8);
select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary);
explain extended
select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary);
--echo #
--echo # column get real
--echo #
select column_get(column_create(1, 1212.12 AS double), 1 as double);
explain extended
select column_get(column_create(1, 1212.12 AS double), 1 as double);
explain extended
select column_get(column_create(1, 1212.12 AS double), 1 as double(6,2));
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as double);
select column_get(column_create(1, 9223372036854775807 AS int), 1 as double);
select column_get(column_create(1, -9223372036854775808 AS int), 1 as double);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as double);
select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as double);
select column_get(column_create(1, "2011-04-05" AS date), 1 as double);
select column_get(column_create(1, "8:46:06.23434" AS time), 1 as double);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double(20,6));
select column_get(column_create(1, NULL AS double), 1 as double);
-- echo # column get real truncation & warnings
select column_get(column_create(1, "1223.5aa" AS char), 1 as double);
select column_get(column_create(1, "aa" AS char), 1 as double);
select column_get(column_create(1, "1223.5555" AS double), 1 as double(5,2));
select column_get(column_create(1, "1223.5555" AS double), 1 as double(3,2));
--echo #
--echo # column get decimal
--echo #
select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
explain extended
select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
explain extended
select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal(20,0));
select column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal(32,0));
select column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal(32,0));
select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as decimal(40,10));
select column_get(column_create(1, "2011-04-05" AS date), 1 as decimal(32,6));
select column_get(column_create(1, "8:46:06.23434" AS time), 1 as decimal(32,6));
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as decimal(32,6));
select column_get(column_create(1, NULL as decimal), 1 as decimal(32,10));
select column_get(column_create(1, "1223.5555" as decimal(10,5)), 1 as decimal(6,2));
-- echo # column get decimal truncation & warnings
select column_get(column_create(1, "1223.5aa" AS char), 1 as decimal(32,10));
select column_get(column_create(1, "aa" AS char), 1 as decimal(32,10));
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal);
select column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal);
select column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as decimal);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as decimal);
select column_get(column_create(1, "1223.5555" as double), 1 as decimal(5,2));
select column_get(column_create(1, "-1223.5555" as double), 1 as decimal(5,2));
select column_get(column_create(1, "1223.5555" AS double), 1 as decimal(3,2));
select column_get(column_create(1, "1223.5555" AS decimal(10,5)), 1 as decimal(3,2));
--echo #
--echo # column get datetime
--echo #
select column_get(column_create(1, 20010203101112.121314 as double), 1 as datetime);
select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as datetime);
select column_get(column_create(1, 20010203101112 as unsigned int), 1 as datetime);
select column_get(column_create(1, 20010203101112 as int), 1 as datetime);
select column_get(column_create(1, "20010203101112" as char), 1 as datetime);
select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as datetime);
select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as datetime);
select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as datetime);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime);
select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as datetime);
select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as datetime);
select column_get(column_create(1, 20010203 as unsigned int), 1 as datetime);
select column_get(column_create(1, 20010203 as int), 1 as datetime);
select column_get(column_create(1, 20010203), 1 as datetime);
select column_get(column_create(1, 20010203.0), 1 as datetime);
select column_get(column_create(1, 20010203.0 as double), 1 as datetime);
select column_get(column_create(1, "2001-02-03"), 1 as datetime);
select column_get(column_create(1, "20010203"), 1 as datetime);
select column_get(column_create(1, 0), 1 as datetime);
select column_get(column_create(1, "2001021"), 1 as datetime);
select column_get(column_create(1, "8:46:06.23434" AS time), 1 as datetime);
set @@sql_mode="allow_invalid_dates";
select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as datetime);
select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as datetime);
select column_get(column_create(1, "2001-00-02" AS CHAR), 1 as datetime);
set @@sql_mode="";
-- echo # column get datetime truncation & warnings
select column_get(column_create(1, "1223.5aa" AS char), 1 as datetime);
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as datetime);
select column_get(column_create(1, 9223372036854775807 AS int), 1 as datetime);
select column_get(column_create(1, -9223372036854775808 AS int), 1 as datetime);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as datetime);
select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as datetime);
select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as datetime);
select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as datetime);
select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as datetime);
select column_get(column_create(1, "20010231"), 1 as datetime);
select column_get(column_create(1, "0" AS CHAR), 1 as datetime);
--echo #
--echo # column get date
--echo #
select column_get(column_create(1, 20010203101112.121314 as double), 1 as date);
select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as date);
select column_get(column_create(1, 20010203101112 as unsigned int), 1 as date);
select column_get(column_create(1, 20010203101112 as int), 1 as date);
select column_get(column_create(1, "20010203101112" as char), 1 as date);
select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as date);
select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as date);
select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as date);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as date);
select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as date);
select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as date);
select column_get(column_create(1, 20010203 as unsigned int), 1 as date);
select column_get(column_create(1, 20010203 as int), 1 as date);
select column_get(column_create(1, 20010203), 1 as date);
select column_get(column_create(1, 20010203.0), 1 as date);
select column_get(column_create(1, 20010203.0 as double), 1 as date);
select column_get(column_create(1, "2001-02-03"), 1 as date);
select column_get(column_create(1, "20010203"), 1 as date);
select column_get(column_create(1, 0), 1 as date);
select column_get(column_create(1, "2001021"), 1 as date);
set @@sql_mode="allow_invalid_dates";
select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as date);
select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as date);
select column_get(column_create(1, "2001-00-02" AS CHAR), 1 as date);
set @@sql_mode="";
-- echo # column get date truncation & warnings
select column_get(column_create(1, "1223.5aa" AS char), 1 as date);
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as date);
select column_get(column_create(1, 9223372036854775807 AS int), 1 as date);
select column_get(column_create(1, -9223372036854775808 AS int), 1 as date);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as date);
select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as date);
select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as date);
select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as date);
select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as date);
select column_get(column_create(1, "20010231"), 1 as date);
select column_get(column_create(1, "0" AS CHAR), 1 as date);
--echo #
--echo # column get time
--echo #
select column_get(column_create(1, 20010203101112.121314 as double), 1 as time);
select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as time);
select column_get(column_create(1, 20010203101112 as unsigned int), 1 as time);
select column_get(column_create(1, 20010203101112 as int), 1 as time);
select column_get(column_create(1, "20010203101112" as char), 1 as time);
select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as time);
select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time);
select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as time);
select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as time);
select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as time);
select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as time);
select column_get(column_create(1, "830:46:06.23434" AS CHAR), 1 as time);
select cast("-830:46:06.23434" AS time);
select 1,cast("-830:46:06.23434" AS time);
select hex(column_create(1, "-830:46:06.23434" AS CHAR));
select column_get(column_create(1, "-830:46:06.23434" AS CHAR), 1 as time);
select column_get(column_create(1, "0" AS CHAR), 1 as time);
select column_get(column_create(1, "6" AS CHAR), 1 as time);
select column_get(column_create(1, "1:6" AS CHAR), 1 as time);
select column_get(column_create(1, "2:1:6" AS CHAR), 1 as time);
select column_get(column_create(1, 0), 1 as time);
select column_get(column_create(1, "2001021"), 1 as time);
set @@sql_mode="allow_invalid_dates";
select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as time);
set @@sql_mode="";
-- echo # column get date truncation & warnings
select column_get(column_create(1, "1223.5aa" AS char), 1 as time);
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as time);
select column_get(column_create(1, 9223372036854775807 AS int), 1 as time);
select column_get(column_create(1, -9223372036854775808 AS int), 1 as time);
select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as time);
select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as time);
select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as time);
select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as time);
select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as time);
select column_get(column_create(1, "2001-02-03"), 1 as time);
select column_get(column_create(1, "20010203"), 1 as time);
-- echo # column add
select hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer));
select hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer));
select hex(column_add(column_create(1, 1212 as integer), 1, NULL as integer));
select hex(column_add(column_create(1, 1212 as integer), 2, NULL as integer));
select hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer));
select column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 1 as integer);
select column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 2 as integer);
select hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer, 2, 11 as integer));
select hex(column_add(column_create(1, NULL as integer), 1, 1212 as integer, 2, 11 as integer));
select hex(column_add(column_create(1, 1212 as integer, 2, 1212 as integer), 1, 11 as integer));
select hex(column_add(column_create(1, 1), 1, null));
select column_list(column_add(column_create(1, 1), 1, null));
select column_list(column_add(column_create(1, 1), 1, ""));
select hex(column_add("", 1, 1));
-- echo # column delete
select hex(column_delete(column_create(1, 1212 as integer, 2, 1212 as integer), 1));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 3));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 4));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 1));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 3));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3));
select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3, 10));
select hex(column_delete(column_create(1, 1), 1));
select hex(column_delete("", 1));
-- echo # column exists
select column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 1);
select column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 4);
-- echo # column list
select column_list(column_create(1, 1212 as integer, 2, 1212 as integer));
select column_list(column_create(1, 1212 as integer));
select column_list(column_create(1, NULL as integer));
--echo #
--echo # check error handling
--echo #
--error ER_DYN_COL_DATA
select HEX(COLUMN_CREATE(1, 5, 1, 5));
--error 1064
select HEX(COLUMN_CREATE("", 1, 5, 1, 5));
--error ER_DYN_COL_WRONG_FORMAT
select COLUMN_LIST("a");
--error ER_DYN_COL_WRONG_FORMAT
select column_delete("a", 1);
select hex(column_delete("", 1));
--error ER_DYN_COL_DATA
select hex(column_delete("", -1));
--error ER_DYN_COL_DATA
select hex(column_create(-1, 1));
--error ER_DYN_COL_DATA
select hex(column_create(65536, 1));
--error ER_DYN_COL_DATA
select hex(column_add("", -1, 1));
--error ER_DYN_COL_DATA
select hex(column_add("", 65536, 1));
select hex(column_get("", -1 as int));
--echo #
--echo # Test with table
--echo #
# create table with 'str' to hold a set of dynamic columns
create table t1 (id int primary key, str mediumblob);
insert into t1 values (1, ''), (2, ''), (3, ''), (4, ''), (5, null);
# Selecting a non existing column
select id, str, column_get(str, 1 as int) from t1;
# Add some dynamic columns. One and do it with create or add.
update t1 set str=column_create(1, id, 2, "a") where id < 3;
update t1 set str=column_add(str, 1, id, 2, "b") where id >= 4;
# Show some data, if it exists
select id, column_get(str, 1 as int), column_get(str, 2 as char) from t1 where column_exists(str,1) or column_exists(str,2);
# Add data to row 5 and 6
update t1 set str=column_create(1, id, 10, "test") where id = 5;
insert into t1 values (6, column_create(10, "test2"));
# Update some of the columns and add a new column 3
update t1 set str=column_add(str, 2, 'c', 1, column_get(str, 1 as int) + 1, 3, 100) where id > 2;
# Check data
select id, length(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1;
# You can do anything with the columns, like SUM() or GROUP
select column_get(str, 2 as char), sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char);
select column_get(str, 2 as char), sum(column_get(str, 1 as int)) from t1 where column_exists(str, 2) <> 0 group by 1;
select sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char) order by sum(column_get(str, 1 as int)) desc;
select sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char) having sum(column_get(str, 1 as int)) > 2;
select sum(column_get(str, 1 as int)) from t1 where column_get(str, 3 as int) > 50 group by column_get(str, 2 as char);
# Deleting of column
select id, column_list(str) from t1 where id= 5;
update t1 set str=column_delete(str, 3, 4, 2) where id= 5;
select id, length(str), column_list(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1;
update t1 set str=column_add(str, 4, 45 as char, 2, 'c') where id= 5;
select id, length(str), column_list(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1 where id = 5;
# Check which column exists
select id, length(str), column_list(str), column_exists(str, 4) from t1;
select sum(column_get(str, 1 as int)), column_list(str) from t1 group by 2;
select id, hex(str) from t1;
# Check with a bit larger strings
update t1 set str=column_add(str, 4, repeat("a", 100000)) where id=5;
select id from t1 where column_get(str,4 as char(100000)) = repeat("a", 100000);
select id from t1 where column_get(str,4 as char(100)) = repeat("a", 100);
update t1 set str=column_add(str, 4, repeat("b", 10000)) where id=5;
select id from t1 where column_get(str,4 as char(100000)) = repeat("b", 10000);
update t1 set str=column_add(str, 4, repeat("c", 100)) where id=5;
select id from t1 where column_get(str,4 as char(100000)) = repeat("c", 100);
update t1 set str=column_add(str, 4, repeat("d", 10000)) where id=5;
select id from t1 where column_get(str,4 as char(100000)) = repeat("d", 10000);
update t1 set str=column_add(str, 4, repeat("e", 10), 5, repeat("f", 100000)) where id=5;
select id from t1 where column_get(str,5 as char(100000)) = repeat("f", 100000);
select id, column_list(str), length(str) from t1 where id=5;
update t1 set str=column_delete(str, 5) where id=5;
select id, column_list(str), length(str) from t1 where id=5;
drop table t1;

View file

@ -367,6 +367,8 @@ INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE)); INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
--error 1292 --error 1292
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE)); INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
--error 1292
INSERT INTO t1 (col1) VALUES('2004-0-10');
# deactivated because of Bug#8294 # deactivated because of Bug#8294
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE # Bug#8294 Traditional: Misleading error message for invalid CAST to DATE

View file

@ -40,7 +40,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c ma_dyncol.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c lf_alloc-pin.c lf_dynarray.c lf_hash.c
my_atomic.c my_getncpus.c my_rnd.c my_atomic.c my_getncpus.c my_rnd.c
my_uuid.c wqueue.c waiting_threads.c my_uuid.c wqueue.c waiting_threads.c

View file

@ -27,7 +27,7 @@ libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \ mf_path.c mf_loadpath.c my_file.c \
my_open.c my_create.c my_dup.c my_seek.c my_read.c \ my_open.c my_create.c my_dup.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \ my_pread.c my_write.c my_getpagesize.c \
my_crc32.c \ my_crc32.c ma_dyncol.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \ my_malloc.c my_realloc.c my_once.c mulalloc.c \

2044
mysys/ma_dyncol.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -183,3 +183,15 @@ void dynstr_free(DYNAMIC_STRING *str)
str->str=0; str->str=0;
} }
} }
/* Give over the control of the dynamic string to caller */
void dynstr_reassociate(DYNAMIC_STRING *str, char **ptr, size_t *length,
size_t *alloc_length)
{
*ptr= str->str;
*length= str->length;
*alloc_length= str->max_length;
str->str=0;
}

View file

@ -482,7 +482,7 @@ err:
*/ */
my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
int *warning) ulong fuzzydate, int *warning)
{ {
ulong date[5]; ulong date[5];
ulonglong value; ulonglong value;
@ -509,7 +509,7 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
int was_cut; int was_cut;
enum enum_mysql_timestamp_type enum enum_mysql_timestamp_type
res= str_to_datetime(str, length, l_time, res= str_to_datetime(str, length, l_time,
(TIME_FUZZY_DATE | TIME_DATETIME_ONLY), &was_cut); fuzzydate | TIME_DATETIME_ONLY, &was_cut);
if ((int) res >= (int) MYSQL_TIMESTAMP_ERROR) if ((int) res >= (int) MYSQL_TIMESTAMP_ERROR)
{ {
if (was_cut) if (was_cut)
@ -1028,11 +1028,15 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type)
int my_time_to_str(const MYSQL_TIME *l_time, char *to) int my_time_to_str(const MYSQL_TIME *l_time, char *to)
{ {
uint extra_hours= 0; uint extra_hours= 0;
return my_sprintf(to, (to, "%s%02u:%02u:%02u", return my_sprintf(to, (to,
(l_time->second_part ?
"%s%02u:%02u:%02u.%06ld" :
"%s%02u:%02u:%02u"),
(l_time->neg ? "-" : ""), (l_time->neg ? "-" : ""),
extra_hours+ l_time->hour, extra_hours+ l_time->hour,
l_time->minute, l_time->minute,
l_time->second)); l_time->second,
l_time->second_part));
} }
int my_date_to_str(const MYSQL_TIME *l_time, char *to) int my_date_to_str(const MYSQL_TIME *l_time, char *to)
@ -1045,13 +1049,17 @@ 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_datetime_to_str(const MYSQL_TIME *l_time, char *to)
{ {
return my_sprintf(to, (to, "%04u-%02u-%02u %02u:%02u:%02u", return my_sprintf(to, (to,
(l_time->second_part ?
"%04u-%02u-%02u %02u:%02u:%02u.%06ld" :
"%04u-%02u-%02u %02u:%02u:%02u"),
l_time->year, l_time->year,
l_time->month, l_time->month,
l_time->day, l_time->day,
l_time->hour, l_time->hour,
l_time->minute, l_time->minute,
l_time->second)); l_time->second,
l_time->second_part));
} }
@ -1062,6 +1070,9 @@ int my_datetime_to_str(const MYSQL_TIME *l_time, char *to)
SYNOPSIS SYNOPSIS
my_TIME_to_string() my_TIME_to_string()
RETURN
length of string
NOTE NOTE
The string must have at least MAX_DATE_STRING_REP_LENGTH bytes reserved. The string must have at least MAX_DATE_STRING_REP_LENGTH bytes reserved.
*/ */
@ -1118,7 +1129,6 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
long part1,part2; long part1,part2;
*was_cut= 0; *was_cut= 0;
bzero((char*) time_res, sizeof(*time_res));
time_res->time_type=MYSQL_TIMESTAMP_DATE; time_res->time_type=MYSQL_TIMESTAMP_DATE;
if (nr == LL(0) || nr >= LL(10000101000000)) if (nr == LL(0) || nr >= LL(10000101000000))
@ -1171,6 +1181,8 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
time_res->hour= (int) (part2/10000L); part2%=10000L; time_res->hour= (int) (part2/10000L); part2%=10000L;
time_res->minute=(int) part2 / 100; time_res->minute=(int) part2 / 100;
time_res->second=(int) part2 % 100; time_res->second=(int) part2 % 100;
time_res->second_part= 0;
time_res->neg= 0;
if (time_res->year <= 9999 && time_res->month <= 12 && if (time_res->year <= 9999 && time_res->month <= 12 &&
time_res->day <= 31 && time_res->hour <= 23 && time_res->day <= 31 && time_res->hour <= 23 &&
@ -1179,15 +1191,59 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
return nr; return nr;
/* Don't want to have was_cut get set if NO_ZERO_DATE was violated. */ /* Don't want to have was_cut get set if NO_ZERO_DATE was violated. */
if (!nr && (flags & TIME_NO_ZERO_DATE)) if (nr || !(flags & TIME_NO_ZERO_DATE))
return LL(-1); *was_cut= 1;
return LL(-1);
err: err:
*was_cut= 1; {
/* reset everything except time_type */
enum enum_mysql_timestamp_type save= time_res->time_type;
bzero((char*) time_res, sizeof(*time_res));
time_res->time_type= save; /* Restore range */
*was_cut= 1; /* Found invalid date */
}
return LL(-1); return LL(-1);
} }
/*
Convert a double to a date/datetime
Note that for sub seconds, the precision of double is not good enough!
RESULT:
0 ok
1 error ; ltime is zeroed
*/
my_bool double_to_datetime(double value, MYSQL_TIME *ltime,
uint fuzzydate)
{
double datepart_value;
int was_cut;
if (value < 0 || value > 99991231235959.0)
{
bzero((char*) ltime, sizeof(*ltime));
return 1;
}
datepart_value= floor(value);
if (number_to_datetime((longlong) datepart_value, ltime, fuzzydate,
&was_cut) == LL(-1))
return 1;
if (ltime->time_type == MYSQL_TIMESTAMP_DATETIME ||
ltime->time_type == MYSQL_TIMESTAMP_TIME)
{
/* Add sub seconds to results */
ltime->second_part= (ulong) (floor((value - datepart_value) *
TIME_SUBSECOND_RANGE));
}
return 0;
}
/* Convert time value to integer in YYYYMMDDHHMMSS format */ /* Convert time value to integer in YYYYMMDDHHMMSS format */
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time) ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time)

View file

@ -1578,17 +1578,19 @@ longlong Field::convert_decimal2longlong(const my_decimal *val,
i= 0; i= 0;
*err= 1; *err= 1;
} }
else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & else if (warn_if_overflow(my_decimal2int((E_DEC_ERROR &
~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, ~E_DEC_OVERFLOW &
val, TRUE, &i))) ~E_DEC_TRUNCATED),
val, TRUE, &i)))
{ {
i= ~(longlong) 0; i= ~(longlong) 0;
*err= 1; *err= 1;
} }
} }
else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & else if (warn_if_overflow(my_decimal2int((E_DEC_ERROR &
~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, ~E_DEC_OVERFLOW &
val, FALSE, &i))) ~E_DEC_TRUNCATED),
val, FALSE, &i)))
{ {
i= (val->sign() ? LONGLONG_MIN : LONGLONG_MAX); i= (val->sign() ? LONGLONG_MIN : LONGLONG_MAX);
*err= 1; *err= 1;
@ -1753,7 +1755,10 @@ bool Field::get_time(MYSQL_TIME *ltime)
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res; String tmp(buff,sizeof(buff),&my_charset_bin),*res;
if (!(res=val_str(&tmp)) || if (!(res=val_str(&tmp)) ||
str_to_time_with_warn(res->ptr(), res->length(), ltime)) str_to_time_with_warn(res->ptr(), res->length(), ltime,
table->in_use->variables.sql_mode &
(MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
MODE_INVALID_DATES)))
return 1; return 1;
return 0; return 0;
} }
@ -3866,40 +3871,11 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_longlong::store(double nr) int Field_longlong::store(double nr)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
int error= 0; bool error;
longlong res; longlong res;
nr= rint(nr); res= double_to_longlong(nr, unsigned_flag, &error);
if (unsigned_flag)
{
if (nr < 0)
{
res=0;
error= 1;
}
else if (nr >= (double) ULONGLONG_MAX)
{
res= ~(longlong) 0;
error= 1;
}
else
res=(longlong) double2ulonglong(nr);
}
else
{
if (nr <= (double) LONGLONG_MIN)
{
res= LONGLONG_MIN;
error= (nr < (double) LONGLONG_MIN);
}
else if (nr >= (double) (ulonglong) LONGLONG_MAX)
{
res= LONGLONG_MAX;
error= (nr > (double) LONGLONG_MAX);
}
else
res=(longlong) nr;
}
if (error) if (error)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@ -4144,7 +4120,18 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_float::store(double nr) int Field_float::store(double nr)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
int error= truncate(&nr, FLT_MAX); int error= truncate_double(&nr, field_length,
not_fixed ? NOT_FIXED_DEC : dec,
unsigned_flag, FLT_MAX);
if (error)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
if (error < 0) // Wrong double value
{
error= 1;
set_null();
}
}
float j= (float)nr; float j= (float)nr;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -4406,7 +4393,18 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_double::store(double nr) int Field_double::store(double nr)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
int error= truncate(&nr, DBL_MAX); int error= truncate_double(&nr, field_length,
not_fixed ? NOT_FIXED_DEC : dec,
unsigned_flag, DBL_MAX);
if (error)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
if (error < 0) // Wrong double value
{
error= 1;
set_null();
}
}
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first) if (table->s->db_low_byte_first)
@ -4430,28 +4428,31 @@ int Field_double::store(longlong nr, bool unsigned_val)
If a field has fixed length, truncate the double argument pointed to by 'nr' If a field has fixed length, truncate the double argument pointed to by 'nr'
appropriately. appropriately.
Also ensure that the argument is within [-max_value; max_value] range. Also ensure that the argument is within [-max_value; max_value] range.
return
0 ok
-1 Illegal double value
1 Value was truncated
*/ */
int Field_real::truncate(double *nr, double max_value) int truncate_double(double *nr, uint field_length, uint dec,
bool unsigned_flag, double max_value)
{ {
int error= 1; int error= 0;
double res= *nr; double res= *nr;
if (isnan(res)) if (isnan(res))
{ {
res= 0; *nr= 0;
set_null(); return -1;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
goto end;
} }
else if (unsigned_flag && res < 0) else if (unsigned_flag && res < 0)
{ {
res= 0; *nr= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); return 1;
goto end;
} }
if (!not_fixed) if (dec < NOT_FIXED_DEC)
{ {
uint order= field_length - dec; uint order= field_length - dec;
uint step= array_elements(log_10) - 1; uint step= array_elements(log_10) - 1;
@ -4467,22 +4468,70 @@ int Field_real::truncate(double *nr, double max_value)
if (res < -max_value) if (res < -max_value)
{ {
res= -max_value; res= -max_value;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1;
} }
else if (res > max_value) else if (res > max_value)
{ {
res= max_value; res= max_value;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1;
} }
else
error= 0;
end:
*nr= res; *nr= res;
return error; return error;
} }
/*
Convert double to longlong / ulonglong.
If double is outside of range, adjust return value and set error.
SYNOPSIS
double_to_longlong()
nr Number to convert
unsigned_flag 1 if result is unsigned
error Will be set to 1 in case of overflow.
*/
longlong double_to_longlong(double nr, bool unsigned_flag, bool *error)
{
longlong res;
*error= 0;
nr= rint(nr);
if (unsigned_flag)
{
if (nr < 0)
{
res= 0;
*error= 1;
}
else if (nr >= (double) ULONGLONG_MAX)
{
res= ~(longlong) 0;
*error= 1;
}
else
res= (longlong) double2ulonglong(nr);
}
else
{
if (nr <= (double) LONGLONG_MIN)
{
res= LONGLONG_MIN;
*error= (nr < (double) LONGLONG_MIN);
}
else if (nr >= (double) (ulonglong) LONGLONG_MAX)
{
res= LONGLONG_MAX;
*error= (nr > (double) LONGLONG_MAX);
}
else
res= (longlong) nr;
}
return res;
}
int Field_real::store_decimal(const my_decimal *dm) int Field_real::store_decimal(const my_decimal *dm)
{ {
@ -4511,6 +4560,7 @@ longlong Field_double::val_int(void)
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
double j; double j;
longlong res; longlong res;
bool error;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first) if (table->s->db_low_byte_first)
{ {
@ -4519,20 +4569,9 @@ longlong Field_double::val_int(void)
else else
#endif #endif
doubleget(j,ptr); doubleget(j,ptr);
/* Check whether we fit into longlong range */
if (j <= (double) LONGLONG_MIN)
{
res= (longlong) LONGLONG_MIN;
goto warn;
}
if (j >= (double) (ulonglong) LONGLONG_MAX)
{
res= (longlong) LONGLONG_MAX;
goto warn;
}
return (longlong) rint(j);
warn: res= double_to_longlong(j, 0, &error);
if (error)
{ {
char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
String tmp(buf, sizeof(buf), &my_charset_latin1), *str; String tmp(buf, sizeof(buf), &my_charset_latin1), *str;
@ -5147,7 +5186,10 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
int error= 0; int error= 0;
int warning; int warning;
if (str_to_time(from, len, &ltime, &warning)) if (str_to_time(from, len, &ltime,
table->in_use->variables.sql_mode &
(MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
MODE_INVALID_DATES), &warning))
{ {
tmp=0L; tmp=0L;
error= 2; error= 2;
@ -5305,6 +5347,7 @@ String *Field_time::val_str(String *val_buffer,
ltime.hour= (uint) (tmp/10000); ltime.hour= (uint) (tmp/10000);
ltime.minute= (uint) (tmp/100 % 100); ltime.minute= (uint) (tmp/100 % 100);
ltime.second= (uint) (tmp % 100); ltime.second= (uint) (tmp % 100);
ltime.second_part= 0;
make_time((DATE_TIME_FORMAT*) 0, &ltime, val_buffer); make_time((DATE_TIME_FORMAT*) 0, &ltime, val_buffer);
return val_buffer; return val_buffer;
} }

View file

@ -33,6 +33,9 @@ class Relay_log_info;
struct st_cache_field; struct st_cache_field;
int field_conv(Field *to,Field *from); int field_conv(Field *to,Field *from);
int truncate_double(double *nr, uint field_length, uint dec,
bool unsigned_flag, double max_value);
longlong double_to_longlong(double nr, bool unsigned_flag, bool *error);
inline uint get_enum_pack_length(int elements) inline uint get_enum_pack_length(int elements)
{ {
@ -808,7 +811,6 @@ public:
{} {}
int store_decimal(const my_decimal *); int store_decimal(const my_decimal *);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
int truncate(double *nr, double max_length);
uint32 max_display_length() { return field_length; } uint32 max_display_length() { return field_length; }
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
virtual const uchar *unpack(uchar* to, const uchar *from, virtual const uchar *unpack(uchar* to, const uchar *from,

View file

@ -985,19 +985,13 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const
bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{ {
if (result_type() == STRING_RESULT) switch (result_type()) {
case INT_RESULT:
{ {
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)
goto err;
}
else
{
longlong value= val_int();
int was_cut; int was_cut;
longlong value= val_int();
if (null_value)
goto err;
if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1)) if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1))
{ {
char buff[22], *end; char buff[22], *end;
@ -1005,8 +999,52 @@ bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE, buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE,
NullS); NullS);
null_value= 1;
goto err; goto err;
} }
break;
}
case REAL_RESULT:
{
double value= val_real();
if (null_value)
goto err;
if (double_to_datetime_with_warn(value, ltime, fuzzydate))
{
null_value= 1;
goto err;
}
break;
}
case DECIMAL_RESULT:
{
my_decimal value, *res;
if (!(res= val_decimal(&value)))
goto err; // Null
if (decimal_to_datetime_with_warn(res, ltime, fuzzydate))
{
null_value= 1;
goto err;
}
break;
}
default:
{
/*
Default go trough string as this is the safest way to ensure that
we also get the microseconds.
*/
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)
{
null_value= 1;
goto err;
}
break;
}
} }
return 0; return 0;
@ -1026,7 +1064,11 @@ bool Item::get_time(MYSQL_TIME *ltime)
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res; String tmp(buff,sizeof(buff),&my_charset_bin),*res;
if (!(res=val_str(&tmp)) || if (!(res=val_str(&tmp)) ||
str_to_time_with_warn(res->ptr(), res->length(), ltime)) str_to_time_with_warn(res->ptr(), res->length(), ltime,
TIME_FUZZY_DATE |
(current_thd->variables.sql_mode &
(MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
MODE_INVALID_DATES))))
{ {
bzero((char*) ltime,sizeof(*ltime)); bzero((char*) ltime,sizeof(*ltime));
return 1; return 1;

View file

@ -18,6 +18,10 @@
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
C_MODE_START
#include <ma_dyncol.h>
C_MODE_END
inline inline
bool trace_unsupported_func(const char *where, const char *processor_name) bool trace_unsupported_func(const char *where, const char *processor_name)
{ {
@ -471,6 +475,17 @@ public:
}; };
struct st_dyncall_create_def
{
Item *num, *value;
CHARSET_INFO *cs;
uint len, frac;
DYNAMIC_COLUMN_TYPE type;
};
typedef struct st_dyncall_create_def DYNCALL_CREATE_DEF;
typedef bool (Item::*Item_processor) (uchar *arg); typedef bool (Item::*Item_processor) (uchar *arg);
/* /*
Analyzer function Analyzer function
@ -804,7 +819,11 @@ public:
{ return val_decimal(val); } { return val_decimal(val); }
virtual bool val_bool_result() { return val_bool(); } virtual bool val_bool_result() { return val_bool(); }
virtual bool is_null_result() { return is_null(); } virtual bool is_null_result() { return is_null(); }
/*
Returns 1 if result type and collation for val_str() can change between
calls
*/
virtual bool dynamic_result() { return 0; }
/* /*
Bitmap of tables used by item Bitmap of tables used by item
(note: if you need to check dependencies on individual columns, check out (note: if you need to check dependencies on individual columns, check out

View file

@ -6041,7 +6041,7 @@ Item* Item_equal::get_first(Item *field_item)
} }
else else
{ {
#if 0 #if TO_BE_DELETED
/* /*
The field is not in SJ-Materialization nest. We must return the first The field is not in SJ-Materialization nest. We must return the first
field that's not embedded in a SJ-Materialization nest. field that's not embedded in a SJ-Materialization nest.
@ -6050,8 +6050,8 @@ Item* Item_equal::get_first(Item *field_item)
SJ-Mat(it1 it2) ot1 ot2 SJ-Mat(it1 it2) ot1 ot2
and equality ot2.col = ot1.col = it2.col and equality ot2.col = ot1.col = it2.col
If we're looking for best substitute for 'ot2.col', we should pick ot1.col If we're looking for best substitute for 'ot2.col', we should pick
and not it2.col, because when we run a join between ot1 and ot2 ot1.col and not it2.col, because when we run a join between ot1 and ot2
execution of SJ-Mat(...) has already finished and we can't rely on the execution of SJ-Mat(...) has already finished and we can't rely on the
value of it*.*. value of it*.*.
psergey-fix-fix: ^^ THAT IS INCORRECT ^^. Pick the first, whatever that psergey-fix-fix: ^^ THAT IS INCORRECT ^^. Pick the first, whatever that
@ -6074,3 +6074,34 @@ Item* Item_equal::get_first(Item *field_item)
DBUG_ASSERT(0); DBUG_ASSERT(0);
return NULL; return NULL;
} }
longlong Item_func_dyncol_exists::val_int()
{
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
DYNAMIC_COLUMN col;
String *str;
ulonglong num;
enum enum_dyncol_func_result rc;
num= args[1]->val_int();
str= args[0]->val_str(&tmp);
if (args[0]->null_value || args[1]->null_value || num > UINT_MAX16)
goto null;
col.length= str->length();
/* We do not change the string, so could do this trick */
col.str= (char *)str->ptr();
rc= dynamic_column_exists(&col, (uint) num);
if (rc < 0)
{
dynamic_column_error_message(rc);
goto null;
}
null_value= FALSE;
return rc == ER_DYNCOL_YES;
null:
null_value= TRUE;
return 0;
}

View file

@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. /* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1869,3 +1870,11 @@ Item *and_expressions(Item *a, Item *b, Item **org_item);
bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type, bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
const char *warn_name, MYSQL_TIME *l_time); const char *warn_name, MYSQL_TIME *l_time);
class Item_func_dyncol_exists :public Item_bool_func
{
public:
Item_func_dyncol_exists(Item *str, Item *num) :Item_bool_func(str, num) {}
longlong val_int();
const char *func_name() const { return "column_exists"; }
};

View file

@ -25,6 +25,50 @@
#include "sp_head.h" #include "sp_head.h"
#include "sp.h" #include "sp.h"
/*
=============================================================================
HELPER FUNCTIONS
=============================================================================
*/
/*
Get precision and scale for a declaration
return
0 ok
1 error
*/
bool get_length_and_scale(ulonglong length, ulonglong decimals,
ulong *out_length, uint *out_decimals,
uint max_precision, uint max_scale,
const char *name)
{
if (length > (ulonglong) max_precision)
{
my_error(ER_TOO_BIG_PRECISION, MYF(0), (int) length, name,
max_precision);
return 1;
}
if (decimals > (ulonglong) max_scale)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), (int) decimals, name,
DECIMAL_MAX_SCALE);
return 1;
}
*out_length= (ulong) length;
*out_decimals= (uint) decimals;
my_decimal_trim(out_length, out_decimals);
if (*out_length < *out_decimals)
{
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
return 1;
}
return 0;
}
/* /*
============================================================================= =============================================================================
LOCAL DECLARATIONS LOCAL DECLARATIONS
@ -5054,6 +5098,17 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
CHARSET_INFO *cs) CHARSET_INFO *cs)
{ {
Item *UNINIT_VAR(res); Item *UNINIT_VAR(res);
ulonglong length= 0, decimals= 0;
int error;
/*
We don't have to check for error here as sql_yacc.yy has guaranteed
that the values are in range of ulonglong
*/
if (c_len)
length= (ulonglong) my_strtoll10(c_len, NULL, &error);
if (c_dec)
decimals= (ulonglong) my_strtoll10(c_dec, NULL, &error);
switch (cast_type) { switch (cast_type) {
case ITEM_CAST_BINARY: case ITEM_CAST_BINARY:
@ -5076,72 +5131,46 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
break; break;
case ITEM_CAST_DECIMAL: case ITEM_CAST_DECIMAL:
{ {
ulong len= 0; ulong len;
uint dec= 0; uint dec;
if (get_length_and_scale(length, decimals, &len, &dec,
if (c_len) DECIMAL_MAX_PRECISION, DECIMAL_MAX_SCALE,
{ a->name))
ulong decoded_size; return NULL;
errno= 0;
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);
return NULL;
}
len= decoded_size;
}
if (c_dec)
{
ulong decoded_size;
errno= 0;
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);
return NULL;
}
dec= decoded_size;
}
my_decimal_trim(&len, &dec);
if (len < dec)
{
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
return 0;
}
if (len > DECIMAL_MAX_PRECISION)
{
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
DECIMAL_MAX_PRECISION);
return 0;
}
if (dec > DECIMAL_MAX_SCALE)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
DECIMAL_MAX_SCALE);
return 0;
}
res= new (thd->mem_root) Item_decimal_typecast(a, len, dec); res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
break; break;
} }
case ITEM_CAST_DOUBLE:
{
ulong len;
uint dec;
if (!c_len)
{
length= DBL_DIG+7;
decimals= NOT_FIXED_DEC;
}
else if (get_length_and_scale(length, decimals, &len, &dec,
DECIMAL_MAX_PRECISION, NOT_FIXED_DEC-1,
a->name))
return NULL;
res= new (thd->mem_root) Item_double_typecast(a, (uint) length,
(uint) decimals);
break;
}
case ITEM_CAST_CHAR: case ITEM_CAST_CHAR:
{ {
int len= -1; int len= -1;
CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection); CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection);
if (c_len) if (c_len)
{ {
ulong decoded_size; if (length > MAX_FIELD_BLOBLENGTH)
errno= 0;
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; return NULL;
} }
len= (int) decoded_size; len= (int) length;
} }
res= new (thd->mem_root) Item_char_typecast(a, len, real_cs); res= new (thd->mem_root) Item_char_typecast(a, len, real_cs);
break; break;
@ -5155,3 +5184,95 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
} }
return res; return res;
} }
static List<Item> *create_func_dyncol_prepare(THD *thd,
DYNCALL_CREATE_DEF **dfs,
List<DYNCALL_CREATE_DEF> &list)
{
DYNCALL_CREATE_DEF *def;
List_iterator_fast<DYNCALL_CREATE_DEF> li(list);
List<Item> *args= new (thd->mem_root) List<Item>;
*dfs= (DYNCALL_CREATE_DEF *)alloc_root(thd->mem_root,
sizeof(DYNCALL_CREATE_DEF) *
list.elements);
if (!args || !*dfs)
return NULL;
for (uint i= 0; (def= li++) ;)
{
dfs[0][i++]= *def;
args->push_back(def->num);
args->push_back(def->value);
}
return args;
}
Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list)
{
List<Item> *args;
DYNCALL_CREATE_DEF *dfs;
if (!(args= create_func_dyncol_prepare(thd, &dfs, list)))
return NULL;
return new (thd->mem_root) Item_func_dyncol_create(*args, dfs);
}
Item *create_func_dyncol_add(THD *thd, Item *str,
List<DYNCALL_CREATE_DEF> &list)
{
List<Item> *args;
DYNCALL_CREATE_DEF *dfs;
if (!(args= create_func_dyncol_prepare(thd, &dfs, list)))
return NULL;
args->push_back(str);
return new (thd->mem_root) Item_func_dyncol_add(*args, dfs);
}
Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums)
{
DYNCALL_CREATE_DEF *dfs;
Item *num;
List_iterator_fast<Item> it(nums);
List<Item> *args= new (thd->mem_root) List<Item>;
dfs= (DYNCALL_CREATE_DEF *)alloc_root(thd->mem_root,
sizeof(DYNCALL_CREATE_DEF) *
nums.elements);
if (!args || !dfs)
return NULL;
for (uint i= 0; (num= it++); i++)
{
dfs[i].num= num;
dfs[i].value= new Item_null();
dfs[i].type= DYN_COL_INT;
args->push_back(dfs[i].num);
args->push_back(dfs[i].value);
}
args->push_back(str);
return new (thd->mem_root) Item_func_dyncol_add(*args, dfs);
}
Item *create_func_dyncol_get(THD *thd, Item *str, Item *num,
Cast_target cast_type,
const char *c_len, const char *c_dec,
CHARSET_INFO *cs)
{
Item *res;
if (!(res= new (thd->mem_root) Item_dyncol_get(str, num)))
return res; // Return NULL
return create_func_cast(thd, res, cast_type, c_len, c_dec, cs);
}

View file

@ -164,5 +164,15 @@ Item *
create_func_cast(THD *thd, Item *a, Cast_target cast_type, create_func_cast(THD *thd, Item *a, Cast_target cast_type,
const char *len, const char *dec, const char *len, const char *dec,
CHARSET_INFO *cs); CHARSET_INFO *cs);
Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list);
Item *create_func_dyncol_add(THD *thd, Item *str,
List<DYNCALL_CREATE_DEF> &list);
Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums);
Item *create_func_dyncol_get(THD *thd, Item *num, Item *str,
Cast_target cast_type,
const char *c_len, const char *c_dec,
CHARSET_INFO *cs);
#endif #endif

View file

@ -989,14 +989,26 @@ longlong Item_func_signed::val_int()
null_value= args[0]->null_value; null_value= args[0]->null_value;
return value; return value;
} }
else if (args[0]->dynamic_result())
{
/* We come here when argument has an unknown type */
args[0]->unsigned_flag= 0; // Mark that we want to have a signed value
value= args[0]->val_int();
null_value= args[0]->null_value;
if (!null_value && args[0]->unsigned_flag && value < 0)
goto err; // Warn about overflow
return value;
}
value= val_int_from_str(&error); value= val_int_from_str(&error);
if (value < 0 && error == 0) if (value < 0 && error == 0)
{ goto err;
push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, return value;
"Cast to signed converted positive out-of-range integer to "
"it's negative complement"); err:
} push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"Cast to signed converted positive out-of-range integer to "
"it's negative complement");
return value; return value;
} }
@ -1024,19 +1036,36 @@ longlong Item_func_unsigned::val_int()
value= 0; value= 0;
return value; return value;
} }
else if (args[0]->dynamic_result())
{
/* We come here when argument has an unknown type */
args[0]->unsigned_flag= 1; // Mark that we want to have an unsigned value
value= args[0]->val_int();
null_value= args[0]->null_value;
if (!null_value && args[0]->unsigned_flag == 0 && value < 0)
goto err; // Warn about overflow
return value;
}
else if (args[0]->cast_to_int_type() != STRING_RESULT || else if (args[0]->cast_to_int_type() != STRING_RESULT ||
args[0]->result_as_longlong()) args[0]->result_as_longlong())
{ {
value= args[0]->val_int(); value= args[0]->val_int();
null_value= args[0]->null_value; null_value= args[0]->null_value;
if (!null_value && args[0]->unsigned_flag == 0 && value < 0)
goto err; // Warn about overflow
return value; return value;
} }
value= val_int_from_str(&error); value= val_int_from_str(&error);
if (error < 0) if (error < 0)
push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, goto err;
"Cast to unsigned converted negative integer to it's "
"positive complement"); return value;
err:
push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"Cast to unsigned converted negative integer to it's "
"positive complement");
return value; return value;
} }
@ -1134,6 +1163,51 @@ void Item_decimal_typecast::print(String *str, enum_query_type query_type)
} }
double Item_double_typecast::val_real()
{
int error;
double tmp= args[0]->val_real();
if ((null_value= args[0]->null_value))
return 0.0;
if ((error= truncate_double(&tmp, max_length, decimals, 0, DBL_MAX)))
{
push_warning_printf(current_thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
ER(ER_WARN_DATA_OUT_OF_RANGE),
name, 1);
if (error < 0)
{
null_value= 1; // Illegal value
tmp= 0.0;
}
}
return tmp;
}
void Item_double_typecast::print(String *str, enum_query_type query_type)
{
char len_buf[20*3 + 1];
char *end;
str->append(STRING_WITH_LEN("cast("));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as double"));
if (decimals != NOT_FIXED_DEC)
{
str->append('(');
end= int10_to_str(max_length, len_buf,10);
str->append(len_buf, (uint32) (end - len_buf));
str->append(',');
end= int10_to_str(decimals, len_buf,10);
str->append(len_buf, (uint32) (end - len_buf));
str->append(')');
}
str->append(')');
}
double Item_func_plus::real_op() double Item_func_plus::real_op()
{ {
double value= args[0]->val_real() + args[1]->val_real(); double value= args[0]->val_real() + args[1]->val_real();

View file

@ -470,12 +470,29 @@ public:
my_decimal *val_decimal(my_decimal*); my_decimal *val_decimal(my_decimal*);
enum Item_result result_type () const { return DECIMAL_RESULT; } enum Item_result result_type () const { return DECIMAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; } enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
void fix_length_and_dec() {}; void fix_length_and_dec() {}
const char *func_name() const { return "decimal_typecast"; } const char *func_name() const { return "decimal_typecast"; }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
}; };
class Item_double_typecast :public Item_real_func
{
public:
Item_double_typecast(Item *a, int len, int dec) :Item_real_func(a)
{
decimals= dec;
max_length= len;
}
double val_real();
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
void fix_length_and_dec() { maybe_null= 1; }
const char *func_name() const { return "double_typecast"; }
virtual void print(String *str, enum_query_type query_type);
};
class Item_func_additive_op :public Item_num_op class Item_func_additive_op :public Item_num_op
{ {
public: public:
@ -1713,7 +1730,7 @@ enum Cast_target
{ {
ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT, ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR, ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR,
ITEM_CAST_DECIMAL ITEM_CAST_DECIMAL, ITEM_CAST_DOUBLE
}; };
@ -1877,4 +1894,3 @@ public:
return trace_unsupported_by_check_vcol_func_processor(func_name()); return trace_unsupported_by_check_vcol_func_processor(func_name());
} }
}; };

View file

@ -3451,3 +3451,767 @@ String *Item_func_uuid::val_str(String *str)
return str; return str;
} }
Item_func_dyncol_create::Item_func_dyncol_create(List<Item> &args,
DYNCALL_CREATE_DEF *dfs)
: Item_str_func(args), defs(dfs), vals(0), nums(0)
{
DBUG_ASSERT((args.elements & 0x1) == 0); // even number of arguments
}
bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref)
{
bool res= Item_func::fix_fields(thd, ref); // no need Item_str_func here
vals= (DYNAMIC_COLUMN_VALUE *) alloc_root(thd->mem_root,
sizeof(DYNAMIC_COLUMN_VALUE) *
(arg_count / 2));
nums= (uint *) alloc_root(thd->mem_root,
sizeof(uint) * (arg_count / 2));
return res || vals == 0 || nums == 0;
}
void Item_func_dyncol_create::fix_length_and_dec()
{
maybe_null= TRUE;
collation.set(&my_charset_bin);
decimals= 0;
}
void Item_func_dyncol_create::prepare_arguments()
{
char buff[STRING_BUFFER_USUAL_SIZE];
String *res, tmp(buff, sizeof(buff), &my_charset_bin);
uint column_count= (arg_count / 2);
uint i;
my_decimal dtmp, *dres;
/* get values */
for (i= 0; i < column_count; i++)
{
uint valpos= i * 2 + 1;
DYNAMIC_COLUMN_TYPE type= defs[i].type;
if (type == DYN_COL_NULL) // auto detect
{
/*
We don't have a default here to ensure we get a warning if
one adds a new not handled MYSQL_TYPE_...
*/
switch (args[valpos]->field_type()) {
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
type= DYN_COL_DECIMAL;
break;
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:
type= DYN_COL_INT;
break;
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
type= DYN_COL_DOUBLE;
break;
case MYSQL_TYPE_NULL:
type= DYN_COL_NULL;
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
type= DYN_COL_DATETIME;
break;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_NEWDATE:
type= DYN_COL_DATE;
break;
case MYSQL_TYPE_TIME:
type= DYN_COL_TIME;
break;
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
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:
type= DYN_COL_STRING;
break;
}
}
nums[i]= (uint) args[i * 2]->val_int();
vals[i].type= type;
switch (type) {
case DYN_COL_NULL:
DBUG_ASSERT(args[valpos]->field_type() == MYSQL_TYPE_NULL);
break;
case DYN_COL_INT:
vals[i].long_value= args[valpos]->val_int();
break;
case DYN_COL_UINT:
vals[i].ulong_value= args[valpos]->val_int();
break;
case DYN_COL_DOUBLE:
vals[i].double_value= args[valpos]->val_real();
break;
case DYN_COL_STRING:
res= args[valpos]->val_str(&tmp);
if (res &&
(vals[i].string_value.str= my_strndup(res->ptr(), res->length(),
MYF(MY_WME))))
{
vals[i].string_value.length= res->length();
vals[i].charset= res->charset();
}
else
{
args[valpos]->null_value= 1; // In case of out of memory
vals[i].string_value.str= NULL;
vals[i].string_value.length= 0; // just to be safe
}
break;
case DYN_COL_DECIMAL:
if ((dres= args[valpos]->val_decimal(&dtmp)))
{
dynamic_column_prepare_decimal(&vals[i]);
DBUG_ASSERT(vals[i].decimal_value.len == dres->len);
vals[i].decimal_value.intg= dres->intg;
vals[i].decimal_value.frac= dres->frac;
vals[i].decimal_value.sign= dres->sign();
memcpy(vals[i].decimal_buffer, dres->buf,
sizeof(vals[i].decimal_buffer));
}
else
{
dynamic_column_prepare_decimal(&vals[i]); // just to be safe
DBUG_ASSERT(args[valpos]->null_value);
}
break;
case DYN_COL_DATETIME:
args[valpos]->get_date(&vals[i].time_value, TIME_FUZZY_DATE);
break;
case DYN_COL_DATE:
args[valpos]->get_date(&vals[i].time_value, TIME_FUZZY_DATE);
break;
case DYN_COL_TIME:
args[valpos]->get_time(&vals[i].time_value);
break;
default:
DBUG_ASSERT(0);
vals[i].type= DYN_COL_NULL;
}
if (vals[i].type != DYN_COL_NULL && args[valpos]->null_value)
{
if (vals[i].type == DYN_COL_STRING)
my_free(vals[i].string_value.str, MYF(MY_ALLOW_ZERO_PTR));
vals[i].type= DYN_COL_NULL;
}
}
}
void Item_func_dyncol_create::cleanup_arguments()
{
uint column_count= (arg_count / 2);
uint i;
for (i= 0; i < column_count; i++)
{
if (vals[i].type == DYN_COL_STRING)
my_free(vals[i].string_value.str, MYF(MY_ALLOW_ZERO_PTR));
}
}
String *Item_func_dyncol_create::val_str(String *str)
{
DYNAMIC_COLUMN col;
String *res;
uint column_count= (arg_count / 2);
enum enum_dyncol_func_result rc;
DBUG_ASSERT((arg_count & 0x1) == 0); // even number of arguments
prepare_arguments();
if ((rc= dynamic_column_create_many(&col, column_count, nums, vals)))
{
dynamic_column_error_message(rc);
dynamic_column_column_free(&col);
res= NULL;
null_value= TRUE;
}
else
{
/* Move result from DYNAMIC_COLUMN to str_value */
char *ptr;
size_t length, alloc_length;
dynamic_column_reassociate(&col, &ptr, &length, &alloc_length);
str_value.reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_bin);
res= &str_value;
}
/* cleanup */
cleanup_arguments();
return res;
}
void Item_func_dyncol_create::print_arguments(String *str,
enum_query_type query_type)
{
uint i;
uint column_count= (arg_count / 2);
for (i= 0; i < column_count; i++)
{
args[i*2]->print(str, query_type);
str->append(',');
args[i*2 + 1]->print(str, query_type);
switch (defs[i].type) {
case DYN_COL_NULL: // automatic type => write nothing
break;
case DYN_COL_INT:
str->append(STRING_WITH_LEN(" AS int"));
break;
case DYN_COL_UINT:
str->append(STRING_WITH_LEN(" AS unsigned int"));
break;
case DYN_COL_DOUBLE:
str->append(STRING_WITH_LEN(" AS double"));
break;
case DYN_COL_STRING:
str->append(STRING_WITH_LEN(" AS char"));
if (defs[i].cs)
{
str->append(STRING_WITH_LEN(" charset "));
str->append(defs[i].cs->csname);
str->append(' ');
}
break;
case DYN_COL_DECIMAL:
str->append(STRING_WITH_LEN(" AS decimal"));
break;
case DYN_COL_DATETIME:
str->append(STRING_WITH_LEN(" AS datetime"));
break;
case DYN_COL_DATE:
str->append(STRING_WITH_LEN(" AS date"));
break;
case DYN_COL_TIME:
str->append(STRING_WITH_LEN(" AS time"));
break;
}
if (i < column_count - 1)
str->append(',');
}
}
void Item_func_dyncol_create::print(String *str,
enum_query_type query_type)
{
DBUG_ASSERT((arg_count & 0x1) == 0); // even number of arguments
str->append(STRING_WITH_LEN("column_create("));
print_arguments(str, query_type);
str->append(')');
}
String *Item_func_dyncol_add::val_str(String *str)
{
DYNAMIC_COLUMN col;
String *res;
uint column_count= (arg_count / 2);
enum enum_dyncol_func_result rc;
DBUG_ASSERT((arg_count & 0x1) == 1); // odd number of arguments
/* We store the packed data last */
res= args[arg_count - 1]->val_str(str);
if (args[arg_count - 1]->null_value)
goto null;
init_dynamic_string(&col, NULL, res->length() + STRING_BUFFER_USUAL_SIZE,
STRING_BUFFER_USUAL_SIZE);
col.length= res->length();
memcpy(col.str, res->ptr(), col.length);
prepare_arguments();
if ((rc= dynamic_column_update_many(&col, column_count, nums, vals)))
{
dynamic_column_error_message(rc);
dynamic_column_column_free(&col);
cleanup_arguments();
goto null;
}
{
/* Move result from DYNAMIC_COLUMN to str */
char *ptr;
size_t length, alloc_length;
dynamic_column_reassociate(&col, &ptr, &length, &alloc_length);
str->reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_bin);
}
/* cleanup */
dynamic_column_column_free(&col);
cleanup_arguments();
return str;
null:
null_value= TRUE;
return NULL;
}
void Item_func_dyncol_add::print(String *str,
enum_query_type query_type)
{
DBUG_ASSERT((arg_count & 0x1) == 1); // odd number of arguments
str->append(STRING_WITH_LEN("column_create("));
args[arg_count - 1]->print(str, query_type);
str->append(',');
print_arguments(str, query_type);
str->append(')');
}
bool Item_dyncol_get::get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp)
{
DYNAMIC_COLUMN dyn_str;
String *res;
longlong num;
enum enum_dyncol_func_result rc;
num= args[1]->val_int();
if (args[1]->null_value || num < 0 || num > INT_MAX)
{
null_value= 1;
return 1;
}
res= args[0]->val_str(tmp);
if (args[0]->null_value)
{
null_value= 1;
return 1;
}
dyn_str.str= (char*) res->ptr();
dyn_str.length= res->length();
if ((rc= dynamic_column_get(&dyn_str, (uint) num, val)))
{
dynamic_column_error_message(rc);
null_value= 1;
return 1;
}
null_value= 0;
return 0; // ok
}
String *Item_dyncol_get::val_str(String *str_result)
{
DYNAMIC_COLUMN_VALUE val;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
if (get_dyn_value(&val, &tmp))
return NULL;
switch (val.type) {
case DYN_COL_NULL:
goto null;
case DYN_COL_INT:
case DYN_COL_UINT:
str_result->set_int(val.long_value, test(val.type == DYN_COL_UINT),
&my_charset_latin1);
break;
case DYN_COL_DOUBLE:
str_result->set_real(val.double_value, NOT_FIXED_DEC, &my_charset_latin1);
break;
case DYN_COL_STRING:
if ((char*) tmp.ptr() <= val.string_value.str &&
(char*) tmp.ptr() + tmp.length() >= val.string_value.str)
{
/* value is allocated in tmp buffer; We have to make a copy */
str_result->copy(val.string_value.str, val.string_value.length,
val.charset);
}
else
{
/*
It's safe to use the current value because it's either pointing
into a field or in a buffer for another item and this buffer
is not going to be deleted during expression evaluation
*/
str_result->set(val.string_value.str, val.string_value.length,
val.charset);
}
break;
case DYN_COL_DECIMAL:
{
int res;
int length=
my_decimal_string_length((const my_decimal*)&val.decimal_value);
if (str_result->alloc(length))
goto null;
if ((res= decimal2string(&val.decimal_value, (char*) str_result->ptr(),
&length, 0, 0, ' ')) != E_DEC_OK)
{
char buff[40];
int len= sizeof(buff);
DBUG_ASSERT(length < (int)sizeof(buff));
decimal2string(&val.decimal_value, buff, &len, 0, 0, ' ');
decimal_operation_results(res, buff, "CHAR");
}
str_result->set_charset(&my_charset_latin1);
str_result->length(length);
break;
}
case DYN_COL_DATETIME:
case DYN_COL_DATE:
case DYN_COL_TIME:
{
int length;
if (str_result->alloc(MAX_DATE_STRING_REP_LENGTH) ||
!(length= my_TIME_to_str(&val.time_value, (char*) str_result->ptr())))
goto null;
str_result->set_charset(&my_charset_latin1);
str_result->length(length);
break;
}
}
return str_result;
null:
null_value= TRUE;
return 0;
}
longlong Item_dyncol_get::val_int()
{
DYNAMIC_COLUMN_VALUE val;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
if (get_dyn_value(&val, &tmp))
return 0;
switch (val.type) {
case DYN_COL_NULL:
goto null;
case DYN_COL_UINT:
unsigned_flag= 1; // Make it possible for caller to detect sign
return val.long_value;
case DYN_COL_INT:
unsigned_flag= 0; // Make it possible for caller to detect sign
return val.long_value;
case DYN_COL_DOUBLE:
{
bool error;
longlong num;
num= double_to_longlong(val.double_value, unsigned_flag, &error);
if (error)
{
char buff[30];
sprintf(buff, "%lg", val.double_value);
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_DATA_OVERFLOW,
ER(ER_DATA_OVERFLOW),
buff,
unsigned_flag ? "UNSIGNED INT" : "INT");
}
return num;
}
case DYN_COL_STRING:
{
int error;
longlong num;
char *end= val.string_value.str + val.string_value.length, *org_end= end;
num= my_strtoll10(val.string_value.str, &end, &error);
if (end != org_end || error > 0)
{
char buff[80];
strmake(buff, val.string_value.str, min(sizeof(buff)-1,
val.string_value.length));
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_BAD_DATA,
ER(ER_BAD_DATA),
buff,
unsigned_flag ? "UNSIGNED INT" : "INT");
}
unsigned_flag= error >= 0;
return num;
}
case DYN_COL_DECIMAL:
{
longlong num;
my_decimal2int(E_DEC_FATAL_ERROR, &val.decimal_value, unsigned_flag,
&num);
return num;
}
case DYN_COL_DATETIME:
case DYN_COL_DATE:
case DYN_COL_TIME:
unsigned_flag= 1;
return TIME_to_ulonglong(&val.time_value);
}
null:
null_value= TRUE;
return 0;
}
double Item_dyncol_get::val_real()
{
DYNAMIC_COLUMN_VALUE val;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
if (get_dyn_value(&val, &tmp))
return 0.0;
switch (val.type) {
case DYN_COL_NULL:
goto null;
case DYN_COL_UINT:
return ulonglong2double(val.ulong_value);
case DYN_COL_INT:
return (double) val.long_value;
case DYN_COL_DOUBLE:
return (double) val.double_value;
case DYN_COL_STRING:
{
int error;
char *end;
double res= my_strntod(val.charset, (char*) val.string_value.str,
val.string_value.length, &end, &error);
if (end != (char*) val.string_value.str + val.string_value.length ||
error)
{
char buff[80];
strmake(buff, val.string_value.str, min(sizeof(buff)-1,
val.string_value.length));
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_BAD_DATA,
ER(ER_BAD_DATA),
buff, "DOUBLE");
}
return res;
}
case DYN_COL_DECIMAL:
{
double res;
/* This will always succeed */
decimal2double(&val.decimal_value, &res);
return res;
}
case DYN_COL_DATETIME:
case DYN_COL_DATE:
case DYN_COL_TIME:
return (ulonglong2double(TIME_to_ulonglong(&val.time_value)) +
val.time_value.second_part / (double) TIME_SUBSECOND_RANGE);
}
null:
null_value= TRUE;
return 0.0;
}
my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value)
{
DYNAMIC_COLUMN_VALUE val;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
if (get_dyn_value(&val, &tmp))
return NULL;
switch (val.type) {
case DYN_COL_NULL:
goto null;
case DYN_COL_UINT:
int2my_decimal(E_DEC_FATAL_ERROR, val.long_value, TRUE, decimal_value);
break;
case DYN_COL_INT:
int2my_decimal(E_DEC_FATAL_ERROR, val.long_value, FALSE, decimal_value);
break;
case DYN_COL_DOUBLE:
double2my_decimal(E_DEC_FATAL_ERROR, val.double_value, decimal_value);
break;
case DYN_COL_STRING:
{
int rc;
rc= str2my_decimal(0, val.string_value.str, val.string_value.length,
val.charset, decimal_value);
char buff[80];
strmake(buff, val.string_value.str, min(sizeof(buff)-1,
val.string_value.length));
if (rc != E_DEC_OK)
{
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_BAD_DATA,
ER(ER_BAD_DATA),
buff, "DECIMAL");
}
break;
}
case DYN_COL_DECIMAL:
{
int length= STRING_BUFFER_USUAL_SIZE;
decimal2string(&val.decimal_value, buff, &length, 0,0, 0);
decimal2my_decimal(&val.decimal_value, decimal_value);
break;
}
case DYN_COL_DATETIME:
case DYN_COL_DATE:
case DYN_COL_TIME:
{
double tmp= (ulonglong2double(TIME_to_ulonglong(&val.time_value)) +
val.time_value.second_part / (double) TIME_SUBSECOND_RANGE);
/* This can't overflow as time is always in the range of decimal */
double2my_decimal(E_DEC_FATAL_ERROR, tmp, decimal_value);
break;
}
}
return decimal_value;
null:
null_value= TRUE;
return 0;
}
bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DYNAMIC_COLUMN_VALUE val;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
bool signed_value= 0;
if (get_dyn_value(&val, &tmp))
return 0;
switch (val.type) {
case DYN_COL_NULL:
goto null;
case DYN_COL_INT:
signed_value= 1; // For error message
/* fall_trough */
case DYN_COL_UINT:
{
ulonglong num;
int error;
num= val.ulong_value;
number_to_datetime(num, ltime, fuzzy_date, &error);
if (error)
{
char buff[65];
int errnum= error == 2 ? ER_DATA_OVERFLOW : ER_BAD_DATA;
longlong2str(num, buff, signed_value ? -10 : 10, 1);
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
errnum,
ER(errnum),
buff, "DATE or DATETIME");
goto null;
}
return 0;
}
case DYN_COL_DOUBLE:
{
if (double_to_datetime_with_warn(val.double_value, ltime, fuzzy_date))
goto null;
return 0;
}
case DYN_COL_DECIMAL:
if (decimal_to_datetime_with_warn(&val.decimal_value, ltime, fuzzy_date))
goto null;
return 0;
case DYN_COL_STRING:
{
if (str_to_datetime_with_warn(val.string_value.str,
val.string_value.length,
ltime, fuzzy_date) <= MYSQL_TIMESTAMP_ERROR)
goto null;
return 0;
}
case DYN_COL_DATETIME:
case DYN_COL_DATE:
case DYN_COL_TIME:
*ltime= val.time_value;
return 0;
}
null:
null_value= TRUE;
return 1;
}
void Item_dyncol_get::print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN("column_get("));
args[0]->print(str, query_type);
str->append(',');
args[1]->print(str, query_type);
str->append(')');
}
String *Item_func_dyncol_list::val_str(String *str)
{
uint i;
enum enum_dyncol_func_result rc;
DYNAMIC_ARRAY arr;
DYNAMIC_COLUMN col;
String *res= args[0]->val_str(str);
if (args[0]->null_value)
goto null;
col.length= res->length();
/* We do not change the string, so could do this trick */
col.str= (char *)res->ptr();
if ((rc= dynamic_column_list(&col, &arr)))
{
dynamic_column_error_message(rc);
delete_dynamic(&arr);
goto null;
}
/*
We support elements from 0 - 65536, so max size for one element is
6 (including ,).
*/
if (str->alloc(arr.elements * 6))
goto null;
str->length(0);
for (i= 0; i < arr.elements; i++)
{
str->qs_append(*dynamic_element(&arr, i, uint*));
if (i < arr.elements - 1)
str->qs_append(',');
}
delete_dynamic(&arr);
return str;
null:
null_value= TRUE;
return NULL;
}

View file

@ -871,3 +871,71 @@ public:
} }
}; };
class Item_func_dyncol_create: public Item_str_func
{
protected:
DYNCALL_CREATE_DEF *defs;
DYNAMIC_COLUMN_VALUE *vals;
uint *nums;
void prepare_arguments();
void cleanup_arguments();
void print_arguments(String *str, enum_query_type query_type);
public:
Item_func_dyncol_create(List<Item> &args, DYNCALL_CREATE_DEF *dfs);
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const{ return "column_create"; }
String *val_str(String *);
virtual void print(String *str, enum_query_type query_type);
};
class Item_func_dyncol_add: public Item_func_dyncol_create
{
public:
Item_func_dyncol_add(List<Item> &args, DYNCALL_CREATE_DEF *dfs)
:Item_func_dyncol_create(args, dfs)
{}
const char *func_name() const{ return "column_add"; }
String *val_str(String *);
virtual void print(String *str, enum_query_type query_type);
};
/*
The following functions is always called from an Item_cast function
*/
class Item_dyncol_get: public Item_str_func
{
public:
Item_dyncol_get(Item *str, Item *num)
:Item_str_func(str, num)
{
max_length= MAX_FIELD_BLOBLENGTH;
}
void fix_length_and_dec()
{ maybe_null= 1; }
/* Mark that collation can change between calls */
bool dynamic_result() { return 1; }
const char *func_name() const { return "column_get"; }
String *val_str(String *);
longlong val_int();
double val_real();
my_decimal *val_decimal(my_decimal *);
bool get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp);
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
void print(String *str, enum_query_type query_type);
};
class Item_func_dyncol_list: public Item_str_func
{
public:
Item_func_dyncol_list(Item *str) :Item_str_func(str) {};
void fix_length_and_dec() { maybe_null= 1; max_length= MAX_BLOB_WIDTH; };
const char *func_name() const{ return "column_list"; }
String *val_str(String *);
};

View file

@ -1952,7 +1952,10 @@ String *Item_func_date_format::val_str(String *str)
{ {
String *res; String *res;
if (!(res=args[0]->val_str(str)) || if (!(res=args[0]->val_str(str)) ||
(str_to_time_with_warn(res->ptr(), res->length(), &l_time))) (str_to_time_with_warn(res->ptr(), res->length(), &l_time,
current_thd->variables.sql_mode &
(MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
MODE_INVALID_DATES))))
goto null_date; goto null_date;
l_time.year=l_time.month=l_time.day=0; l_time.year=l_time.month=l_time.day=0;
@ -2322,7 +2325,11 @@ longlong Item_extract::val_int()
char buf[40]; char buf[40];
String value(buf, sizeof(buf), &my_charset_bin);; String value(buf, sizeof(buf), &my_charset_bin);;
String *res= args[0]->val_str(&value); String *res= args[0]->val_str(&value);
if (!res || str_to_time_with_warn(res->ptr(), res->length(), &ltime)) if (!res ||
str_to_time_with_warn(res->ptr(), res->length(), &ltime,
current_thd->variables.sql_mode &
(MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
MODE_INVALID_DATES)))
{ {
null_value=1; null_value=1;
return 0; return 0;
@ -2461,10 +2468,15 @@ String *Item_char_typecast::val_str(String *str)
} }
else else
{ {
// Convert character set if differ /*
Convert character set if differ
from_cs is 0 in the case where the result set may vary between calls,
for example with dynamic columns.
*/
uint dummy_errors; uint dummy_errors;
if (!(res= args[0]->val_str(str)) || if (!(res= args[0]->val_str(str)) ||
tmp_value.copy(res->ptr(), res->length(), from_cs, tmp_value.copy(res->ptr(), res->length(),
from_cs ? from_cs : res->charset(),
cast_cs, &dummy_errors)) cast_cs, &dummy_errors))
{ {
null_value= 1; null_value= 1;
@ -2542,15 +2554,19 @@ void Item_char_typecast::fix_length_and_dec()
and thus avoid unnecessary character set conversion. and thus avoid unnecessary character set conversion.
- If the argument is not a number, then from_cs is set to - If the argument is not a number, then from_cs is set to
the argument's charset. the argument's charset.
- If argument has a dynamic collation (can change from call to call)
we set from_cs to 0 as a marker that we have to take the collation
from the result string.
Note (TODO): we could use repertoire technique here. Note (TODO): we could use repertoire technique here.
*/ */
from_cs= (args[0]->result_type() == INT_RESULT || from_cs= ((args[0]->result_type() == INT_RESULT ||
args[0]->result_type() == DECIMAL_RESULT || args[0]->result_type() == DECIMAL_RESULT ||
args[0]->result_type() == REAL_RESULT) ? args[0]->result_type() == REAL_RESULT) ?
(cast_cs->mbminlen == 1 ? cast_cs : &my_charset_latin1) : (cast_cs->mbminlen == 1 ? cast_cs : &my_charset_latin1) :
args[0]->collation.collation; args[0]->dynamic_result() ? 0 :
charset_conversion= (cast_cs->mbmaxlen > 1) || args[0]->collation.collation);
charset_conversion= !from_cs || (cast_cs->mbmaxlen > 1) ||
(!my_charset_same(from_cs, cast_cs) && (!my_charset_same(from_cs, cast_cs) &&
from_cs != &my_charset_bin && from_cs != &my_charset_bin &&
cast_cs != &my_charset_bin); cast_cs != &my_charset_bin);
@ -2604,6 +2620,11 @@ bool Item_time_typecast::get_time(MYSQL_TIME *ltime)
return res; return res;
} }
bool Item_time_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
return get_time(ltime);
}
longlong Item_time_typecast::val_int() longlong Item_time_typecast::val_int()
{ {
@ -2621,7 +2642,7 @@ String *Item_time_typecast::val_str(String *str)
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (!get_arg0_time(&ltime) && if (!get_time(&ltime) &&
!make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY, !make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY,
&ltime, str)) &ltime, str))
return str; return str;

View file

@ -937,6 +937,7 @@ class Item_time_typecast :public Item_typecast_maybe_null
public: public:
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {} Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
const char *func_name() const { return "cast_as_time"; } const char *func_name() const { return "cast_as_time"; }
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
String *val_str(String *str); String *val_str(String *str);
bool get_time(MYSQL_TIME *ltime); bool get_time(MYSQL_TIME *ltime);
const char *cast_type() const { return "time"; } const char *cast_type() const { return "time"; }

View file

@ -116,6 +116,12 @@ static SYMBOL symbols[] = {
{ "COLLATION", SYM(COLLATION_SYM)}, { "COLLATION", SYM(COLLATION_SYM)},
{ "COLUMN", SYM(COLUMN_SYM)}, { "COLUMN", SYM(COLUMN_SYM)},
{ "COLUMNS", SYM(COLUMNS)}, { "COLUMNS", SYM(COLUMNS)},
{ "COLUMN_ADD", SYM(COLUMN_ADD_SYM)},
{ "COLUMN_CREATE", SYM(COLUMN_CREATE_SYM)},
{ "COLUMN_DELETE", SYM(COLUMN_DELETE_SYM)},
{ "COLUMN_EXISTS", SYM(COLUMN_EXISTS_SYM)},
{ "COLUMN_GET", SYM(COLUMN_GET_SYM)},
{ "COLUMN_LIST", SYM(COLUMN_LIST_SYM)},
{ "COMMENT", SYM(COMMENT_SYM)}, { "COMMENT", SYM(COMMENT_SYM)},
{ "COMMIT", SYM(COMMIT_SYM)}, { "COMMIT", SYM(COMMIT_SYM)},
{ "COMMITTED", SYM(COMMITTED_SYM)}, { "COMMITTED", SYM(COMMITTED_SYM)},

View file

@ -30,21 +30,20 @@
result result
*/ */
int decimal_operation_results(int result) int decimal_operation_results(int result, const char *value, const char *type)
{ {
switch (result) { switch (result) {
case E_DEC_OK: case E_DEC_OK:
break; break;
case E_DEC_TRUNCATED: case E_DEC_TRUNCATED:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED), ER_DATA_TRUNCATED, ER(ER_DATA_TRUNCATED),
"", (ulong) 0); value, type);
break; break;
case E_DEC_OVERFLOW: case E_DEC_OVERFLOW:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_TRUNCATED_WRONG_VALUE, ER_DATA_OVERFLOW, ER(ER_DATA_OVERFLOW),
ER(ER_TRUNCATED_WRONG_VALUE), value, type);
"DECIMAL", "");
break; break;
case E_DEC_DIV_ZERO: case E_DEC_DIV_ZERO:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
@ -52,9 +51,8 @@ int decimal_operation_results(int result)
break; break;
case E_DEC_BAD_NUM: case E_DEC_BAD_NUM:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, ER_BAD_DATA, ER(ER_BAD_DATA),
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), value, type);
"decimal", "", "", (ulong) 0);
break; break;
case E_DEC_OOM: case E_DEC_OOM:
my_error(ER_OUT_OF_RESOURCES, MYF(0)); my_error(ER_OUT_OF_RESOURCES, MYF(0));
@ -237,6 +235,34 @@ void my_decimal_trim(ulong *precision, uint *scale)
} }
/*
Convert a decimal to an ulong with a descreptive error message
*/
int my_decimal2int(uint mask, const decimal_t *d, bool unsigned_flag,
longlong *l)
{
int res;
my_decimal rounded;
/* decimal_round can return only E_DEC_TRUNCATED */
decimal_round(d, &rounded, 0, HALF_UP);
res= (unsigned_flag ?
decimal2ulonglong(&rounded, (ulonglong *) l) :
decimal2longlong(&rounded, l));
if (res & mask)
{
char buff[DECIMAL_MAX_STR_LENGTH];
int length= sizeof(buff);
decimal2string(d, buff, &length, 0, 0, 0);
decimal_operation_results(res, buff,
unsigned_flag ? "UNSIGNED INT" :
"INT");
}
return res;
}
#ifndef DBUG_OFF #ifndef DBUG_OFF
/* routines for debugging print */ /* routines for debugging print */
@ -283,7 +309,6 @@ const char *dbug_decimal_as_string(char *buff, const my_decimal *val)
return buff; return buff;
} }
#endif /*DBUG_OFF*/ #endif /*DBUG_OFF*/
#endif /*MYSQL_CLIENT*/ #endif /*MYSQL_CLIENT*/

View file

@ -32,32 +32,7 @@ C_MODE_START
#include <decimal.h> #include <decimal.h>
C_MODE_END C_MODE_END
#define DECIMAL_LONGLONG_DIGITS 22 #include <my_decimal_limits.h>
#define DECIMAL_LONG_DIGITS 10
#define DECIMAL_LONG3_DIGITS 8
/** maximum length of buffer in our big digits (uint32). */
#define DECIMAL_BUFF_LENGTH 9
/* the number of digits that my_decimal can possibly contain */
#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
/**
maximum guaranteed precision of number in decimal digits (number of our
digits * number of decimal digits in one our big digit - number of decimal
digits in one our big digit decreased by 1 (because we always put decimal
point on the border of our big digits))
*/
#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
#define DECIMAL_MAX_SCALE 30
#define DECIMAL_NOT_SPECIFIED 31
/**
maximum length of string representation (number of maximum decimal
digits + 1 position for sign + 1 position for decimal point)
*/
#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
/** /**
maximum size of packet length. maximum size of packet length.
@ -134,9 +109,10 @@ const char *dbug_decimal_as_string(char *buff, const my_decimal *val);
#endif #endif
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
int decimal_operation_results(int result); int decimal_operation_results(int result, const char *value, const char *type);
#else #else
inline int decimal_operation_results(int result) inline int decimal_operation_results(int result, const char *value,
const char *type)
{ {
return result; return result;
} }
@ -158,7 +134,7 @@ inline void max_internal_decimal(my_decimal *to)
inline int check_result(uint mask, int result) inline int check_result(uint mask, int result)
{ {
if (result & mask) if (result & mask)
decimal_operation_results(result); decimal_operation_results(result, "", "DECIMAL");
return result; return result;
} }
@ -294,24 +270,14 @@ int my_decimal2string(uint mask, const my_decimal *d, uint fixed_prec,
uint fixed_dec, char filler, String *str); uint fixed_dec, char filler, String *str);
#endif #endif
inline int my_decimal2int(uint mask, const decimal_t *d, bool unsigned_flag,
int my_decimal2int(uint mask, const my_decimal *d, my_bool unsigned_flag, longlong *l);
longlong *l)
{
my_decimal rounded;
/* decimal_round can return only E_DEC_TRUNCATED */
decimal_round((decimal_t*)d, &rounded, 0, HALF_UP);
return check_result(mask, (unsigned_flag ?
decimal2ulonglong(&rounded, (ulonglong *)l) :
decimal2longlong(&rounded, l)));
}
inline inline
int my_decimal2double(uint, const my_decimal *d, double *result) int my_decimal2double(uint, const decimal_t *d, double *result)
{ {
/* No need to call check_result as this will always succeed */ /* No need to call check_result as this will always succeed */
return decimal2double((decimal_t*) d, result); return decimal2double(d, result);
} }
@ -354,6 +320,16 @@ int int2my_decimal(uint mask, longlong i, my_bool unsigned_flag, my_decimal *d)
longlong2decimal(i, d))); longlong2decimal(i, d)));
} }
inline
void decimal2my_decimal(decimal_t *from, my_decimal *to)
{
DBUG_ASSERT(to->len >= from->len);
to->intg= from->intg;
to->frac= from->frac;
to->sign(from->sign);
memcpy(to->buf, from->buf, to->len*sizeof(decimal_digit_t));
}
inline inline
void my_decimal_neg(decimal_t *arg) void my_decimal_neg(decimal_t *arg)
@ -417,7 +393,6 @@ int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
res); res);
} }
/** /**
@return @return
-1 if a<b, 1 if a>b and 0 if a==b -1 if a<b, 1 if a>b and 0 if a==b

View file

@ -1412,6 +1412,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
Field * Field *
find_field_in_table_sef(TABLE *table, const char *name); find_field_in_table_sef(TABLE *table, const char *name);
int update_virtual_fields(THD *thd, TABLE *table, bool ignore_stored= FALSE); int update_virtual_fields(THD *thd, TABLE *table, bool ignore_stored= FALSE);
int dynamic_column_error_message(enum_dyncol_func_result rc);
#endif /* MYSQL_SERVER */ #endif /* MYSQL_SERVER */
@ -2322,16 +2323,22 @@ ulong convert_month_to_period(ulong month);
void get_date_from_daynr(long daynr,uint *year, uint *month, void get_date_from_daynr(long daynr,uint *year, uint *month,
uint *day); uint *day);
my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist); my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist);
bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time); bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time,
ulong fuzzydate);
timestamp_type str_to_datetime_with_warn(const char *str, uint length, timestamp_type str_to_datetime_with_warn(const char *str, uint length,
MYSQL_TIME *l_time, uint flags); MYSQL_TIME *l_time, ulong flags);
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds); void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, void make_truncated_value_warning(THD *thd,
MYSQL_ERROR::enum_warning_level level,
const char *str_val, const char *str_val,
uint str_length, timestamp_type time_type, uint str_length, timestamp_type time_type,
const char *field_name); const char *field_name);
bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
ulong fuzzy_date);
bool decimal_to_datetime_with_warn(decimal_t *value, MYSQL_TIME *ltime,
ulong fuzzy_date);
bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval); bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,

View file

@ -5321,7 +5321,7 @@ ER_NO_DEFAULT_FOR_FIELD
ER_DIVISION_BY_ZERO 22012 ER_DIVISION_BY_ZERO 22012
eng "Division by 0" eng "Division by 0"
ger "Division durch 0" ger "Division durch 0"
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD ER_TRUNCATED_WRONG_VALUE_FOR_FIELD 22007
eng "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %lu" eng "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %lu"
ger "Falscher %-.32s-Wert: '%-.128s' für Feld '%.192s' in Zeile %lu" ger "Falscher %-.32s-Wert: '%-.128s' für Feld '%.192s' in Zeile %lu"
ER_ILLEGAL_VALUE_FOR_TYPE 22007 ER_ILLEGAL_VALUE_FOR_TYPE 22007
@ -6251,4 +6251,17 @@ ER_BAD_OPTION_VALUE
eng "Incorrect value '%-.64s' for option '%-.64s'" eng "Incorrect value '%-.64s' for option '%-.64s'"
ER_CANT_DO_ONLINE ER_CANT_DO_ONLINE
eng "Can't execute the given '%s' command as online" eng "Can't execute the given '%s' command as online"
ER_DATA_OVERFLOW 22003
eng "Got overflow when converting '%-.128s' to %-.32s. Value truncated."
ER_DATA_TRUNCATED 22003
eng "Truncated value '%-.128s' when converting to %-.32s"
ER_BAD_DATA 22007
eng "Encountered illegal value '%-.128s' when converting to %-.32s"
ER_DYN_COL_WRONG_FORMAT
eng "Encountered illegal format of dynamic column string"
ER_DYN_COL_IMPLEMENTATION_LIMIT
eng "Dynamic column implementation limit reached"
ER_DYN_COL_DATA 22007
eng "Illegal value used as argument of dynamic column function"
ER_DYN_COL_WRONG_CHARSET
eng "Dynamic column contains unknown character set"

View file

@ -7999,7 +7999,8 @@ static int do_auth_once(THD *thd, LEX_STRING *auth_plugin_name,
@retval 1 error @retval 1 error
*/ */
bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_len) bool acl_authenticate(THD *thd, uint connect_errors,
uint com_change_user_pkt_len)
{ {
int res= CR_OK; int res= CR_OK;
MPVIO_EXT mpvio; MPVIO_EXT mpvio;

View file

@ -9406,6 +9406,40 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
thd->restore_backup_open_tables_state(backup); thd->restore_backup_open_tables_state(backup);
} }
/**
Check result of dynamic column function and issue error if it is needed
@param rc The result code of dynamic column function
@return the result code which was get as an argument\
*/
int dynamic_column_error_message(enum_dyncol_func_result rc)
{
switch (rc) {
case ER_DYNCOL_YES:
case ER_DYNCOL_OK:
break; // it is not an error
case ER_DYNCOL_FORMAT:
my_error(ER_DYN_COL_WRONG_FORMAT, MYF(0));
break;
case ER_DYNCOL_LIMIT:
my_error(ER_DYN_COL_IMPLEMENTATION_LIMIT, MYF(0));
break;
case ER_DYNCOL_RESOURCE:
my_error(ER_OUT_OF_RESOURCES, MYF(0));
break;
case ER_DYNCOL_DATA:
my_error(ER_DYN_COL_DATA, MYF(0));
break;
case ER_DYNCOL_UNKNOWN_CHARSET:
my_error(ER_DYN_COL_WRONG_CHARSET, MYF(0));
break;
}
return rc;
}
/** /**
@} (end of group Data_Dictionary) @} (end of group Data_Dictionary)
*/ */

View file

@ -176,6 +176,18 @@ public:
{ return set_int((longlong)num, true, cs); } { return set_int((longlong)num, true, cs); }
bool set_real(double num,uint decimals, CHARSET_INFO *cs); bool set_real(double num,uint decimals, CHARSET_INFO *cs);
/* Move handling of buffer from some other object to String */
void reassociate(char *ptr, uint32 length, uint32 alloced_length,
CHARSET_INFO *cs)
{
free();
Ptr= ptr;
str_length= length;
Alloced_length= alloced_length;
str_charset= cs;
alloced= ptr != 0;
}
/* /*
PMG 2004.11.12 PMG 2004.11.12
This is a method that works the same as perl's "chop". It simply This is a method that works the same as perl's "chop". It simply

View file

@ -34,6 +34,7 @@
#define YYINITDEPTH 100 #define YYINITDEPTH 100
#define YYMAXDEPTH 3200 /* Because of 64K stack */ #define YYMAXDEPTH 3200 /* Because of 64K stack */
#define Lex (YYTHD->lex) #define Lex (YYTHD->lex)
#define Select Lex->current_select #define Select Lex->current_select
#include "mysql_priv.h" #include "mysql_priv.h"
#include "slave.h" #include "slave.h"
@ -671,6 +672,8 @@ static bool add_create_index (LEX *lex, Key::Keytype type, const char *name,
sp_head *sphead; sp_head *sphead;
struct p_elem_val *p_elem_value; struct p_elem_val *p_elem_value;
enum index_hint_type index_hint; enum index_hint_type index_hint;
DYNCALL_CREATE_DEF *dyncol_def;
List<DYNCALL_CREATE_DEF> *dyncol_def_list;
} }
%{ %{
@ -770,6 +773,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token COLLATE_SYM /* SQL-2003-R */ %token COLLATE_SYM /* SQL-2003-R */
%token COLLATION_SYM /* SQL-2003-N */ %token COLLATION_SYM /* SQL-2003-N */
%token COLUMNS %token COLUMNS
%token COLUMN_ADD_SYM
%token COLUMN_CREATE_SYM
%token COLUMN_DELETE_SYM
%token COLUMN_EXISTS_SYM
%token COLUMN_GET_SYM
%token COLUMN_LIST_SYM
%token COLUMN_SYM /* SQL-2003-R */ %token COLUMN_SYM /* SQL-2003-R */
%token COMMENT_SYM %token COMMENT_SYM
%token COMMITTED_SYM /* SQL-2003-N */ %token COMMITTED_SYM /* SQL-2003-N */
@ -1338,7 +1347,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_natural_language_mode opt_query_expansion opt_natural_language_mode opt_query_expansion
opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment
ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt
optional_flush_tables_arguments optional_flush_tables_arguments opt_dyncol_type dyncol_type
%type <ulong_num> %type <ulong_num>
ulong_num real_ulong_num merge_insert_types ulong_num real_ulong_num merge_insert_types
@ -1438,6 +1447,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <boolfunc2creator> comp_op %type <boolfunc2creator> comp_op
%type <dyncol_def> dyncall_create_element
%type <dyncol_def_list> dyncall_create_list
%type <NONE> %type <NONE>
query verb_clause create change select do drop insert replace insert2 query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename insert_values update delete truncate rename
@ -7506,6 +7519,131 @@ all_or_any:
| ANY_SYM { $$ = 0; } | ANY_SYM { $$ = 0; }
; ;
opt_dyncol_type:
/* empty */
{
LEX *lex= Lex;
$$= DYN_COL_NULL; /* automatic type */
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| AS dyncol_type { $$= $2; }
;
dyncol_type:
INT_SYM
{
LEX *lex= Lex;
$$= DYN_COL_INT;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| UNSIGNED INT_SYM
{
LEX *lex= Lex;
$$= DYN_COL_UINT;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| DOUBLE_SYM
{
LEX *lex= Lex;
$$= DYN_COL_DOUBLE;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| REAL
{
LEX *lex= Lex;
$$= DYN_COL_DOUBLE;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| FLOAT_SYM
{
LEX *lex= Lex;
$$= DYN_COL_DOUBLE;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| DECIMAL_SYM float_options
{
$$= DYN_COL_DECIMAL;
Lex->charset= NULL;
}
| char opt_binary
{
LEX *lex= Lex;
$$= DYN_COL_STRING;
lex->length= lex->dec= 0;
}
| nchar
{
LEX *lex= Lex;
$$= DYN_COL_STRING;
lex->charset= national_charset_info;
lex->length= lex->dec= 0;
}
| DATE_SYM
{
LEX *lex= Lex;
$$= DYN_COL_DATE;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| TIME_SYM
{
LEX *lex= Lex;
$$= DYN_COL_TIME;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
| DATETIME
{
LEX *lex= Lex;
$$= DYN_COL_DATETIME;
lex->charset= NULL;
lex->length= lex->dec= 0;
}
;
dyncall_create_element:
expr ',' expr opt_dyncol_type
{
LEX *lex= Lex;
$$= (DYNCALL_CREATE_DEF *)
alloc_root(YYTHD->mem_root, sizeof(DYNCALL_CREATE_DEF));
if ($$ == NULL)
MYSQL_YYABORT;
$$->num= $1;
$$->value= $3;
$$->type= (DYNAMIC_COLUMN_TYPE)$4;
$$->cs= lex->charset;
if (lex->length)
$$->len= strtoul(lex->length, NULL, 10);
else
$$->len= 0;
if (lex->dec)
$$->frac= strtoul(lex->dec, NULL, 10);
else
$$->len= 0;
}
dyncall_create_list:
dyncall_create_element
{
$$= new (YYTHD->mem_root) List<DYNCALL_CREATE_DEF>;
if ($$ == NULL)
MYSQL_YYABORT;
$$->push_back($1);
}
| dyncall_create_list ',' dyncall_create_element
{
$1->push_back($3);
$$= $1;
}
;
simple_expr: simple_expr:
simple_ident simple_ident
| function_call_keyword | function_call_keyword
@ -8040,6 +8178,51 @@ function_call_nonkeyword:
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->safe_to_cache_query=0; Lex->safe_to_cache_query=0;
} }
|
COLUMN_ADD_SYM '(' expr ',' dyncall_create_list ')'
{
$$= create_func_dyncol_add(YYTHD, $3, *$5);
if ($$ == NULL)
MYSQL_YYABORT;
}
|
COLUMN_DELETE_SYM '(' expr ',' expr_list ')'
{
$$= create_func_dyncol_delete(YYTHD, $3, *$5);
if ($$ == NULL)
MYSQL_YYABORT;
}
|
COLUMN_EXISTS_SYM '(' expr ',' expr ')'
{
$$= new (YYTHD->mem_root) Item_func_dyncol_exists($3, $5);
if ($$ == NULL)
MYSQL_YYABORT;
}
|
COLUMN_LIST_SYM '(' expr ')'
{
$$= new (YYTHD->mem_root) Item_func_dyncol_list($3);
if ($$ == NULL)
MYSQL_YYABORT;
}
|
COLUMN_CREATE_SYM '(' dyncall_create_list ')'
{
$$= create_func_dyncol_create(YYTHD, *$3);
if ($$ == NULL)
MYSQL_YYABORT;
}
|
COLUMN_GET_SYM '(' expr ',' expr AS cast_type ')'
{
LEX *lex= Lex;
$$= create_func_dyncol_get(YYTHD, $3, $5, $7,
lex->length, lex->dec,
lex->charset);
if ($$ == NULL)
MYSQL_YYABORT;
}
; ;
/* /*
@ -8641,6 +8824,8 @@ cast_type:
{ $$=ITEM_CAST_CHAR; Lex->dec= 0; } { $$=ITEM_CAST_CHAR; Lex->dec= 0; }
| NCHAR_SYM opt_field_length | NCHAR_SYM opt_field_length
{ $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; Lex->dec=0; } { $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; Lex->dec=0; }
| INT_SYM
{ $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
| SIGNED_SYM | SIGNED_SYM
{ $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
| SIGNED_SYM INT_SYM | SIGNED_SYM INT_SYM
@ -8657,7 +8842,10 @@ cast_type:
{ $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
| DECIMAL_SYM float_options | DECIMAL_SYM float_options
{ $$=ITEM_CAST_DECIMAL; Lex->charset= NULL; } { $$=ITEM_CAST_DECIMAL; Lex->charset= NULL; }
; | DOUBLE_SYM
{ Lex->charset= NULL; Lex->length= Lex->dec= 0;}
opt_precision
{ $$=ITEM_CAST_DOUBLE; }
opt_expr_list: opt_expr_list:
/* empty */ { $$= NULL; } /* empty */ { $$= NULL; }
@ -11887,6 +12075,12 @@ keyword:
| CHECKSUM_SYM {} | CHECKSUM_SYM {}
| CHECKPOINT_SYM {} | CHECKPOINT_SYM {}
| CLOSE_SYM {} | CLOSE_SYM {}
| COLUMN_ADD_SYM {}
| COLUMN_CREATE_SYM {}
| COLUMN_DELETE_SYM {}
| COLUMN_EXISTS_SYM {}
| COLUMN_GET_SYM {}
| COLUMN_LIST_SYM {}
| COMMENT_SYM {} | COMMENT_SYM {}
| COMMIT_SYM {} | COMMIT_SYM {}
| CONTAINS_SYM {} | CONTAINS_SYM {}

View file

@ -223,7 +223,7 @@ ulong convert_month_to_period(ulong month)
timestamp_type timestamp_type
str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time, str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time,
uint flags) ulong flags)
{ {
int was_cut; int was_cut;
THD *thd= current_thd; THD *thd= current_thd;
@ -232,15 +232,42 @@ str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time,
ts_type= str_to_datetime(str, length, l_time, ts_type= str_to_datetime(str, length, l_time,
(flags | (thd->variables.sql_mode & (flags | (thd->variables.sql_mode &
(MODE_INVALID_DATES | (MODE_INVALID_DATES |
MODE_NO_ZERO_IN_DATE |
MODE_NO_ZERO_DATE))), MODE_NO_ZERO_DATE))),
&was_cut); &was_cut);
if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR) if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR)
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
str, length, ts_type, NullS); str, length, ts_type, NullS);
return ts_type; return ts_type;
} }
bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
ulong fuzzydate)
{
if (double_to_datetime(value, ltime, fuzzydate))
{
char buff[40];
uint length= my_sprintf(buff, (buff, "%-30.21g", value));
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buff, length, MYSQL_TIMESTAMP_DATETIME,
NullS);
return 1;
}
return 0;
}
bool decimal_to_datetime_with_warn(decimal_t *value, MYSQL_TIME *ltime,
ulong fuzzydate)
{
char buff[40];
int length= sizeof(buff);
decimal2string(value, buff, &length, 0, 0, 0);
return (str_to_datetime_with_warn(buff, length, ltime, fuzzydate) <=
MYSQL_TIMESTAMP_ERROR);
}
/* /*
Convert a datetime from broken-down MYSQL_TIME representation to corresponding Convert a datetime from broken-down MYSQL_TIME representation to corresponding
TIMESTAMP value. TIMESTAMP value.
@ -284,10 +311,11 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_
See str_to_time() for more info. See str_to_time() for more info.
*/ */
bool bool
str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time) str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time,
ulong fuzzydate)
{ {
int warning; int warning;
bool ret_val= str_to_time(str, length, l_time, &warning); bool ret_val= str_to_time(str, length, l_time, fuzzydate, &warning);
if (ret_val || warning) if (ret_val || warning)
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
str, length, MYSQL_TIMESTAMP_TIME, NullS); str, length, MYSQL_TIMESTAMP_TIME, NullS);
@ -719,7 +747,8 @@ void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)),
} }
void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, void make_truncated_value_warning(THD *thd,
MYSQL_ERROR::enum_warning_level level,
const char *str_val, const char *str_val,
uint str_length, timestamp_type time_type, uint str_length, timestamp_type time_type,
const char *field_name) const char *field_name)
@ -763,6 +792,7 @@ void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level leve
ER_TRUNCATED_WRONG_VALUE, warn_buff); ER_TRUNCATED_WRONG_VALUE, warn_buff);
} }
/* Daynumber from year 0 to 9999-12-31 */ /* Daynumber from year 0 to 9999-12-31 */
#define MAX_DAY_NUMBER 3652424L #define MAX_DAY_NUMBER 3652424L

View file

@ -255,7 +255,7 @@ void max_decimal(int precision, int frac, decimal_t *to)
} }
static dec1 *remove_leading_zeroes(decimal_t *from, int *intg_result) static dec1 *remove_leading_zeroes(const decimal_t *from, int *intg_result)
{ {
int intg= from->intg, i; int intg= from->intg, i;
dec1 *buf0= from->buf; dec1 *buf0= from->buf;
@ -333,7 +333,7 @@ int decimal_actual_fraction(decimal_t *from)
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
*/ */
int decimal2string(decimal_t *from, char *to, int *to_len, int decimal2string(const decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals, int fixed_precision, int fixed_decimals,
char filler) char filler)
{ {
@ -949,7 +949,7 @@ fatal_error:
E_DEC_OK E_DEC_OK
*/ */
int decimal2double(decimal_t *from, double *to) int decimal2double(const decimal_t *from, double *to)
{ {
double result= 0.0; double result= 0.0;
int i, exp= 0; int i, exp= 0;
@ -1041,7 +1041,7 @@ int longlong2decimal(longlong from, decimal_t *to)
return ull2dec(from, to); return ull2dec(from, to);
} }
int decimal2ulonglong(decimal_t *from, ulonglong *to) int decimal2ulonglong(const decimal_t *from, ulonglong *to)
{ {
dec1 *buf=from->buf; dec1 *buf=from->buf;
ulonglong x=0; ulonglong x=0;
@ -1070,7 +1070,7 @@ int decimal2ulonglong(decimal_t *from, ulonglong *to)
return E_DEC_OK; return E_DEC_OK;
} }
int decimal2longlong(decimal_t *from, longlong *to) int decimal2longlong(const decimal_t *from, longlong *to)
{ {
dec1 *buf=from->buf; dec1 *buf=from->buf;
longlong x=0; longlong x=0;
@ -1189,7 +1189,7 @@ int decimal2longlong(decimal_t *from, longlong *to)
7E F2 04 37 2D FB 2D 7E F2 04 37 2D FB 2D
*/ */
int decimal2bin(decimal_t *from, uchar *to, int precision, int frac) int decimal2bin(const decimal_t *from, uchar *to, int precision, int frac)
{ {
dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1; dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1;
int error=E_DEC_OK, intg=precision-frac, int error=E_DEC_OK, intg=precision-frac,
@ -1479,7 +1479,7 @@ int decimal_bin_size(int precision, int scale)
*/ */
int int
decimal_round(decimal_t *from, decimal_t *to, int scale, decimal_round(const decimal_t *from, decimal_t *to, int scale,
decimal_round_mode mode) decimal_round_mode mode)
{ {
int frac0=scale>0 ? ROUND_UP(scale) : scale/DIG_PER_DEC1, int frac0=scale>0 ? ROUND_UP(scale) : scale/DIG_PER_DEC1,

View file

@ -25,4 +25,4 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
EXTRA_DIST = CMakeLists.txt EXTRA_DIST = CMakeLists.txt
noinst_PROGRAMS = bitmap-t base64-t my_atomic-t lf-t waiting_threads-t \ noinst_PROGRAMS = bitmap-t base64-t my_atomic-t lf-t waiting_threads-t \
my_vsnprintf-t my_vsnprintf-t ma_dyncol-t

View file

@ -0,0 +1,795 @@
/* Copyright (c) 2011, Monty Program Ab
Copyright (c) 2011, Oleksandr Byelkin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <ma_dyncol.h>
#include <tap.h>
void test_value_single_null()
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_NULL;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_NULL);
err:
ok(rc, "%s", "NULL");
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_single_uint(ulonglong num, const char *name)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_UINT;
val.ulong_value= num;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_UINT) && (res.ulong_value == num);
num= res.ulong_value;
err:
ok(rc, "%s - %llu", name, num);
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_single_sint(longlong num, const char *name)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_INT;
val.long_value= num;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_INT) && (res.long_value == num);
num= res.ulong_value;
err:
ok(rc, "%s - %lld", name, num);
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_single_double(double num, const char *name)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_DOUBLE;
val.double_value= num;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_DOUBLE) && (res.double_value == num);
num= res.ulong_value;
err:
ok(rc, "%s - %lf", name, num);
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_single_decimal(const char *num)
{
char *end= (((char*)num) + strlen(num));
char buff[80];
int rc= FALSE;
int length= 80;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
dynamic_column_prepare_decimal(&val); // special procedure for decimal!!!
if (string2decimal(num, &val.decimal_value, &end) != E_DEC_OK)
goto err;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_DECIMAL) &&
(decimal_cmp(&res.decimal_value, &val.decimal_value) == 0));
decimal2string(&res.decimal_value, buff, &length, 0, 0, ' ');
err:
ok(rc, "%s - %s", num, buff);
/* cleanup */
dynamic_column_column_free(&str);
}
static CHARSET_INFO *charset_list[]=
{
#ifdef HAVE_CHARSET_big5
&my_charset_big5_chinese_ci,
&my_charset_big5_bin,
#endif
#ifdef HAVE_CHARSET_euckr
&my_charset_euckr_korean_ci,
&my_charset_euckr_bin,
#endif
#ifdef HAVE_CHARSET_gb2312
&my_charset_gb2312_chinese_ci,
&my_charset_gb2312_bin,
#endif
#ifdef HAVE_CHARSET_gbk
&my_charset_gbk_chinese_ci,
&my_charset_gbk_bin,
#endif
#ifdef HAVE_CHARSET_latin1
&my_charset_latin1,
&my_charset_latin1_bin,
#endif
#ifdef HAVE_CHARSET_sjis
&my_charset_sjis_japanese_ci,
&my_charset_sjis_bin,
#endif
#ifdef HAVE_CHARSET_tis620
&my_charset_tis620_thai_ci,
&my_charset_tis620_bin,
#endif
#ifdef HAVE_CHARSET_ujis
&my_charset_ujis_japanese_ci,
&my_charset_ujis_bin,
#endif
#ifdef HAVE_CHARSET_utf8
&my_charset_utf8_general_ci,
#ifdef HAVE_HAVE_UCA_COLLATIONS
&my_charset_utf8_unicode_ci,
#endif
&my_charset_utf8_bin,
#endif
};
void test_value_single_string(const char *string, size_t len,
CHARSET_INFO *cs)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_STRING;
val.string_value.str= (char*)string;
val.string_value.length= len;
val.charset= cs;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_STRING) &&
(res.string_value.length == len) &&
(memcmp(res.string_value.str, string, len) == 0) &&
(res.charset->number == cs->number));
err:
ok(rc, "'%s' - '%s' %u %u-%s", string,
res.string_value.str, (uint)res.string_value.length,
(uint)res.charset->number, res.charset->name);
/* cleanup */
val.string_value.str= NULL; // we did not allocated it
dynamic_column_column_free(&str);
}
void test_value_single_date(uint year, uint month, uint day, const char *name)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_DATE;
val.time_value.time_type= MYSQL_TIMESTAMP_DATE;
val.time_value.year= year;
val.time_value.month= month;
val.time_value.day= day;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_DATE) &&
(res.time_value.time_type == MYSQL_TIMESTAMP_DATE) &&
(res.time_value.year == year) &&
(res.time_value.month == month) &&
(res.time_value.day == day));
err:
ok(rc, "%s - %04u-%02u-%02u", name, year, month, day);
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_single_time(uint neg, uint hour, uint minute, uint second,
uint mic, const char *name)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_TIME;
val.time_value.time_type= MYSQL_TIMESTAMP_TIME;
val.time_value.neg= neg;
val.time_value.hour= hour;
val.time_value.minute= minute;
val.time_value.second= second;
val.time_value.second_part= mic;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_TIME) &&
(res.time_value.time_type == MYSQL_TIMESTAMP_TIME) &&
(res.time_value.neg == (int)neg) &&
(res.time_value.hour == hour) &&
(res.time_value.minute == minute) &&
(res.time_value.second == second) &&
(res.time_value.second_part == mic));
err:
ok(rc, "%s - %c%02u:%02u:%02u.%06u", name, (neg ? '-' : '+'),
hour, minute, second, mic);
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_single_datetime(uint neg, uint year, uint month, uint day,
uint hour, uint minute, uint second,
uint mic, const char *name)
{
int rc= FALSE;
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_DATETIME;
val.time_value.time_type= MYSQL_TIMESTAMP_DATETIME;
val.time_value.neg= neg;
val.time_value.year= year;
val.time_value.month= month;
val.time_value.day= day;
val.time_value.hour= hour;
val.time_value.minute= minute;
val.time_value.second= second;
val.time_value.second_part= mic;
dynamic_column_value_init(&res);
/* create column */
if (dynamic_column_create(&str, 1, &val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
if (dynamic_column_get(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_DATETIME) &&
(res.time_value.time_type == MYSQL_TIMESTAMP_DATETIME) &&
(res.time_value.neg == (int)neg) &&
(res.time_value.year == year) &&
(res.time_value.month == month) &&
(res.time_value.day == day) &&
(res.time_value.hour == hour) &&
(res.time_value.minute == minute) &&
(res.time_value.second == second) &&
(res.time_value.second_part == mic));
err:
ok(rc, "%s - %c %04u-%02u-%02u %02u:%02u:%02u.%06u", name, (neg ? '-' : '+'),
year, month, day, hour, minute, second, mic);
/* cleanup */
dynamic_column_column_free(&str);
}
void test_value_multi(ulonglong num0,
longlong num1,
double num2,
const char *num3,
const char *string4, size_t len4, CHARSET_INFO *cs4,
uint year5, uint month5, uint day5,
uint neg6, uint hour6, uint minute6,
uint second6, uint mic6,
uint neg7, uint year7, uint month7, uint day7,
uint hour7, uint minute7, uint second7,
uint mic7,
uint *column_numbers,
const char *name)
{
char *end3= (((char*)num3) + strlen(num3));
int rc= FALSE;
uint i;
DYNAMIC_COLUMN_VALUE val[9], res[9];
DYNAMIC_COLUMN str;
/* init values */
val[0].type= DYN_COL_UINT;
val[0].ulong_value= num0;
val[1].type= DYN_COL_INT;
val[1].long_value= num1;
val[2].type= DYN_COL_DOUBLE;
val[2].double_value= num2;
dynamic_column_prepare_decimal(val + 3); // special procedure for decimal!!!
if (string2decimal(num3, &val[3].decimal_value, &end3) != E_DEC_OK)
goto err;
val[4].type= DYN_COL_STRING;
val[4].string_value.str= (char*)string4;
val[4].string_value.length= len4;
val[4].charset= cs4;
val[5].type= DYN_COL_DATE;
val[5].time_value.time_type= MYSQL_TIMESTAMP_DATE;
val[5].time_value.year= year5;
val[5].time_value.month= month5;
val[5].time_value.day= day5;
val[6].type= DYN_COL_TIME;
val[6].time_value.time_type= MYSQL_TIMESTAMP_TIME;
val[6].time_value.neg= neg6;
val[6].time_value.hour= hour6;
val[6].time_value.minute= minute6;
val[6].time_value.second= second6;
val[6].time_value.second_part= mic6;
val[7].type= DYN_COL_DATETIME;
val[7].time_value.time_type= MYSQL_TIMESTAMP_DATETIME;
val[7].time_value.neg= neg7;
val[7].time_value.year= year7;
val[7].time_value.month= month7;
val[7].time_value.day= day7;
val[7].time_value.hour= hour7;
val[7].time_value.minute= minute7;
val[7].time_value.second= second7;
val[7].time_value.second_part= mic7;
val[8].type= DYN_COL_NULL;
for (i= 0; i < 9; i++)
dynamic_column_value_init(res + i);
/* create column */
if (dynamic_column_create_many(&str, 9, column_numbers, val))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
for (i= 0; i < 9; i++)
if (dynamic_column_get(&str, column_numbers[i], res + i))
goto err;
rc= ((res[0].type == DYN_COL_UINT) &&
(res[0].ulong_value == num0) &&
(res[1].type == DYN_COL_INT) &&
(res[1].long_value == num1) &&
(res[2].type == DYN_COL_DOUBLE) &&
(res[2].double_value == num2) &&
(res[3].type == DYN_COL_DECIMAL) &&
(decimal_cmp(&res[3].decimal_value, &val[3].decimal_value) == 0) &&
(res[4].type == DYN_COL_STRING) &&
(res[4].string_value.length == len4) &&
(memcmp(res[4].string_value.str, string4, len4) == 0) &&
(res[4].charset->number == cs4->number) &&
(res[5].type == DYN_COL_DATE) &&
(res[5].time_value.time_type == MYSQL_TIMESTAMP_DATE) &&
(res[5].time_value.year == year5) &&
(res[5].time_value.month == month5) &&
(res[5].time_value.day == day5) &&
(res[6].type == DYN_COL_TIME) &&
(res[6].time_value.time_type == MYSQL_TIMESTAMP_TIME) &&
(res[6].time_value.neg == (int)neg6) &&
(res[6].time_value.hour == hour6) &&
(res[6].time_value.minute == minute6) &&
(res[6].time_value.second == second6) &&
(res[6].time_value.second_part == mic6) &&
(res[7].type == DYN_COL_DATETIME) &&
(res[7].time_value.time_type == MYSQL_TIMESTAMP_DATETIME) &&
(res[7].time_value.neg == (int)neg7) &&
(res[7].time_value.year == year7) &&
(res[7].time_value.month == month7) &&
(res[7].time_value.day == day7) &&
(res[7].time_value.hour == hour7) &&
(res[7].time_value.minute == minute7) &&
(res[7].time_value.second == second7) &&
(res[7].time_value.second_part == mic7) &&
(res[8].type == DYN_COL_NULL));
err:
ok(rc, "%s", name);
/* cleanup */
val[4].string_value.str= NULL; // we did not allocated it
dynamic_column_column_free(&str);
}
void test_value_multi_same_num()
{
int rc= FALSE;
uint i;
DYNAMIC_COLUMN_VALUE val[5];
uint column_numbers[]= {3,4,5,3,6}; // same column numbers
DYNAMIC_COLUMN str;
/* init values */
for (i= 0; i < 5; i++)
val[i].type= DYN_COL_NULL;
/* create column */
if (!dynamic_column_create_many(&str, 5, column_numbers, val))
goto err;
rc= TRUE;
err:
ok(rc, "%s", "same column numbers check");
/* cleanup */
dynamic_column_column_free(&str);
}
void test_update_multi(uint *column_numbers, uint *column_values,
my_bool *null_values, int only_add, int all)
{
int rc= FALSE;
int i, j;
DYNAMIC_COLUMN str;
DYNAMIC_COLUMN_VALUE val;
val.type= DYN_COL_UINT;
val.ulong_value= column_values[0];
if (dynamic_column_create(&str, column_numbers[0], &val))
goto err;
for (i= 1; i < all; i++)
{
val.type= (null_values[i] ? DYN_COL_NULL : DYN_COL_UINT);
val.ulong_value= column_values[i];
if (dynamic_column_update(&str, column_numbers[i], &val))
goto err;
/* check value(s) */
for (j= i; j >= (i < only_add ? 0 : i); j--)
{
if (dynamic_column_get(&str, column_numbers[j], &val))
goto err;
if (null_values[j])
{
if (val.type != DYN_COL_NULL ||
dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_YES)
goto err;
}
else
{
if (val.type != DYN_COL_UINT ||
val.ulong_value != column_values[j] ||
dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_NO)
goto err;
}
}
if (i < only_add)
{
DYNAMIC_ARRAY num;
if (dynamic_column_list(&str, &num))
goto err;
/* cross check arrays */
if ((int)num.elements != i + 1)
{
delete_dynamic(&num);
goto err;
}
for(j= 0; j < i + 1; j++)
{
int k;
for(k= 0;
k < i + 1 && column_numbers[j] !=
*dynamic_element(&num, k, uint*);
k++);
if (k >= i + 1)
{
delete_dynamic(&num);
goto err;
}
for(k= 0;
k < i + 1 && column_numbers[k] !=
*dynamic_element(&num, j, uint*);
k++);
if (k >= i + 1)
{
delete_dynamic(&num);
goto err;
}
}
delete_dynamic(&num);
}
}
rc= TRUE;
err:
ok(rc, "%s", "add/delete/update");
/* cleanup */
dynamic_column_column_free(&str);
}
void test_empty_string()
{
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
DYNAMIC_ARRAY array_of_uint;
int rc;
/* empty string */
bzero(&str, sizeof(str));
rc= dynamic_column_get(&str, 1, &res);
ok( (rc == ER_DYNCOL_OK) && (res.type == DYN_COL_NULL), "%s", "empty get");
rc= dynamic_column_delete(&str, 1);
ok( (rc == ER_DYNCOL_OK), "%s", "empty delete");
rc= dynamic_column_exists(&str, 1);
ok( (rc == ER_DYNCOL_NO), "%s", "empty exists");
rc= dynamic_column_list(&str, &array_of_uint);
ok( (rc == ER_DYNCOL_OK) && (array_of_uint.elements == 0),
"%s", "empty list");
val.type= DYN_COL_UINT;
val.ulong_value= 1212;
rc= dynamic_column_update(&str, 1, &val);
if (rc == ER_DYNCOL_OK)
rc= dynamic_column_get(&str, 1, &res);
ok( (rc == ER_DYNCOL_OK) &&
(res.type == DYN_COL_UINT) && (res.ulong_value == val.ulong_value),
"%s", "empty update");
}
void test_update_many(uint *column_numbers, uint *column_values,
uint column_count,
uint *update_numbers, uint *update_values,
my_bool *update_nulls, uint update_count,
uint *result_numbers, uint *result_values,
uint result_count)
{
int rc= FALSE;
uint i;
DYNAMIC_COLUMN str1;
DYNAMIC_COLUMN str2;
DYNAMIC_COLUMN_VALUE *val, *upd, *res;
val= (DYNAMIC_COLUMN_VALUE *)malloc(sizeof(DYNAMIC_COLUMN_VALUE) *
column_count);
upd= (DYNAMIC_COLUMN_VALUE *)malloc(sizeof(DYNAMIC_COLUMN_VALUE) *
update_count);
res= (DYNAMIC_COLUMN_VALUE *)malloc(sizeof(DYNAMIC_COLUMN_VALUE) *
result_count);
for (i= 0; i < column_count; i++)
{
val[i].type= DYN_COL_UINT;
val[i].ulong_value= column_values[i];
}
for (i= 0; i < update_count; i++)
{
if (update_nulls[i])
upd[i].type= DYN_COL_NULL;
else
{
upd[i].type= DYN_COL_UINT;
upd[i].ulong_value= update_values[i];
}
}
for (i= 0; i < result_count; i++)
{
res[i].type= DYN_COL_UINT;
res[i].ulong_value= result_values[i];
}
if (dynamic_column_create_many(&str1, column_count, column_numbers, val))
goto err;
if (dynamic_column_update_many(&str1, update_count, update_numbers, upd))
goto err;
if (dynamic_column_create_many(&str2, result_count, result_numbers, res))
goto err;
if (str1.length == str2.length &&
memcmp(str1.str, str2.str, str1.length) ==0)
rc= TRUE;
err:
ok(rc, "%s", "update_many");
/* cleanup */
dynamic_column_column_free(&str1);
dynamic_column_column_free(&str2);
}
int main(int argc __attribute__((unused)), char **argv)
{
uint i;
char *big_string= (char *)malloc(1024*1024);
MY_INIT(argv[0]);
plan(60);
if (!big_string)
exit(1);
for (i= 0; i < 1024*1024; i++)
big_string[i]= ('0' + (i % 10));
test_value_single_null();
test_value_single_uint(0, "0");
test_value_single_uint(ULL(0xffffffffffffffff), "0xffffffffffffffff");
test_value_single_uint(ULL(0xaaaaaaaaaaaaaaaa), "0xaaaaaaaaaaaaaaaa");
test_value_single_uint(ULL(0x5555555555555555), "0x5555555555555555");
test_value_single_uint(27652, "27652");
test_value_single_sint(0, "0");
test_value_single_sint(1, "1");
test_value_single_sint(-1, "-1");
test_value_single_sint(LL(0x7fffffffffffffff),
"0x7fffffffffffffff");
test_value_single_sint(LL(0xaaaaaaaaaaaaaaaa),
"0xaaaaaaaaaaaaaaaa");
test_value_single_sint(LL(0x5555555555555555),
"0x5555555555555555");
test_value_single_sint(LL(0x8000000000000000),
"0x8000000000000000");
test_value_single_double(0.0, "0.0");
test_value_single_double(1.0, "1.0");
test_value_single_double(-1.0, "-1.0");
test_value_single_double(1.0e100, "1.0e100");
test_value_single_double(1.0e-100, "1.0e-100");
test_value_single_double(9999999999999999999999999999999999999.0,
"9999999999999999999999999999999999999.0");
test_value_single_double(-9999999999999999999999999999999999999.0,
"-9999999999999999999999999999999999999.0");
test_value_single_decimal("0");
test_value_single_decimal("1");
test_value_single_decimal("-1");
test_value_single_decimal("9999999999999999999999999999999");
test_value_single_decimal("-9999999999999999999999999999999");
test_value_single_decimal("0.9999999999999999999999999999999");
test_value_single_decimal("-0.9999999999999999999999999999999");
test_value_single_string("", 0, charset_list[0]);
test_value_single_string("", 1, charset_list[0]);
test_value_single_string("1234567890", 11, charset_list[0]);
test_value_single_string("nulls\0\0\0\0\0", 10, charset_list[0]);
sprintf(big_string, "%x", 0x7a);
test_value_single_string(big_string, 0x7a, charset_list[0]);
sprintf(big_string, "%x", 0x80);
test_value_single_string(big_string, 0x80, charset_list[0]);
sprintf(big_string, "%x", 0x7ffa);
test_value_single_string(big_string, 0x7ffa, charset_list[0]);
sprintf(big_string, "%x", 0x8000);
test_value_single_string(big_string, 0x8000, charset_list[0]);
sprintf(big_string, "%x", 1024*1024);
test_value_single_string(big_string, 1024*1024, charset_list[0]);
test_value_single_date(0, 0, 0, "zero date");
test_value_single_date(9999, 12, 31, "max date");
test_value_single_date(2011, 3, 26, "some date");
test_value_single_time(0, 0, 0, 0, 0, "zero time");
test_value_single_time(1, 23, 59, 59, 999999, "min time");
test_value_single_time(0, 23, 59, 59, 999999, "max time");
test_value_single_time(0, 21, 36, 20, 28, "some time");
test_value_single_datetime(0, 0, 0, 0, 0, 0, 0, 0, "zero datetime");
test_value_single_datetime(1, 9999, 12, 31, 23, 59, 59, 999999,
"min datetime");
test_value_single_datetime(0, 9999, 12, 31, 23, 59, 59, 999999,
"max datetime");
test_value_single_datetime(0, 2011, 3, 26, 21, 53, 12, 3445,
"some datetime");
{
uint column_numbers[]= {100,1,2,3,4,5,6,7,8};
test_value_multi(0, 0, 0.0, "0",
"", 0, charset_list[0],
0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
column_numbers,
"zero data");
}
{
uint column_numbers[]= {10,1,12,37,4,57,6,76,87};
test_value_multi(ULL(0xffffffffffffffff), LL(0x7fffffffffffffff),
99999999.999e120, "9999999999999999999999999999999",
big_string, 1024*1024, charset_list[0],
9999, 12, 31,
0, 23, 59, 59, 999999,
0, 9999, 12, 31, 23, 59, 59, 999999,
column_numbers,
"much data");
}
free(big_string);
{
uint column_numbers[]= {101,12,122,37,24,572,16,726,77};
test_value_multi(37878, -3344,
2873.3874, "92743.238984789898",
"string", 6, charset_list[0],
2011, 3, 26,
1, 23, 23, 20, 333,
0, 2011, 3, 26, 23, 23, 53, 334,
column_numbers,
"zero data");
}
test_value_multi_same_num();
{
uint column_numbers[]= {1,2,3,4,5,6,7,2, 3, 4};
uint column_values[]= {1,2,3,4,5,6,7,0,30,40};
my_bool null_values[]= {0,0,0,0,0,0,0,1, 0, 0};
test_update_multi(column_numbers, column_values, null_values, 7, 10);
}
{
uint column_numbers[]= {4,3,2,1, 1,2,3,4};
uint column_values[]= {4,3,2,1, 0,0,0,0};
my_bool null_values[]= {0,0,0,0, 1,1,1,1};
test_update_multi(column_numbers, column_values, null_values, 4, 8);
}
{
uint column_numbers[]= {4,3,2,1, 4,3,2,1};
uint column_values[]= {4,3,2,1, 0,0,0,0};
my_bool null_values[]= {0,0,0,0, 1,1,1,1};
test_update_multi(column_numbers, column_values, null_values, 4, 8);
}
test_empty_string();
{
uint column_numbers[]= {1, 2, 3};
uint column_values[]= {1, 2, 3};
uint update_numbers[]= {4, 3, 2, 1};
uint update_values[]= {40,30, 0,10};
my_bool update_nulls[]={0, 0, 1, 0};
uint result_numbers[]= {1, 3, 4};
uint result_values[]= {10,30,40};
test_update_many(column_numbers, column_values, 3,
update_numbers, update_values, update_nulls, 4,
result_numbers, result_values, 3);
}
return exit_status();
}