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.94.2) (envelope-from ) id 1sFOLR-001rCv-UY for pgsql-docs@arkaria.postgresql.org; Fri, 07 Jun 2024 01:24:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sFOLQ-005xDn-Ho for pgsql-docs@arkaria.postgresql.org; Fri, 07 Jun 2024 01:24:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFOLQ-005xDf-85 for pgsql-docs@lists.postgresql.org; Fri, 07 Jun 2024 01:24:41 +0000 Received: from mout-u-107.mailbox.org ([80.241.59.207]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFOLN-000565-D6 for pgsql-docs@lists.postgresql.org; Fri, 07 Jun 2024 01:24:39 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4VwNlg6JDJz9smd; Fri, 7 Jun 2024 03:24:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1717723472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7j9MF4Y1p/dWPDsdji8x7zHAQEcOw/s5eO27e/9TmhE=; b=ata1I1y2NibCdSrFzNQnD6EiPlSVdCxZZnDsfpqDKQzx4wYWpqjWqL+/7WW5BPfmgpckXQ 0NhY6jGhzQl0yLHb5f+KDnX7DqAbs14rr589zuBTCe00ByKZE0295NGFw6XD9lNW0/RkbZ UbQ46yz8kG7lTW2WeHrmpoy5NTguRuInYUL8T3oJ5un7OVDAbE4A4PC/u/8E2MdXwfh14D 6PQeBmegd5q43HaAXZj+Qhh3gQAilLat0lmfjH4MYmqsviN2rJLS5bSfQQlE7G+jRx0ygD g9ayTp4Q3f2YTsuQpfCOgxudOes8oCLM9FlZKRTvIBl1Wog0cto2I3c4Ldihkw== Date: Fri, 7 Jun 2024 03:24:19 +0200 From: Erik Wienhold To: Florian Koch Cc: pgsql-docs@lists.postgresql.org Subject: Re: I get ERROR: column "table_name" does not exist Message-ID: References: <171753061515.2021730.14624637049210791754@wrigleys.postgresql.org> <26d7c4dd-2809-426a-acb4-bbd2828fba93@ewie.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 4VwNlg6JDJz9smd List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-06-06 15:08 +0200, Florian Koch wrote: > This is the working example, when I replace any of e.g. > 'PG_EXCEPTION_HINT' with 'TABLE_NAME'. Then the function throws. I am > using postgres 16.1. Perhaps you did not declare variable table_name and run something like: RETURN jsonb_build_object('table', table_name); But that's still guesswork without seeing the actual function definition with your edits. > On Wed, Jun 5, 2024 at 6:32 PM Erik Wienhold wrote: > > > > On 2024-06-04 21:50 +0200, PG Doc comments form wrote: > > > When using GET STACKED DIAGNOSTICS in PL/pgSQL accessing TABLE_NAME, > > > COLUMN_NAME, CONSTRAINT_NAME or SCHEMA_NAME throws an error. > > > > > > The function "shared.test_raise_exception": > > > https://github.com/rin-nas/postgresql-patterns-library/issues/8#issuecomment-2147984520 > > > > * Do you have a reproducer with those diagnostic items? The linked > > script does not use any of the items that you've mentioned. > > > > * Which Postgres version? -- Erik