提交 617df841 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add INFORMATION_SCHEMA.COLUMNS.DOMAIN_*

上级 68f46168
......@@ -165,6 +165,9 @@ public class MetaTable extends Table {
"TABLE_NAME",
"COLUMN_NAME",
"ORDINAL_POSITION INT",
"DOMAIN_CATALOG",
"DOMAIN_SCHEMA",
"DOMAIN_NAME",
"COLUMN_DEFAULT",
"IS_NULLABLE",
"DATA_TYPE INT",
......@@ -843,6 +846,7 @@ public class MetaTable extends Table {
String collation = database.getCompareMode().getName();
for (int j = 0; j < cols.length; j++) {
Column c = cols[j];
UserDataType domain = c.getUserDataType();
DataType dataType = c.getDataType();
ValueInt precision = ValueInt.get(c.getPrecisionAsInt());
ValueInt scale = ValueInt.get(c.getScale());
......@@ -876,6 +880,12 @@ public class MetaTable extends Table {
identifier(c.getName()),
// ORDINAL_POSITION
ValueInt.get(j + 1),
// DOMAIN_CATALOG
domain != null ? catalog : null,
// DOMAIN_SCHEMA
domain != null ? Constants.SCHEMA_MAIN : null,
// DOMAIN_NAME
domain != null ? domain.getName() : null,
// COLUMN_DEFAULT
c.getDefaultSQL(),
// IS_NULLABLE
......
......@@ -9,13 +9,13 @@ create memory table orders ( orderid varchar(10), name varchar(20), customer_id
> ok
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 DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- ------------------- ---------------- ----------
> SCRIPT PUBLIC ORDERS COMPLETED 4 null NO 3 1 1 1 10 0 null null null Unicode OFF DECIMAL 0 FALSE 50 null null NUMERIC(1) NOT NULL null TRUE
> SCRIPT PUBLIC ORDERS CUSTOMER_ID 3 null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS NAME 2 null YES 12 20 20 20 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(20) null TRUE
> SCRIPT PUBLIC ORDERS ORDERID 1 null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS VERIFIED 5 null YES 3 1 1 1 10 0 null null null Unicode OFF DECIMAL 1 FALSE 50 null null NUMERIC(1) null TRUE
> TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- ------------------- ---------------- ----------
> SCRIPT PUBLIC ORDERS COMPLETED 4 null null null null NO 3 1 1 1 10 0 null null null Unicode OFF DECIMAL 0 FALSE 50 null null NUMERIC(1) NOT NULL null TRUE
> SCRIPT PUBLIC ORDERS CUSTOMER_ID 3 null null null null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS NAME 2 null null null null YES 12 20 20 20 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(20) null TRUE
> SCRIPT PUBLIC ORDERS ORDERID 1 null null null null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS VERIFIED 5 null null null null YES 3 1 1 1 10 0 null null null Unicode OFF DECIMAL 1 FALSE 50 null null NUMERIC(1) null TRUE
> rows: 5
drop table orders;
......
......@@ -9,13 +9,13 @@ create memory table orders ( orderid varchar(10), name varchar(20), customer_id
> ok
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 DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- ------------------- ---------------- ----------
> SCRIPT PUBLIC ORDERS COMPLETED 4 null NO 2 1 1 1 10 0 null null null Unicode OFF NUMERIC 0 FALSE 50 null null NUMERIC(1) NOT NULL null TRUE
> SCRIPT PUBLIC ORDERS CUSTOMER_ID 3 null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS NAME 2 null YES 12 20 20 20 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(20) null TRUE
> SCRIPT PUBLIC ORDERS ORDERID 1 null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS VERIFIED 5 null YES 2 1 1 1 10 0 null null null Unicode OFF NUMERIC 1 FALSE 50 null null NUMERIC(1) null TRUE
> TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- ------------------- ---------------- ----------
> SCRIPT PUBLIC ORDERS COMPLETED 4 null null null null NO 2 1 1 1 10 0 null null null Unicode OFF NUMERIC 0 FALSE 50 null null NUMERIC(1) NOT NULL null TRUE
> SCRIPT PUBLIC ORDERS CUSTOMER_ID 3 null null null null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS NAME 2 null null null null YES 12 20 20 20 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(20) null TRUE
> SCRIPT PUBLIC ORDERS ORDERID 1 null null null null YES 12 10 10 10 10 0 null null null Unicode OFF VARCHAR 1 FALSE 50 null null VARCHAR(10) null TRUE
> SCRIPT PUBLIC ORDERS VERIFIED 5 null null null null YES 2 1 1 1 10 0 null null null Unicode OFF NUMERIC 1 FALSE 50 null null NUMERIC(1) null TRUE
> rows: 5
drop table orders;
......
......@@ -251,13 +251,13 @@ SELECT * FROM V3;
>> -1
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_NAME;
> 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 DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ----------
> SCRIPT PUBLIC TEST E 1 null YES 1111 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE
> SCRIPT PUBLIC V E 1 null YES 1111 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE
> SCRIPT PUBLIC V1 E 1 null YES 4 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> SCRIPT PUBLIC V2 E 1 null YES 4 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> SCRIPT PUBLIC V3 E 1 null YES 4 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ----------
> SCRIPT PUBLIC TEST E 1 null null null null YES 1111 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE
> SCRIPT PUBLIC V E 1 null null null null YES 1111 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE
> SCRIPT PUBLIC V1 E 1 null null null null YES 4 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> SCRIPT PUBLIC V2 E 1 null null null null YES 4 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> SCRIPT PUBLIC V3 E 1 null null null null YES 4 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> rows (ordered): 5
DROP VIEW V;
......
......@@ -15,14 +15,14 @@ CREATE TABLE TEST(I INT PRIMARY KEY, E1 E, E2 E NOT NULL, E3 E_NN, E4 E_NN NULL)
INSERT INTO TEST VALUES (1, 'A', 'B', 'A', 'B');
> update count: 1
SELECT COLUMN_NAME, NULLABLE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TEST' ORDER BY ORDINAL_POSITION;
> COLUMN_NAME NULLABLE COLUMN_TYPE
> ----------- -------- -------------
> I 0 INT NOT NULL
> E1 1 E
> E2 0 E NOT NULL
> E3 0 E_NN NOT NULL
> E4 1 E_NN NULL
SELECT COLUMN_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, NULLABLE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TEST' ORDER BY ORDINAL_POSITION;
> COLUMN_NAME DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME NULLABLE COLUMN_TYPE
> ----------- -------------- ------------- ----------- -------- -------------
> I null null null 0 INT NOT NULL
> E1 SCRIPT PUBLIC E 1 E
> E2 SCRIPT PUBLIC E 0 E NOT NULL
> E3 SCRIPT PUBLIC E_NN 0 E_NN NOT NULL
> E4 SCRIPT PUBLIC E_NN 1 E_NN NULL
> rows (ordered): 5
DROP DOMAIN E RESTRICT;
......@@ -34,14 +34,14 @@ DROP DOMAIN E CASCADE;
DROP DOMAIN E_NN CASCADE;
> ok
SELECT COLUMN_NAME, NULLABLE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TEST' ORDER BY ORDINAL_POSITION;
> COLUMN_NAME NULLABLE COLUMN_TYPE
> ----------- -------- -----------------------
> I 0 INT NOT NULL
> E1 1 ENUM('A', 'B')
> E2 0 ENUM('A', 'B') NOT NULL
> E3 0 ENUM('A', 'B') NOT NULL
> E4 1 ENUM('A', 'B')
SELECT COLUMN_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME, NULLABLE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TEST' ORDER BY ORDINAL_POSITION;
> COLUMN_NAME DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME NULLABLE COLUMN_TYPE
> ----------- -------------- ------------- ----------- -------- -----------------------
> I null null null 0 INT NOT NULL
> E1 null null null 1 ENUM('A', 'B')
> E2 null null null 0 ENUM('A', 'B') NOT NULL
> E3 null null null 0 ENUM('A', 'B') NOT NULL
> E4 null null null 1 ENUM('A', 'B')
> rows (ordered): 5
DROP TABLE TEST;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论