NULL vs. `infinity` in PostgreSQL range types

后端 未结 1 469
失恋的感觉
失恋的感觉 2021-01-12 17:32

What is the meaning of \'infinity\' in PostgreSQL range types? Is there any difference between specifying infinity or -infinity as a bound, or

相关标签:
1条回答
  • 2021-01-12 18:01

    NULL does the same thing for the overlap operator && as -infinity or infinity, respectively. I quote the manual here:

    Using NULL for either bound causes the range to be unbounded on that side.

    But as value, NULL is still distinct from 'infinity'!

    SELECT tstzrange('-infinity','infinity') = tstzrange(NULL, NULL);
    

    Returns FALSE (not NULL, mind you!).

    More in this SQLfiddle.

    0 讨论(0)
提交回复
热议问题