Re: Rules und crypt Problem

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-de-allgemein(at)postgresql(dot)org
Subject: Re: Rules und crypt Problem
Date: 2008-10-26 15:54:22
Message-ID: 20081026155422.GA7344@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-de-allgemein

Oliver Kamzol <itsok(at)okamzol(dot)de> schrieb:
> Funktioniert. Aber ich möchte jetzt gerne, daß das pw Feld per crypt
> verschlüsselt wird, auch wenn die Applikation nur plain übergibt, also
> nur 'me' und 'pass'. Also dachte ich, ich kann das mit einer Regel lösen:
>
> => CREATE RULE pw_tt AS ON INSERT TO tt
> -> DO INSTEAD
> -> INSERT INTO tt VALUES (NEW.un, crypt(NEW.pw, gen_salt('bf')));
> CREATE RULE
>
> => insert into tt values ('me', 'pass');
> FEHLER:  unendliche Rekursion entdeckt in Regeln für Relation »tt«
>
>
> Kann mir bitte jemand erklären, wo hier der Fehler liegt? Ich schein
> betriebsblind zu sein, aber ich weiß nicht, woher er die Rekursionen holt...

Die RULE macht bei insert ein instead insert. Die Rule für das Insert
ist wieder ein... richtig, insert.

Ich würde das eher als TRIGGER machen.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Responses

Browse pgsql-de-allgemein by date

  From Date Subject
Next Message Oliver Kamzol 2008-10-26 22:02:20 Re: Rules und crypt Problem
Previous Message Oliver Kamzol 2008-10-25 09:59:08 Rules und crypt Problem