Re: [HACKERS] Proposal: Local indexes for partitioned table

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Maksim Milyutin <milyutinma(at)gmail(dot)com>
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
Date: 2017-12-25 08:30:39
Message-ID: 24ed32c9-51fa-be1c-0a85-170d88483d2b@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/12/25 13:52, Amit Langote wrote:
> Hi Alvaro,
>
> On 2017/12/23 0:10, Alvaro Herrera wrote:
>> I believe these are all fixed by the attached delta patch.
>
> @@ -1676,7 +1694,12 @@ psql_completion(const char *text, int start, int end)
> "UNION SELECT 'ALL IN TABLESPACE'");
> /* ALTER INDEX <name> */
> else if (Matches3("ALTER", "INDEX", MatchAny))
> - COMPLETE_WITH_LIST5("ALTER COLUMN", "OWNER TO", "RENAME TO",
> "SET", "RESET");
> + COMPLETE_WITH_LIST7("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET",
> + "RESET", "ATTACH PARTITION");
>
> This should be COMPLETE_WITH_LIST6().

I noticed a few things I thought I'd report. I was using the latest patch
(v8 + the delta patch).

1. The following crashes because of an Assert in ATExecCmd():

ALTER TABLE an_index DETACH PARTITION ...

It seems ATPrepCmd() should not pass ATT_INDEX to ATSimplePermissions()
for the ATDetachPartition sub-command type.

2. Something strange about how dependencies are managed:

create table p (a char) partition by list (a);
create table pa partition of p for values in ('a');;
create table pb partition of p for values in ('b');
create index on p (a);

\d pa
Table "public.pa"
Column | Type | Collation | Nullable | Default
|-------+--------------+-----------+----------+---------
a | character(1) | | |
Partition of: p FOR VALUES IN ('a')
Indexes:
"pa_a_idx" btree (a)

drop table pa;
ERROR: cannot drop table pa because other objects depend on it
DETAIL: index p_a_idx depends on table pa
HINT: Use DROP ... CASCADE to drop the dependent objects too.

set client_min_messages to debug2;

drop table pa;
DEBUG: drop auto-cascades to index pa_a_idx
DEBUG: drop auto-cascades to index pb_a_idx
DEBUG: drop auto-cascades to type pa
DEBUG: drop auto-cascades to type pa[]
ERROR: cannot drop table pa because other objects depend on it
DETAIL: index p_a_idx depends on table pa
HINT: Use DROP ... CASCADE to drop the dependent objects too.

Thanks,
Amit

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-12-25 09:49:05 Re: Unique indexes & constraints on partitioned tables
Previous Message Konstantin Knizhnik 2017-12-25 08:13:08 Re: Huge backend memory footprint