Re: How to get schema name which violates fk constraint

Lists: pgsql-general
From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: How to get schema name which violates fk constraint
Date: 2008-10-14 15:43:30
Message-ID: gd2ep9$htj$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

FK violation erroro is displayed as

7/23503:ERROR: insert or update on table "summak" violates foreign key
constraint "summak_kontonr_fkey1"
Key (kontonr)=(2421 ) is not present in table "konto".

I have large numbers of schemas all containing tables with same name.

How to determine schema name where error occurs?

Andrus.


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 02:07:41
Message-ID: dcc563d10810211907n3c59a920ia9eb7cd2a6d5ea58@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Actually this sounds like a TODO to me. I imagine the db knows the
schema and it's just not reporting it in the error message. Bruce?
Tom?

On Tue, Oct 14, 2008 at 9:43 AM, Andrus <kobruleht2(at)hot(dot)ee> wrote:
> FK violation erroro is displayed as
>
> 7/23503:ERROR: insert or update on table "summak" violates foreign key
> constraint "summak_kontonr_fkey1"
> Key (kontonr)=(2421 ) is not present in table "konto".
>
> I have large numbers of schemas all containing tables with same name.
>
> How to determine schema name where error occurs?
>
> Andrus.
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
When fascism comes to America, it will be draped in a flag and
carrying a cross - Sinclair Lewis


From: "jimmy Zhang" <crackeur(at)comcast(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: [ANN] VTD-XML extended edition released
Date: 2008-10-22 02:23:19
Message-ID: 00ab01c933ed$260b4bb0$0402a8c0@your55e5f9e3d2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

The Java version of extended VTD-XmL is released and available for download.
This version supports 256 GB max file sizes and memory mapped capabilities.
The updated documentation is also available for download. In short, you can
basically do full XPath query on documents that are bigger than memory space
available on your machine.

A special thanks to Duane May who provided value suggestions and inputs and
helped refine the VTD specs to make this happen.

To download the package and the documentation, go to
https://sourceforge.net/project/downloading.php?group_id=110612&use_mirror=&filename=vtd-xml_2.4_doc.zip&64621261

https://sourceforge.net/project/downloading.php?group_id=110612&use_mirror=&filename=ximpleware_extended_2.4.zip&99532507


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 13:31:42
Message-ID: 20081022133142.GB4022@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Scott Marlowe escribió:
> Actually this sounds like a TODO to me. I imagine the db knows the
> schema and it's just not reporting it in the error message. Bruce?
> Tom?

Added -- it should be easy to do, so marked as such.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 13:50:21
Message-ID: 22398.1224683421@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Scott Marlowe escribi:
>> Actually this sounds like a TODO to me. I imagine the db knows the
>> schema and it's just not reporting it in the error message. Bruce?
>> Tom?

> Added -- it should be easy to do, so marked as such.

A comprehensive response to this type of gripe wouldn't be all that
"easy". In the first place, there'd be a lot of code to touch. In the
second place, the reason most of our messages don't already contain
schema names is that in the past we've judged it would be mostly
clutter; and given the infrequency of complaints I see no reason to
change that opinion.

The type of fix I'd like to see would be to not change message texts at
all, but to add separate error-message fields for the name and schema
name of object(s) involved in an error; which would be details that
psql, for example, would show only in VERBOSE mode. Note that error
report fields along this line are actually required by the SQL spec
(cf GET DIAGNOSTICS) but we've never got round to implementing 'em.

regards, tom lane


From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 13:58:06
Message-ID: 760EC27241A6495F87DC92FC1B9685BF@andrusnotebook
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> The type of fix I'd like to see would be to not change message texts at
> all, but to add separate error-message fields for the name and schema
> name of object(s) involved in an error; which would be details that
> psql, for example, would show only in VERBOSE mode. Note that error
> report fields along this line are actually required by the SQL spec
> (cf GET DIAGNOSTICS) but we've never got round to implementing 'em.

How about adding also a way to get primary key value(s) of the row which
causes error ?

Andrus.


From: Ben Chobot <bench(at)silentmedia(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 15:51:04
Message-ID: 7CD8F0E1-7C22-4C6E-A962-7424B20ED61D@silentmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On Oct 22, 2008, at 6:50 AM, Tom Lane wrote:

> In the
> second place, the reason most of our messages don't already contain
> schema names is that in the past we've judged it would be mostly
> clutter; and given the infrequency of complaints I see no reason to
> change that opinion.

Well, FWIW, I also would like to be able to see which schema caused
the violation, as I'm in a similar boat of having the same table name
in multiple schemas.


From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:13:04
Message-ID: gdnmva$1ran$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> Well, FWIW, I also would like to be able to see which schema caused the
> violation, as I'm in a similar boat of having the same table name in
> multiple schemas.

Maybe to report schema name only if it is not public or if same table
exists in different schemas or report it in detail message or hint.

Andrus.


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:14:43
Message-ID: 20081022171443.GC4022@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Tom Lane escribió:

> A comprehensive response to this type of gripe wouldn't be all that
> "easy". In the first place, there'd be a lot of code to touch.

Well, that makes it tedious, which is not the same as hard.

> In the second place, the reason most of our messages don't already
> contain schema names is that in the past we've judged it would be
> mostly clutter; and given the infrequency of complaints I see no
> reason to change that opinion.

I tend to disagree. We can run a poll in a wider audience.

> The type of fix I'd like to see would be to not change message texts at
> all, but to add separate error-message fields for the name and schema
> name of object(s) involved in an error; which would be details that
> psql, for example, would show only in VERBOSE mode. Note that error
> report fields along this line are actually required by the SQL spec
> (cf GET DIAGNOSTICS) but we've never got round to implementing 'em.

Now that's a bit more complex than the trivial solution of adding an
extra %s to the error message, but it's still not all that difficult, I
think.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:27:58
Message-ID: 9293.1224696478@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Tom Lane escribi:
>> In the second place, the reason most of our messages don't already
>> contain schema names is that in the past we've judged it would be
>> mostly clutter; and given the infrequency of complaints I see no
>> reason to change that opinion.

> I tend to disagree. We can run a poll in a wider audience.

We already have a large poll: divide the number of complaints on this
topic since 7.3 came out by the number of users ...

regards, tom lane


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:34:12
Message-ID: dcc563d10810221034ue12f03vf7cbd9fd0d0aa0c2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Oct 22, 2008 at 11:27 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>> Tom Lane escribió:
>>> In the second place, the reason most of our messages don't already
>>> contain schema names is that in the past we've judged it would be
>>> mostly clutter; and given the infrequency of complaints I see no
>>> reason to change that opinion.
>
>> I tend to disagree. We can run a poll in a wider audience.
>
> We already have a large poll: divide the number of complaints on this
> topic since 7.3 came out by the number of users ...

But it could well be a chicken and egg issue. People don't use a lot
of schemas because the support for error reporting and other stuff is
not finished, so they can't complain about a feature they don't use.
Just a thought. I like schemas, but they do feel like some parts
aren't quite done.


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:35:20
Message-ID: dcc563d10810221035o413f8f65k2eac36ef75d1df6f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Oct 22, 2008 at 11:13 AM, Andrus <kobruleht2(at)hot(dot)ee> wrote:
>> Well, FWIW, I also would like to be able to see which schema caused the
>> violation, as I'm in a similar boat of having the same table name in
>> multiple schemas.
>
> Maybe to report schema name only if it is not public or if same table exists
> in different schemas or report it in detail message or hint.

I doubt that would make it any easier to implement, and I don't see
reporting schemaname.relationname as being all that cluttery anyway.

-- When fascism comes to America, it will be draped in a flag and
carrying a cross - Sinclair Lewis


From: "George Pavlov" <gpavlov(at)mynewplace(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, "Andrus" <kobruleht2(at)hot(dot)ee>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:39:04
Message-ID: 8C5B026B51B6854CBE88121DBF097A8602EF6351@ehost010-33.exch010.intermedia.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> >> In the second place, the reason most of our messages don't already
> >> contain schema names is that in the past we've judged it would be
> >> mostly clutter; and given the infrequency of complaints I see no
> >> reason to change that opinion.
>
> > I tend to disagree. We can run a poll in a wider audience.
>
> We already have a large poll: divide the number of complaints on this
> topic since 7.3 came out by the number of users ...

Since it seems like we are voting (!) let me say that fully informative
errors that include the schema would be very useful for those of us who
do use schemas to organize their tables. The generic "proper" way to
address a table in a schema (short of user path settings) is to qualify
it by its schema, so that's the unique fully descriptive name of the
table so all errors/diagnostics should reference that. Otherwise schemas
look like they are delegated to a second-class feature ("we have it so
we can check off a feature matrix, but our heart is not fully in it"). I
suspect lack of complaints is largely due to the (small) number of
people using namespaces -- the denominator should be users of the
feature, not all users...

George


From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get schema name which violates fk constraint
Date: 2008-10-22 17:48:23
Message-ID: 48FF6767.1090808@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

George Pavlov wrote:

> I
> suspect lack of complaints is largely due to the (small) number of
> people using namespaces -- the denominator should be users of the
> feature, not all users...

I certainly found it extremely frustrating that errors didn't reference
the involved schema when I was working on a database that used several
sets of tables with the same names and structure under different schema.
As it happens I ended up finding it to be much better to store all the
data in a single set of tables with composite primary keys, but there
are certainly situations where that won't be the case.

I can see, however, that it might be a pretty tedious thing to do and
not very high on anybody's fun-to-code list.

--
Craig Ringer