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-5779: use encoding to check alter table alter column statement correctly
This commit is contained in:
committed by
Leonid Fedorov
parent
eeac2addd2
commit
a46232f830
@ -45,6 +45,8 @@ using namespace ddlpackage;
|
||||
#include "messagelog.h"
|
||||
using namespace logging;
|
||||
|
||||
#include "mariadb_my_sys.h"
|
||||
|
||||
#include "we_messages.h"
|
||||
#include "we_ddlcommandclient.h"
|
||||
#include "we_ddlcommon.h"
|
||||
@ -88,6 +90,14 @@ struct extentInfo
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool checkTextTypesLengthAreUqual(const CalpontSystemCatalog::ColType& colType, const ColumnType& newType)
|
||||
{
|
||||
auto newTypeCharset = get_charset(newType.fCharsetNum, MYF(MY_WME));
|
||||
auto bytesInChar = newTypeCharset ? newTypeCharset->mbmaxlen : colType.getCharset()->mbmaxlen;
|
||||
return colType.colWidth == newType.fLength * bytesInChar;
|
||||
}
|
||||
|
||||
bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType& newType)
|
||||
{
|
||||
switch (colType.colDataType)
|
||||
@ -117,7 +127,7 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::CHAR):
|
||||
if (newType.fType == DDL_CHAR && colType.colWidth == newType.fLength)
|
||||
if (newType.fType == DDL_CHAR && checkTextTypesLengthAreUqual(colType, newType))
|
||||
return true;
|
||||
|
||||
break;
|
||||
@ -252,7 +262,7 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::VARCHAR):
|
||||
if (newType.fType == DDL_VARCHAR && colType.colWidth == newType.fLength)
|
||||
if (newType.fType == DDL_VARCHAR && checkTextTypesLengthAreUqual(colType, newType))
|
||||
return true;
|
||||
|
||||
break;
|
||||
@ -738,8 +748,7 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC
|
||||
if ((dataType == CalpontSystemCatalog::CHAR && columnDefPtr->fType->fLength > 8) ||
|
||||
(dataType == CalpontSystemCatalog::VARCHAR && columnDefPtr->fType->fLength > 7) ||
|
||||
(dataType == CalpontSystemCatalog::VARBINARY && columnDefPtr->fType->fLength > 7) ||
|
||||
(dataType == CalpontSystemCatalog::TEXT) ||
|
||||
(dataType == CalpontSystemCatalog::BLOB))
|
||||
(dataType == CalpontSystemCatalog::TEXT) || (dataType == CalpontSystemCatalog::BLOB))
|
||||
{
|
||||
isDict = true;
|
||||
}
|
||||
|
@ -6192,7 +6192,7 @@ CalpontSystemCatalog::ColType& CalpontSystemCatalog::ColType::operator=(const Co
|
||||
return *this;
|
||||
}
|
||||
|
||||
CHARSET_INFO* CalpontSystemCatalog::ColType::getCharset()
|
||||
CHARSET_INFO* CalpontSystemCatalog::ColType::getCharset() const
|
||||
{
|
||||
if (!cs)
|
||||
cs = &datatypes::Charset(charsetNumber).getCharset();
|
||||
|
@ -223,7 +223,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
||||
bool autoincrement = 0; // set to true if SYSCOLUMN autoincrement is <20>y<EFBFBD>
|
||||
uint64_t nextvalue = 0; // next autoincrement value
|
||||
uint32_t charsetNumber = default_charset_info->number;
|
||||
const CHARSET_INFO* cs = nullptr;
|
||||
const mutable CHARSET_INFO* cs = nullptr;
|
||||
|
||||
private:
|
||||
long timeZone;
|
||||
@ -236,7 +236,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
||||
const ColDataType& colDataType_);
|
||||
ColType& operator=(const ColType& rhs);
|
||||
|
||||
CHARSET_INFO* getCharset();
|
||||
CHARSET_INFO* getCharset() const;
|
||||
|
||||
long getTimeZone() const
|
||||
{
|
||||
|
Reference in New Issue
Block a user