2201E
Read PG 18 manual ↗invalid_argument_for_logarithm
- SQLSTATE
- 2201E
- Condition name
- invalid_argument_for_logarithm
- Class
- Data Exception
- Source macro
- ERRCODE_INVALID_ARGUMENT_FOR_LOG
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
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
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
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
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
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.
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.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
2201E is invalid_argument_for_logarithm in SQLSTATE Class 22
Method: Read the fixed errcodes row and macro.
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.
Method: Read complete source contexts for the representative guards.
Limits: Source confirmation is not a natural runtime observation.
The locked catalogue records 2201E from 8.0.0 without proving an exact implementation introduction date.
Method: Use catalogue presence and history boundaries.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/utils/adt/float.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/utils/adt/numeric.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/utils/adt/numeric.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.zero
Primary
cannot take logarithm of zero
ERROR · message.negative
Primary
cannot take logarithm of a negative number
Reproduction & repair cases
No reproduction case is attached to this condition.
Recorded runtime evidence
No runtime observation is attached to this entry.
Definition snapshot: english-manuals:4df9e83cc1331d6566c9bcf3043… · English manual source