From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Martin Jacobs <100(dot)179370(at)germanynet(dot)de> |
Cc: | PGSQL Mailinglist <pgsql-general(at)hub(dot)org> |
Subject: | Re: RI violated, bug or feature? |
Date: | 2000-10-15 06:16:01 |
Message-ID: | Pine.BSF.4.10.10010142312420.67171-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, 14 Oct 2000, Martin Jacobs wrote:
> Hi,
>
> my 7.0.2 runs no stable, all tests except one numerical (least
> signifcant digit was off by one) ran successfull. No I did play
> with RI and discovered the following:
>
> Lets create two tables:
>
> test_ri=> create table publisher (name char(20));
> CREATE
>
> test_ri=> create index publ on publisher (name);
> CREATE
>
> test_ri=> create table books (title char(32), publisher char(20)
> references publisher(name));
> NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
> CREATE
>
> Now let's insert some data:
>
> test_ri=> insert into publisher (name) values ('prentice');
> INSERT 35900 1
> test_ri=> insert into publisher (name) values ('addison');
> INSERT 35901 1
> test_ri=> insert into publisher (name) values ('springer');
> INSERT 35902 1
>
> and at least
>
> test_ri=> insert into books (title) values ('violated');
> INSERT 35903 1
>
> Hey, I have now a row in books, which has no corresponding
> publisher entry. Let's do another test:
>
True, but it is NULL which is explicitly allowed by the spec.
(If no <match type> was specified then, for each row R1 of the
referencing table, either at least one of the values of the
referencing columns in R1 shall be a null value, or the value of
each referencing column in R1 shall be equal to the value of the
corresponding referenced column in some row of the referenced
table.)
So, that's not a violation of the constraint. If you want to
disallow nulls, you have to explicitly make the column
NOT NULL.
From | Date | Subject | |
---|---|---|---|
Next Message | Warren Flemmer | 2000-10-15 08:41:31 | Fw: Postgresql 7 does not always start on RH 6.2 |
Previous Message | Tom Lane | 2000-10-15 04:21:42 | Re: [Solved] SQL Server to PostgreSQL |