Commit 991b9ee7 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535

parent 93aadda5
......@@ -4375,5 +4375,27 @@ SEC_TO_TIME(CONVERT(900*24*60*60 USING ucs2))
Warnings:
Warning 1292 Truncated incorrect time value: '77760000'
#
# MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
#
CREATE TABLE t1 (c1 VARCHAR(32766) CHARACTER SET ucs2);
DESCRIBE t1;
Field Type Null Key Default Extra
c1 varchar(32766) YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(32767) CHARACTER SET ucs2);
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 text YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(32768) CHARACTER SET ucs2);
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 mediumtext YES NULL
DROP TABLE t1;
#
# End of 5.5 tests
#
......@@ -1283,5 +1283,20 @@ NO_ENGINE_SUBSTITUTION
SET sql_mode=DEFAULT;
SET NAMES utf8;
#
# MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
#
CREATE TABLE t1 (c1 VARCHAR(16383) CHARACTER SET utf32);
DESCRIBE t1;
Field Type Null Key Default Extra
c1 varchar(16383) YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(16384) CHARACTER SET utf32);
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 mediumtext YES NULL
DROP TABLE t1;
#
# End of 5.5 tests
#
......@@ -5933,5 +5933,27 @@ Warnings:
SET sql_mode=DEFAULT;
DROP TABLE t1;
#
# MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
#
CREATE TABLE t1 (c1 VARCHAR(21844) CHARACTER SET utf8);
DESCRIBE t1;
Field Type Null Key Default Extra
c1 varchar(21844) YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(21845) CHARACTER SET utf8);
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 text YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(21846) CHARACTER SET utf8);
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 mediumtext YES NULL
DROP TABLE t1;
#
# End of 5.5 tests
#
......@@ -27,7 +27,7 @@ create table t1 (a int(256));
ERROR 42000: Display width out of range for 'a' (max = 255)
set sql_mode='traditional';
create table t1 (a varchar(66000));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
ERROR 42000: Column length too big for column 'a' (max = 65532); use BLOB or TEXT instead
set sql_mode=default;
CREATE TABLE t1 (a INT);
SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
......
......@@ -1697,7 +1697,14 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(65535));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` text
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
set storage_engine=MyISAM;
set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1;
......
......@@ -314,12 +314,14 @@ bbbb
drop table t1;
create table t1 (a varchar(3070)) partition by key (a);
ERROR HY000: The total length of the partitioning fields is too large
create table t1 (a varchar(65532) not null) partition by key (a);
ERROR HY000: The total length of the partitioning fields is too large
create table t1 (a varchar(65533)) partition by key (a);
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
ERROR HY000: A BLOB field is not allowed in partition function
create table t1 (a varchar(65534) not null) partition by key (a);
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
ERROR HY000: A BLOB field is not allowed in partition function
create table t1 (a varchar(65535)) partition by key (a);
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
ERROR HY000: A BLOB field is not allowed in partition function
create table t1 (a bit(27), primary key (a)) engine=myisam
partition by hash (a)
(partition p0, partition p1, partition p2);
......
......@@ -959,7 +959,7 @@ def information_schema COLUMNS COLUMNS TABLE_CATALOG TABLE_CATALOG 253 1536 3 N
def information_schema COLUMNS COLUMNS TABLE_SCHEMA TABLE_SCHEMA 253 192 4 N 1 0 33
def information_schema COLUMNS COLUMNS TABLE_NAME TABLE_NAME 253 192 2 N 1 0 33
def information_schema COLUMNS COLUMNS COLUMN_NAME COLUMN_NAME 253 192 1 N 1 0 33
def information_schema COLUMNS COLUMNS COLUMN_DEFAULT COLUMN_DEFAULT 252 589815 0 Y 16 0 33
def information_schema COLUMNS COLUMNS COLUMN_DEFAULT COLUMN_DEFAULT 252 589788 0 Y 16 0 33
def information_schema COLUMNS COLUMNS IS_NULLABLE IS_NULLABLE 253 9 2 N 1 0 33
def information_schema COLUMNS COLUMNS DATA_TYPE DATA_TYPE 253 192 3 N 1 0 33
def information_schema COLUMNS COLUMNS CHARACTER_SET_NAME CHARACTER_SET_NAME 253 96 0 Y 0 0 33
......@@ -984,7 +984,7 @@ def information_schema COLUMNS COLUMNS COLUMN_NAME Field 253 192 1 N 1 0 33
def information_schema COLUMNS COLUMNS COLUMN_TYPE Type 252 589815 7 N 17 0 33
def information_schema COLUMNS COLUMNS IS_NULLABLE Null 253 9 2 N 1 0 33
def information_schema COLUMNS COLUMNS COLUMN_KEY Key 253 9 3 N 1 0 33
def information_schema COLUMNS COLUMNS COLUMN_DEFAULT Default 252 589815 0 Y 16 0 33
def information_schema COLUMNS COLUMNS COLUMN_DEFAULT Default 252 589788 0 Y 16 0 33
def information_schema COLUMNS COLUMNS EXTRA Extra 253 81 0 N 1 0 33
Field Type Null Key Default Extra
c int(11) NO PRI NULL
......
......@@ -1240,9 +1240,9 @@ Warning 1364 Field 'i' doesn't have a default value
DROP TABLE t1;
set @@sql_mode='traditional';
create table t1(a varchar(65537));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
ERROR 42000: Column length too big for column 'a' (max = 65532); use BLOB or TEXT instead
create table t1(a varbinary(65537));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
ERROR 42000: Column length too big for column 'a' (max = 65532); use BLOB or TEXT instead
set @@sql_mode='traditional';
create table t1(a int, b date not null);
alter table t1 modify a bigint unsigned not null;
......
......@@ -37,7 +37,7 @@ ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT
CREATE TABLE t2 (a char(256));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t1 (a varchar(70000) default "hello");
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
ERROR 42000: Column length too big for column 'a' (max = 65532); use BLOB or TEXT instead
CREATE TABLE t2 (a blob default "hello");
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
drop table if exists t1,t2;
......
......@@ -510,3 +510,72 @@ SELECT 5 = a FROM t1;
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 's '
DROP TABLE t1;
#
# MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
#
CREATE TABLE t1 (c1 VARBINARY(65532));
DESCRIBE t1;
Field Type Null Key Default Extra
c1 varbinary(65532) YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65533));
Warnings:
Note 1246 Converting column 'c1' from VARBINARY to BLOB
DESCRIBE t1;
Field Type Null Key Default Extra
c1 blob YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65534));
Warnings:
Note 1246 Converting column 'c1' from VARBINARY to BLOB
DESCRIBE t1;
Field Type Null Key Default Extra
c1 blob YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65535));
Warnings:
Note 1246 Converting column 'c1' from VARBINARY to BLOB
DESCRIBE t1;
Field Type Null Key Default Extra
c1 blob YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65536));
Warnings:
Note 1246 Converting column 'c1' from VARBINARY to BLOB
DESCRIBE t1;
Field Type Null Key Default Extra
c1 mediumblob YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65532));
DESCRIBE t1;
Field Type Null Key Default Extra
c1 varchar(65532) YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65533));
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 text YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65534));
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 text YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65535));
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 text YES NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65536));
Warnings:
Note 1246 Converting column 'c1' from VARCHAR to TEXT
DESCRIBE t1;
Field Type Null Key Default Extra
c1 mediumtext YES NULL
DROP TABLE t1;
......@@ -1586,7 +1586,14 @@ t1 CREATE TABLE `t1` (
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
drop table t1;
create table t1 (v varchar(65535));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` text
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
drop table t1;
set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1;
create table t1 (a int) ROW_FORMAT=FIXED;
......
......@@ -924,8 +924,9 @@ show create table t1;
drop table t1;
# ARIA specific varchar tests
--error 1118
create table t1 (v varchar(65535));
show create table t1;
drop table t1;
#
# Test concurrent insert
......
......@@ -868,6 +868,22 @@ SET NAMES utf8;
SELECT SEC_TO_TIME(CONVERT(900*24*60*60 USING ucs2));
--echo #
--echo # MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
--echo #
CREATE TABLE t1 (c1 VARCHAR(32766) CHARACTER SET ucs2);
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(32767) CHARACTER SET ucs2);
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(32768) CHARACTER SET ucs2);
DESCRIBE t1;
DROP TABLE t1;
--echo #
--echo # End of 5.5 tests
......
......@@ -890,6 +890,19 @@ SELECT @@sql_mode;
SET sql_mode=DEFAULT;
SET NAMES utf8;
--echo #
--echo # MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
--echo #
CREATE TABLE t1 (c1 VARCHAR(16383) CHARACTER SET utf32);
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(16384) CHARACTER SET utf32);
DESCRIBE t1;
DROP TABLE t1;
--echo #
--echo # End of 5.5 tests
--echo #
......@@ -1695,6 +1695,22 @@ SELECT CHAR(i USING utf8) FROM t1;
SET sql_mode=DEFAULT;
DROP TABLE t1;
--echo #
--echo # MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
--echo #
CREATE TABLE t1 (c1 VARCHAR(21844) CHARACTER SET utf8);
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(21845) CHARACTER SET utf8);
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(21846) CHARACTER SET utf8);
DESCRIBE t1;
DROP TABLE t1;
--echo #
--echo # End of 5.5 tests
--echo #
......@@ -1030,8 +1030,9 @@ show create table t1;
drop table t1;
# MyISAM specific varchar tests
--error 1118
create table t1 (v varchar(65535));
show create table t1;
drop table t1;
eval set storage_engine=$default;
......
......@@ -217,11 +217,13 @@ select * from t1 where a = 'bbbb';
drop table t1;
-- error ER_PARTITION_FIELDS_TOO_LONG
create table t1 (a varchar(3070)) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
-- error ER_PARTITION_FIELDS_TOO_LONG
create table t1 (a varchar(65532) not null) partition by key (a);
-- error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
create table t1 (a varchar(65533)) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
-- error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
create table t1 (a varchar(65534) not null) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
-- error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
create table t1 (a varchar(65535)) partition by key (a);
#
......
......@@ -217,3 +217,47 @@ CREATE TABLE t1 (a CHAR(16));
INSERT INTO t1 VALUES ('5'), ('s'), ('');
SELECT 5 = a FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
--echo #
CREATE TABLE t1 (c1 VARBINARY(65532));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65533));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65534));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65535));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARBINARY(65536));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65532));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65533));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65534));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65535));
DESCRIBE t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 VARCHAR(65536));
DESCRIBE t1;
DROP TABLE t1;
......@@ -41,7 +41,18 @@
#define MAX_MBWIDTH 3 /* Max multibyte sequence */
#define MAX_FIELD_CHARLENGTH 255
#define MAX_FIELD_VARCHARLENGTH 65535
/*
In MAX_FIELD_VARCHARLENGTH we reserve extra bytes for the overhead:
- 2 bytes for the length
- 1 byte for NULL bits
to avoid the "Row size too large" error for these three corner definitions:
CREATE TABLE t1 (c VARBINARY(65533));
CREATE TABLE t1 (c VARBINARY(65534));
CREATE TABLE t1 (c VARBINARY(65535));
Like VARCHAR(65536), they will be converted to BLOB automatically
in non-sctict mode.
*/
#define MAX_FIELD_VARCHARLENGTH (65535-2-1)
#define MAX_FIELD_BLOBLENGTH UINT_MAX32 /* cf field_blob::get_length() */
#define CONVERT_IF_BIGGER_TO_BLOB 512 /* Threshold *in characters* */
......
......@@ -38,7 +38,7 @@ ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT
CREATE TABLE t2 (a char(256));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t1 (a varchar(70000) default "hello");
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
ERROR 42000: Column length too big for column 'a' (max = 65532); use BLOB or TEXT instead
CREATE TABLE t2 (a blob default "hello");
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
drop table if exists t1,t2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment