Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-06-06 Thread Albe Laurenz
Tom Lane wrote: >> Andres Freund writes: >>> Hm, strategically sprinkled CheckTableNotInUse() might do the trick? > > Attached is a proposed patch that closes off this problem. I've tested > it to the extent that it blocks Albe's example and passes check-world. I tested it,

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-06-04 Thread Tom Lane
Michael Paquier writes: > The patch looks good to me, could you add a regression test? Done, thanks for the review. I stuck the test into triggers.sql, which is not completely on point since there are other ways to get to this error. But if we're thinking of it as a

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-06-03 Thread Andres Freund
On 2017-06-03 18:23:33 -0400, Tom Lane wrote: > Attached is a proposed patch that closes off this problem. I've tested > it to the extent that it blocks Albe's example and passes check-world. Cool. > I'm unsure whether to back-patch or not; the main argument for not doing > so is that if any

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-06-03 Thread Michael Paquier
On Sun, Jun 4, 2017 at 7:23 AM, Tom Lane wrote: > I'm unsure whether to back-patch or not; the main argument for not doing > so is that if any extensions are calling DefineIndex() directly, this > would be an API break for them. Given what a weird case this is, I'm not > sure

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-06-03 Thread Tom Lane
I wrote: > Andres Freund writes: >> Hm, strategically sprinkled CheckTableNotInUse() might do the trick? > +1. We can't reasonably make it work: the outer query already has its > list of indexes that need to be inserted into. Also, if you try to > make the index via ALTER

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-05-28 Thread Tom Lane
Andres Freund writes: > On 2017-05-24 08:26:24 -0400, Robert Haas wrote: >> I'm willing to bet that nobody ever thought about that case very hard. >> It seems like we should either make it work or prohibit it, but I >> can't actually see quite how to do either off-hand. > Hm,

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-05-24 Thread Andres Freund
On 2017-05-24 08:26:24 -0400, Robert Haas wrote: > On Mon, May 22, 2017 at 7:05 AM, Albe Laurenz wrote: > > Not that it is a useful use case, but I believe that this is > > a bug that causes index corruption: > > > > CREATE TABLE mytable( > >id integer PRIMARY KEY, >

Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-05-24 Thread Robert Haas
On Mon, May 22, 2017 at 7:05 AM, Albe Laurenz wrote: > Not that it is a useful use case, but I believe that this is > a bug that causes index corruption: > > CREATE TABLE mytable( >id integer PRIMARY KEY, >id2 integer NOT NULL > ); > > CREATE FUNCTION makeindex()

[HACKERS] Index created in BEFORE trigger not updated during INSERT

2017-05-22 Thread Albe Laurenz
Not that it is a useful use case, but I believe that this is a bug that causes index corruption: CREATE TABLE mytable( id integer PRIMARY KEY, id2 integer NOT NULL ); CREATE FUNCTION makeindex() RETURNS trigger LANGUAGE plpgsql AS $$BEGIN CREATE INDEX ON mytable(id2); RETURN NEW;