summaryrefslogtreecommitdiff
path: root/sql/sql_const.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-10-13 07:06:09 +0400
committerAlexander Barkov <bar@mariadb.org>2017-10-13 07:06:09 +0400
commit991b9ee73597ba7287267207b3918e157e346899 (patch)
treecec11c143502fc4a5ecfe308d042680f7511a282 /sql/sql_const.h
parent93aadda513d8b5c2b49001514e235c4fdd73e08a (diff)
downloadmariadb-git-991b9ee73597ba7287267207b3918e157e346899.tar.gz
MDEV-13530 VARBINARY doesn't convert to to BLOB for sizes 65533, 65534 and 65535
Diffstat (limited to 'sql/sql_const.h')
-rw-r--r--sql/sql_const.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/sql/sql_const.h b/sql/sql_const.h
index abe2a496045..e8385b537a8 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -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* */