[MDEV-12476] DO unknown_function_name() does not return an error Created: 2017-04-10  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0, 10.1, 10.5.3, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: upstream-fixed


 Description   

I create a number of stored functions as follow:

DROP FUNCTION IF EXISTS f1a;
DROP FUNCTION IF EXISTS f1b;
DROP FUNCTION IF EXISTS f2;
DELIMITER $$
CREATE FUNCTION f1a() RETURNS TEXT
BEGIN
  RETURN f2();
END;
$$
CREATE FUNCTION f1b() RETURNS TEXT
BEGIN
  DO f2();
  RETURN '';
END;
$$
CREATE FUNCTION f2() RETURNS TEXT
BEGIN
  DO unknown_function_name();
  RETURN '';
END;
$$
DELIMITER ;

Now I run:

SELECT f1a();

It correctly returns the error:

ERROR 1305 (42000): FUNCTION test.unknown_function_name does not exist

Now I run:

SELECT f1b();

It returns a result without errors:

+-------+
| f1b() |
+-------+
|       |
+-------+

The second SELECT query should return the same error with the first SELECT query.

Now I run this script:

DO f1a();
SHOW WARNINGS;

It works without errors and return a warning:

+-------+------+----------------------------------------------------+
| Level | Code | Message                                            |
+-------+------+----------------------------------------------------+
| Error | 1305 | FUNCTION test.unknown_function_name does not exist |
+-------+------+----------------------------------------------------+

This script should return FUNCTION test.unknown_function_name does not exist.

Now I run:

DO f1b();

It returns without errors and without warnings.
It should return FUNCTION test.unknown_function_name does not exist.



 Comments   
Comment by Elena Stepanova [ 2017-04-20 ]

Also reproducible on 10.0, 10.1, MySQL 5.6.
In 5.5 (MariaDB and MySQL) it's slightly different, queries 2 and 4 also produce warnings:

SELECT f1b();
f1b()
 
Warnings:
Error	1305	FUNCTION test.unknown_function_name does not exist
 
DO f1b();
Warnings:
Error	1305	FUNCTION test.unknown_function_name does not exist

Fixed in MySQL 5.7, all four queries return an error there.

Generated at Thu Feb 08 07:58:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.