提交 a906ce7f authored 作者: Noel Grandin's avatar Noel Grandin

Issue #654: List ENUM type values in INFORMATION_SCHEMA.COLUMNS

上级 ac33aa6d
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #654: List ENUM type values in INFORMATION_SCHEMA.COLUMNS
</li>
<li>Issue #668: Fail of an update command on large table with ENUM column <li>Issue #668: Fail of an update command on large table with ENUM column
</li> </li>
<li>Issue #662: column called CONSTRAINT is not properly escaped when storing to metadata <li>Issue #662: column called CONSTRAINT is not properly escaped when storing to metadata
......
...@@ -471,9 +471,17 @@ public class Column { ...@@ -471,9 +471,17 @@ public class Column {
} }
} }
public String getCreateSQLWithoutName() {
return getCreateSQL(false);
}
public String getCreateSQL() { public String getCreateSQL() {
return getCreateSQL(true);
}
private String getCreateSQL(boolean includeName) {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
if (name != null) { if (includeName && name != null) {
buff.append(Parser.quoteIdentifier(name)).append(' '); buff.append(Parser.quoteIdentifier(name)).append(' ');
} }
if (originalSQL != null) { if (originalSQL != null) {
......
...@@ -174,7 +174,8 @@ public class MetaTable extends Table { ...@@ -174,7 +174,8 @@ public class MetaTable extends Table {
"CHECK_CONSTRAINT", "CHECK_CONSTRAINT",
"SEQUENCE_NAME", "SEQUENCE_NAME",
"REMARKS", "REMARKS",
"SOURCE_DATA_TYPE SMALLINT" "SOURCE_DATA_TYPE SMALLINT",
"COLUMN_TYPE"
); );
indexColumnName = "TABLE_NAME"; indexColumnName = "TABLE_NAME";
break; break;
...@@ -828,7 +829,9 @@ public class MetaTable extends Table { ...@@ -828,7 +829,9 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(c.getComment()), replaceNullWithEmpty(c.getComment()),
// SOURCE_DATA_TYPE // SOURCE_DATA_TYPE
null null,
// COLUMN_TYPE
c.getCreateSQLWithoutName()
); );
} }
} }
......
...@@ -48,6 +48,12 @@ select rank from card where suit = 'diamonds'; ...@@ -48,6 +48,12 @@ select rank from card where suit = 'diamonds';
> ---- > ----
> 8 > 8
select column_type from information_schema.columns where COLUMN_NAME = 'SUIT';
> COLUMN_TYPE
> ------------------------------------------
> ENUM('hearts','clubs','spades','diamonds')
> rows: 1
--- ENUM integer-based operations --- ENUM integer-based operations
select rank from card where suit = 1; select rank from card where suit = 1;
......
...@@ -2705,13 +2705,13 @@ create memory table orders ( orderid varchar(10), name varchar(20), customer_id ...@@ -2705,13 +2705,13 @@ create memory table orders ( orderid varchar(10), name varchar(20), customer_id
> ok > ok
select * from information_schema.columns where table_name = 'ORDERS'; select * from information_schema.columns where table_name = 'ORDERS';
> 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_PRECISION_RADIX NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE > 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_PRECISION_RADIX NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE
> ------------- ------------ ---------- ----------- ---------------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- > ------------- ------------ ---------- ----------- ---------------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------------
> SCRIPT PUBLIC ORDERS COMPLETED 4 null NO 3 1 1 1 10 0 Unicode OFF DECIMAL 0 FALSE 50 null null > SCRIPT PUBLIC ORDERS COMPLETED 4 null NO 3 1 1 1 10 0 Unicode OFF DECIMAL 0 FALSE 50 null null NUMERIC(1) NOT NULL
> SCRIPT PUBLIC ORDERS CUSTOMER_ID 3 null YES 12 10 10 10 10 0 Unicode OFF VARCHAR 1 FALSE 50 null null > SCRIPT PUBLIC ORDERS CUSTOMER_ID 3 null YES 12 10 10 10 10 0 Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10)
> SCRIPT PUBLIC ORDERS NAME 2 null YES 12 20 20 20 10 0 Unicode OFF VARCHAR 1 FALSE 50 null null > SCRIPT PUBLIC ORDERS NAME 2 null YES 12 20 20 20 10 0 Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(20)
> SCRIPT PUBLIC ORDERS ORDERID 1 null YES 12 10 10 10 10 0 Unicode OFF VARCHAR 1 FALSE 50 null null > SCRIPT PUBLIC ORDERS ORDERID 1 null YES 12 10 10 10 10 0 Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10)
> SCRIPT PUBLIC ORDERS VERIFIED 5 null YES 3 1 1 1 10 0 Unicode OFF DECIMAL 1 FALSE 50 null null > SCRIPT PUBLIC ORDERS VERIFIED 5 null YES 3 1 1 1 10 0 Unicode OFF DECIMAL 1 FALSE 50 null null NUMERIC(1)
> rows: 5 > rows: 5
drop table orders; drop table orders;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论