From ff23273b7afe24ebc5927178895c18c97c01d3cf Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 May 2004 12:47:16 +0500 Subject: [PATCH 1/2] A fix (bug #3756: ISNULL(QUOTE()) returns 1 for every row after 1st NULL) --- mysql-test/r/func_str.result | 9 +++++++++ mysql-test/t/func_str.test | 9 +++++++++ sql/item_strfunc.cc | 1 + 3 files changed, 19 insertions(+) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index dd20ffa2dbb..12c1cf78f7c 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -273,3 +273,12 @@ i ELT(j, '345', '34') 1 345 2 34 DROP TABLE t1; +create table t1(a char(4)); +insert into t1 values ('one'),(NULL),('two'),('four'); +select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1; +a quote(a) isnull(quote(a)) quote(a) is null ifnull(quote(a), 'n') +one 'one' 0 0 'one' +NULL NULL 1 1 n +two 'two' 0 0 'two' +four 'four' 0 0 'four' +drop table t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index d6255e4d93c..1d33e459372 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -163,3 +163,12 @@ CREATE TABLE t1 (i int, j int); INSERT INTO t1 VALUES (1,1),(2,2); SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; DROP TABLE t1; + +# +# bug #3756: quote and NULL +# + +create table t1(a char(4)); +insert into t1 values ('one'),(NULL),('two'),('four'); +select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1; +drop table t1; \ No newline at end of file diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index ac70ef2cbd3..5d017b3a27a 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2215,6 +2215,7 @@ String *Item_func_quote::val_str(String *str) } *to= '\''; str->length(new_length); + null_value= 0; return str; null: From f948d7bb2434ae2431f6401a030414d07c4ab82c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 May 2004 13:40:02 +0500 Subject: [PATCH 2/2] added newline at the end of the file. --- mysql-test/t/func_str.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 1d33e459372..9b0c076f23e 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -171,4 +171,4 @@ DROP TABLE t1; create table t1(a char(4)); insert into t1 values ('one'),(NULL),('two'),('four'); select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1; -drop table t1; \ No newline at end of file +drop table t1;