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
5a1b9e1d
Commit
5a1b9e1d
authored
Nov 28, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More use of new string->number conversion functions
parent
e761be55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
25 deletions
+11
-25
sql/field.cc
sql/field.cc
+6
-20
sql/item_strfunc.cc
sql/item_strfunc.cc
+4
-4
sql/item_sum.cc
sql/item_sum.cc
+1
-1
No files found.
sql/field.cc
View file @
5a1b9e1d
...
...
@@ -15,16 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
NOTES:
Some of the number class uses the system functions strtol(), strtoll()...
To avoid patching the end \0 or copying the buffer unnecessary, all calls
to system functions are wrapped to a String object that adds the end null
if it only if it isn't there.
This adds some overhead when assigning numbers from strings but makes
everything simpler.
*/
/*****************************************************************************
** This file implements classes defined in field.h
*****************************************************************************/
...
...
@@ -1592,7 +1582,6 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
}
long
tmp
;
int
error
=
0
;
String
tmp_str
(
from
,
len
,
default_charset_info
);
errno
=
0
;
if
(
unsigned_flag
)
{
...
...
@@ -1603,10 +1592,10 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
error
=
1
;
}
else
tmp
=
(
long
)
strtoul
(
tmp_str
.
c_ptr
()
,
NULL
,
10
);
tmp
=
(
long
)
my_strntoul
(
cs
,
from
,
len
,
NULL
,
10
);
}
else
tmp
=
strtol
(
tmp_str
.
c_ptr
()
,
NULL
,
10
);
tmp
=
my_strntol
(
cs
,
from
,
len
,
NULL
,
10
);
if
(
errno
||
current_thd
->
count_cuted_fields
&&
!
test_if_int
(
from
,
len
))
{
current_thd
->
cuted_fields
++
;
...
...
@@ -1837,7 +1826,6 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
len
--
;
from
++
;
}
longlong
tmp
;
String
tmp_str
(
from
,
len
,
default_charset_info
);
int
error
=
0
;
errno
=
0
;
if
(
unsigned_flag
)
...
...
@@ -1849,10 +1837,10 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
error
=
1
;
}
else
tmp
=
(
longlong
)
strtoull
(
tmp_str
.
c_ptr
()
,
NULL
,
10
);
tmp
=
(
longlong
)
my_strntoull
(
cs
,
from
,
len
,
NULL
,
10
);
}
else
tmp
=
strtoll
(
tmp_str
.
c_ptr
()
,
NULL
,
10
);
tmp
=
my_strntoll
(
cs
,
from
,
len
,
NULL
,
10
);
if
(
errno
||
current_thd
->
count_cuted_fields
&&
!
test_if_int
(
from
,
len
))
{
current_thd
->
cuted_fields
++
;
...
...
@@ -2052,9 +2040,8 @@ void Field_longlong::sql_type(String &res) const
int
Field_float
::
store
(
const
char
*
from
,
uint
len
,
CHARSET_INFO
*
cs
)
{
String
tmp_str
(
from
,
len
,
default_charset_info
);
errno
=
0
;
Field_float
::
store
(
atof
(
tmp_str
.
c_ptr
()
));
Field_float
::
store
(
my_strntod
(
cs
,
from
,
len
,(
char
**
)
NULL
));
if
(
errno
||
current_thd
->
count_cuted_fields
&&
!
test_if_real
(
from
,
len
))
{
current_thd
->
cuted_fields
++
;
...
...
@@ -2314,10 +2301,9 @@ void Field_float::sql_type(String &res) const
int
Field_double
::
store
(
const
char
*
from
,
uint
len
,
CHARSET_INFO
*
cs
)
{
String
tmp_str
(
from
,
len
,
default_charset_info
);
errno
=
0
;
int
error
=
0
;
double
j
=
atof
(
tmp_str
.
c_ptr
()
);
double
j
=
my_strntod
(
cs
,
from
,
len
,(
char
**
)
0
);
if
(
errno
||
current_thd
->
count_cuted_fields
&&
!
test_if_real
(
from
,
len
))
{
current_thd
->
cuted_fields
++
;
...
...
sql/item_strfunc.cc
View file @
5a1b9e1d
...
...
@@ -54,14 +54,14 @@ double Item_str_func::val()
{
String
*
res
;
res
=
val_str
(
&
str_value
);
return
res
?
atof
(
res
->
c_ptr
()
)
:
0.0
;
return
res
?
my_strntod
(
res
->
charset
(),
res
->
ptr
(),
res
->
length
(),
NULL
)
:
0.0
;
}
longlong
Item_str_func
::
val_int
()
{
String
*
res
;
res
=
val_str
(
&
str_value
);
return
res
?
strtoll
(
res
->
c_ptr
(),
NULL
,
10
)
:
(
longlong
)
0
;
return
res
?
my_strntoll
(
res
->
charset
(),
res
->
ptr
(),
res
->
length
(),
NULL
,
10
)
:
(
longlong
)
0
;
}
...
...
@@ -1905,9 +1905,9 @@ String *Item_func_conv::val_str(String *str)
}
null_value
=
0
;
if
(
from_base
<
0
)
dec
=
strtoll
(
res
->
c_ptr
(),
&
endptr
,
-
from_base
);
dec
=
my_strntoll
(
res
->
charset
(),
res
->
ptr
(),
res
->
length
(),
&
endptr
,
-
from_base
);
else
dec
=
(
longlong
)
strtoull
(
res
->
c_ptr
(),
&
endptr
,
from_base
);
dec
=
(
longlong
)
my_strntoull
(
res
->
charset
(),
res
->
ptr
(),
res
->
length
(),
&
endptr
,
from_base
);
ptr
=
longlong2str
(
dec
,
ans
,
to_base
);
if
(
str
->
copy
(
ans
,(
uint32
)
(
ptr
-
ans
),
thd_charset
()))
return
&
empty_string
;
...
...
sql/item_sum.cc
View file @
5a1b9e1d
...
...
@@ -334,7 +334,7 @@ double Item_sum_hybrid::val()
switch
(
hybrid_type
)
{
case
STRING_RESULT
:
String
*
res
;
res
=
val_str
(
&
str_value
);
return
res
?
atof
(
res
->
c_ptr
()
)
:
0.0
;
return
res
?
my_strntod
(
res
->
charset
(),
res
->
ptr
(),
res
->
length
(),(
char
**
)
0
)
:
0.0
;
case
INT_RESULT
:
if
(
unsigned_flag
)
return
ulonglong2double
(
sum_int
);
...
...
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