← Back to team overview

maria-discuss team mailing list archive

Re: virtual columns

 

Hi,

I don't believe that UDF or stored functions are compatible with
virtual columns.  This makes sense, since these functions could be
dropped after the table is created.

--Justin

On Mon, Nov 8, 2010 at 7:03 PM, Federico Razzoli <federico_raz@xxxxxxxx> wrote:
> 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
>
>
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~maria-discuss
> Post to     : maria-discuss@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~maria-discuss
> More help   : https://help.launchpad.net/ListHelp
>



References