1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-27668 Assertion `item->type_handler()->is_traditional_scalar_type() || item->type_handler() == type_handler()' failed in Field_inet6::can_optimize_keypart_ref

This commit is contained in:
Alexander Barkov
2022-01-28 22:32:56 +04:00
parent fb8fea3490
commit 059a8fd87e
4 changed files with 50 additions and 2 deletions

View File

@ -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;

View File

@ -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;

View File

@ -936,8 +936,11 @@ public:
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 @@ public:
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;
} }

View File

@ -3773,6 +3773,11 @@ public:
{ {
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
{ {