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
b43eb82b
Commit
b43eb82b
authored
Aug 09, 2002
by
ram@ram.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QUOTE() func changes according to monty's suggestions
parent
b7403f3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
38 deletions
+20
-38
sql/item_strfunc.cc
sql/item_strfunc.cc
+19
-34
sql/item_strfunc.h
sql/item_strfunc.h
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+0
-3
No files found.
sql/item_strfunc.cc
View file @
b43eb82b
...
...
@@ -2071,55 +2071,40 @@ String* Item_func_inet_ntoa::val_str(String* str)
return
str
;
}
/*
QUOTE() function returns argument string in single quotes,
also adds a \ before \, ' CHAR(0) and CHAR(24)
*/
String
*
Item_func_quote
::
val_str
(
String
*
str
)
{
static
char
escmask
[
64
]
=
{
0x01
,
0x00
,
0x00
,
0x04
,
0x80
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
String
*
arg
=
args
[
0
]
->
val_str
(
str
);
char
*
strptr
,
*
argptr
,
*
end
,
*
arglast
;
char
*
from
,
*
to
,
*
end
;
uint
delta
=
2
;
/* for beginning and ending ' signs */
for
(
argptr
=
(
char
*
)
arg
->
ptr
(),
end
=
argptr
+
arg
->
length
();
argptr
<
end
;
argptr
++
)
for
(
from
=
(
char
*
)
arg
->
ptr
(),
end
=
from
+
arg
->
length
();
from
<
end
;
from
++
)
{
switch
(
*
argptr
)
{
case
'\''
:
case
'\\'
:
case
0
:
case
'\032'
:
if
(
*
(
escmask
+
(
*
from
>>
3
))
and
(
1
<<
(
*
from
&
7
)))
delta
++
;
}
}
if
(
str
->
alloc
(
arg
->
length
()
+
delta
))
{
null_value
=
1
;
return
0
;
}
strptr
=
(
char
*
)
str
->
ptr
()
+
arg
->
length
()
+
delta
-
1
;
*
strptr
=
'\''
;
for
(
end
=
(
char
*
)
arg
->
ptr
(),
arglast
=
end
+
arg
->
length
(),
argptr
=
arglast
-
1
;
argptr
>=
end
;
argptr
--
)
{
switch
(
*
argptr
)
{
case
'\''
:
case
'\\'
:
case
0
:
case
'\032'
:
strptr
-=
arglast
-
argptr
;
memmove
(
strptr
,
argptr
,
arglast
-
argptr
);
arglast
=
argptr
;
*--
strptr
=
'\\'
;
}
}
if
(
arglast
!=
end
)
to
=
(
char
*
)
str
->
ptr
()
+
arg
->
length
()
+
delta
-
1
;
*
to
--=
'\''
;
for
(
end
=
(
char
*
)
arg
->
ptr
(),
from
=
end
+
arg
->
length
()
-
1
;
from
>=
end
;
from
--
,
to
--
)
{
strptr
-=
arglast
-
end
;
memmove
(
strptr
,
end
,
arglast
-
end
);
*
to
=
*
from
;
if
(
*
(
escmask
+
(
*
from
>>
3
))
and
(
1
<<
(
*
from
&
7
)))
*--
to
=
'\\'
;
}
*
--
strptr
=
'\''
;
*
to
=
'\''
;
str
->
length
(
arg
->
length
()
+
delta
);
return
str
;
}
void
Item_func_quote
::
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
*
2
+
2
;
}
sql/item_strfunc.h
View file @
b43eb82b
...
...
@@ -542,5 +542,5 @@ public:
Item_func_quote
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
const
char
*
func_name
()
const
{
return
"quote"
;
}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
;
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
*
2
+
2
;
}
};
sql/sql_yacc.yy
View file @
b43eb82b
...
...
@@ -283,7 +283,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token PROCESS
%token PROCESSLIST_SYM
%token QUERY_SYM
%token QUOTE
%token RAID_0_SYM
%token RAID_STRIPED_SYM
%token RAID_TYPE
...
...
@@ -1816,8 +1815,6 @@ simple_expr:
}
| POSITION_SYM '(' no_in_expr IN_SYM expr ')'
{ $$ = new Item_func_locate($5,$3); }
| QUOTE '(' expr ')'
{ $$= new Item_func_quote($3); }
| RAND '(' expr ')'
{ $$= new Item_func_rand($3); current_thd->safe_to_cache_query=0;}
| RAND '(' ')'
...
...
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