MySQL stores a function: CONTAINS SQL or NO SQL?

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 at http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html , but I'm still not sure:

  • CONTAINS SQL indicates that the routine contains no statements that read or write data. This is the default if none of these characteristics are explicitly specified. Examples of such statements are SET @x = 1 or DO RELEASE_LOCK ('abc'), which execute, but do not read or write data.

  • NO SQL indicates that the routine contains no SQL statements.

+3


source to share


1 answer


Both are NO SQL

because they do not access data in tables, cursors, or variables.

For help on what a SQL statement is, see below: http://dev.mysql.com/doc/refman/5.1/en/sql-syntax.html



Note that functions like CONV()

SHA()

or CONCAT()

are not mentioned in this chapter.

+1


source







All Articles