On 12/12/2014 2:38 PM, Alexander Syvak wrote:
Hello!

How is actually a function done internally in MySQL after CREATE FUNCTION
statement?

Why can't there be a dynamic SQL inside a function?


Sorry for the delay.


The answer is embedded in this description of what is or is not allowed within a function:

from: http://dev.mysql.com/doc/refman/5.6/en/create-procedure.html
Stored functions may not contain statements that perform explicit or implicit 
commit or rollback. Support for these statements is not required by the SQL 
standard, which states that each DBMS vendor may decide whether to permit them.

Since we cannot easily restrict the types of commands generated by dynamic SQL within a function, we simply disallowed those as part of the design.

This and several other restrictions for functions are also listed here
http://dev.mysql.com/doc/refman/5.6/en/stored-program-restrictions.html

The gist of all of these restrictions is that a FUNCTION shall create the least side effects possible while generating the result value.

--
Shawn Green
MySQL Senior Principal Technical Support Engineer
Oracle USA, Inc. - Hardware and Software, Engineered to Work Together.
Office: Blountville, TN

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

  • Function Alexander Syvak
    • Re: Function shawn l.green

Reply via email to