Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id DCF301337BDF for ; Sat, 7 May 2011 07:08:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 49484-05 for ; Sat, 7 May 2011 10:07:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from zebedee.cranntara.net (zebedee.cranntara.net [91.186.7.79]) by mail.postgresql.org (Postfix) with ESMTP id 91C9B1337BA3 for ; Sat, 7 May 2011 07:07:53 -0300 (ADT) Received: from [88.210.188.180] (helo=bolek.coachhouse) by zebedee.cranntara.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1QIeQR-0005v6-TD for pgsql-sql@postgresql.org; Sat, 07 May 2011 11:07:53 +0100 Received: from dick.coachhouse ([192.168.1.32] ident=tarlika) by bolek.coachhouse with esmtp (Exim 4.69) (envelope-from ) id 1QIdzN-0008Va-0H for pgsql-sql@postgresql.org; Sat, 07 May 2011 10:39:53 +0100 Date: Sat, 7 May 2011 10:39:44 +0100 From: Tarlika Elisabeth Schmitz To: pgsql-sql@postgresql.org Subject: Re: data import via COPY, Rules + Triggers Message-ID: <20110507103944.53c2dca5@dick.coachhouse> In-Reply-To: <20110504234804.0d0a1fff@dick.coachhouse> References: <20110504234804.0d0a1fff@dick.coachhouse> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.12; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/39 X-Sequence-Number: 35323 On Wed, 4 May 2011 23:48:04 +0100 Tarlika Elisabeth Schmitz wrote: >I have got a database that needs to be populated, first with historical >data, then on a daily basis.[...] >Once imported, data will neither be modified nor deleted. > >Data come in denormalized CSV formats. [...] >I created interim tables matching the structure of the CSV formats >I want to import via COPY and distribute the data to >the "proper" tables via triggers. [...] I am the only user of the system and at the moment I have only one database user. I only want the insdert/update triggers to be executed when I am importing data. There might be situations where I need to intervene "manually" and fix some data without the triggers being actioned. How about creating a second user through whom the imports are done? I could query current_user in the trigger and simply skip the trigger actions for any other user. QUESTION: Or could I do something more sophisticated with privileges? -- Tarlika Elisabeth Schmitz