← Back to team overview

maria-discuss team mailing list archive

virtual columns

 

Hello

I've read in the documentation that any legal SQL expression SHOULD be allowed 
in the Virtual Columns definition. I'm trying to use a (deterministic) stored 
function, but I get an error:
ERROR 1642 (HY000): Function or expression is not allowed for column 'vc1'

Here's my create table:
CREATE TABLE t1 (c1 int, c2 int, vc1 INT AS (c1+functest()) VIRTUAL);

Here's how functest() is defined:

CREATE FUNCTION functest() RETURNS TINYINT DETERMINISTIC
BEGIN
    UPDATE t2 SET c1 = c1 + 1;
    RETURN 0;
END

I think this clearly explains what I am trying to do: a function which logs 
accesses to a certain column.

Why do I get error 1642? Is the bug in the documentation or in the software? 
Will future MariaDB versions allow us to create virtual columns which call 
stored functions?

Federico







Follow ups