Re: Problem with trigger makes Detail record be invalid

2018-04-20 Thread Adrian Klaver
On 04/20/2018 01:30 PM, PegoraroF10 wrote: Well, talking about responsabilities, I think one of responsabilities of a mature database is that it can only accept data it was configured for. If you try to store a timestamp in a integer field or a huge numeric value in a Actually there have been

Re: Problem with trigger makes Detail record be invalid

2018-04-20 Thread PegoraroF10
Well, talking about responsabilities, I think one of responsabilities of a mature database is that it can only accept data it was configured for. If you try to store a timestamp in a integer field or a huge numeric value in a smallint field, Postgres will block you because that operation is not

Re: Problem with trigger makes Detail record be invalid

2018-04-20 Thread Adrian Klaver
On 04/20/2018 07:21 AM, David G. Johnston wrote: On 04/19/2018 06:49 PM, PegoraroF10 wrote: On Fri, Apr 20, 2018 at 6:55 AM, Adrian Klaver >wrote: I know I did that trigger incorrectly but referential integrity is

Re: Problem with trigger makes Detail record be invalid

2018-04-20 Thread Adrian Klaver
On 04/19/2018 06:49 PM, PegoraroF10 wrote: Correct, that delete done a partial commit. And this is absolutely unacceptable. Yet a known possible outcome. See the section on Triggers towards bottom of page: https://en.wikipedia.org/wiki/Foreign_key I know I did that trigger incorrectly but

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread PegoraroF10
Correct, that delete done a partial commit. And this is absolutely unacceptable. I know I did that trigger incorrectly but referential integrity is obligatory. Imagine if I have a database crash and need to restore as soon as possible. How much time I´ll spend removing those records from a backup

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Ken Tanzer
On Thu, Apr 19, 2018 at 12:21 PM, Tom Lane wrote: > =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= writes: > > 2018-04-19 15:57 GMT-03:00 Tom Lane : > >> (I'm not sure that this issue is adequately documented, though. > >> I'd have

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Tom Lane
=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= writes: > 2018-04-19 15:57 GMT-03:00 Tom Lane : >> (I'm not sure that this issue is adequately documented, though. >> I'd have expected to find something about it in triggers.sgml and/or >> create_trigger.sgml,

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread David G. Johnston
On Thu, Apr 19, 2018 at 11:57 AM, Tom Lane wrote: > (I'm not sure that this issue is adequately documented, though. > I'd have expected to find something about it in triggers.sgml and/or > create_trigger.sgml, but in a quick look neither of them mentions foreign > keys.) >

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Fabrízio de Royes Mello
2018-04-19 15:57 GMT-03:00 Tom Lane : > > Adrian Klaver writes: > > On 04/19/2018 10:55 AM, PegoraroF10 wrote: > >> Is this a bug or it´s mine responsability to check that trigger result ? > > > Without seeing exactly what the trigger function on

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Adrian Klaver
On 04/19/2018 11:52 AM, PegoraroF10 wrote: My point of view that there was a partial rollback, just on detail table. If I´ve done a delete from Master and I have a foreign key to it with cascade option, or all records should be deleted or no one should, this is my point. Except you now have a

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Tom Lane
Adrian Klaver writes: > On 04/19/2018 10:55 AM, PegoraroF10 wrote: >> Is this a bug or it´s mine responsability to check that trigger result ? > Without seeing exactly what the trigger function on Detail is doing that > is not answerable. I think the OP is

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread PegoraroF10
My point of view that there was a partial rollback, just on detail table. If I´ve done a delete from Master and I have a foreign key to it with cascade option, or all records should be deleted or no one should, this is my point. Did you see that Master table has no records and Detail table has

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Adrian Klaver
On 04/19/2018 11:30 AM, PegoraroF10 wrote: I know my trigger is incorrect. I know that I can use TG_OP to know what operation is being done. My question is ... Is this a bug or it´s mine responsability to check that trigger result ? I think it´s a bug because if something got wrong on detail

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Adrian Klaver
On 04/19/2018 11:30 AM, PegoraroF10 wrote: I know my trigger is incorrect. I know that I can use TG_OP to know what operation is being done. My question is ... Is this a bug or it´s mine responsability to check that trigger result ? I think it´s a bug because if something got wrong on detail

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread PegoraroF10
I know my trigger is incorrect. I know that I can use TG_OP to know what operation is being done. My question is ... > Is this a bug or it´s mine responsability to check that trigger result ? I think it´s a bug because if something got wrong on detail deletion and it was rolled back, how could

Re: Problem with trigger makes Detail record be invalid

2018-04-19 Thread Adrian Klaver
On 04/19/2018 10:55 AM, PegoraroF10 wrote: I´m using Postgres 10 on ubuntu. suppose a simple Master/Detail structure like this: create table Master(ID integer primary key, name text); create table Detail(ID integer primary key, Master_ID Integer, OtherInfo text); alter table Detail add

Problem with trigger makes Detail record be invalid

2018-04-19 Thread PegoraroF10
I´m using Postgres 10 on ubuntu. suppose a simple Master/Detail structure like this: create table Master(ID integer primary key, name text); create table Detail(ID integer primary key, Master_ID Integer, OtherInfo text); alter table Detail add constraint FKMasterDetail foreign key (Master_ID)