PMA version 3.2.0.1
Create a database, open an SQL window, and run a "CREATE FUNCTION" script. Here's one for you to cut/paste:
CREATE FUNCTION count_letters(s VARCHAR(255), l VARCHAR(1)) RETURNS INTEGER
NO SQL
DETERMINISTIC
BEGIN
DECLARE n INTEGER DEFAULT 0;
DECLARE p INTEGER DEFAULT LENGTH(s);
WHILE p>0 DO
IF SUBSTR(s, p, 1)=l THEN
SET n=n+1;
END IF;
SET p=p-1;
END WHILE;
RETURN n;
END//
Set the delimiter to // and click "Go".
In the top of the screen there is a box showing the SQL that was just executed. It just contains the first letter - "C". If you click the edit link, you get the full SQL back. If the script had started with "DROP FUNCTION IF EXISTS ...", then the letter "D" would be displayed, etc.
[My guess is that the code is confusing strings with arrays, and the subscript [0] gives the first char, rather than the first element.]
Screen dump
Merged this patch:
https://sourceforge.net/tracker/index.php?func=detail&aid=2859788&group_id=23067&atid=377410
Fixed in subversion, thanks for reporting.