Re: [HACKERS] use of SEQ_MINVALUE in btree_gin

2016-07-12 Thread Tom Lane
Peter Eisentraut  writes:
> btree_gin uses SEQ_MINVALUE as a way to get the smallest int64 value.
> This is actually wrong because the smallest int64 value is
> SEQ_MINVALUE-1, so this might be slightly broken.

> The whole thing was done as a convenience when INT64_IS_BUSTED had to be
> considered, but I think we can get rid of that now.  See attached
> proposed patch.

+1.  I agree that this is actually a bug fix, so it should be back-patched.

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] use of SEQ_MINVALUE in btree_gin

2016-07-11 Thread Peter Eisentraut
btree_gin uses SEQ_MINVALUE as a way to get the smallest int64 value.
This is actually wrong because the smallest int64 value is
SEQ_MINVALUE-1, so this might be slightly broken.

The whole thing was done as a convenience when INT64_IS_BUSTED had to be
considered, but I think we can get rid of that now.  See attached
proposed patch.

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
index f74e912..030b610 100644
--- a/contrib/btree_gin/btree_gin.c
+++ b/contrib/btree_gin/btree_gin.c
@@ -223,10 +223,7 @@ GIN_SUPPORT(int4, false, leftmostvalue_int4, btint4cmp)
 static Datum
 leftmostvalue_int8(void)
 {
-   /*
-* Use sequence's definition to keep compatibility.
-*/
-   return Int64GetDatum(SEQ_MINVALUE);
+   return Int64GetDatum(PG_INT64_MIN);
 }
 
 GIN_SUPPORT(int8, false, leftmostvalue_int8, btint8cmp)
@@ -250,10 +247,7 @@ GIN_SUPPORT(float8, false, leftmostvalue_float8, 
btfloat8cmp)
 static Datum
 leftmostvalue_money(void)
 {
-   /*
-* Use sequence's definition to keep compatibility.
-*/
-   return Int64GetDatum(SEQ_MINVALUE);
+   return Int64GetDatum(PG_INT64_MIN);
 }
 
 GIN_SUPPORT(money, false, leftmostvalue_money, cash_cmp)

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers