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
42263a2b
Commit
42263a2b
authored
Mar 27, 2014
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
43498927
aef0b4a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
sql/field.cc
sql/field.cc
+11
-2
No files found.
sql/field.cc
View file @
42263a2b
...
@@ -1175,6 +1175,15 @@ inline ulonglong char_prefix_to_ulonglong(uchar *src)
...
@@ -1175,6 +1175,15 @@ inline ulonglong char_prefix_to_ulonglong(uchar *src)
return
uint8korr
(
src
);
return
uint8korr
(
src
);
}
}
/*
Compute res = a - b, without losing precision and taking care that these are
unsigned numbers.
*/
static
inline
double
safe_substract
(
ulonglong
a
,
ulonglong
b
)
{
return
(
a
>
b
)
?
double
(
a
-
b
)
:
-
double
(
b
-
a
);
}
/**
/**
@brief
@brief
...
@@ -1227,10 +1236,10 @@ double Field::pos_in_interval_val_str(Field *min, Field *max, uint data_offset)
...
@@ -1227,10 +1236,10 @@ double Field::pos_in_interval_val_str(Field *min, Field *max, uint data_offset)
minp
=
char_prefix_to_ulonglong
(
minp_prefix
);
minp
=
char_prefix_to_ulonglong
(
minp_prefix
);
maxp
=
char_prefix_to_ulonglong
(
maxp_prefix
);
maxp
=
char_prefix_to_ulonglong
(
maxp_prefix
);
double
n
,
d
;
double
n
,
d
;
n
=
mp
-
minp
;
n
=
safe_substract
(
mp
,
minp
)
;
if
(
n
<
0
)
if
(
n
<
0
)
return
0.0
;
return
0.0
;
d
=
maxp
-
minp
;
d
=
safe_substract
(
maxp
,
minp
)
;
if
(
d
<=
0
)
if
(
d
<=
0
)
return
1.0
;
return
1.0
;
return
MY_MIN
(
n
/
d
,
1.0
);
return
MY_MIN
(
n
/
d
,
1.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