Commit 5168c2ac authored by Sergey Glukhov's avatar Sergey Glukhov

5.0-bugteam->5.1-bugteam merge

parents b3012d08 0661c210
......@@ -717,8 +717,6 @@ insert(_latin2'abcd',2,3,_latin2'ef'),
replace(_latin2'abcd',_latin2'b',_latin2'B'),
encode('abcd','ab')
;
Warnings:
Warning 1265 Data truncated for column 'format(130,10)' at row 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -727,7 +725,7 @@ t1 CREATE TABLE `t1` (
`conv(130,16,10)` varchar(64) DEFAULT NULL,
`hex(130)` varchar(6) NOT NULL DEFAULT '',
`char(130)` varbinary(4) NOT NULL DEFAULT '',
`format(130,10)` varchar(4) NOT NULL DEFAULT '',
`format(130,10)` varchar(37) NOT NULL DEFAULT '',
`left(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
`right(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
`lcase(_latin2'a')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
......@@ -2513,4 +2511,12 @@ SELECT HEX(c1) from v1;
HEX(c1)
414243
DROP VIEW v1;
create table t1(a float);
insert into t1 values (1.33);
select format(a, 2) from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def format(a, 2) 253 49 4 Y 0 31 8
format(a, 2)
1.33
drop table t1;
End of 5.0 tests
......@@ -40,3 +40,4 @@ count(*)
65536
DROP PROCEDURE sp_addRec;
DROP TABLE t1;
SET @@global.myisam_data_pointer_size = default;
......@@ -324,7 +324,7 @@ partition by hash (a)
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bit(27) NOT NULL DEFAULT '\0\0\0\0',
`a` bit(27) NOT NULL DEFAULT b'0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
......
......@@ -708,6 +708,21 @@ HEX(b1) HEX(b2) i2
1 0 100
1 0 200
DROP TABLE t1, t2;
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b'10',
f2 bit(14) NOT NULL default b'11110000111100'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` bit(2) NOT NULL DEFAULT b'10',
`f2` bit(14) NOT NULL DEFAULT b'11110000111100'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
DROP TABLE t1;
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
ERROR 42000: Invalid default value for 'f1'
End of 5.0 tests
create table t1(a bit(7));
insert into t1 values(0x40);
......
......@@ -1263,4 +1263,14 @@ CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1;
SELECT HEX(c1) from v1;
DROP VIEW v1;
#
# Bug #35558 Wrong server metadata blows up the client
#
create table t1(a float);
insert into t1 values (1.33);
--enable_metadata
select format(a, 2) from t1;
--disable_metadata
drop table t1;
--echo End of 5.0 tests
......@@ -105,6 +105,7 @@ SELECT count(*) from t1;
DROP PROCEDURE sp_addRec;
DROP TABLE t1;
SET @@global.myisam_data_pointer_size = default;
################################################################
# End of functionality Testing for myisam_data_pointer_size #
################################################################
......
......@@ -352,6 +352,21 @@ SELECT HEX(b1), HEX(b2), i2 FROM t2
DROP TABLE t1, t2;
#
# Bug #35796 SHOW CREATE TABLE and default value for BIT field
#
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b'10',
f2 bit(14) NOT NULL default b'11110000111100'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
SHOW CREATE TABLE t1;
DROP TABLE t1;
--error ER_INVALID_DEFAULT
CREATE TABLE IF NOT EXISTS t1 (
f1 bit(2) NOT NULL default b''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
--echo End of 5.0 tests
#
......
......@@ -5114,6 +5114,9 @@ int Item_hex_string::save_in_field(Field *field, bool no_conversions)
ulonglong nr;
uint32 length= str_value.length();
if (!length)
return 1;
if (length > 8)
{
nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX;
......
......@@ -2033,10 +2033,11 @@ Item_func_format::Item_func_format(Item *org, Item *dec)
void Item_func_format::fix_length_and_dec()
{
collation.set(default_charset());
uint char_length= args[0]->max_length/args[0]->collation.collation->mbmaxlen;
max_length= ((char_length + (char_length-args[0]->decimals)/3) *
collation.collation->mbmaxlen);
uint max_sep_count= char_length/3 + (decimals ? 1 : 0) + /*sign*/1;
collation.set(default_charset());
max_length= (char_length + max_sep_count + decimals) *
collation.collation->mbmaxlen;
}
......
......@@ -993,7 +993,7 @@ static bool get_field_default_value(THD *thd, TABLE *table,
{
bool has_default;
bool has_now_default;
enum enum_field_types field_type= field->type();
/*
We are using CURRENT_TIMESTAMP instead of NOW because it is
more standard
......@@ -1001,7 +1001,7 @@ static bool get_field_default_value(THD *thd, TABLE *table,
has_now_default= table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_UN_FIELD;
has_default= (field->type() != FIELD_TYPE_BLOB &&
has_default= (field_type != FIELD_TYPE_BLOB &&
!(field->flags & NO_DEFAULT_VALUE_FLAG) &&
field->unireg_check != Field::NEXT_NUMBER &&
!((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
......@@ -1016,7 +1016,19 @@ static bool get_field_default_value(THD *thd, TABLE *table,
{ // Not null by default
char tmp[MAX_FIELD_WIDTH];
String type(tmp, sizeof(tmp), field->charset());
field->val_str(&type);
if (field_type == MYSQL_TYPE_BIT)
{
longlong dec= field->val_int();
char *ptr= longlong2str(dec, tmp + 2, 2);
uint32 length= (uint32) (ptr - tmp);
tmp[0]= 'b';
tmp[1]= '\'';
tmp[length]= '\'';
type.length(length + 1);
quoted= 0;
}
else
field->val_str(&type);
if (type.length())
{
String def_val;
......
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