Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vZWwJ-00DqEY-0F for pgsql-general@arkaria.postgresql.org; Sat, 27 Dec 2025 16:14:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vZWwI-00Bwyo-0B for pgsql-general@arkaria.postgresql.org; Sat, 27 Dec 2025 16:14:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vZWwH-00Bwyg-2N for pgsql-general@lists.postgresql.org; Sat, 27 Dec 2025 16:14:46 +0000 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vZWwF-0036eO-2I for pgsql-general@postgresql.org; Sat, 27 Dec 2025 16:14:45 +0000 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-78fdb90b670so40521757b3.2 for ; Sat, 27 Dec 2025 08:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766852082; x=1767456882; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jnhllp0uWagiXLCAAZl2fx1QzE7qdRqasAU7FrONdcs=; b=IeolaD3h1aS9cg/S8okbLommkxnii8ZbsTc0+6Pzlgm22HIPM26qi9w5efvdDMrz0g 0PTOMGkE/zrC4xFWHhM1f9NJznZ2drnZF7K/zixz1BB2g+J/re+vTdLeMCMfMyqnNCge V1p+PZLZN3mtZQ9hE5b1WzGtMlQTWMuvEumQpjK1XIAS2vgXGt6KS52zBv6w1eRnvJXD eSbKwH0DSmKYjoD+nTLFu7wMFWTNn4l4WoUL5vlca4Hu1CwndpeMp5qdoM6m0RYiZDcs IVAU7KRd5tmyzDjQ8D1GlOes/CXJ/iyAsPe1Z02Y2x8yPStwAbxSGEwMnnRrBTkRxE1x C3fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766852082; x=1767456882; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jnhllp0uWagiXLCAAZl2fx1QzE7qdRqasAU7FrONdcs=; b=Ta9pK5tk8N0E1/DMWsNSogKlsyqVn0Y7qD/Mc7TqoBcs0L49679Thxsdgs+1qtq4hl TZPbySxlOr4qOkfwZ0O12gDWjUiNQghBKH8/C4hPUfNxc9SKHoCY0BiKpF9wWdWT4yRv MoALQhgPuDc0s9aiHdH/pCpcPw4xVE1dls8dsONVRoC1paAevPZVTYamSSr93DS02jlC AlP0l0MBx9+7Y8FZ+FfciwdmpR2EeNLHMPfTYu1Yon8ttIquMC/vb0EQ914K9rgTHZVJ dFNaDVloBaYAgSL1a/bJL3rE87gqUiquZpneHMya+AQfNYIzSlrKAVlwq85FJkCNWMiT O0mg== X-Gm-Message-State: AOJu0YzrJ06CgckEY6A8a75D3evVhO3rrmONIXFAeLLD4LynoSpujn1w /94VuqSg1MTgGSFNSbMcwm7hJ53ZlETfL0Ly/Pyv93a2cddIMGCqgP3Csd+oyD3zXjj55zT8LDq sOcDH8flwpVnT3wqS7+yraeNFudP/f3EvFyf7UCw= X-Gm-Gg: AY/fxX5CgKGNRQfTvOEluR9Dbj24vLiVpU7jeDtbbrcuUP5dWJRbtmMZHNQQP8fmliM +a+GJt3KN4M/jrVQAaH8Nw3Q+BOcke/2EVaM8+DCWnw6mwkCUWX1/oUK+kLyRzJJcHo56FjgSzR IYRclsKt+xqFp1qbmZwenED4U4p3JIt0d7hC7gpG+vWGk9NLm6i+xdo24hwdFQuI4AhpZQ+7Y1y NTCRXEWYBFQJKTNEHI8PGsVMV6MCHWhxSq6QxGLJRLF1XfBEUnv4HTK10XkdpG61zLptJ8uFym4 um+qHmWw89xTQr0wG7KxpPpC8cKhCA74qWPuM8EGFFIwQU0JSCIdBs9yuGVi6gHM53/R90sszOe yYDnCLdboJYdKRQ== X-Google-Smtp-Source: AGHT+IGikpYUvjb+qkizxnb5yhh3G6LxpcCrKdB6IZ8BZ9fZdmkgIv3Nm61D3EC3pcv46rX7lSip/V+MWD9khlRtFiU= X-Received: by 2002:a53:7703:0:b0:63f:adba:3e69 with SMTP id 956f58d0204a3-6466a8c09c4mr16515268d50.54.1766852081803; Sat, 27 Dec 2025 08:14:41 -0800 (PST) MIME-Version: 1.0 References: <0102019b608b1887-d8e9137f-46a7-4796-9f43-0addbab3c645-000000@eu-west-1.amazonses.com> In-Reply-To: <0102019b608b1887-d8e9137f-46a7-4796-9f43-0addbab3c645-000000@eu-west-1.amazonses.com> From: Pavel Stehule Date: Sat, 27 Dec 2025 17:14:04 +0100 X-Gm-Features: AQt7F2qLn0yhMPQXa2MewhmtTkeBC31Adh37z96wF0uIHlIPCOpGudYgyRQPPhY Message-ID: Subject: Re: plpgsql: remove a field from a record? To: "Ray O'Donnell" Cc: pgsql-general Content-Type: multipart/alternative; boundary="000000000000b4e6860646f14ee9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b4e6860646f14ee9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi so 27. 12. 2025 v 17:01 odes=C3=ADlatel Ray O'Donnell na= psal: > Hi all, > > In a plpgsql function, is it possible to remove a field from a RECORD > value? > > My specific use-case is that I have a row returned from a MERGE > operation into a variable, declared as type RECORD, which will then be > logged; and I want to remove some potentially sensitive stuff from it > before it gets logged. > > I could manually redact the sensitive items (e.g. set them to null); but > it'd be tidier just to remove them altogether if I can. > > Thanks in advance, > I think so it is not possible - not directly. Maybe you can use jsonb or hstore (2025-12-27 17:12:06) postgres=3D# create type t as (a int, b int); (2025-12-27 17:12:24) postgres=3D# select * from jsonb_to_record(row_to_json(row(10,20)::t)::jsonb - 'a') as (b int); =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 =E2=94=82 b =E2=94=82 =E2=95=9E=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=A1 =E2=94=82 20 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98 (1 row) Regards Pavel > > Ray. > > -- > Ray O'Donnell // Galway // Ireland > ray@rodonnell.ie > > > > --000000000000b4e6860646f14ee9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

so 27. 12. 2025 v=C2=A017:01 = odes=C3=ADlatel Ray O'Donnell <r= ay@rodonnell.ie> napsal:
Hi all,

In a plpgsql function, is it possible to remove a field from a RECORD value= ?

My specific use-case is that I have a row returned from a MERGE
operation into a variable, declared as type RECORD, which will then be
logged; and I want to remove some potentially sensitive stuff from it
before it gets logged.

I could manually redact the sensitive items (e.g. set them to null); but it'd be tidier just to remove them altogether if I can.

Thanks in advance,

I think so it is not= possible - not directly. Maybe you can use jsonb or hstore=C2=A0

(2025-12-27 17:12:06)= postgres=3D# create type t as (a int, b int);
(2025-12-27 17:12:24) pos= tgres=3D# select * from jsonb_to_record(row_to_json(row(10,20)::t)::jsonb -= 'a') as (b int);
=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=90
=E2=94=82 b =C2=A0=E2=94=82
=E2=95=9E=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=A1
=E2=94=82 20 =E2=94=82
=E2=94=94=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=98
(1 row)


Regar= ds

Pavel
=C2=A0

Ray.

--
Ray O'Donnell // Galway // Ireland
ray@rodonnell.ie<= br>


--000000000000b4e6860646f14ee9--