diff --git a/src/observer/virtual_table/ob_information_columns_table.cpp b/src/observer/virtual_table/ob_information_columns_table.cpp index 5a4f6c330..0b679060e 100644 --- a/src/observer/virtual_table/ob_information_columns_table.cpp +++ b/src/observer/virtual_table/ob_information_columns_table.cpp @@ -887,7 +887,15 @@ int ObInfoSchemaColumnsTable::fill_row_cells(const ObString &database_name, cells[cell_idx].set_collation_type(ObCharset::get_default_collation( ObCharset::get_default_charset())); break; - } + } + case SRS_ID: { + if (!column_schema->is_default_srid()) { + cells[cell_idx].set_uint32(column_schema->get_srid()); + } else { + cells[cell_idx].reset(); + } + break; + } default: { ret = OB_ERR_UNEXPECTED; SERVER_LOG(WARN, "invalid column id", K(ret), K(cell_idx), @@ -1266,7 +1274,10 @@ int ObInfoSchemaColumnsTable::fill_row_cells(const common::ObString &database_na } case GENERATION_EXPRESSION: { break; - } + } + case SRS_ID: { + break; + } default: { ret = OB_ERR_UNEXPECTED; SERVER_LOG(WARN, "invalid column id", K(ret), K(cell_idx), diff --git a/src/observer/virtual_table/ob_information_columns_table.h b/src/observer/virtual_table/ob_information_columns_table.h index 6ffbd1575..4ea9b0201 100644 --- a/src/observer/virtual_table/ob_information_columns_table.h +++ b/src/observer/virtual_table/ob_information_columns_table.h @@ -38,7 +38,7 @@ namespace observer { class ObInfoSchemaColumnsTable : public common::ObVirtualTableScannerIterator { - static const int32_t COLUMNS_COLUMN_COUNT = 21; + static const int32_t COLUMNS_COLUMN_COUNT = 22; enum COLUMN_NAME { TABLE_SCHEMA = common::OB_APP_MIN_COLUMN_ID, TABLE_NAME, @@ -60,7 +60,8 @@ class ObInfoSchemaColumnsTable : public common::ObVirtualTableScannerIterator EXTRA, PRIVILEGES, COLUMN_COMMENT, - GENERATION_EXPRESSION + GENERATION_EXPRESSION, + SRS_ID }; public: ObInfoSchemaColumnsTable(); diff --git a/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp b/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp index de1533305..cbca7f098 100644 --- a/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp @@ -9892,6 +9892,21 @@ int ObInnerTableSchema::all_virtual_information_columns_schema(ObTableSchema &ta generation_expression_default, generation_expression_default); //default_value } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("SRS_ID", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false); //is_autoincrement + } table_schema.set_index_using_type(USING_HASH); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp b/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp index f3823fdb8..c919d26c7 100644 --- a/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp +++ b/src/share/inner_table/ob_inner_table_schema.21051_21100.cpp @@ -437,7 +437,8 @@ int ObInnerTableSchema::columns_schema(ObTableSchema &table_schema) EXTRA, PRIVILEGES, COLUMN_COMMENT, - GENERATION_EXPRESSION + GENERATION_EXPRESSION, + SRS_ID FROM OCEANBASE.__ALL_VIRTUAL_INFORMATION_COLUMNS where 0 = sys_privilege_check('table_acc', effective_tenant_id(), table_schema, table_name))__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } diff --git a/src/share/inner_table/ob_inner_table_schema_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index 2cf9bd588..82722db9b 100755 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -11270,7 +11270,8 @@ def_table_schema( ('EXTRA', 'varchar:COLUMN_EXTRA_LENGTH', 'false', ''), ('PRIVILEGES', 'varchar:MAX_COLUMN_PRIVILEGE_LENGTH', 'false', ''), ('COLUMN_COMMENT', 'longtext', 'false', ''), - ('GENERATION_EXPRESSION', 'longtext', 'false', '') + ('GENERATION_EXPRESSION', 'longtext', 'false', ''), + ('SRS_ID', 'uint32', 'true') ], ) @@ -18468,7 +18469,8 @@ def_table_schema( EXTRA, PRIVILEGES, COLUMN_COMMENT, - GENERATION_EXPRESSION + GENERATION_EXPRESSION, + SRS_ID FROM OCEANBASE.__ALL_VIRTUAL_INFORMATION_COLUMNS where 0 = sys_privilege_check('table_acc', effective_tenant_id(), table_schema, table_name)""", in_tenant_space = True, normal_columns = [ ], diff --git a/tools/deploy/mysql_test/r/mysql/information_schema.result b/tools/deploy/mysql_test/r/mysql/information_schema.result index 6ed820099..e4ac36048 100644 --- a/tools/deploy/mysql_test/r/mysql/information_schema.result +++ b/tools/deploy/mysql_test/r/mysql/information_schema.result @@ -26,6 +26,7 @@ desc information_schema.columns; | PRIVILEGES | varchar(200) | NO | | | | | COLUMN_COMMENT | longtext | NO | | | | | GENERATION_EXPRESSION | longtext | NO | | | | +| SRS_ID | int(10) unsigned | YES | | NULL | | +--------------------------+---------------------+------+-----+---------+-------+ desc information_schema.tables; +------------------------+---------------------+------+-----+---------+-------+ diff --git a/tools/deploy/mysql_test/test_suite/geometry/r/mysql/geometry_basic_mysql.result b/tools/deploy/mysql_test/test_suite/geometry/r/mysql/geometry_basic_mysql.result index a5ed1e792..e9f2574f8 100644 --- a/tools/deploy/mysql_test/test_suite/geometry/r/mysql/geometry_basic_mysql.result +++ b/tools/deploy/mysql_test/test_suite/geometry/r/mysql/geometry_basic_mysql.result @@ -123,3 +123,13 @@ Outputs & filters: is_index_back=true, is_global_index=false, range_key([gis_point.x], [gis_point.y], [gis_point.__pk_increment]), range(MIN,MIN,MIN ; MAX,MAX,MAX)always true drop table if exists gis_point; +drop table if exists t_test_srs_id_column; +CREATE TABLE `t_test_srs_id_column` ( `id` INT PRIMARY KEY, `c1` POINT NOT NULL SRID 4326, `c2` GEOMETRY NOT NULL SRID 4326, `c3` POLYGON NOT NULL SRID 4326, `c4` GEOMETRY NOT NULL ); +SELECT `COLUMN_NAME`, `COLUMN_TYPE` /*!80003 ,`SRS_ID` */ FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = 't_test_srs_id_column'; +COLUMN_NAME COLUMN_TYPE SRS_ID +id int(11) NULL +c1 point 4326 +c2 geometry 4326 +c3 polygon 4326 +c4 geometry NULL +drop table t_test_srs_id_column; diff --git a/tools/deploy/mysql_test/test_suite/geometry/t/geometry_basic_mysql.test b/tools/deploy/mysql_test/test_suite/geometry/t/geometry_basic_mysql.test index d0952d228..7064e1170 100644 --- a/tools/deploy/mysql_test/test_suite/geometry/t/geometry_basic_mysql.test +++ b/tools/deploy/mysql_test/test_suite/geometry/t/geometry_basic_mysql.test @@ -111,3 +111,12 @@ call geom_insert(10000); explain select x,y,st_astext(poi) from gis_point order by x,y desc limit 1; drop table if exists gis_point; + +# test for SRS_ID column +--disable_warnings +drop table if exists t_test_srs_id_column; +--enable_warnings +CREATE TABLE `t_test_srs_id_column` ( `id` INT PRIMARY KEY, `c1` POINT NOT NULL SRID 4326, `c2` GEOMETRY NOT NULL SRID 4326, `c3` POLYGON NOT NULL SRID 4326, `c4` GEOMETRY NOT NULL ); +SELECT `COLUMN_NAME`, `COLUMN_TYPE` /*!80003 ,`SRS_ID` */ FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = 't_test_srs_id_column'; +drop table t_test_srs_id_column; + diff --git a/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result b/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result index 4878c473d..eccf25937 100644 --- a/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result +++ b/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result @@ -40,6 +40,7 @@ EXTRA varchar(4096) NO PRIVILEGES varchar(200) NO COLUMN_COMMENT longtext NO GENERATION_EXPRESSION longtext NO +SRS_ID int(10) unsigned YES NULL desc global_status; Field Type Null Key Default Extra VARIABLE_NAME varchar(128) NO @@ -234,7 +235,8 @@ COLUMNS CREATE VIEW `COLUMNS` AS SELECT TABLE_CATALOG, EXTRA, PRIVILEGES, COLUMN_COMMENT, - GENERATION_EXPRESSION + GENERATION_EXPRESSION, + SRS_ID FROM OCEANBASE.__ALL_VIRTUAL_INFORMATION_COLUMNS where 0 = sys_privilege_check('table_acc', effective_tenant_id(), table_schema, table_name) utf8mb4 utf8mb4_general_ci show create table global_status; Table Create Table diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result index 2182cef18..3ac607260 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result @@ -1433,6 +1433,7 @@ EXTRA varchar(4096) NO PRIVILEGES varchar(200) NO COLUMN_COMMENT longtext NO GENERATION_EXPRESSION longtext NO +SRS_ID int(10) unsigned YES NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from information_schema.COLUMNS limit 1); cnt 1 diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result index bfd50547e..98f7a0f8a 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result @@ -1434,6 +1434,7 @@ EXTRA varchar(4096) NO PRIVILEGES varchar(200) NO COLUMN_COMMENT longtext NO GENERATION_EXPRESSION longtext NO +SRS_ID int(10) unsigned YES NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from information_schema.COLUMNS limit 1); cnt 1 diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result index c13a2562c..1d1a3ec61 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result @@ -1917,6 +1917,7 @@ EXTRA varchar(4096) NO PRIVILEGES varchar(200) NO COLUMN_COMMENT longtext NO GENERATION_EXPRESSION longtext NO +SRS_ID int(10) unsigned YES NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__ALL_VIRTUAL_INFORMATION_COLUMNS; IF(count(*) >= 0, 1, 0) 1 diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result index 67c518994..0bdccd0fe 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result @@ -4183,6 +4183,7 @@ EXTRA varchar(4096) NO PRIVILEGES varchar(200) NO COLUMN_COMMENT longtext NO GENERATION_EXPRESSION longtext NO +SRS_ID int(10) unsigned YES NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__ALL_VIRTUAL_INFORMATION_COLUMNS; IF(count(*) >= 0, 1, 0) 1