You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
MCOL-5162 This patch allows for an automatic upgrade of syscat tables via dbbuilder.
We have added a new function, SystemCatalog::upgrade(), which will create a new column in the database and fill it with default values. It uses a reference column to fill the column, which is passed as a std::unordered_map<key, value> value to SystemCatalog::upgrade() function, where key is the target column which needs to be created. In addition, we pass additional std::unordered_map's to SystemCatalog::upgrade() containing information such as the datatypes and colwidths of the target and reference columns, as well as the default value which will be used to fill the target column.
This commit is contained in:
@@ -51,15 +51,6 @@ void SystemCatalog::build()
|
||||
ostringstream msg;
|
||||
WErrorCodes ec;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Get the DBRoot count, and rotate the tables through those DBRoots.
|
||||
// All the columns in the first table (SYSTABLE) start on DBRoot1, all the
|
||||
// columns in the second table (SYSCOLUMN) start on DBRoot2, etc.
|
||||
//------------------------------------------------------------------------------
|
||||
config::Config* cf = config::Config::makeConfig();
|
||||
string root = cf->getConfig("SystemConfig", "DBRootCount");
|
||||
uint32_t dbRootCount = cf->uFromText(root);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSTABLE table
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -249,9 +240,6 @@ void SystemCatalog::build()
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSCOLUMN table
|
||||
//------------------------------------------------------------------------------
|
||||
// dbRoot++;
|
||||
// if (dbRoot > dbRootCount)
|
||||
// dbRoot = 1;
|
||||
|
||||
// SYSCOLUMN
|
||||
if (rm->useHdfs())
|
||||
@@ -585,14 +573,6 @@ void SystemCatalog::build()
|
||||
|
||||
msg.str("");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSCONSTRAINT table
|
||||
//------------------------------------------------------------------------------
|
||||
dbRoot++;
|
||||
|
||||
if (dbRoot > dbRootCount)
|
||||
dbRoot = 1;
|
||||
|
||||
// flush data files
|
||||
fWriteEngine.flushDataFiles(rc, 1, oids);
|
||||
// save brm
|
||||
@@ -624,3 +604,51 @@ void SystemCatalog::remove()
|
||||
for (int d = 2001; d <= 2312; d++)
|
||||
colOp.deleteFile(d);
|
||||
}
|
||||
|
||||
int SystemCatalog::upgrade(const std::unordered_map<int,
|
||||
std::pair<int, bool>>& upgradeOidMap,
|
||||
std::unordered_map<int, OidTypeT> upgradeOidTypeMap,
|
||||
std::unordered_map<int, std::string> upgradeOidDefaultValStrMap)
|
||||
{
|
||||
TxnID txnID = 0;
|
||||
int rc = 0;
|
||||
int compressionType = 0;
|
||||
ostringstream msg;
|
||||
WErrorCodes ec;
|
||||
|
||||
cout << "Upgrading System Catalog..." << endl << endl;
|
||||
|
||||
for (auto iter = upgradeOidMap.begin(); iter != upgradeOidMap.end(); iter++)
|
||||
{
|
||||
if ((iter->second).second == true)
|
||||
{
|
||||
msg.str("");
|
||||
msg << " Creating column OID: " << iter->first;
|
||||
cout << msg.str() << endl;
|
||||
|
||||
execplan::CalpontSystemCatalog::ColType colType;
|
||||
colType.colDataType = upgradeOidTypeMap[iter->first].first;
|
||||
colType.colWidth = upgradeOidTypeMap[iter->first].second;
|
||||
|
||||
ColTuple defaultVal;
|
||||
std::string defaultValStr = upgradeOidDefaultValStrMap[iter->first];
|
||||
bool pushWarning = false;
|
||||
bool isNULL = false;
|
||||
long timeZone = 0;
|
||||
defaultVal.data = colType.convertColumnData(defaultValStr, pushWarning, timeZone, isNULL, false, false);
|
||||
|
||||
rc = fWriteEngine.fillColumn(txnID, iter->first, colType, defaultVal,
|
||||
(iter->second).first,
|
||||
upgradeOidTypeMap[iter->first].first,
|
||||
upgradeOidTypeMap[iter->first].second, compressionType,
|
||||
isNULL, compressionType, defaultValStr, 0, false);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Reference in New Issue
Block a user