Re: [HACKERS] [PATCH] Lockable views

2018-04-16 Thread Yugo Nagata
On Thu, 05 Apr 2018 07:53:42 +0900 (JST) Tatsuo Ishii wrote: I update the patch to fix the lockable view issues. > >> > > +typedef struct > >> > > +{ > >> > > + Oid root_reloid; > >> > > + LOCKMODE lockmode; > >> > > + bool nowait; > >> > > + Oid viewowner; > >> > > + Oi

Re: [HACKERS] [PATCH] Lockable views

2018-04-04 Thread Tatsuo Ishii
>> > > +typedef struct >> > > +{ >> > > +Oid root_reloid; >> > > +LOCKMODE lockmode; >> > > +bool nowait; >> > > +Oid viewowner; >> > > +Oid viewoid; >> > > +} LockViewRecurse_context; >> > >> > Probably wouldn't hurt to pgindent the larger changes in the pa

Re: [HACKERS] [PATCH] Lockable views

2018-04-02 Thread Yugo Nagata
On Mon, 2 Apr 2018 18:32:53 +0900 Yugo Nagata wrote: > On Thu, 29 Mar 2018 17:26:36 -0700 > Andres Freund wrote: > > Thank you for your comments. I attach a patch to fix issues > you've pointed out. I found a typo in the documentation and attach the updated patch. Regards, > > > Hi, > > >

Re: [HACKERS] [PATCH] Lockable views

2018-04-02 Thread Yugo Nagata
On Thu, 29 Mar 2018 17:26:36 -0700 Andres Freund wrote: Thank you for your comments. I attach a patch to fix issues you've pointed out. > Hi, > > On 2018-03-28 20:26:48 +0900, Yugo Nagata wrote: > > diff --git a/doc/src/sgml/ref/lock.sgml b/doc/src/sgml/ref/lock.sgml > > index b2c7203..96d477c

Re: [HACKERS] [PATCH] Lockable views

2018-03-30 Thread Tatsuo Ishii
>> The buildfarm is fairly unhappy, and I think it's because of this patch. > > Thanks for the info. Yes, at least prion is unhappy because of the > patch. I will look into this. Done. See if the buildarm becomes happy. Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss

Re: [HACKERS] [PATCH] Lockable views

2018-03-30 Thread Tatsuo Ishii
>> I have just pushed the v10 patch. > > The buildfarm is fairly unhappy, and I think it's because of this patch. Thanks for the info. Yes, at least prion is unhappy because of the patch. I will look into this. Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss.co.jp/in

Re: [HACKERS] [PATCH] Lockable views

2018-03-30 Thread Tom Lane
Tatsuo Ishii writes: > I have just pushed the v10 patch. The buildfarm is fairly unhappy, and I think it's because of this patch. regards, tom lane

Re: [HACKERS] [PATCH] Lockable views

2018-03-29 Thread Tatsuo Ishii
Andres, I have just pushed the v10 patch. Yugo will reply back to your point but I will look into your review as well. Thanks. Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss.co.jp/index_en.php Japanese:http://www.sraoss.co.jp > Hi, > > On 2018-03-28 20:26:48 +0900

Re: [HACKERS] [PATCH] Lockable views

2018-03-29 Thread Andres Freund
Hi, On 2018-03-28 20:26:48 +0900, Yugo Nagata wrote: > diff --git a/doc/src/sgml/ref/lock.sgml b/doc/src/sgml/ref/lock.sgml > index b2c7203..96d477c 100644 > --- a/doc/src/sgml/ref/lock.sgml > +++ b/doc/src/sgml/ref/lock.sgml > @@ -46,6 +46,11 @@ LOCK [ TABLE ] [ ONLY ] class="parameter">name [ *

Re: [HACKERS] [PATCH] Lockable views

2018-03-28 Thread Tatsuo Ishii
> On Wed, 28 Mar 2018 15:45:09 +0900 (JST) > Tatsuo Ishii wrote: > >> >> I found the previous patch was broken and this can't handle >> >> views that has subqueries as bellow; >> >> >> >>  CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub; >> >> >> >> I fixed this and attach

Re: [HACKERS] [PATCH] Lockable views

2018-03-28 Thread Yugo Nagata
On Wed, 28 Mar 2018 15:45:09 +0900 (JST) Tatsuo Ishii wrote: > >> I found the previous patch was broken and this can't handle > >> views that has subqueries as bellow; > >> > >>  CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub; > >> > >> I fixed this and attached the updat

Re: [HACKERS] [PATCH] Lockable views

2018-03-27 Thread Tatsuo Ishii
>> I found the previous patch was broken and this can't handle >> views that has subqueries as bellow; >> >>  CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub; >> >> I fixed this and attached the updated version including additional tests. > > This patch gives a warning whil

Re: [HACKERS] [PATCH] Lockable views

2018-03-27 Thread Tatsuo Ishii
> On Tue, 27 Mar 2018 23:28:04 +0900 > Yugo Nagata wrote: > > I found the previous patch was broken and this can't handle > views that has subqueries as bellow; > >  CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub; > > I fixed this and attached the updated version includin

Re: [HACKERS] [PATCH] Lockable views

2018-03-27 Thread Yugo Nagata
On Tue, 27 Mar 2018 23:28:04 +0900 Yugo Nagata wrote: I found the previous patch was broken and this can't handle views that has subqueries as bellow;  CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub; I fixed this and attached the updated version including additional tests

Re: [HACKERS] [PATCH] Lockable views

2018-03-27 Thread Yugo Nagata
On Tue, 6 Feb 2018 11:12:37 -0500 Robert Haas wrote: > On Tue, Feb 6, 2018 at 1:28 AM, Tatsuo Ishii wrote: > >> But what does that have to do with locking? > > > > Well, if the view is not updatable, I think there will be less point > > to allow to lock the base tables in the view because lockin

Re: [HACKERS] [PATCH] Lockable views

2018-02-06 Thread Robert Haas
On Tue, Feb 6, 2018 at 1:28 AM, Tatsuo Ishii wrote: >> But what does that have to do with locking? > > Well, if the view is not updatable, I think there will be less point > to allow to lock the base tables in the view because locking is > typically used in a case when updates are required. > > Of

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Tatsuo Ishii
> But what does that have to do with locking? Well, if the view is not updatable, I think there will be less point to allow to lock the base tables in the view because locking is typically used in a case when updates are required. Of course we could add special triggers to allow to update views t

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Robert Haas
On Mon, Feb 5, 2018 at 10:49 PM, Tatsuo Ishii wrote: >> Hmm, true. Why exactly are we imposing the restriction to updateable >> views, anyway? > > In my understanding, because of ambiguity to determine which rows in > which base tables needs to be modified by just looking at the DML > against a v

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Tatsuo Ishii
> Hmm, true. Why exactly are we imposing the restriction to updateable > views, anyway? In my understanding, because of ambiguity to determine which rows in which base tables needs to be modified by just looking at the DML against a view. There could be multiple ways to modify the base tables. B

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Robert Haas
On Mon, Feb 5, 2018 at 10:26 PM, Tatsuo Ishii wrote: >> True. But the same exact analysis also applies to this definition, >> which contains no subquery: >> >> CREATE VIEW v1 AS SELECT t1.* FROM t1, t2 WHERE t1.i = t2.i; > > That's not an updatable view, thus cannot be locked according to the > p

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Tatsuo Ishii
> True. But the same exact analysis also applies to this definition, > which contains no subquery: > > CREATE VIEW v1 AS SELECT t1.* FROM t1, t2 WHERE t1.i = t2.i; That's not an updatable view, thus cannot be locked according to the proposed implementation. Anyway do you want to allow to lock a

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Robert Haas
On Mon, Feb 5, 2018 at 8:18 PM, Tatsuo Ishii wrote: > We have: CREATE VIEW v1 AS SELECT * FROM t1 WHERE i = (SELECT i FROM t2); > > 1. Session A tries to lock v1 (I suppose it tries to acquire lock in > the order of t1, then t2). A acquires lock on t1 but yet on t2. > > 2. Another session B acquir

Re: [HACKERS] [PATCH] Lockable views

2018-02-05 Thread Tatsuo Ishii
Robert, > I just reread those discussions but I don't see that they really make > any argument for the behavior the patch implements. I see no > explanation on the thread for why locking a table inside of a subquery > is more or less likely to cause deadlock than locking one outside of a > subque

Re: [HACKERS] [PATCH] Lockable views

2018-02-02 Thread Robert Haas
On Thu, Feb 1, 2018 at 8:09 PM, Tatsuo Ishii wrote: > Initially I thought all base tables including ones in a subquery also > should be locked like you. But after some discussions with Yugo, I > agree that locking table in a subquery is less valuable for users (and > I am afraid it may introduce m

Re: [HACKERS] [PATCH] Lockable views

2018-02-01 Thread Tatsuo Ishii
> On Tue, Jan 30, 2018 at 1:21 AM, Thomas Munro > wrote: >> About the idea: it makes some kind of sense to me that we should lock >> the underlying table, in all the same cases that you could do DML on >> the view automatically. I wonder if this is a problem for the >> soundness: "Tables appear

Re: [HACKERS] [PATCH] Lockable views

2018-02-01 Thread Robert Haas
On Tue, Jan 30, 2018 at 1:21 AM, Thomas Munro wrote: > About the idea: it makes some kind of sense to me that we should lock > the underlying table, in all the same cases that you could do DML on > the view automatically. I wonder if this is a problem for the > soundness: "Tables appearing in a

Re: [HACKERS] [PATCH] Lockable views

2018-01-31 Thread Yugo Nagata
On Thu, 01 Feb 2018 09:48:49 +0900 (JST) Tatsuo Ishii wrote: > > On Tue, Jan 30, 2018 at 6:48 PM, Tatsuo Ishii wrote: > >> Looks good to me. If there's no objection, especially from Thomas > >> Munro, I will mark this as "ready for committer". > > > > No objection from me. > > I marked this as

Re: [HACKERS] [PATCH] Lockable views

2018-01-31 Thread Tatsuo Ishii
> On Tue, Jan 30, 2018 at 6:48 PM, Tatsuo Ishii wrote: >> Looks good to me. If there's no objection, especially from Thomas >> Munro, I will mark this as "ready for committer". > > No objection from me. I marked this as "Ready for Committer". Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan En

Re: [HACKERS] [PATCH] Lockable views

2018-01-31 Thread Thomas Munro
On Tue, Jan 30, 2018 at 6:48 PM, Tatsuo Ishii wrote: > Looks good to me. If there's no objection, especially from Thomas > Munro, I will mark this as "ready for committer". No objection from me. -- Thomas Munro http://www.enterprisedb.com

Re: [HACKERS] [PATCH] Lockable views

2018-01-31 Thread Yugo Nagata
On Tue, 30 Jan 2018 19:21:04 +1300 Thomas Munro wrote: > On Tue, Jan 30, 2018 at 6:48 PM, Tatsuo Ishii wrote: > >>> You need to DROP VIEW lock_view4 and lock_view5 in the regression > >>> test as well. > >> > >> Thank you for reviewing the patch. > >> > >> I fixed this and attached a updated pat

Re: [HACKERS] [PATCH] Lockable views

2018-01-29 Thread Thomas Munro
On Tue, Jan 30, 2018 at 6:48 PM, Tatsuo Ishii wrote: >>> You need to DROP VIEW lock_view4 and lock_view5 in the regression >>> test as well. >> >> Thank you for reviewing the patch. >> >> I fixed this and attached a updated patch v6. > > Looks good to me. If there's no objection, especially from T

Re: [HACKERS] [PATCH] Lockable views

2018-01-29 Thread Tatsuo Ishii
>> You need to DROP VIEW lock_view4 and lock_view5 in the regression >> test as well. > > Thank you for reviewing the patch. > > I fixed this and attached a updated patch v6. Looks good to me. If there's no objection, especially from Thomas Munro, I will mark this as "ready for committer". Best

Re: [HACKERS] [PATCH] Lockable views

2018-01-29 Thread Yugo Nagata
On Tue, 30 Jan 2018 13:58:30 +0900 (JST) Tatsuo Ishii wrote: > > Attached is the updated patch v5 including fixing SGML and rebase to HEAD. > > You need to DROP VIEW lock_view4 and lock_view5 in the regression > test as well. Thank you for reviewing the patch. I fixed this and attached a updat

Re: [HACKERS] [PATCH] Lockable views

2018-01-29 Thread Tatsuo Ishii
> Attached is the updated patch v5 including fixing SGML and rebase to HEAD. You need to DROP VIEW lock_view4 and lock_view5 in the regression test as well. Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss.co.jp/index_en.php Japanese:http://www.sraoss.co.jp

Re: [HACKERS] [PATCH] Lockable views

2018-01-29 Thread Yugo Nagata
On Fri, 26 Jan 2018 21:30:49 +0900 Yugo Nagata wrote: > On Thu, 25 Jan 2018 20:51:41 +1300 > Thomas Munro wrote: > > > On Sun, Dec 31, 2017 at 11:57 PM, Yugo Nagata wrote: > > > On Fri, 29 Dec 2017 23:39:39 +0900 (JST) > > > Tatsuo Ishii wrote: > > >> Your addition to the doc: > > >> + Auto

Re: [HACKERS] [PATCH] Lockable views

2018-01-26 Thread Yugo Nagata
On Thu, 25 Jan 2018 20:51:41 +1300 Thomas Munro wrote: > On Sun, Dec 31, 2017 at 11:57 PM, Yugo Nagata wrote: > > On Fri, 29 Dec 2017 23:39:39 +0900 (JST) > > Tatsuo Ishii wrote: > >> Your addition to the doc: > >> + Automatically updatable views (see ) > >> + that do not have INSTEAD OF tr

Re: [HACKERS] [PATCH] Lockable views

2018-01-24 Thread Thomas Munro
On Sun, Dec 31, 2017 at 11:57 PM, Yugo Nagata wrote: > On Fri, 29 Dec 2017 23:39:39 +0900 (JST) > Tatsuo Ishii wrote: >> Your addition to the doc: >> + Automatically updatable views (see ) >> + that do not have INSTEAD OF triggers or INSTEAD >> + rules are also lockable. When a view is lock

Re: [HACKERS] [PATCH] Lockable views

2017-12-31 Thread Yugo Nagata
Hi, The updated patch is attached. On Fri, 29 Dec 2017 23:39:39 +0900 (JST) Tatsuo Ishii wrote: > The patch produces a warning. > > /home/t-ishii/lock_view-v3.patch:542: trailing whitespace. > -- Verify that we can lock a auto-updatable views > warning: 1 line adds whitespace errors. Fixe

Re: [HACKERS] [PATCH] Lockable views

2017-12-29 Thread Tatsuo Ishii
>> >> > 1) Leave as it is (ignore tables appearing in a subquery) >> >> > >> >> > 2) Lock all tables including in a subquery >> >> > >> >> > 3) Check subquery in the view >> > >> >> > So it seem #1 is the most reasonable way to deal with the problem >> >> > assuming that it's user's responsibil

Re: [HACKERS] [PATCH] Lockable views

2017-12-28 Thread Yugo Nagata
On Thu, 28 Dec 2017 09:29:11 +0900 (JST) Tatsuo Ishii wrote: > > I didn't want to change the interface of view_query_is_auto_updatable() > > because this might be called from other third-patry software, so I renamed > > this function to view_query_is_auto_updatable_or_lockable() and added the >

Re: [HACKERS] [PATCH] Lockable views

2017-12-27 Thread Tatsuo Ishii
> I didn't want to change the interface of view_query_is_auto_updatable() > because this might be called from other third-patry software, so I renamed > this function to view_query_is_auto_updatable_or_lockable() and added the flag > to this. I created view_query_is_auto_updatable() as a wrapper of

Re: [HACKERS] [PATCH] Lockable views

2017-12-27 Thread Yugo Nagata
Hi, Attached is the updated patch. On Mon, 16 Oct 2017 10:07:48 +0900 (JST) Tatsuo Ishii wrote: > >> > It would be nice if the message would be something like: > >> > > >> > DETAIL: Views that return aggregate functions are not lockable > You could add a flag to view_query_is_auto_updatable()

Re: [HACKERS] [PATCH] Lockable views

2017-12-27 Thread Yugo Nagata
On Tue, 26 Dec 2017 22:22:33 +0900 Michael Paquier wrote: > On Tue, Dec 26, 2017 at 06:37:06PM +0900, Yugo Nagata wrote: > > I have created a new entry in CF-2017-1 and registered this thread again. > > Fine for me. Thanks for the update. And I guess that you are planning to > send a new version

Re: [HACKERS] [PATCH] Lockable views

2017-12-26 Thread Alvaro Herrera
Yugo Nagata wrote: > On Fri, 27 Oct 2017 07:11:14 +0200 > Robert Haas wrote: > > > On Wed, Oct 11, 2017 at 11:36 AM, Yugo Nagata wrote: > > > In the attached patch, only automatically-updatable views that do not have > > > INSTEAD OF rules or INSTEAD OF triggers are lockable. It is assumed that

Re: [HACKERS] [PATCH] Lockable views

2017-12-26 Thread Michael Paquier
On Tue, Dec 26, 2017 at 06:37:06PM +0900, Yugo Nagata wrote: > I have created a new entry in CF-2017-1 and registered this thread again. Fine for me. Thanks for the update. And I guess that you are planning to send a new version before the beginning of the next commit fest using the feedback provi

Re: [HACKERS] [PATCH] Lockable views

2017-12-26 Thread Yugo Nagata
On Sat, 23 Dec 2017 09:44:30 +0900 Michael Paquier wrote: > On Fri, Dec 22, 2017 at 04:19:46PM +0900, Yugo Nagata wrote: > > I was busy for and I could not work on this patch. After reading the > > previous discussion, I still think the behavior of this patch would > > be right. So, I would like

Re: [HACKERS] [PATCH] Lockable views

2017-12-22 Thread Michael Paquier
On Fri, Dec 22, 2017 at 04:19:46PM +0900, Yugo Nagata wrote: > I was busy for and I could not work on this patch. After reading the > previous discussion, I still think the behavior of this patch would > be right. So, I would like to reregister to CF 2018-1. Do I need to > create a new entry on CF?

Re: [HACKERS] [PATCH] Lockable views

2017-12-21 Thread Yugo Nagata
On Wed, 29 Nov 2017 11:29:36 +0900 Michael Paquier wrote: > On Fri, Oct 27, 2017 at 2:11 PM, Robert Haas wrote: > > On Wed, Oct 11, 2017 at 11:36 AM, Yugo Nagata wrote: > >> In the attached patch, only automatically-updatable views that do not have > >> INSTEAD OF rules or INSTEAD OF triggers a

Re: [HACKERS] [PATCH] Lockable views

2017-12-21 Thread Yugo Nagata
On Fri, 27 Oct 2017 07:11:14 +0200 Robert Haas wrote: > On Wed, Oct 11, 2017 at 11:36 AM, Yugo Nagata wrote: > > In the attached patch, only automatically-updatable views that do not have > > INSTEAD OF rules or INSTEAD OF triggers are lockable. It is assumed that > > those views definition have

Re: [HACKERS] [PATCH] Lockable views

2017-12-19 Thread Yugo Nagata
On Tue, 17 Oct 2017 11:59:05 +0900 (JST) Tatsuo Ishii wrote: > > I'm a bit confused. What is difference between tables and functions > > in a subquery with regard to view locking? I think also none view queries > > using a subquery do not care about the changes of tables in the > > subquery whil

Re: [HACKERS] [PATCH] Lockable views

2017-11-28 Thread Michael Paquier
On Fri, Oct 27, 2017 at 2:11 PM, Robert Haas wrote: > On Wed, Oct 11, 2017 at 11:36 AM, Yugo Nagata wrote: >> In the attached patch, only automatically-updatable views that do not have >> INSTEAD OF rules or INSTEAD OF triggers are lockable. It is assumed that >> those views definition have only