diff options
author | unknown <ingo@mysql.com> | 2004-09-11 12:31:28 +0200 |
---|---|---|
committer | unknown <ingo@mysql.com> | 2004-09-11 12:31:28 +0200 |
commit | 3ffc483275d6b8e733ddd98d534263f6f533cc9d (patch) | |
tree | 72484b6643fb7ad93e32a0f1c59e406d1795b9eb | |
parent | 6607b50754b35747f43b09355ee6c372c67c7503 (diff) | |
parent | 7c80446c4e0bd6d4572bdbc3a5498c379c49d0a5 (diff) | |
download | mariadb-git-3ffc483275d6b8e733ddd98d534263f6f533cc9d.tar.gz |
Merge mysql.com:/home/mydev/mysql-4.1
into mysql.com:/home/mydev/mysql-4.1-bug4788
-rw-r--r-- | include/mysql_com.h | 5 | ||||
-rw-r--r-- | mysql-test/r/variables.result | 26 | ||||
-rw-r--r-- | mysql-test/t/variables.test | 19 | ||||
-rw-r--r-- | sql/item_func.cc | 12 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 |
5 files changed, 67 insertions, 5 deletions
diff --git a/include/mysql_com.h b/include/mysql_com.h index 3b65d6f3fbc..449cd0ba396 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -136,6 +136,11 @@ enum enum_server_command struct st_vio; /* Only C */ typedef struct st_vio Vio; +#define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */ +#define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */ +#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */ +#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */ +#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */ #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */ #define MAX_BLOB_WIDTH 8192 /* Default width for blob */ diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 5d3f32cdd55..b2a97ce3e48 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -452,3 +452,29 @@ set global log_warnings = @tstlw; show global variables like 'log_warnings'; Variable_name Value log_warnings 1 +create table t1 ( +c1 tinyint, +c2 smallint, +c3 mediumint, +c4 int, +c5 bigint); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` tinyint(4) default NULL, + `c2` smallint(6) default NULL, + `c3` mediumint(9) default NULL, + `c4` int(11) default NULL, + `c5` bigint(20) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @arg00= 8, @arg01= 8.8, @arg02= 'a string'; +create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint(20) default NULL, + `c2` double default NULL, + `c3` longtext +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index a480ecb570a..fd6ab4d6405 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -335,3 +335,22 @@ show global variables like 'log_warnings'; set global log_warnings = @tstlw; show global variables like 'log_warnings'; +# +# BUG#4788 show create table provides incorrect statement +# +# What default width have numeric types? +create table t1 ( + c1 tinyint, + c2 smallint, + c3 mediumint, + c4 int, + c5 bigint); +show create table t1; +drop table t1; +# +# What types and widths have variables? +set @arg00= 8, @arg01= 8.8, @arg02= 'a string'; +create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3; +show create table t1; +drop table t1; + diff --git a/sql/item_func.cc b/sql/item_func.cc index ef845bb8266..6952effb48f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2724,7 +2724,19 @@ void Item_func_get_user_var::fix_length_and_dec() error= get_var_with_binlog(thd, name, &var_entry); if (var_entry) + { collation.set(var_entry->collation); + switch (var_entry->type) { + case REAL_RESULT: + max_length= DBL_DIG + 8; + case INT_RESULT: + max_length= MAX_BIGINT_WIDTH; + break; + case STRING_RESULT: + max_length= MAX_BLOB_WIDTH; + break; + } + } else null_value= 1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 39b94362269..b5f5a30d77f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4208,23 +4208,23 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, switch (type) { case FIELD_TYPE_TINY: - if (!length) new_field->length=3+sign_len; + if (!length) new_field->length=MAX_TINYINT_WIDTH+sign_len; allowed_type_modifier= AUTO_INCREMENT_FLAG; break; case FIELD_TYPE_SHORT: - if (!length) new_field->length=5+sign_len; + if (!length) new_field->length=MAX_SMALLINT_WIDTH+sign_len; allowed_type_modifier= AUTO_INCREMENT_FLAG; break; case FIELD_TYPE_INT24: - if (!length) new_field->length=8+sign_len; + if (!length) new_field->length=MAX_MEDIUMINT_WIDTH+sign_len; allowed_type_modifier= AUTO_INCREMENT_FLAG; break; case FIELD_TYPE_LONG: - if (!length) new_field->length=10+sign_len; + if (!length) new_field->length=MAX_INT_WIDTH+sign_len; allowed_type_modifier= AUTO_INCREMENT_FLAG; break; case FIELD_TYPE_LONGLONG: - if (!length) new_field->length=20; + if (!length) new_field->length=MAX_BIGINT_WIDTH; allowed_type_modifier= AUTO_INCREMENT_FLAG; break; case FIELD_TYPE_NULL: |