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-4758 Limit LONGTEXT and LONGBLOB to 16MB (#1995)
MCOL-4758 Limit LONGTEXT and LONGBLOB to 16MB Also add the original test case from MCOL-3879.
This commit is contained in:
@ -87,11 +87,8 @@ void fix_column_length(SchemaObject* elem, const CHARSET_INFO* def_cs) {
|
||||
column->fType->fLength = 255;
|
||||
else if (column->fType->fLength <= 65535)
|
||||
column->fType->fLength = 65535;
|
||||
else if (column->fType->fLength <= 16777215)
|
||||
else
|
||||
column->fType->fLength = 16777215;
|
||||
else if (column->fType->fLength <= 2100000000)
|
||||
column->fType->fLength = 2100000000;
|
||||
// otherwise leave the decision to a caller code
|
||||
}
|
||||
}
|
||||
|
||||
@ -1000,7 +997,7 @@ blob_type:
|
||||
| LONGBLOB
|
||||
{
|
||||
$$ = new ColumnType(DDL_BLOB);
|
||||
$$->fLength = 2100000000;
|
||||
$$->fLength = 16777215;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1029,7 +1026,7 @@ text_type:
|
||||
| LONGTEXT
|
||||
{
|
||||
$$ = new ColumnType(DDL_TEXT);
|
||||
$$->fLength = 2100000000;
|
||||
$$->fLength = 16777215;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -3157,15 +3157,12 @@ CalpontSystemCatalog::ColType colType_MysqlToIDB (const Item* item)
|
||||
case STRING_RESULT:
|
||||
ct.colDataType = CalpontSystemCatalog::VARCHAR;
|
||||
|
||||
// MCOL-697 the longest TEXT we deal with is 2100000000 so
|
||||
// limit to that. Otherwise for LONGBLOB ct.colWidth ends
|
||||
// up being -1 and demons eat your data and first born
|
||||
// (or you just get truncated to 20 bytes with the 'if'
|
||||
// below)
|
||||
if (item->max_length < 2100000000)
|
||||
// MCOL-4758 the longest TEXT we deal with is 16777215 so
|
||||
// limit to that.
|
||||
if (item->max_length < 16777215)
|
||||
ct.colWidth = item->max_length;
|
||||
else
|
||||
ct.colWidth = 2100000000;
|
||||
ct.colWidth = 16777215;
|
||||
|
||||
// force token
|
||||
if (item->type() == Item::FUNC_ITEM)
|
||||
|
@ -1,4 +1,5 @@
|
||||
drop database if exists test_mcol2000;
|
||||
SET @@SQL_MODE = CONCAT(@@SQL_MODE, ',STRICT_TRANS_TABLES');
|
||||
create database test_mcol2000;
|
||||
use test_mcol2000;
|
||||
drop table if exists orig;
|
||||
@ -1079,7 +1080,7 @@ g text 65535
|
||||
h datetime 8
|
||||
i text 16777215
|
||||
j datetime 8
|
||||
k text 2100000000
|
||||
k text 16777215
|
||||
l datetime 8
|
||||
drop table if exists cs1;
|
||||
drop table if exists cs2;
|
||||
@ -1186,7 +1187,7 @@ g text 65535
|
||||
h datetime 8
|
||||
i text 16777215
|
||||
j datetime 8
|
||||
k text 2100000000
|
||||
k text 16777215
|
||||
l datetime 8
|
||||
drop table if exists cs1;
|
||||
drop table if exists cs2;
|
||||
@ -1293,7 +1294,7 @@ g text 65535
|
||||
h datetime 8
|
||||
i text 16777215
|
||||
j datetime 8
|
||||
k text 2100000000
|
||||
k text 16777215
|
||||
l datetime 8
|
||||
drop table cs1;
|
||||
drop table cs2;
|
||||
|
@ -9,6 +9,8 @@
|
||||
drop database if exists test_mcol2000;
|
||||
-- enable_warnings
|
||||
|
||||
SET @@SQL_MODE = CONCAT(@@SQL_MODE, ',STRICT_TRANS_TABLES');
|
||||
|
||||
#let $saved_cs = `SELECT @@character_set_client`;
|
||||
#SET CHARSET utf8;
|
||||
|
||||
|
22
mysql-test/columnstore/bugfixes/mcol-3879.result
Normal file
22
mysql-test/columnstore/bugfixes/mcol-3879.result
Normal file
@ -0,0 +1,22 @@
|
||||
DROP DATABASE IF EXISTS `mcol_3879`;
|
||||
CREATE DATABASE `mcol_3879`;
|
||||
USE `mcol_3879`;
|
||||
create table t1 (
|
||||
id bigint(20) DEFAULT NULL,
|
||||
v1 varchar(32) DEFAULT NULL,
|
||||
v2 varchar(100) DEFAULT NULL,
|
||||
json1 longtext DEFAULT NULL,
|
||||
json2 longtext DEFAULT NULL,
|
||||
json3 longtext DEFAULT NULL)
|
||||
ENGINE = COLUMNSTORE
|
||||
DEFAULT CHARSET utf8mb4;
|
||||
insert into t1 (id, v1, v2) values (1, "DUP", "This is a test of a bug 1"),
|
||||
(2, "REF", "This is a test of a bug 2"),
|
||||
(1002, "REF", "This is a test of a bug 3"),
|
||||
(1002, "DUP", "This is a test of a bug 4"),
|
||||
(5, "dup", "This is a test of a bug 5");
|
||||
select * from t1 where v1 = "DUP" and id <> 1002;
|
||||
id v1 v2 json1 json2 json3
|
||||
1 DUP This is a test of a bug 1 NULL NULL NULL
|
||||
5 dup This is a test of a bug 5 NULL NULL NULL
|
||||
DROP DATABASE `mcol_3879`;
|
27
mysql-test/columnstore/bugfixes/mcol-3879.test
Normal file
27
mysql-test/columnstore/bugfixes/mcol-3879.test
Normal file
@ -0,0 +1,27 @@
|
||||
--source ../include/have_columnstore.inc
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS `mcol_3879`;
|
||||
--enable_warnings
|
||||
CREATE DATABASE `mcol_3879`;
|
||||
USE `mcol_3879`;
|
||||
|
||||
create table t1 (
|
||||
id bigint(20) DEFAULT NULL,
|
||||
v1 varchar(32) DEFAULT NULL,
|
||||
v2 varchar(100) DEFAULT NULL,
|
||||
json1 longtext DEFAULT NULL,
|
||||
json2 longtext DEFAULT NULL,
|
||||
json3 longtext DEFAULT NULL)
|
||||
ENGINE = COLUMNSTORE
|
||||
DEFAULT CHARSET utf8mb4;
|
||||
|
||||
insert into t1 (id, v1, v2) values (1, "DUP", "This is a test of a bug 1"),
|
||||
(2, "REF", "This is a test of a bug 2"),
|
||||
(1002, "REF", "This is a test of a bug 3"),
|
||||
(1002, "DUP", "This is a test of a bug 4"),
|
||||
(5, "dup", "This is a test of a bug 5");
|
||||
|
||||
select * from t1 where v1 = "DUP" and id <> 1002;
|
||||
|
||||
# cleanup
|
||||
DROP DATABASE `mcol_3879`;
|
14
mysql-test/columnstore/bugfixes/mcol-4758.result
Normal file
14
mysql-test/columnstore/bugfixes/mcol-4758.result
Normal file
@ -0,0 +1,14 @@
|
||||
DROP DATABASE IF EXISTS `mcol_4758`;
|
||||
CREATE DATABASE `mcol_4758`;
|
||||
USE `mcol_4758`;
|
||||
CREATE TABLE src (c0 INT, cLB LONGBLOB, cLT LONGTEXT)engine=columnstore default charset utf8mb4;
|
||||
SELECT column_name, data_type, column_length FROM information_schema.columnstore_columns WHERE hex(table_schema)=hex('mcol_4758') and hex(table_name)=hex('src');
|
||||
column_name data_type column_length
|
||||
c0 int 4
|
||||
clb blob 16777215
|
||||
clt text 16777215
|
||||
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
|
||||
DROP DATABASE `mcol_4758`;
|
19
mysql-test/columnstore/bugfixes/mcol-4758.test
Normal file
19
mysql-test/columnstore/bugfixes/mcol-4758.test
Normal file
@ -0,0 +1,19 @@
|
||||
--source ../include/have_columnstore.inc
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS `mcol_4758`;
|
||||
--enable_warnings
|
||||
CREATE DATABASE `mcol_4758`;
|
||||
USE `mcol_4758`;
|
||||
|
||||
CREATE TABLE src (c0 INT, cLB LONGBLOB, cLT LONGTEXT)engine=columnstore default charset utf8mb4;
|
||||
SELECT column_name, data_type, column_length FROM information_schema.columnstore_columns WHERE hex(table_schema)=hex('mcol_4758') and hex(table_name)=hex('src');
|
||||
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";
|
||||
|
||||
# cleanup
|
||||
DROP DATABASE `mcol_4758`;
|
@ -67,7 +67,7 @@ const int m_bigSpace = // free space in an empty block
|
||||
const int START_HDR1 = // start loc of 2nd offset (HDR1)
|
||||
HDR_UNIT_SIZE + NEXT_PTR_BYTES + HDR_UNIT_SIZE;
|
||||
const int PSEUDO_COL_WIDTH = DICT_COL_WIDTH; // used to convert row count to block count
|
||||
const int MAX_BLOB_SIZE = 2100000000; // for safety, we use an 18bit block count of 8KB blocks
|
||||
const int MAX_BLOB_SIZE = 16777215; // MCOL-4758 limit TEXT and BLOB to 16MB
|
||||
}
|
||||
|
||||
namespace WriteEngine
|
||||
|
Reference in New Issue
Block a user