Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSOy0-00055e-9t for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Dec 2017 15:10:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSOxz-0001Zk-Kw for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Dec 2017 15:10:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eSOxz-0001Za-BK for pgsql-hackers@lists.postgresql.org; Fri, 22 Dec 2017 15:10:31 +0000 Received: from smtprelay0183.b.hostedemail.com ([64.98.42.183] helo=smtprelay.b.hostedemail.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eSOxw-0006P8-6V for pgsql-hackers@postgresql.org; Fri, 22 Dec 2017 15:10:30 +0000 Received: from filter.hostedemail.com (10.5.19.248.rfc1918.com [10.5.19.248]) by smtprelay05.b.hostedemail.com (Postfix) with ESMTP id DFF4B32B03D; Fri, 22 Dec 2017 15:10:26 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,alvherre@alvh.no-ip.org,:::::::::::,RULES_HIT:41:355:379:599:871:967:973:988:989:1260:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1535:1538:1567:1575:1594:1595:1596:1711:1714:1730:1747:1764:1777:1792:2393:2525:2560:2563:2682:2685:2691:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3622:3865:3868:3873:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4362:4605:5007:6261:6748:7281:7903:8828:9025:9121:10004:10394:10400:10848:11232:11604:11658:11914:13071:13439:13894:13895:14180:14658:14721:21080:21627,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: jelly71_3deed78f02e62 X-Filterd-Recvd-Size: 6921 Received: from alvin.alvh.no-ip.org (unknown [179.57.113.18]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf10.b.hostedemail.com (Postfix) with ESMTPA; Fri, 22 Dec 2017 15:10:25 +0000 (UTC) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 910738CE; Fri, 22 Dec 2017 12:10:23 -0300 (-03) Date: Fri, 22 Dec 2017 12:10:23 -0300 From: Alvaro Herrera To: Jesper Pedersen Cc: Robert Haas , David Rowley , Simon Riggs , Pg Hackers , Maksim Milyutin Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table Message-ID: <20171222151023.ie4zrbgwtva7flij@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="oorlkm762ozaqakd" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <242e9c8d-113e-22e5-05bf-550eb0801f7b@redhat.com> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --oorlkm762ozaqakd Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello Jesper, Jesper Pedersen wrote: > Passes check-world here too w/ TAP + cassert. Great, thanks for checking. > index.c: > [and a few other comments] I believe these are all fixed by the attached delta patch. If you have wording suggestions for the doc changes, please send them along. Thanks for reading, -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --oorlkm762ozaqakd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-some-fixes-per-Jesper.patch" From 24ec874da257cf617359cce253ff4f8ad33166d7 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 22 Dec 2017 11:41:15 -0300 Subject: [PATCH] some fixes per Jesper --- doc/src/sgml/ref/create_index.sgml | 28 +++++++++++++++++----------- doc/src/sgml/ref/reindex.sgml | 5 +++++ src/backend/catalog/index.c | 2 +- src/bin/psql/tab-complete.c | 7 ++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml index b7b0506d6d..5137fe6383 100644 --- a/doc/src/sgml/ref/create_index.sgml +++ b/doc/src/sgml/ref/create_index.sgml @@ -557,17 +557,23 @@ Indexes: When CREATE INDEX is invoked on a partitioned - table, the default behavior is to recurse to all partitions to - ensure they all have a matching indexes. Each partition is first - checked to determine whether equivalent index already exists, - and if so, that index will become attached as a partition index to - the index being created, which will be its parent index. If no - matching index exists, a new index will be created and automatically - attached. If ONLY is specified, no recursion - is done. Note, however, that any partition that is created in the - future using CREATE TABLE .. PARTITION OF will - automatically contain the index regardless of whether this option - was specified. + table, the default behavior is to recurse to all partitions to ensure + they all have matching indexes. + Each partition is first checked to determine whether an equivalent + index already exists, and if so, that index will become attached as a + partition index to the index being created, which will become its + parent index. + If no matching index exists, a new index will be created and + automatically attached; the name of the new index in each partition + will be determined as if no index name had been specified in the + command. + If the ONLY option is specified, no recursion + is done, and the index is marked invalid + (ALTER INDEX ... ATTACH PARTITION turns the index + valid, once all partitions acquire the index.) Note, however, that + any partition that is created in the future using + CREATE TABLE ... PARTITION OF will automatically + contain the index regardless of whether this option was specified. diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml index 79f6931c6a..1c21fafb80 100644 --- a/doc/src/sgml/ref/reindex.sgml +++ b/doc/src/sgml/ref/reindex.sgml @@ -231,6 +231,11 @@ REINDEX [ ( VERBOSE ) ] { INDEX | TABLE | SCHEMA | DATABASE | SYSTEM } + + Reindexing partitioned tables or partitioned indexes is not supported. + Each individual partition can be reindexed separately instead. + + diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index a62fe158ce..eee16dde25 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -629,7 +629,7 @@ UpdateIndexRelation(Oid indexoid, values[Anum_pg_index_indexrelid - 1] = ObjectIdGetDatum(indexoid); values[Anum_pg_index_indrelid - 1] = ObjectIdGetDatum(heapoid); - values[Anum_pg_index_indparentidx - 1 ] = ObjectIdGetDatum(parentIndexOid); + values[Anum_pg_index_indparentidx - 1] = ObjectIdGetDatum(parentIndexOid); values[Anum_pg_index_indnatts - 1] = Int16GetDatum(indexInfo->ii_NumIndexAttrs); values[Anum_pg_index_indisunique - 1] = BoolGetDatum(indexInfo->ii_Unique); values[Anum_pg_index_indisprimary - 1] = BoolGetDatum(primary); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 6af773f1bf..159ce4129e 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1695,14 +1695,11 @@ psql_completion(const char *text, int start, int end) /* ALTER INDEX */ else if (Matches3("ALTER", "INDEX", MatchAny)) COMPLETE_WITH_LIST7("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET", - "RESET", "ATTACH PARTITION", "DETACH PARTITION"); - else if (Matches4("ALTER", "INDEX", MatchAny, "ATTACH|DETACH")) + "RESET", "ATTACH PARTITION"); + else if (Matches4("ALTER", "INDEX", MatchAny, "ATTACH")) COMPLETE_WITH_CONST("PARTITION"); else if (Matches5("ALTER", "INDEX", MatchAny, "ATTACH", "PARTITION")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); - /* can be improved to show only indexes that are already attached */ - else if (Matches5("ALTER", "INDEX", MatchAny, "DETACH", "PARTITION")) - COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); /* ALTER INDEX ALTER COLUMN */ else if (Matches6("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny)) COMPLETE_WITH_CONST("SET STATISTICS"); -- 2.11.0 --oorlkm762ozaqakd--