Thread: min() and max() with int8

min() and max() with int8

From
Adam Buble
Date:
Hello,
I have some troubles using MIN and MAX aggregation functions with int8
values. If values are small (?) the functions works well, but if the size
of the number grows, or is lower than zero, it does not work well.

Example:
=> CREATE TABLE INT8_TBL(q1 int8, q2 int8);
=> INSERT INTO INT8_TBL VALUES('123','456');
=> select min(q1) from INT8_TBL;
min
---
123
(1 row)

=> INSERT INTO INT8_TBL VALUES('-123','-456');
=> select min(q1) from INT8_TBL;
min
---
  0
(1 row)

max works fine in this scenario, but it depends on values in table. Too
big numbers (but in int8 range) confuse Postgres as well.

What's wrong?

    Adam