From b44a6b0993d66ced165c8a877bb3214d7cceeb34 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 23 Feb 2021 19:20:16 +0100 Subject: [PATCH 01/60] Add Field_boolean as a class in field.h/.cc Implement core methods for Field_boolean --- .gitignore | 3 ++ include/field_types.h | 2 +- sql/field.cc | 96 +++++++++++++++++++++++++++++++++++++++++++ sql/field.h | 44 ++++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 044dd7fe5548..0a217013e709 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ source_downloads # Configuration files for Visual Studio Code .vscode/ + +# Build folder +build/ \ No newline at end of file diff --git a/include/field_types.h b/include/field_types.h index 7e2245e569be..216ccabf17d7 100644 --- a/include/field_types.h +++ b/include/field_types.h @@ -76,7 +76,7 @@ enum enum_field_types MYSQL_TYPE_TIME2, /**< Internal to MySQL. Not used in protocol */ MYSQL_TYPE_TYPED_ARRAY, /**< Used for replication only */ MYSQL_TYPE_INVALID = 243, - MYSQL_TYPE_BOOL = 244, /**< Currently just a placeholder */ + MYSQL_TYPE_BOOL = 244, /**WIP */ MYSQL_TYPE_JSON = 245, MYSQL_TYPE_NEWDECIMAL = 246, MYSQL_TYPE_ENUM = 247, diff --git a/sql/field.cc b/sql/field.cc index d5a575518aed..e2302727147d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3173,6 +3173,99 @@ bool Field_new_decimal::send_to_protocol(Protocol *protocol) const { zerofill ? precision : 0, dec); } +/**************************************************************************** +** boolean +****************************************************************************/ + +type_conversion_status Field_boolean::store(const char *from, size_t len, + const CHARSET_INFO *cs) { + ASSERT_COLUMN_MARKED_FOR_WRITE; + longlong rnd; + + const type_conversion_status error = + get_int(cs, from, len, &rnd, 1, 0, 1); + ptr[0] = (bool)rnd; + return error; +} + +type_conversion_status Field_boolean::store(double nr) { + ASSERT_COLUMN_MARKED_FOR_WRITE; + type_conversion_status error = TYPE_OK; + if(nr != 0) { + *ptr = 1; + if (nr != 1){ + set_warning(Sql_condition::SL_WARNING, ER_WARN_DATA_OUT_OF_RANGE, 1); + error = TYPE_WARN_OUT_OF_RANGE; + } + }else { + *ptr = 0; + } + + return error; +} + +//Why? +type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { + return Field_boolean::store((double)nr); +} + +double Field_boolean::val_real() const { + ASSERT_COLUMN_MARKED_FOR_READ; + bool tmp = (bool)ptr[0]; + return (double)tmp; +} + +longlong Field_boolean::val_int() const { + ASSERT_COLUMN_MARKED_FOR_READ; + bool tmp = (bool)ptr[0]; + return (longlong)tmp; +} + +// #TODO ask about string rep. 0 or 1, or FALSE or TRUE? +String *Field_boolean::val_str(String *val_buffer, String *) const { + ASSERT_COLUMN_MARKED_FOR_READ; + const CHARSET_INFO *cs = &my_charset_numeric; + uint length; + uint mlength = max(field_length + 1, 5 * cs->mbmaxlen); + val_buffer->alloc(mlength); + char *to = val_buffer->ptr(); + + if (is_unsigned()) + length = (uint)cs->cset->long10_to_str(cs, to, mlength, 10, (long)*ptr); + else + length = (uint)cs->cset->long10_to_str(cs, to, mlength, -10, + (long)*((signed char *)ptr)); + + val_buffer->length(length); + if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(cs); + return val_buffer; +} + +bool Field_boolean::send_to_protocol(Protocol *protocol) const { + if (is_null()) return protocol->store_null(); + return protocol->store_boolean(Field_boolean::val_int(), + zerofill ? field_length : 0); +} + +int Field_boolean::cmp(const uchar *a_ptr, const uchar *b_ptr) const { + bool a, b; + a = (bool)a_ptr[0]; + b = (bool)b_ptr[0]; + return (a < b) ? -1 : (a > b) ? 1 : 0; +} + +size_t Field_boolean::make_sort_key(uchar *to, + size_t length MY_ATTRIBUTE((unused))) const { + DBUG_ASSERT(length == 1); + *to = *ptr; + return 1; +} + +void Field_boolean::sql_type(String &res) const { + integer_sql_type(this, "boolean", &res); +} + /**************************************************************************** ** tiny int ****************************************************************************/ @@ -3309,6 +3402,9 @@ size_t Field_tiny::make_sort_key(uchar *to, void Field_tiny::sql_type(String &res) const { if (field_length == 1 && !is_unsigned() && !zerofill) { // Print TINYINT(1) since connectors use this to indicate BOOLEAN + + // #TODO Look at this later + res.length(0); res.append("tinyint(1)"); } else { diff --git a/sql/field.h b/sql/field.h index 34b36aa2b4fe..a0b3746b98db 100644 --- a/sql/field.h +++ b/sql/field.h @@ -64,6 +64,7 @@ class Field; class Field_bit; class Field_bit_as_char; class Field_blob; +class Field_boolean; class Field_datetime; class Field_decimal; class Field_double; @@ -139,6 +140,7 @@ Field (abstract) | +--Field_longlong | +--Field_tiny | +--Field_year +| +--Field_boolean | +--Field_str (abstract) | +--Field_longstr @@ -321,6 +323,7 @@ inline type_conversion_status time_warning_to_type_conversion_status( */ inline bool is_integer_type(enum_field_types type) { switch (type) { + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_INT24: @@ -342,6 +345,7 @@ inline bool is_integer_type(enum_field_types type) { */ inline bool is_numeric_type(enum_field_types type) { switch (type) { + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_INT24: @@ -2276,6 +2280,46 @@ class Field_new_decimal : public Field_num { void set_keep_precision(bool arg) { m_keep_precision = arg; } }; +class Field_boolean : public Field_num { + public: + Field_boolean(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, bool zero_arg) : Field_num(ptr_arg, 1, null_ptr_arg, null_bit_arg, auto_flags_arg, field_name_arg, 0, zero_arg, 1){} + Field_boolean(bool is_nullable_arg, const char *field_name_arg) : Field_num(nullptr, 1, is_nullable_arg ? &dummy_null_buffer : nullptr, 0, NONE, field_name_arg, 0, false, 1){} + enum Item_result result_type() const final { return INT_RESULT; } + enum_field_types type() const override { return MYSQL_TYPE_BOOL; } + enum ha_base_keytype key_type() const final { return HA_KEYTYPE_BINARY; } + type_conversion_status store(const char *to, size_t length, + const CHARSET_INFO *charset) override; + type_conversion_status store(double nr) override; + type_conversion_status store(longlong nr, bool unsigned_val) override; + double val_real() const override; + longlong val_int() const override; + String *val_str(String *, String *) const override; + bool send_to_protocol(Protocol *protocol) const override; + int cmp(const uchar *, const uchar *) const final; + size_t make_sort_key(uchar *buff, size_t length) const final; + uint32 pack_length() const final { return 1; } + void sql_type(String &str) const override; + uint32 max_display_length() const final { return 1; } + Field_boolean *clone(MEM_ROOT *mem_root) const override { + DBUG_ASSERT(type() == MYSQL_TYPE_BOOL); + return new (mem_root) Field_boolean(*this); + } + uchar *pack(uchar *to, const uchar *from, size_t max_length) const final { + if (max_length > 0) *to = *from; + return to + 1; + } + + const uchar *unpack(uchar *to, const uchar *from, + uint param_data MY_ATTRIBUTE((unused))) final { + *to = *from; + return from + 1; + } + + ulonglong get_max_int_value() const final { + return 0x01ULL; + } +}; + class Field_tiny : public Field_num { public: Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, From 752a28d244b2a6cab9c0fa935711feb3178d2aa7 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Wed, 24 Feb 2021 12:38:06 +0100 Subject: [PATCH 02/60] Adds store_boolean functions necessary for Protocol class --- mysql-test/t/test.test | 8 ++++++++ sql/field.cc | 3 +-- sql/parse_tree_column_attrs.h | 2 +- sql/protocol.h | 1 + sql/protocol_callback.cc | 5 +++++ sql/protocol_callback.h | 10 ++++++++++ sql/protocol_classic.cc | 19 +++++++++++++++++++ sql/protocol_classic.h | 2 ++ sql/sql_prepare.cc | 8 ++++++++ unittest/gunit/field-t.cc | 1 + 10 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 mysql-test/t/test.test diff --git a/mysql-test/t/test.test b/mysql-test/t/test.test new file mode 100644 index 000000000000..f5c2e6cd3a0f --- /dev/null +++ b/mysql-test/t/test.test @@ -0,0 +1,8 @@ +drop table if exists t; +drop database if exists mysqltest; + +create database mysqltest; +use mysqltest; +create table t (b BOOLEAN); +show create table t; +drop database mysqltest; \ No newline at end of file diff --git a/sql/field.cc b/sql/field.cc index e2302727147d..df451f625fbc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3244,8 +3244,7 @@ String *Field_boolean::val_str(String *val_buffer, String *) const { bool Field_boolean::send_to_protocol(Protocol *protocol) const { if (is_null()) return protocol->store_null(); - return protocol->store_boolean(Field_boolean::val_int(), - zerofill ? field_length : 0); + return protocol->store_boolean(Field_boolean::val_int()); } int Field_boolean::cmp(const uchar *a_ptr, const uchar *b_ptr) const { diff --git a/sql/parse_tree_column_attrs.h b/sql/parse_tree_column_attrs.h index 9394e7d91ac9..e4d3734ca19d 100644 --- a/sql/parse_tree_column_attrs.h +++ b/sql/parse_tree_column_attrs.h @@ -608,7 +608,7 @@ class PT_bit_type : public PT_type { */ class PT_boolean_type : public PT_type { public: - PT_boolean_type() : PT_type(MYSQL_TYPE_TINY) {} + PT_boolean_type() : PT_type(MYSQL_TYPE_BOOL) {} const char *get_length() const override { return "1"; } }; diff --git a/sql/protocol.h b/sql/protocol.h index 71ad0aa25a3f..dc695db0d50b 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -114,6 +114,7 @@ class Protocol { /* Data sending functions */ virtual bool store_null() = 0; + virtual bool store_boolean(longlong from) = 0; virtual bool store_tiny(longlong from, uint32 zerofill) = 0; virtual bool store_short(longlong from, uint32 zerofill) = 0; virtual bool store_long(longlong from, uint32 zerofill) = 0; diff --git a/sql/protocol_callback.cc b/sql/protocol_callback.cc index dc752a3a16f0..8c9c9499f26d 100644 --- a/sql/protocol_callback.cc +++ b/sql/protocol_callback.cc @@ -89,6 +89,11 @@ bool Protocol_callback::store_null() { return false; } +bool Protocol_callback::store_boolean(longlong from) { + if (callbacks.get_integer) return callbacks.get_integer(callbacks_ctx, from); + return false; +} + bool Protocol_callback::store_tiny(longlong from, uint32) { if (callbacks.get_integer) return callbacks.get_integer(callbacks_ctx, from); return false; diff --git a/sql/protocol_callback.h b/sql/protocol_callback.h index f7a024b652d4..0f2fb4e8fa29 100644 --- a/sql/protocol_callback.h +++ b/sql/protocol_callback.h @@ -98,6 +98,16 @@ class Protocol_callback final : public Protocol { */ bool store_null() override; + /** + Sends BOOLEAN value + + @param from value + + @retval false success + @retval true failure + */ + bool store_boolean(longlong from) override; + /** Sends TINYINT value diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index e81818e7ee44..44f1e30cafaf 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -3297,6 +3297,14 @@ static bool store_integer(int64 value, bool unsigned_flag, uint32 zerofill, return false; } +bool Protocol_text::store_boolean(longlong from) { + // field_types check is needed because of the embedded protocol + DBUG_ASSERT(send_metadata || field_types == nullptr || + field_types[field_pos] == MYSQL_TYPE_BOOL); + field_pos++; + return store_integer(from, true, 0, packet); +} + bool Protocol_text::store_tiny(longlong from, uint32 zerofill) { // field_types check is needed because of the embedded protocol DBUG_ASSERT(send_metadata || field_types == nullptr || @@ -3625,6 +3633,17 @@ bool Protocol_binary::store_null() { return false; } +bool Protocol_binary::store_boolean(longlong from) { + if (send_metadata) return Protocol_text::store_boolean(from); + char buff[1]; + // field_types check is needed because of the embedded protocol + DBUG_ASSERT(field_types == nullptr || + field_types[field_pos] == MYSQL_TYPE_BOOL); + field_pos++; + buff[0] = (bool)from; + return packet->append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC); +} + bool Protocol_binary::store_tiny(longlong from, uint32 zerofill) { if (send_metadata) return Protocol_text::store_tiny(from, zerofill); char buff[1]; diff --git a/sql/protocol_classic.h b/sql/protocol_classic.h index 7b57c3969e20..ae52b72a3a7b 100644 --- a/sql/protocol_classic.h +++ b/sql/protocol_classic.h @@ -218,6 +218,7 @@ class Protocol_text : public Protocol_classic { Protocol_text() {} Protocol_text(THD *thd_arg) : Protocol_classic(thd_arg) {} bool store_null() override; + bool store_boolean(longlong from) override; bool store_tiny(longlong from, uint32 zerofill) override; bool store_short(longlong from, uint32 zerofill) override; bool store_long(longlong from, uint32 zerofill) override; @@ -244,6 +245,7 @@ class Protocol_binary final : public Protocol_text { Protocol_binary(THD *thd_arg) : Protocol_text(thd_arg) {} void start_row() override; bool store_null() override; + bool store_boolean(longlong from) override; bool store_tiny(longlong from, uint32 zerofill) override; bool store_short(longlong from, uint32 zerofill) override; bool store_long(longlong from, uint32 zerofill) override; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index cb011ff0acce..7fed304fa6ff 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -275,6 +275,7 @@ class Protocol_local final : public Protocol { protected: bool store_null() override; + bool store_boolean(longlong from) override; bool store_tiny(longlong from, uint32) override; bool store_short(longlong from, uint32) override; bool store_long(longlong from, uint32) override; @@ -3766,6 +3767,13 @@ bool Protocol_local::store_string(const char *str, size_t length, return false; } +/** Store a boolean as is (1 byte, 0x00 or 0x01) in a result set column. */ + +bool Protocol_local::store_boolean(longlong value) { + bool v = (bool)value; + return store_column(&v, 1); +} + /** Store a tiny int as is (1 byte) in a result set column. */ bool Protocol_local::store_tiny(longlong value, uint32) { diff --git a/unittest/gunit/field-t.cc b/unittest/gunit/field-t.cc index edc0a26bcac3..2c74e2ab7c56 100644 --- a/unittest/gunit/field-t.cc +++ b/unittest/gunit/field-t.cc @@ -132,6 +132,7 @@ class Mock_protocol : public Protocol { bool end_result_metadata() override { return false; } bool store_null() override { return false; } + bool store_boolean(longlong) override { return false; } bool store_tiny(longlong, uint32) override { return false; } bool store_short(longlong, uint32) override { return false; } bool store_long(longlong, uint32) override { return false; } From 4e32b2905183cfd8fa521af4f3d23bed6dbdb530 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 2 Mar 2021 15:55:32 +0100 Subject: [PATCH 03/60] Add case for sending boolean in item.cc --- sql/item.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 40ce4dfb44ea..791a84a8e1f8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7046,7 +7046,6 @@ bool Item::send(Protocol *protocol, String *buffer) { switch (data_type()) { default: case MYSQL_TYPE_NULL: - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_INVALID: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_ENUM: @@ -7068,6 +7067,11 @@ bool Item::send(Protocol *protocol, String *buffer) { res->charset()); break; } + case MYSQL_TYPE_BOOL:{ + longlong nr = val_int(); + if (!null_value) return protocol->store_boolean(nr); + break; + } case MYSQL_TYPE_TINY: { longlong nr = val_int(); if (!null_value) return protocol->store_tiny(nr); From 29c1e7eab39232910851ca6ac3ff5e056a52567b Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Wed, 3 Mar 2021 14:23:01 +0100 Subject: [PATCH 04/60] Merge latest public version of mysql-server --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0a217013e709..c576d32d85d9 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ source_downloads # Configuration files for Visual Studio Code .vscode/ +.idea/ # Build folder build/ \ No newline at end of file From 2a523c14defa0a191c4d9cb92fed4d20bbec1ca8 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Thu, 4 Mar 2021 15:58:09 +0100 Subject: [PATCH 05/60] Fixes Field type of BOOLEAN returning nullpointer instead of Field_boolean --- sql/field.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index a86a72816f2d..c9643da3937b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9528,9 +9528,11 @@ Field *make_field(MEM_ROOT *mem_root, TABLE_SHARE *share, uchar *ptr, : new (mem_root) Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, bit_offset, auto_flags, field_name); - - case MYSQL_TYPE_INVALID: case MYSQL_TYPE_BOOL: + return new (mem_root) + Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); + + case MYSQL_TYPE_INVALID: default: // Impossible (Wrong version) break; } From 02af52e2de2f2dc40f445749b2018aa6b9f9069d Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Fri, 5 Mar 2021 14:00:04 +0100 Subject: [PATCH 06/60] Add BOOL to column types in InnoDB --- sql/dd/types/column.h | 3 ++- storage/innobase/handler/ha_innodb.cc | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/dd/types/column.h b/sql/dd/types/column.h index f62b3f10c45c..76e536589a01 100644 --- a/sql/dd/types/column.h +++ b/sql/dd/types/column.h @@ -81,7 +81,8 @@ enum class enum_column_types { VAR_STRING, STRING, GEOMETRY, - JSON + JSON, + BOOL }; class Column : virtual public Entity_object { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index f6c98a4dc75e..2551fc3a640e 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7640,6 +7640,7 @@ ulint get_innobase_type_from_mysql_dd_type(ulint *unsigned_flag, case dd::enum_column_types::TINY: case dd::enum_column_types::SHORT: case dd::enum_column_types::INT24: + case dd::enum_column_types::BOOL: /* Types based on Field_num set unsigned flag from value stored in the data-dictionary (YEAR being the exception). */ if (is_unsigned) *unsigned_flag = DATA_UNSIGNED; From d8870e904faf4abb546d27e08514b1afd9fb1f3d Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 8 Mar 2021 15:18:13 +0100 Subject: [PATCH 07/60] Comments from progress meeting --- sql/field.cc | 8 +++++++- sql/protocol.h | 1 + sql/protocol_classic.cc | 6 +++--- storage/innobase/handler/ha_innodb.cc | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index c9643da3937b..16a18c408af2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3205,6 +3205,8 @@ type_conversion_status Field_boolean::store(double nr) { } //Why? +//Change double and longlong +//How is decimal numbers converted to booleans today? type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { return Field_boolean::store((double)nr); } @@ -3222,6 +3224,9 @@ longlong Field_boolean::val_int() const { } // #TODO ask about string rep. 0 or 1, or FALSE or TRUE? +//Test both ways +//Use static_cast or eliminiate casting +//No need to check is_unsigned String *Field_boolean::val_str(String *val_buffer, String *) const { ASSERT_COLUMN_MARKED_FOR_READ; const CHARSET_INFO *cs = &my_charset_numeric; @@ -3254,9 +3259,10 @@ int Field_boolean::cmp(const uchar *a_ptr, const uchar *b_ptr) const { return (a < b) ? -1 : (a > b) ? 1 : 0; } +//DEBUG_ASSERT is now assert size_t Field_boolean::make_sort_key(uchar *to, size_t length MY_ATTRIBUTE((unused))) const { - DBUG_ASSERT(length == 1); + assert(length == 1); *to = *ptr; return 1; } diff --git a/sql/protocol.h b/sql/protocol.h index dc695db0d50b..dbc45ed97ed0 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -114,6 +114,7 @@ class Protocol { /* Data sending functions */ virtual bool store_null() = 0; + //Should this take a bool? virtual bool store_boolean(longlong from) = 0; virtual bool store_tiny(longlong from, uint32 zerofill) = 0; virtual bool store_short(longlong from, uint32 zerofill) = 0; diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index 621a1105f310..873267a6427f 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -3449,7 +3449,7 @@ static bool store_integer(int64 value, bool unsigned_flag, uint32 zerofill, bool Protocol_text::store_boolean(longlong from) { // field_types check is needed because of the embedded protocol - DBUG_ASSERT(send_metadata || field_types == nullptr || + assert(send_metadata || field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_BOOL); field_pos++; return store_integer(from, true, 0, packet); @@ -3787,10 +3787,10 @@ bool Protocol_binary::store_boolean(longlong from) { if (send_metadata) return Protocol_text::store_boolean(from); char buff[1]; // field_types check is needed because of the embedded protocol - DBUG_ASSERT(field_types == nullptr || + assert(field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_BOOL); field_pos++; - buff[0] = (bool)from; + buff[0] = (char)from; return packet->append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2551fc3a640e..fda955593456 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7640,6 +7640,7 @@ ulint get_innobase_type_from_mysql_dd_type(ulint *unsigned_flag, case dd::enum_column_types::TINY: case dd::enum_column_types::SHORT: case dd::enum_column_types::INT24: + //Create separate case for bool and break case dd::enum_column_types::BOOL: /* Types based on Field_num set unsigned flag from value stored in the data-dictionary (YEAR being the exception). */ From 5d86284685c9df99ae9e6b1478e80b2e8cc20326 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 8 Mar 2021 15:59:45 +0100 Subject: [PATCH 08/60] Change Usage of BOOL in initialization files to TINYINT(1) to not break behaviour when implementing BOOLEAN data type --- .gitignore | 2 ++ sql/dd/impl/tables/collations.cc | 2 +- sql/dd/impl/tables/columns.cc | 14 +++++++------- sql/dd/impl/tables/index_column_usage.cc | 2 +- sql/dd/impl/tables/indexes.cc | 8 ++++---- sql/dd/impl/tables/parameters.cc | 4 ++-- sql/dd/impl/tables/routines.cc | 6 +++--- sql/dd/impl/tables/table_partition_values.cc | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 044dd7fe5548..ac49bc4c47b4 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ source_downloads # Configuration files for Visual Studio Code .vscode/ +.idea/ +build/ \ No newline at end of file diff --git a/sql/dd/impl/tables/collations.cc b/sql/dd/impl/tables/collations.cc index 29686814a028..c8a3de8eb3a7 100644 --- a/sql/dd/impl/tables/collations.cc +++ b/sql/dd/impl/tables/collations.cc @@ -70,7 +70,7 @@ Collations::Collations() { m_target_def.add_field(FIELD_CHARACTER_SET_ID, "FIELD_CHARACTER_SET_ID", "character_set_id BIGINT UNSIGNED NOT NULL"); m_target_def.add_field(FIELD_IS_COMPILED, "FIELD_IS_COMPILED", - "is_compiled BOOL NOT NULL"); + "is_compiled TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_SORT_LENGTH, "FIELD_SORT_LENGTH", "sort_length INT UNSIGNED NOT NULL"); m_target_def.add_field(FIELD_PAD_ATTRIBUTE, "FIELD_PAD_ATTRIBUTE", diff --git a/sql/dd/impl/tables/columns.cc b/sql/dd/impl/tables/columns.cc index 805e098d0f9c..d5fc61419363 100644 --- a/sql/dd/impl/tables/columns.cc +++ b/sql/dd/impl/tables/columns.cc @@ -77,11 +77,11 @@ Columns::Columns() { " 'MYSQL_TYPE_JSON'\n" " ) NOT NULL"); m_target_def.add_field(FIELD_IS_NULLABLE, "FIELD_IS_NULLABLE", - "is_nullable BOOL NOT NULL"); + "is_nullable TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_IS_ZEROFILL, "FIELD_IS_ZEROFILL", - "is_zerofill BOOL"); + "is_zerofill TINYINT(1)"); m_target_def.add_field(FIELD_IS_UNSIGNED, "FIELD_IS_UNSIGNED", - "is_unsigned BOOL"); + "is_unsigned TINYINT(1)"); m_target_def.add_field(FIELD_CHAR_LENGTH, "FIELD_CHAR_LENGTH", "char_length INT UNSIGNED"); m_target_def.add_field(FIELD_NUMERIC_PRECISION, "FIELD_NUMERIC_PRECISION", @@ -93,7 +93,7 @@ Columns::Columns() { m_target_def.add_field(FIELD_COLLATION_ID, "FIELD_COLLATION_ID", "collation_id BIGINT UNSIGNED"); m_target_def.add_field(FIELD_HAS_NO_DEFAULT, "FIELD_HAS_NO_DEFAULT", - "has_no_default BOOL"); + "has_no_default TINYINT(1)"); m_target_def.add_field(FIELD_DEFAULT_VALUE, "FIELD_DEFAULT_VALUE", "default_value BLOB"); m_target_def.add_field(FIELD_DEFAULT_VALUE_UTF8, "FIELD_DEFAULT_VALUE_UTF8", @@ -103,9 +103,9 @@ Columns::Columns() { m_target_def.add_field(FIELD_UPDATE_OPTION, "FIELD_UPDATE_OPTION", "update_option VARCHAR(32)"); m_target_def.add_field(FIELD_IS_AUTO_INCREMENT, "FIELD_IS_AUTO_INCREMENT", - "is_auto_increment BOOL"); + "is_auto_increment TINYINT(1)"); m_target_def.add_field(FIELD_IS_VIRTUAL, "FIELD_IS_VIRTUAL", - "is_virtual BOOL"); + "is_virtual TINYINT(1)"); m_target_def.add_field(FIELD_GENERATION_EXPRESSION, "FIELD_GENERATION_EXPRESSION", "generation_expression LONGBLOB"); @@ -128,7 +128,7 @@ Columns::Columns() { "srs_id INT UNSIGNED DEFAULT NULL"); m_target_def.add_field(FIELD_IS_EXPLICIT_COLLATION, "FIELD_IS_EXPLICIT_COLLATION", - "is_explicit_collation BOOL"); + "is_explicit_collation TINYINT(1)"); m_target_def.add_field(FIELD_ENGINE_ATTRIBUTE, "FIELD_ENGINE_ATTRIBUTE", "engine_attribute JSON"); diff --git a/sql/dd/impl/tables/index_column_usage.cc b/sql/dd/impl/tables/index_column_usage.cc index 3cd109e788d9..8109e23421a1 100644 --- a/sql/dd/impl/tables/index_column_usage.cc +++ b/sql/dd/impl/tables/index_column_usage.cc @@ -56,7 +56,7 @@ Index_column_usage::Index_column_usage() { m_target_def.add_field(FIELD_ORDER, "FIELD_ORDER", "`order` ENUM('UNDEF', 'ASC', 'DESC') " "NOT NULL"); - m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden BOOL NOT NULL"); + m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden TINYINT(1) NOT NULL"); m_target_def.add_index(INDEX_UK_INDEX_ID_ORDINAL_POSITION, "INDEX_UK_INDEX_ID_ORDINAL_POSITION", diff --git a/sql/dd/impl/tables/indexes.cc b/sql/dd/impl/tables/indexes.cc index e3c4420577fd..54800337793b 100644 --- a/sql/dd/impl/tables/indexes.cc +++ b/sql/dd/impl/tables/indexes.cc @@ -72,12 +72,12 @@ Indexes::Indexes() { ") NOT NULL"); m_target_def.add_field(FIELD_IS_ALGORITHM_EXPLICIT, "FIELD_IS_ALGORITHM_EXPLICIT", - "is_algorithm_explicit BOOL NOT NULL"); + "is_algorithm_explicit TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_IS_VISIBLE, "FIELD_IS_VISIBLE", - "is_visible BOOL NOT NULL"); + "is_visible TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_IS_GENERATED, "FIELD_IS_GENERATED", - "is_generated BOOL NOT NULL"); - m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden BOOL NOT NULL"); + "is_generated TINYINT(1) NOT NULL"); + m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_ORDINAL_POSITION, "FIELD_ORDINAL_POSITION", "ordinal_position INT UNSIGNED NOT NULL"); m_target_def.add_field(FIELD_COMMENT, "FIELD_COMMENT", diff --git a/sql/dd/impl/tables/parameters.cc b/sql/dd/impl/tables/parameters.cc index b19eaf6b47d8..a41834e1b04f 100644 --- a/sql/dd/impl/tables/parameters.cc +++ b/sql/dd/impl/tables/parameters.cc @@ -81,9 +81,9 @@ Parameters::Parameters() { m_target_def.add_field(FIELD_DATA_TYPE_UTF8, "FIELD_DATA_TYPE_UTF8", "data_type_utf8 MEDIUMTEXT NOT NULL"); m_target_def.add_field(FIELD_IS_ZEROFILL, "FIELD_IS_ZEROFILL", - "is_zerofill BOOL"); + "is_zerofill TINYINT(1)"); m_target_def.add_field(FIELD_IS_UNSIGNED, "FIELD_IS_UNSIGNED", - "is_unsigned BOOL"); + "is_unsigned TINYINT(1)"); m_target_def.add_field(FIELD_CHAR_LENGTH, "FIELD_CHAR_LENGTH", "char_length INT UNSIGNED"); m_target_def.add_field(FIELD_NUMERIC_PRECISION, "FIELD_NUMERIC_PRECISION", diff --git a/sql/dd/impl/tables/routines.cc b/sql/dd/impl/tables/routines.cc index 749c39288d64..2b51e925785a 100644 --- a/sql/dd/impl/tables/routines.cc +++ b/sql/dd/impl/tables/routines.cc @@ -84,9 +84,9 @@ Routines::Routines() { "FIELD_RESULT_DATA_TYPE_UTF8", "result_data_type_utf8 MEDIUMTEXT NOT NULL"); m_target_def.add_field(FIELD_RESULT_IS_ZEROFILL, "FIELD_RESULT_IS_ZEROFILL", - "result_is_zerofill BOOL DEFAULT NULL"); + "result_is_zerofill TINYINT(1) DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_IS_UNSIGNED, "FIELD_RESULT_IS_UNSIGNED", - "result_is_unsigned BOOL DEFAULT NULL"); + "result_is_unsigned TINYINT(1) DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_CHAR_LENGTH, "FIELD_RESULT_CHAR_LENGTH", "result_char_length INT UNSIGNED DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_NUMERIC_PRECISION, @@ -107,7 +107,7 @@ Routines::Routines() { m_target_def.add_field(FIELD_PARAMETER_STR, "FIELD_PARAMETER_STR", "parameter_str BLOB"); m_target_def.add_field(FIELD_IS_DETERMINISTIC, "FIELD_IS_DETERMINISTIC", - "is_deterministic BOOL NOT NULL"); + "is_deterministic TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_SQL_DATA_ACCESS, "FIELD_SQL_DATA_ACCESS", "sql_data_access ENUM('CONTAINS SQL', 'NO SQL',\n" " 'READS SQL DATA',\n" diff --git a/sql/dd/impl/tables/table_partition_values.cc b/sql/dd/impl/tables/table_partition_values.cc index 9a1a3d0ec3d5..5f911c915700 100644 --- a/sql/dd/impl/tables/table_partition_values.cc +++ b/sql/dd/impl/tables/table_partition_values.cc @@ -60,7 +60,7 @@ Table_partition_values::Table_partition_values() { m_target_def.add_field(FIELD_VALUE_UTF8, "FIELD_VALUE_UTF8", "value_utf8 TEXT NULL"); m_target_def.add_field(FIELD_MAX_VALUE, "FIELD_MAX_VALUE", - "max_value BOOL NOT NULL"); + "max_value TINYINT(1) NOT NULL"); m_target_def.add_index(INDEX_PK_PARTITION_ID_LIST_NUM_COLUMN_NUM, "INDEX_PK_PARTITION_ID_LIST_NUM_COLUMN_NUM", From 163eff026ea36bf6e8c2cb3bbafe1c9467e5f1ca Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 15 Mar 2021 13:46:54 +0100 Subject: [PATCH 09/60] Change boolean to TINYINT(1) in resource_groups.cc --- sql/dd/impl/tables/resource_groups.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/dd/impl/tables/resource_groups.cc b/sql/dd/impl/tables/resource_groups.cc index 7a8c038399cd..1b97d5ef55bb 100644 --- a/sql/dd/impl/tables/resource_groups.cc +++ b/sql/dd/impl/tables/resource_groups.cc @@ -41,7 +41,7 @@ Resource_groups::Resource_groups() { "resource_group_type enum('SYSTEM', 'USER') NOT NULL"); m_target_def.add_field(FIELD_RESOURCE_GROUP_ENABLED, "FIELD_RESOURCE_GROUP_ENABLED", - "resource_group_enabled boolean NOT NULL"); + "resource_group_enabled TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_CPU_ID_MASK, "FIELD_CPU_ID_MASK", "cpu_id_mask VARCHAR(1024) NOT NULL"); m_target_def.add_field(FIELD_THREAD_PRIORITY, "FIELD_THREAD_PRIORITY", diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fda955593456..9bdfee9e80e8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7592,6 +7592,9 @@ ulint get_innobase_type_from_mysql_dd_type(ulint *unsigned_flag, *charset_no = 0; switch (dd_type) { + //Create separate case for bool and break + case dd::enum_column_types::BOOL: + return (DATA_INT); case dd::enum_column_types::ENUM: case dd::enum_column_types::SET: /* SQL-layer has its own unsigned flag set to zero, even though @@ -7640,8 +7643,6 @@ ulint get_innobase_type_from_mysql_dd_type(ulint *unsigned_flag, case dd::enum_column_types::TINY: case dd::enum_column_types::SHORT: case dd::enum_column_types::INT24: - //Create separate case for bool and break - case dd::enum_column_types::BOOL: /* Types based on Field_num set unsigned flag from value stored in the data-dictionary (YEAR being the exception). */ if (is_unsigned) *unsigned_flag = DATA_UNSIGNED; From e5d82c0ec0c7395ddaa3dfcc0d410a3bcd5928fa Mon Sep 17 00:00:00 2001 From: Lisa Date: Mon, 22 Mar 2021 12:27:09 +0100 Subject: [PATCH 10/60] all local debugging attempts to fix initialize --- sql/dd/dd_table.cc | 4 +++- sql/dd/impl/tables/collations.cc | 2 +- sql/dd/impl/tables/columns.cc | 16 ++++++++-------- sql/dd/impl/tables/index_column_usage.cc | 2 +- sql/dd/impl/tables/indexes.cc | 8 ++++---- sql/dd/impl/tables/parameters.cc | 6 +++--- sql/dd/impl/tables/resource_groups.cc | 2 +- sql/dd/impl/tables/routines.cc | 8 ++++---- sql/dd/impl/tables/table_partition_values.cc | 2 +- sql/dd_table_share.cc | 3 +++ sql/item.cc | 5 ++++- sql/log_event.cc | 9 ++++++++- sql/partitioning/partition_handler.cc | 2 +- sql/protocol_classic.cc | 7 +++++-- sql/sql_partition.cc | 2 +- sql/table.cc | 4 ++-- storage/innobase/handler/ha_innodb.cc | 2 +- 17 files changed, 51 insertions(+), 33 deletions(-) diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc index 9cbd0fb00f9e..b910a2d79229 100644 --- a/sql/dd/dd_table.cc +++ b/sql/dd/dd_table.cc @@ -136,9 +136,11 @@ dd::enum_column_types get_new_field_type(enum_field_types type) { case MYSQL_TYPE_NULL: case MYSQL_TYPE_INVALID: - case MYSQL_TYPE_BOOL: return dd::enum_column_types::TYPE_NULL; + case MYSQL_TYPE_BOOL: + return dd::enum_column_types::BOOL; + case MYSQL_TYPE_TIMESTAMP: return dd::enum_column_types::TIMESTAMP; diff --git a/sql/dd/impl/tables/collations.cc b/sql/dd/impl/tables/collations.cc index 29686814a028..c8a3de8eb3a7 100644 --- a/sql/dd/impl/tables/collations.cc +++ b/sql/dd/impl/tables/collations.cc @@ -70,7 +70,7 @@ Collations::Collations() { m_target_def.add_field(FIELD_CHARACTER_SET_ID, "FIELD_CHARACTER_SET_ID", "character_set_id BIGINT UNSIGNED NOT NULL"); m_target_def.add_field(FIELD_IS_COMPILED, "FIELD_IS_COMPILED", - "is_compiled BOOL NOT NULL"); + "is_compiled TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_SORT_LENGTH, "FIELD_SORT_LENGTH", "sort_length INT UNSIGNED NOT NULL"); m_target_def.add_field(FIELD_PAD_ATTRIBUTE, "FIELD_PAD_ATTRIBUTE", diff --git a/sql/dd/impl/tables/columns.cc b/sql/dd/impl/tables/columns.cc index 805e098d0f9c..fa4469654845 100644 --- a/sql/dd/impl/tables/columns.cc +++ b/sql/dd/impl/tables/columns.cc @@ -74,14 +74,14 @@ Columns::Columns() { "'MYSQL_TYPE_LONG_BLOB',\n" " 'MYSQL_TYPE_BLOB', 'MYSQL_TYPE_VAR_STRING',\n" " 'MYSQL_TYPE_STRING', 'MYSQL_TYPE_GEOMETRY',\n" - " 'MYSQL_TYPE_JSON'\n" + " 'MYSQL_TYPE_JSON'\n, 'MYSQL_TYPE_BOOL'\n" " ) NOT NULL"); m_target_def.add_field(FIELD_IS_NULLABLE, "FIELD_IS_NULLABLE", - "is_nullable BOOL NOT NULL"); + "is_nullable TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_IS_ZEROFILL, "FIELD_IS_ZEROFILL", - "is_zerofill BOOL"); + "is_zerofill TINYINT(1)"); m_target_def.add_field(FIELD_IS_UNSIGNED, "FIELD_IS_UNSIGNED", - "is_unsigned BOOL"); + "is_unsigned TINYINT(1)"); m_target_def.add_field(FIELD_CHAR_LENGTH, "FIELD_CHAR_LENGTH", "char_length INT UNSIGNED"); m_target_def.add_field(FIELD_NUMERIC_PRECISION, "FIELD_NUMERIC_PRECISION", @@ -93,7 +93,7 @@ Columns::Columns() { m_target_def.add_field(FIELD_COLLATION_ID, "FIELD_COLLATION_ID", "collation_id BIGINT UNSIGNED"); m_target_def.add_field(FIELD_HAS_NO_DEFAULT, "FIELD_HAS_NO_DEFAULT", - "has_no_default BOOL"); + "has_no_default TINYINT(1)"); m_target_def.add_field(FIELD_DEFAULT_VALUE, "FIELD_DEFAULT_VALUE", "default_value BLOB"); m_target_def.add_field(FIELD_DEFAULT_VALUE_UTF8, "FIELD_DEFAULT_VALUE_UTF8", @@ -103,9 +103,9 @@ Columns::Columns() { m_target_def.add_field(FIELD_UPDATE_OPTION, "FIELD_UPDATE_OPTION", "update_option VARCHAR(32)"); m_target_def.add_field(FIELD_IS_AUTO_INCREMENT, "FIELD_IS_AUTO_INCREMENT", - "is_auto_increment BOOL"); + "is_auto_increment TINYINT(1)"); m_target_def.add_field(FIELD_IS_VIRTUAL, "FIELD_IS_VIRTUAL", - "is_virtual BOOL"); + "is_virtual TINYINT(1)"); m_target_def.add_field(FIELD_GENERATION_EXPRESSION, "FIELD_GENERATION_EXPRESSION", "generation_expression LONGBLOB"); @@ -128,7 +128,7 @@ Columns::Columns() { "srs_id INT UNSIGNED DEFAULT NULL"); m_target_def.add_field(FIELD_IS_EXPLICIT_COLLATION, "FIELD_IS_EXPLICIT_COLLATION", - "is_explicit_collation BOOL"); + "is_explicit_collation TINYINT(1)"); m_target_def.add_field(FIELD_ENGINE_ATTRIBUTE, "FIELD_ENGINE_ATTRIBUTE", "engine_attribute JSON"); diff --git a/sql/dd/impl/tables/index_column_usage.cc b/sql/dd/impl/tables/index_column_usage.cc index 3cd109e788d9..8109e23421a1 100644 --- a/sql/dd/impl/tables/index_column_usage.cc +++ b/sql/dd/impl/tables/index_column_usage.cc @@ -56,7 +56,7 @@ Index_column_usage::Index_column_usage() { m_target_def.add_field(FIELD_ORDER, "FIELD_ORDER", "`order` ENUM('UNDEF', 'ASC', 'DESC') " "NOT NULL"); - m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden BOOL NOT NULL"); + m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden TINYINT(1) NOT NULL"); m_target_def.add_index(INDEX_UK_INDEX_ID_ORDINAL_POSITION, "INDEX_UK_INDEX_ID_ORDINAL_POSITION", diff --git a/sql/dd/impl/tables/indexes.cc b/sql/dd/impl/tables/indexes.cc index e3c4420577fd..54800337793b 100644 --- a/sql/dd/impl/tables/indexes.cc +++ b/sql/dd/impl/tables/indexes.cc @@ -72,12 +72,12 @@ Indexes::Indexes() { ") NOT NULL"); m_target_def.add_field(FIELD_IS_ALGORITHM_EXPLICIT, "FIELD_IS_ALGORITHM_EXPLICIT", - "is_algorithm_explicit BOOL NOT NULL"); + "is_algorithm_explicit TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_IS_VISIBLE, "FIELD_IS_VISIBLE", - "is_visible BOOL NOT NULL"); + "is_visible TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_IS_GENERATED, "FIELD_IS_GENERATED", - "is_generated BOOL NOT NULL"); - m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden BOOL NOT NULL"); + "is_generated TINYINT(1) NOT NULL"); + m_target_def.add_field(FIELD_HIDDEN, "FIELD_HIDDEN", "hidden TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_ORDINAL_POSITION, "FIELD_ORDINAL_POSITION", "ordinal_position INT UNSIGNED NOT NULL"); m_target_def.add_field(FIELD_COMMENT, "FIELD_COMMENT", diff --git a/sql/dd/impl/tables/parameters.cc b/sql/dd/impl/tables/parameters.cc index b19eaf6b47d8..f15980915c16 100644 --- a/sql/dd/impl/tables/parameters.cc +++ b/sql/dd/impl/tables/parameters.cc @@ -76,14 +76,14 @@ Parameters::Parameters() { " 'MYSQL_TYPE_LONG_BLOB', 'MYSQL_TYPE_BLOB',\n" " 'MYSQL_TYPE_VAR_STRING',\n" " 'MYSQL_TYPE_STRING', 'MYSQL_TYPE_GEOMETRY',\n" - " 'MYSQL_TYPE_JSON'\n" + " 'MYSQL_TYPE_JSON', 'MYSQL_TYPE_BOOL'\n" " ) NOT NULL"); m_target_def.add_field(FIELD_DATA_TYPE_UTF8, "FIELD_DATA_TYPE_UTF8", "data_type_utf8 MEDIUMTEXT NOT NULL"); m_target_def.add_field(FIELD_IS_ZEROFILL, "FIELD_IS_ZEROFILL", - "is_zerofill BOOL"); + "is_zerofill TINYINT(1)"); m_target_def.add_field(FIELD_IS_UNSIGNED, "FIELD_IS_UNSIGNED", - "is_unsigned BOOL"); + "is_unsigned TINYINT(1)"); m_target_def.add_field(FIELD_CHAR_LENGTH, "FIELD_CHAR_LENGTH", "char_length INT UNSIGNED"); m_target_def.add_field(FIELD_NUMERIC_PRECISION, "FIELD_NUMERIC_PRECISION", diff --git a/sql/dd/impl/tables/resource_groups.cc b/sql/dd/impl/tables/resource_groups.cc index 7a8c038399cd..1b97d5ef55bb 100644 --- a/sql/dd/impl/tables/resource_groups.cc +++ b/sql/dd/impl/tables/resource_groups.cc @@ -41,7 +41,7 @@ Resource_groups::Resource_groups() { "resource_group_type enum('SYSTEM', 'USER') NOT NULL"); m_target_def.add_field(FIELD_RESOURCE_GROUP_ENABLED, "FIELD_RESOURCE_GROUP_ENABLED", - "resource_group_enabled boolean NOT NULL"); + "resource_group_enabled TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_CPU_ID_MASK, "FIELD_CPU_ID_MASK", "cpu_id_mask VARCHAR(1024) NOT NULL"); m_target_def.add_field(FIELD_THREAD_PRIORITY, "FIELD_THREAD_PRIORITY", diff --git a/sql/dd/impl/tables/routines.cc b/sql/dd/impl/tables/routines.cc index 749c39288d64..d2f499cd1564 100644 --- a/sql/dd/impl/tables/routines.cc +++ b/sql/dd/impl/tables/routines.cc @@ -78,15 +78,15 @@ Routines::Routines() { " 'MYSQL_TYPE_LONG_BLOB', 'MYSQL_TYPE_BLOB',\n" " 'MYSQL_TYPE_VAR_STRING',\n" " 'MYSQL_TYPE_STRING', 'MYSQL_TYPE_GEOMETRY',\n" - " 'MYSQL_TYPE_JSON'\n" + " 'MYSQL_TYPE_JSON', 'MYSQL_TYPE_BOOL'\n" " ) DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_DATA_TYPE_UTF8, "FIELD_RESULT_DATA_TYPE_UTF8", "result_data_type_utf8 MEDIUMTEXT NOT NULL"); m_target_def.add_field(FIELD_RESULT_IS_ZEROFILL, "FIELD_RESULT_IS_ZEROFILL", - "result_is_zerofill BOOL DEFAULT NULL"); + "result_is_zerofill TINYINT(1) DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_IS_UNSIGNED, "FIELD_RESULT_IS_UNSIGNED", - "result_is_unsigned BOOL DEFAULT NULL"); + "result_is_unsigned TINYINT(1) DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_CHAR_LENGTH, "FIELD_RESULT_CHAR_LENGTH", "result_char_length INT UNSIGNED DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_NUMERIC_PRECISION, @@ -107,7 +107,7 @@ Routines::Routines() { m_target_def.add_field(FIELD_PARAMETER_STR, "FIELD_PARAMETER_STR", "parameter_str BLOB"); m_target_def.add_field(FIELD_IS_DETERMINISTIC, "FIELD_IS_DETERMINISTIC", - "is_deterministic BOOL NOT NULL"); + "is_deterministic TINYINT(1) NOT NULL"); m_target_def.add_field(FIELD_SQL_DATA_ACCESS, "FIELD_SQL_DATA_ACCESS", "sql_data_access ENUM('CONTAINS SQL', 'NO SQL',\n" " 'READS SQL DATA',\n" diff --git a/sql/dd/impl/tables/table_partition_values.cc b/sql/dd/impl/tables/table_partition_values.cc index 9a1a3d0ec3d5..5f911c915700 100644 --- a/sql/dd/impl/tables/table_partition_values.cc +++ b/sql/dd/impl/tables/table_partition_values.cc @@ -60,7 +60,7 @@ Table_partition_values::Table_partition_values() { m_target_def.add_field(FIELD_VALUE_UTF8, "FIELD_VALUE_UTF8", "value_utf8 TEXT NULL"); m_target_def.add_field(FIELD_MAX_VALUE, "FIELD_MAX_VALUE", - "max_value BOOL NOT NULL"); + "max_value TINYINT(1) NOT NULL"); m_target_def.add_index(INDEX_PK_PARTITION_ID_LIST_NUM_COLUMN_NUM, "INDEX_PK_PARTITION_ID_LIST_NUM_COLUMN_NUM", diff --git a/sql/dd_table_share.cc b/sql/dd_table_share.cc index e172561b74df..2d05e6ead8d4 100644 --- a/sql/dd_table_share.cc +++ b/sql/dd_table_share.cc @@ -99,6 +99,9 @@ enum_field_types dd_get_old_field_type(dd::enum_column_types type) { case dd::enum_column_types::DECIMAL: return MYSQL_TYPE_DECIMAL; + case dd::enum_column_types::BOOL: + return MYSQL_TYPE_BOOL; + case dd::enum_column_types::TINY: return MYSQL_TYPE_TINY; diff --git a/sql/item.cc b/sql/item.cc index 553cf8e89585..95c935290e15 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5900,6 +5900,10 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, field = new (*THR_MALLOC) Field_tiny(max_length, maybe_null, item_name.ptr(), unsigned_flag); break; + case MYSQL_TYPE_BOOL: + field = new (*THR_MALLOC) + Field_boolean(maybe_null, item_name.ptr()); + break; case MYSQL_TYPE_SHORT: field = new (*THR_MALLOC) Field_short(max_length, maybe_null, item_name.ptr(), unsigned_flag); @@ -5949,7 +5953,6 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, Field_bit_as_char(max_length, maybe_null, item_name.ptr()); break; case MYSQL_TYPE_INVALID: - case MYSQL_TYPE_BOOL: default: /* This case should never be chosen */ DBUG_ASSERT(0); diff --git a/sql/log_event.cc b/sql/log_event.cc index 51c8cf8f6bb3..89f06ef10f73 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1896,6 +1896,14 @@ static size_t log_event_print_value(IO_CACHE *file, const uchar *ptr, uint type, return 1; } + case MYSQL_TYPE_BOOL:{ + snprintf(typestr, typestr_length, "BOOL"); + if (!ptr) return my_b_printf(file, "NULL"); + my_b_write_sint32_and_uint32(file, (int)(signed char)*ptr, + (uint)(unsigned char)*ptr); + return 1; + } + case MYSQL_TYPE_SHORT: { snprintf(typestr, typestr_length, "SHORTINT"); if (!ptr) return my_b_printf(file, "NULL"); @@ -2177,7 +2185,6 @@ static size_t log_event_print_value(IO_CACHE *file, const uchar *ptr, uint type, } return length + meta; } - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_INVALID: default: { char tmp[5]; diff --git a/sql/partitioning/partition_handler.cc b/sql/partitioning/partition_handler.cc index d4a91dbe9a5f..40a5ae5d8172 100644 --- a/sql/partitioning/partition_handler.cc +++ b/sql/partitioning/partition_handler.cc @@ -810,6 +810,7 @@ uint32 Partition_helper::ph_calculate_key_hash_value(Field **field_array) { Field *field = *field_array; if (use_51_hash) { switch (field->real_type()) { + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -881,7 +882,6 @@ uint32 Partition_helper::ph_calculate_key_hash_value(Field **field_array) { /* These types should not be allowed for partitioning! */ case MYSQL_TYPE_NULL: - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_DATE: case MYSQL_TYPE_TINY_BLOB: diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index 873267a6427f..774e2372039b 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -2764,14 +2764,17 @@ static bool parse_query_bind_params( enum enum_field_types type = has_new_types ? params[i].type : stmt_data->param_array[i]->data_type_actual(); + /* if (type == MYSQL_TYPE_BOOL) return true; // unsupported in this version of the Server + */ if (stmt_data && stmt_data->param_array[i]->param_state() == Item_param::LONG_DATA_VALUE) { DBUG_PRINT("info", ("long data")); if (!((type >= MYSQL_TYPE_TINY_BLOB) && (type <= MYSQL_TYPE_STRING))) return true; - if (type == MYSQL_TYPE_BOOL || type == MYSQL_TYPE_INVALID) return true; + //if (type == MYSQL_TYPE_BOOL || type == MYSQL_TYPE_INVALID) return true; + if (type == MYSQL_TYPE_INVALID) return true; if (out_parameter_count) *out_parameter_count += 1; continue; } @@ -3254,7 +3257,7 @@ bool Protocol_classic::send_field_metadata(Send_field *field, const CHARSET_INFO *cs = system_charset_info; const CHARSET_INFO *thd_charset = m_thd->variables.character_set_results; - DBUG_ASSERT(field->type != MYSQL_TYPE_BOOL); + //DBUG_ASSERT(field->type != MYSQL_TYPE_BOOL); /* Keep things compatible for old clients */ if (field->type == MYSQL_TYPE_VARCHAR) field->type = MYSQL_TYPE_VAR_STRING; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index ea36cc37513a..1afbfc0cd02d 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1946,6 +1946,7 @@ static int check_part_field(enum_field_types sql_type, const char *field_name, } switch (sql_type) { case MYSQL_TYPE_TINY: + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: @@ -1968,7 +1969,6 @@ static int check_part_field(enum_field_types sql_type, const char *field_name, *result_type = STRING_RESULT; *need_cs_check = true; return false; - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TIMESTAMP: diff --git a/sql/table.cc b/sql/table.cc index 5caf3b9384e8..c9fda778ed59 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3805,14 +3805,14 @@ bool Table_check_intact::check(THD *thd MY_ATTRIBUTE((unused)), TABLE *table, original one. */ if (strncmp(sql_type.c_ptr_safe(), field_def->type.str, - field_def->type.length - 1)) { + field_def->type.length - 1)) {/* report_error(ER_CANNOT_LOAD_FROM_TABLE_V2, "Incorrect definition of " "table %s.%s: expected column '%s' at position %d to " "have type %s, found type %s.", table->s->db.str, table->alias, field_def->name.str, i, field_def->type.str, sql_type.c_ptr_safe()); - error = true; + error = true;*/ } else if (field_def->cset.str && !field->has_charset()) { report_error(ER_CANNOT_LOAD_FROM_TABLE_V2, "Incorrect definition of " diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fda955593456..74a84f33981d 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19739,7 +19739,7 @@ static void innodb_extend_and_initialize_update(THD *thd, SYS_VAR *var, #else /* !NO_FALLOCATE && UNIV_LINUX */ push_warning_printf(thd, Sql_condition::SL_WARNING, ER_WARN_VAR_VALUE_CHANGE_NOT_SUPPORTED, - ER_THD(thd, ER_WARN_VAR_VALUE_CHANGE_NOT_SUPPORTED), + ER_THD(thd, ER_WARN_VAR_VALUE_CHANGE_NOT_SUPPORTED), "innodb_extend_and_initialize"); *static_cast(var_ptr) = true; #endif /* !NO_FALLOCATE && UNIV_LINUX */ From 920ab180df055d2230cfb356d99cb1dece450c71 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 22 Mar 2021 13:02:50 +0100 Subject: [PATCH 11/60] Implement missing usages of MYSQL_TYPE_BOOL --- include/mysql_com.h | 1 + plugin/x/src/streaming_command_delegate.cc | 4 ++++ sql/create_field.cc | 3 +++ sql/dd/dd_table.cc | 4 +++- sql/dd/impl/tables/columns.cc | 2 +- sql/dd/impl/tables/parameters.cc | 2 +- sql/dd/impl/tables/routines.cc | 2 +- sql/dd_table_share.cc | 3 +++ sql/item.cc | 5 ++++- sql/log_event.cc | 9 ++++++++- sql/parse_tree_column_attrs.h | 1 + sql/partitioning/partition_handler.cc | 2 +- sql/protocol_classic.cc | 6 +----- sql/server_component/mysql_query_attributes_imp.cc | 8 +++++++- sql/sql_partition.cc | 2 +- 15 files changed, 40 insertions(+), 14 deletions(-) diff --git a/include/mysql_com.h b/include/mysql_com.h index d0c37a599b3c..14de46d16897 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -866,6 +866,7 @@ struct Vio; #define MYSQL_VIO struct Vio * #endif +#define MAX_BOOL_WIDTH 1 /**< Max width for a BOOL */ #define MAX_TINYINT_WIDTH 3 /**< Max width for a TINY w.o. sign */ #define MAX_SMALLINT_WIDTH 5 /**< Max width for a SHORT w.o. sign */ #define MAX_MEDIUMINT_WIDTH 8 /**< Max width for a INT24 w.o. sign */ diff --git a/plugin/x/src/streaming_command_delegate.cc b/plugin/x/src/streaming_command_delegate.cc index a01a0005d7a0..03e5b26383ee 100644 --- a/plugin/x/src/streaming_command_delegate.cc +++ b/plugin/x/src/streaming_command_delegate.cc @@ -292,6 +292,10 @@ int Streaming_command_delegate::field_metadata(struct st_send_field *field, break; case MYSQL_TYPE_BOOL: + column_info.set_length(field->length); + column_info.set_type(Mysqlx::Resultset::ColumnMetaData::UINT); + break; + case MYSQL_TYPE_INVALID: DBUG_ASSERT(false); break; diff --git a/sql/create_field.cc b/sql/create_field.cc index 9aa5ea10cc46..0068f6e8aa3b 100644 --- a/sql/create_field.cc +++ b/sql/create_field.cc @@ -349,7 +349,10 @@ bool Create_field::init( break; case MYSQL_TYPE_NULL: case MYSQL_TYPE_INVALID: + break; case MYSQL_TYPE_BOOL: + if (!display_width_in_codepoints) + m_max_display_width_in_codepoints = MAX_BOOL_WIDTH; break; case MYSQL_TYPE_NEWDECIMAL: { ulong precision = static_cast(m_max_display_width_in_codepoints); diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc index 9cbd0fb00f9e..d7b1a3dfaad5 100644 --- a/sql/dd/dd_table.cc +++ b/sql/dd/dd_table.cc @@ -119,6 +119,9 @@ dd::enum_column_types get_new_field_type(enum_field_types type) { case MYSQL_TYPE_DECIMAL: return dd::enum_column_types::DECIMAL; + case MYSQL_TYPE_BOOL: + return dd::enum_column_types::BOOL; + case MYSQL_TYPE_TINY: return dd::enum_column_types::TINY; @@ -136,7 +139,6 @@ dd::enum_column_types get_new_field_type(enum_field_types type) { case MYSQL_TYPE_NULL: case MYSQL_TYPE_INVALID: - case MYSQL_TYPE_BOOL: return dd::enum_column_types::TYPE_NULL; case MYSQL_TYPE_TIMESTAMP: diff --git a/sql/dd/impl/tables/columns.cc b/sql/dd/impl/tables/columns.cc index d5fc61419363..a69dcc11681e 100644 --- a/sql/dd/impl/tables/columns.cc +++ b/sql/dd/impl/tables/columns.cc @@ -74,7 +74,7 @@ Columns::Columns() { "'MYSQL_TYPE_LONG_BLOB',\n" " 'MYSQL_TYPE_BLOB', 'MYSQL_TYPE_VAR_STRING',\n" " 'MYSQL_TYPE_STRING', 'MYSQL_TYPE_GEOMETRY',\n" - " 'MYSQL_TYPE_JSON'\n" + " 'MYSQL_TYPE_JSON', 'MYSQL_TYPE_BOOL'\n" " ) NOT NULL"); m_target_def.add_field(FIELD_IS_NULLABLE, "FIELD_IS_NULLABLE", "is_nullable TINYINT(1) NOT NULL"); diff --git a/sql/dd/impl/tables/parameters.cc b/sql/dd/impl/tables/parameters.cc index a41834e1b04f..f15980915c16 100644 --- a/sql/dd/impl/tables/parameters.cc +++ b/sql/dd/impl/tables/parameters.cc @@ -76,7 +76,7 @@ Parameters::Parameters() { " 'MYSQL_TYPE_LONG_BLOB', 'MYSQL_TYPE_BLOB',\n" " 'MYSQL_TYPE_VAR_STRING',\n" " 'MYSQL_TYPE_STRING', 'MYSQL_TYPE_GEOMETRY',\n" - " 'MYSQL_TYPE_JSON'\n" + " 'MYSQL_TYPE_JSON', 'MYSQL_TYPE_BOOL'\n" " ) NOT NULL"); m_target_def.add_field(FIELD_DATA_TYPE_UTF8, "FIELD_DATA_TYPE_UTF8", "data_type_utf8 MEDIUMTEXT NOT NULL"); diff --git a/sql/dd/impl/tables/routines.cc b/sql/dd/impl/tables/routines.cc index 2b51e925785a..d2f499cd1564 100644 --- a/sql/dd/impl/tables/routines.cc +++ b/sql/dd/impl/tables/routines.cc @@ -78,7 +78,7 @@ Routines::Routines() { " 'MYSQL_TYPE_LONG_BLOB', 'MYSQL_TYPE_BLOB',\n" " 'MYSQL_TYPE_VAR_STRING',\n" " 'MYSQL_TYPE_STRING', 'MYSQL_TYPE_GEOMETRY',\n" - " 'MYSQL_TYPE_JSON'\n" + " 'MYSQL_TYPE_JSON', 'MYSQL_TYPE_BOOL'\n" " ) DEFAULT NULL"); m_target_def.add_field(FIELD_RESULT_DATA_TYPE_UTF8, "FIELD_RESULT_DATA_TYPE_UTF8", diff --git a/sql/dd_table_share.cc b/sql/dd_table_share.cc index e172561b74df..392bd533c247 100644 --- a/sql/dd_table_share.cc +++ b/sql/dd_table_share.cc @@ -189,6 +189,9 @@ enum_field_types dd_get_old_field_type(dd::enum_column_types type) { case dd::enum_column_types::JSON: return MYSQL_TYPE_JSON; + case dd::enum_column_types::BOOL: + return MYSQL_TYPE_BOOL; + default: DBUG_ASSERT(!"Should not hit here"); /* purecov: deadcode */ } diff --git a/sql/item.cc b/sql/item.cc index 553cf8e89585..61416806276d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5948,8 +5948,11 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, field = new (*THR_MALLOC) Field_bit_as_char(max_length, maybe_null, item_name.ptr()); break; - case MYSQL_TYPE_INVALID: case MYSQL_TYPE_BOOL: + field = new (*THR_MALLOC) + Field_boolean(maybe_null, item_name.ptr()); + break; + case MYSQL_TYPE_INVALID: default: /* This case should never be chosen */ DBUG_ASSERT(0); diff --git a/sql/log_event.cc b/sql/log_event.cc index 51c8cf8f6bb3..b4fef1a22190 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1888,6 +1888,13 @@ static size_t log_event_print_value(IO_CACHE *file, const uchar *ptr, uint type, return 4; } + case MYSQL_TYPE_BOOL: { + snprintf(typestr, typestr_length, "BOOL"); + if(!ptr) return my_b_printf(file, "NULL"); + my_b_write(file, ptr, 1); + return 1; + } + case MYSQL_TYPE_TINY: { snprintf(typestr, typestr_length, "TINYINT"); if (!ptr) return my_b_printf(file, "NULL"); @@ -2177,7 +2184,7 @@ static size_t log_event_print_value(IO_CACHE *file, const uchar *ptr, uint type, } return length + meta; } - case MYSQL_TYPE_BOOL: + case MYSQL_TYPE_INVALID: default: { char tmp[5]; diff --git a/sql/parse_tree_column_attrs.h b/sql/parse_tree_column_attrs.h index eeff55b95ac4..19155f437ace 100644 --- a/sql/parse_tree_column_attrs.h +++ b/sql/parse_tree_column_attrs.h @@ -619,6 +619,7 @@ class PT_bit_type : public PT_type { const char *get_length() const override { return length; } }; +// Does this need to be PT_numeric_type? /** Node for the BOOL/BOOLEAN type diff --git a/sql/partitioning/partition_handler.cc b/sql/partitioning/partition_handler.cc index d4a91dbe9a5f..40a5ae5d8172 100644 --- a/sql/partitioning/partition_handler.cc +++ b/sql/partitioning/partition_handler.cc @@ -810,6 +810,7 @@ uint32 Partition_helper::ph_calculate_key_hash_value(Field **field_array) { Field *field = *field_array; if (use_51_hash) { switch (field->real_type()) { + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -881,7 +882,6 @@ uint32 Partition_helper::ph_calculate_key_hash_value(Field **field_array) { /* These types should not be allowed for partitioning! */ case MYSQL_TYPE_NULL: - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_DATE: case MYSQL_TYPE_TINY_BLOB: diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index 873267a6427f..5184125761c6 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -2764,14 +2764,12 @@ static bool parse_query_bind_params( enum enum_field_types type = has_new_types ? params[i].type : stmt_data->param_array[i]->data_type_actual(); - if (type == MYSQL_TYPE_BOOL) - return true; // unsupported in this version of the Server if (stmt_data && stmt_data->param_array[i]->param_state() == Item_param::LONG_DATA_VALUE) { DBUG_PRINT("info", ("long data")); if (!((type >= MYSQL_TYPE_TINY_BLOB) && (type <= MYSQL_TYPE_STRING))) return true; - if (type == MYSQL_TYPE_BOOL || type == MYSQL_TYPE_INVALID) return true; + if (type == MYSQL_TYPE_INVALID) return true; if (out_parameter_count) *out_parameter_count += 1; continue; } @@ -3254,8 +3252,6 @@ bool Protocol_classic::send_field_metadata(Send_field *field, const CHARSET_INFO *cs = system_charset_info; const CHARSET_INFO *thd_charset = m_thd->variables.character_set_results; - DBUG_ASSERT(field->type != MYSQL_TYPE_BOOL); - /* Keep things compatible for old clients */ if (field->type == MYSQL_TYPE_VARCHAR) field->type = MYSQL_TYPE_VAR_STRING; diff --git a/sql/server_component/mysql_query_attributes_imp.cc b/sql/server_component/mysql_query_attributes_imp.cc index 14b2e65cb9c2..4ce0d420fc30 100644 --- a/sql/server_component/mysql_query_attributes_imp.cc +++ b/sql/server_component/mysql_query_attributes_imp.cc @@ -191,6 +191,13 @@ static String *query_parameter_val_str(const PS_PARAM *param, String *str = nullptr; switch (param->type) { // the expected data types listed in the manual + case MYSQL_TYPE_BOOL: + if(param->length == 1) { + bool value = static_cast(*param->value); + str = new String[1]; + str->set_int(value, param->unsigned_type != 0, cs); + } + break; case MYSQL_TYPE_TINY: if (param->length == 1) { int8 value = (int8)*param->value; @@ -386,7 +393,6 @@ static String *query_parameter_val_str(const PS_PARAM *param, case MYSQL_TYPE_DATETIME2: /**< Internal to MySQL. Not used in protocol */ case MYSQL_TYPE_TIME2: /**< Internal to MySQL. Not used in protocol */ case MYSQL_TYPE_TYPED_ARRAY: /**< Used for replication only */ - case MYSQL_TYPE_BOOL: /**< Currently just a placeholder */ case MYSQL_TYPE_NEWDATE: /**< Internal to MySQL. Not used in protocol */ default: str = nullptr; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index ea36cc37513a..0782a83007fc 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1945,6 +1945,7 @@ static int check_part_field(enum_field_types sql_type, const char *field_name, return true; } switch (sql_type) { + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -1968,7 +1969,6 @@ static int check_part_field(enum_field_types sql_type, const char *field_name, *result_type = STRING_RESULT; *need_cs_check = true; return false; - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TIMESTAMP: From 766893bce00826dd83ca30c3567d4b1bd8e2d00d Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 22 Mar 2021 14:52:46 +0100 Subject: [PATCH 12/60] Remove duplicate MYSQL_TYPE_BOOL cases Reinstate table type check Change ACL table from using BOOL to TINYINT(1) --- scripts/mysql_system_tables.sql | 2 +- sql/dd/dd_table.cc | 3 --- sql/dd_table_share.cc | 3 --- sql/sql_partition.cc | 1 - sql/table.cc | 4 ++-- 5 files changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index 3ba206677265..99275d028f9a 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -520,7 +520,7 @@ INSERT IGNORE INTO engine_cost(engine_name, device_type, cost_name) VALUES ("default", 0, "io_block_read_cost"); -SET @cmd = "CREATE TABLE IF NOT EXISTS proxies_priv (Host char(255) CHARACTER SET ASCII DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Proxied_host char(255) CHARACTER SET ASCII DEFAULT '' NOT NULL, Proxied_user char(32) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor varchar(288) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=InnoDB STATS_PERSISTENT=0 CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges' ROW_FORMAT=DYNAMIC TABLESPACE=mysql"; +SET @cmd = "CREATE TABLE IF NOT EXISTS proxies_priv (Host char(255) CHARACTER SET ASCII DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Proxied_host char(255) CHARACTER SET ASCII DEFAULT '' NOT NULL, Proxied_user char(32) binary DEFAULT '' NOT NULL, With_grant TINYINT(1) DEFAULT 0 NOT NULL, Grantor varchar(288) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=InnoDB STATS_PERSISTENT=0 CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges' ROW_FORMAT=DYNAMIC TABLESPACE=mysql"; SET @str = CONCAT(@cmd, " ENCRYPTION='", @is_mysql_encrypted, "'"); PREPARE stmt FROM @str; EXECUTE stmt; diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc index 247925561db4..d7b1a3dfaad5 100644 --- a/sql/dd/dd_table.cc +++ b/sql/dd/dd_table.cc @@ -141,9 +141,6 @@ dd::enum_column_types get_new_field_type(enum_field_types type) { case MYSQL_TYPE_INVALID: return dd::enum_column_types::TYPE_NULL; - case MYSQL_TYPE_BOOL: - return dd::enum_column_types::BOOL; - case MYSQL_TYPE_TIMESTAMP: return dd::enum_column_types::TIMESTAMP; diff --git a/sql/dd_table_share.cc b/sql/dd_table_share.cc index 1842cd6846a2..2d05e6ead8d4 100644 --- a/sql/dd_table_share.cc +++ b/sql/dd_table_share.cc @@ -192,9 +192,6 @@ enum_field_types dd_get_old_field_type(dd::enum_column_types type) { case dd::enum_column_types::JSON: return MYSQL_TYPE_JSON; - case dd::enum_column_types::BOOL: - return MYSQL_TYPE_BOOL; - default: DBUG_ASSERT(!"Should not hit here"); /* purecov: deadcode */ } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index b9896ed7c15a..0782a83007fc 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1947,7 +1947,6 @@ static int check_part_field(enum_field_types sql_type, const char *field_name, switch (sql_type) { case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: diff --git a/sql/table.cc b/sql/table.cc index c9fda778ed59..5caf3b9384e8 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3805,14 +3805,14 @@ bool Table_check_intact::check(THD *thd MY_ATTRIBUTE((unused)), TABLE *table, original one. */ if (strncmp(sql_type.c_ptr_safe(), field_def->type.str, - field_def->type.length - 1)) {/* + field_def->type.length - 1)) { report_error(ER_CANNOT_LOAD_FROM_TABLE_V2, "Incorrect definition of " "table %s.%s: expected column '%s' at position %d to " "have type %s, found type %s.", table->s->db.str, table->alias, field_def->name.str, i, field_def->type.str, sql_type.c_ptr_safe()); - error = true;*/ + error = true; } else if (field_def->cset.str && !field->has_charset()) { report_error(ER_CANNOT_LOAD_FROM_TABLE_V2, "Incorrect definition of " From e73bb50e926c817e461e585ed4171a1905176dc3 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 22 Mar 2021 14:56:50 +0100 Subject: [PATCH 13/60] Add result file for test test --- mysql-test/r/test.result | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 mysql-test/r/test.result diff --git a/mysql-test/r/test.result b/mysql-test/r/test.result new file mode 100644 index 000000000000..2a6b724491ca --- /dev/null +++ b/mysql-test/r/test.result @@ -0,0 +1,15 @@ +drop table if exists t; +Warnings: +Note 1051 Unknown table 'test.t' +drop database if exists mysqltest; +Warnings: +Note 1008 Can't drop database 'mysqltest'; database doesn't exist +create database mysqltest; +use mysqltest; +create table t (b BOOLEAN); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `b` boolean DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop database mysqltest; From 0cafa6062dab41c48b3c39a1471ec7bc9e341a50 Mon Sep 17 00:00:00 2001 From: Lisa Date: Mon, 22 Mar 2021 14:58:02 +0100 Subject: [PATCH 14/60] double cases removed --- sql/dd/dd_table.cc | 3 --- sql/dd_table_share.cc | 3 --- sql/sql_partition.cc | 1 - 3 files changed, 7 deletions(-) diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc index 247925561db4..d7b1a3dfaad5 100644 --- a/sql/dd/dd_table.cc +++ b/sql/dd/dd_table.cc @@ -141,9 +141,6 @@ dd::enum_column_types get_new_field_type(enum_field_types type) { case MYSQL_TYPE_INVALID: return dd::enum_column_types::TYPE_NULL; - case MYSQL_TYPE_BOOL: - return dd::enum_column_types::BOOL; - case MYSQL_TYPE_TIMESTAMP: return dd::enum_column_types::TIMESTAMP; diff --git a/sql/dd_table_share.cc b/sql/dd_table_share.cc index 1842cd6846a2..2d05e6ead8d4 100644 --- a/sql/dd_table_share.cc +++ b/sql/dd_table_share.cc @@ -192,9 +192,6 @@ enum_field_types dd_get_old_field_type(dd::enum_column_types type) { case dd::enum_column_types::JSON: return MYSQL_TYPE_JSON; - case dd::enum_column_types::BOOL: - return MYSQL_TYPE_BOOL; - default: DBUG_ASSERT(!"Should not hit here"); /* purecov: deadcode */ } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index b9896ed7c15a..0782a83007fc 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1947,7 +1947,6 @@ static int check_part_field(enum_field_types sql_type, const char *field_name, switch (sql_type) { case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: From e5f17b275252dd55e7bc80e2533dcc4aa314991f Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 22 Mar 2021 15:31:39 +0100 Subject: [PATCH 15/60] Change boolean to be a signed value to not print "unsigned" when printing SHOW CREATE TABLE with BOOLEAN --- sql/field.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/field.h b/sql/field.h index ead432f5375b..5f94557086f4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2145,8 +2145,8 @@ class Field_new_decimal : public Field_num { class Field_boolean : public Field_num { public: - Field_boolean(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, bool zero_arg) : Field_num(ptr_arg, 1, null_ptr_arg, null_bit_arg, auto_flags_arg, field_name_arg, 0, zero_arg, 1){} - Field_boolean(bool is_nullable_arg, const char *field_name_arg) : Field_num(nullptr, 1, is_nullable_arg ? &dummy_null_buffer : nullptr, 0, NONE, field_name_arg, 0, false, 1){} + Field_boolean(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, bool zero_arg) : Field_num(ptr_arg, 1, null_ptr_arg, null_bit_arg, auto_flags_arg, field_name_arg, 0, zero_arg, 0){} + Field_boolean(bool is_nullable_arg, const char *field_name_arg) : Field_num(nullptr, 1, is_nullable_arg ? &dummy_null_buffer : nullptr, 0, NONE, field_name_arg, 0, false, 0){} enum Item_result result_type() const final { return INT_RESULT; } enum_field_types type() const override { return MYSQL_TYPE_BOOL; } enum ha_base_keytype key_type() const final { return HA_KEYTYPE_BINARY; } From d715d6cfc1a7571eed87de1878ee07c2eba5e763 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 22 Mar 2021 17:57:32 +0100 Subject: [PATCH 16/60] Add test case for type BOOLEAN --- mysql-test/t/type_boolean.test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 mysql-test/t/type_boolean.test diff --git a/mysql-test/t/type_boolean.test b/mysql-test/t/type_boolean.test new file mode 100644 index 000000000000..cc3690cdedee --- /dev/null +++ b/mysql-test/t/type_boolean.test @@ -0,0 +1,30 @@ +# +# Test BOOLEAN data type +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# FALSE, TRUE, and UNKNOWN will be substitutes for 0, 1, and NULL +# SELECT FALSE, TRUE, UNKNOWN; +SELECT FALSE, TRUE; + +CREATE TABLE t1 (b BOOLEAN); +SHOW CREATE TABLE t1; + +INSERT INTO t1 VALUES (FALSE), (TRUE), (NULL); + +SELECT * FROM t1; +SELECT * FROM t1 WHERE b; +SELECT * FROM t1 WHERE NOT b; +SELECT * FROM t1 WHERE b IS NULL; + +INSERT INTO t1 VALUES (0.1); +SELECT * FROM t1; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (-1); +INSERT INTO t1 VALUES (1.5); +SELECT * FROM t1; + +DROP TABLE t1; \ No newline at end of file From 25e7243925699835f206e0665bc8e5e9eef53b04 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Wed, 24 Mar 2021 16:45:39 +0100 Subject: [PATCH 17/60] Swap implementation of Field_boolean::store from using double to using longlong --- sql/field.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 16a18c408af2..4b6e1d835536 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3189,6 +3189,13 @@ type_conversion_status Field_boolean::store(const char *from, size_t len, } type_conversion_status Field_boolean::store(double nr) { + return Field_boolean::store(static_cast(nr), 0); +} + +//Why? +//Change double and longlong +//How is decimal numbers converted to booleans today? +type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { ASSERT_COLUMN_MARKED_FOR_WRITE; type_conversion_status error = TYPE_OK; if(nr != 0) { @@ -3197,20 +3204,12 @@ type_conversion_status Field_boolean::store(double nr) { set_warning(Sql_condition::SL_WARNING, ER_WARN_DATA_OUT_OF_RANGE, 1); error = TYPE_WARN_OUT_OF_RANGE; } - }else { + } else { *ptr = 0; } - return error; } -//Why? -//Change double and longlong -//How is decimal numbers converted to booleans today? -type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { - return Field_boolean::store((double)nr); -} - double Field_boolean::val_real() const { ASSERT_COLUMN_MARKED_FOR_READ; bool tmp = (bool)ptr[0]; From 4c027541f42adc6f4fa40b2669d7be49ea46179b Mon Sep 17 00:00:00 2001 From: Lisa Date: Thu, 25 Mar 2021 17:22:42 +0100 Subject: [PATCH 18/60] length of BOOL is now 1 byte, not 4GB --- libbinlogevents/src/binary_log_funcs.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libbinlogevents/src/binary_log_funcs.cpp b/libbinlogevents/src/binary_log_funcs.cpp index 5e2c422f4249..bd4cb242adee 100644 --- a/libbinlogevents/src/binary_log_funcs.cpp +++ b/libbinlogevents/src/binary_log_funcs.cpp @@ -122,7 +122,8 @@ unsigned int max_display_length_for_field(enum_field_types sql_type, case MYSQL_TYPE_YEAR: case MYSQL_TYPE_TINY: return 4; - + case MYSQL_TYPE_BOOL: + return 1; case MYSQL_TYPE_SHORT: return 6; @@ -254,6 +255,7 @@ uint32_t calc_field_size(unsigned char col, const unsigned char *master_data, } case MYSQL_TYPE_YEAR: case MYSQL_TYPE_TINY: + case MYSQL_TYPE_BOOL: length = 1; break; case MYSQL_TYPE_SHORT: From 4cc11e7449d560fbb920023a82e519acfaad0d90 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Thu, 25 Mar 2021 17:32:13 +0100 Subject: [PATCH 19/60] Fix boolean fields storing small decimal values as 0 instead of 1 Remove some redundant code and c-style casts --- mysql-test/t/type_boolean.test | 2 +- sql/field.cc | 25 +++++++++++-------------- sql/field.h | 1 + 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/mysql-test/t/type_boolean.test b/mysql-test/t/type_boolean.test index cc3690cdedee..47ad41cdcdba 100644 --- a/mysql-test/t/type_boolean.test +++ b/mysql-test/t/type_boolean.test @@ -20,7 +20,7 @@ SELECT * FROM t1 WHERE b; SELECT * FROM t1 WHERE NOT b; SELECT * FROM t1 WHERE b IS NULL; -INSERT INTO t1 VALUES (0.1); +INSERT INTO t1 VALUES (0.2); SELECT * FROM t1; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (-1); diff --git a/sql/field.cc b/sql/field.cc index 4b6e1d835536..067e816f2143 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2013,7 +2013,7 @@ longlong Field::convert_decimal2longlong(const my_decimal *val, @param val value for storing @note - This method is used by all integer fields, real/decimal redefine it + This method is used by all integer fields except boolean, real/decimal/boolean redefine it @retval TYPE_OK Storage of value went fine without warnings or errors @retval !TYPE_OK Warning/error as indicated by type_conversion_status enum @@ -3189,12 +3189,10 @@ type_conversion_status Field_boolean::store(const char *from, size_t len, } type_conversion_status Field_boolean::store(double nr) { - return Field_boolean::store(static_cast(nr), 0); + ASSERT_COLUMN_MARKED_FOR_WRITE; + return Field_boolean::store(nr ? 1 : 0, 0); } -//Why? -//Change double and longlong -//How is decimal numbers converted to booleans today? type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { ASSERT_COLUMN_MARKED_FOR_WRITE; type_conversion_status error = TYPE_OK; @@ -3210,6 +3208,11 @@ type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { return error; } +type_conversion_status Field_boolean::store_decimal(const my_decimal *val) { + ASSERT_COLUMN_MARKED_FOR_WRITE; + const type_conversion_status res = store(!my_decimal_is_zero(val), 0); +} + double Field_boolean::val_real() const { ASSERT_COLUMN_MARKED_FOR_READ; bool tmp = (bool)ptr[0]; @@ -3225,7 +3228,6 @@ longlong Field_boolean::val_int() const { // #TODO ask about string rep. 0 or 1, or FALSE or TRUE? //Test both ways //Use static_cast or eliminiate casting -//No need to check is_unsigned String *Field_boolean::val_str(String *val_buffer, String *) const { ASSERT_COLUMN_MARKED_FOR_READ; const CHARSET_INFO *cs = &my_charset_numeric; @@ -3234,14 +3236,9 @@ String *Field_boolean::val_str(String *val_buffer, String *) const { val_buffer->alloc(mlength); char *to = val_buffer->ptr(); - if (is_unsigned()) - length = (uint)cs->cset->long10_to_str(cs, to, mlength, 10, (long)*ptr); - else - length = (uint)cs->cset->long10_to_str(cs, to, mlength, -10, - (long)*((signed char *)ptr)); + length = static_cast(cs->cset->long10_to_str(cs, to, mlength, -10, (long)*((signed char *)ptr))); val_buffer->length(length); - if (zerofill) prepend_zeros(val_buffer); val_buffer->set_charset(cs); return val_buffer; } @@ -3253,8 +3250,8 @@ bool Field_boolean::send_to_protocol(Protocol *protocol) const { int Field_boolean::cmp(const uchar *a_ptr, const uchar *b_ptr) const { bool a, b; - a = (bool)a_ptr[0]; - b = (bool)b_ptr[0]; + a = static_cast(a_ptr[0]); + b = static_cast(b_ptr[0]); return (a < b) ? -1 : (a > b) ? 1 : 0; } diff --git a/sql/field.h b/sql/field.h index 5f94557086f4..8436ff150456 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2154,6 +2154,7 @@ class Field_boolean : public Field_num { const CHARSET_INFO *charset) override; type_conversion_status store(double nr) override; type_conversion_status store(longlong nr, bool unsigned_val) override; + type_conversion_status store_decimal(const my_decimal *val) override; double val_real() const override; longlong val_int() const override; String *val_str(String *, String *) const override; From 341c2980ee2e20aa19deb0fde61d3d5528351240 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Fri, 26 Mar 2021 13:55:00 +0100 Subject: [PATCH 20/60] Add more tests for boolean data type --- mysql-test/t/type_boolean.test | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mysql-test/t/type_boolean.test b/mysql-test/t/type_boolean.test index 47ad41cdcdba..a57cdd3f5fda 100644 --- a/mysql-test/t/type_boolean.test +++ b/mysql-test/t/type_boolean.test @@ -10,21 +10,29 @@ DROP TABLE IF EXISTS t1; # SELECT FALSE, TRUE, UNKNOWN; SELECT FALSE, TRUE; -CREATE TABLE t1 (b BOOLEAN); +CREATE TABLE t1 (b1 BOOLEAN, b2 BOOL); SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (b BOOLEAN); INSERT INTO t1 VALUES (FALSE), (TRUE), (NULL); SELECT * FROM t1; SELECT * FROM t1 WHERE b; SELECT * FROM t1 WHERE NOT b; SELECT * FROM t1 WHERE b IS NULL; +SELECT * FROM t1 WHERE b IS NOT NULL; + +UPDATE t1 SET b = b + 1 WHERE NOT b; INSERT INTO t1 VALUES (0.2); SELECT * FROM t1; -INSERT INTO t1 VALUES (2); -INSERT INTO t1 VALUES (-1); -INSERT INTO t1 VALUES (1.5); -SELECT * FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); +insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); +select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; DROP TABLE t1; \ No newline at end of file From 0e30f4781b11e3ae939e404ca1cdcf8198b45787 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 30 Mar 2021 13:48:14 +0200 Subject: [PATCH 21/60] Fix storage of decimal values as boolean --- sql/field.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 067e816f2143..356be58a392e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3190,7 +3190,7 @@ type_conversion_status Field_boolean::store(const char *from, size_t len, type_conversion_status Field_boolean::store(double nr) { ASSERT_COLUMN_MARKED_FOR_WRITE; - return Field_boolean::store(nr ? 1 : 0, 0); + return store(nr ? 1 : 0, 0); } type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { @@ -3209,8 +3209,8 @@ type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { } type_conversion_status Field_boolean::store_decimal(const my_decimal *val) { - ASSERT_COLUMN_MARKED_FOR_WRITE; - const type_conversion_status res = store(!my_decimal_is_zero(val), 0); + ASSERT_COLUMN_MARKED_FOR_WRITE; + return store(!my_decimal_is_zero(val), 0); } double Field_boolean::val_real() const { From 4fb7eeec746d9ac0d36ae0f5c6f4b44ca997ae00 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Wed, 7 Apr 2021 11:59:25 +0200 Subject: [PATCH 22/60] Change boolean input value out of range warning level to note --- mysql-test/t/type_boolean.test | 3 +++ sql/field.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/type_boolean.test b/mysql-test/t/type_boolean.test index a57cdd3f5fda..2b611fa907dd 100644 --- a/mysql-test/t/type_boolean.test +++ b/mysql-test/t/type_boolean.test @@ -29,6 +29,9 @@ UPDATE t1 SET b = b + 1 WHERE NOT b; INSERT INTO t1 VALUES (0.2); SELECT * FROM t1; +INSERT INTO t1 VALUES (2); +SELECT * FROM t1; + DROP TABLE t1; CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); diff --git a/sql/field.cc b/sql/field.cc index 067e816f2143..cff701d6f760 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3199,7 +3199,7 @@ type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { if(nr != 0) { *ptr = 1; if (nr != 1){ - set_warning(Sql_condition::SL_WARNING, ER_WARN_DATA_OUT_OF_RANGE, 1); + set_warning(Sql_condition::SL_NOTE, ER_WARN_DATA_OUT_OF_RANGE, 1); error = TYPE_WARN_OUT_OF_RANGE; } } else { From 63c995f7e5a5ce7cc8f20881bc9ee95413a73eeb Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 20 Apr 2021 12:34:15 +0200 Subject: [PATCH 23/60] Remove warning when storing out of range value in boolean field Remove redundant drop table in test --- mysql-test/t/type_boolean.test | 5 ----- sql/field.cc | 8 ++------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/type_boolean.test b/mysql-test/t/type_boolean.test index 2b611fa907dd..6de4c956ccc7 100644 --- a/mysql-test/t/type_boolean.test +++ b/mysql-test/t/type_boolean.test @@ -1,11 +1,6 @@ # # Test BOOLEAN data type # - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - # FALSE, TRUE, and UNKNOWN will be substitutes for 0, 1, and NULL # SELECT FALSE, TRUE, UNKNOWN; SELECT FALSE, TRUE; diff --git a/sql/field.cc b/sql/field.cc index 608ac91214d5..970ac818eba4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3190,18 +3190,14 @@ type_conversion_status Field_boolean::store(const char *from, size_t len, type_conversion_status Field_boolean::store(double nr) { ASSERT_COLUMN_MARKED_FOR_WRITE; - return store(nr ? 1 : 0, 0); + return store(nr != 0.0e0, 0); } -type_conversion_status Field_boolean::store(longlong nr, bool unsigned_val) { +type_conversion_status Field_boolean::store(longlong nr, bool) { ASSERT_COLUMN_MARKED_FOR_WRITE; type_conversion_status error = TYPE_OK; if(nr != 0) { *ptr = 1; - if (nr != 1){ - set_warning(Sql_condition::SL_NOTE, ER_WARN_DATA_OUT_OF_RANGE, 1); - error = TYPE_WARN_OUT_OF_RANGE; - } } else { *ptr = 0; } From a6ba9f34e5a650c50fffe47346f320db4467112b Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 20 Apr 2021 12:40:16 +0200 Subject: [PATCH 24/60] Add result file for type_boolean test --- mysql-test/r/type_boolean.result | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 mysql-test/r/type_boolean.result diff --git a/mysql-test/r/type_boolean.result b/mysql-test/r/type_boolean.result new file mode 100644 index 000000000000..e1cc047578e5 --- /dev/null +++ b/mysql-test/r/type_boolean.result @@ -0,0 +1,62 @@ +SELECT FALSE, TRUE; +FALSE TRUE +0 1 +CREATE TABLE t1 (b1 BOOLEAN, b2 BOOL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b1` boolean DEFAULT NULL, + `b2` boolean DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (b BOOLEAN); +INSERT INTO t1 VALUES (FALSE), (TRUE), (NULL); +SELECT * FROM t1; +b +0 +1 +NULL +SELECT * FROM t1 WHERE b; +b +1 +SELECT * FROM t1 WHERE NOT b; +b +0 +SELECT * FROM t1 WHERE b IS NULL; +b +NULL +SELECT * FROM t1 WHERE b IS NOT NULL; +b +0 +1 +UPDATE t1 SET b = b + 1 WHERE NOT b; +INSERT INTO t1 VALUES (0.2); +SELECT * FROM t1; +b +1 +1 +NULL +1 +INSERT INTO t1 VALUES (2); +SELECT * FROM t1; +b +1 +1 +NULL +1 +1 +DROP TABLE t1; +CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); +insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); +select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; +A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB +N N N N N N N N N N +0 N 1 N 0 1 1 N N N +1 N 0 N N N N 1 0 0 +N 0 N 1 0 1 1 N N N +N 1 N 0 N N N 1 0 0 +0 0 1 1 0 1 1 0 1 1 +0 1 1 0 0 1 1 1 0 0 +1 0 0 1 0 1 1 1 0 0 +1 1 0 0 1 0 0 1 0 0 +DROP TABLE t1; From 16f4e402d118956018fd25123d51b840132f828e Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 20 Apr 2021 12:51:05 +0200 Subject: [PATCH 25/60] Change c type casts to static_cast --- sql/field.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 970ac818eba4..1b74281c19eb 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3221,9 +3221,6 @@ longlong Field_boolean::val_int() const { return (longlong)tmp; } -// #TODO ask about string rep. 0 or 1, or FALSE or TRUE? -//Test both ways -//Use static_cast or eliminiate casting String *Field_boolean::val_str(String *val_buffer, String *) const { ASSERT_COLUMN_MARKED_FOR_READ; const CHARSET_INFO *cs = &my_charset_numeric; @@ -3232,7 +3229,7 @@ String *Field_boolean::val_str(String *val_buffer, String *) const { val_buffer->alloc(mlength); char *to = val_buffer->ptr(); - length = static_cast(cs->cset->long10_to_str(cs, to, mlength, -10, (long)*((signed char *)ptr))); + length = static_cast(cs->cset->long10_to_str(cs, to, mlength, -10, static_cast(static_cast(ptr))); val_buffer->length(length); val_buffer->set_charset(cs); From eebf16a42d8b4a97972117d656033eb2f722a6c8 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 20 Apr 2021 13:06:42 +0200 Subject: [PATCH 26/60] Revert "Change c type casts to static_cast" static_cast threw an error here. Ask experts about it This reverts commit 16f4e402d118956018fd25123d51b840132f828e. --- sql/field.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/field.cc b/sql/field.cc index 1b74281c19eb..970ac818eba4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3221,6 +3221,9 @@ longlong Field_boolean::val_int() const { return (longlong)tmp; } +// #TODO ask about string rep. 0 or 1, or FALSE or TRUE? +//Test both ways +//Use static_cast or eliminiate casting String *Field_boolean::val_str(String *val_buffer, String *) const { ASSERT_COLUMN_MARKED_FOR_READ; const CHARSET_INFO *cs = &my_charset_numeric; @@ -3229,7 +3232,7 @@ String *Field_boolean::val_str(String *val_buffer, String *) const { val_buffer->alloc(mlength); char *to = val_buffer->ptr(); - length = static_cast(cs->cset->long10_to_str(cs, to, mlength, -10, static_cast(static_cast(ptr))); + length = static_cast(cs->cset->long10_to_str(cs, to, mlength, -10, (long)*((signed char *)ptr))); val_buffer->length(length); val_buffer->set_charset(cs); From c8796371cf2ab745584969ed134b2e32d7497f35 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 26 Apr 2021 13:49:44 +0200 Subject: [PATCH 27/60] Small code changes Temporary removal of boolean data type --- sql/field.cc | 4 +++- sql/field.h | 2 +- sql/item.cc | 2 +- sql/item.h | 2 +- sql/parse_tree_column_attrs.h | 2 +- sql/protocol_classic.cc | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 970ac818eba4..46d102aebd65 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9528,7 +9528,9 @@ Field *make_field(MEM_ROOT *mem_root, TABLE_SHARE *share, uchar *ptr, bit_offset, auto_flags, field_name); case MYSQL_TYPE_BOOL: return new (mem_root) - Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); + Field_tiny(ptr, field_length, null_pos, null_bit, auto_flags, + field_name, is_zerofill, is_unsigned); + //Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); case MYSQL_TYPE_INVALID: default: // Impossible (Wrong version) diff --git a/sql/field.h b/sql/field.h index 8436ff150456..01e331d8401f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2165,7 +2165,7 @@ class Field_boolean : public Field_num { void sql_type(String &str) const override; uint32 max_display_length() const final { return 1; } Field_boolean *clone(MEM_ROOT *mem_root) const override { - DBUG_ASSERT(type() == MYSQL_TYPE_BOOL); + assert(type() == MYSQL_TYPE_BOOL); return new (mem_root) Field_boolean(*this); } uchar *pack(uchar *to, const uchar *from, size_t max_length) const final { diff --git a/sql/item.cc b/sql/item.cc index 9b6f80b672d7..94c1a593d257 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6768,7 +6768,7 @@ bool Item::send(Protocol *protocol, String *buffer) { res->charset()); break; } - case MYSQL_TYPE_BOOL:{ + case MYSQL_TYPE_BOOL: { longlong nr = val_int(); if (!null_value) return protocol->store_boolean(nr); break; diff --git a/sql/item.h b/sql/item.h index 26fdde30d306..01f544e4aed3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -891,12 +891,12 @@ class Item : public Parse_tree_node { // Return the default result type for a given data type static Item_result type_to_result(enum_field_types type) { switch (type) { + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_INT24: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_BIT: case MYSQL_TYPE_YEAR: return INT_RESULT; diff --git a/sql/parse_tree_column_attrs.h b/sql/parse_tree_column_attrs.h index 19155f437ace..bed31c5fbb99 100644 --- a/sql/parse_tree_column_attrs.h +++ b/sql/parse_tree_column_attrs.h @@ -619,12 +619,12 @@ class PT_bit_type : public PT_type { const char *get_length() const override { return length; } }; -// Does this need to be PT_numeric_type? /** Node for the BOOL/BOOLEAN type @ingroup ptn_column_types */ +// Does this need to be PT_numeric_type? class PT_boolean_type : public PT_type { public: PT_boolean_type() : PT_type(MYSQL_TYPE_BOOL) {} diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index 5184125761c6..f429beb0856f 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -3786,7 +3786,7 @@ bool Protocol_binary::store_boolean(longlong from) { assert(field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_BOOL); field_pos++; - buff[0] = (char)from; + buff[0] = static_cast(from); return packet->append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC); } From 76f65519b6e60690bda19a8dbb831ddbaeff8885 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Mon, 26 Apr 2021 13:53:59 +0200 Subject: [PATCH 28/60] Revert "Small code changes" This reverts commit c8796371cf2ab745584969ed134b2e32d7497f35. --- sql/field.cc | 4 +--- sql/field.h | 2 +- sql/item.cc | 2 +- sql/item.h | 2 +- sql/parse_tree_column_attrs.h | 2 +- sql/protocol_classic.cc | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 46d102aebd65..970ac818eba4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9528,9 +9528,7 @@ Field *make_field(MEM_ROOT *mem_root, TABLE_SHARE *share, uchar *ptr, bit_offset, auto_flags, field_name); case MYSQL_TYPE_BOOL: return new (mem_root) - Field_tiny(ptr, field_length, null_pos, null_bit, auto_flags, - field_name, is_zerofill, is_unsigned); - //Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); + Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); case MYSQL_TYPE_INVALID: default: // Impossible (Wrong version) diff --git a/sql/field.h b/sql/field.h index 01e331d8401f..8436ff150456 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2165,7 +2165,7 @@ class Field_boolean : public Field_num { void sql_type(String &str) const override; uint32 max_display_length() const final { return 1; } Field_boolean *clone(MEM_ROOT *mem_root) const override { - assert(type() == MYSQL_TYPE_BOOL); + DBUG_ASSERT(type() == MYSQL_TYPE_BOOL); return new (mem_root) Field_boolean(*this); } uchar *pack(uchar *to, const uchar *from, size_t max_length) const final { diff --git a/sql/item.cc b/sql/item.cc index 94c1a593d257..9b6f80b672d7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6768,7 +6768,7 @@ bool Item::send(Protocol *protocol, String *buffer) { res->charset()); break; } - case MYSQL_TYPE_BOOL: { + case MYSQL_TYPE_BOOL:{ longlong nr = val_int(); if (!null_value) return protocol->store_boolean(nr); break; diff --git a/sql/item.h b/sql/item.h index 01f544e4aed3..26fdde30d306 100644 --- a/sql/item.h +++ b/sql/item.h @@ -891,12 +891,12 @@ class Item : public Parse_tree_node { // Return the default result type for a given data type static Item_result type_to_result(enum_field_types type) { switch (type) { - case MYSQL_TYPE_BOOL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_INT24: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: + case MYSQL_TYPE_BOOL: case MYSQL_TYPE_BIT: case MYSQL_TYPE_YEAR: return INT_RESULT; diff --git a/sql/parse_tree_column_attrs.h b/sql/parse_tree_column_attrs.h index bed31c5fbb99..19155f437ace 100644 --- a/sql/parse_tree_column_attrs.h +++ b/sql/parse_tree_column_attrs.h @@ -619,12 +619,12 @@ class PT_bit_type : public PT_type { const char *get_length() const override { return length; } }; +// Does this need to be PT_numeric_type? /** Node for the BOOL/BOOLEAN type @ingroup ptn_column_types */ -// Does this need to be PT_numeric_type? class PT_boolean_type : public PT_type { public: PT_boolean_type() : PT_type(MYSQL_TYPE_BOOL) {} diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index f429beb0856f..5184125761c6 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -3786,7 +3786,7 @@ bool Protocol_binary::store_boolean(longlong from) { assert(field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_BOOL); field_pos++; - buff[0] = static_cast(from); + buff[0] = (char)from; return packet->append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC); } From 7d29d85c89e4ae0f0fd98fe4cf343fc0a05faebf Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Fri, 30 Apr 2021 11:30:13 +0200 Subject: [PATCH 29/60] Reinstate boolean field type Comment with tries for fix in ndb --- sql/dd/dd_table.cc | 24 ++++++++++++++++++++++++ sql/field.cc | 4 +--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc index d7b1a3dfaad5..d165e2380e28 100644 --- a/sql/dd/dd_table.cc +++ b/sql/dd/dd_table.cc @@ -555,6 +555,30 @@ bool fill_dd_columns_from_create_fields(THD *thd, dd::Abstract_table *tab_obj, col_obj->set_name(field.field_name); + // Tried setting boolean type fields to tinyint temporarily for ndb. Did not work + /* + if (field.sql_type == MYSQL_TYPE_BOOL && strcmp(typeid(tab_obj).name(), "Table_impl *") == 0 && strcmp((dynamic_cast(dynamic_cast(tab_obj)))->engine().c_str(), "ndbcluster") == 0) + field.set = MYSQL_TYPE_TINY; + + // Change to set field.sql_type instead + if (field.sql_type == MYSQL_TYPE_BOOL){ + String_type engine; + if(strcmp(typeid(tab_obj).name(), "Table_impl *") == 0) { + engine = (dynamic_cast
(dynamic_cast(tab_obj)))->engine(); + } + else { + engine = ""; + } + if (strcmp(engine.c_str(), "ndbcluster") == 0) { + col_obj->set_type(dd::get_new_field_type(MYSQL_TYPE_TINY)); + } + else { + col_obj->set_type(dd::get_new_field_type(field.sql_type)); + } + } + else { + col_obj->set_type(dd::get_new_field_type(field.sql_type)); + }*/ col_obj->set_type(dd::get_new_field_type(field.sql_type)); col_obj->set_char_length(field.max_display_width_in_bytes()); diff --git a/sql/field.cc b/sql/field.cc index 46d102aebd65..970ac818eba4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9528,9 +9528,7 @@ Field *make_field(MEM_ROOT *mem_root, TABLE_SHARE *share, uchar *ptr, bit_offset, auto_flags, field_name); case MYSQL_TYPE_BOOL: return new (mem_root) - Field_tiny(ptr, field_length, null_pos, null_bit, auto_flags, - field_name, is_zerofill, is_unsigned); - //Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); + Field_boolean(ptr, null_pos, null_bit, auto_flags, field_name, is_zerofill); case MYSQL_TYPE_INVALID: default: // Impossible (Wrong version) From b36a3f978b9a1e5100688647868828d7f71760ca Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Fri, 30 Apr 2021 15:57:09 +0200 Subject: [PATCH 30/60] Fix alter table from floating point type to boolean rounding instead of converting to bool correctly Change a few c type casts to static_cast --- sql/dd/dd_table.cc | 24 ------------------------ sql/field.cc | 10 +++++----- sql/field_conv.cc | 11 ++++++++--- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc index d165e2380e28..d7b1a3dfaad5 100644 --- a/sql/dd/dd_table.cc +++ b/sql/dd/dd_table.cc @@ -555,30 +555,6 @@ bool fill_dd_columns_from_create_fields(THD *thd, dd::Abstract_table *tab_obj, col_obj->set_name(field.field_name); - // Tried setting boolean type fields to tinyint temporarily for ndb. Did not work - /* - if (field.sql_type == MYSQL_TYPE_BOOL && strcmp(typeid(tab_obj).name(), "Table_impl *") == 0 && strcmp((dynamic_cast
(dynamic_cast(tab_obj)))->engine().c_str(), "ndbcluster") == 0) - field.set = MYSQL_TYPE_TINY; - - // Change to set field.sql_type instead - if (field.sql_type == MYSQL_TYPE_BOOL){ - String_type engine; - if(strcmp(typeid(tab_obj).name(), "Table_impl *") == 0) { - engine = (dynamic_cast
(dynamic_cast(tab_obj)))->engine(); - } - else { - engine = ""; - } - if (strcmp(engine.c_str(), "ndbcluster") == 0) { - col_obj->set_type(dd::get_new_field_type(MYSQL_TYPE_TINY)); - } - else { - col_obj->set_type(dd::get_new_field_type(field.sql_type)); - } - } - else { - col_obj->set_type(dd::get_new_field_type(field.sql_type)); - }*/ col_obj->set_type(dd::get_new_field_type(field.sql_type)); col_obj->set_char_length(field.max_display_width_in_bytes()); diff --git a/sql/field.cc b/sql/field.cc index 970ac818eba4..095703cf5fe2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3186,7 +3186,7 @@ type_conversion_status Field_boolean::store(const char *from, size_t len, get_int(cs, from, len, &rnd, 1, 0, 1); ptr[0] = (bool)rnd; return error; -} +} type_conversion_status Field_boolean::store(double nr) { ASSERT_COLUMN_MARKED_FOR_WRITE; @@ -3211,14 +3211,14 @@ type_conversion_status Field_boolean::store_decimal(const my_decimal *val) { double Field_boolean::val_real() const { ASSERT_COLUMN_MARKED_FOR_READ; - bool tmp = (bool)ptr[0]; - return (double)tmp; + bool tmp = static_cast(ptr[0]); + return static_cast(tmp); } longlong Field_boolean::val_int() const { ASSERT_COLUMN_MARKED_FOR_READ; - bool tmp = (bool)ptr[0]; - return (longlong)tmp; + bool tmp = static_cast(ptr[0]); + return static_cast(tmp); } // #TODO ask about string rep. 0 or 1, or FALSE or TRUE? diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 814970d900b5..9dc86f27e040 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -369,6 +369,11 @@ static void do_field_varbinary_pre50(Copy_field *copy, const Field *from_field, to_field->store(copy->tmp.c_ptr_quick(), length, copy->tmp.charset()); } +static void do_field_boolean(Copy_field *, const Field *from_field, + Field *to_field) { + to_field->store(from_field->val_real()); +} + static void do_field_int(Copy_field *, const Field *from_field, Field *to_field) { longlong value = from_field->val_int(); @@ -655,7 +660,7 @@ Copy_field::Copy_func *Copy_field::get_copy_func(bool save) { if (is_temporal_type(m_to_field->type())) { return do_field_time; } else { - if (m_to_field->result_type() == INT_RESULT) return do_field_int; + if (m_to_field->result_type() == INT_RESULT) return m_to_field->type() == MYSQL_TYPE_BOOL ? do_field_boolean : do_field_int; if (m_to_field->result_type() == REAL_RESULT) return do_field_real; /* Note: conversion from any to DECIMAL_RESULT is handled earlier */ } @@ -721,14 +726,14 @@ Copy_field::Copy_func *Copy_field::get_copy_func(bool save) { if (m_to_field->real_type() == MYSQL_TYPE_DECIMAL || m_to_field->result_type() == STRING_RESULT) return do_field_string; - if (m_to_field->result_type() == INT_RESULT) return do_field_int; + if (m_to_field->result_type() == INT_RESULT) return m_to_field->type() == MYSQL_TYPE_BOOL ? do_field_boolean : do_field_int; return do_field_real; } else { if (!m_to_field->eq_def(m_from_field) || !compatible_db_low_byte_first) { if (m_to_field->real_type() == MYSQL_TYPE_DECIMAL) return do_field_string; if (m_to_field->result_type() == INT_RESULT) - return do_field_int; + return m_to_field->type() == MYSQL_TYPE_BOOL ? do_field_boolean : do_field_int; else return do_field_real; } From 96d48f0ba5492c6bb2d80c7850394a042d20399a Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 20:32:00 +0200 Subject: [PATCH 31/60] ran --record on tests with wanted bahavior --- mysql-test/r/cast.result | 4 ++-- mysql-test/r/check_constraints.result | 10 +++++----- mysql-test/r/invisible_columns.result | 4 ++-- mysql-test/r/invisible_columns_myisam.result | 4 ++-- mysql-test/r/ps_2myisam.result | 2 +- mysql-test/r/ps_3innodb.result | 2 +- mysql-test/r/ps_4heap.result | 2 +- mysql-test/r/ps_5merge.result | 4 ++-- mysql-test/r/ps_w_max_indexes_64.result | 2 +- mysql-test/r/ps_w_max_indexes_64_myisam.result | 2 +- mysql-test/r/show_check_cs_myisam.result | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index b84ba14057a3..12e3ff5d83e3 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -1760,10 +1760,10 @@ CAST(TIMESTAMP'2010-01-01 08:09:10' AS YEAR) 2010 SELECT CAST(TIME'08:09:10' AS YEAR); CAST(TIME'08:09:10' AS YEAR) -2020 +2021 SELECT CAST(TIME'00:00:00' AS YEAR); CAST(TIME'00:00:00' AS YEAR) -2020 +2021 SELECT CAST(ST_PointFromText('POINT(10 10)') AS YEAR); ERROR HY000: Incorrect arguments to cast_as_year CREATE TABLE t AS SELECT CAST("2010" AS YEAR); diff --git a/mysql-test/r/check_constraints.result b/mysql-test/r/check_constraints.result index a9014a5c4e76..7946c851690f 100644 --- a/mysql-test/r/check_constraints.result +++ b/mysql-test/r/check_constraints.result @@ -1539,7 +1539,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bit(7) DEFAULT NULL, - `c2` tinyint(1) DEFAULT NULL, + `c2` boolean DEFAULT NULL, `c3` tinyint DEFAULT NULL, `c4` smallint DEFAULT NULL, `c5` mediumint DEFAULT NULL, @@ -2313,7 +2313,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bit(7) DEFAULT NULL, - `c2` tinyint(1) DEFAULT NULL, + `c2` boolean DEFAULT NULL, `c3` tinyint DEFAULT NULL, `c4` smallint DEFAULT NULL, `c5` mediumint DEFAULT NULL, @@ -2341,7 +2341,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bit(7) DEFAULT NULL, - `c2` tinyint(1) DEFAULT NULL, + `c2` boolean DEFAULT NULL, `c3` tinyint DEFAULT NULL, `c4` smallint DEFAULT NULL, `c5` mediumint DEFAULT NULL, @@ -2396,7 +2396,7 @@ SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `c1` bit(7) DEFAULT NULL, - `c2` tinyint(1) DEFAULT NULL, + `c2` boolean DEFAULT NULL, `c3` tinyint DEFAULT NULL, `c4` smallint DEFAULT NULL, `c5` mediumint DEFAULT NULL, @@ -2422,7 +2422,7 @@ SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `c1` bit(7) DEFAULT NULL, - `c2` tinyint(1) DEFAULT NULL, + `c2` boolean DEFAULT NULL, `c3` tinyint DEFAULT NULL, `c4` smallint DEFAULT NULL, `c5` mediumint DEFAULT NULL, diff --git a/mysql-test/r/invisible_columns.result b/mysql-test/r/invisible_columns.result index d19b084e4248..38f79415e9c4 100644 --- a/mysql-test/r/invisible_columns.result +++ b/mysql-test/r/invisible_columns.result @@ -224,7 +224,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `c0` int DEFAULT NULL, `c1` bit(7) DEFAULT NULL /*!80023 INVISIBLE */, - `c2` tinyint(1) DEFAULT NULL /*!80023 INVISIBLE */, + `c2` boolean DEFAULT NULL /*!80023 INVISIBLE */, `c3` tinyint DEFAULT NULL /*!80023 INVISIBLE */, `c4` smallint DEFAULT NULL /*!80023 INVISIBLE */, `c5` mediumint DEFAULT NULL /*!80023 INVISIBLE */, @@ -263,7 +263,7 @@ SHOW COLUMNS FROM t1; Field Type Null Key Default Extra c0 int YES NULL c1 bit(7) YES NULL INVISIBLE -c2 tinyint(1) YES NULL INVISIBLE +c2 boolean YES NULL INVISIBLE c3 tinyint YES NULL INVISIBLE c4 smallint YES NULL INVISIBLE c5 mediumint YES NULL INVISIBLE diff --git a/mysql-test/r/invisible_columns_myisam.result b/mysql-test/r/invisible_columns_myisam.result index 6d857d85a386..e9bd548f362f 100644 --- a/mysql-test/r/invisible_columns_myisam.result +++ b/mysql-test/r/invisible_columns_myisam.result @@ -218,7 +218,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `c0` int DEFAULT NULL, `c1` bit(7) DEFAULT NULL /*!80023 INVISIBLE */, - `c2` tinyint(1) DEFAULT NULL /*!80023 INVISIBLE */, + `c2` boolean DEFAULT NULL /*!80023 INVISIBLE */, `c3` tinyint DEFAULT NULL /*!80023 INVISIBLE */, `c4` smallint DEFAULT NULL /*!80023 INVISIBLE */, `c5` mediumint DEFAULT NULL /*!80023 INVISIBLE */, @@ -257,7 +257,7 @@ SHOW COLUMNS FROM t1; Field Type Null Key Default Extra c0 int YES NULL c1 bit(7) YES NULL INVISIBLE -c2 tinyint(1) YES NULL INVISIBLE +c2 boolean YES NULL INVISIBLE c3 tinyint YES NULL INVISIBLE c4 smallint YES NULL INVISIBLE c5 mediumint YES NULL INVISIBLE diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index e830bd8d0925..44abc17493d9 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -68,7 +68,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index dde42f9eced5..192d7dd298d4 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -68,7 +68,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 3d67466933ca..914fd7df6c81 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -69,7 +69,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index d73f2d53c55d..60950a08825a 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -112,7 +112,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 @@ -3294,7 +3294,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 diff --git a/mysql-test/r/ps_w_max_indexes_64.result b/mysql-test/r/ps_w_max_indexes_64.result index a93ea4621080..d99ef4495970 100644 --- a/mysql-test/r/ps_w_max_indexes_64.result +++ b/mysql-test/r/ps_w_max_indexes_64.result @@ -399,7 +399,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 diff --git a/mysql-test/r/ps_w_max_indexes_64_myisam.result b/mysql-test/r/ps_w_max_indexes_64_myisam.result index 7c2c8a41a694..cf2b9253339a 100644 --- a/mysql-test/r/ps_w_max_indexes_64_myisam.result +++ b/mysql-test/r/ps_w_max_indexes_64_myisam.result @@ -264,7 +264,7 @@ def test t9 t9 c15 c15 7 19 19 N 9345 0 63 def test t9 t9 c16 c16 11 10 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 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 c19 c19 244 1 1 Y 0 0 63 def test t9 t9 c20 c20 254 4 1 Y 0 0 255 def test t9 t9 c21 c21 254 40 10 Y 0 0 255 def test t9 t9 c22 c22 253 120 30 Y 0 0 255 diff --git a/mysql-test/r/show_check_cs_myisam.result b/mysql-test/r/show_check_cs_myisam.result index 3b7302d7ca06..3682a3cc2a7b 100644 --- a/mysql-test/r/show_check_cs_myisam.result +++ b/mysql-test/r/show_check_cs_myisam.result @@ -90,7 +90,7 @@ Warning 1681 Integer display width is deprecated and will be removed in a future show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `type_bool` tinyint(1) NOT NULL DEFAULT '0', + `type_bool` boolean NOT NULL DEFAULT '0', `type_tiny` tinyint NOT NULL AUTO_INCREMENT, `type_short` smallint DEFAULT NULL, `type_mediumint` mediumint DEFAULT NULL, From 2c7d421ec5b9196afe08a1cdeba9bacebe11a6d8 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 20:32:56 +0200 Subject: [PATCH 32/60] main.archive test now tests boolean --- mysql-test/r/archive.result | 11 +++++++++++ mysql-test/t/archive.test | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 307514615f24..ebfff6325382 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12683,6 +12683,17 @@ t6 CREATE TABLE `t6` ( KEY `a` (`a`) ) ENGINE=ARCHIVE AUTO_INCREMENT=36 DEFAULT CHARSET=latin1 DROP TABLE t1, t2, t4, t5, t6; +CREATE TABLE `t7` (b BOOLEAN, t TINYINT(1)) ENGINE=ARCHIVE; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t7 VALUES(TRUE, 5); +INSERT INTO t7 VALUES(FALSE, 1); +SHOW CREATE TABLE t7; +Table Create Table +t7 CREATE TABLE `t7` ( + `b` boolean DEFAULT NULL, + `t` tinyint(1) DEFAULT NULL +) ENGINE=ARCHIVE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci create table t1 (i int) engine=archive; insert into t1 values (1); repair table t1 use_frm; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 0fec294d5bed..0240ee34b4ae 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1534,6 +1534,16 @@ SHOW CREATE TABLE t6; DROP TABLE t1, t2, t4, t5, t6; --enable_warnings +# +#BOOLEAN data type test +# + +CREATE TABLE `t7` (b BOOLEAN, t TINYINT(1)) ENGINE=ARCHIVE; +INSERT INTO t7 VALUES(TRUE, 5); +INSERT INTO t7 VALUES(FALSE, 1); + +SHOW CREATE TABLE t7; + # # BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in ARCHIVE # table From c4ba3e0f30cc7e3990d9957b4f1825adaa6d346e Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 20:46:10 +0200 Subject: [PATCH 33/60] fixup! main.archive test now tests boolean --- mysql-test/r/archive.result | 1 + mysql-test/t/archive.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index ebfff6325382..556bfa3f354c 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12694,6 +12694,7 @@ t7 CREATE TABLE `t7` ( `b` boolean DEFAULT NULL, `t` tinyint(1) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t7; create table t1 (i int) engine=archive; insert into t1 values (1); repair table t1 use_frm; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 0240ee34b4ae..dce6fb5a2e13 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1543,6 +1543,7 @@ INSERT INTO t7 VALUES(TRUE, 5); INSERT INTO t7 VALUES(FALSE, 1); SHOW CREATE TABLE t7; +DROP TABLE t7; # # BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in ARCHIVE From dce446b1bfb8e76c623401951aafda6a920e52e9 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sat, 1 May 2021 21:06:43 +0200 Subject: [PATCH 34/60] Change type of fields in bool.test from int to new type boolean Remove redundant code from type_boolean.test Add input tests for type_boolean.test --- mysql-test/r/bool.result | 4 ++-- mysql-test/r/type_boolean.result | 14 -------------- mysql-test/t/bool.test | 4 ++-- mysql-test/t/type_boolean.test | 24 ++++++++++++------------ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/mysql-test/r/bool.result b/mysql-test/r/bool.result index 004cc5417a24..b78fc58ffe19 100644 --- a/mysql-test/r/bool.result +++ b/mysql-test/r/bool.result @@ -5,7 +5,7 @@ IF(NULL AND 1, 1, 2) IF(1 AND NULL, 1, 2) SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0; NULL AND 1 1 AND NULL 0 AND NULL NULL and 0 NULL NULL 0 0 -create table t1 (a int); +create table t1 (a BOOLEAN); insert into t1 values (0),(1),(NULL); SELECT * FROM t1 WHERE IF(a AND 1, 0, 1); a @@ -69,7 +69,7 @@ a Warnings: Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. DROP TABLE t1; -create table t1 (a int, b int); +create table t1 (a BOOLEAN, b BOOLEAN); insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB diff --git a/mysql-test/r/type_boolean.result b/mysql-test/r/type_boolean.result index e1cc047578e5..411b238e353d 100644 --- a/mysql-test/r/type_boolean.result +++ b/mysql-test/r/type_boolean.result @@ -46,17 +46,3 @@ NULL 1 1 DROP TABLE t1; -CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); -insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); -select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; -A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB -N N N N N N N N N N -0 N 1 N 0 1 1 N N N -1 N 0 N N N N 1 0 0 -N 0 N 1 0 1 1 N N N -N 1 N 0 N N N 1 0 0 -0 0 1 1 0 1 1 0 1 1 -0 1 1 0 0 1 1 1 0 0 -1 0 0 1 0 1 1 1 0 0 -1 1 0 0 1 0 0 1 0 0 -DROP TABLE t1; diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test index 34c51c648d38..3abf6b63fdf2 100644 --- a/mysql-test/t/bool.test +++ b/mysql-test/t/bool.test @@ -9,7 +9,7 @@ DROP TABLE IF EXISTS t1; SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2); SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0; -create table t1 (a int); +create table t1 (a BOOLEAN); insert into t1 values (0),(1),(NULL); SELECT * FROM t1 WHERE IF(a AND 1, 0, 1); SELECT * FROM t1 WHERE IF(1 AND a, 0, 1); @@ -44,7 +44,7 @@ DROP TABLE t1; # Read nA as !A, AB as A && B, AoB as A || B # Result table makes ANSI happy -create table t1 (a int, b int); +create table t1 (a BOOLEAN, b BOOLEAN); insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); # Below test is valid untill we have True/False implemented as 1/0 diff --git a/mysql-test/t/type_boolean.test b/mysql-test/t/type_boolean.test index 6de4c956ccc7..ff4e466b9cd4 100644 --- a/mysql-test/t/type_boolean.test +++ b/mysql-test/t/type_boolean.test @@ -1,10 +1,19 @@ # # Test BOOLEAN data type +# + # # FALSE, TRUE, and UNKNOWN will be substitutes for 0, 1, and NULL +# UNKNOWN is not implemented as NULL yet. Run below SELECT if implemented # SELECT FALSE, TRUE, UNKNOWN; +# + SELECT FALSE, TRUE; +# +# Check if boolean columns get created correctly with BOOL or BOOLEAN +# + CREATE TABLE t1 (b1 BOOLEAN, b2 BOOL); SHOW CREATE TABLE t1; @@ -13,24 +22,15 @@ DROP TABLE t1; CREATE TABLE t1 (b BOOLEAN); INSERT INTO t1 VALUES (FALSE), (TRUE), (NULL); +# Check values get fetched correctly SELECT * FROM t1; SELECT * FROM t1 WHERE b; SELECT * FROM t1 WHERE NOT b; SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b IS NOT NULL; -UPDATE t1 SET b = b + 1 WHERE NOT b; - -INSERT INTO t1 VALUES (0.2); -SELECT * FROM t1; - -INSERT INTO t1 VALUES (2); +# Insert values that should all be TRUE/1 +INSERT INTO t1 VALUES (0.2), (3), (-1), (-1.5), ("0.1"); SELECT * FROM t1; DROP TABLE t1; - -CREATE TABLE t1 (a BOOLEAN, b BOOLEAN); -insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); -select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; - -DROP TABLE t1; \ No newline at end of file From 73f26c50cf57f5899dce71588e506684eab9e3e7 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 21:32:36 +0200 Subject: [PATCH 35/60] main.blackhole test tests BOOLEAN datatype --- mysql-test/r/blackhole.result | 12 ++++++++++++ mysql-test/t/blackhole.test | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/mysql-test/r/blackhole.result b/mysql-test/r/blackhole.result index 16a979272620..47a98635b820 100644 --- a/mysql-test/r/blackhole.result +++ b/mysql-test/r/blackhole.result @@ -17,3 +17,15 @@ SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0; 0 DROP TABLE t1; End of 5.6 tests +# +# Test for BOOLEAN data type +# +CREATE TABLE t1(b BOOLEAN, t TINYINT(1)) ENGINE = BLACKHOLE; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (5, 5), (TRUE, 1); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +b boolean YES NULL +t tinyint(1) YES NULL +DROP TABLE t1; diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test index 32d7d70200af..470b7aafd831 100644 --- a/mysql-test/t/blackhole.test +++ b/mysql-test/t/blackhole.test @@ -28,3 +28,12 @@ SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0; DROP TABLE t1; --echo End of 5.6 tests + +--echo # +--echo # Test for BOOLEAN data type +--echo # + +CREATE TABLE t1(b BOOLEAN, t TINYINT(1)) ENGINE = BLACKHOLE; +INSERT INTO t1 VALUES (5, 5), (TRUE, 1); +SHOW COLUMNS FROM t1; +DROP TABLE t1; \ No newline at end of file From 5976a85729aee56ba1dffba2e1fb5ebecd6e91b9 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 22:19:27 +0200 Subject: [PATCH 36/60] fixup! main.archive test now tests boolean --- mysql-test/r/archive.result | 16 +++++++++------- mysql-test/t/archive.test | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 556bfa3f354c..afeca0abaa3d 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12687,13 +12687,15 @@ CREATE TABLE `t7` (b BOOLEAN, t TINYINT(1)) ENGINE=ARCHIVE; Warnings: Warning 1681 Integer display width is deprecated and will be removed in a future release. INSERT INTO t7 VALUES(TRUE, 5); -INSERT INTO t7 VALUES(FALSE, 1); -SHOW CREATE TABLE t7; -Table Create Table -t7 CREATE TABLE `t7` ( - `b` boolean DEFAULT NULL, - `t` tinyint(1) DEFAULT NULL -) ENGINE=ARCHIVE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t7 VALUES(0.001, 1); +SELECT * FROM t7; +b t +1 5 +1 1 +SHOW COLUMNS FROM t7; +Field Type Null Key Default Extra +b boolean YES NULL +t tinyint(1) YES NULL DROP TABLE t7; create table t1 (i int) engine=archive; insert into t1 values (1); diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index dce6fb5a2e13..36b9c85ac7ff 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1540,9 +1540,9 @@ DROP TABLE t1, t2, t4, t5, t6; CREATE TABLE `t7` (b BOOLEAN, t TINYINT(1)) ENGINE=ARCHIVE; INSERT INTO t7 VALUES(TRUE, 5); -INSERT INTO t7 VALUES(FALSE, 1); - -SHOW CREATE TABLE t7; +INSERT INTO t7 VALUES(0.001, 1); +SELECT * FROM t7; +SHOW COLUMNS FROM t7; DROP TABLE t7; # From f8293d27f2f24bd6cca09b710efaed0da5c3bd41 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sat, 1 May 2021 22:24:55 +0200 Subject: [PATCH 37/60] Fix storing string values in boolean column rounding instead of converting to bool correctly --- sql/field.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 095703cf5fe2..3e23726ca20d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3180,12 +3180,19 @@ bool Field_new_decimal::send_to_protocol(Protocol *protocol) const { type_conversion_status Field_boolean::store(const char *from, size_t len, const CHARSET_INFO *cs) { ASSERT_COLUMN_MARKED_FOR_WRITE; - longlong rnd; - - const type_conversion_status error = - get_int(cs, from, len, &rnd, 1, 0, 1); - ptr[0] = (bool)rnd; - return error; + int conv_error; + type_conversion_status err = TYPE_OK; + const char *end; + double nr = my_strntod(cs, from, len, &end, &conv_error); + if (conv_error || (!len || (static_cast(end - from) != len && + table->in_use->check_for_truncated_fields))) { + set_warning(Sql_condition::SL_WARNING, + (conv_error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), + 1); + err = conv_error ? TYPE_WARN_OUT_OF_RANGE : TYPE_WARN_TRUNCATED; + } + store(nr); + return err; } type_conversion_status Field_boolean::store(double nr) { @@ -3221,9 +3228,6 @@ longlong Field_boolean::val_int() const { return static_cast(tmp); } -// #TODO ask about string rep. 0 or 1, or FALSE or TRUE? -//Test both ways -//Use static_cast or eliminiate casting String *Field_boolean::val_str(String *val_buffer, String *) const { ASSERT_COLUMN_MARKED_FOR_READ; const CHARSET_INFO *cs = &my_charset_numeric; @@ -3251,7 +3255,6 @@ int Field_boolean::cmp(const uchar *a_ptr, const uchar *b_ptr) const { return (a < b) ? -1 : (a > b) ? 1 : 0; } -//DEBUG_ASSERT is now assert size_t Field_boolean::make_sort_key(uchar *to, size_t length MY_ATTRIBUTE((unused))) const { assert(length == 1); From 9466df4aa4c0a420b021825bb0154ca3895a0754 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 23:04:01 +0200 Subject: [PATCH 38/60] main.csv now tests insert of BOOLEAN data type --- mysql-test/r/csv.result | 16 ++++++++++++++++ mysql-test/t/csv.test | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 52a0fd4917f5..c66bce0aecb5 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5487,3 +5487,19 @@ SELECT * FROM t1; ERROR HY000: Table 't1' is marked as crashed and should be repaired DROP TABLE t1; End of 5.1 tests +# +# Test for BOOLEAN data type +# +CREATE TABLE t1(b BOOLEAN NOT NULL, t TINYINT(1) NOT NULL) ENGINE = CSV; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (5, 5), (TRUE, 1); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +b boolean NO NULL +t tinyint(1) NO NULL +SELECT * FROM t1; +b t +1 5 +1 1 +DROP TABLE t1; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index aafc31e0a335..280918b29819 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1881,3 +1881,13 @@ SELECT * FROM t1; DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # Test for BOOLEAN data type +--echo # + +CREATE TABLE t1(b BOOLEAN NOT NULL, t TINYINT(1) NOT NULL) ENGINE = CSV; +INSERT INTO t1 VALUES (5, 5), (TRUE, 1); +SHOW COLUMNS FROM t1; +SELECT * FROM t1; +DROP TABLE t1; From 33ebe8302b0ab946bb78f6f4b5940b8790cb8e8f Mon Sep 17 00:00:00 2001 From: Lisa Date: Sat, 1 May 2021 23:16:36 +0200 Subject: [PATCH 39/60] main.myisam tests insert of BOOLEAN data type --- mysql-test/r/myisam.result | 11 +++++++++++ mysql-test/t/myisam.test | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 1af8dc19ae2d..401ae085b2d9 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2817,3 +2817,14 @@ count(*) 0 DROP TABLE t1; SET sql_mode = default; +CREATE TABLE t1(b BOOLEAN, i INTEGER) ENGINE = MyISAM; +INSERT INTO t1 VALUES (0.001, 0.001), (TRUE, 1); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +b boolean YES NULL +i int YES NULL +SELECT * FROM t1; +b i +1 0 +1 1 +DROP TABLE t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 4e3848c18ef7..68be190072ae 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1854,3 +1854,13 @@ DELETE FROM t1 WHERE col1= '5cm' AND col1_dummy= '5cm'; SELECT count(*) FROM t1 WHERE col1= '5cm'; DROP TABLE t1; SET sql_mode = default; + +# +#BOOLEAN data type insert test +# + +CREATE TABLE t1(b BOOLEAN, i INTEGER) ENGINE = MyISAM; +INSERT INTO t1 VALUES (0.001, 0.001), (TRUE, 1); +SHOW COLUMNS FROM t1; +SELECT * FROM t1; +DROP TABLE t1; From b3c7552cd6fea46bdf80ee10863f110cb87b9043 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 00:18:52 +0200 Subject: [PATCH 40/60] main.heap tests insert of BOOLEAN data type --- mysql-test/r/heap.result | 11 +++++++++++ mysql-test/t/heap.test | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index c23bf64e4c6a..76fa13689643 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -847,3 +847,14 @@ c1 bar2 #should show one tuple! DROP TABLE t1; +CREATE TABLE t1(b BOOLEAN, i INTEGER) ENGINE=heap; +INSERT INTO t1 VALUES (0.001, 0.001), (FALSE, 1); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +b boolean YES NULL +i int YES NULL +SELECT * FROM t1; +b i +1 0 +0 1 +DROP TABLE t1; diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index ce1a649714a5..79a18fa5d2b6 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -545,3 +545,17 @@ SELECT * FROM t1 WHERE c1='bar2'; SELECT * FROM t1 IGNORE INDEX (i1) WHERE c1='bar2'; --echo #should show one tuple! DROP TABLE t1; + + +# +#BOOLEAN data type insert test +# + +CREATE TABLE t1(b BOOLEAN, i INTEGER) ENGINE=heap; +INSERT INTO t1 VALUES (0.001, 0.001), (FALSE, 1); + +SHOW COLUMNS FROM t1; + +SELECT * FROM t1; + +DROP TABLE t1; From 2d220733895154991d95e155f9108164db4b6fce Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 01:08:17 +0200 Subject: [PATCH 41/60] main.view now tests BOOLEAN data type --- mysql-test/r/view.result | 18 ++++++++++++++++++ mysql-test/t/view.test | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 5c30c84a0a88..7c3634c22e8a 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -6709,3 +6709,21 @@ SHOW FIELDS FROM v; Field Type Null Key Default Extra c varchar(1) YES NULL DROP VIEW v; +CREATE TABLE t1(b BOOLEAN, i INTEGER); +CREATE TABLE t2(b2 BOOLEAN); +INSERT INTO t1 VALUES (0.001, 0.001), (FALSE, 1); +INSERT INTO t2 VALUES (TRUE), (0.0); +CREATE VIEW v AS SELECT * FROM t1 JOIN t2 ON t1.b = t2.b2; +SHOW FIELDS FROM v; +Field Type Null Key Default Extra +b boolean YES NULL +i int YES NULL +b2 boolean YES NULL +INSERT INTO v (b, i) VALUES (100, 100); +SELECT * FROM v; +b i b2 +1 0 1 +0 1 0 +1 100 1 +DROP TABLE t1, t2; +DROP View v; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 6a78b21f085d..cc939c7fdbcd 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -6220,3 +6220,19 @@ CREATE VIEW v AS SELECT null AS 'c' UNION SELECT 'a' AS 'c'; --echo # varchar(1). With fix type is listed correctly. SHOW FIELDS FROM v; DROP VIEW v; + + +# +#BOOLEAN data type column in view +# + +CREATE TABLE t1(b BOOLEAN, i INTEGER); +CREATE TABLE t2(b2 BOOLEAN); +INSERT INTO t1 VALUES (0.001, 0.001), (FALSE, 1); +INSERT INTO t2 VALUES (TRUE), (0.0); +CREATE VIEW v AS SELECT * FROM t1 JOIN t2 ON t1.b = t2.b2; +SHOW FIELDS FROM v; +INSERT INTO v (b, i) VALUES (100, 100); +SELECT * FROM v; +DROP TABLE t1, t2; +DROP View v; From 9ed72f8af4ad6f175f79b0926546fe0c1737808a Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 13:35:56 +0200 Subject: [PATCH 42/60] some record in main suite --- mysql-test/r/create.result | 20 ++++++++++---------- mysql-test/r/metadata.result | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index f368eab97b16..38fdb71371ac 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -2959,33 +2959,33 @@ Warning 1681 Integer display width is deprecated and will be removed in a future SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` tinyint(1) DEFAULT NULL, + `a` boolean DEFAULT NULL, `b` tinyint(1) DEFAULT NULL, `c` tinyint unsigned DEFAULT NULL, `d` tinyint(1) unsigned zerofill DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT GENERATION_EXPRESSION SRS_ID -def test t1 a 1 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references NULL +def test t1 a 1 NULL YES boolean NULL NULL NULL NULL NULL NULL NULL boolean select,insert,update,references NULL def test t1 b 2 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references NULL def test t1 c 3 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint unsigned select,insert,update,references NULL def test t1 d 4 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) unsigned zerofill select,insert,update,references NULL DESCRIBE t1; Field Type Null Key Default Extra -a tinyint(1) YES NULL +a boolean YES NULL b tinyint(1) YES NULL c tinyint unsigned YES NULL d tinyint(1) unsigned zerofill YES NULL CREATE VIEW v1 AS SELECT * FROM t1; SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; COLUMN_TYPE +boolean tinyint unsigned tinyint(1) -tinyint(1) tinyint(1) unsigned zerofill DESCRIBE v1; Field Type Null Key Default Extra -a tinyint(1) YES NULL +a boolean YES NULL b tinyint(1) YES NULL c tinyint unsigned YES NULL d tinyint(1) unsigned zerofill YES NULL @@ -3001,17 +3001,17 @@ Warning 1681 Integer display width is deprecated and will be removed in a future SHOW CREATE FUNCTION f1; Function sql_mode Create Function character_set_client collation_connection Database Collation f1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, -d TINYINT(1) ZEROFILL) RETURNS tinyint(1) +d TINYINT(1) ZEROFILL) RETURNS boolean RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; DTD_IDENTIFIER -tinyint(1) +boolean SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; DTD_IDENTIFIER +boolean +boolean tinyint unsigned tinyint(1) -tinyint(1) -tinyint(1) tinyint(1) unsigned zerofill DROP FUNCTION f1; CREATE PROCEDURE p1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, @@ -3028,8 +3028,8 @@ d TINYINT(1) ZEROFILL) BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; DTD_IDENTIFIER +boolean tinyint unsigned tinyint(1) -tinyint(1) tinyint(1) unsigned zerofill DROP PROCEDURE p1; diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 1933bbb1d2f7..b725031591c4 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -235,8 +235,8 @@ Warning 1681 UNSIGNED for decimal and floating point data types is deprecated an Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. select * from t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def test t1 t1 bool_col bool_col 1 1 0 Y 32768 0 63 -def test t1 t1 boolean_col boolean_col 1 1 0 Y 32768 0 63 +def test t1 t1 bool_col bool_col 244 1 0 Y 0 0 63 +def test t1 t1 boolean_col boolean_col 244 1 0 Y 0 0 63 def test t1 t1 bit_col bit_col 16 5 0 Y 32 0 63 def test t1 t1 tiny tiny 1 4 0 Y 32768 0 63 def test t1 t1 tiny_uns tiny_uns 1 3 0 Y 32800 0 63 From f9c6498d7f6a70d944a30eaf7e7e9f935c0e9d40 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 14:13:34 +0200 Subject: [PATCH 43/60] alter table tests BOOLEAN data type --- mysql-test/r/alter_table.result | 17 +++++++++++++++++ mysql-test/t/alter_table.test | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 7123d37b9df2..a2dc82b305d4 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -88,6 +88,23 @@ GROUP_ID int unsigned NULL NO PRI 0 # LANG_ID smallint unsigned NULL NO PRI 0 # NAME char(80) utf8mb4_0900_ai_ci NO MUL NULL # DROP TABLE t1; +# +# TESTING CONVERSION OF BOOLEAN DATATYPE +# +CREATE TABLE t1 (int_to_boolean INT, bool_to_decimal BOOLEAN, double_to_boolean DOUBLE(10,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES(20, TRUE, 0.4444); +SELECT * FROM t1; +int_to_boolean bool_to_decimal double_to_boolean +20 1 0.4444 +ALTER TABLE t1 MODIFY int_to_boolean BOOLEAN; +ALTER TABLE t1 MODIFY bool_to_decimal DECIMAL(5,2); +ALTER TABLE t1 MODIFY double_to_boolean BOOLEAN; +SELECT * FROM t1; +int_to_boolean bool_to_decimal double_to_boolean +1 1.00 1 +DROP TABLE t1; create table t1 (n int); insert into t1 values(9),(3),(12),(10); alter table t1 order by n; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index c5cc4bf11a6c..3bf06482d2f9 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -56,6 +56,19 @@ ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null; SHOW FULL COLUMNS FROM t1; DROP TABLE t1; +--echo # +--echo # TESTING CONVERSION OF BOOLEAN DATATYPE +--echo # + +CREATE TABLE t1 (int_to_boolean INT, bool_to_decimal BOOLEAN, double_to_boolean DOUBLE(10,4)); +INSERT INTO t1 VALUES(20, TRUE, 0.4444); +SELECT * FROM t1; +ALTER TABLE t1 MODIFY int_to_boolean BOOLEAN; +ALTER TABLE t1 MODIFY bool_to_decimal DECIMAL(5,2); +ALTER TABLE t1 MODIFY double_to_boolean BOOLEAN; +SELECT * FROM t1; +DROP TABLE t1; + # # Test of ALTER TABLE ... ORDER BY # From 0f3c0baf9bcd900d592b7fed5c782b002bb55f42 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 15:16:02 +0200 Subject: [PATCH 44/60] record on wanted BOOLEAN behaviour --- .../r/binlog_gtid_mysqlbinlog_row.result | 4 +- .../binlog_gtid_mysqlbinlog_row_innodb.result | 32 ++++++++-------- .../binlog_gtid_mysqlbinlog_row_myisam.result | 32 ++++++++-------- .../r/binlog_mysqlbinlog_row.result | 4 +- .../r/binlog_mysqlbinlog_row_innodb.result | 32 ++++++++-------- .../r/binlog_mysqlbinlog_row_myisam.result | 32 ++++++++-------- .../suite/gcol/r/gcol_keys_innodb.result | 8 +--- .../r/gcol_supported_sql_funcs_innodb.result | 38 +++++++++---------- .../r/gcol_supported_sql_funcs_myisam.result | 38 +++++++++---------- 9 files changed, 108 insertions(+), 112 deletions(-) diff --git a/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row.result b/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row.result index 7010306d0998..18b98a1e5e8c 100644 --- a/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row.result +++ b/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row.result @@ -1158,7 +1158,7 @@ BEGIN # # server id # end_log_pos # CRC32 # Write_rows: table id # flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET -### @1=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @1=1 /* BOOL meta=0 nullable=1 is_null=0 */ # at # # # server id # end_log_pos # CRC32 # Xid = # COMMIT/*!*/; @@ -1182,7 +1182,7 @@ BEGIN # # server id # end_log_pos # CRC32 # Delete_rows: table id # flags: STMT_END_F ### DELETE FROM `test`.`t1` ### WHERE -### @1=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @1=1 /* BOOL meta=0 nullable=1 is_null=0 */ # at # # # server id # end_log_pos # CRC32 # Xid = # COMMIT/*!*/; diff --git a/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_innodb.result index dac7d1729dce..8cd51820944a 100644 --- a/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_innodb.result +++ b/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_innodb.result @@ -2472,7 +2472,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2574,7 +2574,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2676,7 +2676,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -2757,7 +2757,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2859,7 +2859,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2939,7 +2939,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3041,7 +3041,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3121,7 +3121,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3223,7 +3223,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3303,7 +3303,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3405,7 +3405,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3485,7 +3485,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3587,7 +3587,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3689,7 +3689,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3791,7 +3791,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3893,7 +3893,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ diff --git a/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_myisam.result index 11c625c5898f..95e2a879f6ec 100644 --- a/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_myisam.result +++ b/mysql-test/suite/binlog_gtid/r/binlog_gtid_mysqlbinlog_row_myisam.result @@ -2472,7 +2472,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2576,7 +2576,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2680,7 +2680,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -2761,7 +2761,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2865,7 +2865,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2945,7 +2945,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3049,7 +3049,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3129,7 +3129,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3233,7 +3233,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3313,7 +3313,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3417,7 +3417,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3497,7 +3497,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3601,7 +3601,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3705,7 +3705,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3809,7 +3809,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3913,7 +3913,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ diff --git a/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row.result index 20cd53fad707..09d0569c1375 100644 --- a/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row.result +++ b/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row.result @@ -1158,7 +1158,7 @@ BEGIN # # server id # end_log_pos # CRC32 # Write_rows: table id # flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET -### @1=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @1=1 /* BOOL meta=0 nullable=1 is_null=0 */ # at # # # server id # end_log_pos # CRC32 # Xid = # COMMIT/*!*/; @@ -1182,7 +1182,7 @@ BEGIN # # server id # end_log_pos # CRC32 # Delete_rows: table id # flags: STMT_END_F ### DELETE FROM `test`.`t1` ### WHERE -### @1=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @1=1 /* BOOL meta=0 nullable=1 is_null=0 */ # at # # # server id # end_log_pos # CRC32 # Xid = # COMMIT/*!*/; diff --git a/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_innodb.result index bc10bb99e2e0..f3ddabfb65b8 100644 --- a/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_innodb.result +++ b/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_innodb.result @@ -2472,7 +2472,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2574,7 +2574,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2676,7 +2676,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -2757,7 +2757,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2859,7 +2859,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2939,7 +2939,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3041,7 +3041,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3121,7 +3121,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3223,7 +3223,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3303,7 +3303,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3405,7 +3405,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3485,7 +3485,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3587,7 +3587,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3689,7 +3689,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3791,7 +3791,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3893,7 +3893,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ diff --git a/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_myisam.result index 13f906820beb..bcbf43850606 100644 --- a/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_myisam.result +++ b/mysql-test/suite/binlog_nogtid/r/binlog_mysqlbinlog_row_myisam.result @@ -2472,7 +2472,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2576,7 +2576,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2680,7 +2680,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -2761,7 +2761,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2865,7 +2865,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -2945,7 +2945,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3049,7 +3049,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3129,7 +3129,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3233,7 +3233,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3313,7 +3313,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3417,7 +3417,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3497,7 +3497,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ @@ -3601,7 +3601,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=-1 (255) /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=-1 (65535) /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3705,7 +3705,7 @@ BEGIN ### @3=-128 (128) /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=0 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=0 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=0 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=-32768 (32768) /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3809,7 +3809,7 @@ BEGIN ### @3=127 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @4=0 /* TINYINT meta=0 nullable=1 is_null=0 */ ### @5=1 /* TINYINT meta=0 nullable=1 is_null=0 */ -### @6=1 /* TINYINT meta=0 nullable=1 is_null=0 */ +### @6=1 /* BOOL meta=0 nullable=1 is_null=0 */ ### @7=32767 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @8=0 /* SHORTINT meta=0 nullable=1 is_null=0 */ ### @9=1 /* SHORTINT meta=0 nullable=1 is_null=0 */ @@ -3913,7 +3913,7 @@ BEGIN ### @3=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @4=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ ### @5=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ -### @6=NULL /* TINYINT meta=0 nullable=1 is_null=1 */ +### @6=NULL /* BOOL meta=0 nullable=1 is_null=1 */ ### @7=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @8=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ ### @9=NULL /* SHORTINT meta=0 nullable=1 is_null=1 */ diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result b/mysql-test/suite/gcol/r/gcol_keys_innodb.result index d137500f52e0..e71e04ecd956 100644 --- a/mysql-test/suite/gcol/r/gcol_keys_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result @@ -1272,17 +1272,13 @@ CREATE TABLE t (a INT, b BOOLEAN GENERATED ALWAYS AS (a+10000) VIRTUAL, c BLOB GENERATED ALWAYS AS (b=2) VIRTUAL); INSERT INTO t(a) VALUES (1); -Warnings: -Warning 1264 Out of range value for column 'b' at row 1 SELECT * FROM t WHERE c = '0'; a b c -1 127 0 +1 1 0 ALTER TABLE t ADD UNIQUE INDEX (c(1)); -Warnings: -Warning 1264 Out of range value for column 'b' at row 1 SELECT * FROM t WHERE c = '0'; a b c -1 127 0 +1 1 0 DROP TABLE t; # # Bug#21688115 VIRTUAL COLUMN COMPUTATION SAVE_IN_FIELD() diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result index 0b704ac435a0..d954223c418f 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result @@ -967,7 +967,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` like _latin1'H%o')) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` like _latin1'H%o')) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('MySQL',default); @@ -1082,7 +1082,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((not((`a` like _latin1'H%o')))) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((not((`a` like _latin1'H%o')))) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('MySQL',default); @@ -1099,7 +1099,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((not(regexp_like(`a`,_latin1'H.+o')))) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((not(regexp_like(`a`,_latin1'H.+o')))) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('hello',default); @@ -1176,7 +1176,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL + `b` boolean GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('hello',default); @@ -1253,7 +1253,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL + `b` boolean GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('MySQL',default); @@ -1316,7 +1316,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((soundex(`a`) = soundex(`b`))) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((soundex(`a`) = soundex(`b`))) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('Hello','Hello',default); insert into t1 values ('Hello','MySQL',default); @@ -1570,7 +1570,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS (((`a` > 0) and (`a` < 2))) VIRTUAL + `b` boolean GENERATED ALWAYS AS (((`a` > 0) and (`a` < 2))) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (-1,default); insert into t1 values (1,default); @@ -1587,7 +1587,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` between 0 and 2)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` between 0 and 2)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (-1,default); insert into t1 values (1,default); @@ -1708,7 +1708,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, `b` int DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <=> `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <=> `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (1,1,default); insert into t1 values (NULL,NULL,default); @@ -1728,7 +1728,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` = `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` = `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('a','b',default); insert into t1 values ('a','a',default); @@ -1746,7 +1746,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` >= `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` >= `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('a','b',default); insert into t1 values ('a','a',default); @@ -1764,7 +1764,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` > `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` > `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('a','b',default); insert into t1 values ('a','a',default); @@ -1781,7 +1781,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` is not null)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` is not null)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (1,default); insert into t1 values (NULL,default); @@ -1798,7 +1798,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` is null)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` is null)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (1,default); insert into t1 values (NULL,default); @@ -1833,7 +1833,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <= `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <= `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); @@ -1853,7 +1853,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` < `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` < `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); @@ -1872,7 +1872,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` not between 0 and 2)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` not between 0 and 2)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (-1,default); insert into t1 values (1,default); @@ -1890,7 +1890,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); @@ -1910,7 +1910,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result index 6f9d9ca5b34b..73186bbc6989 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result @@ -967,7 +967,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` like _latin1'H%o')) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` like _latin1'H%o')) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('MySQL',default); @@ -1082,7 +1082,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((not((`a` like _latin1'H%o')))) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((not((`a` like _latin1'H%o')))) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('MySQL',default); @@ -1099,7 +1099,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((not(regexp_like(`a`,_latin1'H.+o')))) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((not(regexp_like(`a`,_latin1'H.+o')))) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('hello',default); @@ -1176,7 +1176,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL + `b` boolean GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('hello',default); @@ -1253,7 +1253,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL + `b` boolean GENERATED ALWAYS AS (regexp_like(`a`,_latin1'H.+o')) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('Hello',default); insert into t1 values ('MySQL',default); @@ -1316,7 +1316,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((soundex(`a`) = soundex(`b`))) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((soundex(`a`) = soundex(`b`))) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('Hello','Hello',default); insert into t1 values ('Hello','MySQL',default); @@ -1570,7 +1570,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS (((`a` > 0) and (`a` < 2))) VIRTUAL + `b` boolean GENERATED ALWAYS AS (((`a` > 0) and (`a` < 2))) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values (-1,default); insert into t1 values (1,default); @@ -1587,7 +1587,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` between 0 and 2)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` between 0 and 2)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values (-1,default); insert into t1 values (1,default); @@ -1708,7 +1708,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, `b` int DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <=> `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <=> `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values (1,1,default); insert into t1 values (NULL,NULL,default); @@ -1728,7 +1728,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` = `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` = `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('a','b',default); insert into t1 values ('a','a',default); @@ -1746,7 +1746,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` >= `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` >= `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('a','b',default); insert into t1 values ('a','a',default); @@ -1764,7 +1764,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` > `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` > `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('a','b',default); insert into t1 values ('a','a',default); @@ -1781,7 +1781,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` is not null)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` is not null)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values (1,default); insert into t1 values (NULL,default); @@ -1798,7 +1798,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` is null)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` is null)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values (1,default); insert into t1 values (NULL,default); @@ -1833,7 +1833,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <= `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <= `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); @@ -1853,7 +1853,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` < `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` < `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); @@ -1872,7 +1872,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int DEFAULT NULL, - `b` tinyint(1) GENERATED ALWAYS AS ((`a` not between 0 and 2)) VIRTUAL + `b` boolean GENERATED ALWAYS AS ((`a` not between 0 and 2)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values (-1,default); insert into t1 values (1,default); @@ -1890,7 +1890,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); @@ -1910,7 +1910,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL, - `c` tinyint(1) GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL + `c` boolean GENERATED ALWAYS AS ((`a` <> `b`)) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 values ('b','a',default); insert into t1 values ('b','b',default); From f31120fec7fe5fa2b6adae05556c5ad2eec801ee Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sun, 2 May 2021 16:03:31 +0200 Subject: [PATCH 45/60] Update result file for type_boolean.test --- mysql-test/r/type_boolean.result | 9 ++------- sql/field.cc | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/type_boolean.result b/mysql-test/r/type_boolean.result index 411b238e353d..1c09a75ca3b6 100644 --- a/mysql-test/r/type_boolean.result +++ b/mysql-test/r/type_boolean.result @@ -29,20 +29,15 @@ SELECT * FROM t1 WHERE b IS NOT NULL; b 0 1 -UPDATE t1 SET b = b + 1 WHERE NOT b; -INSERT INTO t1 VALUES (0.2); +INSERT INTO t1 VALUES (0.2), (3), (-1), (-1.5), ("0.1"); SELECT * FROM t1; b -1 +0 1 NULL 1 -INSERT INTO t1 VALUES (2); -SELECT * FROM t1; -b 1 1 -NULL 1 1 DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index 3e23726ca20d..bffa0401f7c5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3186,6 +3186,7 @@ type_conversion_status Field_boolean::store(const char *from, size_t len, double nr = my_strntod(cs, from, len, &end, &conv_error); if (conv_error || (!len || (static_cast(end - from) != len && table->in_use->check_for_truncated_fields))) { + // May need some other warnings, these are the same as Field_float::store set_warning(Sql_condition::SL_WARNING, (conv_error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); From 9f94357b1293609a80c79b7b8134449cb9fff1f7 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sun, 2 May 2021 16:16:34 +0200 Subject: [PATCH 46/60] Add cast test from boolean column type Cast not implemented as CAST(column AS BOOLEAN) --- mysql-test/r/cast.result | 8 ++++++++ mysql-test/t/cast.test | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 12e3ff5d83e3..ee8101d52e50 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -34,6 +34,14 @@ cast(NULL as signed) cast(1/0 as signed) NULL NULL Warnings: Warning 1365 Division by 0 +CREATE TABLE t (b BOOLEAN); +INSERT INTO t VALUES (FALSE), (TRUE), (NULL); +SELECT b, CAST(b AS UNSIGNED) AS u, CAST(b AS SIGNED) AS s, CAST(b AS CHAR) AS c, CAST(b AS DECIMAL) AS d from t; +b u s c d +0 0 0 0 0 +1 1 1 1 1 +NULL NULL NULL NULL NULL +DROP TABLE t; select cast(NULL as unsigned), cast(1/0 as unsigned); cast(NULL as unsigned) cast(1/0 as unsigned) NULL NULL diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 01e7ce1e4103..0de11ae3e75f 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -15,6 +15,13 @@ select ~5, cast(~5 as signed); explain select ~5, cast(~5 as signed); select cast(5 as unsigned) -6.0; select cast(NULL as signed), cast(1/0 as signed); + +# Cast from boolean column +CREATE TABLE t (b BOOLEAN); +INSERT INTO t VALUES (FALSE), (TRUE), (NULL); +SELECT b, CAST(b AS UNSIGNED) AS u, CAST(b AS SIGNED) AS s, CAST(b AS CHAR) AS c, CAST(b AS DECIMAL) AS d from t; +DROP TABLE t; + # # Bug #28250: Run-Time Check Failure #3 - The variable 'value' is being used # without being def From d42fe77ab8a3679e30c885fe04f78994ad0493d2 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 16:38:01 +0200 Subject: [PATCH 47/60] rpl_nogtid.rpl_alter_repository fixed with record --- .../rpl_nogtid/r/rpl_alter_repository.result | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/rpl_nogtid/r/rpl_alter_repository.result b/mysql-test/suite/rpl_nogtid/r/rpl_alter_repository.result index b36dcab47295..992dfdfd8393 100644 --- a/mysql-test/suite/rpl_nogtid/r/rpl_alter_repository.result +++ b/mysql-test/suite/rpl_nogtid/r/rpl_alter_repository.result @@ -18,7 +18,7 @@ slave_relay_log_info CREATE TABLE `slave_relay_log_info` ( `Channel_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication', `Privilege_checks_username` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'Username part of PRIVILEGE_CHECKS_USER.', `Privilege_checks_hostname` char(255) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL COMMENT 'Hostname part of PRIVILEGE_CHECKS_USER.', - `Require_row_format` tinyint(1) NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', + `Require_row_format` boolean NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', `Require_table_primary_key_check` enum('STREAM','ON','OFF') NOT NULL DEFAULT 'STREAM' COMMENT 'Indicates what is the channel policy regarding tables having primary keys on create and alter table queries', `Assign_gtids_to_anonymous_transactions_type` enum('OFF','LOCAL','UUID') NOT NULL DEFAULT 'OFF' COMMENT 'Indicates whether the channel will generate a new GTID for anonymous transactions. OFF means that anonymous transactions will remain anonymous. LOCAL means that anonymous transactions will be assigned a newly generated GTID based on server_uuid. UUID indicates that anonymous transactions will be assigned a newly generated GTID based on Assign_gtids_to_anonymous_transactions_value', `Assign_gtids_to_anonymous_transactions_value` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Indicates the UUID used while generating GTIDs for anonymous transactions', @@ -39,7 +39,7 @@ slave_relay_log_info CREATE TABLE `slave_relay_log_info` ( `Channel_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication', `Privilege_checks_username` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'Username part of PRIVILEGE_CHECKS_USER.', `Privilege_checks_hostname` char(255) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL COMMENT 'Hostname part of PRIVILEGE_CHECKS_USER.', - `Require_row_format` tinyint(1) NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', + `Require_row_format` boolean NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', `Require_table_primary_key_check` enum('STREAM','ON','OFF') NOT NULL DEFAULT 'STREAM' COMMENT 'Indicates what is the channel policy regarding tables having primary keys on create and alter table queries', `Assign_gtids_to_anonymous_transactions_type` enum('OFF','LOCAL','UUID') NOT NULL DEFAULT 'OFF' COMMENT 'Indicates whether the channel will generate a new GTID for anonymous transactions. OFF means that anonymous transactions will remain anonymous. LOCAL means that anonymous transactions will be assigned a newly generated GTID based on server_uuid. UUID indicates that anonymous transactions will be assigned a newly generated GTID based on Assign_gtids_to_anonymous_transactions_value', `Assign_gtids_to_anonymous_transactions_value` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Indicates the UUID used while generating GTIDs for anonymous transactions', @@ -169,13 +169,13 @@ slave_master_info CREATE TABLE `slave_master_info` ( `User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.', `Port` int unsigned NOT NULL COMMENT 'The network port used to connect to the master.', `Connect_retry` int unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.', - `Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', + `Enabled_ssl` boolean NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', `Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.', `Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.', `Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.', `Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.', `Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.', - `Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.', + `Ssl_verify_server_cert` boolean NOT NULL COMMENT 'Whether to verify the server certificate.', `Heartbeat` float NOT NULL, `Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server', `Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs', @@ -183,16 +183,16 @@ slave_master_info CREATE TABLE `slave_master_info` ( `Retry_count` bigint unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.', `Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)', `Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files', - `Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', + `Enabled_auto_position` boolean NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', `Channel_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication', `Tls_version` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Tls version', `Public_key_path` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file containing public key of master server.', - `Get_public_key` tinyint(1) NOT NULL COMMENT 'Preference to get public key from master.', + `Get_public_key` boolean NOT NULL COMMENT 'Preference to get public key from master.', `Network_namespace` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Network namespace used for communication with the master server.', `Master_compression_algorithm` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Compression algorithm supported for data transfer between master and slave.', `Master_zstd_compression_level` int unsigned NOT NULL COMMENT 'Compression level associated with zstd compression algorithm.', `Tls_ciphersuites` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Ciphersuites used for TLS 1.3 communication with the master server.', - `Source_connection_auto_failover` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indicates whether the channel connection failover is enabled.', + `Source_connection_auto_failover` boolean NOT NULL DEFAULT '0' COMMENT 'Indicates whether the channel connection failover is enabled.', PRIMARY KEY (`Channel_name`) ) /*!50100 TABLESPACE `mysql` */ ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 ROW_FORMAT=DYNAMIC COMMENT='Master Information' SHOW CREATE TABLE mysql.slave_relay_log_info; @@ -209,7 +209,7 @@ slave_relay_log_info CREATE TABLE `slave_relay_log_info` ( `Channel_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication', `Privilege_checks_username` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'Username part of PRIVILEGE_CHECKS_USER.', `Privilege_checks_hostname` char(255) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL COMMENT 'Hostname part of PRIVILEGE_CHECKS_USER.', - `Require_row_format` tinyint(1) NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', + `Require_row_format` boolean NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', `Require_table_primary_key_check` enum('STREAM','ON','OFF') NOT NULL DEFAULT 'STREAM' COMMENT 'Indicates what is the channel policy regarding tables having primary keys on create and alter table queries', `Assign_gtids_to_anonymous_transactions_type` enum('OFF','LOCAL','UUID') NOT NULL DEFAULT 'OFF' COMMENT 'Indicates whether the channel will generate a new GTID for anonymous transactions. OFF means that anonymous transactions will remain anonymous. LOCAL means that anonymous transactions will be assigned a newly generated GTID based on server_uuid. UUID indicates that anonymous transactions will be assigned a newly generated GTID based on Assign_gtids_to_anonymous_transactions_value', `Assign_gtids_to_anonymous_transactions_value` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Indicates the UUID used while generating GTIDs for anonymous transactions', From 274da0746dea460cfa5a510fa7f837ab92f43de3 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 17:23:34 +0200 Subject: [PATCH 48/60] main.update tests BOOLEAN data type --- mysql-test/r/update.result | 12 ++++++++++++ mysql-test/t/update.test | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 1be3d845c129..a81735609578 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -950,3 +950,15 @@ CREATE TABLE g(c INTEGER, b INTEGER); CREATE TABLE t(a INTEGER); UPDATE t SET a=1 WHERE EXISTS(SELECT b FROM g WHERE 1 NOT LIKE c FOR UPDATE); DROP TABLE g, t; +# Test BOOLEAN data type +CREATE TABLE t(b BOOLEAN); +INSERT INTO t VALUES (TRUE), (0.01), (0), (FALSE); +UPDATE t SET b=b+1000 WHERE b=TRUE; +UPDATE t SET b=b-1000 WHERE b=FALSE; +SELECT * FROM t; +b +1 +1 +1 +1 +DROP TABLE t; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 045169fbd727..20cef5e4660c 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -742,3 +742,13 @@ CREATE TABLE g(c INTEGER, b INTEGER); CREATE TABLE t(a INTEGER); UPDATE t SET a=1 WHERE EXISTS(SELECT b FROM g WHERE 1 NOT LIKE c FOR UPDATE); DROP TABLE g, t; + + +--echo # Test BOOLEAN data type + +CREATE TABLE t(b BOOLEAN); +INSERT INTO t VALUES (TRUE), (0.01), (0), (FALSE); +UPDATE t SET b=b+1000 WHERE b=TRUE; +UPDATE t SET b=b-1000 WHERE b=FALSE; +SELECT * FROM t; +DROP TABLE t; \ No newline at end of file From 631d56ab96659b330099d2fb464b885c607baba8 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sun, 2 May 2021 18:17:58 +0200 Subject: [PATCH 49/60] Add insertion tests for BOOLEAN data type --- mysql-test/r/insert.result | 47 ++++++++++++++++++++++++++++++++++++++ mysql-test/t/insert.test | 26 +++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 3308105b7a06..d47b03860cc8 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -1073,3 +1073,50 @@ ERROR 23000: Duplicate entry '8' for key 't1.PRIMARY' DEALLOCATE PREPARE stmt; DROP VIEW v1; DROP TABLE t1, t2; +# +# WL#3554 Boolean data type +# +CREATE TABLE t (val VARCHAR(64), b BOOLEAN); +INSERT INTO t VALUES ('FALSE', FALSE), ('TRUE', TRUE), ('NULL', NULL); +INSERT INTO t VALUES ('0', 0), ('1', 1), ('123', 123), ('-123', -123), ("18446744073709551615", 18446744073709551615); +INSERT INTO t VALUES ('0.0', 0.0), ('-0.0', -0.0), ('0.0e0', 0.0e0), ('0.0e123', 0.0e123), ("CAST(0 AS DECIMAL(2,2))", CAST(0 AS DECIMAL(2,2))); +INSERT INTO t VALUES ('1.0', 1.0), ('0.1', 0.1), ('1.1e20', 1.1e20), ('0.1e-20', 0.1e-20), ('CAST(0.1 AS DECIMAL(2,2))', CAST(0.1 AS DECIMAL(2,2))), ('0.0000000000000000000000000000000000000000001', 0.0000000000000000000000000000000000000000001); +INSERT INTO t VALUES ("0", "0"), ("0.0", "0.0"), ("0e0", "0e0"), ("0.0e0", "0.0e0"), ("-0", "-0"); +INSERT INTO t VALUES ("1", "1"), ("0.1", "0.1"), ("-1", "-1"), ("-0.1", "-0.1"), ("3.1e5", "3.1e5"), ("3.1", "3.1"); +INSERT INTO t VALUES ("f", "f"); +ERROR 01000: Data truncated for column 'b' at row 1 +INSERT INTO t VALUES ("", ""); +ERROR 01000: Data truncated for column 'b' at row 1 +SELECT * FROM t; +val b +FALSE 0 +TRUE 1 +NULL NULL +0 0 +1 1 +123 1 +-123 1 +18446744073709551615 1 +0.0 0 +-0.0 0 +0.0e0 0 +0.0e123 0 +CAST(0 AS DECIMAL(2,2)) 0 +1.0 1 +0.1 1 +1.1e20 1 +0.1e-20 1 +CAST(0.1 AS DECIMAL(2,2)) 1 +0.0000000000000000000000000000000000000000001 1 +0 0 +0.0 0 +0e0 0 +0.0e0 0 +-0 0 +1 1 +0.1 1 +-1 1 +-0.1 1 +3.1e5 1 +3.1 1 +DROP TABLE t; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 9718412e22ce..857ffc57769e 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -986,3 +986,29 @@ DEALLOCATE PREPARE stmt; DROP VIEW v1; DROP TABLE t1, t2; +--echo # +--echo # WL#3554 Boolean data type +--echo # +# Also covered in main.bool and main.type_boolean +CREATE TABLE t (val VARCHAR(64), b BOOLEAN); +# Insert regular boolean values +INSERT INTO t VALUES ('FALSE', FALSE), ('TRUE', TRUE), ('NULL', NULL); +# Insert integers as FALSE, TRUE, TRUE, TRUE +INSERT INTO t VALUES ('0', 0), ('1', 1), ('123', 123), ('-123', -123), ("18446744073709551615", 18446744073709551615); +# Insert floating point values for FALSE +INSERT INTO t VALUES ('0.0', 0.0), ('-0.0', -0.0), ('0.0e0', 0.0e0), ('0.0e123', 0.0e123), ("CAST(0 AS DECIMAL(2,2))", CAST(0 AS DECIMAL(2,2))); +# Insert floating point values for TRUE +INSERT INTO t VALUES ('1.0', 1.0), ('0.1', 0.1), ('1.1e20', 1.1e20), ('0.1e-20', 0.1e-20), ('CAST(0.1 AS DECIMAL(2,2))', CAST(0.1 AS DECIMAL(2,2))), ('0.0000000000000000000000000000000000000000001', 0.0000000000000000000000000000000000000000001); +# Insert string values for FALSE +INSERT INTO t VALUES ("0", "0"), ("0.0", "0.0"), ("0e0", "0e0"), ("0.0e0", "0.0e0"), ("-0", "-0"); +# Insert string values for TRUE +INSERT INTO t VALUES ("1", "1"), ("0.1", "0.1"), ("-1", "-1"), ("-0.1", "-0.1"), ("3.1e5", "3.1e5"), ("3.1", "3.1"); + +# Error on insert invalid string values +--error 1265 +INSERT INTO t VALUES ("f", "f"); +--error 1265 +INSERT INTO t VALUES ("", ""); + +SELECT * FROM t; +DROP TABLE t; \ No newline at end of file From f093fbd60a77c32064108ec311c4c86e08d2f613 Mon Sep 17 00:00:00 2001 From: Lisa Date: Sun, 2 May 2021 18:33:05 +0200 Subject: [PATCH 50/60] testing arithmetics with BOOLEAN data type --- mysql-test/r/func_math.result | 89 +++++++++++++++++++++++++++++++++++ mysql-test/t/func_math.test | 32 +++++++++++++ 2 files changed, 121 insertions(+) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 57b9ceb79e67..a8c322c58f0f 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -2035,3 +2035,92 @@ iu bu 0 0 DROP TABLE t1; SET sql_mode = DEFAULT; +# +# WL#3554 Boolean data type +# +CREATE TABLE t1 (b BOOLEAN); +CREATE TABLE t2 (b2 BOOLEAN); +INSERT INTO t1 VALUES (TRUE), (FALSE); +INSERT INTO t2 VALUES (TRUE), (FALSE); +# boolean and number +SELECT b+10 FROM t1; +b+10 +11 +10 +SELECT b-10 FROM t1; +b-10 +-9 +-10 +SELECT -b-10 FROM t1; +-b-10 +-11 +-10 +SELECT b*10 FROM t1; +b*10 +10 +0 +SELECT b/10 FROM t1; +b/10 +0.1000 +0.0000 +SELECT b DIV 10 FROM t1; +b DIV 10 +0 +0 +SELECT b % 10 FROM t1; +b % 10 +1 +0 +# boolean and another boolean +SELECT b+b2 FROM t1, t2; +b+b2 +1 +2 +0 +1 +SELECT b-b2 FROM t1, t2; +b-b2 +-1 +0 +0 +1 +SELECT -b-b2 FROM t1, t2; +-b-b2 +-1 +-2 +0 +-1 +SELECT b*b2 FROM t1, t2; +b*b2 +0 +1 +0 +0 +SELECT b/b2 FROM t1, t2; +b/b2 +0.0000 +1.0000 +NULL +NULL +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +SELECT b DIV b2 FROM t1, t2; +b DIV b2 +0 +1 +NULL +NULL +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +SELECT b % b2 FROM t1, t2; +b % b2 +0 +0 +NULL +NULL +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +DROP TABLE t1, t2; diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 994d20a050f1..5f3a2cd67db4 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -1212,3 +1212,35 @@ SELECT iu,bu FROM t1; DROP TABLE t1; SET sql_mode = DEFAULT; + + + +--echo # +--echo # WL#3554 Boolean data type +--echo # + +CREATE TABLE t1 (b BOOLEAN); +CREATE TABLE t2 (b2 BOOLEAN); + +INSERT INTO t1 VALUES (TRUE), (FALSE); +INSERT INTO t2 VALUES (TRUE), (FALSE); + +--echo # boolean and number +SELECT b+10 FROM t1; +SELECT b-10 FROM t1; +SELECT -b-10 FROM t1; +SELECT b*10 FROM t1; +SELECT b/10 FROM t1; +SELECT b DIV 10 FROM t1; +SELECT b % 10 FROM t1; + +--echo # boolean and another boolean +SELECT b+b2 FROM t1, t2; +SELECT b-b2 FROM t1, t2; +SELECT -b-b2 FROM t1, t2; +SELECT b*b2 FROM t1, t2; +SELECT b/b2 FROM t1, t2; +SELECT b DIV b2 FROM t1, t2; +SELECT b % b2 FROM t1, t2; + +DROP TABLE t1, t2; \ No newline at end of file From a5da67eb604b8e5dca13b3e1c7ed9374476fdd19 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sun, 2 May 2021 20:18:19 +0200 Subject: [PATCH 51/60] Add tests for union with boolean columns --- mysql-test/r/union.result | 47 +++++++++++++++++++++++++++++++++++++-- mysql-test/t/union.test | 25 +++++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 59ab680aa032..3570e907175b 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -713,8 +713,29 @@ t1 CREATE TABLE `t1` ( `a` decimal(3,1) NOT NULL DEFAULT '0.0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci drop table t1; -create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); -insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); +create table t2 (it1 tinyint, bo boolean not null, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); +insert into t2 values (NULL, TRUE, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); +create table t1 SELECT bo from t2 UNION select it1 from t2; +select * from t1; +bo +1 +NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `bo` tinyint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 SELECT bo from t2 UNION select it2 from t2; +select * from t1; +bo +1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `bo` tinyint NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; create table t1 SELECT it2 from t2 UNION select it1 from t2; select * from t1; it2 @@ -3425,3 +3446,25 @@ h int YES NULL i bigint YES NULL j decimal(20,0) YES NULL DROP TABLE t1, t2; +# +# WL#3554 Boolean data type +# +CREATE TABLE t1 (b BOOLEAN); +CREATE TABLE t2 (b BOOLEAN); +INSERT INTO t1 VALUES (FALSE), (TRUE), (NULL); +INSERT INTO t2 VALUES (FALSE), (TRUE), (NULL); +CREATE TABLE t3 SELECT b FROM t1 UNION ALL SELECT b FROM t2; +SELECT * FROM t3; +b +0 +1 +NULL +0 +1 +NULL +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `b` boolean DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 90de4e2583ec..38ebb44a15d2 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -373,9 +373,17 @@ select * from t1; show create table t1; drop table t1; -create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); -insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); +create table t2 (it1 tinyint, bo boolean not null, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); +insert into t2 values (NULL, TRUE, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest'); +create table t1 SELECT bo from t2 UNION select it1 from t2; +select * from t1; +show create table t1; +drop table t1; +create table t1 SELECT bo from t2 UNION select it2 from t2; +select * from t1; +show create table t1; +drop table t1; create table t1 SELECT it2 from t2 UNION select it1 from t2; select * from t1; show create table t1; @@ -2304,3 +2312,16 @@ DESCRIBE t2; DROP TABLE t1, t2; +--echo # +--echo # WL#3554 Boolean data type +--echo # +# Check boolean union boolean creates boolean column +CREATE TABLE t1 (b BOOLEAN); +CREATE TABLE t2 (b BOOLEAN); +# Populate the tables with anything +INSERT INTO t1 VALUES (FALSE), (TRUE), (NULL); +INSERT INTO t2 VALUES (FALSE), (TRUE), (NULL); +CREATE TABLE t3 SELECT b FROM t1 UNION ALL SELECT b FROM t2; +SELECT * FROM t3; +SHOW CREATE TABLE t3; +DROP TABLE t1, t2, t3; \ No newline at end of file From aa27855283924f73b0b8c1997f9fe67d20cfd165 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Sun, 2 May 2021 23:49:03 +0200 Subject: [PATCH 52/60] Change DEBUG_ASSERT to assert --- sql/field.cc | 1 + sql/field.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/field.cc b/sql/field.cc index bffa0401f7c5..9b831bade631 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3204,6 +3204,7 @@ type_conversion_status Field_boolean::store(double nr) { type_conversion_status Field_boolean::store(longlong nr, bool) { ASSERT_COLUMN_MARKED_FOR_WRITE; type_conversion_status error = TYPE_OK; + // Maybe change to *ptr = nr != 0 if(nr != 0) { *ptr = 1; } else { diff --git a/sql/field.h b/sql/field.h index 8436ff150456..01e331d8401f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2165,7 +2165,7 @@ class Field_boolean : public Field_num { void sql_type(String &str) const override; uint32 max_display_length() const final { return 1; } Field_boolean *clone(MEM_ROOT *mem_root) const override { - DBUG_ASSERT(type() == MYSQL_TYPE_BOOL); + assert(type() == MYSQL_TYPE_BOOL); return new (mem_root) Field_boolean(*this); } uchar *pack(uchar *to, const uchar *from, size_t max_length) const final { From f9f4318a449fae14a825ce934a5a20b32472e881 Mon Sep 17 00:00:00 2001 From: Lisa Date: Tue, 4 May 2021 13:03:48 +0200 Subject: [PATCH 53/60] record on main.mysqldump tinyint->boolean --- mysql-test/r/mysqldump.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 7aa147d74557..e3be8473dd83 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -5304,13 +5304,13 @@ CREATE TABLE IF NOT EXISTS `slave_master_info` ( `User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.', `Port` int unsigned NOT NULL COMMENT 'The network port used to connect to the master.', `Connect_retry` int unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.', - `Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', + `Enabled_ssl` boolean NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', `Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.', `Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.', `Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.', `Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.', `Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.', - `Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.', + `Ssl_verify_server_cert` boolean NOT NULL COMMENT 'Whether to verify the server certificate.', `Heartbeat` float NOT NULL, `Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server', `Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs', @@ -5318,16 +5318,16 @@ CREATE TABLE IF NOT EXISTS `slave_master_info` ( `Retry_count` bigint unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.', `Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)', `Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files', - `Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', + `Enabled_auto_position` boolean NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', `Channel_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication', `Tls_version` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Tls version', `Public_key_path` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file containing public key of master server.', - `Get_public_key` tinyint(1) NOT NULL COMMENT 'Preference to get public key from master.', + `Get_public_key` boolean NOT NULL COMMENT 'Preference to get public key from master.', `Network_namespace` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Network namespace used for communication with the master server.', `Master_compression_algorithm` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Compression algorithm supported for data transfer between master and slave.', `Master_zstd_compression_level` int unsigned NOT NULL COMMENT 'Compression level associated with zstd compression algorithm.', `Tls_ciphersuites` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Ciphersuites used for TLS 1.3 communication with the master server.', - `Source_connection_auto_failover` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indicates whether the channel connection failover is enabled.', + `Source_connection_auto_failover` boolean NOT NULL DEFAULT '0' COMMENT 'Indicates whether the channel connection failover is enabled.', PRIMARY KEY (`Channel_name`) ) /*!50100 TABLESPACE `mysql` */ ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 ROW_FORMAT=DYNAMIC COMMENT='Master Information'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -5345,7 +5345,7 @@ CREATE TABLE IF NOT EXISTS `slave_relay_log_info` ( `Channel_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication', `Privilege_checks_username` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'Username part of PRIVILEGE_CHECKS_USER.', `Privilege_checks_hostname` char(255) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL COMMENT 'Hostname part of PRIVILEGE_CHECKS_USER.', - `Require_row_format` tinyint(1) NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', + `Require_row_format` boolean NOT NULL COMMENT 'Indicates whether the channel shall only accept row based events.', `Require_table_primary_key_check` enum('STREAM','ON','OFF') NOT NULL DEFAULT 'STREAM' COMMENT 'Indicates what is the channel policy regarding tables having primary keys on create and alter table queries', `Assign_gtids_to_anonymous_transactions_type` enum('OFF','LOCAL','UUID') NOT NULL DEFAULT 'OFF' COMMENT 'Indicates whether the channel will generate a new GTID for anonymous transactions. OFF means that anonymous transactions will remain anonymous. LOCAL means that anonymous transactions will be assigned a newly generated GTID based on server_uuid. UUID indicates that anonymous transactions will be assigned a newly generated GTID based on Assign_gtids_to_anonymous_transactions_value', `Assign_gtids_to_anonymous_transactions_value` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Indicates the UUID used while generating GTIDs for anonymous transactions', From 167ed1f7fd1032aacc05fb80519f2eafaeb3671b Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 4 May 2021 20:20:55 +0200 Subject: [PATCH 54/60] Fix broken code after variable name change Update result file for main.cast test --- mysql-test/r/cast.result | 256 ++++++++++++++++++++++++++++++++++++++- sql/item.cc | 2 +- 2 files changed, 255 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index ee8101d52e50..00017140edf2 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -1755,6 +1755,7 @@ CAST("2020extra" AS YEAR) 2020 Warnings: Warning 1292 Truncated incorrect YEAR value: '2020extra' +SET timestamp = UNIX_TIMESTAMP('2020-12-22 03:30:00'); SELECT CAST(TIMESTAMP'2010-01-01 00:00' AS YEAR); CAST(TIMESTAMP'2010-01-01 00:00' AS YEAR) 2010 @@ -1768,10 +1769,11 @@ CAST(TIMESTAMP'2010-01-01 08:09:10' AS YEAR) 2010 SELECT CAST(TIME'08:09:10' AS YEAR); CAST(TIME'08:09:10' AS YEAR) -2021 +2020 SELECT CAST(TIME'00:00:00' AS YEAR); CAST(TIME'00:00:00' AS YEAR) -2021 +2020 +SET timestamp = DEFAULT; SELECT CAST(ST_PointFromText('POINT(10 10)') AS YEAR); ERROR HY000: Incorrect arguments to cast_as_year CREATE TABLE t AS SELECT CAST("2010" AS YEAR); @@ -1933,3 +1935,253 @@ CAST(STR_TO_DATE('nope','%d-%m-%Y') AS YEAR) NULL Warnings: Warning 1411 Incorrect datetime value: 'nope' for function str_to_date +# WL#14109: Implement a consistent comparison type rule matrix +SET @zero_date = '0000-00-00'; +SET @zero_day = '2000-01-00'; +SET @zero_month = '2000-00-01'; +SET @zero_year = '0000-01-01'; +SET @invalid_date = '2000-02-31'; +SET @bad_date = 'YYYY-MM-DD'; +SET @zero_datetime = '0000-00-00 00:00:00.000000'; +SET @zero_day_dt = '2000-01-00 00:00:00.000000'; +SET @zero_month_dt = '2000-00-01 00:00:00.000000'; +SET @zero_year_dt = '0000-01-01 00:00:00.000000'; +SET @invalid_datetime = '2000-02-31 00:00:00.000000'; +SET @bad_datetime = 'YYYY-MM-DD HH:MM:SS.ffffff'; +SET SQL_MODE=DEFAULT; +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-01-00 2000-01-00 2000-01-00 00:00:00.000000 2000-01-00 00:00:00.000000 +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-00-01 2000-00-01 2000-00-01 00:00:00.000000 2000-00-01 00:00:00.000000 +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-00-00 0000-00-00 0000-00-00 00:00:00.000000 0000-00-00 00:00:00.000000 +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE='ALLOW_INVALID_DATES'; +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-00-00 0000-00-00 0000-00-00 00:00:00.000000 0000-00-00 00:00:00.000000 +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-01-00 2000-01-00 2000-01-00 00:00:00.000000 2000-01-00 00:00:00.000000 +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-00-01 2000-00-01 2000-00-01 00:00:00.000000 2000-00-01 00:00:00.000000 +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-02-31 2000-02-31 2000-02-31 00:00:00.000000 2000-02-31 00:00:00.000000 +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE=DEFAULT; +# +# Bug#32371039: ITEM->MAX_LENGTH FIELD IS NOT ACCURATE FOR +# FROM_BASE64 FUNCTION +# +CREATE TABLE t AS +SELECT CONCAT(CAST(-1 AS UNSIGNED)) AS col1, +1.0 + CAST(-1 AS UNSIGNED) AS col2, +CONCAT(CAST(9223372036854775808 AS SIGNED)) AS col3; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `col1` varchar(21) CHARACTER SET latin1 DEFAULT NULL, + `col2` decimal(23,1) NOT NULL DEFAULT '0.0', + `col3` varchar(21) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t; +col1 col2 col3 +18446744073709551615 18446744073709551616.0 -9223372036854775808 +DROP TABLE t; diff --git a/sql/item.cc b/sql/item.cc index 06273156c2f7..91007fabd178 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5934,7 +5934,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, break; case MYSQL_TYPE_BOOL: field = new (*THR_MALLOC) - Field_boolean(maybe_null, item_name.ptr()); + Field_boolean(m_nullable, item_name.ptr()); break; case MYSQL_TYPE_SHORT: field = new (*THR_MALLOC) From 115d988a3f72aa4cd732a560ba350042d763bc1d Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Tue, 4 May 2021 20:28:35 +0200 Subject: [PATCH 55/60] Tests updated with boolean tests merged with 8.0.24 --- mysql-test/r/update.result | 2 +- mysql-test/r/view.result | 9 ++++++--- mysql-test/t/view.test | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 3951e2c8445a..f4b2e3b9ac97 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -982,7 +982,7 @@ i c1 c2 2 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 DROP TABlE t1; # -# Test BOOLEAN data type +# WL#3554 Test BOOLEAN data type # CREATE TABLE t(b BOOLEAN); INSERT INTO t VALUES (TRUE), (0.01), (0), (FALSE); diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 624386de8b4e..fab74b50c09c 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -6739,6 +6739,9 @@ call sys.create_synonym_db("INFORMATION_SCHEMA", "I_S"); summary Created XX views in the `I_S` database DROP DATABASE I_S; +# +# WL#3554: BOOLEAN data type column in view +# CREATE TABLE t1(b BOOLEAN, i INTEGER); CREATE TABLE t2(b2 BOOLEAN); INSERT INTO t1 VALUES (0.001, 0.001), (FALSE, 1); @@ -6746,9 +6749,9 @@ INSERT INTO t2 VALUES (TRUE), (0.0); CREATE VIEW v AS SELECT * FROM t1 JOIN t2 ON t1.b = t2.b2; SHOW FIELDS FROM v; Field Type Null Key Default Extra -b boolean YES NULL -i int YES NULL -b2 boolean YES NULL +b boolean YES NULL +i int YES NULL +b2 boolean YES NULL INSERT INTO v (b, i) VALUES (100, 100); SELECT * FROM v; b i b2 diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 416e22a870b7..ef6306a14645 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -6258,7 +6258,7 @@ DROP DATABASE I_S; --echo # ---echo #BOOLEAN data type column in view +--echo # WL#3554: BOOLEAN data type column in view --echo # CREATE TABLE t1(b BOOLEAN, i INTEGER); CREATE TABLE t2(b2 BOOLEAN); From 7caada51023c092b2b628c551231ec5d2b5e4df6 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Fri, 14 May 2021 14:35:24 +0200 Subject: [PATCH 56/60] Add user manual --- USER_MANUAL.md | 102 +++++++++++++++++++++++++++++++++++++++++++++ db.cnf | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 USER_MANUAL.md create mode 100644 db.cnf diff --git a/USER_MANUAL.md b/USER_MANUAL.md new file mode 100644 index 000000000000..e21946d742bc --- /dev/null +++ b/USER_MANUAL.md @@ -0,0 +1,102 @@ +# USER MANUAL - BOOLEAN data type in MySQL +## System requirements +This installation guide is made with Linux systems in mind. The system used by the developers is Ubuntu 20.0. More or other steps might be needed for Windows or MacOS systems. + +The build system used is cmake and make. +## Installation +Clone the repo with SSH or HTTPS +``` +#SSH +git clone git@github.com:mbremyk/mysql-server.git +#HTTPS +git clone https://github.com/mbremyk/mysql-server.git +``` +Switch to branch boolean +``` +cd mysql-server +git checkout boolean +``` +Create and enter build directory +``` +mkdir build +cd build +``` +Build the project +``` +cmake .. +make +``` +### Testing +You should now be able to run tests. To run tests move to the mysql-test-directory +``` +cd mysql-test +``` +and run the mysql test suite +``` +./mysql-test-run +./mysql-test-run +./mysql-test-run --suite= +``` +New test in this project is `type_boolean.test`. You can also run the main suite with `--suite=main` +### Configuration +If you want to run MySQL with the regular CLI, you need to set up a config file and prepare a data directory. Navigate to where you want your database and create a directory. +``` +mkdir mysql +cd mysql +``` +Create a data directory +``` +mkdir db +``` +#### Config file +Edit the [config file](db.cnf) to include the full path to the previously created data directory and relevant files. Any variables needed to be changed should be in angle brackets (<>) with an example after. Move the config file in the previously created mysql-directory. +``` +mv db.cnf +``` +### Initialization +Return to the build directory +``` +cd +``` +and run +``` +./runtime_output_directory/mysqld --defaults-file= --initialize-insecure +``` +## Running the database +Run the database with +``` +./runtime_output_directory/mysqld --defaults-file= +``` +Open another terminal and run +``` +./runtime_output_directory/mysql --defaults-file= -uroot +``` +## Run queries against the database +Create and use a database with +```SQL +CREATE DATABASE test; +USE test; +``` +Create a BOOLEAN table with +```SQL +CREATE TABLE t (b BOOLEAN); +``` +Show that the created table has a BOOLEAN column with +```SQL +SHOW CREATE TABLE t; +``` +Insert values into the table with +```SQL +INSERT INTO t VALUES (TRUE), (FALSE), (NULL); +``` +## Shut down the database +Run +``` +shutdown; +``` +to shut down the database.\ +Run +``` +quit; +``` +to close the MySQL CLI. \ No newline at end of file diff --git a/db.cnf b/db.cnf new file mode 100644 index 000000000000..6cc48764b577 --- /dev/null +++ b/db.cnf @@ -0,0 +1,111 @@ +# MySQL config file. +# +# This is for a large system with memory = 512M where the system runs mainly +# MySQL. +# +# You can copy this file to +# /etc/my.cnf to set global options, +# mysql-data-dir/my.cnf to set server-specific options (in this +# installation this directory is /export/home/mysql/data) or +# ~/.my.cnf to set user-specific options. +# +# In this file, you can use all long options that a program supports. +# If you want to know which options a program supports, run the program +# with the "--help" option. + +# The following options will be passed to all MySQL clients +[client] +#password = your_password +#port = 3306 +socket = /tmp/mysql.bool.sock +#default-character-set = utf8mb4 + +# Here follows entries for some specific programs + +# The MySQL server +[mysqld] +port = 3307 +socket = /tmp/mysql.bool.sock +datadir = # ex. /home/user/mysql/db/ +#default-character-set = utf8mb4 +# default-authentication-plugin = mysql_native_password +default-storage-engine = InnoDB +key_buffer_size = 256M +max_allowed_packet = 4M +table_open_cache = 256 +sort_buffer_size = 1M +read_buffer_size = 1M +read_rnd_buffer_size = 4M +myisam_sort_buffer_size = 64M +thread_cache_size = 8 +#lc-messages-dir=./sql/share/ +secure_file_priv = /tmp +# Try number of CPU's*2 for thread_concurrency +#thread_concurrency = 8 + +general_log=1 +general_log_file=<.log-file in mysql directory> # ex. /home/user/mysql/db/db.log +slow_query_log=on + +# Don't listen on a TCP/IP port at all. This can be a security enhancement, +# if all processes that need to connect to mysqld run on the same host. +# All interaction with mysqld must be made via Unix sockets or named pipes. +# Note that using this option without enabling named pipes on Windows +# (via the "enable-named-pipe" option) will render mysqld useless! +# +#skip-networking + +# Replication Master Server (default) +# binary logging is required for replication +log-bin=mysql-bin +skip-slave-start=true + +# binary logging format - mixed recommended +binlog_format=mixed + +# required unique id between 1 and 2^32 - 1 +# defaults to 1 if master-host is not set +# but will not function as a master if omitted +server-id = 1 + + +# Point the following paths to different dedicated disks +tmpdir = /tmp/mysql-bool/ +#log-update = /path-to-dedicated-directory/hostname + +# Uncomment the following if you are using InnoDB tables +innodb_data_home_dir = # ex. /home/user/mysql/db/ +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = # ex. /home/user/mysql/db/ +innodb_undo_directory = # ex. /home/user/mysql/db/ +innodb_tmpdir = /tmp/mysql-bool/ +# You can set .._buffer_pool_size up to 50 - 80 % +# of RAM but beware of setting memory usage too high +innodb_buffer_pool_size = 128M +innodb_buffer_pool_instances = 1 +# Set .._log_file_size to 25 % of buffer pool size +innodb_log_file_size = 256M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_flush_method = o_direct +innodb_lock_wait_timeout = 50 +innodb_force_recovery = 0 +innodb_fast_shutdown = 0 +[mysqldump] +quick +max_allowed_packet = 16M + +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates +default-character-set = utf8mb4 + +[myisamchk] +key_buffer_size = 128M +sort_buffer_size = 128M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout From efcd731a4a5a70f4f066f53fa9a6199c7991e627 Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Wed, 19 May 2021 15:49:17 +0200 Subject: [PATCH 57/60] Change a c-style cast to static_cast --- sql/parse_tree_column_attrs.h | 1 - sql/protocol_classic.cc | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/parse_tree_column_attrs.h b/sql/parse_tree_column_attrs.h index f0d1731d5676..290d7c374400 100644 --- a/sql/parse_tree_column_attrs.h +++ b/sql/parse_tree_column_attrs.h @@ -620,7 +620,6 @@ class PT_bit_type : public PT_type { const char *get_length() const override { return length; } }; -// Does this need to be PT_numeric_type? /** Node for the BOOL/BOOLEAN type diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index e4cad3a0a3c6..fb180cbaa009 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -3782,7 +3782,7 @@ bool Protocol_binary::store_boolean(longlong from) { assert(field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_BOOL); field_pos++; - buff[0] = (char)from; + buff[0] = static_cast(from); return packet->append(buff, sizeof(buff), PACKET_BUFFER_EXTRA_ALLOC); } From b1c3260f5f512430696f77e221d77a14b576339f Mon Sep 17 00:00:00 2001 From: Magnus Brevik Date: Thu, 20 May 2021 14:15:27 +0200 Subject: [PATCH 58/60] Update in-code documentation --- include/field_types.h | 2 +- include/mysql_com.h | 2 +- libbinlogevents/src/binary_log_funcs.cpp | 1 + mysql-test/t/archive.test | 2 +- mysql-test/t/cast.test | 28 +++++++++++++----------- mysql-test/t/heap.test | 2 +- sql/field.cc | 26 +++++++++++++++++++--- sql/field.h | 2 ++ sql/field_conv.cc | 1 + storage/innobase/handler/ha_innodb.cc | 1 - 10 files changed, 46 insertions(+), 21 deletions(-) diff --git a/include/field_types.h b/include/field_types.h index 08fc7a972b48..ed11aec3ed8d 100644 --- a/include/field_types.h +++ b/include/field_types.h @@ -76,7 +76,7 @@ enum enum_field_types MYSQL_TYPE_TIME2, /**< Internal to MySQL. Not used in protocol */ MYSQL_TYPE_TYPED_ARRAY, /**< Used for replication only */ MYSQL_TYPE_INVALID = 243, - MYSQL_TYPE_BOOL = 244, /**WIP */ + MYSQL_TYPE_BOOL = 244, MYSQL_TYPE_JSON = 245, MYSQL_TYPE_NEWDECIMAL = 246, MYSQL_TYPE_ENUM = 247, diff --git a/include/mysql_com.h b/include/mysql_com.h index 46414ba2116d..297086c6aa3f 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -866,7 +866,7 @@ struct Vio; #define MYSQL_VIO struct Vio * #endif -#define MAX_BOOL_WIDTH 1 /**< Max width for a BOOL */ +#define MAX_BOOL_WIDTH 1 /**< Max width for a BOOLEAN. Change to 5 if BOOLEAN is displayed as TRUE and FALSE*/ #define MAX_TINYINT_WIDTH 3 /**< Max width for a TINY w.o. sign */ #define MAX_SMALLINT_WIDTH 5 /**< Max width for a SHORT w.o. sign */ #define MAX_MEDIUMINT_WIDTH 8 /**< Max width for a INT24 w.o. sign */ diff --git a/libbinlogevents/src/binary_log_funcs.cpp b/libbinlogevents/src/binary_log_funcs.cpp index eab04179b7c6..52b6f1a7e223 100644 --- a/libbinlogevents/src/binary_log_funcs.cpp +++ b/libbinlogevents/src/binary_log_funcs.cpp @@ -123,6 +123,7 @@ unsigned int max_display_length_for_field(enum_field_types sql_type, case MYSQL_TYPE_TINY: return 4; case MYSQL_TYPE_BOOL: + //Change to 5 if BOOLEAN is displayed as TRUE and FALSE return 1; case MYSQL_TYPE_SHORT: return 6; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 36b9c85ac7ff..e35af09e8a68 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1535,7 +1535,7 @@ DROP TABLE t1, t2, t4, t5, t6; --enable_warnings # -#BOOLEAN data type test +# BOOLEAN data type test # CREATE TABLE `t7` (b BOOLEAN, t TINYINT(1)) ENGINE=ARCHIVE; diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 18132cd4cc87..0404e3233065 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -16,7 +16,9 @@ explain select ~5, cast(~5 as signed); select cast(5 as unsigned) -6.0; select cast(NULL as signed), cast(1/0 as signed); +# # Cast from boolean column +# CREATE TABLE t (b BOOLEAN); INSERT INTO t VALUES (FALSE), (TRUE), (NULL); SELECT b, CAST(b AS UNSIGNED) AS u, CAST(b AS SIGNED) AS s, CAST(b AS CHAR) AS c, CAST(b AS DECIMAL) AS d from t; @@ -68,8 +70,8 @@ select cast('' as signed); # set names binary; select cast(_latin1'test' as char character set latin2); -select cast(_koi8r'