Commit 5d6d28f2 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20798 Conversion from INET6 to other types performed without errors or warnings

parent d8e599bb
...@@ -1580,6 +1580,280 @@ a ...@@ -1580,6 +1580,280 @@ a
2001:db8::ff00:42:8329 2001:db8::ff00:42:8329
DROP TABLE t1; DROP TABLE t1;
# #
# SET from INET6 to INET6
#
CREATE TABLE t1 (a INET6, b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# SET from INET6 to numeric
#
CREATE TABLE t1 (a INET6, b INT);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect integer value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DOUBLE);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect double value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DECIMAL(32,0));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect decimal value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b YEAR);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect integer value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from numeric to INET6
#
CREATE TABLE t1 (a INT, b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE, b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL(32,0), b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a YEAR, b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from INET6 to temporal
#
CREATE TABLE t1 (a INET6, b TIME);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect time value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DATE);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect date value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DATETIME);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect datetime value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b TIMESTAMP NULL DEFAULT NULL);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect datetime value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from temporal to INET6
#
CREATE TABLE t1 (a TIME, b INET6);
INSERT INTO t1 VALUES ('00:00:00', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '00:00:00' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DATE, b INET6);
INSERT INTO t1 VALUES ('2001-01:01', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001-01-01' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME, b INET6);
INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a TIMESTAMP, b INET6);
INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from INET6 to character string
#
CREATE TABLE t1 (a INET6, b CHAR(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b VARCHAR(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b TEXT);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b ENUM('ffff::ffff'));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b SET('ffff::ffff'));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# SET from character string to INET6
#
CREATE TABLE t1 (a CHAR(39), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(39), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a ENUM('ffff::ffff'), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a SET('ffff::ffff'), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# SET from INET6 to binary
#
CREATE TABLE t1 (a INET6, b BINARY(16));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
HEX(b)
FFFF000000000000000000000000FFFF
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b VARBINARY(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
HEX(b)
FFFF000000000000000000000000FFFF
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b BLOB);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
HEX(b)
FFFF000000000000000000000000FFFF
DROP TABLE t1;
#
# SET from binary to INET6
#
CREATE TABLE t1 (a BINARY(16), b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a VARBINARY(16), b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a BLOB, b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# Limit clause parameter # Limit clause parameter
# TODO: this should fail. # TODO: this should fail.
# The test for a valid data type should be moved # The test for a valid data type should be moved
...@@ -1631,3 +1905,29 @@ INSERT INTO t1 VALUES ('::'); ...@@ -1631,3 +1905,29 @@ INSERT INTO t1 VALUES ('::');
SELECT CAST(a AS FLOAT) FROM t1; SELECT CAST(a AS FLOAT) FROM t1;
ERROR HY000: Illegal parameter data type inet6 for operation 'float_typecast' ERROR HY000: Illegal parameter data type inet6 for operation 'float_typecast'
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-20798 Conversion from INET6 to other types performed without errors or warnings
#
CREATE TABLE t1 (a INET6, b INT);
INSERT INTO t1 (a) VALUES ('::');
UPDATE t1 SET b=a;
ERROR 22007: Incorrect integer value: '::' for column `test`.`t1`.`b` at row 1
SELECT * FROM t1;
a b
:: NULL
DROP TABLE t1;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
CREATE TABLE t1 (a INET6, b TIMESTAMP);
INSERT INTO t1 (a) VALUES ('::');
UPDATE t1 SET b=a;
ERROR 22007: Incorrect datetime value: '::' for column `test`.`t1`.`b` at row 1
SELECT * FROM t1;
a b
:: 2001-01-01 10:20:30
DROP TABLE t1;
SET timestamp=DEFAULT;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 (a) VALUES ('::');
ALTER TABLE t1 MODIFY a DATE;
ERROR 22007: Incorrect date value: '::' for column `test`.`t1`.`a` at row 1
DROP TABLE t1;
...@@ -1065,6 +1065,264 @@ SELECT a FROM t1; ...@@ -1065,6 +1065,264 @@ SELECT a FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # SET from INET6 to INET6
--echo #
CREATE TABLE t1 (a INET6, b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from INET6 to numeric
--echo #
CREATE TABLE t1 (a INET6, b INT);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DOUBLE);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DECIMAL(32,0));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b YEAR);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from numeric to INET6
--echo #
CREATE TABLE t1 (a INT, b INET6);
INSERT INTO t1 VALUES (1, NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE, b INET6);
INSERT INTO t1 VALUES (1, NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL(32,0), b INET6);
INSERT INTO t1 VALUES (1, NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a YEAR, b INET6);
INSERT INTO t1 VALUES (1, NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from INET6 to temporal
--echo #
CREATE TABLE t1 (a INET6, b TIME);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DATE);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DATETIME);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b TIMESTAMP NULL DEFAULT NULL);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from temporal to INET6
--echo #
CREATE TABLE t1 (a TIME, b INET6);
INSERT INTO t1 VALUES ('00:00:00', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE, b INET6);
INSERT INTO t1 VALUES ('2001-01:01', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME, b INET6);
INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a TIMESTAMP, b INET6);
INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL);
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from INET6 to character string
--echo #
CREATE TABLE t1 (a INET6, b CHAR(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b VARCHAR(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b TEXT);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b ENUM('ffff::ffff'));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b SET('ffff::ffff'));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from character string to INET6
--echo #
CREATE TABLE t1 (a CHAR(39), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(39), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a ENUM('ffff::ffff'), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a SET('ffff::ffff'), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from INET6 to binary
--echo #
CREATE TABLE t1 (a INET6, b BINARY(16));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b VARBINARY(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b BLOB);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
DROP TABLE t1;
--echo #
--echo # SET from binary to INET6
--echo #
CREATE TABLE t1 (a BINARY(16), b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARBINARY(16), b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a BLOB, b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
DROP TABLE t1;
--echo # --echo #
--echo # Limit clause parameter --echo # Limit clause parameter
--echo # TODO: this should fail. --echo # TODO: this should fail.
...@@ -1127,3 +1385,29 @@ INSERT INTO t1 VALUES ('::'); ...@@ -1127,3 +1385,29 @@ INSERT INTO t1 VALUES ('::');
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION --error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CAST(a AS FLOAT) FROM t1; SELECT CAST(a AS FLOAT) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-20798 Conversion from INET6 to other types performed without errors or warnings
--echo #
CREATE TABLE t1 (a INET6, b INT);
INSERT INTO t1 (a) VALUES ('::');
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE t1 SET b=a;
SELECT * FROM t1;
DROP TABLE t1;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
CREATE TABLE t1 (a INET6, b TIMESTAMP);
INSERT INTO t1 (a) VALUES ('::');
--error ER_TRUNCATED_WRONG_VALUE
UPDATE t1 SET b=a;
SELECT * FROM t1;
DROP TABLE t1;
SET timestamp=DEFAULT;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 (a) VALUES ('::');
--error ER_TRUNCATED_WRONG_VALUE
ALTER TABLE t1 MODIFY a DATE;
DROP TABLE t1;
...@@ -802,23 +802,15 @@ class Field_inet6: public Field ...@@ -802,23 +802,15 @@ class Field_inet6: public Field
int save_in_field(Field *to) override int save_in_field(Field *to) override
{ {
// INSERT INTO t2 (different_field_type) SELECT inet6_field FROM t1; // INSERT INTO t2 (different_field_type) SELECT inet6_field FROM t1;
switch (to->cmp_type()) { if (to->charset() == &my_charset_bin &&
case INT_RESULT: dynamic_cast<const Type_handler_general_purpose_string*>
case REAL_RESULT: (to->type_handler()))
case DECIMAL_RESULT:
case TIME_RESULT:
{ {
my_decimal buff; NativeBufferInet6 res;
return to->store_decimal(val_decimal(&buff)); val_native(&res);
return to->store(res.ptr(), res.length(), &my_charset_bin);
} }
case STRING_RESULT:
return save_in_field_str(to); return save_in_field_str(to);
case ROW_RESULT:
break;
}
DBUG_ASSERT(0);
to->reset();
return 0;
} }
Copy_func *get_copy_func(const Field *from) const override Copy_func *get_copy_func(const Field *from) const override
{ {
......
...@@ -393,6 +393,7 @@ class Type_handler_inet6: public Type_handler ...@@ -393,6 +393,7 @@ class Type_handler_inet6: public Type_handler
bool can_return_text() const override { return true; } bool can_return_text() const override { return true; }
bool can_return_date() const override { return false; } bool can_return_date() const override { return false; }
bool can_return_time() const override { return false; } bool can_return_time() const override { return false; }
bool convert_to_binary_using_val_native() const override { return true; }
uint Item_time_precision(THD *thd, Item *item) const override uint Item_time_precision(THD *thd, Item *item) const override
{ {
......
...@@ -4168,6 +4168,14 @@ class Field_blob :public Field_longstr { ...@@ -4168,6 +4168,14 @@ class Field_blob :public Field_longstr {
} }
int store_field(Field *from) override int store_field(Field *from) override
{ // Be sure the value is stored { // Be sure the value is stored
if (field_charset() == &my_charset_bin &&
from->type_handler()->convert_to_binary_using_val_native())
{
NativeBuffer<64> tmp;
from->val_native(&tmp);
value.copy(tmp.ptr(), tmp.length(), &my_charset_bin);
return store(value.ptr(), value.length(), &my_charset_bin);
}
from->val_str(&value); from->val_str(&value);
if (table->copy_blobs || if (table->copy_blobs ||
(!value.is_alloced() && from->is_varchar_and_in_write_set())) (!value.is_alloced() && from->is_varchar_and_in_write_set()))
......
...@@ -3411,6 +3411,16 @@ class Type_handler ...@@ -3411,6 +3411,16 @@ class Type_handler
{ {
return false; return false;
} }
/*
If operations such as:
UPDATE t1 SET binary_string_field=this_type_field;
should store this_type_field->val_native() rather than
this_type_field->val_str().
*/
virtual bool convert_to_binary_using_val_native() const
{
return false;
}
virtual bool is_timestamp_type() const virtual bool is_timestamp_type() const
{ {
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment