RQG: Virtual persistent columns not computed properly for default NULL values

Bug #603186 reported by Philip Stoev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
High
Igor Babaev

Bug Description

In the example below, the virtual persistent column does not agree that the result from INTERVAL ( NULL , NULL ) is -1 . If the computation is executed without the aid of a virtual column, or if the virtual column is not persisted, the result is correct.

CREATE TABLE t1 ( f1 CHAR(32), f2 CHAR(32), v1 INT AS ( INTERVAL( f2 , NULL ) ) PERSISTENT );
INSERT INTO t1 ( f1 ) VALUES ( NULL );

SELECT INTERVAL(NULL , NULL), v1, ( INTERVAL( f2, NULL ) ) FROM t1;

Revision history for this message
Philip Stoev (pstoev-askmonty) wrote :

Here is another example:

--disable_abort_on_error
DROP TABLE t1;
DROP TABLE t2;

CREATE TABLE t1 ( f1 CHAR(32) NOT NULL, v1 INT AS ( f1 ) PERSISTENT );
INSERT INTO t1 () VALUES ();

CREATE TABLE t2 ( f1 CHAR(32) NOT NULL, v1 INT AS ( f1 ) VIRTUAL );
INSERT INTO t2 () VALUES ();

SELECT f1, v1 FROM t1;
SELECT f1, v1 FROM t2;

summary: - Virtual persistent columns not computed properly for default NULL values
+ RQG: Virtual persistent columns not computed properly for default NULL
+ values
Revision history for this message
Philip Stoev (philip-stoev) wrote :

What happens here is that if you use an INSERT that does not explicitly list all the columns in the table, some of the columns will get the default value. If such default values are then used in a virtual column computation, the result from the computation will be incorrect.

If you use an INSERT form where all fields are specified and thus no defaults kick in, virtual columns are computed correctly.

Changed in maria:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Igor Babaev (igorb-seattle)
Changed in maria:
milestone: none → 5.2
Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.