Bug #8785 INFORMATION_SCHEMA.COLUMNS.COLUMN_DEFAULT strange content
Submitted: 24 Feb 2005 17:22 Modified: 16 Mar 2005 18:53
Reporter: Matthias Leich Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.10 OS:
Assigned to: Alexander Barkov CPU Architecture:Any

[24 Feb 2005 17:22] Matthias Leich
Description:
CREATE TABLE t1 ( f1 BIGINT, f2 VARCHAR (5) NOT NULL);
....                                                              NOT NULL
CREATE TABLE t4 ( f1 BIGINT, f2 DATE NOT NULL );
SELECT TABLE_NAME, '->' || COLUMN_DEFAULT || '<-', COLUMN_DEFAULT 
from INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA= 'test' AND COLUMN_NAME= 'f2';
TABLE_NAME	'->' || COLUMN_DEFAULT || '<-'	COLUMN_DEFAULT
t1	-><-	
t2	-><-<-	
t3	-><-<-<-	
t4	-><-<-<-<-
The content of COLUMN_DEFAULT is a bit strange.
1. The NIST tests expect that in the cases above COLUMN_DEFAULT is NULL.
    I don't know if their expectation is correct.
2. Our current MySQL shows something similar to an empty string.
    But when I concat some extra character to this column I get an
    output which is obviously wrong.
Please have a look into the fixed Bug#3796: 
      Prepared statement, select concat(<parameter>,<column>), wrong result .
Maybe the current bug has a similar reason.

My environment:
   - Intel PC with Linux(SuSE 9.1)
   - MySQL compiled from source
        Version 5.0 ChangeSet@1.1843, 2005-02-24

How to repeat:
Please use my attached test file ml32.test , copy it to mysql-test/t
  touch r/ml32.result     # Produce a dummy file with 
                                  # expected results.
  ./mysql-test-run ml32
  <inspect> r/ml32.reject    # The protocol of the execution.
[24 Feb 2005 17:24] Matthias Leich
test case

Attachment: ml32.test (application/test, text), 464 bytes.

[10 Mar 2005 11:55] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/22888
[10 Mar 2005 12:00] Sergei Glukhov
This bug exists in 4.1

How to repeat:
set @@session.sql_mode=pipes_as_concat;
create table t1 (f1 varchar(1) not null) default charset utf8;
insert into t1 values (''), ('');
select '->' || f1 || '<-'  from t1;
drop table t1;
set @@session.sql_mode=default;
[11 Mar 2005 15:19] Alexander Barkov
An easier example:
create table t1 (f1 varchar(1) not null) default charset utf8;
insert into t1 values (''), ('');
select concat(concat('->',f1),'<-') from t1;

------------------------------+
| concat(concat('->',f1),'<-') |
+------------------------------+
| -><-                         |
| -><-<-                       |
+------------------------------+
2 rows in set (0.00 sec)
[15 Mar 2005 13:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23036
[16 Mar 2005 10:47] Alexander Barkov
Fixed in 4.1.11
[16 Mar 2005 18:53] Paul DuBois
Noted in 4.1.11 changelog.