Commit 059a8fd8 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-27668 Assertion `item->type_handler()->is_traditional_scalar_type() ||...

MDEV-27668 Assertion `item->type_handler()->is_traditional_scalar_type() || item->type_handler() == type_handler()' failed in Field_inet6::can_optimize_keypart_ref
parent fb8fea34
...@@ -40,3 +40,24 @@ ERROR HY000: Illegal parameter data types inet6 and longblob/json for operation ...@@ -40,3 +40,24 @@ ERROR HY000: Illegal parameter data types inet6 and longblob/json for operation
SELECT a+c FROM t1; SELECT a+c FROM t1;
ERROR HY000: Illegal parameter data types inet6 and longblob for operation '+' ERROR HY000: Illegal parameter data types inet6 and longblob for operation '+'
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-27668 Assertion `item->type_handler()->is_traditional_scalar_type() || item->type_handler() == type_handler()' failed in Field_inet6::can_optimize_keypart_ref
#
CREATE TABLE t1 (i INET6 PRIMARY KEY);
CREATE TABLE t2 (a VARCHAR(40) CHECK (JSON_VALID(a)));
SELECT * FROM t1 JOIN t2 ON (i = a);
i a
INSERT INTO t1 VALUES ('::'),('ffff::ffff');
INSERT INTO t2 VALUES ('{}'),('[]');
SELECT * FROM t1 JOIN t2 ON (i = a);
i a
DROP TABLE t1, t2;
CREATE TABLE t1 (i INET6 PRIMARY KEY);
SELECT * FROM t1 WHERE i<JSON_OBJECT('c','b');
i
INSERT INTO t1 VALUES ('::'),('ffff::ffff');
SELECT * FROM t1 WHERE i<JSON_OBJECT('c','b');
i
Warnings:
Warning 1292 Incorrect inet6 value: '{"c": "b"}'
DROP TABLE t1;
...@@ -48,3 +48,21 @@ SELECT a+b FROM t1; ...@@ -48,3 +48,21 @@ SELECT a+b FROM t1;
SELECT a+c FROM t1; SELECT a+c FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-27668 Assertion `item->type_handler()->is_traditional_scalar_type() || item->type_handler() == type_handler()' failed in Field_inet6::can_optimize_keypart_ref
--echo #
CREATE TABLE t1 (i INET6 PRIMARY KEY);
CREATE TABLE t2 (a VARCHAR(40) CHECK (JSON_VALID(a)));
SELECT * FROM t1 JOIN t2 ON (i = a);
INSERT INTO t1 VALUES ('::'),('ffff::ffff');
INSERT INTO t2 VALUES ('{}'),('[]');
SELECT * FROM t1 JOIN t2 ON (i = a);
DROP TABLE t1, t2;
CREATE TABLE t1 (i INET6 PRIMARY KEY);
SELECT * FROM t1 WHERE i<JSON_OBJECT('c','b');
INSERT INTO t1 VALUES ('::'),('ffff::ffff');
SELECT * FROM t1 WHERE i<JSON_OBJECT('c','b');
DROP TABLE t1;
...@@ -936,8 +936,11 @@ class Field_inet6: public Field ...@@ -936,8 +936,11 @@ class Field_inet6: public Field
Mixing of two different non-traditional types is currently prevented. Mixing of two different non-traditional types is currently prevented.
This may change in the future. For example, INET4 and INET6 This may change in the future. For example, INET4 and INET6
data types can be made comparable. data types can be made comparable.
But we allow mixing INET6 to a data type directly inherited from
a traditional type, e.g. INET6=VARCHAR/JSON.
*/ */
DBUG_ASSERT(item->type_handler()->is_traditional_scalar_type() || DBUG_ASSERT(item->type_handler()->type_handler_base_or_self()->
is_traditional_scalar_type() ||
item->type_handler() == type_handler()); item->type_handler() == type_handler());
return true; return true;
} }
...@@ -951,7 +954,8 @@ class Field_inet6: public Field ...@@ -951,7 +954,8 @@ class Field_inet6: public Field
bool is_eq_func) const override bool is_eq_func) const override
{ {
// See the DBUG_ASSERT comment in can_optimize_keypart_ref() // See the DBUG_ASSERT comment in can_optimize_keypart_ref()
DBUG_ASSERT(item->type_handler()->is_traditional_scalar_type() || DBUG_ASSERT(item->type_handler()->type_handler_base_or_self()->
is_traditional_scalar_type() ||
item->type_handler() == type_handler()); item->type_handler() == type_handler());
return true; return true;
} }
......
...@@ -3773,6 +3773,11 @@ class Type_handler ...@@ -3773,6 +3773,11 @@ class Type_handler
{ {
return NULL; return NULL;
} }
const Type_handler *type_handler_base_or_self() const
{
const Type_handler *res= type_handler_base();
return res ? res : this;
}
virtual const Type_handler *type_handler_for_comparison() const= 0; virtual const Type_handler *type_handler_for_comparison() const= 0;
virtual const Type_handler *type_handler_for_native_format() const virtual const Type_handler *type_handler_for_native_format() const
{ {
......
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