Bug #101401 ISNULL continously returns the same value for LOAD_FILE
Submitted: 30 Oct 2020 13:21 Modified: 16 Nov 2020 22:44
Reporter: Kamil Holubicki (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:8.0.22, 5.7.32 OS:Any
Assigned to: CPU Architecture:Any
Tags: regression

[30 Oct 2020 13:21] Kamil Holubicki
Description:
When ISNULL is used together with LOAD_FILE as the condition on WHILE loop, it continuously returns the value caught on the first try. If the file is created/delete, ISNULL still returns the captured value.

How to repeat:
mysql> delimiter ;
mysql> show variables like 'secure_file_priv';
+------------------+------------------------------------------+
| Variable_name    | Value                                    |
+------------------+------------------------------------------+
| secure_file_priv | /home/kamil/repo/8.0/bld/mysql-test/var/ |
+------------------+------------------------------------------+
1 row in set (0.01 sec)

mysql> delimiter //
mysql> CREATE PROCEDURE p1() BEGIN WHILE ISNULL(LOAD_FILE('/home/kamil/repo/8.0/bld/mysql-test/var/tmp/trigger')) DO SELECT SLEEP(10); SELECT 'WAITING'; END WHILE; END//
Query OK, 0 rows affected (0.01 sec)

mysql> delimiter ;

mysql> call p1();
+-----------+
| SLEEP(10) |
+-----------+
|         0 |
+-----------+
1 row in set (10.00 sec)

+---------+
| WAITING |
+---------+
| WAITING |
+---------+
1 row in set (10.00 sec)

+-----------+
| SLEEP(10) |
+-----------+
|         0 |
+-----------+
1 row in set (20.00 sec)

+---------+
| WAITING |
+---------+
| WAITING |
+---------+
1 row in set (20.00 sec)

Now from the command line:
touch /home/kamil/repo/8.0/bld/mysql-test/var/trigger

Result: stored procedure loop still goes on.

Expected result: Loop should finish, as the file appeared and 'while' condition is not met anymore.

Suggested fix:
item_strfunc.h Item_Load_File class

Add method

table_map used_tables() const override { return (table_map)1L; }

to prevent caching in Item_func_isnull.
[31 Oct 2020 5:31] MySQL Verification Team
Hello Kamil Holubicki ,

Thank you for the report and test case.
Verified as described with 8.0.22 build.

regards,
Umesh
[16 Nov 2020 22:44] Paul DuBois
Posted by developer:
 
Fixed in 8.0.23.

In multiple-row queries, the LOAD_FILE() function evaluated to the
same value for every row.