Re: [HACKERS] Disallow unique index on system columns

2016-04-21 Thread Eric Ridge
On Wed, Apr 20, 2016 at 9:24 PM Tom Lane wrote: > > SELECT FROM table WHERE my_func('table', ctid) ==> 'index condition' > > Um, why's the ctid important here, or perhaps more directly, what is > it you're really trying to do? > This function is defined as my_func(regclass, tid) and simply

Re: [HACKERS] Disallow unique index on system columns

2016-04-20 Thread Tom Lane
Eric Ridge writes: > I've got an extension that's actually a custom Access Method, and for > reasons that are probably too boring to go into here, it requires that the > first column in the index be a function that takes the ctid. Ie, something > akin to: >CREATE INDEX idx ON table (my_func('

Re: [HACKERS] Disallow unique index on system columns

2016-04-20 Thread Eric Ridge
On Sat, Apr 16, 2016 at 12:14 PM Tom Lane wrote: > > Pushed. I moved the check into DefineIndex, as that's where user-facing > complaints about indexes generally ought to be. > If you're planning on back-patching this, please don't. :) It'll literally ruin my life. I've got an extension that

Re: [HACKERS] Disallow unique index on system columns

2016-04-16 Thread Tom Lane
David Rowley writes: > On 15 April 2016 at 13:43, David Rowley wrote: >> The attached patch just disallows any index containing a system >> column, apart from OID. > Seems I only did half the job as I forgot to think to check for system > columns that are hidden away inside expressions or predica

Re: [HACKERS] Disallow unique index on system columns

2016-04-15 Thread Tom Lane
Andres Freund writes: > On 2016-04-15 11:49:27 -0400, Tom Lane wrote: >> I think what we should do with this is split it into two patches, one >> to fix ALTER REPLICA IDENTITY's crash (which we'd back-patch to 9.4) >> and one to forbid indexes on system columns (which IMO should be HEAD >> only).

Re: [HACKERS] Disallow unique index on system columns

2016-04-15 Thread Andres Freund
On 2016-04-15 11:49:27 -0400, Tom Lane wrote: > I think what we should do with this is split it into two patches, one > to fix ALTER REPLICA IDENTITY's crash (which we'd back-patch to 9.4) > and one to forbid indexes on system columns (which IMO should be HEAD > only). The first of those should be

Re: [HACKERS] Disallow unique index on system columns

2016-04-15 Thread Tom Lane
David Rowley writes: > On 15 April 2016 at 13:43, David Rowley wrote: >> The attached patch just disallows any index containing a system >> column, apart from OID. > Seems I only did half the job as I forgot to think to check for system > columns that are hidden away inside expressions or predic

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread David Rowley
On 15 April 2016 at 13:43, David Rowley wrote: > The attached patch just disallows any index containing a system > column, apart from OID. Seems I only did half the job as I forgot to think to check for system columns that are hidden away inside expressions or predicates. The attached fixes that

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread David Rowley
On 15 April 2016 at 13:56, Tom Lane wrote: > David Rowley writes: >> On 15 April 2016 at 13:30, Andres Freund wrote: >>> What'd be the point of indexing ctid, and why would it be correct? >>> Wouldn't, hm, HOT break it? > >> I don't personally see the point. > > An index on ctid is useless by de

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread Tom Lane
David Rowley writes: > On 15 April 2016 at 13:30, Andres Freund wrote: >> What'd be the point of indexing ctid, and why would it be correct? >> Wouldn't, hm, HOT break it? > I don't personally see the point. An index on ctid is useless by definition: if you know the ctid of a tuple, you can jus

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread David Rowley
On 15 April 2016 at 13:30, Andres Freund wrote: > On 2016-04-15 13:26:35 +1200, David Rowley wrote: >> On 15 April 2016 at 13:02, Tom Lane wrote: >> > David Rowley writes: >> >> I proposed a fix over there, but it didn't go anywhere, probably >> >> because Tom and Andres discussed just disallowi

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread Andres Freund
On 2016-04-15 13:26:35 +1200, David Rowley wrote: > On 15 April 2016 at 13:02, Tom Lane wrote: > > David Rowley writes: > >> I proposed a fix over there, but it didn't go anywhere, probably > >> because Tom and Andres discussed just disallowing unique indexes on > >> system columns altogether. So

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread David Rowley
On 15 April 2016 at 13:02, Tom Lane wrote: > David Rowley writes: >> I proposed a fix over there, but it didn't go anywhere, probably >> because Tom and Andres discussed just disallowing unique indexes on >> system columns altogether. So, the attached patch does just that, and >> also fixes up th

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread Andres Freund
On 2016-04-14 21:02:26 -0400, Tom Lane wrote: > David Rowley writes: > > I proposed a fix over there, but it didn't go anywhere, probably > > because Tom and Andres discussed just disallowing unique indexes on > > system columns altogether. So, the attached patch does just that, and > > also fixes

Re: [HACKERS] Disallow unique index on system columns

2016-04-14 Thread Tom Lane
David Rowley writes: > I proposed a fix over there, but it didn't go anywhere, probably > because Tom and Andres discussed just disallowing unique indexes on > system columns altogether. So, the attached patch does just that, and > also fixes up the replica identity bugs too, as it's still possibl

[HACKERS] Disallow unique index on system columns

2016-04-14 Thread David Rowley
Hi, Over in [1], while I was aiming to fix some incorrect formatting in an error message, Tom noticed that the code in that area was much more broken than I had thought. Basically, if you do; postgres=# create table t (a int) with oids; CREATE TABLE postgres=# create unique index t_oid_idx on t(