Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Repetitive code in RI triggers

Lists: pgsql-hackers
From: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Repetitive code in RI triggers
Date: 2017-04-10 15:55:04
Message-ID: ca7064a7-6adc-6f22-ca47-8615ba9425a5@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,

I was looking through the RI triggers code recently and noticed a few
almost identical functions, e.g. ri_restrict_upd() and
ri_restrict_del(). The following patch is an attempt to reduce some of
repetitive code. Yet there is still room for improvement.

Thanks,
--
Ildar Musin
i(dot)musin(at)postgrespro(dot)ru

Attachment Content-Type Size
ri_patch.diff text/x-patch 27.4 KB

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Repetitive code in RI triggers
Date: 2017-04-11 01:41:27
Message-ID: 47da34d3-35d1-b35d-921e-75365207bbac@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 4/10/17 11:55, Ildar Musin wrote:
> I was looking through the RI triggers code recently and noticed a few
> almost identical functions, e.g. ri_restrict_upd() and
> ri_restrict_del(). The following patch is an attempt to reduce some of
> repetitive code.

That looks like something worth pursuing. Please add it to the next
commit fest.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: Repetitive code in RI triggers
Date: 2017-09-19 08:09:04
Message-ID: 16566BD9-C3BD-490A-B1B9-41C62081C486@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> On 11 Apr 2017, at 03:41, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>
> On 4/10/17 11:55, Ildar Musin wrote:
>> I was looking through the RI triggers code recently and noticed a few
>> almost identical functions, e.g. ri_restrict_upd() and
>> ri_restrict_del(). The following patch is an attempt to reduce some of
>> repetitive code.
>
> That looks like something worth pursuing. Please add it to the next
> commit fest.

Removing reviewer Maksim Milyutin from patch entry due to inactivity and
community account email bouncing. Maksim: if you are indeed reviewing this
patch, then please update the community account and re-add to the patch entry.

cheers ./daniel


From: Maksim Milyutin <milyutinma(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>, Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: Repetitive code in RI triggers
Date: 2017-09-26 08:51:26
Message-ID: e315af79-01fb-73bb-9ba6-749505395723@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 19.09.2017 11:09, Daniel Gustafsson wrote:

> Removing reviewer Maksim Milyutin from patch entry due to inactivity and
> community account email bouncing. Maksim: if you are indeed reviewing this
> patch, then please update the community account and re-add to the patch entry.
>
> cheers ./daniel

Daniel, thanks for noticing. I have updated my account and re-added to
the patch entry.

Ildar, your patch is conflicting with the current HEAD of master branch,
please update it.

--
Regards,
Maksim Milyutin


From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Maksim Milyutin <milyutinma(at)gmail(dot)com>
Cc: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: Repetitive code in RI triggers
Date: 2017-09-26 08:53:11
Message-ID: 4B1F460F-DD51-4235-98C0-46471AA1AA3D@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> On 26 Sep 2017, at 10:51, Maksim Milyutin <milyutinma(at)gmail(dot)com> wrote:
>
> On 19.09.2017 11:09, Daniel Gustafsson wrote:
>
>> Removing reviewer Maksim Milyutin from patch entry due to inactivity and
>> community account email bouncing. Maksim: if you are indeed reviewing this
>> patch, then please update the community account and re-add to the patch entry.
>>
>> cheers ./daniel
>
> Daniel, thanks for noticing. I have updated my account and re-added to the patch entry.

Great, thanks!

> Ildar, your patch is conflicting with the current HEAD of master branch, please update it.

I’ve changed status to Waiting on Author based on this.

cheers ./daniel


From: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
To: Maksim Milyutin <milyutinma(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: Repetitive code in RI triggers
Date: 2017-10-03 10:48:43
Message-ID: b5853239-8fe6-8821-1580-1e6a86e48074@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Maksim,

On 26.09.2017 11:51, Maksim Milyutin wrote:
> On 19.09.2017 11:09, Daniel Gustafsson wrote:
>
>> Removing reviewer Maksim Milyutin from patch entry due to inactivity and
>> community account email bouncing. Maksim: if you are indeed reviewing
>> this
>> patch, then please update the community account and re-add to the
>> patch entry.
>>
>> cheers ./daniel
>
> Daniel, thanks for noticing. I have updated my account and re-added to
> the patch entry.
>
> Ildar, your patch is conflicting with the current HEAD of master branch,
> please update it.
>

Thank you for checking the patch out. Yes, it seems that original code
was reformatted and this led to merging conflicts. I've fixed that and
also introduced some minor improvements. The new version is in attachment.

Thanks!

--
Ildar Musin
i(dot)musin(at)postgrespro(dot)ru

Attachment Content-Type Size
ri_triggers_v2.patch text/x-patch 27.4 KB

From: Ildus Kurbangaliev <i(dot)kurbangaliev(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
Subject: Re: Repetitive code in RI triggers
Date: 2017-11-17 15:05:31
Message-ID: 20171117150531.1377.56306.pgcf@coridan.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The following review has been posted through the commitfest application:
make installcheck-world: tested, failed
Implements feature: tested, failed
Spec compliant: tested, failed
Documentation: tested, failed

The patch looks good. It just removes repetitive code and I think it's ready to commit.

The new status of this patch is: Ready for Committer


From: Ildus Kurbangaliev <i(dot)kurbangaliev(at)postgrespro(dot)ru>
To: Ildus Kurbangaliev <i(dot)kurbangaliev(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
Subject: Re: Repetitive code in RI triggers
Date: 2017-11-17 15:08:53
Message-ID: 20171117180853.6946a9e4@wp.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 17 Nov 2017 15:05:31 +0000
Ildus Kurbangaliev <i(dot)kurbangaliev(at)gmail(dot)com> wrote:

> The following review has been posted through the commitfest
> application: make installcheck-world: tested, failed
> Implements feature: tested, failed
> Spec compliant: tested, failed
> Documentation: tested, failed
>
> The patch looks good. It just removes repetitive code and I think
> it's ready to commit.
>
> The new status of this patch is: Ready for Committer

"tested, failed" should be read as "tested, passed". Forgot to check
them.

--
---
Ildus Kurbangaliev
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
Cc: Maksim Milyutin <milyutinma(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: [HACKERS] Repetitive code in RI triggers
Date: 2017-11-18 21:31:16
Message-ID: 25372.1511040676@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Ildar Musin <i(dot)musin(at)postgrespro(dot)ru> writes:
> [ ri_triggers_v2.patch ]

Pushed with two minor improvements. I noticed that ri_setdefault could
just go directly to ri_restrict rather than call the two separate triggers
that would end up there anyway; that lets its argument be "TriggerData
*trigdata" for more consistency with the other cases. Also, this patch
made it very obvious that we were caching identical queries under hash
keys RI_PLAN_RESTRICT_DEL_CHECKREF and RI_PLAN_RESTRICT_UPD_CHECKREF,
so we might as well just use one hash entry for both cases, saving a few
lines of code as well as a lot of cycles. Likewise in the other two
functions.

regards, tom lane


From: Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Maksim Milyutin <milyutinma(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: [HACKERS] Repetitive code in RI triggers
Date: 2017-11-20 08:53:38
Message-ID: 557339c8-46f0-666a-8a3d-e5a3ba35daf6@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 19.11.2017 00:31, Tom Lane wrote:
> Ildar Musin <i(dot)musin(at)postgrespro(dot)ru> writes:
>> [ ri_triggers_v2.patch ]
>
> Pushed with two minor improvements. I noticed that ri_setdefault could
> just go directly to ri_restrict rather than call the two separate triggers
> that would end up there anyway; that lets its argument be "TriggerData
> *trigdata" for more consistency with the other cases. Also, this patch
> made it very obvious that we were caching identical queries under hash
> keys RI_PLAN_RESTRICT_DEL_CHECKREF and RI_PLAN_RESTRICT_UPD_CHECKREF,
> so we might as well just use one hash entry for both cases, saving a few
> lines of code as well as a lot of cycles. Likewise in the other two
> functions.
>
> regards, tom lane
>

Great, thanks

--
Ildar Musin
i(dot)musin(at)postgrespro(dot)ru