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 1gT5rA-0000XJ-SJ for pgsql-general@arkaria.postgresql.org; Sat, 01 Dec 2018 14:02:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gT5r9-0005eT-9Y for pgsql-general@arkaria.postgresql.org; Sat, 01 Dec 2018 14:02:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT5r7-0005eM-SQ for pgsql-general@lists.postgresql.org; Sat, 01 Dec 2018 14:02:51 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT5r0-0006At-FT for pgsql-general@postgresql.org; Sat, 01 Dec 2018 14:02:48 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 3A26C21947; Sat, 1 Dec 2018 09:02:41 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 01 Dec 2018 09:02:41 -0500 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=fm1; bh=D +xY7456J8qxrO8b7oWbgwaGrGv7lSJFOTnCV85gx+Q=; b=sQqzjCfHEADPf3CZd qyVcRIU7voxOroG7oIUnbqsA561BVzNTI678JEAfmhvxLCV7l5Lp7lSnRCkLynEY MmrWCbJVZnLSf47h7HHSngQg3BiS3aTy7ZfoNL3XeS1HU0oLB0MqRcmzJW6T+sIC r7wi6BCHrCjVYg2YYB2kDCorUl6Zo1SFCINqflb/Ak3ehreRibJWTBGTpv3NPQEu PCSlmNajJooOIsyPgNq/f5mMc4XlM6MuNCiEQKDGmQQyShk+YBvn28QnbQUcReTN zEO5iiYByzEiRMzLTdH86vfY4r1fhgjwhgKr7DFHMHIGxx/xYLNfY/sVtXDvT78T fTbqA== 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=fm1; bh=D+xY7456J8qxrO8b7oWbgwaGrGv7lSJFOTnCV85gx +Q=; b=lrJYbNVqdiakva6RuOOIc23fyqoq9dgMVIiQiqPMzj6JiDa5+B2gMC5bW pnNs4rq4oXfFZdYJhw2TZ+6JZW5ilpipUPX99QAmAqSTCwaZwZrzJO55KuiMqMxW Y4c1HsVlYLokzJhOBl9/PTihjA6hWI5bp+Gjk5bhg1G50gsutu+aqctEa8VaEWd/ r8fu8ZmaiSQOv3TvxUGR/Yze+XdGYbVPWgTorvTxzOvGOOs4OMTybqiOngn3lTIO rTrWuIqEl3u5fIzivLiww7JYZkIG2hBS+ZUGH0b1vltHCBYhoJ8cMshhkg/PzF8e RqjjPHPEtMZqrzQuTWDFj4Kj8Deyw== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id E011AE405B; Sat, 1 Dec 2018 09:02:39 -0500 (EST) Subject: =?UTF-8?Q?Re=3a_Transition_Tables_doesn=c2=b4t_have_OID?= To: PegoraroF10 , pgsql-general@postgresql.org References: <1543666938082-0.post@n3.nabble.com> From: Adrian Klaver Message-ID: Date: Sat, 1 Dec 2018 06:02:38 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <1543666938082-0.post@n3.nabble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/1/18 4:22 AM, PegoraroF10 wrote: > I´m trying to use transition tables for auditing purposes. > > create trigger MyTableAudit_UPD after update on MyTable referencing old > table as Transition_old new table as Transition_new for each statement > execute procedure AuditTable(); > > create or replace function AuditTable() returns trigger language plpgsql as > $$ > if (TG_OP = 'UPDATE') then > insert into audittable(table_name, oid, audit_action, user_id, > table_schema, values_old, values_new) > select TG_TABLE_NAME, Transition_new.oid, TG_OP, CURRENT_USER, > TG_TABLE_SCHEMA, row_to_json(Transition_old.*)::jsonb, > row_to_json(Transition_new.*)::jsonb from Transition_new inner join > Transition_old on Transition_new.OID = Transition_old.OID; > elsif (TG_OP = 'DELETE') then > insert into audittable(table_name, oid, audit_action, user_id, > table_schema, values_old) > select TG_TABLE_NAME, Transition_old.oid, TG_OP, CURRENT_USER, > TG_TABLE_SCHEMA, row_to_json(Transition_old.*)::jsonb from Transition_old; > end if; > > [42703] ERROR: column transition_new.oid does not exist Where: função > PL/pgSQL audittable() linha 14 em comando SQL > > I would like to user OID value because we change our primary keys, > sometimes, OID doesn´t. > > So, there is a way to get OID on transition tables ? You will want to get away from using OID's as they are going away: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=578b229718e8f15fa779e20f086c4b6bb3776106 > > > > -- > Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > -- Adrian Klaver adrian.klaver@aklaver.com