Re: Temparary disable constraint

Lists: pgsql-hackers
From: Hubert FONGARNAND <informatique(dot)internet(at)fiducial(dot)fr>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Temparary disable constraint
Date: 2007-01-16 10:26:37
Message-ID: 1168943197.745.8.camel@hublinux.fidudev.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Is there a way to temporary disable a constraint (without drop and
recreating it) in postgresql?

Thanks
_______________________________________________
Ce message et les ventuels documents joints peuvent contenir des informations confidentielles.
Au cas o il ne vous serait pas destin, nous vous remercions de bien vouloir le supprimer et en aviser immdiatement l'expditeur. Toute utilisation de ce message non conforme sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Les communications sur internet n'tant pas scurises, l'intgrit de ce message n'est pas assure et la socit mettrice ne peut tre tenue pour responsable de son contenu.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Hubert FONGARNAND <informatique(dot)internet(at)fiducial(dot)fr>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temparary disable constraint
Date: 2007-01-17 03:02:34
Message-ID: 200701170302.l0H32Yn23178@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hubert FONGARNAND wrote:
> Hi,
>
> Is there a way to temporary disable a constraint (without drop and
> recreating it) in postgresql?

Sure, try ALTER TABLE ... DISABLE TRIGGER for the constraint trigger
name.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

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


From: Hubert FONGARNAND <informatique(dot)internet(at)fiducial(dot)fr>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temparary disable constraint
Date: 2007-01-17 08:36:49
Message-ID: 1169023009.25076.3.camel@hublinux.fidudev.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Ok it works, but we have to write a plpgsql function that takes the
table_name and the constraint name in parameters....

It could be useful to have a : ALTER TABLE ... DISABLE CONSTRAINT ...
(as oracle does)

it could be good to add this to the TODO LIST...

Thanks

Le mardi 16 janvier 2007 à 22:02 -0500, Bruce Momjian a écrit :

> Hubert FONGARNAND wrote:
> > Hi,
> >
> > Is there a way to temporary disable a constraint (without drop and
> > recreating it) in postgresql?
>
> Sure, try ALTER TABLE ... DISABLE TRIGGER for the constraint trigger
> name.
>
_______________________________________________
Ce message et les ventuels documents joints peuvent contenir des informations confidentielles.
Au cas o il ne vous serait pas destin, nous vous remercions de bien vouloir le supprimer et en aviser immdiatement l'expditeur. Toute utilisation de ce message non conforme sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Les communications sur internet n'tant pas scurises, l'intgrit de ce message n'est pas assure et la socit mettrice ne peut tre tenue pour responsable de son contenu.


From: "Adnan DURSUN" <a_dursun(at)hotmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temparary disable constraint
Date: 2007-01-17 09:14:25
Message-ID: BAY106-DAV22F57FEFAF966AA4CD60B6FAAB0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,
Maybe added more further things to TODO list. Enabled / disabled other objects like view/funtion. imagine a lot of views that referances a table and i wanna drop a column on this table that used by these views. Postgres doesnt allow this. First i must drop these views then drop the column on that table and then recreate these views.
Can this be resolved (like oracle does) ?

Best regards

Adnan DURSUN
ASRIN Bilişim Ltd.
----- Original Message -----
From: Hubert FONGARNAND
To: Bruce Momjian
Cc: pgsql-hackers(at)postgresql(dot)org
Sent: Wednesday, January 17, 2007 10:36 AM
Subject: Re: [HACKERS] Temparary disable constraint

Ok it works, but we have to write a plpgsql function that takes the table_name and the constraint name in parameters....

It could be useful to have a : ALTER TABLE ... DISABLE CONSTRAINT ...
(as oracle does)

it could be good to add this to the TODO LIST...

Thanks

Le mardi 16 janvier 2007 à 22:02 -0500, Bruce Momjian a écrit :
Hubert FONGARNAND wrote:
> Hi,
>
> Is there a way to temporary disable a constraint (without drop and
> recreating it) in postgresql?

Sure, try ALTER TABLE ... DISABLE TRIGGER for the constraint trigger
name.

_______________________________________________
Ce message et les 鶥ntuels documents joints peuvent contenir des informations confidentielles.
Au cas o?ne vous serait pas destin鬠nous vous remercions de bien vouloir le supprimer et en aviser imm餩atement l'exp餩teur. Toute utilisation de ce message non conforme ࠳a destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Les communications sur internet n'鴡nt pas s飵ris饳, l'int駲it頤e ce message n'est pas assur饠et la soci鴩 魥ttrice ne peut 괲e tenue pour responsable de son contenu.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Hubert FONGARNAND <informatique(dot)internet(at)fiducial(dot)fr>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temparary disable constraint
Date: 2007-01-17 15:48:37
Message-ID: 200701171548.l0HFmbI22698@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hubert FONGARNAND wrote:
> Ok it works, but we have to write a plpgsql function that takes the
> table_name and the constraint name in parameters....
>
> It could be useful to have a : ALTER TABLE ... DISABLE CONSTRAINT ...
> (as oracle does)
>
> it could be good to add this to the TODO LIST...

Well, we currently only allow disabling foreign key constraints (those
that have triggers). There is no way to disable a UNIQUE or NOT NULL
constraint, for example, so I don't see how we can do DISABLE CONSTRAINT
cleanly.

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

>
> Thanks
>
>
>
> Le mardi 16 janvier 2007 ? 22:02 -0500, Bruce Momjian a ?crit :
>
> > Hubert FONGARNAND wrote:
> > > Hi,
> > >
> > > Is there a way to temporary disable a constraint (without drop and
> > > recreating it) in postgresql?
> >
> > Sure, try ALTER TABLE ... DISABLE TRIGGER for the constraint trigger
> > name.
> >
> _______________________________________________
> Ce message et les ?entuels documents joints peuvent contenir des informations confidentielles.
> Au cas o?il ne vous serait pas destin? nous vous remercions de bien vouloir le supprimer et en aviser imm?iatement l'exp?iteur. Toute utilisation de ce message non conforme ?sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
> Les communications sur internet n'?ant pas s?uris?s, l'int?rit?de ce message n'est pas assur? et la soci???ettrice ne peut ?re tenue pour responsable de son contenu.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Adnan DURSUN <a_dursun(at)hotmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Temparary disable constraint
Date: 2007-01-17 15:49:22
Message-ID: 200701171549.l0HFnMl22811@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Adnan DURSUN wrote:
> Hi, Maybe added more further things to TODO list. Enabled /
> disabled other objects like view/funtion. imagine a lot of
> views that referances a table and i wanna drop a column on this
> table that used by these views. Postgres doesnt allow this.
> First i must drop these views then drop the column on that
> table and then recreate these views. Can this be resolved
> (like oracle does) ?

Not easily, because the view are bound to the object id of the tables
involved.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

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


From: "Adnan DURSUN" <a_dursun(at)hotmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temparary disable constraint
Date: 2007-01-18 15:20:29
Message-ID: BAY106-DAV175F3FAA132599A5BE1908FAAA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Maybe you are right as technically but this behaver causes a lot
of maintance problem on a database that alot of view and functions that
depends on a table or a type. I think objects has a property if that object
is enable or not. We hope this problem can be resolved at 8.4 release.

Best Regards

Adnan DURSUN
ASRIN Bilisim Ltd.

----- Original Message -----
From: "Bruce Momjian" <bruce(at)momjian(dot)us>
To: "Adnan DURSUN" <a_dursun(at)hotmail(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Wednesday, January 17, 2007 5:49 PM
Subject: Re: [HACKERS] Temparary disable constraint

> Adnan DURSUN wrote:
>> Hi, Maybe added more further things to TODO list. Enabled /
>> disabled other objects like view/funtion. imagine a lot of
>> views that referances a table and i wanna drop a column on this
>> table that used by these views. Postgres doesnt allow this.
>> First i must drop these views then drop the column on that
>> table and then recreate these views. Can this be resolved
>> (like oracle does) ?
>
> Not easily, because the view are bound to the object id of the tables
> involved.
>
> --
> Bruce Momjian bruce(at)momjian(dot)us
> EnterpriseDB http://www.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


From: Richard Huxton <dev(at)archonet(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Adnan DURSUN <a_dursun(at)hotmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Temparary disable constraint
Date: 2007-01-18 15:57:09
Message-ID: 45AF98D5.8080209@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> Adnan DURSUN wrote:
>> Hi, Maybe added more further things to TODO list. Enabled /
>> disabled other objects like view/funtion. imagine a lot of
>> views that referances a table and i wanna drop a column on this
>> table that used by these views. Postgres doesnt allow this.
>> First i must drop these views then drop the column on that
>> table and then recreate these views. Can this be resolved
>> (like oracle does) ?
>
> Not easily, because the view are bound to the object id of the tables
> involved.

The trick would be I think to bind them to individual columns, so if
view V doesn't mention column C then dropping C has no effect on it.

That's a lot more dependencies to track of course.

--
Richard Huxton
Archonet Ltd


From: "Adnan DURSUN" <a_dursun(at)hotmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temparary disable constraint
Date: 2007-01-18 22:09:17
Message-ID: BAY106-DAV119B8C02FE8CD82F7D0573FAAA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

----- Original Message -----
From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Adnan DURSUN" <a_dursun(at)hotmail(dot)com>; <pgsql-hackers(at)postgresql(dot)org>
Sent: Thursday, January 18, 2007 5:57 PM
Subject: Re: [HACKERS] Temparary disable constraint

>> Not easily, because the view are bound to the object id of the tables
>> involved.
>
> The trick would be I think to bind them to individual columns, so if view
> V doesn't mention column C then dropping C has no effect on it.
>
> That's a lot more dependencies to track of course.
>
Is that not possible that all objects have a column that says whether
object state is ok or not.
When any session wants to try to execute any DML on object, then the
Postgres checks that state column.
If object state is not ok then Postgres raises an exception.

Best Regards

Adnan DURSUN
ASRIN Bilisim Ltd.