From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Me again with an insert trigger problem
Date: Tue, 27 Feb 2024 14:20:52 -0800
Message-ID: <f03929e9-4188-4b21-9f64-e7929d68933d@aklaver.com> (raw)
In-Reply-To: <d56f1205-ff78-42f6-8735-25c5129b1ffa@gelassene-pferde.biz>
References: <0eb1e688-009a-4eaf-873a-931e3fd79d6b@gelassene-pferde.biz>
<d033108d-3aea-483c-96b6-8217fcda945a@aklaver.com>
<72bb6841-7f48-4d0f-8dac-a36bdc24ec56@gelassene-pferde.biz>
<df6c9695-eb3a-4a9e-a7b0-d72a726b254a@aklaver.com>
<d56f1205-ff78-42f6-8735-25c5129b1ffa@gelassene-pferde.biz>
On 2/27/24 14:11, Thiemo Kellner wrote:
> Am 27.02.2024 um 21:42 schrieb Adrian Klaver:
>> Also not sure what this:
>>
>> select NODE_TYPE⠒NAME into V⠒NODE_TYPE⠒NAME
>> from NODE⠒V
>> where 1 = 1
>> and ID = new.NODE⠒ID
>> and 1 = 1;
>>
>> is supposed to be doing especially the 1 = 1 tests?
>
> The select retrieves the type of the node in order to determine whether
> a task name must be given or not.
>
> It is a habit of mine to pad conditions in the where clause. This way,
> it is easy to comment/uncomment parts of the clause for testing
> purposes. Coming from Oracle, I missed that using "true" is also
> possible and better because clearer.
create table true_test(id integer);
insert into true_test select * from generate_series(1, 10000);
select count(*) from true_test where true;
count
-------
10000
(1 row)
select count(*) from true_test where id < 100 and true;
count
-------
99
>
>> Seems '... where ID = new.NODE⠒ID ...' is sufficient.
>
> Right. Semantically sufficient.
>
>
>> Also what do you want to return as NEW?
>
> The unchanged new record. And it works as intended.
>
> Thanks for your help!
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, thiemo@gelassene-pferde.biz
Subject: Re: Me again with an insert trigger problem
In-Reply-To: <f03929e9-4188-4b21-9f64-e7929d68933d@aklaver.com>
References: <0eb1e688-009a-4eaf-873a-931e3fd79d6b@gelassene-pferde.biz> <d033108d-3aea-483c-96b6-8217fcda945a@aklaver.com> <72bb6841-7f48-4d0f-8dac-a36bdc24ec56@gelassene-pferde.biz> <df6c9695-eb3a-4a9e-a7b0-d72a726b254a@aklaver.com> <d56f1205-ff78-42f6-8735-25c5129b1ffa@gelassene-pferde.biz> <f03929e9-4188-4b21-9f64-e7929d68933d@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox