rem0cmp.c, data0type.c, data0type.ic, data0type.h, ha_innodb.cc:

  Remove the now redundant flag DATA_NONLATIN1; better comments
parent 9ceddd4a
...@@ -18,8 +18,9 @@ column definitions, or records in the insert buffer, we use this ...@@ -18,8 +18,9 @@ column definitions, or records in the insert buffer, we use this
charset-collation code for them. */ charset-collation code for them. */
ulint data_mysql_default_charset_coll = 99999999; ulint data_mysql_default_charset_coll = 99999999;
ulint data_mysql_latin1_swedish_charset_coll = 99999999;
dtype_t dtype_binary_val = {DATA_BINARY, 0, 0, 0, 0}; dtype_t dtype_binary_val = {DATA_BINARY, 0, 0, 0};
dtype_t* dtype_binary = &dtype_binary_val; dtype_t* dtype_binary = &dtype_binary_val;
/************************************************************************* /*************************************************************************
......
...@@ -12,6 +12,7 @@ Created 1/16/1996 Heikki Tuuri ...@@ -12,6 +12,7 @@ Created 1/16/1996 Heikki Tuuri
#include "univ.i" #include "univ.i"
extern ulint data_mysql_default_charset_coll; extern ulint data_mysql_default_charset_coll;
extern ulint data_mysql_latin1_swedish_charset_coll;
/* SQL data type struct */ /* SQL data type struct */
typedef struct dtype_struct dtype_t; typedef struct dtype_struct dtype_t;
...@@ -30,8 +31,8 @@ extern dtype_t* dtype_binary; ...@@ -30,8 +31,8 @@ extern dtype_t* dtype_binary;
#define DATA_BINARY 4 /* binary string */ #define DATA_BINARY 4 /* binary string */
#define DATA_BLOB 5 /* binary large object, or a TEXT type; #define DATA_BLOB 5 /* binary large object, or a TEXT type;
if prtype & DATA_BINARY_TYPE == 0, then this is if prtype & DATA_BINARY_TYPE == 0, then this is
actually a TEXT column; see also below about actually a TEXT column (or a BLOB created
the flag DATA_NONLATIN1 */ with < 4.0.14) */
#define DATA_INT 6 /* integer: can be any size 1 - 8 bytes */ #define DATA_INT 6 /* integer: can be any size 1 - 8 bytes */
#define DATA_SYS_CHILD 7 /* address of the child page in node pointer */ #define DATA_SYS_CHILD 7 /* address of the child page in node pointer */
#define DATA_SYS 8 /* system column */ #define DATA_SYS 8 /* system column */
...@@ -59,7 +60,7 @@ Tables created by a MySQL user have the following convention: ...@@ -59,7 +60,7 @@ Tables created by a MySQL user have the following convention:
code (not applicable for system columns). code (not applicable for system columns).
- In the second least significant byte we OR flags DATA_NOT_NULL, - In the second least significant byte we OR flags DATA_NOT_NULL,
DATA_UNSIGNED, DATA_BINARY_TYPE, DATA_NONLATIN1. DATA_UNSIGNED, DATA_BINARY_TYPE.
- In the third least significant byte of the precise type of string types we - In the third least significant byte of the precise type of string types we
store the MySQL charset-collation code. In DATA_BLOB columns created with store the MySQL charset-collation code. In DATA_BLOB columns created with
...@@ -73,6 +74,23 @@ installation. If the stored charset code is 0 in the system table SYS_COLUMNS ...@@ -73,6 +74,23 @@ installation. If the stored charset code is 0 in the system table SYS_COLUMNS
of InnoDB, that means that the default charset of this MySQL installation of InnoDB, that means that the default charset of this MySQL installation
should be used. should be used.
When loading a table definition from the system tables to the InnoDB data
dictionary cache in main memory, InnoDB versions >= 4.1.2 and >= 5.0.1 check
if the stored charset-collation is 0, and if that is the case and the type is
a non-binary string, replace that 0 by the default charset-collation code of
this MySQL installation. In short, in old tables, the charset-collation code
in the system tables on disk can be 0, but in in-memory data structures
(dtype_t), the charset-collation code is always != 0 for non-binary string
types.
In new tables, in binary string types, the charset-collation code is the
MySQL code for the 'binary charset', that is, != 0.
For binary string types and for DATA_CHAR, DATA_VARCHAR, and for those
DATA_BLOB which are binary or have the charset-collation latin1_swedish_ci,
InnoDB performs all comparisons internally, without resorting to the MySQL
comparison functions. This is to save CPU time.
InnoDB's own internal system tables have different precise types for their InnoDB's own internal system tables have different precise types for their
columns, and for them the precise type is usually not used at all. columns, and for them the precise type is usually not used at all.
*/ */
...@@ -112,14 +130,10 @@ be less than 256 */ ...@@ -112,14 +130,10 @@ be less than 256 */
string, this is ORed to the precise type: string, this is ORed to the precise type:
this only holds for tables created with this only holds for tables created with
>= MySQL-4.0.14 */ >= MySQL-4.0.14 */
#define DATA_NONLATIN1 2048 /* If the data type is DATA_BLOB with /* #define DATA_NONLATIN1 2048 This is a relic from < 4.1.2 and < 5.0.1.
the prtype & DATA_BINARY_TYPE == 0, that is, In earlier versions this was set for some
TEXT, then in versions 4.0.14 - 4.0.xx this BLOB columns.
flag is set to 1, if the charset is not */
latin1. In version 4.1.1 this was set
to 1 for all TEXT columns. In versions >= 4.1.2
this is set to 1 if the charset-collation of a
TEXT column is not latin1_swedish_ci. */
/*-------------------------------------------*/ /*-------------------------------------------*/
/* This many bytes we need to store the type information affecting the /* This many bytes we need to store the type information affecting the
...@@ -210,7 +224,7 @@ ulint ...@@ -210,7 +224,7 @@ ulint
dtype_form_prtype( dtype_form_prtype(
/*==============*/ /*==============*/
ulint old_prtype, /* in: the MySQL type code and the flags ulint old_prtype, /* in: the MySQL type code and the flags
DATA_NONLATIN1 etc. */ DATA_BINARY_TYPE etc. */
ulint charset_coll); /* in: MySQL charset-collation code */ ulint charset_coll); /* in: MySQL charset-collation code */
/************************************************************************* /*************************************************************************
Gets the type length. */ Gets the type length. */
......
...@@ -143,7 +143,7 @@ dtype_get_charset_coll( ...@@ -143,7 +143,7 @@ dtype_get_charset_coll(
/*===================*/ /*===================*/
ulint prtype) /* in: precise data type */ ulint prtype) /* in: precise data type */
{ {
return((prtype >> 16) & 0xFF); return((prtype >> 16) & 0xFFUL);
} }
/************************************************************************* /*************************************************************************
...@@ -153,7 +153,7 @@ ulint ...@@ -153,7 +153,7 @@ ulint
dtype_form_prtype( dtype_form_prtype(
/*==============*/ /*==============*/
ulint old_prtype, /* in: the MySQL type code and the flags ulint old_prtype, /* in: the MySQL type code and the flags
DATA_NONLATIN1 etc. */ DATA_BINARY_TYPE etc. */
ulint charset_coll) /* in: MySQL charset-collation code */ ulint charset_coll) /* in: MySQL charset-collation code */
{ {
ut_a(old_prtype < 256 * 256); ut_a(old_prtype < 256 * 256);
...@@ -237,9 +237,10 @@ dtype_new_store_for_order_and_null_size( ...@@ -237,9 +237,10 @@ dtype_new_store_for_order_and_null_size(
buf[0] = buf[0] | 128; buf[0] = buf[0] | 128;
} }
if (type->prtype & DATA_NONLATIN1) { /* In versions < 4.1.2 we had: if (type->prtype & DATA_NONLATIN1) {
buf[0] = buf[0] | 64; buf[0] = buf[0] | 64;
} }
*/
buf[1] = (byte)(type->prtype & 0xFFUL); buf[1] = (byte)(type->prtype & 0xFFUL);
...@@ -271,10 +272,6 @@ dtype_read_for_order_and_null_size( ...@@ -271,10 +272,6 @@ dtype_read_for_order_and_null_size(
type->prtype = type->prtype | DATA_BINARY_TYPE; type->prtype = type->prtype | DATA_BINARY_TYPE;
} }
if (buf[0] & 64) {
type->prtype = type->prtype | DATA_NONLATIN1;
}
type->len = mach_read_from_2(buf + 2); type->len = mach_read_from_2(buf + 2);
type->prtype = dtype_form_prtype(type->prtype, type->prtype = dtype_form_prtype(type->prtype,
...@@ -303,10 +300,6 @@ dtype_new_read_for_order_and_null_size( ...@@ -303,10 +300,6 @@ dtype_new_read_for_order_and_null_size(
type->prtype = type->prtype | DATA_BINARY_TYPE; type->prtype = type->prtype | DATA_BINARY_TYPE;
} }
if (buf[0] & 64) {
type->prtype = type->prtype | DATA_NONLATIN1;
}
type->len = mach_read_from_2(buf + 2); type->len = mach_read_from_2(buf + 2);
mach_read_from_2(buf + 4); mach_read_from_2(buf + 4);
......
...@@ -331,7 +331,9 @@ cmp_data_data_slow( ...@@ -331,7 +331,9 @@ cmp_data_data_slow(
if (cur_type->mtype >= DATA_FLOAT if (cur_type->mtype >= DATA_FLOAT
|| (cur_type->mtype == DATA_BLOB || (cur_type->mtype == DATA_BLOB
&& (cur_type->prtype & DATA_NONLATIN1))) { && 0 == (cur_type->prtype & DATA_BINARY_TYPE)
&& dtype_get_charset_coll(cur_type->prtype) !=
data_mysql_latin1_swedish_charset_coll)) {
return(cmp_whole_field(cur_type, data1, len1, data2, len2)); return(cmp_whole_field(cur_type, data1, len1, data2, len2));
} }
...@@ -532,8 +534,10 @@ cmp_dtuple_rec_with_match( ...@@ -532,8 +534,10 @@ cmp_dtuple_rec_with_match(
} }
if (cur_type->mtype >= DATA_FLOAT if (cur_type->mtype >= DATA_FLOAT
|| (cur_type->mtype == DATA_BLOB || (cur_type->mtype == DATA_BLOB
&& (cur_type->prtype & DATA_NONLATIN1))) { && 0 == (cur_type->prtype & DATA_BINARY_TYPE)
&& dtype_get_charset_coll(cur_type->prtype) !=
data_mysql_latin1_swedish_charset_coll)) {
ret = cmp_whole_field(cur_type, ret = cmp_whole_field(cur_type,
dfield_get_data(dtuple_field), dtuple_f_len, dfield_get_data(dtuple_field), dtuple_f_len,
...@@ -854,8 +858,10 @@ cmp_rec_rec_with_match( ...@@ -854,8 +858,10 @@ cmp_rec_rec_with_match(
} }
if (cur_type->mtype >= DATA_FLOAT if (cur_type->mtype >= DATA_FLOAT
|| (cur_type->mtype == DATA_BLOB || (cur_type->mtype == DATA_BLOB
&& (cur_type->prtype & DATA_NONLATIN1))) { && 0 == (cur_type->prtype & DATA_BINARY_TYPE)
&& dtype_get_charset_coll(cur_type->prtype) !=
data_mysql_latin1_swedish_charset_coll)) {
ret = cmp_whole_field(cur_type, ret = cmp_whole_field(cur_type,
rec1_b_ptr, rec1_f_len, rec1_b_ptr, rec1_f_len,
......
...@@ -755,11 +755,6 @@ innobase_init(void) ...@@ -755,11 +755,6 @@ innobase_init(void)
srv_set_thread_priorities = TRUE; srv_set_thread_priorities = TRUE;
srv_query_thread_priority = QUERY_PRIOR; srv_query_thread_priority = QUERY_PRIOR;
} }
/* Store the default charset-collation number of this MySQL
installation */
data_mysql_default_charset_coll = (ulint)default_charset_info->number;
/* Set InnoDB initialization parameters according to the values /* Set InnoDB initialization parameters according to the values
read from MySQL .cnf file */ read from MySQL .cnf file */
...@@ -875,6 +870,14 @@ innobase_init(void) ...@@ -875,6 +870,14 @@ innobase_init(void)
srv_print_verbose_log = mysql_embedded ? 0 : 1; srv_print_verbose_log = mysql_embedded ? 0 : 1;
/* Store the default charset-collation number of this MySQL
installation */
data_mysql_default_charset_coll = (ulint)default_charset_info->number;
data_mysql_latin1_swedish_charset_coll =
(ulint)my_charset_latin1.number;
/* Store the latin1_swedish_ci character ordering table to InnoDB. For /* Store the latin1_swedish_ci character ordering table to InnoDB. For
non-latin1_swedish_ci charsets we use the MySQL comparison functions, non-latin1_swedish_ci charsets we use the MySQL comparison functions,
and consequently we do not need to know the ordering internally in and consequently we do not need to know the ordering internally in
...@@ -3260,7 +3263,6 @@ create_table_def( ...@@ -3260,7 +3263,6 @@ create_table_def(
ulint nulls_allowed; ulint nulls_allowed;
ulint unsigned_type; ulint unsigned_type;
ulint binary_type; ulint binary_type;
ulint nonlatin1_type;
ulint charset_no; ulint charset_no;
ulint i; ulint i;
...@@ -3290,17 +3292,8 @@ create_table_def( ...@@ -3290,17 +3292,8 @@ create_table_def(
unsigned_type = 0; unsigned_type = 0;
} }
if (col_type == DATA_BLOB
&& strcmp(field->charset()->name,
"latin1_swedish_ci") != 0) {
nonlatin1_type = DATA_NONLATIN1;
} else {
nonlatin1_type = 0;
}
if (field->binary()) { if (field->binary()) {
binary_type = DATA_BINARY_TYPE; binary_type = DATA_BINARY_TYPE;
nonlatin1_type = 0;
} else { } else {
binary_type = 0; binary_type = 0;
} }
...@@ -3319,7 +3312,7 @@ create_table_def( ...@@ -3319,7 +3312,7 @@ create_table_def(
col_type, dtype_form_prtype( col_type, dtype_form_prtype(
(ulint)field->type() (ulint)field->type()
| nulls_allowed | unsigned_type | nulls_allowed | unsigned_type
| nonlatin1_type | binary_type, | binary_type,
+ charset_no), + charset_no),
field->pack_length(), 0); field->pack_length(), 0);
} }
......
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