Skip to content

Commit

Permalink
Bug#32096341: ISNULL continuously returns the same value for LOAD_FILE
Browse files Browse the repository at this point in the history
The LOAD_FILE() function must be evaluated per execution, but was
classified as a function returning a const value.

Fixed by adding the proper get_initial_pseudo_tables()
implementation for the class implementing LOAD_FILE().

Reviewed by: Chaithra Gopalareddy <chaithra.gopalareddy@oracle.com>
  • Loading branch information
roylyseng committed Nov 9, 2020
1 parent 93c55ed commit de4b3f7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mysql-test/r/func_str.result
Original file line number Diff line number Diff line change
Expand Up @@ -5203,3 +5203,14 @@ DROP TABLE t1;
SELECT INSERT(1, 1, 2, _utf8mb4 x'E4B8ADE69687');
INSERT(1, 1, 2, _utf8mb4 x'E4B8ADE69687')
中文
# Bug#32096341: ISNULL continuously returns the same value for LOAD_FILE
CREATE TABLE t1(id INTEGER NOT NULL PRIMARY KEY);
INSERT INTO t1 VALUES(0);
CALL p1();
is null
1
CALL p1();
is null
0
DROP PROCEDURE p1;
DROP TABLE t1;
19 changes: 19 additions & 0 deletions mysql-test/t/func_str.test
Original file line number Diff line number Diff line change
Expand Up @@ -2118,3 +2118,22 @@ DROP TABLE t1;

# E4B8ADE69687 == Zhōngwén
SELECT INSERT(1, 1, 2, _utf8mb4 x'E4B8ADE69687');

--echo # Bug#32096341: ISNULL continuously returns the same value for LOAD_FILE

--let $file=$MYSQLTEST_VARDIR/tmp/bug32096341.txt
CREATE TABLE t1(id INTEGER NOT NULL PRIMARY KEY);
INSERT INTO t1 VALUES(0);
--disable_query_log
eval CREATE PROCEDURE p1()
SELECT ISNULL(LOAD_FILE("$file")) AS "is null";
--enable_query_log
CALL p1();
--disable_query_log
eval SELECT * INTO OUTFILE "$file" from t1;
--enable_query_log
CALL p1();
DROP PROCEDURE p1;
DROP TABLE t1;
#isable_query_log;
remove_file $file;
3 changes: 3 additions & 0 deletions sql/item_strfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ class Item_load_file final : public Item_str_func {
bool itemize(Parse_context *pc, Item **res) override;
String *val_str(String *) override;
const char *func_name() const override { return "load_file"; }
table_map get_initial_pseudo_tables() const override {
return INNER_TABLE_BIT;
}
bool resolve_type(THD *thd) override {
if (param_type_is_default(thd, 0, 1)) return true;
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
Expand Down

0 comments on commit de4b3f7

Please sign in to comment.