Обсуждение: FK creation -- "ON DELETE NO ACTION" seems to be a no-op

Поиск
Список
Период
Сортировка

FK creation -- "ON DELETE NO ACTION" seems to be a no-op

От
"Webb Sprague"
Дата:
Hi list,

First, my select version() gives:

PostgreSQL 8.2.4 on x86_64-pc-linux-gnu, compiled by GCC
x86_64-pc-linux-gnu-gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.0.2)

The Problem:  when I run

ALTER TABLE currentsessions ADD CONSTRAINT
currentsessions_username_fkey FOREIGN KEY (username) REFERENCES
authorizedusers on delete no action on update cascade;

It is not updating the table correctly to reflect the "no action".
After \d currentsessions (and some editing) I get the following,
which, as I understand it, should say something about the "ON DELETE
NO ACTION":

  ... "currentsessions_username_fkey" FOREIGN KEY (username)
REFERENCES authorizedusers(username) ON UPDATE CASCADE

However, if I drop the constraint and rebuild it with

ALTER TABLE currentsessions ADD CONSTRAINT
currentsessions_username_fkey FOREIGN KEY (username) REFERENCES
authorizedusers on delete cascade on update cascade;

I get:

  ... "currentsessions_username_fkey" FOREIGN KEY (username)
REFERENCES authorizedusers(username) ON UPDATE CASCADE ON DELETE
CASCADE

Is this a bug or a strange thing I had thought I understood?  Or has
it been fixed in 8.2.5 ("Fix incorrect handling of some foreign-key
corner cases (Tom)" -- from the release notes)

If anyone wants more data, just holler.

Thanks
W

Re: FK creation -- "ON DELETE NO ACTION" seems to be a no-op

От
Alvaro Herrera
Дата:
Webb Sprague escribió:

> It is not updating the table correctly to reflect the "no action".
> After \d currentsessions (and some editing) I get the following,
> which, as I understand it, should say something about the "ON DELETE
> NO ACTION":
>
>   ... "currentsessions_username_fkey" FOREIGN KEY (username)
> REFERENCES authorizedusers(username) ON UPDATE CASCADE

Hmm, NO ACTION is the default.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Re: FK creation -- "ON DELETE NO ACTION" seems to be a no-op

От
"Webb Sprague"
Дата:
> >
> >   ... "currentsessions_username_fkey" FOREIGN KEY (username)
> > REFERENCES authorizedusers(username) ON UPDATE CASCADE
>
> Hmm, NO ACTION is the default.

Oh, how embarrassing.  Never mind...

>
> --
> Alvaro Herrera                                http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>