Menu

#2921 (ok 3.2.3) SQL truncated to one character

3.2.0
fixed
1
2013-06-11
2009-08-28
Greg Roach
No

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.]

Discussion

  • Greg Roach

    Greg Roach - 2009-08-28

    Screen dump

     
  • Marc Delisle

    Marc Delisle - 2009-09-17
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2009-09-17
    • priority: 5 --> 1
    • summary: SQL truncated to one character --> (ok 3.2.3) SQL truncated to one character
    • status: open --> open-fixed
     
  • Marc Delisle

    Marc Delisle - 2009-09-17

    Fixed in subversion, thanks for reporting.

     
  • Marc Delisle

    Marc Delisle - 2009-10-30
    • status: open-fixed --> closed-fixed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-fixed --> fixed