Commit f21905e0 authored by unknown's avatar unknown
Browse files

data0type.h, row0sel.c:

  Fix a crash in a simple search with a key: the dtype->len of a true VARCHAR is the payload maximum len in bytes: it does not include the 2 bytes MySQL uses to store the string length
ha_innodb.cc:
  Fix a crash in true VARCHARs in test-innodb: we passed a wrong pointer to the column conversion in an UPDATE
rowid_order_innodb.result, ps_3innodb.result, innodb.result, endspace.result:
  Edit InnoDB test results to reflect the arrival of true VARCHARs


mysql-test/r/endspace.result:
  Edit InnoDB test results to reflect the arrival of true VARCHARs
mysql-test/r/innodb.result:
  Edit InnoDB test results to reflect the arrival of true VARCHARs
mysql-test/r/ps_3innodb.result:
  Edit InnoDB test results to reflect the arrival of true VARCHARs
mysql-test/r/rowid_order_innodb.result:
  Edit InnoDB test results to reflect the arrival of true VARCHARs
sql/ha_innodb.cc:
  Fix a crash in true VARCHARs in test-innodb: we passed a wrong pointer to the column conversion in an UPDATE
innobase/row/row0sel.c:
  Fix a crash in a simple search with a key: the dtype->len of a true VARCHAR is the payload maximum len in bytes: it does not include the 2 bytes MySQL uses to store the string length
innobase/include/data0type.h:
  Fix a crash in a simple search with a key: the dtype->len of a true VARCHAR is the payload maximum len in bytes: it does not include the 2 bytes MySQL uses to store the string length
parent ded3d0cb
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -401,11 +401,20 @@ sym_tab_add_null_lit() */

struct dtype_struct{
	ulint	mtype;		/* main data type */
	ulint	prtype;		/* precise type; MySQL data type */
	ulint	prtype;		/* precise type; MySQL data type, charset code,
				flags to indicate nullability, signedness,
				whether this is a binary string, whether this
				is a true VARCHAR where MySQL uses 2 bytes to
				store the length */

	/* the remaining fields do not affect alphabetical ordering: */

	ulint	len;		/* length */
	ulint	len;		/* length; for MySQL data this is
				field->pack_length(), except that for a
				>= 5.0.3 type true VARCHAR this is the
				maximum byte length of the string data
				(in addition to the string, MySQL uses 1 or
				2 bytes to store the string length) */
	ulint	prec;		/* precision */

	ulint	mbminlen;	/* minimum length of a character, in bytes */
+20 −12
Original line number Diff line number Diff line
@@ -2018,7 +2018,8 @@ Converts a key value stored in MySQL format to an Innobase dtuple. The last
field of the key value may be just a prefix of a fixed length field: hence
the parameter key_len. But currently we do not allow search keys where the
last field is only a prefix of the full key field len and print a warning if
such appears. */
such appears. A counterpart of this function is
ha_innobase::store_key_val_for_row() in ha_innodb.cc. */

void
row_sel_convert_mysql_key_to_innobase(
@@ -2100,12 +2101,9 @@ row_sel_convert_mysql_key_to_innobase(

		/* Calculate data length and data field total length */
		
		if (type == DATA_BLOB ||
			dtype_get_mysql_type(dfield_get_type(dfield))
					== DATA_MYSQL_TRUE_VARCHAR) {

			/* The key field is a column prefix of a BLOB,
			TEXT, OR TRUE VARCHAR type column */
		if (type == DATA_BLOB) {
			/* The key field is a column prefix of a BLOB or
			TEXT */

			ut_a(field->prefix_len > 0);

@@ -2122,11 +2120,9 @@ row_sel_convert_mysql_key_to_innobase(
				   + 256 * key_ptr[data_offset + 1];
			data_field_len = data_offset + 2 + field->prefix_len;

			if (type == DATA_BLOB) {
			data_offset += 2;
			}

			/* now that we know the length, we store the column
			/* Now that we know the length, we store the column
			value like it would be a fixed char field */

		} else if (field->prefix_len > 0) {
@@ -2148,6 +2144,18 @@ row_sel_convert_mysql_key_to_innobase(
			data_field_len = data_offset + data_len;
		}

 		if (dtype_get_mysql_type(dfield_get_type(dfield))
					== DATA_MYSQL_TRUE_VARCHAR) {
			/* In a MySQL key value format, a true VARCHAR is
			always preceded by 2 bytes of a length field.
			dfield_get_type(dfield)->len returns the maximum
			'payload' len in bytes. That does not include the
			2 bytes that tell the actual data length. */

			data_len += 2;
			data_field_len += 2;
		}

		/* Storing may use at most data_len bytes of buf */
		
		if (!is_null) {
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ teststring
teststring
explain select * from t1 order by text1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	index	NULL	key1	32	NULL	3	Using index
1	SIMPLE	t1	index	NULL	key1	34	NULL	3	Using index
alter table t1 modify text1 char(32) binary not null;
select * from t1 order by text1;
text1
+4 −5
Original line number Diff line number Diff line
@@ -1466,13 +1466,13 @@ Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3;
Table	Checksum
test.t1	2948697075
test.t2	968604391
test.t3	968604391
test.t2	1157260244
test.t3	1157260244
checksum table t1, t2, t3 extended;
Table	Checksum
test.t1	3092701434
test.t2	968604391
test.t3	968604391
test.t2	1157260244
test.t3	1157260244
drop table t1,t2,t3;
create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
@@ -1809,6 +1809,5 @@ show variables like "innodb_thread_sleep_delay";
Variable_name	Value
innodb_thread_sleep_delay	10000
create table t1 (v varchar(16384)) engine=innodb;
ERROR 42000: Column length too big for column 'v' (max = 255); use BLOB instead
create table t1 (a bit, key(a)) engine=innodb;
ERROR 42000: The storage engine for the table doesn't support BIT FIELD
+5 −5
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def	test	t9	t9	c19	c19	1	1	1	Y	32768	0	63
def	test	t9	t9	c20	c20	254	1	1	Y	0	0	8
def	test	t9	t9	c21	c21	254	10	10	Y	0	0	8
def	test	t9	t9	c22	c22	254	30	30	Y	0	0	8
def	test	t9	t9	c22	c22	253	30	30	Y	0	0	8
def	test	t9	t9	c23	c23	252	255	8	Y	144	0	63
def	test	t9	t9	c24	c24	252	255	8	Y	16	0	8
def	test	t9	t9	c25	c25	252	65535	4	Y	144	0	63
Loading