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
f8df836a
Commit
f8df836a
authored
May 09, 2008
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust power() error messages to be more descriptive.
parent
31590406
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
src/backend/utils/adt/float.c
src/backend/utils/adt/float.c
+7
-4
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numeric.c
+10
-6
No files found.
src/backend/utils/adt/float.c
View file @
f8df836a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.15
6 2008/05/09 15:36:06
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.15
7 2008/05/09 21:31:23
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1334,11 +1334,14 @@ dpow(PG_FUNCTION_ARGS)
* certain error conditions. Specifically, we don't return a divide-by-zero
* error code for 0 ^ -1.
*/
if
((
arg1
==
0
&&
arg2
<
0
)
||
(
arg1
<
0
&&
floor
(
arg2
)
!=
arg2
))
if
(
arg1
==
0
&&
arg2
<
0
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION
),
errmsg
(
"invalid argument for power function"
)));
errmsg
(
"zero raised to a negative power is undefined"
)));
if
(
arg1
<
0
&&
floor
(
arg2
)
!=
arg2
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION
),
errmsg
(
"a negative number raised to a non-integer power yields a complex result"
)));
/*
* pow() sets errno only on some platforms, depending on whether it
...
...
src/backend/utils/adt/numeric.c
View file @
f8df836a
...
...
@@ -14,7 +14,7 @@
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.11
3 2008/05/09 15:36:06
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.11
4 2008/05/09 21:31:23
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1897,13 +1897,17 @@ numeric_power(PG_FUNCTION_ARGS)
* certain error conditions. Specifically, we don't return a divide-by-zero
* error code for 0 ^ -1.
*/
if
((
cmp_var
(
&
arg1
,
&
const_zero
)
==
0
&&
cmp_var
(
&
arg2
,
&
const_zero
)
<
0
)
||
(
cmp_var
(
&
arg1
,
&
const_zero
)
<
0
&&
cmp_var
(
&
arg2
,
&
arg2_trunc
)
!=
0
))
if
(
cmp_var
(
&
arg1
,
&
const_zero
)
==
0
&&
cmp_var
(
&
arg2
,
&
const_zero
)
<
0
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION
),
errmsg
(
"invalid argument for power function"
)));
errmsg
(
"zero raised to a negative power is undefined"
)));
if
(
cmp_var
(
&
arg1
,
&
const_zero
)
<
0
&&
cmp_var
(
&
arg2
,
&
arg2_trunc
)
!=
0
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION
),
errmsg
(
"a negative number raised to a non-integer power yields a complex result"
)));
/*
* Call power_var() to compute and return the result; note it handles
...
...
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