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
Adding NULL flag into ConstString class
This commit is contained in:
@ -518,14 +518,18 @@ inline bool isSignedInteger(const datatypes::SystemCatalog::ColDataType type)
|
||||
}
|
||||
}
|
||||
|
||||
inline bool sameSignednessInteger(const datatypes::SystemCatalog::ColDataType type1, const datatypes::SystemCatalog::ColDataType type2)
|
||||
inline bool sameSignednessInteger(const datatypes::SystemCatalog::ColDataType type1,
|
||||
const datatypes::SystemCatalog::ColDataType type2)
|
||||
{
|
||||
return (isSignedInteger(type1) && isSignedInteger(type2)) || (isUnsignedInteger(type1) && isUnsignedInteger(type2));
|
||||
return (isSignedInteger(type1) && isSignedInteger(type2)) ||
|
||||
(isUnsignedInteger(type1) && isUnsignedInteger(type2));
|
||||
}
|
||||
|
||||
inline bool differentSignednessInteger(const datatypes::SystemCatalog::ColDataType type1, const datatypes::SystemCatalog::ColDataType type2)
|
||||
inline bool differentSignednessInteger(const datatypes::SystemCatalog::ColDataType type1,
|
||||
const datatypes::SystemCatalog::ColDataType type2)
|
||||
{
|
||||
return (isSignedInteger(type1) && isUnsignedInteger(type2)) || (isUnsignedInteger(type1) && isSignedInteger(type2));
|
||||
return (isSignedInteger(type1) && isUnsignedInteger(type2)) ||
|
||||
(isUnsignedInteger(type1) && isSignedInteger(type2));
|
||||
}
|
||||
|
||||
inline void promoteSignedInteger(datatypes::SystemCatalog::TypeHolderStd& unionedType)
|
||||
@ -590,40 +594,6 @@ namespace datatypes
|
||||
static constexpr int128_t minInt128 = int128_t(0x8000000000000000LL) << 64;
|
||||
static constexpr int128_t maxInt128 = (int128_t(0x7FFFFFFFFFFFFFFFLL) << 64) + 0xFFFFFFFFFFFFFFFFLL;
|
||||
|
||||
class ConstString
|
||||
{
|
||||
const char* m_str;
|
||||
size_t m_length;
|
||||
|
||||
public:
|
||||
ConstString(const char* str, size_t length) : m_str(str), m_length(length)
|
||||
{
|
||||
}
|
||||
const char* str() const
|
||||
{
|
||||
return m_str;
|
||||
}
|
||||
const char* end() const
|
||||
{
|
||||
return m_str + m_length;
|
||||
}
|
||||
size_t length() const
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
void bin2hex(char* o)
|
||||
{
|
||||
static const char hexdig[] = {'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
const char* e = end();
|
||||
for (const char* s = m_str; s < e; s++)
|
||||
{
|
||||
*o++ = hexdig[*s >> 4];
|
||||
*o++ = hexdig[*s & 0xf];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
enum class round_style_t : uint8_t
|
||||
{
|
||||
NONE = 0,
|
||||
|
@ -92,7 +92,7 @@ class StoreFieldMariaDB : public StoreField
|
||||
{
|
||||
size_t ll = length * 2;
|
||||
boost::scoped_array<char> sca(new char[ll]);
|
||||
ConstString(str, length).bin2hex(sca.get());
|
||||
utils::ConstString(str, length).bin2hex(sca.get());
|
||||
return m_field->store_binary(sca.get(), ll);
|
||||
}
|
||||
return m_field->store_binary(str, length);
|
||||
@ -103,7 +103,7 @@ class StoreFieldMariaDB : public StoreField
|
||||
return m_field->store(val, 0);
|
||||
}
|
||||
|
||||
int store_ulonglong(uint64_t val)override
|
||||
int store_ulonglong(uint64_t val) override
|
||||
{
|
||||
return m_field->store(static_cast<int64_t>(val), 1);
|
||||
}
|
||||
@ -844,4 +844,3 @@ class WriteBatchFieldMariaDB : public WriteBatchField
|
||||
};
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
||||
|
@ -19,18 +19,21 @@
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <execinfo.h>
|
||||
#include "exceptclasses.h"
|
||||
|
||||
namespace utils
|
||||
{
|
||||
class ConstString
|
||||
{
|
||||
protected:
|
||||
const char* mStr;
|
||||
const char* mStr; // it can be NULL now.
|
||||
size_t mLength;
|
||||
|
||||
public:
|
||||
ConstString(const char* str, size_t length) : mStr(str), mLength(length)
|
||||
{
|
||||
idbassert(mStr || mLength == 0); // nullptr mStr should have zero length.
|
||||
}
|
||||
explicit ConstString(const std::string& str) : mStr(str.data()), mLength(str.length())
|
||||
{
|
||||
@ -49,6 +52,7 @@ class ConstString
|
||||
}
|
||||
std::string toString() const
|
||||
{
|
||||
idbassert(mStr);
|
||||
return std::string(mStr, mLength);
|
||||
}
|
||||
bool eq(char ch) const
|
||||
@ -73,6 +77,21 @@ class ConstString
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
void bin2hex(char* o)
|
||||
{
|
||||
static const char hexdig[] = {'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
const char* e = end();
|
||||
for (const char* s = mStr; s < e; s++)
|
||||
{
|
||||
*o++ = hexdig[*s >> 4];
|
||||
*o++ = hexdig[*s & 0xf];
|
||||
}
|
||||
}
|
||||
bool isNull() const
|
||||
{
|
||||
return mStr == nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace utils
|
||||
|
Reference in New Issue
Block a user