Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-05-19 Thread Michael Paquier
On Fri, May 17, 2019 at 06:37:22PM -0700, Peter Geoghegan wrote: > On Fri, May 17, 2019 at 6:36 PM Tom Lane wrote: >> Will do so tomorrow. Should we back-patch this? > > I wouldn't, because I see no reason to. Somebody else might. FWIW, I see no reason either for a back-patch. -- Michael sign

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-05-17 Thread Peter Geoghegan
On Fri, May 17, 2019 at 6:36 PM Tom Lane wrote: > Will do so tomorrow. Should we back-patch this? I wouldn't, because I see no reason to. Somebody else might. -- Peter Geoghegan

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-05-17 Thread Tom Lane
Peter Geoghegan writes: > On Tue, Apr 30, 2019 at 3:22 PM Tom Lane wrote: >> So now I'm feeling more favorable about the idea of adding a >> PrepareTempTablespaces call to BufFileCreateTemp, and just stopping >> with that. If we want to do more, I feel like it requires a >> significant amount of

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-05-17 Thread Peter Geoghegan
On Tue, Apr 30, 2019 at 3:22 PM Tom Lane wrote: > So now I'm feeling more favorable about the idea of adding a > PrepareTempTablespaces call to BufFileCreateTemp, and just stopping > with that. If we want to do more, I feel like it requires a > significant amount of rethinking about what the expe

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-30 Thread Tom Lane
I wrote: > So maybe a reasonable compromise is to add the Assert(s) in fd.c as > per previous patch, but *also* add PrepareTempTablespaces in > BufFileCreateTemp, so that at least users of buffile.c are insulated > from the issue. buffile.c is still kind of low-level, but it's not > part of core i

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-30 Thread Tom Lane
Melanie Plageman writes: > I also think that if there is a step that a caller should always take before > calling a function, then there needs to be a very compelling reason not to > move that step into the function itself. Fair complaint. > PrepareTempTablespaces should not be called in BufFile

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-30 Thread Melanie Plageman
On Fri, Apr 26, 2019 at 8:05 AM Tom Lane wrote: > The version that I posted left it to GetNextTempTableSpace to assert > that. That seemed cleaner to me than an Assert that has to depend > on interXact. > > Running `make check` with [1] applied and one of the calls to PrepareTempTablespaces comm

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-29 Thread Peter Geoghegan
On Mon, Apr 29, 2019 at 12:31 PM Ashwin Agrawal wrote: > Well the one thing I wish to point out explicitly is just taking fd.c > changes from [1], and running make check hits no assertions and > doesn't flag issue exist for gistbuildbuffers.c. Means its missing > coverage and in future same can ha

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-29 Thread Ashwin Agrawal
On Thu, Apr 25, 2019 at 11:53 PM Michael Paquier wrote: > > On Thu, Apr 25, 2019 at 12:45:03PM -0400, Tom Lane wrote: > > I still remain concerned that invoking catalog lookups from fd.c is a darn > > bad idea, even if we have a fallback for it to work (for some value of > > "work") in non-transac

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-26 Thread Michael Paquier
On Fri, Apr 26, 2019 at 11:05:11AM -0400, Tom Lane wrote: > Michael Paquier writes: > The version that I posted left it to GetNextTempTableSpace to assert > that. That seemed cleaner to me than an Assert that has to depend > on interXact. Okay, no objections for that approach as well. Are you p

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-26 Thread Tom Lane
Michael Paquier writes: > I think that one piece is missing from the patch. Wouldn't it be > better to add an assertion at the beginning of OpenTemporaryFile() to > make sure that PrepareTempTablespaces() has been called when interXact > is true? We could just go with that: > Assert(!interXact |

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-25 Thread Michael Paquier
On Thu, Apr 25, 2019 at 10:40:01AM -0700, Ashwin Agrawal wrote: > Is there (easy) way to assert for that assumption? If yes, then can add the > same and make it not rickety. IsTransactionState() would be enough? -- Michael signature.asc Description: PGP signature

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-25 Thread Michael Paquier
On Thu, Apr 25, 2019 at 12:45:03PM -0400, Tom Lane wrote: > I still remain concerned that invoking catalog lookups from fd.c is a darn > bad idea, even if we have a fallback for it to work (for some value of > "work") in non-transactional states. It's not really hard to envision > that kind of thi

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-25 Thread Ashwin Agrawal
On Thu, Apr 25, 2019 at 9:45 AM Tom Lane wrote: > However, by that argument we should change all 3 of these functions to > set up the data. If we're eating the layering violation to the extent > of letting OpenTemporaryFile call into commands/tablespace, then there's > little reason for the othe

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-25 Thread Melanie Plageman
On Thu, Apr 25, 2019 at 9:19 AM Ashwin Agrawal wrote: > Just to provide my opinion, since we are at intersection and can go > either way on this. Second approach (just adding assert) only helps > if the code path for ALL future callers gets excersied and test exist for > the > same, to expose pot

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-25 Thread Tom Lane
Ashwin Agrawal writes: > On Wed, Apr 24, 2019 at 5:48 PM Peter Geoghegan wrote: >> Like you, I find it hard to prefer one of the approaches over the >> other, though I don't really know how to assess this layering >> business. I'm glad that either approach will prevent oversights, >> though. > J

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-25 Thread Ashwin Agrawal
On Wed, Apr 24, 2019 at 5:48 PM Peter Geoghegan wrote: > On Wed, Apr 24, 2019 at 12:17 PM Tom Lane wrote: > > After a bit more thought it seemed like another answer would be to > > make all three of those functions assert that the caller did the > > right thing, as per attached. This addresses

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-24 Thread Tom Lane
Peter Geoghegan writes: > ... I'm not > seeing why the context that the PrepareTempTablespaces() catalog > access occurs in actually matters. The point there is that a catalog access might leak some amount of memory. Probably not enough to be a big deal, but ... regards,

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-24 Thread Peter Geoghegan
On Wed, Apr 24, 2019 at 12:17 PM Tom Lane wrote: > After a bit more thought it seemed like another answer would be to > make all three of those functions assert that the caller did the > right thing, as per attached. This addresses the layering-violation > complaint, but might be more of a pain i

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-24 Thread Tom Lane
I wrote: > Here's a draft patch for that. > > It's slightly ugly that this adds a dependency on commands/tablespace > to fd.c, which is a pretty low-level module. I think wanting to avoid > that layering violation might've been the reason for doing things the > way they are. However, this gets ri

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-24 Thread Melanie Plageman
On Tue, Apr 23, 2019 at 1:06 PM Tom Lane wrote: > There are three functions in fd.c that have a dependency on the > temp tablespace info having been set up: > OpenTemporaryFile > GetTempTablespaces > GetNextTempTableSpace > This patch makes the first of those automatically

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-23 Thread Tom Lane
I wrote: > Peter Geoghegan writes: >> That doesn't seem like a particularly good or complete answer, though. >> Perhaps it should simply be called within BufFileCreateTemp(). The >> BufFile/fd.c layering is confusing in a number of ways IMV. > I don't actually see why BufFileCreateTemp should do

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-22 Thread Tom Lane
Peter Geoghegan writes: > On Mon, Apr 22, 2019 at 3:12 PM Melanie Plageman > wrote: >> PrepareTempTablespaces is called by most callers of BufFileCreateTemp, so I >> was >> wondering if there is a reason not to call it inside BufFileCreateTemp. > The best answer I can think of is that a BufFile

Re: Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-22 Thread Peter Geoghegan
On Mon, Apr 22, 2019 at 3:12 PM Melanie Plageman wrote: > PrepareTempTablespaces is called by most callers of BufFileCreateTemp, so I > was > wondering if there is a reason not to call it inside BufFileCreateTemp. The best answer I can think of is that a BufFileCreateTemp() caller might not want

Calling PrepareTempTablespaces in BufFileCreateTemp

2019-04-22 Thread Melanie Plageman
Hi, PrepareTempTablespaces is called by most callers of BufFileCreateTemp, so I was wondering if there is a reason not to call it inside BufFileCreateTemp. As a developer using BufFileCreateTemp to write code that will create spill files, it was easy to forget the extra step of checking the temp_t