Re: schema-qualified SET CONSTRAINTS

Lists: pgsql-hackerspgsql-patches
From: Kris Jurka <books(at)ejurka(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: schema-qualified SET CONSTRAINTS
Date: 2006-04-11 00:05:09
Message-ID: Pine.BSO.4.63.0604101902450.24976@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


The attached patch allows SET CONSTRAINTS to take a schema qualified
constraint name (myschema.t1_fk_t2) and when given a bare constraint name
it uses the search_path to determine the matching constraint instead of
the previous behavior of disabling all identically named constraints.

Kris Jurka

Attachment Content-Type Size
set-constraints-schema.patch text/plain 10.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: schema-qualified SET CONSTRAINTS
Date: 2006-04-11 02:35:44
Message-ID: 3055.1144722944@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Kris Jurka <books(at)ejurka(dot)com> writes:
> The attached patch allows SET CONSTRAINTS to take a schema qualified
> constraint name (myschema.t1_fk_t2) and when given a bare constraint name
> it uses the search_path to determine the matching constraint instead of
> the previous behavior of disabling all identically named constraints.

This patch seems egregiously non backwards compatible :-(. A behavior
that would be backwards compatible is to retain the previous behavior
given an un-qualified name, while if given a schema-qualified name,
modify all matching constraints within that schema. That doesn't seem
very self-consistent though. A compromise that might succeed in making
*everybody* unhappy would be for the unqualified-name case to only
affect constraints that are visible in the current search path (but
affect all of them, not only one as in this patch).

Given the fundamental point that we don't insist on uniqueness of
constraint names within schemas, I'm not sure that the spec gives us
any useful guidance on what SET CONSTRAINTS should affect.

Anyway, I'm not sure what to do, but I am sure it requires some
discussion not just a patch.

regards, tom lane


From: Kris Jurka <books(at)ejurka(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] schema-qualified SET CONSTRAINTS
Date: 2006-04-11 20:30:18
Message-ID: Pine.BSO.4.63.0604111509030.29104@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Mon, 10 Apr 2006, Tom Lane wrote:

> Kris Jurka <books(at)ejurka(dot)com> writes:
>> The attached patch allows SET CONSTRAINTS to take a schema qualified
>> constraint name (myschema.t1_fk_t2) and when given a bare constraint name
>> it uses the search_path to determine the matching constraint instead of
>> the previous behavior of disabling all identically named constraints.
>
> This patch seems egregiously non backwards compatible :-(.

Yes, it does change the existing behavior, but "egregiously"? How many
applications intentionally defer constraints in multiple schemas at once?
Not many. I would guess the more likely situation is that these
applications don't even realize that they are deferring more than one
constraint when it happens. So there will be some very minor pain when
they must select the desired constraint (if it doesn't happen already by
search_path) or explicitly defer more than one constraint, but I'm OK
with that. The existing behavior of SET CONSTRAINTS affecting everything
is not what a user would expect when we have tools like search_path
available.

Kris Jurka


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: schema-qualified SET CONSTRAINTS
Date: 2006-04-18 03:40:33
Message-ID: 200604180340.k3I3eXw21416@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Based on discussion, it seems the idea of using search path seems
accepted.

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------

Kris Jurka wrote:
>
> The attached patch allows SET CONSTRAINTS to take a schema qualified
> constraint name (myschema.t1_fk_t2) and when given a bare constraint name
> it uses the search_path to determine the matching constraint instead of
> the previous behavior of disabling all identically named constraints.
>
> Kris Jurka

Content-Description:

[ Attachment, skipping... ]

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: schema-qualified SET CONSTRAINTS
Date: 2006-04-27 00:34:54
Message-ID: 200604270034.k3R0YsH02869@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Patch applied. Thanks. I also updated our SGML documentation:

The current schema search path is used to find the first matching name
if no schema name is specified.

---------------------------------------------------------------------------

Kris Jurka wrote:
>
> The attached patch allows SET CONSTRAINTS to take a schema qualified
> constraint name (myschema.t1_fk_t2) and when given a bare constraint name
> it uses the search_path to determine the matching constraint instead of
> the previous behavior of disabling all identically named constraints.
>
> Kris Jurka

Content-Description:

[ Attachment, skipping... ]

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +