1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-4791 Fix ColumnCommand fudged data type format to clearly identify CHAR vs VARCHAR

This commit is contained in:
Alexander Barkov
2021-07-02 12:42:03 +04:00
parent ceb73cddcd
commit e8126bede5
22 changed files with 228 additions and 318 deletions

View File

@ -108,6 +108,44 @@ namespace
namespace execplan
{
ColumnCommandDataType::ColumnCommandDataType(const CalpontSystemCatalog::DataType &rhs,
bool fudge)
:DataType(rhs),
mIsDict(false)
{
if (!fudge)
return;
//If this is a dictionary column, fudge the numbers...
if (colDataType == CalpontSystemCatalog::VARCHAR )
colWidth++;
//If this is a dictionary column, fudge the numbers...
if ((colDataType == CalpontSystemCatalog::VARBINARY)
|| (colDataType == CalpontSystemCatalog::BLOB)
|| (colDataType == CalpontSystemCatalog::TEXT))
{
colWidth = 8;
mIsDict = true;
}
// MCOL-641 WIP
else if (colWidth > 8
&& colDataType != CalpontSystemCatalog::DECIMAL
&& colDataType != CalpontSystemCatalog::UDECIMAL)
{
colWidth = 8;
mIsDict = true;
}
//Round colWidth up
if (colWidth == 3)
colWidth = 4;
else if (colWidth == 5 || colWidth == 6 || colWidth == 7)
colWidth = 8;
}
const SOP opeq(new Operator("="));
const string colDataTypeToString(CalpontSystemCatalog::ColDataType cdt)
@ -6090,43 +6128,34 @@ CalpontSystemCatalog::ColType::ColType() :
constraintType(NO_CONSTRAINT),
defaultValue(""),
colPosition(-1),
compressionType(NO_COMPRESSION),
columnOID(0),
autoincrement(0),
nextvalue(0),
cs(NULL)
nextvalue(0)
{
charsetNumber = default_charset_info->number;
}
CalpontSystemCatalog::ColType::ColType(const ColType& rhs)
:TypeHolderStd(rhs)
:DataType(rhs)
{
constraintType = rhs.constraintType;
ddn = rhs.ddn;
defaultValue = rhs.defaultValue;
colPosition = rhs.colPosition;
compressionType = rhs.compressionType;
columnOID = rhs.columnOID;
autoincrement = rhs.autoincrement;
nextvalue = rhs.nextvalue;
charsetNumber = rhs.charsetNumber;
cs = rhs.cs;
}
CalpontSystemCatalog::ColType& CalpontSystemCatalog::ColType::operator=(const ColType& rhs)
{
TypeHolderStd::operator=(rhs);
DataType::operator=(rhs);
constraintType = rhs.constraintType;
ddn = rhs.ddn;
defaultValue = rhs.defaultValue;
colPosition = rhs.colPosition;
compressionType = rhs.compressionType;
columnOID = rhs.columnOID;
autoincrement = rhs.autoincrement;
nextvalue = rhs.nextvalue;
charsetNumber = rhs.charsetNumber;
cs = rhs.cs;
return *this;
}
@ -6134,11 +6163,11 @@ CalpontSystemCatalog::ColType& CalpontSystemCatalog::ColType::operator=(const Co
CHARSET_INFO* CalpontSystemCatalog::ColType::getCharset()
CHARSET_INFO* CalpontSystemCatalog::DataType::getCharset()
{
if (!cs)
cs= & datatypes::Charset(charsetNumber).getCharset();
return cs;
if (!mCharset)
mCharset= & datatypes::Charset(charsetNumber).getCharset();
return mCharset;
}
const string CalpontSystemCatalog::ColType::toString() const

View File

@ -198,26 +198,19 @@ public:
typedef std::vector<DictOID> DictOIDList;
/** the structure returned by colType
*
* defaultValue is only meaningful when constraintType == DEFAULT_CONSTRAINT
*/
struct ColType: public datatypes::SystemCatalog::TypeHolderStd
class DataType: public datatypes::SystemCatalog::TypeHolderStd
{
ColType();
ConstraintType constraintType;
DictOID ddn;
std::string defaultValue;
int32_t colPosition; // temporally put here. may need to have ColInfo struct later
public:
int32_t compressionType;
OID columnOID;
bool autoincrement; //set to true if SYSCOLUMN autoincrement is <20>y<EFBFBD>
uint64_t nextvalue; //next autoincrement value
uint32_t charsetNumber;
const CHARSET_INFO* cs;
ColType(const ColType& rhs);
ColType& operator=(const ColType& rhs);
protected:
const CHARSET_INFO* mCharset;
public:
DataType()
:compressionType(NO_COMPRESSION),
charsetNumber(63), // &my_charset_bin
mCharset(nullptr)
{ }
CHARSET_INFO* getCharset();
// for F&E use. only serialize necessary info for now
@ -242,6 +235,27 @@ public:
b >> (uint32_t&)compressionType;
b >> charsetNumber;
}
};
/** the structure returned by colType
*
* defaultValue is only meaningful when constraintType == DEFAULT_CONSTRAINT
*/
struct ColType: public DataType
{
ColType();
ConstraintType constraintType;
DictOID ddn;
std::string defaultValue;
int32_t colPosition; // temporally put here. may need to have ColInfo struct later
OID columnOID;
bool autoincrement; //set to true if SYSCOLUMN autoincrement is <20>y<EFBFBD>
uint64_t nextvalue; //next autoincrement value
ColType(const ColType& rhs);
ColType& operator=(const ColType& rhs);
/**
* @brief convert a columns data, represnted as a string,
@ -885,6 +899,52 @@ private:
static uint32_t fModuleID;
};
class ColumnCommandDataType: public CalpontSystemCatalog::DataType
{
bool mIsDict;
public:
ColumnCommandDataType()
:DataType(),
mIsDict(false)
{ }
explicit ColumnCommandDataType(const DataType &rhs, bool fudge);
bool isDict() const
{
return mIsDict;
}
void serialize(messageqcpp::ByteStream& bs) const
{
bs << (uint8_t) colDataType;
bs << (uint8_t) colWidth;
bs << (uint8_t) scale;
bs << (uint8_t) compressionType;
bs << (uint32_t) charsetNumber;
bs << (bool) mIsDict;
}
void unserialize(messageqcpp::ByteStream& bs)
{
uint8_t tmp8;
uint32_t tmp32;
bool tmpBool;
bs >> tmp8;
colDataType = (execplan::CalpontSystemCatalog::ColDataType) tmp8;
bs >> tmp8;
colWidth = tmp8;
bs >> tmp8;
scale = tmp8;
bs >> tmp8;
compressionType = tmp8;
bs >> tmp32;
charsetNumber = tmp32;
mCharset = nullptr;
bs >> tmpBool;
mIsDict = tmpBool;
}
};
/** convenience function to make a TableColName from 3 strings
*/
const CalpontSystemCatalog::TableColName make_tcn(const std::string& s, const std::string& t, const std::string& c, int lower_case_table_names=0);
@ -897,12 +957,12 @@ const CalpontSystemCatalog::TableAliasName make_aliastable(const std::string& s,
const CalpontSystemCatalog::TableAliasName make_aliasview(const std::string& s, const std::string& t, const std::string& a, const std::string& v,
const bool fisColumnStore = true, int lower_case_table_names=0);
inline bool isNull(int128_t val, const execplan::CalpontSystemCatalog::ColType& ct)
inline bool isNull(int128_t val, const execplan::CalpontSystemCatalog::DataType& ct)
{
return datatypes::Decimal::isWideDecimalNullValue(val);
}
inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& ct)
inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::DataType& ct)
{
bool ret = false;