From 4bfce51628d145ecb46bab99b490dda0973bdd21 Mon Sep 17 00:00:00 2001 From: Sergey Zefirov <72864488+mariadb-SergeyZefirov@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:40:10 +0300 Subject: [PATCH] Fix autoincrement filtering problems with utf-8 (#2964) MCOL-5572: Widen the autoincrement column to accomodate utf-8 encoded into weights with strnxfrm function. --- dbcon/execplan/calpontsystemcatalog.cpp | 7 +++++- .../MCOL-5572-autoincrement-filtering.result | 20 +++++++++++++++++ .../t/MCOL-5572-autoincrement-filtering.test | 22 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 mysql-test/columnstore/basic/r/MCOL-5572-autoincrement-filtering.result create mode 100644 mysql-test/columnstore/basic/t/MCOL-5572-autoincrement-filtering.test diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 53294ccc1..443d5a0b4 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -6043,7 +6043,12 @@ void CalpontSystemCatalog::buildSysColinfomap() fColinfomap[OID_SYSCOLUMN_PRECISION] = ColType(4, scale, precision, NOTNULL_CONSTRAINT, notDict, colPosition++, compressionType, OID_SYSCOLUMN_PRECISION, INT); - fColinfomap[OID_SYSCOLUMN_AUTOINC] = ColType(1, scale, precision, NO_CONSTRAINT, + // please note that column width specified in table creation is 1. + // we specify 4 because we use strnxfrm in filtering and it may convert + // data to, well, unsigned long int (my_cw_t type). But, all of the + // contemporary character sets have weights up to 32-bit, thus, here we + // specify 4-byte width which ill be enough for time being. + fColinfomap[OID_SYSCOLUMN_AUTOINC] = ColType(4, scale, precision, NO_CONSTRAINT, notDict, colPosition++, compressionType, OID_SYSCOLUMN_AUTOINC, CHAR); fColinfomap[OID_SYSCOLUMN_DISTCOUNT] = ColType(4, scale, precision, NO_CONSTRAINT, diff --git a/mysql-test/columnstore/basic/r/MCOL-5572-autoincrement-filtering.result b/mysql-test/columnstore/basic/r/MCOL-5572-autoincrement-filtering.result new file mode 100644 index 000000000..f638c9e48 --- /dev/null +++ b/mysql-test/columnstore/basic/r/MCOL-5572-autoincrement-filtering.result @@ -0,0 +1,20 @@ +SET default_storage_engine=columnstore; +DROP DATABASE IF EXISTS mcol5572; +CREATE DATABASE mcol5572; +USE mcol5572; +create table foo (col1 int) engine=columnstore; +insert into foo values ( 1 ), ( 2 ), ( 3 ), ( 4 ), ( 5 ); +Alter table foo add column newcol bigint comment 'autoincrement'; +select callastinsertid('foo'); +callastinsertid('foo') +5 +select tablename, autoincrement, nextvalue from calpontsys.syscolumn where autoincrement = 'y' and `schema`='mcol5572' and tablename='foo'; +tablename autoincrement nextvalue +foo y 6 +select tablename, autoincrement, nextvalue from calpontsys.syscolumn where autoincrement != 'n' and `schema`='mcol5572' and tablename='foo'; +tablename autoincrement nextvalue +foo y 6 +select tablename, autoincrement, nextvalue from calpontsys.syscolumn where autoincrement = 'n' and `schema`='mcol5572' and tablename='foo'; +tablename autoincrement nextvalue +foo n 1 +DROP DATABASE mcol5572; diff --git a/mysql-test/columnstore/basic/t/MCOL-5572-autoincrement-filtering.test b/mysql-test/columnstore/basic/t/MCOL-5572-autoincrement-filtering.test new file mode 100644 index 000000000..513d41df7 --- /dev/null +++ b/mysql-test/columnstore/basic/t/MCOL-5572-autoincrement-filtering.test @@ -0,0 +1,22 @@ +--source ../include/have_columnstore.inc + +SET default_storage_engine=columnstore; + +--disable_warnings +DROP DATABASE IF EXISTS mcol5572; +--enable_warnings + + +CREATE DATABASE mcol5572; +USE mcol5572; + +create table foo (col1 int) engine=columnstore; +insert into foo values ( 1 ), ( 2 ), ( 3 ), ( 4 ), ( 5 ); +Alter table foo add column newcol bigint comment 'autoincrement'; +select callastinsertid('foo'); +select tablename, autoincrement, nextvalue from calpontsys.syscolumn where autoincrement = 'y' and `schema`='mcol5572' and tablename='foo'; +select tablename, autoincrement, nextvalue from calpontsys.syscolumn where autoincrement != 'n' and `schema`='mcol5572' and tablename='foo'; +select tablename, autoincrement, nextvalue from calpontsys.syscolumn where autoincrement = 'n' and `schema`='mcol5572' and tablename='foo'; + +DROP DATABASE mcol5572; +