2201E — invalid_argument_for_logarithm
Logarithm functions reject zero and negative inputs at their defined-domain guards. Fixed float paths report cannot take logarithm of zero or cannot take logarithm of a negative number; numeric ln and base-log paths apply the same SQLSTATE while handling NaN and infinities separately.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Data Exception
- condition name
- invalid_argument_for_logarithm
- lang
- en
- sqlstate
- 2201E
Definition PG 18
2201E
At a glance {#at-a-glance}
Logarithm functions reject zero and negative inputs at their defined-domain guards. Fixed float paths report cannot take logarithm of zero or cannot take logarithm of a negative number; numeric ln and base-log paths apply the same SQLSTATE while handling NaN and infinities separately.
Meaning {#meaning}
2201E is a logarithm domain error, not a generic numeric overflow. In float.c, ln() and log() reject an argument equal to zero and then one less than zero. Numeric ln rejects negative infinity but returns numeric NaN or positive infinity unchanged; numeric base-log rejects a negative or zero base/argument and has defined NaN/infinity results for some positive special-value combinations.
Diagnosis {#diagnosis}
Read the function signature and the actual numeric type before changing the value. Match the primary message: zero and negative inputs are different guards. For float inputs, NaN does not satisfy either comparison and therefore is not this particular guard; later float overflow or underflow reports are separate conditions. Preserve the input and business rule while checking whether the logarithm domain is really intended.
Response {#response}
Supply a value in the domain required by the named logarithm function, or change the business rule explicitly. If an ERROR occurred inside an explicit transaction, roll back or roll back to the existing savepoint before retrying; an autocommit client can retry the corrected statement. Casting blindly can move the value without making the operation defined.
Versions {#versions}
The locked catalogue records this condition from 8.0.0; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.
Related {#related}
Sources {#sources}
Fixed paths include src/backend/utils/adt/float.c#L1687-1747 and src/backend/utils/adt/numeric.c#L3935-4020 plus #L11156-11168, which bind the zero/negative guards and special-value branches. The structured evidence record retains the exact message roles and scope boundary; no natural runtime was run.
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read the fixed errcodes row and macro.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2201E is invalid_argument_for_logarithm in SQLSTATE Class 22"
}claims · resolved-path
{
"claim_id": "resolved-path",
"limits": "Source confirmation is not a natural runtime observation.",
"method": "Read complete source contexts for the representative guards.",
"position": 1,
"runtime": [],
"sources": [
"src.float.log",
"src.numeric.log",
"src.numeric.ln.finite"
],
"statement": "Fixed PostgreSQL 18.6 float and numeric logarithm paths bind zero/negative guards and distinct NaN/infinity handling for both ln and base-log operations."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue presence and history boundaries.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 2201E from 8.0.0 without proving an exact implementation introduction date."
}messages · message.zero
{
"limits": "",
"message_id": "message.zero",
"path": "",
"position": 0,
"raw": {
"id": "message.zero",
"primary_template": "cannot take logarithm of zero",
"severity_source": "ERROR",
"sources": [
"src.float.log",
"src.numeric.log",
"src.numeric.ln.finite"
],
"sqlstate": "2201E"
},
"severity": "ERROR",
"sources": [
"src.float.log",
"src.numeric.log",
"src.numeric.ln.finite"
],
"templates": [
{
"kind": "primary",
"literal": "cannot take logarithm of zero",
"position": 0,
"role": "",
"template": "cannot take logarithm of zero"
}
]
}messages · message.negative
{
"limits": "",
"message_id": "message.negative",
"path": "",
"position": 1,
"raw": {
"id": "message.negative",
"primary_template": "cannot take logarithm of a negative number",
"severity_source": "ERROR",
"sources": [
"src.float.log",
"src.numeric.log",
"src.numeric.ln.finite"
],
"sqlstate": "2201E"
},
"severity": "ERROR",
"sources": [
"src.float.log",
"src.numeric.log",
"src.numeric.ln.finite"
],
"templates": [
{
"kind": "primary",
"literal": "cannot take logarithm of a negative number",
"position": 0,
"role": "",
"template": "cannot take logarithm of a negative number"
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L173"
}sources · src.float.log
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/float.c",
"position": 1,
"sha256": "58914ae93c06c281e581a4bb2dcf2280e4ae1619f3ceb8f801f50beca87eecd8",
"source_id": "src.float.log",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/float.c#L1687"
}sources · src.numeric.log
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/numeric.c",
"position": 2,
"sha256": "6cde7cd60b3330b83be35d1f014045f5fb5fe737f3c5db4c8ed4080b99f2b666",
"source_id": "src.numeric.log",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/numeric.c#L3935"
}sources · src.numeric.ln.finite
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/numeric.c",
"position": 3,
"sha256": "6cde7cd60b3330b83be35d1f014045f5fb5fe737f3c5db4c8ed4080b99f2b666",
"source_id": "src.numeric.ln.finite",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/numeric.c#L11156"
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:a92aece2256db02908d389611b2095ed53aa45d6da34ae4d4c5dda015e0264a8
Text language: en · english-manuals:a92aece2256db02908d389611b2095ed53aa45d6da34ae4d4c5dda015e0264a8