[MDEV-3647] LP:607177 - Virtual columns do not evaluate properly with set/enum and certain expressions Created: 2010-07-19 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Philip Stoev (Inactive) | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
set/enum columns that participate in virtual columns may lead to wrong results depending on the virtual column expression. There may be a deeper underlying problem since sometimes the expression is not evaluated properly even without a virtual column. The test case below evaluates one and the same expression in a virtual column context and as a normal expression in the SELECT list. SET @c1 = " SET @virtcol_def = " ( ROUND( 1 , NULLIF( f4 , 1 AND f1 ) ) ) "; PREPARE cs FROM @create; INSERT INTO `X` (f1, f4) VALUES (7,'0'); SET @s1 = CONCAT("SELECT f1, f4, CAST( ",@virtcol_def," AS SIGNED) AS c1 , v4 FROM X"); The result set is as follows: f1 f4 c1 v4 The first two columns show that the underlying rows of the table are the same and there is no reason for the expression to return NULL or to return a different result for each row. However, the expression does return NULL when used in a virtual column and it does return a different result for each row when used as a standard expression in the SELECT list. |
| Comments |
| Comment by Philip Stoev (Inactive) [ 2010-07-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Virtual columns do not evaluate properly with set/enum and certain expressions CREATE TABLE `X` ( SELECT v3 This query returns only NULLs even though in-lining the same expression produces some integer results as well (plus one NULL that seems unwarranted, since none of the fields in that particular row are NULL): mysql> SELECT f2, f3, f1, v3, ( ( ROUND( ( ( f2 ) XOR ( f3 ) ) , f1 ) )) FROM X;
---
--- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2010-07-21 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Virtual columns do not evaluate properly with set/enum and certain expressions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 607177 |