From: Tom Lane <tgl@sss.pgh.pa.us>
To: stan <stanb@panix.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
Date: Mon, 16 Sep 2019 00:12:34 -0400
Message-ID: <10128.1568607154@sss.pgh.pa.us> (raw)
In-Reply-To: <20190916010439.GA7478@panix.com>
References: <20190915174649.GB2078@panix.com>
<50d5b256-74b9-1949-a634-0df37cbfb783@aklaver.com>
<20190916010439.GA7478@panix.com>
stan <stanb@panix.com> writes:
> On Sun, Sep 15, 2019 at 12:27:14PM -0700, Adrian Klaver wrote:
>> On 9/15/19 10:46 AM, stan wrote:
>>> So, my test tell me that the validity check is done BEFORE an attempt to
>>> insert (thus firing the trigger) occurs.
>> What validity check?
> The check to see if it is the type enum.
Indeed, a trigger cannot fix an input-validity error, because that
will happen while trying to form the row value that would be passed
to the trigger. So I guess that when you say "the trigger doesn't
fire" you really mean "this other error is raised first".
However, I still don't understand your claim that it works the
way you wanted in an INSERT statement. The enum input function
is going to complain in either context.
Generally you need to fix issues like this before trying to
insert the data into your table. You might try preprocessing
the data file before feeding it to COPY. Another way is to
copy into a temporary table that has very lax column data types
(all "text", perhaps) and then transform the data using
INSERT ... SELECT from the temp table to the final storage table.
regards, tom lane
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: tgl@sss.pgh.pa.us, stanb@panix.com, adrian.klaver@aklaver.com
Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
In-Reply-To: <10128.1568607154@sss.pgh.pa.us>
References: <20190915174649.GB2078@panix.com> <50d5b256-74b9-1949-a634-0df37cbfb783@aklaver.com> <20190916010439.GA7478@panix.com> <10128.1568607154@sss.pgh.pa.us>
* 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