Skip to content
Permalink
Browse files
MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImp…
…l>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()

The assuption that Field::is_null() is always false when
Field_fbt::val_native() or Field_fbt::to_fbt() are called
was wrong.

In some cases, e.g. when this helper Field method is called:

  inline String *val_str(String *str, const uchar *new_ptr)

we temporarily reset Field::ptr to some alternative record buffer
but don't reset null_ptr, so null_ptr still points to null flags
of the original record. In such cases it's meaningless to test
the original Field::null_ptr when Field::ptr is temporarily reset:
they don't relate to each other.

Removing the DBUG_ASSERT.
  • Loading branch information
abarkov committed Jul 5, 2022
1 parent 3dff84c commit c12192b
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 2 deletions.
@@ -2213,3 +2213,31 @@ SELECT * FROM companies;
id name
DROP TABLE divisions;
DROP TABLE companies;
#
# MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
#
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a INET6(6) DEFAULT '::10');
INSERT INTO t1(id) VALUES (1), (2), (3), (4);
INSERT INTO t1 VALUES (5,'::5'), (6,'::6');
SELECT * FROM t1 ORDER BY a;
id a
5 ::5
6 ::6
1 ::10
2 ::10
3 ::10
4 ::10
CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a;
CREATE TABLE t2 SELECT * FROM v1;
SELECT * FROM v1 ORDER BY a;
a m
::5 5
::6 6
::10 1
SELECT * FROM t2 ORDER BY a;
a m
::5 5
::6 6
::10 1
DROP VIEW v1;
DROP TABLE t1, t2;
@@ -1629,3 +1629,18 @@ DELETE FROM companies WHERE id IN (SELECT company_id FROM divisions);
SELECT * FROM companies;
DROP TABLE divisions;
DROP TABLE companies;

--echo #
--echo # MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
--echo #

CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a INET6(6) DEFAULT '::10');
INSERT INTO t1(id) VALUES (1), (2), (3), (4);
INSERT INTO t1 VALUES (5,'::5'), (6,'::6');
SELECT * FROM t1 ORDER BY a;
CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a;
CREATE TABLE t2 SELECT * FROM v1;
SELECT * FROM v1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
DROP VIEW v1;
DROP TABLE t1, t2;
@@ -0,0 +1,51 @@
#
# Start of 10.7 tests
#
#
# MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
#
CREATE TABLE t1 (i6 INET6, a1 TIME, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::','09:43:12','uw'), ('70:ef59::46:c7b:f:678:bd9f','00:00:00','a');
SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1)
::
Warnings:
Warning 1292 Incorrect inet6 value: 'a'
DROP TABLE t1;
CREATE TABLE t1 (i6 inet6, a2 varchar(10));
INSERT INTO t1 VALUES ('::','uw'), (null,'a');
SELECT group_concat(coalesce(i6, a2) ORDER BY 1) FROM t1;
group_concat(coalesce(i6, a2) ORDER BY 1)
::
Warnings:
Warning 1292 Incorrect inet6 value: 'a'
DROP TABLE t1;
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES();
SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1;
JSON_ARRAYAGG(a ORDER BY a DESC)
[null]
DROP TABLE t1;
CREATE TABLE t1 (i6 INET6, a1 INT, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::',1,'uw'), ('70:ef59::46:c7b:f:678:bd9f',0,'a');
SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1)
::
Warnings:
Warning 1292 Incorrect inet6 value: 'a'
DROP TABLE t1;
CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
SELECT GROUP_CONCAT(COALESCE(i6, a2) ORDER BY 1) FROM t1;
GROUP_CONCAT(COALESCE(i6, a2) ORDER BY 1)
::
DROP TABLE t1;
CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
SELECT GROUP_CONCAT(DISTINCT COALESCE(i6, a2)) FROM t1;
GROUP_CONCAT(DISTINCT COALESCE(i6, a2))
::
DROP TABLE t1;
#
# End of 10.7 tests
#
@@ -0,0 +1,41 @@
--echo #
--echo # Start of 10.7 tests
--echo #

--echo #
--echo # MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
--echo #

CREATE TABLE t1 (i6 INET6, a1 TIME, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::','09:43:12','uw'), ('70:ef59::46:c7b:f:678:bd9f','00:00:00','a');
SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
DROP TABLE t1;

CREATE TABLE t1 (i6 inet6, a2 varchar(10));
INSERT INTO t1 VALUES ('::','uw'), (null,'a');
SELECT group_concat(coalesce(i6, a2) ORDER BY 1) FROM t1;
DROP TABLE t1;

CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES();
SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1;
DROP TABLE t1;

CREATE TABLE t1 (i6 INET6, a1 INT, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::',1,'uw'), ('70:ef59::46:c7b:f:678:bd9f',0,'a');
SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
DROP TABLE t1;

CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
SELECT GROUP_CONCAT(COALESCE(i6, a2) ORDER BY 1) FROM t1;
DROP TABLE t1;

CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
SELECT GROUP_CONCAT(DISTINCT COALESCE(i6, a2)) FROM t1;
DROP TABLE t1;

--echo #
--echo # End of 10.7 tests
--echo #
@@ -0,0 +1,17 @@
#
# Start of 10.7 tests
#
#
# MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
#
CREATE TABLE t1 (i6 UUID, a1 TIME, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-fffffffffffe','09:43:12','uw'), (uuid(),'00:00:00','a');
SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1)
ffffffff-ffff-ffff-ffff-fffffffffffe
Warnings:
Warning 1292 Incorrect uuid value: 'a'
DROP TABLE t1;
#
# End of 10.7 tests
#
@@ -0,0 +1,17 @@
--echo #
--echo # Start of 10.7 tests
--echo #

--echo #
--echo # MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
--echo #

CREATE TABLE t1 (i6 UUID, a1 TIME, a2 VARCHAR(10));
INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-fffffffffffe','09:43:12','uw'), (uuid(),'00:00:00','a');
SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
DROP TABLE t1;


--echo #
--echo # End of 10.7 tests
--echo #
@@ -1190,7 +1190,6 @@ class FixedBinTypeBundle
bool val_native(Native *to) override
{
DBUG_ASSERT(marked_for_read());
DBUG_ASSERT(!is_null());
if (to->alloc(FbtImpl::binary_length()))
return true;
to->length(FbtImpl::binary_length());
@@ -1201,7 +1200,6 @@ class FixedBinTypeBundle
Fbt to_fbt() const
{
DBUG_ASSERT(marked_for_read());
DBUG_ASSERT(!is_null());
return Fbt::record_to_memory((const char*) ptr);
}

0 comments on commit c12192b

Please sign in to comment.