You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-5779: use encoding to check alter table alter column statement correctly
This commit is contained in:
committed by
Leonid Fedorov
parent
7828ded2d2
commit
539db054b3
@ -372,7 +372,7 @@ run_unit_tests()
|
|||||||
else
|
else
|
||||||
message "Running unittests"
|
message "Running unittests"
|
||||||
cd $MARIA_BUILD_PATH
|
cd $MARIA_BUILD_PATH
|
||||||
${CTEST_BIN_NAME} . -R columnstore: -j $(nproc) --progress
|
${CTEST_BIN_NAME} . -R columnstore: -j $(nproc) --progress --output-on-failure
|
||||||
cd - > /dev/null
|
cd - > /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@ using namespace ddlpackage;
|
|||||||
#include "messagelog.h"
|
#include "messagelog.h"
|
||||||
using namespace logging;
|
using namespace logging;
|
||||||
|
|
||||||
|
#include "mariadb_my_sys.h"
|
||||||
|
|
||||||
#include "we_messages.h"
|
#include "we_messages.h"
|
||||||
#include "we_ddlcommandclient.h"
|
#include "we_ddlcommandclient.h"
|
||||||
#include "we_ddlcommon.h"
|
#include "we_ddlcommon.h"
|
||||||
@ -88,6 +90,14 @@ struct extentInfo
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool checkTextTypesLengthAreEqual(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)
|
bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType& newType)
|
||||||
{
|
{
|
||||||
switch (colType.colDataType)
|
switch (colType.colDataType)
|
||||||
@ -117,7 +127,7 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case (CalpontSystemCatalog::CHAR):
|
case (CalpontSystemCatalog::CHAR):
|
||||||
if (newType.fType == DDL_CHAR && colType.colWidth == newType.fLength)
|
if (newType.fType == DDL_CHAR && checkTextTypesLengthAreEqual(colType, newType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -252,7 +262,7 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case (CalpontSystemCatalog::VARCHAR):
|
case (CalpontSystemCatalog::VARCHAR):
|
||||||
if (newType.fType == DDL_VARCHAR && colType.colWidth == newType.fLength)
|
if (newType.fType == DDL_VARCHAR && checkTextTypesLengthAreEqual(colType, newType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -738,8 +748,7 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC
|
|||||||
if ((dataType == CalpontSystemCatalog::CHAR && columnDefPtr->fType->fLength > 8) ||
|
if ((dataType == CalpontSystemCatalog::CHAR && columnDefPtr->fType->fLength > 8) ||
|
||||||
(dataType == CalpontSystemCatalog::VARCHAR && columnDefPtr->fType->fLength > 7) ||
|
(dataType == CalpontSystemCatalog::VARCHAR && columnDefPtr->fType->fLength > 7) ||
|
||||||
(dataType == CalpontSystemCatalog::VARBINARY && columnDefPtr->fType->fLength > 7) ||
|
(dataType == CalpontSystemCatalog::VARBINARY && columnDefPtr->fType->fLength > 7) ||
|
||||||
(dataType == CalpontSystemCatalog::TEXT) ||
|
(dataType == CalpontSystemCatalog::TEXT) || (dataType == CalpontSystemCatalog::BLOB))
|
||||||
(dataType == CalpontSystemCatalog::BLOB))
|
|
||||||
{
|
{
|
||||||
isDict = true;
|
isDict = true;
|
||||||
}
|
}
|
||||||
|
@ -6192,7 +6192,7 @@ CalpontSystemCatalog::ColType& CalpontSystemCatalog::ColType::operator=(const Co
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHARSET_INFO* CalpontSystemCatalog::ColType::getCharset()
|
CHARSET_INFO* CalpontSystemCatalog::ColType::getCharset() const
|
||||||
{
|
{
|
||||||
if (!cs)
|
if (!cs)
|
||||||
cs = &datatypes::Charset(charsetNumber).getCharset();
|
cs = &datatypes::Charset(charsetNumber).getCharset();
|
||||||
|
@ -224,7 +224,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
|||||||
bool autoincrement = 0; // set to true if SYSCOLUMN autoincrement is <20>y<EFBFBD>
|
bool autoincrement = 0; // set to true if SYSCOLUMN autoincrement is <20>y<EFBFBD>
|
||||||
uint64_t nextvalue = 0; // next autoincrement value
|
uint64_t nextvalue = 0; // next autoincrement value
|
||||||
uint32_t charsetNumber = default_charset_info->number;
|
uint32_t charsetNumber = default_charset_info->number;
|
||||||
const CHARSET_INFO* cs = nullptr;
|
const mutable CHARSET_INFO* cs = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long timeZone;
|
long timeZone;
|
||||||
@ -237,7 +237,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
|||||||
int32_t compressionType_, OID columnOID_, const ColDataType& colDataType_);
|
int32_t compressionType_, OID columnOID_, const ColDataType& colDataType_);
|
||||||
ColType& operator=(const ColType& rhs);
|
ColType& operator=(const ColType& rhs);
|
||||||
|
|
||||||
CHARSET_INFO* getCharset();
|
CHARSET_INFO* getCharset() const;
|
||||||
|
|
||||||
long getTimeZone() const
|
long getTimeZone() const
|
||||||
{
|
{
|
||||||
|
28
mysql-test/columnstore/bugfixes/mcol-5779.result
Normal file
28
mysql-test/columnstore/bugfixes/mcol-5779.result
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
DROP DATABASE IF EXISTS mcol5779;
|
||||||
|
CREATE DATABASE mcol5779;
|
||||||
|
USE mcol5779;
|
||||||
|
CREATE TABLE `t1` (
|
||||||
|
`id` int(11) DEFAULT NULL,
|
||||||
|
`name1` char(10) DEFAULT NULL COMMENT 'test name',
|
||||||
|
`name2` varchar(100) DEFAULT NULL COMMENT 'test name',
|
||||||
|
`name3` text DEFAULT NULL COMMENT 'test name'
|
||||||
|
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN id id1 INT;
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN id1 id INT COMMENT 'new comment';
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN name1 firstname char(10);
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN firstname firstname char(10) COMMENT 'new comment';
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN name2 lastname varchar(100);
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN lastname lastname varchar(100) COMMENT 'new comment';
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN name3 surname text;
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN surname surname text COMMENT 'new comment';
|
||||||
|
CREATE TABLE `t2` (
|
||||||
|
`name4` varchar(2666) DEFAULT NULL COMMENT 'test name'
|
||||||
|
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||||
|
ALTER TABLE t2 CHANGE COLUMN name4 pseudoname varchar(2666);
|
||||||
|
ALTER TABLE t2 CHANGE COLUMN pseudoname pseudoname varchar(2666) COMMENT 'new comment';
|
||||||
|
CREATE TABLE `t3` (
|
||||||
|
`name4` varchar(8000) DEFAULT NULL COMMENT 'test name'
|
||||||
|
) ENGINE=Columnstore DEFAULT CHARSET=latin1;
|
||||||
|
ALTER TABLE t3 CHANGE COLUMN name4 pseudoname varchar(8000);
|
||||||
|
ALTER TABLE t3 CHANGE COLUMN pseudoname pseudoname varchar(8000) COMMENT 'new comment';
|
||||||
|
DROP DATABASE mcol5779;
|
48
mysql-test/columnstore/bugfixes/mcol-5779.test
Normal file
48
mysql-test/columnstore/bugfixes/mcol-5779.test
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
--source ../include/have_columnstore.inc
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
DROP DATABASE IF EXISTS mcol5779;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
CREATE DATABASE mcol5779;
|
||||||
|
USE mcol5779;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `t1` (
|
||||||
|
`id` int(11) DEFAULT NULL,
|
||||||
|
`name1` char(10) DEFAULT NULL COMMENT 'test name',
|
||||||
|
`name2` varchar(100) DEFAULT NULL COMMENT 'test name',
|
||||||
|
`name3` text DEFAULT NULL COMMENT 'test name'
|
||||||
|
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN id id1 INT;
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN id1 id INT COMMENT 'new comment';
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN name1 firstname char(10);
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN firstname firstname char(10) COMMENT 'new comment';
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN name2 lastname varchar(100);
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN lastname lastname varchar(100) COMMENT 'new comment';
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN name3 surname text;
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN surname surname text COMMENT 'new comment';
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `t2` (
|
||||||
|
`name4` varchar(2666) DEFAULT NULL COMMENT 'test name'
|
||||||
|
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE t2 CHANGE COLUMN name4 pseudoname varchar(2666);
|
||||||
|
ALTER TABLE t2 CHANGE COLUMN pseudoname pseudoname varchar(2666) COMMENT 'new comment';
|
||||||
|
|
||||||
|
CREATE TABLE `t3` (
|
||||||
|
`name4` varchar(8000) DEFAULT NULL COMMENT 'test name'
|
||||||
|
) ENGINE=Columnstore DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE t3 CHANGE COLUMN name4 pseudoname varchar(8000);
|
||||||
|
ALTER TABLE t3 CHANGE COLUMN pseudoname pseudoname varchar(8000) COMMENT 'new comment';
|
||||||
|
|
||||||
|
DROP DATABASE mcol5779;
|
||||||
|
|
Reference in New Issue
Block a user