Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-07-16 Thread Amit Langote
On 2018/07/17 13:57, Alvaro Herrera wrote: > On 2018-Feb-19, David G. Johnston wrote: > >> As an aside, adding a link to "Data Definiton/Table Partitioning" from at >> least CREATE TABLE ... PARTITION BY; and swapping "PARTITION BY" and >> "PARTITION OF" in the Parameters section of that page - on

Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-07-16 Thread Alvaro Herrera
On 2018-Feb-19, David G. Johnston wrote: > As an aside, adding a link to "Data Definiton/Table Partitioning" from at > least CREATE TABLE ... PARTITION BY; and swapping "PARTITION BY" and > "PARTITION OF" in the Parameters section of that page - one must partition > by a table before one can parti

RE: unique indexes on partitioned tables

2018-03-12 Thread Shinoda, Noriyoshi
Pedersen ; Pg Hackers Subject: Re: unique indexes on partitioned tables Shinoda, Noriyoshi wrote: Hi, > I tried this feature with the latest snapshot. When I executed the > following SQL statement, multiple primary keys were created on the > partition. > Is this the intended behavior?

Re: unique indexes on partitioned tables

2018-03-12 Thread Alvaro Herrera
Shinoda, Noriyoshi wrote: Hi, > I tried this feature with the latest snapshot. When I executed the > following SQL statement, multiple primary keys were created on the > partition. > Is this the intended behavior? It turns out that the error check for duplicate PKs is only invoked if you tell t

Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-03-12 Thread Alvaro Herrera
David G. Johnston wrote: > Something like: > > When establishing a unique constraint for a multi-level partition hierarchy > all the "partition by" columns of the target partitioned table, as well as > those of all its descendant partitioned tables, must be included in the > constraint definition

Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-03-12 Thread Alvaro Herrera
David Rowley wrote: > On 20 February 2018 at 09:40, Alvaro Herrera wrote: > > Modified Files > > -- > > doc/src/sgml/ddl.sgml | 9 +- > > Attached is a very small fix to a small error this patch created in the docs. Pushed, thanks. -- Álvaro Herrera

Re: unique indexes on partitioned tables

2018-03-08 Thread Alvaro Herrera
Hi, Shinoda, Noriyoshi wrote: > I tried this feature with the latest snapshot. When I executed the > following SQL statement, multiple primary keys were created on the > partition. Is this the intended behavior? Hahah. Is that a serious question? Of course it isn't. I'll fix it: > -- test >

RE: unique indexes on partitioned tables

2018-03-08 Thread Shinoda, Noriyoshi
[mailto:langote_amit...@lab.ntt.co.jp] Sent: Tuesday, February 20, 2018 6:24 PM To: Alvaro Herrera ; Peter Eisentraut ; Jaime Casanova Cc: Jesper Pedersen ; Pg Hackers Subject: Re: unique indexes on partitioned tables Hi. On 2018/02/20 5:45, Alvaro Herrera wrote: > I pushed this now, wit

Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-02-20 Thread David G. Johnston
On Tue, Feb 20, 2018 at 8:36 AM, Alvaro Herrera wrote: > Many thanks for reading through it! > > David G. Johnston wrote: > > I found the following change to be confusing. > [...] > > I was expecting the doc for ADD CONSTRAINT USING INDEX to note the > > limitation explicitly - in lieu of the ab

Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-02-20 Thread Alvaro Herrera
Many thanks for reading through it! David G. Johnston wrote: > I found the following change to be confusing. [...] > I was expecting the doc for ADD CONSTRAINT USING INDEX to note the > limitation explicitly - in lieu of the above paragraph. Agreed. I moved the note to ADD CONSTRAINT and added

Re: unique indexes on partitioned tables

2018-02-20 Thread Amit Langote
Hi. On 2018/02/20 5:45, Alvaro Herrera wrote: > I pushed this now, with fixes for the last few comments there were. I noticed with the commit that, while ON CONFLICT (conflict_target) DO UPDATE gives a less surprising error message by catching it in the parser, ON CONFLICT (conflict_target) DO NO

Re: pgsql: Allow UNIQUE indexes on partitioned tables

2018-02-19 Thread David G. Johnston
der), would be helpful. David J. On Mon, Feb 19, 2018 at 1:40 PM, Alvaro Herrera wrote: > Allow UNIQUE indexes on partitioned tables > > If we restrict unique constraints on partitioned tables so that they > must always include the partition key, then our standard approach to >

Re: unique indexes on partitioned tables

2018-02-19 Thread Alvaro Herrera
I pushed this now, with fixes for the last few comments there were. Peter Eisentraut wrote: > I don't understand the variable name "third". I don't see a "first" or > "second" nearby. Hah. That was referring to variables "myself" and "referenced". I changed the variable name to "parentConstr"

Re: unique indexes on partitioned tables

2018-02-19 Thread Alvaro Herrera
Jaime Casanova wrote: > Hi Álvaro, > > attached a tiny patch (on top of yours) that silence two "variables > uninitilized" warnings. Thanks! Applied. > also noted that if you: > > """ > create table t1(i int) partition by hash (i); > create table t1_0 partition of t1 for values with (modulus

Re: unique indexes on partitioned tables

2018-02-19 Thread Jaime Casanova
On 12 February 2018 at 15:26, Alvaro Herrera wrote: > Hello, > > Thanks, Peter, Jesper, Amit, for reviewing the patch. Replying to > all review comments at once: > [... v5 of patch attached ...] Hi Álvaro, attached a tiny patch (on top of yours) that silence two "variables uninitilized" warnin

Re: unique indexes on partitioned tables

2018-02-13 Thread Peter Eisentraut
Here is a mini-patch on top of yours to fix a few cosmetic things. I don't understand the variable name "third". I don't see a "first" or "second" nearby. I find some of the columns in pg_constraint confusing. For a primary key on a partitioned table, for the PK on the partition I get conisloc

Re: unique indexes on partitioned tables

2018-02-12 Thread Alvaro Herrera
Hello, Thanks, Peter, Jesper, Amit, for reviewing the patch. Replying to all review comments at once: Jesper Pedersen wrote: > Maybe add a test case to indexing.sql that highlights that hash indexes > doesn't support UNIQUE; although not unique to partitioned indexes. I'm not sure about this.

Re: unique indexes on partitioned tables

2018-02-01 Thread Peter Eisentraut
On 1/26/18 13:42, Peter Eisentraut wrote: > Other than that, this looks pretty good to me. A logical extension of > the previous partitioned index patch. Moved to next CF. Seems close to ready. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, R

Re: unique indexes on partitioned tables

2018-01-29 Thread Amit Langote
On 2018/01/29 16:28, Amit Langote wrote: > create table p (a int, b int) partition by list (a); > create table p1 partition of p for values in (1) partition by range (b); > create table p11 partition of p1 for values from (1) to (10); > create table p2 partition of p for values in (2); > > create

Re: unique indexes on partitioned tables

2018-01-28 Thread Amit Langote
Hi Alvaro. On 2018/01/23 7:55, Alvaro Herrera wrote: > Alvaro Herrera wrote: >> Version 4 of this patch, rebased on today's master. With the latest patch, I noticed what I think is an unintended behavior. create table p (a int, b int) partition by list (a); create table p1 partition of p for val

Re: unique indexes on partitioned tables

2018-01-26 Thread Peter Eisentraut
On 1/22/18 17:55, Alvaro Herrera wrote: > Alvaro Herrera wrote: >> Version 4 of this patch, rebased on today's master. + if (key->partattrs[i] == 0) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), +errmsg("unsupporte

Re: unique indexes on partitioned tables

2018-01-25 Thread Jesper Pedersen
Hi Alvaro, On 01/22/2018 05:55 PM, Alvaro Herrera wrote: Alvaro Herrera wrote: Version 4 of this patch, rebased on today's master. Passes make check-world. Maybe add a test case to indexing.sql that highlights that hash indexes doesn't support UNIQUE; although not unique to partitioned i

Re: unique indexes on partitioned tables

2018-01-22 Thread Alvaro Herrera
Alvaro Herrera wrote: > Version 4 of this patch, rebased on today's master. -- Álvaro Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services >From 1a02e7f359c94e5db0bb069666b950775cd3e2af Mon Sep 17 00:00:00 2001 From: Alvaro Her

Re: unique indexes on partitioned tables

2018-01-22 Thread Alvaro Herrera
Version 4 of this patch, rebased on today's master. The main change is in dependency handling for the constraints: you now can't drop a constraint from a partition, if it's attached to a constraint in the parent (you can't drop indexes from under the constraints either, but that was true in previo

Re: unique indexes on partitioned tables

2018-01-06 Thread Simon Riggs
On 29 December 2017 at 23:06, Alvaro Herrera wrote: > This is the patch series for UNIQUE / PRIMARY KEY indexes on partitioned > tables. This is on top of the patch in > https://postgr.es/m/20171229175930.3aew7lzwd5w6m2x6@alvherre.pgsql > but I included it here as 0001 for simplicity. (Don't rev