From 7a2ca9d6bcd08687a94173b855776058fb503700 Mon Sep 17 00:00:00 2001 From: Leonid Fedorov <79837786+mariadb-LeonidFedorov@users.noreply.github.com> Date: Wed, 20 Mar 2024 23:26:35 +0300 Subject: [PATCH] MCOL-4480: TEXT type added (#3142) * TEXT type added * tests --- dbcon/ddlpackageproc/altertableprocessor.cpp | 12 ++++++---- dbcon/mysql/ha_mcs_impl.cpp | 1 + dbcon/mysql/ha_pseudocolumn.cpp | 1 + .../columnstore/bugfixes/MCOL_5175.result | 21 ++++++++++++++++++ .../columnstore/bugfixes/MCOL_5175.test | 22 +++++++++++++++++++ .../columnstore/bugfixes/mcol-4758.result | 5 +++++ .../columnstore/bugfixes/mcol-4758.test | 6 ++--- 7 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 mysql-test/columnstore/bugfixes/MCOL_5175.result create mode 100644 mysql-test/columnstore/bugfixes/MCOL_5175.test diff --git a/dbcon/ddlpackageproc/altertableprocessor.cpp b/dbcon/ddlpackageproc/altertableprocessor.cpp index 2863b092e..a5632f7cf 100644 --- a/dbcon/ddlpackageproc/altertableprocessor.cpp +++ b/dbcon/ddlpackageproc/altertableprocessor.cpp @@ -47,6 +47,7 @@ using namespace logging; #include "we_messages.h" #include "we_ddlcommandclient.h" +#include "we_ddlcommon.h" using namespace WriteEngine; #include "oamcache.h" @@ -685,10 +686,13 @@ void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemC throw std::runtime_error(err); } - if ((columnDefPtr->fType->fType == CalpontSystemCatalog::CHAR && columnDefPtr->fType->fLength > 8) || - (columnDefPtr->fType->fType == CalpontSystemCatalog::VARCHAR && columnDefPtr->fType->fLength > 7) || - (columnDefPtr->fType->fType == CalpontSystemCatalog::VARBINARY && columnDefPtr->fType->fLength > 7) || - (columnDefPtr->fType->fType == CalpontSystemCatalog::BLOB)) + int dataType = WriteEngine::convertDataType(columnDefPtr->fType->fType); + + 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)) { isDict = true; } diff --git a/dbcon/mysql/ha_mcs_impl.cpp b/dbcon/mysql/ha_mcs_impl.cpp index 4c57e0590..fc0ec5078 100644 --- a/dbcon/mysql/ha_mcs_impl.cpp +++ b/dbcon/mysql/ha_mcs_impl.cpp @@ -401,6 +401,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, long t // @2835. Handle empty string and null confusion. store empty string for string column if (colType.colDataType == CalpontSystemCatalog::CHAR || colType.colDataType == CalpontSystemCatalog::VARCHAR || + colType.colDataType == CalpontSystemCatalog::TEXT || colType.colDataType == CalpontSystemCatalog::VARBINARY) { (*f)->reset(); diff --git a/dbcon/mysql/ha_pseudocolumn.cpp b/dbcon/mysql/ha_pseudocolumn.cpp index 04afbd39c..7bd75b6a7 100644 --- a/dbcon/mysql/ha_pseudocolumn.cpp +++ b/dbcon/mysql/ha_pseudocolumn.cpp @@ -428,6 +428,7 @@ execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool& if ((pseudoType == PSEUDO_EXTENTMIN || pseudoType == PSEUDO_EXTENTMAX) && (sc->colType().colDataType == CalpontSystemCatalog::VARBINARY || + (sc->colType().colDataType == CalpontSystemCatalog::TEXT) || (sc->colType().colDataType == CalpontSystemCatalog::VARCHAR && sc->colType().colWidth > 7) || (sc->colType().colDataType == CalpontSystemCatalog::CHAR && sc->colType().colWidth > 8))) return nullOnError(gwi, funcName); diff --git a/mysql-test/columnstore/bugfixes/MCOL_5175.result b/mysql-test/columnstore/bugfixes/MCOL_5175.result new file mode 100644 index 000000000..938d6a93e --- /dev/null +++ b/mysql-test/columnstore/bugfixes/MCOL_5175.result @@ -0,0 +1,21 @@ +DROP DATABASE IF EXISTS MCOL_5175; +CREATE DATABASE MCOL_5175; +USE MCOL_5175; +create table testtext2 ( myvalue varchar(100) )engine=Columnstore CHARSET=utf8; +show create table testtext2; +Table Create Table +testtext2 CREATE TABLE `testtext2` ( + `myvalue` varchar(100) DEFAULT NULL +) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci +alter table testtext2 add column myvalue2 text; +show create table testtext2; +Table Create Table +testtext2 CREATE TABLE `testtext2` ( + `myvalue` varchar(100) DEFAULT NULL, + `myvalue2` text DEFAULT NULL +) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci +insert into testtext2 (myvalue2) VALUES ('myvalue'); +select * from testtext2; +myvalue myvalue2 +NULL myvalue +DROP DATABASE MCOL_5175; diff --git a/mysql-test/columnstore/bugfixes/MCOL_5175.test b/mysql-test/columnstore/bugfixes/MCOL_5175.test new file mode 100644 index 000000000..9a895fc72 --- /dev/null +++ b/mysql-test/columnstore/bugfixes/MCOL_5175.test @@ -0,0 +1,22 @@ +# +# Alter table add column +# Author: Bharath, bharath.bokka@mariadb.com +# +-- source include/have_innodb.inc +-- source ../include/have_columnstore.inc + +--disable_warnings +DROP DATABASE IF EXISTS MCOL_5175; +--enable_warnings + +CREATE DATABASE MCOL_5175; +USE MCOL_5175; + +create table testtext2 ( myvalue varchar(100) )engine=Columnstore CHARSET=utf8; +show create table testtext2; +alter table testtext2 add column myvalue2 text; +show create table testtext2; +insert into testtext2 (myvalue2) VALUES ('myvalue'); +select * from testtext2; + +DROP DATABASE MCOL_5175; \ No newline at end of file diff --git a/mysql-test/columnstore/bugfixes/mcol-4758.result b/mysql-test/columnstore/bugfixes/mcol-4758.result index b3172e3af..d9eb3637b 100644 --- a/mysql-test/columnstore/bugfixes/mcol-4758.result +++ b/mysql-test/columnstore/bugfixes/mcol-4758.result @@ -11,4 +11,9 @@ INSERT INTO src VALUES (1, "Pretty Bloby Thing", "This is some text"); select * from src where c0=1 and substr(cLT, 1, 4)="This"; c0 cLB cLT 1 Pretty Bloby Thing This is some text +ALTER TABLE src ADD COLUMN (cLT2 LONGTEXT); +UPDATE src SET cLT2="My Friday Night" where c0=1; +select * from src where c0=1 and substr(cLT, 1, 4)="This"; +c0 cLB cLT cLT2 +1 Pretty Bloby Thing This is some text My Friday Night DROP DATABASE `mcol_4758`; diff --git a/mysql-test/columnstore/bugfixes/mcol-4758.test b/mysql-test/columnstore/bugfixes/mcol-4758.test index a9117a96f..b5a1991ca 100644 --- a/mysql-test/columnstore/bugfixes/mcol-4758.test +++ b/mysql-test/columnstore/bugfixes/mcol-4758.test @@ -11,9 +11,9 @@ INSERT INTO src VALUES (1, "Pretty Bloby Thing", "This is some text"); select * from src where c0=1 and substr(cLT, 1, 4)="This"; # To be uncommented when MCOL-4480 is fixed -#ALTER TABLE src ADD COLUMN (cLT2 LONGTEXT); -#UPDATE src SET cLT2="My Friday Night" where c0=1; -#select * from src where c0=1 and substr(cLT, 1, 4)="This"; +ALTER TABLE src ADD COLUMN (cLT2 LONGTEXT); +UPDATE src SET cLT2="My Friday Night" where c0=1; +select * from src where c0=1 and substr(cLT, 1, 4)="This"; # cleanup DROP DATABASE `mcol_4758`;