Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIveD-0006tg-9P for pgsql-general@arkaria.postgresql.org; Mon, 10 Jul 2023 18:30:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qIveC-0001tI-6f for pgsql-general@arkaria.postgresql.org; Mon, 10 Jul 2023 18:30:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIveB-0001t9-SD for pgsql-general@lists.postgresql.org; Mon, 10 Jul 2023 18:30:07 +0000 Received: from resdmta-h1p-028597.sys.comcast.net ([2001:558:fd02:2446::d]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qIve8-0037PA-HE for pgsql-general@lists.postgresql.org; Mon, 10 Jul 2023 18:30:05 +0000 Received: from resomta-h1p-027914.sys.comcast.net ([96.102.179.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 256/256 bits) (Client did not present a certificate) by resdmta-h1p-028597.sys.comcast.net with ESMTP id IozxqK9szo8GLIve4qC45C; Mon, 10 Jul 2023 18:30:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1689013800; bh=ZBC552KqeNEjG+Zdvlovl7a0N2hDCWldkx/1HcBpoiY=; h=Received:Received:Date:From:To:Message-ID:Subject:MIME-Version: Content-Type:Xfinity-Spam-Result; b=ANFlUFTpYRFxGWnnHJPnmLxumoeW2shvzv3QdxKL+xP7zoV+sV03OAYhCdG24YW6i bMYgTO0MwiC7IAWyhUPUru1awVgt7tHBUT9ytfqeZ6VwcloLMr5oS23oEtI62fO2/U yWEqxist77qbgx3/cNUUq7lFmvecW4AVeqYV8ox5zYDnyGl4S/+sd5rqzmEJ0QGIgF /vhm5Vu6Vf+Xp9eA08xUtfEdzVRT48qdFU6BApYfNpDlXSi6quI+5m/EEXgErbXGTr yE7diNxDNJz1AbT3RWdZ1HGl7ia97Eu6FXNXauJOHmvWFgW3m5AK+4urc9l9N/BOfd PfWTO6K4sg2vw== Received: from oxappp-hoa-22o.email.comcast.net ([96.116.234.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 256/256 bits) (Client did not present a certificate) by resomta-h1p-027914.sys.comcast.net with ESMTPS id Ive3q9rZwHWw0Ive3qXZFd; Mon, 10 Jul 2023 18:29:59 +0000 X-Xfinity-VAAS: gggruggvucftvghtrhhoucdtuddrgedviedrvdekgdduudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvehomhgtrghsthdqtfgvshhipdfqfgfvpdfpqffurfetoffkrfenuceurghilhhouhhtmecufedtudenucenucfjughrpeffhffvvefkjghfufggtgfgrfgkofhisehtjegstdertdejnecuhfhrohhmpeffteggkfffucftqffvjfcuoegruggrphhtrhhonhestghomhgtrghsthdrnhgvtheqnecuggftrfgrthhtvghrnhephefhkeejhffgffffhfdvieelvefguedvtdejtdevtefhiefhtdetvdehhedukeefnecukfhppeeliedrudduiedrvdefgedrvdegiedpvdeitddumeduledumeekgedttdemugdvrgdtmeeiledvrgemugegtggvmeefvggtvdemvgdtsgefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghlohepohigrghpphhpqdhhohgrqddvvdhordgvmhgrihhlrdgtohhmtggrshhtrdhnvghtpdhinhgvthepleeirdduudeirddvfeegrddvgeeipdhmrghilhhfrhhomheprggurghpthhrohhnsegtohhmtggrshhtrdhnvghtpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepgihofhesthhhvggsuhhilhgurdgtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-Xfinity-VMeta: sc=0.00;st=legit Date: Mon, 10 Jul 2023 14:29:59 -0400 (EDT) From: DAVID ROTH To: Christophe Pettus Cc: "pgsql-general@lists.postgresql.org" Message-ID: <1715546791.171305.1689013799237@connect.xfinity.com> In-Reply-To: References: <1875078143.170839.1689013230630@connect.xfinity.com> Subject: Re: Trigger Function question MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev39 X-Originating-IP: 2601:191:8400:d2a0:692a:d4ce:3ec2:e0b3 X-Originating-Client: open-xchange-appsuite List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I want to use a single trigger function to log multiple tables and the tables have different columns. I can get the names of the columns from the catalog. But I have not been able to figure out how to get NEW.x when x is not known until run time. > On 07/10/2023 2:23 PM EDT Christophe Pettus wrote: > > > > On Jul 10, 2023, at 11:20, DAVID ROTH wrote: > > > > In a trigger function, is there a way to get a list of all of the columns in the triggering table? > > You can get the table that the trigger fired on with TG_TABLE_SCHEMA and TG_TABLE_NAME, and then query the system catalogs to get a list of columns. > > But can you tell us a bit more about your use-case? You may be able to write the trigger in such a way that it doesn't need to change behavior based on the columns.