From: | Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | basti <mailinglist(at)unix-solution(dot)de>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Conditional INSERT |
Date: | 2019-03-15 23:23:43 |
Message-ID: | CAD3a31U5YB8vd4CyKWrbuZoqgiE58SCdOUck6ju9b_yvrZ9Daw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Mar 15, 2019 at 11:59 AM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> On 3/15/19 11:54 AM, basti wrote:
> > this is a dns database, and the client is update the _acme-challenge for
> > LE certificates. I don't want that the client can insert "any" txt
> record.
> > the client should only insert data if the hostname start with
> > _acme-challenge. i have no control on client.
> >
> > i have try this rule but the server reject this with a endless loop:
>
> To borrow a quote:
>
> "I had a problem so I decided to use a rule, now I have two problems."
>
> Do not use a rule. As suggested upstream use a BEFORE INSERT trigger,
> you will be a lot happier.
>
> >
> > CREATE RULE insert_acme AS ON INSERT TO t_dnsadmin_records_txt
> > WHERE NEW.hostname like '_acme-challenge%'
> > DO INSERT INTO t_dnsadmin_records_txt VALUES (
> > NEW.domainid,
> > NEW.hostname,
> > NEW.txtdata
> > );
> >
> >
>
Just curious, but wanted to follow up on whether rules are across-the-board
discouraged? I've seen disparaging comments about them, but I don't see
any indication of that on the create rule page.
The other suggestion in this thread--a foreign key--will throw an error.
Your suggestion of a before trigger might well be better (and if so, why?),
but is there anything particularly wrong or bad about using a rule that
would actually work? Something along these lines:
CREATE RULE insert_acme AS ON INSERT TO t_dnsadmin_records_txt
WHERE NOT NEW.hostname like '_acme-challenge%'
DO INSTEAD NOTHING;
Thanks,
Ken
--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801
Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.
From | Date | Subject | |
---|---|---|---|
Next Message | Morris de Oryx | 2019-03-15 23:30:39 | Re: Camel case identifiers and folding |
Previous Message | Rob Sargent | 2019-03-15 23:09:49 | Re: Camel case identifiers and folding |