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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ae03ccc4
Commit
ae03ccc4
authored
Mar 29, 2002
by
bar@gw.udmsearch.izhnet.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Charset convertion operator CONVERT( string USING charset)
parent
0300bac6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
0 deletions
+90
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+67
-0
sql/item_strfunc.h
sql/item_strfunc.h
+13
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+10
-0
No files found.
sql/item_strfunc.cc
View file @
ae03ccc4
...
@@ -1776,6 +1776,73 @@ String *Item_func_conv::val_str(String *str)
...
@@ -1776,6 +1776,73 @@ String *Item_func_conv::val_str(String *str)
}
}
String
*
Item_func_conv_charset
::
val_str
(
String
*
str
)
{
my_wc_t
wc
;
int
cnvres
;
const
uchar
*
s
,
*
se
;
uchar
*
d
,
*
d0
,
*
de
;
uint
dmaxlen
;
String
*
arg
=
args
[
0
]
->
val_str
(
str
);
CHARSET_INFO
*
from
,
*
to
;
if
(
!
arg
)
{
null_value
=
1
;
return
0
;
}
from
=
arg
->
charset
();
to
=
conv_charset
;
s
=
(
const
uchar
*
)
arg
->
ptr
();
se
=
s
+
arg
->
length
();
dmaxlen
=
arg
->
length
()
*
(
conv_charset
->
mbmaxlen
?
conv_charset
->
mbmaxlen
:
1
)
+
1
;
str
->
alloc
(
dmaxlen
);
d0
=
d
=
(
unsigned
char
*
)
str
->
ptr
();
de
=
d
+
dmaxlen
;
while
(
s
<
se
&&
d
<
de
){
cnvres
=
from
->
mb_wc
(
from
,
&
wc
,
s
,
se
);
if
(
cnvres
>
0
)
{
s
+=
cnvres
;
}
else
if
(
cnvres
==
MY_CS_ILSEQ
)
{
s
++
;
wc
=
'?'
;
}
else
break
;
outp:
cnvres
=
to
->
wc_mb
(
to
,
wc
,
d
,
de
);
if
(
cnvres
>
0
)
{
d
+=
cnvres
;
}
else
if
(
cnvres
==
MY_CS_ILUNI
&&
wc
!=
'?'
)
{
wc
=
'?'
;
goto
outp
;
}
else
break
;
};
str
->
length
((
uint
)
(
d
-
d0
));
str
->
set_charset
(
to
);
return
str
;
}
void
Item_func_conv_charset
::
fix_length_and_dec
()
{
/* BAR TODO: What to do here??? */
}
String
*
Item_func_hex
::
val_str
(
String
*
str
)
String
*
Item_func_hex
::
val_str
(
String
*
str
)
{
{
if
(
args
[
0
]
->
result_type
()
!=
STRING_RESULT
)
if
(
args
[
0
]
->
result_type
()
!=
STRING_RESULT
)
...
...
sql/item_strfunc.h
View file @
ae03ccc4
...
@@ -476,6 +476,19 @@ class Item_func_export_set: public Item_str_func
...
@@ -476,6 +476,19 @@ class Item_func_export_set: public Item_str_func
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
3
*
8
+
7
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
3
*
8
+
7
;
}
};
};
class
Item_func_conv_charset
:
public
Item_str_func
{
CHARSET_INFO
*
conv_charset
;
public:
Item_func_conv_charset
(
Item
*
a
,
CHARSET_INFO
*
cs
)
:
Item_str_func
(
a
)
{
conv_charset
=
cs
;
}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
();
const
char
*
func_name
()
const
{
return
"conv_charset"
;
}
};
/*******************************************************
/*******************************************************
Spatial functions
Spatial functions
...
...
sql/sql_yacc.yy
View file @
ae03ccc4
...
@@ -1654,6 +1654,16 @@ simple_expr:
...
@@ -1654,6 +1654,16 @@ simple_expr:
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ); }
{ $$= new Item_func_case(* $4, $2, $5 ); }
| CONVERT_SYM '(' expr ',' cast_type ')' { $$= create_func_cast($3, $5); }
| CONVERT_SYM '(' expr ',' cast_type ')' { $$= create_func_cast($3, $5); }
| CONVERT_SYM '(' expr USING IDENT ')'
{
CHARSET_INFO *cs=find_compiled_charset_by_name($5.str);
if (!cs)
{
net_printf(¤t_thd->net,ER_UNKNOWN_CHARACTER_SET,$5);
YYABORT;
}
$$= new Item_func_conv_charset($3,cs);
}
| FUNC_ARG0 '(' ')'
| FUNC_ARG0 '(' ')'
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
| FUNC_ARG1 '(' expr ')'
| FUNC_ARG1 '(' expr ')'
...
...
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