Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9WwJ-0002Oq-73 for pgsql-general@arkaria.postgresql.org; Sun, 15 Sep 2019 15:59:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i9WwH-0001qG-Sv for pgsql-general@arkaria.postgresql.org; Sun, 15 Sep 2019 15:59:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9WwH-0001q7-JM for pgsql-general@lists.postgresql.org; Sun, 15 Sep 2019 15:59:49 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9WwF-00061p-Cc for pgsql-general@lists.postgresql.org; Sun, 15 Sep 2019 15:59:49 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 5B1C97A5; Sun, 15 Sep 2019 11:59:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 15 Sep 2019 11:59:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=O x6K/atcomtKPyzTHugH5i0a36rUp147AKYjS1xBNn0=; b=e7oKVm9DECOiEpJ18 Td2q/W3qYAjzm7E5oMaY5NynVASdO+Ef1NenHVNVHuNVXLm0mgi9mH3ugY8mnOy5 Eh6VK5MGRe3+2gnpKFmToJ5oOXHLN2wSqQMaApqRvp53etjlQX0nH67sS2SPIp8s XBOwIifIDmGbLZ7h/Zkj+ey6k+oGMhC3cZm6ST6qk/mtQkD9a4KSwYx3EOinYwR+ 0WRiKYc5x12h351nfpBs+bOg3nbCW0mbsA9b7lXvmM95eUhsyG/TLUY7sLd6hFKz ArCjjcGJueOiXTcsEkzxQZwQUAhcYiP8LU5HGobQ4YIvl49x68aGSZcvcC4k/+vu I+W7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=Ox6K/atcomtKPyzTHugH5i0a36rUp147AKYjS1xBN n0=; b=OA+j7NOQgnJaRhpLx5DFzHHPLze+quuJXMmzyjLPDjrKXOWiiXyRsQSnQ mlrzlewPVbmYwyF0cfyDxm1c/+sv//Fq9EtmmadVxC8EtqaHPb59MJfGAynHwD3c n9JeX2pA1qbOh3i26Cc7MEchkrESI24lM79w2TwdgqEwSk06wLwSkl149McWJNL5 cykjwQ3Pndgo7QRSBKPE/KU6x6UAyVOqLiEbS0SU3kFBotNvaVf51EAdACVWcnO0 SNyEuypIQdFSigHtb1HOe1vh7Nq0Eik/s09dBC3lze1CG9IQgzQEuaiKLYk/Sgdp TjI6tb4XHayYdnWWINLV1sT0pIBKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedruddugdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthejre dttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucfkphepudejgedrvddurdduvdelrdduje ehnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhl rghvvghrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.3] (174-21-129-175.tukw.qwest.net [174.21.129.175]) by mail.messagingengine.com (Postfix) with ESMTPA id DE4E880063; Sun, 15 Sep 2019 11:59:43 -0400 (EDT) Subject: Re: FW: Re: Shouldn;t this trigger be called? To: stan , pgsql-general@lists.postgresql.org References: <20190915155526.GA9056@panix.com> From: Adrian Klaver Message-ID: <35c56985-433c-5fd4-ea4b-d4b05aa512a9@aklaver.com> Date: Sun, 15 Sep 2019 08:59:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190915155526.GA9056@panix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/15/19 8:55 AM, stan wrote: > > Sorry forgot to cc the list > > On Sun, Sep 15, 2019 at 08:42:02AM -0700, Adrian Klaver wrote: >> On 9/15/19 8:33 AM, stan wrote: >>> I have defined this function: >>> >>> CREATE FUNCTION fix_customer_types_case() >>> >>> and this trigger: >>> >>> CREATE TRIGGER fix_customer_types_case_trig BEFORE INSERT OR UPDATE ON customer >>> FOR EACH ROW EXECUTE FUNCTION fix_customer_types_case(); >>> >>> and I put a RAISE NOTICE so I can tell if the function is called. Yet when I >>> do a : >>> >>> \copy to bring data into this table, I do not see the notice. >> >> What is the actual command you are using? > > > \COPY customer(name, location, status , c_type , bill_attention , bill_addresse , bill_address_1 , bill_address_2 , bill_city , bill_state , bill_country , ship_attention , ship_addresse , ship_address_1 , ship_address_2, ship_city ,ship_state ) from '/home/stan/pm_db/live_data/ready/customer.csv' DELIMITER ',' CSV HEADER ; > > and here is the function > > CREATE FUNCTION fix_customer_types_case() > RETURNS trigger AS $$ > BEGIN > if NEW.c_type IS NOT NULL > THEN > NEW.c_type := upper(cast( NEW.c_type AS TEXT)); > END IF ; > if NEW.status IS NOT NULL > THEN > RAISE NOTICE 'Called With %', NEW.status; > NEW.status := upper(cast( NEW.status AS TEXT)); > END IF ; > RAISE NOTICE 'Left With With %', NEW.status; > RAISE NOTICE 'Left With With %', NEW.c_type; > return NEW; > END; > $$ > LANGUAGE PLPGSQL; > > if I do an insert this function is called. However it IS NOT called for the > above copy command. How can I fix that? I thought you said it was fixed now. > > This line from the page you referenced implies this should work, but i must be > doing something wrong: > > COPY FROM will invoke any triggers and check constraints on the destination > table. However, it will not invoke rules. > > -- Adrian Klaver adrian.klaver@aklaver.com