1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

MCOL-739 Add command to get the system catalog

Added to DBRM master for use with the the new API so that it can get the
system catalog via the wire protocol.
This commit is contained in:
Andrew Hutchings
2017-06-06 14:17:23 +01:00
parent ba7825cce6
commit ab9e0a509d
3 changed files with 63 additions and 0 deletions

View File

@ -362,6 +362,7 @@ void MasterDBRMNode::msgProcessor()
case SETREADONLY: doSetReadOnly(p->sock, true); continue;
case SETREADWRITE: doSetReadOnly(p->sock, false); continue;
case GETREADONLY: doGetReadOnly(p->sock); continue;
case GET_SYSTEM_CATALOG: doGetSystemCatalog(msg, p); continue;
}
/* Process SessionManager calls */
@ -1093,6 +1094,66 @@ void MasterDBRMNode::doVerID(ByteStream &msg, ThreadParams *p)
catch (exception&) { }
}
void MasterDBRMNode::doGetSystemCatalog(ByteStream &msg, ThreadParams *p)
{
ByteStream reply;
reply << (uint8_t) ERR_OK;
boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatalogPtr =
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog();
const std::vector< std::pair<execplan::CalpontSystemCatalog::OID, execplan::CalpontSystemCatalog::TableName> > catalog_tables
= systemCatalogPtr->getTables();
reply << (uint32_t) systemCatalogPtr->getTableCount();
for (std::vector<std::pair<execplan::CalpontSystemCatalog::OID, execplan::CalpontSystemCatalog::TableName> >::const_iterator it = catalog_tables.begin();
it != catalog_tables.end(); ++it)
{
execplan::CalpontSystemCatalog::TableInfo tb_info = systemCatalogPtr->tableInfo((*it).second);
reply << (uint32_t)(*it).first;
reply << (*it).second.schema;
reply << (*it).second.table;
reply << (uint32_t)tb_info.numOfCols;
execplan::CalpontSystemCatalog::RIDList column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true);
for (size_t col_num = 0; col_num < column_rid_list.size(); col_num++)
{
execplan::CalpontSystemCatalog::TableColName tcn = systemCatalogPtr->colName(column_rid_list[col_num].objnum);
execplan::CalpontSystemCatalog::ColType ct = systemCatalogPtr->colType(column_rid_list[col_num].objnum);
reply << (uint32_t)column_rid_list[col_num].objnum;
reply << tcn.column;
if (ct.ddn.dictOID == std::numeric_limits<int32_t>::min())
{
reply << (uint32_t) 0;
}
else
{
reply << (uint32_t) ct.ddn.dictOID;
}
reply << (uint8_t) ct.colDataType;
reply << (uint32_t) ct.colWidth;
reply << (uint32_t) ct.colPosition;
reply << ct.defaultValue;
reply << (uint8_t) ct.autoincrement;
reply << (uint32_t) ct.precision;
reply << (uint32_t) ct.scale;
if (ct.constraintType != execplan::CalpontSystemCatalog::NOTNULL_CONSTRAINT)
{
reply << (uint8_t) 1;
}
else
{
reply << (uint8_t) 0;
}
reply << (uint8_t) ct.compressionType;
}
}
try {
p->sock->write(reply);
}
catch (exception&) { }
}
void MasterDBRMNode::doSysCatVerID(ByteStream &msg, ThreadParams *p)
{
ByteStream reply;