Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Abuhujair Javed
Postgres FD Implementation
Commits
286d1fc3
Commit
286d1fc3
authored
Mar 14, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix numeric modulo operator for case of fractional right argument.
parent
2e7835f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numeric.c
+7
-4
No files found.
src/backend/utils/adt/numeric.c
View file @
286d1fc3
...
...
@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.3
6 2000/12/07 02:47:35
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.3
7 2001/03/14 16:50:37
tgl Exp $
*
* ----------
*/
...
...
@@ -3355,16 +3355,19 @@ mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
init_var
(
&
tmp
);
/* ----------
* We do it by fiddling around with global_rscale and truncating
* the result of the division.
* We do this using the equation
* mod(x,y) = x - trunc(x/y)*y
* We fiddle a bit with global_rscale to control result precision.
* ----------
*/
save_global_rscale
=
global_rscale
;
global_rscale
=
var2
->
rscale
+
2
;
div_var
(
var1
,
var2
,
&
tmp
);
/* do trunc() by forgetting digits to the right of the decimal point */
tmp
.
ndigits
=
MAX
(
0
,
MIN
(
tmp
.
ndigits
,
tmp
.
weight
+
1
));
tmp
.
rscale
=
var2
->
rscale
;
tmp
.
ndigits
=
MAX
(
0
,
MIN
(
tmp
.
ndigits
,
tmp
.
weight
+
tmp
.
rscale
+
1
));
global_rscale
=
var2
->
rscale
;
mul_var
(
var2
,
&
tmp
,
&
tmp
);
...
...
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