You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-5021 Add prototype support for the AUX column in CREATE/DROP
DDL commands, single and multi-value INSERTs, cpimport, and DELETE.
This commit is contained in:
@ -682,7 +682,7 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
|
||||
if (columnOid > 0) // Column exists already
|
||||
if ((columnOid > 0) && (columnOid != OID_SYSTABLE_AUXCOLUMNOID)) // Column exists already
|
||||
{
|
||||
err = err + "Internal add column error for " + tableColName.schema + "." + tableColName.table + "." +
|
||||
tableColName.column + ". Column exists already. Your table is probably out-of-sync";
|
||||
@ -747,6 +747,22 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC
|
||||
{
|
||||
fStartingColOID = OID_SYSTABLE_AUTOINCREMENT;
|
||||
}
|
||||
else if ((inTableName.fName == SYSTABLE_TABLE) && (columnDefPtr->fName == AUXCOLUMNOID_COL))
|
||||
{
|
||||
fStartingColOID = OID_SYSTABLE_AUXCOLUMNOID;
|
||||
|
||||
if (!columnDefPtr->fDefaultValue || columnDefPtr->fDefaultValue->fValue != "0" ||
|
||||
columnDefPtr->fConstraints.size() != 1 || !columnDefPtr->fConstraints[0] ||
|
||||
columnDefPtr->fConstraints[0]->fConstraintType != ddlpackage::DDL_NOT_NULL ||
|
||||
columnDefPtr->fType->fType != CalpontSystemCatalog::INT ||
|
||||
columnDefPtr->fType->fLength != 4)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Error adding " << AUXCOLUMNOID_COL << " column to calpontsys table.";
|
||||
oss << " Column should be of type integer, added with NOT NULL constraint and default value of 0";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
}
|
||||
else if ((inTableName.fName == SYSCOLUMN_TABLE) && (columnDefPtr->fName == COMPRESSIONTYPE_COL))
|
||||
{
|
||||
fStartingColOID = OID_SYSCOLUMN_COMPRESSIONTYPE;
|
||||
@ -1003,12 +1019,6 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC
|
||||
else
|
||||
bs << (uint32_t)0;
|
||||
|
||||
// new column info
|
||||
bs << (ByteStream::byte)dataType;
|
||||
bs << (ByteStream::byte)autoincrement;
|
||||
bs << (uint32_t)columnDefPtr->fType->fLength;
|
||||
bs << (uint32_t)columnDefPtr->fType->fScale;
|
||||
bs << (uint32_t)columnDefPtr->fType->fPrecision;
|
||||
std::string tmpStr("");
|
||||
|
||||
if (columnDefPtr->fDefaultValue)
|
||||
@ -1016,6 +1026,13 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC
|
||||
tmpStr = columnDefPtr->fDefaultValue->fValue;
|
||||
}
|
||||
|
||||
// new column info
|
||||
bs << (ByteStream::byte)dataType;
|
||||
bs << (ByteStream::byte)autoincrement;
|
||||
bs << (uint32_t)columnDefPtr->fType->fLength;
|
||||
bs << (uint32_t)columnDefPtr->fType->fScale;
|
||||
bs << (uint32_t)columnDefPtr->fType->fPrecision;
|
||||
|
||||
bs << tmpStr;
|
||||
bs << (ByteStream::byte)columnDefPtr->fType->fCompressiontype;
|
||||
// ref column info
|
||||
|
@ -267,12 +267,17 @@ keepGoing:
|
||||
numDictCols++;
|
||||
}
|
||||
|
||||
fStartingColOID = fObjectIDManager.allocOIDs(numColumns + numDictCols +
|
||||
1); // include column, oids,dictionary oids and tableoid
|
||||
// Include column oids, dictionary oids, tableoid, and
|
||||
// also include AUX oid as of MCOL-5021
|
||||
fStartingColOID = fObjectIDManager.allocOIDs(numColumns + numDictCols + 2);
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " Create table allocOIDs got the starting oid " << fStartingColOID << endl;
|
||||
#endif
|
||||
|
||||
uint32_t size = numColumns + numDictCols;
|
||||
idbassert(size > 0);
|
||||
size += 1; // MCOL-5021
|
||||
|
||||
if (fStartingColOID < 0)
|
||||
{
|
||||
result.result = CREATE_ERROR;
|
||||
@ -295,6 +300,7 @@ keepGoing:
|
||||
bytestream << (uint32_t)createTableStmt.fSessionID;
|
||||
bytestream << (uint32_t)txnID.id;
|
||||
bytestream << (uint32_t)fStartingColOID;
|
||||
bytestream << (uint32_t)(fStartingColOID + size);
|
||||
bytestream << (uint32_t)createTableStmt.fTableWithAutoi;
|
||||
uint16_t dbRoot;
|
||||
BRM::OID_t sysOid = 1001;
|
||||
@ -537,7 +543,7 @@ keepGoing:
|
||||
bytestream << (ByteStream::byte)WE_SVR_WRITE_CREATETABLEFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)txnID.id;
|
||||
bytestream << (numColumns + numDictCols);
|
||||
bytestream << size;
|
||||
unsigned colNum = 0;
|
||||
unsigned dictNum = 0;
|
||||
|
||||
@ -601,6 +607,15 @@ keepGoing:
|
||||
++iter;
|
||||
}
|
||||
|
||||
// MCOL-5021
|
||||
// TODO compressionType is hardcoded to 2 (SNAPPY)
|
||||
bytestream << (fStartingColOID + size);
|
||||
bytestream << (uint8_t)datatypes::SystemCatalog::UTINYINT;
|
||||
bytestream << (uint8_t) false;
|
||||
bytestream << (uint32_t)1;
|
||||
bytestream << (uint16_t)useDBRoot;
|
||||
bytestream << (uint32_t)2;
|
||||
|
||||
//@Bug 4176. save oids to a log file for cleanup after fail over.
|
||||
std::vector<CalpontSystemCatalog::OID> oidList;
|
||||
|
||||
@ -616,6 +631,9 @@ keepGoing:
|
||||
oidList.push_back(fStartingColOID + numColumns + i + 1);
|
||||
}
|
||||
|
||||
// MCOL-5021
|
||||
oidList.push_back(fStartingColOID + size);
|
||||
|
||||
try
|
||||
{
|
||||
createWriteDropLogFile(fStartingColOID, uniqueId, oidList);
|
||||
@ -683,9 +701,9 @@ keepGoing:
|
||||
bytestream.restart();
|
||||
bytestream << (ByteStream::byte)WE_SVR_WRITE_DROPFILES;
|
||||
bytestream << uniqueId;
|
||||
bytestream << (uint32_t)(numColumns + numDictCols);
|
||||
bytestream << (uint32_t)size;
|
||||
|
||||
for (unsigned i = 0; i < (numColumns + numDictCols); i++)
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
{
|
||||
bytestream << (uint32_t)(fStartingColOID + i + 1);
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
CalpontSystemCatalog::OID tableAUXColOid;
|
||||
std::string errorMsg;
|
||||
ByteStream bytestream;
|
||||
uint64_t uniqueId = 0;
|
||||
@ -145,6 +146,7 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(
|
||||
try
|
||||
{
|
||||
roPair = systemCatalogPtr->tableRID(tableName);
|
||||
tableAUXColOid = systemCatalogPtr->tableAUXColumnOID(tableName);
|
||||
}
|
||||
catch (IDBExcept& ie)
|
||||
{
|
||||
@ -580,6 +582,18 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(
|
||||
return result;
|
||||
}
|
||||
|
||||
// MCOL-5021 Valid AUX column OID for a table is > 3000
|
||||
// Tables that were created before this feature was added will have
|
||||
// tableAUXColOid = 0
|
||||
if (tableAUXColOid > 3000)
|
||||
{
|
||||
oidList.push_back(tableAUXColOid);
|
||||
CalpontSystemCatalog::ROPair auxRoPair;
|
||||
auxRoPair.rid = 0;
|
||||
auxRoPair.objnum = tableAUXColOid;
|
||||
tableColRidList.push_back(auxRoPair);
|
||||
}
|
||||
|
||||
// Save the oids to a file
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user