modify information_schema.key_column_usage
This commit is contained in:
parent
254957d87e
commit
c7e696325a
@ -367,32 +367,38 @@ int ObInfoSchemaPartitionsTable::add_partitions(
|
||||
}
|
||||
case TABLE_ROWS: {
|
||||
// TODO no row info now
|
||||
cells[cell_idx].set_uint64(0);
|
||||
// cells[cell_idx].set_uint64(0);
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
case AVG_ROW_LENGTH: {
|
||||
// TODO no row info now
|
||||
cells[cell_idx].set_uint64(0);
|
||||
// cells[cell_idx].set_uint64(0);
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
case DATA_LENGTH: {
|
||||
// TODO no row info now
|
||||
cells[cell_idx].set_uint64(0);
|
||||
// cells[cell_idx].set_uint64(0);
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
case MAX_DATA_LENGTH: {
|
||||
// TODO no row info now
|
||||
cells[cell_idx].set_uint64(0);
|
||||
// cells[cell_idx].set_uint64(0);
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
case INDEX_LENGTH: {
|
||||
// TODO no row info now
|
||||
cells[cell_idx].set_uint64(0);
|
||||
// cells[cell_idx].set_uint64(0);
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
case DATA_FREE: {
|
||||
// TODO no row info now
|
||||
cells[cell_idx].set_uint64(0);
|
||||
// cells[cell_idx].set_uint64(0);
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
case CREATE_TIME: {
|
||||
|
@ -1659,20 +1659,20 @@ int ObInnerTableSchema::all_virtual_processlist_schema(ObTableSchema &table_sche
|
||||
if (OB_SUCC(ret)) {
|
||||
ObObj trace_id_default;
|
||||
trace_id_default.set_varchar(ObString::make_string(""));
|
||||
ADD_COLUMN_SCHEMA_T("trace_id", // column_name
|
||||
++column_id, // column_id
|
||||
0, // rowkey_id
|
||||
0, // index_id
|
||||
0, // part_key_pos
|
||||
ObVarcharType, // column_type
|
||||
CS_TYPE_INVALID, // column_collation_type
|
||||
OB_MAX_TRACE_ID_BUFFER_SIZE, // column_length
|
||||
-1, // column_precision
|
||||
-1, // column_scale
|
||||
true, // is_nullable
|
||||
false, // is_autoincrement
|
||||
trace_id_default,
|
||||
trace_id_default); // default_value
|
||||
ADD_COLUMN_SCHEMA_T("trace_id", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
OB_MAX_TRACE_ID_BUFFER_SIZE, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false, //is_autoincrement
|
||||
trace_id_default,
|
||||
trace_id_default); //default_value
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
table_schema.get_part_option().set_part_func_type(PARTITION_FUNC_TYPE_HASH);
|
||||
|
@ -13451,18 +13451,18 @@ int ObInnerTableSchema::all_virtual_processlist_ora_schema(ObTableSchema &table_
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("TRACE_ID", // column_name
|
||||
++column_id, // column_id
|
||||
0, // rowkey_id
|
||||
0, // index_id
|
||||
0, // part_key_pos
|
||||
ObVarcharType, // column_type
|
||||
CS_TYPE_UTF8MB4_BIN, // column_collation_type
|
||||
OB_MAX_TRACE_ID_BUFFER_SIZE, // column_length
|
||||
2, // column_precision
|
||||
-1, // column_scale
|
||||
true, // is_nullable
|
||||
false); // is_autoincrement
|
||||
ADD_COLUMN_SCHEMA("TRACE_ID", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_UTF8MB4_BIN, //column_collation_type
|
||||
OB_MAX_TRACE_ID_BUFFER_SIZE, //column_length
|
||||
2, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
table_schema.get_part_option().set_part_func_type(PARTITION_FUNC_TYPE_HASH);
|
||||
|
@ -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()) )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
|
@ -10239,7 +10239,7 @@ def_table_schema(
|
||||
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())
|
||||
""".replace("\n", " "),
|
||||
|
||||
in_tenant_space = True,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user