Skip to content

Commit

Permalink
*: fix INFORMATION_SCHEMA.COLUMNS.extra
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Mar 4, 2024
1 parent 583e664 commit dcf6087
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 8 deletions.
21 changes: 17 additions & 4 deletions pkg/ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1632,13 +1632,14 @@ func TestDefaultColumnWithDateFormat(t *testing.T) {

// insert records
nowTime := time.Now()
for i := 0; i < 5; i++ {
tk.MustExec(fmt.Sprintf("insert into t%d(c) values (1),(2)", i))
for i := 0; i < 6; i++ {
tk.MustExec(fmt.Sprintf("insert into t%d(c) values (1)", i))
tk.MustExec(fmt.Sprintf("insert into t%d(c) values (1),(default)", i))
}
tk.MustGetErrCode("insert into t6(c) values (1)", errno.ErrTruncatedWrongValue)
tk.MustGetErrCode("insert into t7(c) values (1)", errno.ErrTruncatedWrongValue)

for i := 0; i < 4; i++ {
for i := 0; i < 6; i++ {
rows := tk.MustQuery(fmt.Sprintf("SELECT c1 from t%d order by c", i)).Rows()
for _, row := range rows {
d, ok := row[0].(string)
Expand All @@ -1653,10 +1654,12 @@ func TestDefaultColumnWithDateFormat(t *testing.T) {
require.Equal(t, nowTime.Add(1*time.Second).Format("2006-01-02 15.04.05"), d,
fmt.Sprintf("now time:%v, get time:%v", nowTime.Format("2006-01-02 15.04.05"), d))
}
case 3, 4, 5:
case 3:
if nowTime.Format("2006-01-02 15:04:05") != d {
require.Equal(t, nowTime.Add(1*time.Second).Format("2006-01-02 15:04:05"), d)
}
case 4, 5:
require.Equal(t, nowTime.Format("2006-01-02"), d)
}
}
}
Expand Down Expand Up @@ -1696,6 +1699,10 @@ func TestDefaultColumnWithDateFormat(t *testing.T) {
" `c` int(10) DEFAULT NULL,\n" +
" `c1` datetime DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d')\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
tk.MustQuery("SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';").Check(testkit.Rows(
"date_format(now(), _utf8mb4'%Y-%m-%d') DEFAULT_GENERATED"))
tk.MustQuery("show columns from test.t1 where field='c1';").Check(testkit.Rows(
"c1 datetime YES date_format(now(), _utf8mb4'%Y-%m-%d') DEFAULT_GENERATED"))
}

func TestDefaultColumnWithReplace(t *testing.T) {
Expand Down Expand Up @@ -1773,6 +1780,8 @@ func TestDefaultColumnWithReplace(t *testing.T) {
" `c` int(10) DEFAULT NULL,\n" +
" `c1` varchar(32) DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'')\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
tk.MustQuery("SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';").Check(testkit.Rows(
"replace(upper(uuid()), _utf8mb4'-', _utf8mb4'') DEFAULT_GENERATED"))
}

func TestDefaultColumnWithStrToDate(t *testing.T) {
Expand Down Expand Up @@ -1871,6 +1880,8 @@ func TestDefaultColumnWithStrToDate(t *testing.T) {
" `c1` varchar(32) DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d'),\n" +
" `c2` int(11) DEFAULT str_to_date(_utf8mb4'9999-01-01', _utf8mb4'%Y-%m-%d')\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
tk.MustQuery("SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';").Check(testkit.Rows(
"str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d') DEFAULT_GENERATED"))
}

func TestDefaultColumnWithUpper(t *testing.T) {
Expand Down Expand Up @@ -1930,6 +1941,8 @@ func TestDefaultColumnWithUpper(t *testing.T) {
" `c` int(10) DEFAULT NULL,\n" +
" `c1` varchar(32) DEFAULT upper(substring_index(user(), _utf8mb4'@', 1))\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
tk.MustQuery("SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';").Check(testkit.Rows(
"upper(substring_index(user(), _utf8mb4'@', 1)) DEFAULT_GENERATED"))
}

func TestChangingDBCharset(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/table/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ func NewColDesc(col *Column) *ColDesc {
} else {
extra = "VIRTUAL GENERATED"
}
} else if col.DefaultIsExpr {
extra = "DEFAULT_GENERATED"
}

desc := &ColDesc{
Expand Down
245 changes: 245 additions & 0 deletions tests/integrationtest/r/ddl/default_as_expression.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
drop table if exists t0, t1, t2, t3;
create table t0 (c int(10), c1 BLOB default (date_format(now(),'%Y-%m-%d')));
create table t1 (c int(10), c1 JSON default (date_format(now(),'%Y-%m-%d')));
create table t2 (c int(10), c1 ENUM('y','n') default (date_format(now(),'%Y-%m-%d')));
create table t3 (c int(10), c1 SET('y','n') default (date_format(now(),'%Y-%m-%d')));
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
c c1
NULL 2024-03-04
1 2024-03-04
INSERT INTO t1 values ();
Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
INSERT INTO t1 values (1, DEFAULT);
Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
SELECT * from t1;
c c1
INSERT INTO t2 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t2 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t2;
c c1
INSERT INTO t3 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t3 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t3;
c c1
show create table t0;
Table Create Table
t0 CREATE TABLE `t0` (
`c` int(10) DEFAULT NULL,
`c1` blob DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(10) DEFAULT NULL,
`c1` json DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(10) DEFAULT NULL,
`c1` enum('y','n') DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c` int(10) DEFAULT NULL,
`c1` set('y','n') DEFAULT date_format(now(), _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
column_default extra
drop table t0, t1, t2, t3;
create table t0 (c int(10), c1 BLOB default (REPLACE(UPPER(UUID()), '-', '')));
create table t1 (c int(10), c1 JSON default (REPLACE(UPPER(UUID()), '-', '')));
create table t2 (c int(10), c1 ENUM('y','n') default (REPLACE(UPPER(UUID()), '-', '')));
create table t3 (c int(10), c1 SET('y','n') default (REPLACE(UPPER(UUID()), '-', '')));
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
c c1
NULL 5320C66CDA0C11EE98DF3C7D0A09BA5A
1 53210A50DA0C11EE98DF3C7D0A09BA5A
INSERT INTO t1 values ();
Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
INSERT INTO t1 values (1, DEFAULT);
Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
SELECT * from t1;
c c1
INSERT INTO t2 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t2 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t2;
c c1
INSERT INTO t3 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t3 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t3;
c c1
show create table t0;
Table Create Table
t0 CREATE TABLE `t0` (
`c` int(10) DEFAULT NULL,
`c1` blob DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(10) DEFAULT NULL,
`c1` json DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(10) DEFAULT NULL,
`c1` enum('y','n') DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c` int(10) DEFAULT NULL,
`c1` set('y','n') DEFAULT replace(upper(uuid()), _utf8mb4'-', _utf8mb4'')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
column_default extra
drop table t0, t1, t2, t3;
create table t0 (c int(10), c1 BLOB default (str_to_date('1980-01-01','%Y-%m-%d')));
create table t1 (c int(10), c1 JSON default (str_to_date('1980-01-01','%Y-%m-%d')));
create table t2 (c int(10), c1 ENUM('y','n') default (str_to_date('1980-01-01','%Y-%m-%d')));
create table t3 (c int(10), c1 SET('y','n') default (str_to_date('1980-01-01','%Y-%m-%d')));
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
c c1
NULL 1980-01-01
1 1980-01-01
INSERT INTO t1 values ();
INSERT INTO t1 values (1, DEFAULT);
SELECT * from t1;
c c1
NULL "1980-01-01"
1 "1980-01-01"
INSERT INTO t2 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t2 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t2;
c c1
INSERT INTO t3 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t3 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t3;
c c1
show create table t0;
Table Create Table
t0 CREATE TABLE `t0` (
`c` int(10) DEFAULT NULL,
`c1` blob DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(10) DEFAULT NULL,
`c1` json DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(10) DEFAULT NULL,
`c1` enum('y','n') DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c` int(10) DEFAULT NULL,
`c1` set('y','n') DEFAULT str_to_date(_utf8mb4'1980-01-01', _utf8mb4'%Y-%m-%d')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
column_default extra
drop table t0, t1, t2, t3;
create table t0 (c int(10), c1 BLOB default (upper(substring_index(user(),'@',1))));
create table t1 (c int(10), c1 JSON default (upper(substring_index(user(),'@',1))));
create table t2 (c int(10), c1 ENUM('y','n') default (upper(substring_index(user(),'@',1))));
create table t3 (c int(10), c1 SET('y','n') default (upper(substring_index(user(),'@',1))));
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
c c1
NULL ROOT
1 ROOT
INSERT INTO t1 values ();
Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
INSERT INTO t1 values (1, DEFAULT);
Error 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
SELECT * from t1;
c c1
INSERT INTO t2 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t2 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t2;
c c1
INSERT INTO t3 values ();
Error 1265 (01000): Data truncated for column '%s' at row %d
INSERT INTO t3 values (1, DEFAULT);
Error 1265 (01000): Data truncated for column '%s' at row %d
SELECT * from t3;
c c1
show create table t0;
Table Create Table
t0 CREATE TABLE `t0` (
`c` int(10) DEFAULT NULL,
`c1` blob DEFAULT upper(substring_index(user(), _utf8mb4'@', 1))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(10) DEFAULT NULL,
`c1` json DEFAULT upper(substring_index(user(), _utf8mb4'@', 1))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c` int(10) DEFAULT NULL,
`c1` enum('y','n') DEFAULT upper(substring_index(user(), _utf8mb4'@', 1))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c` int(10) DEFAULT NULL,
`c1` set('y','n') DEFAULT upper(substring_index(user(), _utf8mb4'@', 1))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
drop table t0, t1, t2, t3;
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
column_default extra
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
column_default extra
23 changes: 19 additions & 4 deletions tests/integrationtest/t/ddl/default_as_expression.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ create table t2 (c int(10), c1 ENUM('y','n') default (date_format(now(),'%Y-%m-%
create table t3 (c int(10), c1 SET('y','n') default (date_format(now(),'%Y-%m-%d')));
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
select count(1) from t0 where c1 = date_format(now(), '%Y-%m-%d');
-- error 3140
INSERT INTO t1 values ();
-- error 3140
Expand All @@ -27,6 +27,10 @@ show create table t0;
show create table t1;
show create table t2;
show create table t3;
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
drop table t0, t1, t2, t3;
# Different data types for replace.
create table t0 (c int(10), c1 BLOB default (REPLACE(UPPER(UUID()), '-', '')));
Expand All @@ -35,7 +39,7 @@ create table t2 (c int(10), c1 ENUM('y','n') default (REPLACE(UPPER(UUID()), '-'
create table t3 (c int(10), c1 SET('y','n') default (REPLACE(UPPER(UUID()), '-', '')));
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
SELECT count(1) FROM t0 WHERE c1 REGEXP '^[A-Z0-9]+$';
-- error 3140
INSERT INTO t1 values ();
-- error 3140
Expand All @@ -55,6 +59,10 @@ show create table t0;
show create table t1;
show create table t2;
show create table t3;
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
drop table t0, t1, t2, t3;
# Different data types for str_to_date.
create table t0 (c int(10), c1 BLOB default (str_to_date('1980-01-01','%Y-%m-%d')));
Expand All @@ -64,9 +72,8 @@ create table t3 (c int(10), c1 SET('y','n') default (str_to_date('1980-01-01','%
INSERT INTO t0 values ();
INSERT INTO t0 values (1, DEFAULT);
SELECT * from t0;
-- error 3140
# MySQL will return an error. Related issue: https://github.com/pingcap/tidb/issues/51275.
INSERT INTO t1 values ();
-- error 3140
INSERT INTO t1 values (1, DEFAULT);
SELECT * from t1;
-- error 1265
Expand All @@ -83,6 +90,10 @@ show create table t0;
show create table t1;
show create table t2;
show create table t3;
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';
drop table t0, t1, t2, t3;
# Different data types for upper.
create table t0 (c int(10), c1 BLOB default (upper(substring_index(user(),'@',1))));
Expand Down Expand Up @@ -112,3 +123,7 @@ show create table t1;
show create table t2;
show create table t3;
drop table t0, t1, t2, t3;
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t0' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t1' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t2' AND COLUMN_NAME='c1';
SELECT column_default, extra FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='test' AND TABLE_NAME='t3' AND COLUMN_NAME='c1';

0 comments on commit dcf6087

Please sign in to comment.