Thread: Primary Key Indexing problem

Primary Key Indexing problem

From
John Brothers
Date:
HI all,

    I have a script which generates a simple table, fills it with
about 11000 unique numbers, in the primary key field,
and then at the end, shows that the index has been
lost for at least one of the values, allowing another
entry to be made that duplicates the index.   This is an
abstract simplification of a problem we are experiencing in
our field database.

  The compressed "script" is 64k - I didn't want to attach it to this
message, but I would be happy to send it to anyone who might
be able to use it to track down whatever bug(s) might be causing
it. (I am assuming that this is a bug.  If not, please accept my
apologies).

[PostgreSQL 6.5.1 on i686-pc-linux-gnu, compiled by gcc 2.7.2.3]

Thanks,

    John
------------
johnbr@incanta.net



RE: [GENERAL] Primary Key Indexing problem

From
"Hiroshi Inoue"
Date:
> -----Original Message-----
> From: owner-pgsql-general@postgreSQL.org
> [mailto:owner-pgsql-general@postgreSQL.org]On Behalf Of John Brothers
>
> HI all,
>
>     I have a script which generates a simple table, fills it with
> about 11000 unique numbers, in the primary key field,
> and then at the end, shows that the index has been
> lost for at least one of the values, allowing another
> entry to be made that duplicates the index.   This is an
> abstract simplification of a problem we are experiencing in
> our field database.
>
>   The compressed "script" is 64k - I didn't want to attach it to this
> message, but I would be happy to send it to anyone who might
> be able to use it to track down whatever bug(s) might be causing
> it. (I am assuming that this is a bug.  If not, please accept my
> apologies).
>
> [PostgreSQL 6.5.1 on i686-pc-linux-gnu, compiled by gcc 2.7.2.3]
>

The following patch seems to fix your problem.

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp

*** nbtcompare.c        2000/01/11 03:33:34     1.3
--- nbtcompare.c        2000/01/19 05:42:06
***************
*** 34,40 ****
  int32
  btint4cmp(int32 a, int32 b)
  {
!       return a - b;
  }

  int32
--- 34,45 ----
  int32
  btint4cmp(int32 a, int32 b)
  {
!       if (a > b)
!               return 1;
!       else if (a == b)
!               return 0;
!       else
!               return -1;
  }

  int32