U140: Range lower bound must be less than or equal to range upper bound
Category: Application / User Errors
SQLSTATE: 22000 (Class 22 - Data Exception: data_exception)
Urgency: medium
SQLSTATE: 22000 (Class 22 - Data Exception: data_exception)
Urgency: medium
Example Postgres Log Output:
ERROR: range lower bound must be less than or equal to range upper bound
CONTEXT: COPY mytable, line 169, column rangecolumn
STATEMENT: COPY public.mytable("rangecolumn") FROM STDIN BINARY
Explanation:
Your application specified a Postgres range type value (for example as part of an INSERT or COPY), with an upper bound value that was lower than the lower bound value.
Postgres requires that you specify the bound values the other way around in this case.
For example, the following SQL would produce the error:
SELECT '[3,2)'::int4range;
ERROR: range lower bound must be less than or equal to range upper bound
LINE 1: SELECT '[3,2)'::int4range;
Changing the order resolves the problem:
SELECT '[2,3)'::int4range;
int4range
-----------
[2,3)
(1 row)
Recommended Action:
Investigate the application code that generated the data being passed to Postgres, and possibly sort the range bounds to ensure that the lower bound is indeed lower than the upper bound.
Learn More:
No additional resources available.
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →