Thread: error messages without schema name

error messages without schema name

From
"Filip Rembiałkowski"
Date:
Hi all,

I heard once that all messages which refer to table names should also
give their schema name.

I mean, if I see something like

rzeznia=# TRUNCATE  nsp2.foo;
ERROR:  cannot truncate a table referenced in a foreign key constraint
DETAIL:  Table "bar" references "foo".
HINT:  Truncate table "bar" at the same time, or use TRUNCATE ... CASCADE.

I do not know which namespace "bar" belongs to.

Is this a bug, or do I have to live with it?

--
Filip Rembiałkowski

Re: error messages without schema name

From
"Filip Rembiałkowski"
Date:
06-12-13, Shoaib Mir <shoaibmir@gmail.com> napisał(a):
> You can not truncate table 'foo' because there is referential integrity
> between 'foo' and 'bar', so try using
>
> TRUNCATE nsp2.foo CASCADE;
>
> You can find the schema name for 'bar' using a query like:
>
> select nspname from pg_namespace where oid = (select relnamespace from
> pg_class where relname = 'bar');
this returns 2 schema names. which one is of my "bar"?

Actually, I was asking if this behaviour of postgres is OK?
I heard from my PostgreSQL teacher, that all such messages should be
corrected in the source code, to include schema name too.

Re: error messages without schema name

From
Tom Lane
Date:
"=?UTF-8?Q?Filip_Rembia=C5=82kowski?=" <plk.zuber@gmail.com> writes:
> I heard from my PostgreSQL teacher, that all such messages should be
> corrected in the source code, to include schema name too.

I doubt we'd ever do that, because in most scenarios it'd just be
unnecessary clutter, and the primary error messages are supposed to
be kept short.

What probably should happen someday is to add additional fields to error
reports that carry object name, schema name, and so forth.  I think
these wouldn't be displayed normally but you could always turn on
"verbose" mode if you needed to see them.  This approach is needed to
support applications that want to know, for example, which constraint
failed during an INSERT without having to try to extract it from the
possibly-translated message text.

            regards, tom lane

Re: error messages without schema name

From
"Shoaib Mir"
Date:
That means you might have the same table in both schemas, so try doing the following to confirm:

select * from schema1.bar
select * from schema2.bar

You can also set search_path if you  want to avoid adding schema name with database objects:

set search_path = schema1
select * from bar

instead of doing:

select * from schema1.bar

-----------------------
Shoaib Mir
EnterpriseDB (www.enterprisedb.com )

On 12/13/06, Filip Rembiałkowski <plk.zuber@gmail.com> wrote:
06-12-13, Shoaib Mir <shoaibmir@gmail.com> napisał(a):
> You can not truncate table 'foo' because there is referential integrity
> between 'foo' and 'bar', so try using
>
> TRUNCATE nsp2.foo CASCADE;
>
> You can find the schema name for 'bar' using a query like:
>
> select nspname from pg_namespace where oid = (select relnamespace from
> pg_class where relname = 'bar');
this returns 2 schema names. which one is of my "bar"?

Actually, I was asking if this behaviour of postgres is OK?
I heard from my PostgreSQL teacher, that all such messages should be
corrected in the source code, to include schema name too.

Re: error messages without schema name

From
"Shoaib Mir"
Date:
You can not truncate table 'foo' because there is referential integrity between 'foo' and 'bar', so try using

TRUNCATE nsp2.foo CASCADE;

You can find the schema name for 'bar' using a query like:

select nspname from pg_namespace where oid = (select relnamespace from pg_class where relname = 'bar');

-------------------------
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)

On 12/13/06, Filip Rembiałkowski <plk.zuber@gmail.com> wrote:
Hi all,

I heard once that all messages which refer to table names should also
give their schema name.

I mean, if I see something like

rzeznia=# TRUNCATE  nsp2.foo;
ERROR:  cannot truncate a table referenced in a foreign key constraint
DETAIL:  Table "bar" references "foo".
HINT:  Truncate table "bar" at the same time, or use TRUNCATE ... CASCADE.

I do not know which namespace "bar" belongs to.

Is this a bug, or do I have to live with it?

--
Filip Rembiałkowski

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly