[MDEV-6286] "Function or expression is not allowed for column 'fd2'" on VIRTUAL column Created: 2014-06-02  Updated: 2014-06-02  Resolved: 2014-06-02

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.10
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Seunguck Lee Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Darwin Mattui-MacBook-Pro.local 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64



 Description   

MariaDB knowledge said "User-defined functions and stored functions cannot be used (built-in functions can be used)" on https://mariadb.com/kb/en/virtual-columns/

So I think we can use any built-in function on VIRTUAL column.
But, MariaDB server complain about the function I used, Especially "NOW()". Without NOW() table created successfully.

Is it expected ?
And are there any document about what function we can use on VIRTUAL column ?

MariaDB [test]> create table t_virtual (fd1 datetime, fd2 bigint as (DATEDIFF(now(), fd1)) VIRTUAL);
ERROR 1901 (HY000): Function or expression is not allowed for column 'fd2'
 
MariaDB [test]> create table t_virtual (fd1 datetime, fd2 bigint as (DATEDIFF(fd1, fd1)) VIRTUAL);
Query OK, 0 rows affected (0.03 sec)



 Comments   
Comment by Sergei Golubchik [ 2014-06-02 ]

The documentation says that only deterministic expressions are permitted. But NOW() is not deterministic — if you call it twice, you may get different results.

Comment by Seunguck Lee [ 2014-06-02 ]

Thanks Sergei Golubchik.

I didn't know that NOW() is not deterministic.
Statement based binary log don't complain deterministic property of NOW() and also on searching index.
In one statement, NOW() return the same value. so I thought it's kind of determinstic. ^^;

And even if it's not deterministic,
If MariaDB can process NOW() like statement based binary log,
It would be good (I think).

Anyway thanks.

Generated at Thu Feb 08 07:10:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.