[feature-wip](multi-catalog) Add catalog name to information schema. (#10349)

Information schema database need to show catalog name after multi-catalog is supported.
This part is step 1, add catalog name for schemata table.
This commit is contained in:
Jibing-Li
2022-06-25 11:53:04 +08:00
committed by GitHub
parent 3757bd521a
commit 8abd00dcd5
8 changed files with 218 additions and 59 deletions

View File

@ -72,7 +72,14 @@ Status SchemaSchemataScanner::fill_one_row(Tuple* tuple, MemPool* pool) {
memset((void*)tuple, 0, _tuple_desc->num_null_bytes());
// catalog
{ tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset()); }
{
void* slot = tuple->get_slot(_tuple_desc->slots()[0]->tuple_offset());
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
std::string catalog_name = _db_result.catalogs[_db_index];
str_slot->ptr = (char*)pool->allocate(catalog_name.size());
str_slot->len = catalog_name.size();
memcpy(str_slot->ptr, catalog_name.c_str(), str_slot->len);
}
// schema
{
void* slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());

View File

@ -89,7 +89,14 @@ Status SchemaTablesScanner::fill_one_row(Tuple* tuple, MemPool* pool) {
memset((void*)tuple, 0, _tuple_desc->num_null_bytes());
const TTableStatus& tbl_status = _table_result.tables[_table_index];
// catalog
{ tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset()); }
{
void* slot = tuple->get_slot(_tuple_desc->slots()[0]->tuple_offset());
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
std::string catalog_name = _db_result.catalogs[_db_index - 1];
str_slot->ptr = (char*)pool->allocate(catalog_name.size());
str_slot->len = catalog_name.size();
memcpy(str_slot->ptr, catalog_name.c_str(), str_slot->len);
}
// schema
{
void* slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
@ -245,7 +252,9 @@ Status SchemaTablesScanner::fill_one_row(Tuple* tuple, MemPool* pool) {
Status SchemaTablesScanner::get_new_table() {
TGetTablesParams table_params;
table_params.__set_db(_db_result.dbs[_db_index++]);
table_params.__set_db(_db_result.dbs[_db_index]);
table_params.__set_catalog(_db_result.catalogs[_db_index]);
_db_index++;
if (nullptr != _param->wild) {
table_params.__set_pattern(*(_param->wild));
}