Re: uniqueness not always correct

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: uniqueness not always correct
Дата
Msg-id 200005312328.TAA04102@candle.pha.pa.us
обсуждение исходный текст
Ответ на uniqueness not always correct  (Frank Cusack <fcusack@iconnet.net>)
Ответы Re: uniqueness not always correct  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
This bug appears to still exist in 7.0:

    test=> create table test (zone int4, net cidr, unique(zone, net));
    NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'test_zone_key'
    for table 'test'
    CREATE
    test=> insert into test (zone, net) values (1, '1.2.3/24');
    INSERT 22157 1
    test=> insert into test (zone, net) values (1, '2.3.4/24');
    INSERT 22158 1
    test=> select * from test;
     zone |   net
    ------+----------
        1 | 1.2.3/24
        1 | 2.3.4/24
    (2 rows)

    test=> insert into test (zone, net) values (1, '2.3.4/24');
    INSERT 22159 1
    test=>


> Solaris 2.6/sparc; postgres 6.5.1
>
> dns=> create table test (zone int4, net cidr, unique(zone, net));
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'test_zone_key' for table 'test'
> CREATE
> dns=> insert into test (zone, net) values (1, '1.2.3/24');
> INSERT 21750 1
> dns=> insert into test (zone, net) values (1, '2.3.4/24');
> INSERT 21751 1
> dns=> insert into test (zone, net) values (1, '1.2.3/24');
> INSERT 21752 1
> dns=> insert into test (zone, net) values (1, '2.3.4/24');
> ERROR:  Cannot insert a duplicate key into a unique index
> dns=> select * from test;
> zone|net
> - ----+--------
>    1|1.2.3/24
>    1|2.3.4/24
>    1|1.2.3/24
> (3 rows)
>
>
> Once a unique error is reported, uniqueness seems to be maintained.
> Also, if you enter 4 values, then try a duplicate, it all works.
>
> The threshold seems to be 3.
>
> A select before the duplicate add also seems to fix it.
>
> ~f
>
>
>
> ************
>
>


--
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Failures with arrays
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: uniqueness not always correct