Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
98df9313
Commit
98df9313
authored
Nov 11, 2004
by
ram@gw.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A fix (bug #6564: QUOTE(NULL) returns NULL, not the string 'NULL')
parent
4f042178
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+4
-1
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+6
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+11
-3
No files found.
mysql-test/r/func_str.result
View file @
98df9313
...
@@ -167,6 +167,9 @@ length(quote(concat(char(0),"test")))
...
@@ -167,6 +167,9 @@ length(quote(concat(char(0),"test")))
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
27E0E3E6E7E8EAEB27
27E0E3E6E7E8EAEB27
select concat('a', quote(NULL));
concat('a', quote(NULL))
aNULL
select reverse("");
select reverse("");
reverse("")
reverse("")
...
@@ -278,7 +281,7 @@ insert into t1 values ('one'),(NULL),('two'),('four');
...
@@ -278,7 +281,7 @@ 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;
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')
a quote(a) isnull(quote(a)) quote(a) is null ifnull(quote(a), 'n')
one 'one' 0 0 'one'
one 'one' 0 0 'one'
NULL NULL
1 1 n
NULL NULL
0 0 NULL
two 'two' 0 0 'two'
two 'two' 0 0 'two'
four 'four' 0 0 'four'
four 'four' 0 0 'four'
drop table t1;
drop table t1;
...
...
mysql-test/t/func_str.test
View file @
98df9313
...
@@ -69,6 +69,12 @@ select quote(1/0), quote('\0\Z');
...
@@ -69,6 +69,12 @@ select quote(1/0), quote('\0\Z');
select
length
(
quote
(
concat
(
char
(
0
),
"test"
)));
select
length
(
quote
(
concat
(
char
(
0
),
"test"
)));
select
hex
(
quote
(
concat
(
char
(
224
),
char
(
227
),
char
(
230
),
char
(
231
),
char
(
232
),
char
(
234
),
char
(
235
))));
select
hex
(
quote
(
concat
(
char
(
224
),
char
(
227
),
char
(
230
),
char
(
231
),
char
(
232
),
char
(
234
),
char
(
235
))));
#
# Bug #6564: QUOTE(NULL
#
select
concat
(
'a'
,
quote
(
NULL
));
#
#
# Wrong usage of functions
# Wrong usage of functions
#
#
...
...
sql/item_strfunc.cc
View file @
98df9313
...
@@ -2142,9 +2142,12 @@ String* Item_func_inet_ntoa::val_str(String* str)
...
@@ -2142,9 +2142,12 @@ String* Item_func_inet_ntoa::val_str(String* str)
This function is very useful when you want to generate SQL statements
This function is very useful when you want to generate SQL statements
NOTE
QUOTE(NULL) returns the string 'NULL' (4 letters, without quotes).
RETURN VALUES
RETURN VALUES
str Quoted string
str Quoted string
NULL
Argument to QUOTE() was NULL or o
ut of memory.
NULL
O
ut of memory.
*/
*/
#define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))
#define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))
...
@@ -2168,7 +2171,12 @@ String *Item_func_quote::val_str(String *str)
...
@@ -2168,7 +2171,12 @@ String *Item_func_quote::val_str(String *str)
String
*
arg
=
args
[
0
]
->
val_str
(
str
);
String
*
arg
=
args
[
0
]
->
val_str
(
str
);
uint
arg_length
,
new_length
;
uint
arg_length
,
new_length
;
if
(
!
arg
)
// Null argument
if
(
!
arg
)
// Null argument
goto
null
;
{
str
->
copy
(
"NULL"
,
4
);
// Return the string 'NULL'
null_value
=
0
;
return
str
;
}
arg_length
=
arg
->
length
();
arg_length
=
arg
->
length
();
new_length
=
arg_length
+
2
;
/* for beginning and ending ' signs */
new_length
=
arg_length
+
2
;
/* for beginning and ending ' signs */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment