summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2008-12-09 15:16:39 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2008-12-09 15:16:39 +0400
commit82aedffa036f79d00f5d76b9ec110a21bf485575 (patch)
treef3d6505d1d67fc4f79a68928e63b7fa06f3a31fc
parent0d2db9c02023c5867e92c31c53da9c5431042387 (diff)
parent681a2d1a53999f70e5437f62d8478caade48f3b3 (diff)
downloadmariadb-git-82aedffa036f79d00f5d76b9ec110a21bf485575.tar.gz
5.0-bugteam->5.1-bugteam merge
mysql-test/r/myisam_data_pointer_size_func.result: restore default value mysql-test/r/partition_datatype.result: test case fix mysql-test/t/myisam_data_pointer_size_func.test: restore default value
-rw-r--r--mysql-test/r/func_str.result12
-rw-r--r--mysql-test/r/myisam_data_pointer_size_func.result1
-rw-r--r--mysql-test/r/partition_datatype.result2
-rw-r--r--mysql-test/r/type_bit.result15
-rw-r--r--mysql-test/t/func_str.test10
-rw-r--r--mysql-test/t/myisam_data_pointer_size_func.test1
-rw-r--r--mysql-test/t/type_bit.test15
-rw-r--r--sql/item.cc3
-rw-r--r--sql/item_strfunc.cc7
-rw-r--r--sql/sql_show.cc18
10 files changed, 74 insertions, 10 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 78748a4622f..0824f13cafc 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -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
diff --git a/mysql-test/r/myisam_data_pointer_size_func.result b/mysql-test/r/myisam_data_pointer_size_func.result
index f32e25c7427..90d224d6584 100644
--- a/mysql-test/r/myisam_data_pointer_size_func.result
+++ b/mysql-test/r/myisam_data_pointer_size_func.result
@@ -40,3 +40,4 @@ count(*)
65536
DROP PROCEDURE sp_addRec;
DROP TABLE t1;
+SET @@global.myisam_data_pointer_size = default;
diff --git a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result
index 3e4acfdee12..607afb71da5 100644
--- a/mysql-test/r/partition_datatype.result
+++ b/mysql-test/r/partition_datatype.result
@@ -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)
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index 782cddaeff7..03f3098ea33 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -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);
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 5a5f4024bc4..5d77c678d52 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -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
diff --git a/mysql-test/t/myisam_data_pointer_size_func.test b/mysql-test/t/myisam_data_pointer_size_func.test
index 36ad31acf6c..985546cbde4 100644
--- a/mysql-test/t/myisam_data_pointer_size_func.test
+++ b/mysql-test/t/myisam_data_pointer_size_func.test
@@ -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 #
################################################################
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index 5793846a0b2..6fb65262e14 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -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
#
diff --git a/sql/item.cc b/sql/item.cc
index 7b7c44b4719..7f85713915d 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 4e01728f71c..bb3f4821c4f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -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;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 28e8c028362..a506429fb97 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -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;