I get ERROR: column "table_name" does not exist

Started by PG Bug reporting formalmost 2 years ago6 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/16/plpgsql-control-structures.html
Description:

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

#2Erik Wienhold
ewie@ewie.name
In reply to: PG Bug reporting form (#1)
Re: I get ERROR: column "table_name" does not exist

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

#3Florian Koch
florian.murat.koch@gmail.com
In reply to: Erik Wienhold (#2)
Re: I get ERROR: column "table_name" does not exist

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.

Show quoted text

On Wed, Jun 5, 2024 at 6:32 PM Erik Wienhold <ewie@ewie.name> 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

#4Erik Wienhold
ewie@ewie.name
In reply to: Florian Koch (#3)
Re: I get ERROR: column "table_name" does not exist

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 <ewie@ewie.name> 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

#5Florian Koch
florian.murat.koch@gmail.com
In reply to: Erik Wienhold (#4)
Re: I get ERROR: column "table_name" does not exist

I made a gist with the error.
https://gist.github.com/floratmin/a4b404f0fd66b03a0428c07686b71410

Show quoted text

On Fri, Jun 7, 2024 at 3:24 AM Erik Wienhold <ewie@ewie.name> wrote:

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 <ewie@ewie.name> 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

#6Erik Wienhold
ewie@ewie.name
In reply to: Florian Koch (#5)
Re: I get ERROR: column "table_name" does not exist

On 2024-06-07 14:24 +0200, Florian Koch wrote:

I made a gist with the error.
https://gist.github.com/floratmin/a4b404f0fd66b03a0428c07686b71410

The problem is the semicolon after PG_DATATYPE_NAME, causing the
TABLE_NAME line to be a separate statement:

exception_datatype := PG_DATATYPE_NAME;
exception_table := TABLE_NAME;

--
Erik