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
442509ac
Commit
442509ac
authored
Nov 11, 2002
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USER(), DATABASE() and CHARSET() functions are now UCS2 compatible
Bug fix in ctype-utf8.c
parent
d1fd7bda
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
16 deletions
+33
-16
sql/item_strfunc.cc
sql/item_strfunc.cc
+15
-7
sql/item_strfunc.h
sql/item_strfunc.h
+12
-3
sql/procedure.h
sql/procedure.h
+5
-5
strings/ctype-utf8.c
strings/ctype-utf8.c
+1
-1
No files found.
sql/item_strfunc.cc
View file @
442509ac
...
...
@@ -1366,17 +1366,25 @@ String *Item_func_database::val_str(String *str)
if
(
!
current_thd
->
db
)
str
->
length
(
0
);
else
str
->
set
((
const
char
*
)
current_thd
->
db
,(
uint
)
strlen
(
current_thd
->
db
),
default_charset_info
);
str
->
copy
((
const
char
*
)
current_thd
->
db
,(
uint
)
strlen
(
current_thd
->
db
),
system_charset_info
,
thd_charset
()
);
return
str
;
}
String
*
Item_func_user
::
val_str
(
String
*
str
)
{
THD
*
thd
=
current_thd
;
if
(
str
->
copy
((
const
char
*
)
thd
->
user
,(
uint
)
strlen
(
thd
->
user
),
system_charset_info
)
||
str
->
append
(
'@'
)
||
str
->
append
(
thd
->
host
?
thd
->
host
:
thd
->
ip
?
thd
->
ip
:
""
))
return
&
empty_string
;
THD
*
thd
=
current_thd
;
CHARSET_INFO
*
cs
=
thd_charset
();
const
char
*
host
=
thd
->
host
?
thd
->
host
:
thd
->
ip
?
thd
->
ip
:
""
;
uint32
res_length
=
(
strlen
(
thd
->
user
)
+
strlen
(
host
)
+
10
)
*
cs
->
mbmaxlen
;
if
(
str
->
alloc
(
res_length
))
{
null_value
=
1
;
return
0
;
}
res_length
=
cs
->
snprintf
(
cs
,
(
char
*
)
str
->
ptr
(),
res_length
,
"%s@%s"
,
thd
->
user
,
host
);
str
->
length
(
res_length
);
str
->
set_charset
(
cs
);
return
str
;
}
...
...
@@ -2120,7 +2128,7 @@ String *Item_func_charset::val_str(String *str)
if
((
null_value
=
(
args
[
0
]
->
null_value
||
!
res
->
charset
())))
return
0
;
str
->
copy
(
res
->
charset
()
->
name
,
strlen
(
res
->
charset
()
->
name
),
default_charset_info
);
str
->
copy
(
res
->
charset
()
->
name
,
strlen
(
res
->
charset
()
->
name
),
my_charset_latin1
,
thd_charset
()
);
return
str
;
}
...
...
sql/item_strfunc.h
View file @
442509ac
...
...
@@ -310,7 +310,11 @@ class Item_func_database :public Item_str_func
public:
Item_func_database
()
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
max_length
=
MAX_FIELD_NAME
;
}
void
fix_length_and_dec
()
{
max_length
=
MAX_FIELD_NAME
*
thd_charset
()
->
mbmaxlen
;
set_charset
(
thd_charset
());
}
const
char
*
func_name
()
const
{
return
"database"
;
}
};
...
...
@@ -319,7 +323,11 @@ class Item_func_user :public Item_str_func
public:
Item_func_user
()
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
max_length
=
USERNAME_LENGTH
+
HOSTNAME_LENGTH
+
1
;
}
void
fix_length_and_dec
()
{
max_length
=
(
USERNAME_LENGTH
+
HOSTNAME_LENGTH
+
1
)
*
thd_charset
()
->
mbmaxlen
;
set_charset
(
thd_charset
());
}
const
char
*
func_name
()
const
{
return
"user"
;
}
};
...
...
@@ -567,7 +575,8 @@ class Item_func_charset :public Item_str_func
const
char
*
func_name
()
const
{
return
"charset"
;
}
void
fix_length_and_dec
()
{
max_length
=
20
;
// should be enough
max_length
=
40
;
// should be enough
set_charset
(
thd_charset
());
};
};
...
...
sql/procedure.h
View file @
442509ac
...
...
@@ -62,7 +62,7 @@ class Item_proc_real :public Item_proc
{
value
=
atof
(
str
);
}
double
val
()
{
return
value
;
}
longlong
val_int
()
{
return
(
longlong
)
value
;
}
String
*
val_str
(
String
*
s
)
{
s
->
set
(
value
,
decimals
,
my_thd_charset
);
return
s
;
}
String
*
val_str
(
String
*
s
)
{
s
->
set
(
value
,
decimals
,
thd_charset
()
);
return
s
;
}
unsigned
int
size_of
()
{
return
sizeof
(
*
this
);}
};
...
...
@@ -80,7 +80,7 @@ class Item_proc_int :public Item_proc
{
value
=
strtoll
(
str
,
NULL
,
10
);
}
double
val
()
{
return
(
double
)
value
;
}
longlong
val_int
()
{
return
value
;
}
String
*
val_str
(
String
*
s
)
{
s
->
set
(
value
,
my_thd_charset
);
return
s
;
}
String
*
val_str
(
String
*
s
)
{
s
->
set
(
value
,
thd_charset
()
);
return
s
;
}
unsigned
int
size_of
()
{
return
sizeof
(
*
this
);}
};
...
...
@@ -92,9 +92,9 @@ class Item_proc_string :public Item_proc
{
this
->
max_length
=
length
;
}
enum
Item_result
result_type
()
const
{
return
STRING_RESULT
;
}
enum_field_types
field_type
()
const
{
return
FIELD_TYPE_STRING
;
}
void
set
(
double
nr
)
{
str_value
.
set
(
nr
,
2
,
my_thd_charset
);
}
void
set
(
longlong
nr
)
{
str_value
.
set
(
nr
,
my_thd_charset
);
}
void
set
(
const
char
*
str
,
uint
length
)
{
str_value
.
copy
(
str
,
length
,
my_thd_charset
);
}
void
set
(
double
nr
)
{
str_value
.
set
(
nr
,
2
,
thd_charset
()
);
}
void
set
(
longlong
nr
)
{
str_value
.
set
(
nr
,
thd_charset
()
);
}
void
set
(
const
char
*
str
,
uint
length
)
{
str_value
.
copy
(
str
,
length
,
thd_charset
()
);
}
double
val
()
{
return
atof
(
str_value
.
ptr
());
}
longlong
val_int
()
{
return
strtoll
(
str_value
.
ptr
(),
NULL
,
10
);
}
String
*
val_str
(
String
*
)
...
...
strings/ctype-utf8.c
View file @
442509ac
...
...
@@ -2383,7 +2383,7 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap)
if
(
left_len
<=
plen
*
2
)
plen
=
left_len
/
2
-
1
;
for
(
;
plen
;
plen
--
,
dst
+
+
,
par
++
)
for
(
;
plen
;
plen
--
,
dst
+
=
2
,
par
++
)
{
dst
[
0
]
=
'\0'
;
dst
[
1
]
=
par
[
0
];
...
...
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