@@ -632,7 +632,7 @@ int ObInnerTableSchema::key_column_usage_schema(ObTableSchema &table_schema)
table_schema.set_create_mem_version(1);
if(OB_SUCC(ret)){
if(OB_FAIL(table_schema.set_view_definition(R"__((select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG, c.database_name as CONSTRAINT_SCHEMA, 'PRIMARY' as CONSTRAINT_NAME, 'def' as TABLE_CATALOG, c.database_name as TABLE_SCHEMA, a.table_name as TABLE_NAME, b.column_name as COLUMN_NAME, b.rowkey_position as ORDINAL_POSITION, NULL as POSITION_IN_UNIQUE_CONSTRAINT, NULL as REFERENCED_TABLE_SCHEMA, NULL as REFERENCED_TABLE_NAME, NULL as REFERENCED_COLUMN_NAME from oceanbase.__all_virtual_table a inner join oceanbase.__all_virtual_column b on a.table_id = b.table_id inner join oceanbase.__all_virtual_database c on a.database_id = c.database_id where a.tenant_id = effective_tenant_id() and b.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and c.in_recyclebin = 0 and c.database_name != '__recyclebin' and b.rowkey_position > 0 and b.column_id >= 16 and a.table_type != 5 and b.column_flags & (0x1 << 8) = 0) union (select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG, d.database_name as CONSTRAINT_SCHEMA, substr(a.table_name, 2 + length(substring_index(a.table_name,'_',4))) as CONSTRAINT_NAME, 'def' as TABLE_CATALOG, d.database_name as TABLE_SCHEMA, c.table_name as TABLE_NAME, b.column_name as COLUMN_NAME, b.index_position as ORDINAL_POSITION, NULL as POSITION_IN_UNIQUE_CONSTRAINT, NULL as REFERENCED_TABLE_SCHEMA, NULL as REFERENCED_TABLE_NAME, NULL as REFERENCED_COLUMN_NAME from oceanbase.__all_virtual_table a inner join oceanbase.__all_virtual_column b on a.table_id = b.table_id inner join oceanbase.__all_virtual_table c on a.data_table_id = c.table_id inner join oceanbase.__all_virtual_database d on c.database_id = d.database_id where a.tenant_id = effective_tenant_id() and b.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and d.in_recyclebin = 0 and d.tenant_id = effective_tenant_id() and d.database_name != '__recyclebin' and a.table_type = 5 and a.index_type in (2, 4, 8) and b.index_position > 0) )__"))){
if(OB_FAIL(table_schema.set_view_definition(R"__((select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG, c.database_name as CONSTRAINT_SCHEMA, 'PRIMARY' as CONSTRAINT_NAME, 'def' as TABLE_CATALOG, c.database_name as TABLE_SCHEMA, a.table_name as TABLE_NAME, b.column_name as COLUMN_NAME, b.rowkey_position as ORDINAL_POSITION, NULL as POSITION_IN_UNIQUE_CONSTRAINT, NULL as REFERENCED_TABLE_SCHEMA, NULL as REFERENCED_TABLE_NAME, NULL as REFERENCED_COLUMN_NAME from oceanbase.__all_virtual_table a inner join oceanbase.__all_virtual_column b on a.table_id = b.table_id inner join oceanbase.__all_virtual_database c on a.database_id = c.database_id where a.tenant_id = effective_tenant_id() and b.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and c.in_recyclebin = 0 and c.database_name != '__recyclebin' and b.rowkey_position > 0 and b.column_id >= 16 and a.table_type != 5 and b.column_flags & (0x1 << 8) = 0) union all (select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG, d.database_name as CONSTRAINT_SCHEMA, substr(a.table_name, 2 + length(substring_index(a.table_name,'_',4))) as CONSTRAINT_NAME, 'def' as TABLE_CATALOG, d.database_name as TABLE_SCHEMA, c.table_name as TABLE_NAME, b.column_name as COLUMN_NAME, b.index_position as ORDINAL_POSITION, NULL as POSITION_IN_UNIQUE_CONSTRAINT, NULL as REFERENCED_TABLE_SCHEMA, NULL as REFERENCED_TABLE_NAME, NULL as REFERENCED_COLUMN_NAME from oceanbase.__all_virtual_table a inner join oceanbase.__all_virtual_column b on a.table_id = b.table_id inner join oceanbase.__all_virtual_table c on a.data_table_id = c.table_id inner join oceanbase.__all_virtual_database d on c.database_id = d.database_id where a.tenant_id = effective_tenant_id() and b.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and d.in_recyclebin = 0 and d.tenant_id = effective_tenant_id() and d.database_name != '__recyclebin' and a.table_type = 5 and a.index_type in (2, 4, 8) and b.index_position > 0) union all (select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG, d.database_name as CONSTRAINT_SCHEMA, f.foreign_key_name as CONSTRAINT_NAME, 'def' as TABLE_CATALOG, d.database_name as TABLE_SCHEMA, t.table_name as TABLE_NAME, c.column_name as COLUMN_NAME, fc.position as ORDINAL_POSITION, NULL as POSITION_IN_UNIQUE_CONSTRAINT, /* POSITION_IN_UNIQUE_CONSTRAINT is not supported now */ d2.database_name as REFERENCED_TABLE_SCHEMA, t2.table_name as REFERENCED_TABLE_NAME, c2.column_name as REFERENCED_COLUMN_NAME from oceanbase.__all_virtual_foreign_key f inner join oceanbase.__all_virtual_table t on f.child_table_id = t.table_id inner join oceanbase.__all_virtual_database d on t.database_id = d.database_id inner join oceanbase.__all_virtual_foreign_key_column fc on f.foreign_key_id = fc.foreign_key_id inner join oceanbase.__all_virtual_column c on fc.child_column_id = c.column_id and t.table_id = c.table_id inner join oceanbase.__all_virtual_table t2 on f.parent_table_id = t2.table_id inner join oceanbase.__all_virtual_database d2 on t2.database_id = d2.database_id inner join oceanbase.__all_virtual_column c2 on fc.parent_column_id = c2.column_id and t2.table_id = c2.table_id where f.tenant_id = effective_tenant_id() and fc.tenant_id = effective_tenant_id() and t.tenant_id = effective_tenant_id() and d.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and t2.tenant_id = effective_tenant_id() and d2.tenant_id = effective_tenant_id() and c2.tenant_id = effective_tenant_id()) )__"))){
inner join oceanbase.__all_virtual_column b on a.table_id = b.table_id
inner join oceanbase.__all_virtual_database c on a.database_id = c.database_id
where a.tenant_id = effective_tenant_id() and b.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and c.in_recyclebin = 0 and c.database_name != '__recyclebin' and b.rowkey_position > 0 and b.column_id >= 16 and a.table_type != 5 and b.column_flags & (0x1 << 8) = 0)
union (select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG,
union all (select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG,
d.database_name as CONSTRAINT_SCHEMA,
substr(a.table_name, 2 + length(substring_index(a.table_name,'_',4))) as CONSTRAINT_NAME,
'def' as TABLE_CATALOG,
...
...
@@ -10256,7 +10256,31 @@ def_table_schema(
inner join oceanbase.__all_virtual_table c on a.data_table_id = c.table_id
inner join oceanbase.__all_virtual_database d on c.database_id = d.database_id
where a.tenant_id = effective_tenant_id() and b.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id() and d.in_recyclebin = 0 and d.tenant_id = effective_tenant_id() and d.database_name != '__recyclebin' and a.table_type = 5 and a.index_type in (2, 4, 8) and b.index_position > 0)
""".replace("\n", " "),
union all (select /*+ READ_CONSISTENCY(WEAK) */ 'def' as CONSTRAINT_CATALOG,
d.database_name as CONSTRAINT_SCHEMA,
f.foreign_key_name as CONSTRAINT_NAME,
'def' as TABLE_CATALOG,
d.database_name as TABLE_SCHEMA,
t.table_name as TABLE_NAME,
c.column_name as COLUMN_NAME,
fc.position as ORDINAL_POSITION,
NULL as POSITION_IN_UNIQUE_CONSTRAINT, /* POSITION_IN_UNIQUE_CONSTRAINT is not supported now */
d2.database_name as REFERENCED_TABLE_SCHEMA,
t2.table_name as REFERENCED_TABLE_NAME,
c2.column_name as REFERENCED_COLUMN_NAME
from
oceanbase.__all_virtual_foreign_key f
inner join oceanbase.__all_virtual_table t on f.child_table_id = t.table_id
inner join oceanbase.__all_virtual_database d on t.database_id = d.database_id
inner join oceanbase.__all_virtual_foreign_key_column fc on f.foreign_key_id = fc.foreign_key_id
inner join oceanbase.__all_virtual_column c on fc.child_column_id = c.column_id and t.table_id = c.table_id
inner join oceanbase.__all_virtual_table t2 on f.parent_table_id = t2.table_id
inner join oceanbase.__all_virtual_database d2 on t2.database_id = d2.database_id
inner join oceanbase.__all_virtual_column c2 on fc.parent_column_id = c2.column_id and t2.table_id = c2.table_id
where f.tenant_id = effective_tenant_id() and fc.tenant_id = effective_tenant_id()
and t.tenant_id = effective_tenant_id() and d.tenant_id = effective_tenant_id() and c.tenant_id = effective_tenant_id()
and t2.tenant_id = effective_tenant_id() and d2.tenant_id = effective_tenant_id() and c2.tenant_id = effective_tenant_id())