Commit eeae4f84 authored by unknown's avatar unknown

Ensure that result from date_format() is binary

Removed warnings from test suite


mysql-test/r/ctype_utf8.result:
  Update results after fix of return argument from date_format()
mysql-test/r/date_formats.result:
  Remove unnecessary warnings
mysql-test/r/type_decimal.result:
  Remove unnecessary warnings
mysql-test/r/warnings.result:
  Remove unnecessary warnings
mysql-test/t/ctype_utf8.test:
  Fixed test
mysql-test/t/date_formats.test:
  Remove unnecessary warnings
mysql-test/t/type_decimal.test:
  Remove unnecessary warnings
mysql-test/t/warnings.test:
  Remove unnecessary warnings
sql/field.cc:
  Optimize
sql/item_timefunc.cc:
  Ensure that result from date_format() is binary
strings/ctype-simple.c:
  Better names for arguments
parent bc6aef6a
......@@ -73,7 +73,7 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")` char(10) character set utf8 default NULL
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")` char(10) binary default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
date_format("2004-01-19 10:10:10", "%Y-%m-%d")
......@@ -87,3 +87,4 @@ Warning 1264 Data truncated for column 's1' at row 1
select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
s1 hex(s1) char_length(s1) octet_length(s1)
D0B0 1 2
drop table t1;
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
SHOW GLOBAL VARIABLES LIKE "%_format%";
Variable_name Value
date_format %d.%m.%Y
......
......@@ -446,39 +446,6 @@ CREATE TABLE t1 (a_dec DECIMAL(-1,1));
ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,1))' at line 1
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
Warnings:
Warning 1263 Data truncated, out of range for column 'a' at row 27
Warning 1263 Data truncated, out of range for column 'a' at row 30
Warning 1263 Data truncated, out of range for column 'a' at row 31
Warning 1263 Data truncated, out of range for column 'a' at row 32
Warning 1263 Data truncated, out of range for column 'a' at row 33
Warning 1263 Data truncated, out of range for column 'a' at row 34
Warning 1263 Data truncated, out of range for column 'a' at row 35
Warning 1263 Data truncated, out of range for column 'a' at row 36
Warning 1263 Data truncated, out of range for column 'a' at row 37
Warning 1263 Data truncated, out of range for column 'a' at row 38
Warning 1263 Data truncated, out of range for column 'a' at row 39
Warning 1263 Data truncated, out of range for column 'a' at row 40
Warning 1263 Data truncated, out of range for column 'a' at row 41
Warning 1263 Data truncated, out of range for column 'a' at row 42
Warning 1263 Data truncated, out of range for column 'a' at row 43
Warning 1263 Data truncated, out of range for column 'a' at row 44
Warning 1263 Data truncated, out of range for column 'a' at row 45
Warning 1263 Data truncated, out of range for column 'a' at row 46
Warning 1263 Data truncated, out of range for column 'a' at row 47
Warning 1263 Data truncated, out of range for column 'a' at row 48
Warning 1263 Data truncated, out of range for column 'a' at row 49
Warning 1263 Data truncated, out of range for column 'a' at row 50
Warning 1263 Data truncated, out of range for column 'a' at row 51
Warning 1263 Data truncated, out of range for column 'a' at row 52
Warning 1263 Data truncated, out of range for column 'a' at row 53
Warning 1263 Data truncated, out of range for column 'a' at row 54
Warning 1263 Data truncated, out of range for column 'a' at row 55
Warning 1263 Data truncated, out of range for column 'a' at row 56
Warning 1263 Data truncated, out of range for column 'a' at row 57
Warning 1263 Data truncated, out of range for column 'a' at row 58
Warning 1263 Data truncated, out of range for column 'a' at row 59
Warning 1263 Data truncated, out of range for column 'a' at row 60
select * from t1;
a
1.000
......@@ -544,51 +511,6 @@ a
drop table t1;
create table t1(a decimal(7,3) unsigned);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
Warnings:
Warning 1263 Data truncated, out of range for column 'a' at row 3
Warning 1263 Data truncated, out of range for column 'a' at row 6
Warning 1263 Data truncated, out of range for column 'a' at row 9
Warning 1263 Data truncated, out of range for column 'a' at row 12
Warning 1263 Data truncated, out of range for column 'a' at row 15
Warning 1263 Data truncated, out of range for column 'a' at row 18
Warning 1263 Data truncated, out of range for column 'a' at row 21
Warning 1263 Data truncated, out of range for column 'a' at row 24
Warning 1263 Data truncated, out of range for column 'a' at row 25
Warning 1263 Data truncated, out of range for column 'a' at row 26
Warning 1263 Data truncated, out of range for column 'a' at row 27
Warning 1263 Data truncated, out of range for column 'a' at row 28
Warning 1263 Data truncated, out of range for column 'a' at row 29
Warning 1263 Data truncated, out of range for column 'a' at row 30
Warning 1263 Data truncated, out of range for column 'a' at row 31
Warning 1263 Data truncated, out of range for column 'a' at row 32
Warning 1263 Data truncated, out of range for column 'a' at row 33
Warning 1263 Data truncated, out of range for column 'a' at row 34
Warning 1263 Data truncated, out of range for column 'a' at row 35
Warning 1263 Data truncated, out of range for column 'a' at row 36
Warning 1263 Data truncated, out of range for column 'a' at row 37
Warning 1263 Data truncated, out of range for column 'a' at row 38
Warning 1263 Data truncated, out of range for column 'a' at row 39
Warning 1263 Data truncated, out of range for column 'a' at row 40
Warning 1263 Data truncated, out of range for column 'a' at row 41
Warning 1263 Data truncated, out of range for column 'a' at row 42
Warning 1263 Data truncated, out of range for column 'a' at row 43
Warning 1263 Data truncated, out of range for column 'a' at row 44
Warning 1263 Data truncated, out of range for column 'a' at row 45
Warning 1263 Data truncated, out of range for column 'a' at row 46
Warning 1263 Data truncated, out of range for column 'a' at row 47
Warning 1263 Data truncated, out of range for column 'a' at row 48
Warning 1263 Data truncated, out of range for column 'a' at row 49
Warning 1263 Data truncated, out of range for column 'a' at row 50
Warning 1263 Data truncated, out of range for column 'a' at row 51
Warning 1263 Data truncated, out of range for column 'a' at row 52
Warning 1263 Data truncated, out of range for column 'a' at row 53
Warning 1263 Data truncated, out of range for column 'a' at row 54
Warning 1263 Data truncated, out of range for column 'a' at row 55
Warning 1263 Data truncated, out of range for column 'a' at row 56
Warning 1263 Data truncated, out of range for column 'a' at row 57
Warning 1263 Data truncated, out of range for column 'a' at row 58
Warning 1263 Data truncated, out of range for column 'a' at row 59
Warning 1263 Data truncated, out of range for column 'a' at row 60
select * from t1;
a
1.000
......@@ -654,51 +576,6 @@ a
drop table t1;
create table t1(a decimal(7,3) zerofill);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
Warnings:
Warning 1263 Data truncated, out of range for column 'a' at row 3
Warning 1263 Data truncated, out of range for column 'a' at row 6
Warning 1263 Data truncated, out of range for column 'a' at row 9
Warning 1263 Data truncated, out of range for column 'a' at row 12
Warning 1263 Data truncated, out of range for column 'a' at row 15
Warning 1263 Data truncated, out of range for column 'a' at row 18
Warning 1263 Data truncated, out of range for column 'a' at row 21
Warning 1263 Data truncated, out of range for column 'a' at row 24
Warning 1263 Data truncated, out of range for column 'a' at row 25
Warning 1263 Data truncated, out of range for column 'a' at row 26
Warning 1263 Data truncated, out of range for column 'a' at row 27
Warning 1263 Data truncated, out of range for column 'a' at row 28
Warning 1263 Data truncated, out of range for column 'a' at row 29
Warning 1263 Data truncated, out of range for column 'a' at row 30
Warning 1263 Data truncated, out of range for column 'a' at row 31
Warning 1263 Data truncated, out of range for column 'a' at row 32
Warning 1263 Data truncated, out of range for column 'a' at row 33
Warning 1263 Data truncated, out of range for column 'a' at row 34
Warning 1263 Data truncated, out of range for column 'a' at row 35
Warning 1263 Data truncated, out of range for column 'a' at row 36
Warning 1263 Data truncated, out of range for column 'a' at row 37
Warning 1263 Data truncated, out of range for column 'a' at row 38
Warning 1263 Data truncated, out of range for column 'a' at row 39
Warning 1263 Data truncated, out of range for column 'a' at row 40
Warning 1263 Data truncated, out of range for column 'a' at row 41
Warning 1263 Data truncated, out of range for column 'a' at row 42
Warning 1263 Data truncated, out of range for column 'a' at row 43
Warning 1263 Data truncated, out of range for column 'a' at row 44
Warning 1263 Data truncated, out of range for column 'a' at row 45
Warning 1263 Data truncated, out of range for column 'a' at row 46
Warning 1263 Data truncated, out of range for column 'a' at row 47
Warning 1263 Data truncated, out of range for column 'a' at row 48
Warning 1263 Data truncated, out of range for column 'a' at row 49
Warning 1263 Data truncated, out of range for column 'a' at row 50
Warning 1263 Data truncated, out of range for column 'a' at row 51
Warning 1263 Data truncated, out of range for column 'a' at row 52
Warning 1263 Data truncated, out of range for column 'a' at row 53
Warning 1263 Data truncated, out of range for column 'a' at row 54
Warning 1263 Data truncated, out of range for column 'a' at row 55
Warning 1263 Data truncated, out of range for column 'a' at row 56
Warning 1263 Data truncated, out of range for column 'a' at row 57
Warning 1263 Data truncated, out of range for column 'a' at row 58
Warning 1263 Data truncated, out of range for column 'a' at row 59
Warning 1263 Data truncated, out of range for column 'a' at row 60
select * from t1;
a
0001.000
......
drop table if exists t1, t2;
Warnings:
Note 1051 Unknown table 't1'
Note 1051 Unknown table 't2'
SET SQL_WARNINGS=1;
create table t1 (a int);
insert into t1 values (1);
......
......@@ -60,3 +60,4 @@ set names koi8r;
create table t1 (s1 char(1) character set utf8);
insert into t1 values (_koi8r'');
select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
drop table t1;
......@@ -2,9 +2,9 @@
# Test of date format functions
#
--disable-warnings
--disable_warnings
drop table if exists t1;
--enable-warnings
--enable_warnings
SHOW GLOBAL VARIABLES LIKE "%_format%";
SHOW SESSION VARIABLES LIKE "%_format%";
......
......@@ -248,7 +248,7 @@ CREATE TABLE t1 (a_dec DECIMAL(-1,1));
#
# Zero prepend overflow bug
#
--disable-warnings
--disable_warnings
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
......@@ -259,6 +259,6 @@ select * from t1;
drop table t1;
create table t1(a decimal(7,3) zerofill);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
--enable-warnings
--enable_warnings
select * from t1;
drop table t1;
#
# Test some warnings
#
--disable-warnings
--disable_warnings
drop table if exists t1, t2;
--enable-warnings
--enable_warnings
SET SQL_WARNINGS=1;
create table t1 (a int);
......
......@@ -4072,7 +4072,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
}
/*
Make sure we don't break a multybite sequence
Make sure we don't break a multibyte sequence
as well as don't copy a malformed data.
*/
copy_length= field_charset->cset->wellformedlen(field_charset,
......@@ -4084,8 +4084,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
field_charset->cset->fill(field_charset,ptr+copy_length,
field_length-copy_length,' ');
if (current_thd->count_cuted_fields && (copy_length < length))
if ((copy_length < length) && current_thd->count_cuted_fields)
{ // Check if we loosed some info
const char *end=from+length;
from+= copy_length;
......
......@@ -1283,16 +1283,21 @@ longlong Item_func_sec_to_time::val_int()
void Item_func_date_format::fix_length_and_dec()
{
decimals=0;
collation.set(&my_charset_bin);
if (args[1]->type() == STRING_ITEM)
{ // Optimize the normal case
fixed_length=1;
max_length= format_length(((Item_string*) args[1])->const_string())*
collation.collation->mbmaxlen;
/*
The result is a binary string (no reason to use collation->mbmaxlen
This is becasue make_date_time() only returns binary strings
*/
max_length= format_length(((Item_string*) args[1])->const_string());
}
else
{
fixed_length=0;
max_length=args[1]->max_length*10*collation.collation->mbmaxlen;
/* The result is a binary string (no reason to use collation->mbmaxlen */
max_length=args[1]->max_length*10;
set_if_smaller(max_length,MAX_BLOB_WIDTH);
}
maybe_null=1; // If wrong date
......
......@@ -1021,11 +1021,11 @@ uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)),
}
uint my_wellformedlen_8bit(CHARSET_INFO *cs __attribute__((unused)),
const char *b,
const char *e,
const char *start,
const char *end,
uint nchars)
{
uint nbytes= e-b;
uint nbytes= (uint) (end-start);
return nbytes < nchars ? nbytes : nchars;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment