Re: Indexes on partitioned tables and foreign partitions
От | Amit Langote |
---|---|
Тема | Re: Indexes on partitioned tables and foreign partitions |
Дата | |
Msg-id | 211ee61d-f91a-9cbd-7b9b-6cd81cb8d08d@lab.ntt.co.jp обсуждение исходный текст |
Ответ на | Re: Indexes on partitioned tables and foreign partitions (Michael Paquier <michael@paquier.xyz>) |
Ответы |
Re: Indexes on partitioned tables and foreign partitions
Re: Indexes on partitioned tables and foreign partitions |
Список | pgsql-hackers |
On 2018/05/10 10:02, Michael Paquier wrote: > Something > that I find confusing on HEAD though is that DefineIndex calls itself > around line 1006 and cascades through each children but there is no > context about the error. > > For example if I have this partition layer: > CREATE TABLE measurement ( > logdate date not null, > peaktemp int, > unitsales int > ) PARTITION BY RANGE (logdate); > CREATE FOREIGN TABLE measurement_y2016m07 > PARTITION OF measurement FOR VALUES FROM ('2016-07-01') TO > ('2016-08-01') > SERVER postgres_server; > > Then by creating an index on the parent I get that: > =# create index measurement_idx on measurement (peaktemp); > ERROR: 42809: cannot create index on foreign table "measurement_y2016m07" > LOCATION: DefineIndex, indexcmds.c:442 > > This may be confusing for the user as the DDL does not complain directly > about the relation worked on. Perhaps we could add an error context? > We surely don't want multiple contexts either when working on long > chains, but we could build a chained list of relation names in the error > message. How about we error out even *before* calling DefineIndex for the 1st time? I see that ProcessUtilitySlow() gets a list of all partitions when locking them for index creation before calling DefineIndex. Maybe, just go through the list and error out if one of them is a partition that we don't support creating an index on? For example, with the attached patch doing the above, I get: create table p (a int) partition by range (a); create table p1 partition of p for values from (minvalue) to (1); create foreign table p2 partition of p for values from (1) to (maxvalue) server loopback options (table_name 'p2base'); create index on p (a); ERROR: cannot create index on partitioned table containing foreign partitions Thanks, Amit
Вложения
В списке pgsql-hackers по дате отправления: