Commit 77d56859 authored by unknown's avatar unknown

Fix for bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns

  The columns CHARACTER_MAXIMUM_LENGTH and CHARACTER_OCTET_LENGTH 
  of INFORMATION_SCHEMA.COLUMNS must be NULL for numeric columns


mysql-test/r/information_schema.result:
  Fix for bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns
mysql-test/t/information_schema.test:
  Fix for bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns
sql/sql_show.cc:
  Fix for bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 3a44dcd1
...@@ -56,6 +56,7 @@ georg@beethoven.local ...@@ -56,6 +56,7 @@ georg@beethoven.local
georg@beethoven.site georg@beethoven.site
georg@lmy002.wdf.sap.corp georg@lmy002.wdf.sap.corp
gerberb@ou800.zenez.com gerberb@ou800.zenez.com
gluh@eagle.intranet.mysql.r18.ru
gluh@gluh.(none) gluh@gluh.(none)
gluh@gluh.mysql.r18.ru gluh@gluh.mysql.r18.ru
gordon@zero.local.lan gordon@zero.local.lan
......
...@@ -133,7 +133,7 @@ c varchar(64) utf8_general_ci NO select,insert,update,references ...@@ -133,7 +133,7 @@ c varchar(64) utf8_general_ci NO select,insert,update,references
select * from information_schema.COLUMNS where table_name="t1" select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a"; and column_name= "a";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references NULL testtets t1 a 1 NULL YES int NULL NULL 11 0 NULL NULL int(11) select,insert,update,references
show columns from testtets.t1 where field like "%a%"; show columns from testtets.t1 where field like "%a%";
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
...@@ -476,15 +476,15 @@ select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH, ...@@ -476,15 +476,15 @@ select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1'; from information_schema.columns where table_name= 't1';
COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE
a decimal(5,3) 7 7 5 3 a decimal(5,3) NULL NULL 5 3
b decimal(5,1) 7 7 5 1 b decimal(5,1) NULL NULL 5 1
c float(5,2) 5 5 5 2 c float(5,2) NULL NULL 5 2
d decimal(6,4) 8 8 6 4 d decimal(6,4) NULL NULL 6 4
e float 12 12 12 NULL e float NULL NULL 12 NULL
f decimal(6,3) 8 8 6 3 f decimal(6,3) NULL NULL 6 3
g int(11) 11 11 11 0 g int(11) NULL NULL 11 0
h double(10,3) 10 10 10 3 h double(10,3) NULL NULL 10 3
i double 22 22 22 NULL i double NULL NULL 22 NULL
drop table t1; drop table t1;
create table t115 as select table_name, column_name, column_type create table t115 as select table_name, column_name, column_type
from information_schema.columns where table_name = 'proc'; from information_schema.columns where table_name = 'proc';
...@@ -678,3 +678,25 @@ WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA ...@@ -678,3 +678,25 @@ WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME); AND A.TABLE_NAME = B.TABLE_NAME);
COUNT(*) COUNT(*)
0 0
create table t1
( x_bigint BIGINT,
x_integer INTEGER,
x_smallint SMALLINT,
x_decimal DECIMAL(5,3),
x_numeric NUMERIC(5,3),
x_real REAL,
x_float FLOAT,
x_double_precision DOUBLE PRECISION );
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME= 't1';
COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
x_bigint NULL NULL
x_integer NULL NULL
x_smallint NULL NULL
x_decimal NULL NULL
x_numeric NULL NULL
x_real NULL NULL
x_float NULL NULL
x_double_precision NULL NULL
drop table t1;
...@@ -432,3 +432,21 @@ WHERE NOT EXISTS ...@@ -432,3 +432,21 @@ WHERE NOT EXISTS
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B (SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME); AND A.TABLE_NAME = B.TABLE_NAME);
#
# Bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns
#
create table t1
( x_bigint BIGINT,
x_integer INTEGER,
x_smallint SMALLINT,
x_decimal DECIMAL(5,3),
x_numeric NUMERIC(5,3),
x_real REAL,
x_float FLOAT,
x_double_precision DOUBLE PRECISION );
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME= 't1';
drop table t1;
...@@ -2333,12 +2333,26 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, ...@@ -2333,12 +2333,26 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
"NO" : "YES"); "NO" : "YES");
table->field[6]->store((const char*) pos, table->field[6]->store((const char*) pos,
strlen((const char*) pos), cs); strlen((const char*) pos), cs);
if (field->has_charset())
table->field[8]->store((longlong) field->representation_length()/ switch (field->type()) {
field->charset()->mbmaxlen); case FIELD_TYPE_TINY_BLOB:
else case FIELD_TYPE_MEDIUM_BLOB:
table->field[8]->store((longlong) field->representation_length()); case FIELD_TYPE_LONG_BLOB:
table->field[9]->store((longlong) field->representation_length()); case FIELD_TYPE_BLOB:
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING:
if (field->has_charset())
table->field[8]->store((longlong) field->representation_length()/
field->charset()->mbmaxlen);
else
table->field[8]->store((longlong) field->representation_length());
table->field[8]->set_notnull();
table->field[9]->store((longlong) field->representation_length());
table->field[9]->set_notnull();
break;
default:
break;
}
{ {
uint dec =field->decimals(); uint dec =field->decimals();
...@@ -3514,8 +3528,8 @@ ST_FIELD_INFO columns_fields_info[]= ...@@ -3514,8 +3528,8 @@ ST_FIELD_INFO columns_fields_info[]=
{"COLUMN_DEFAULT", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Default"}, {"COLUMN_DEFAULT", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Default"},
{"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"}, {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"},
{"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0}, {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},
......
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