Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id XAA16516; Thu, 27 Jan 2000 23:49:21 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id XAA09488; Thu, 27 Jan 2000 23:49:14 -0500 (EST) To: John Brothers cc: pgsql-general@hub.org, pgsql-sql@hub.org Subject: Re: [SQL] RE: [GENERAL] Problem with SELECT on large negative INT4 In-reply-to: <4.1.20000127224856.00c97350@pop.mindspring.com> References: <4.1.20000127224856.00c97350@pop.mindspring.com> Comments: In-reply-to John Brothers message dated "Thu, 27 Jan 2000 22:51:40 -0500" Date: Thu, 27 Jan 2000 23:49:14 -0500 Message-ID: <9485.949034954@sss.pgh.pa.us> From: Tom Lane John Brothers writes: > I don't think that patch will work - Hiroshi whipped up that patch for > me a week ago for a different problem - we have a table with duplicate > primary keys, which seems to be an arithmetic overflow problem because > the index key values can be both very large positive and very large > negative numbers. Actually, if Nicolas' table contains both very large positive and very large negative integers, then his index could be messed up pretty badly. What Hiroshi saw (and I missed :-() was that btint4cmp can fail and return a result of the wrong sign if the difference between two integers overflows. Since index sorting depends critically on the assumption that the comparator always returns consistent results (a < b and b < c must imply a < c, but this can fail if a - c overflows), you could have an out-of-order index. And then probes into the index could fail to find items they should find ... which is exactly the complained-of symptom. Hiroshi neglected to mention that you'd probably need to drop and recreate the index after applying the patch; if it's indeed out of order, just patching the comparator bug isn't enough to fix it. regards, tom lane