Commit cc78e2d9 authored by monty@mysql.com's avatar monty@mysql.com

Ensure that result from date_format() is binary

Removed warnings from test suite
parent 3e35cce5
......@@ -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
......
This diff is collapsed.
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