public inbox for [email protected]
help / color / mirror / Atom feedRe: Strange behaviors with ranges
2+ messages / 2 participants
[nested] [flat]
* Re: Strange behaviors with ranges
@ 2024-08-27 17:37 Adrian Klaver <[email protected]>
2024-08-27 17:51 ` Re: Strange behaviors with ranges Torsten Förtsch <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Klaver @ 2024-08-27 17:37 UTC (permalink / raw)
To: Jean-Christophe Boggio <[email protected]>; [email protected]
On 8/27/24 10:29 AM, Jean-Christophe Boggio wrote:
> Hello,
>
> I have 2 very confusing behaviors when using ranges.
>
> It all started with this query:
>
> WITH rangespaliers AS (
> SELECT numrange( qtep1+1 , qtep2, '[]') AS rangep FROM
> paliers JOIN tmp_limitcontrats USING(idcontrat)
> -- SELECT numrange( qtep1+1 , qtep2, '[]') AS rangep FROM
> paliers WHERE idcontrat=1003
> )
> ,rangespaliers2 AS (
> select *
> FROM rangespaliers
> WHERE rangep <> NUMRANGE(NULL, NULL) -- ERROR IS HERE
> )
> select * from rangespaliers2;
>
> When I run this query, I get the error "Range lower bound must be less
> than or equal to range upper bound".
>
> (a) If I comment out the line marked "ERROR IS HERE", I don't have an
> error (but I'm missing the filter of course).
>
> (b) Also, if I uncomment line 3 and comment out line 2, I get the
> correct behavior. Very strange thing is that tmp_limitcontrats has only
> one row which contains "idcontrat=1003".
What does:
SELECT numrange( qtep1+1 , qtep2, '[]') AS rangep FROM paliers WHERE
idcontrat=1003
return?
>
> This fails on PG 16.4 and 15.7
>
> Thanks a lot for your enlightenment.
>
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Strange behaviors with ranges
2024-08-27 17:37 Re: Strange behaviors with ranges Adrian Klaver <[email protected]>
@ 2024-08-27 17:51 ` Torsten Förtsch <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Torsten Förtsch @ 2024-08-27 17:51 UTC (permalink / raw)
To: Adrian Klaver <[email protected]>; +Cc: Jean-Christophe Boggio <[email protected]>; [email protected]
I guess this query comes back non-empty:
SELECT * FROM paliers JOIN tmp_limitcontrats USING(idcontrat) WHERE
qtep1 >= qtep2
This would then lead somewhere to this expression numrange(3,2)
Check out idpalier=805
On Tue, Aug 27, 2024 at 7:37 PM Adrian Klaver <[email protected]>
wrote:
>
>
> On 8/27/24 10:29 AM, Jean-Christophe Boggio wrote:
> > Hello,
> >
> > I have 2 very confusing behaviors when using ranges.
> >
> > It all started with this query:
> >
> > WITH rangespaliers AS (
> > SELECT numrange( qtep1+1 , qtep2, '[]') AS rangep FROM
> > paliers JOIN tmp_limitcontrats USING(idcontrat)
> > -- SELECT numrange( qtep1+1 , qtep2, '[]') AS rangep FROM
> > paliers WHERE idcontrat=1003
> > )
> > ,rangespaliers2 AS (
> > select *
> > FROM rangespaliers
> > WHERE rangep <> NUMRANGE(NULL, NULL) -- ERROR IS HERE
> > )
> > select * from rangespaliers2;
> >
> > When I run this query, I get the error "Range lower bound must be less
> > than or equal to range upper bound".
> >
> > (a) If I comment out the line marked "ERROR IS HERE", I don't have an
> > error (but I'm missing the filter of course).
> >
> > (b) Also, if I uncomment line 3 and comment out line 2, I get the
> > correct behavior. Very strange thing is that tmp_limitcontrats has only
> > one row which contains "idcontrat=1003".
>
> What does:
>
> SELECT numrange( qtep1+1 , qtep2, '[]') AS rangep FROM paliers WHERE
> idcontrat=1003
>
> return?
>
>
> >
> > This fails on PG 16.4 and 15.7
> >
> > Thanks a lot for your enlightenment.
> >
>
> --
> Adrian Klaver
> [email protected]
>
>
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-08-27 17:51 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 17:37 Re: Strange behaviors with ranges Adrian Klaver <[email protected]>
2024-08-27 17:51 ` Torsten Förtsch <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox