For the stored functions below, which is the correct flag: CONTAINS SQL or NO SQL?
CREATE FUNCTION BigIntHash(str VARCHAR(255)) RETURNS BIGINT UNSIGNED DETERMINISTIC
RETURN CONV(SUBSTRING(CAST(SHA(str) AS CHAR), 1, 15), 16, 10)
and
CREATE FUNCTION upi(a VARCHAR(14), b INT(8) UNSIGNED, c VARCHAR(13)) RETURNS BIGINT UNSIGNED DETERMINISTIC
RETURN IF(a IS NULL,
IF(b IS NULL,
IF(c IS NULL,
NULL,
BigIntHash(CONCAT("a-", a))
),
BigIntHash(CONCAT("b-", b))
),
BigIntHash(CONCAT("c-", c))
)
The definitions are on http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html but I am still not sure:
CONTAINS SQL indicates that the routine does not contain statements that read or write data. This is the default if none of these characteristics is given explicitly. Examples of such statements are SET @x = 1 or DO RELEASE_LOCK('abc'), which execute but neither read nor write data.
NO SQL indicates that the routine contains no SQL statements.
Both are NO SQL
as they do not access data in tables, cursors or variables.
For reference on what constitutes an SQL statement see: http://dev.mysql.com/doc/refman/5.1/en/sql-syntax.html
Notice that functions like CONV()
SHA()
or CONCAT()
are not mentioned in this chapter.