[HACKERS] error detail when partition not found
От | Amit Langote |
---|---|
Тема | [HACKERS] error detail when partition not found |
Дата | |
Msg-id | 9f9dc7ae-14f0-4a25-5485-964d9bfc19bd@lab.ntt.co.jp обсуждение исходный текст |
Ответы |
Re: [HACKERS] error detail when partition not found
|
Список | pgsql-hackers |
Simon pointed out in a nearby thread [0] that the detail part of partition-not-found error should show just the partition keys. I posted a patch on that thread [1], but to avoid confusion being caused by multitude of patches over there I'm re-posting it here. * What the patch does: Currently we show the whole row in the detail part of the error. CREATE TABLE measurement_year_month ( logdate date not null, peaktemp int, unitsales int ) PARTITION BY RANGE (EXTRACT(YEAR FROM logdate), EXTRACT(MONTH FROM logdate)); # INSERT INTO measurement_year_month VALUES ('2016-12-02', 1, 1); ERROR: no partition of relation "measurement_year_month" found for row DETAIL: Failing row contains (2016-12-02, 1, 1). Patch changes it look like the following: # INSERT INTO measurement_year_month VALUES ('2016-12-02', 1, 1); ERROR: no partition of relation "measurement_year_month" found for row DETAIL: Partition key of the failing row contains (date_part('year'::text, logdate), date_part('month'::text, logdate))=(2016, 12). It's similar to error detail shown when btree unique violation occurs: -- just to be clear, using LIKE won't make measurement partitioned too CREATE TABLE measurement (LIKE measurement_year_month); CREATE UNIQUE INDEX ON measurement (EXTRACT(YEAR FROM logdate), EXTRACT(MONTH FROM logdate)) # INSERT INTO measurement VALUES ('2016-12-02', 1, 1); INSERT 0 1 # INSERT INTO measurement VALUES ('2016-12-02', 1, 1); ERROR: duplicate key value violates unique constraint "measurement_date_part_date_part1_idx" DETAIL: Key (date_part('year'::text, logdate), date_part('month'::text, logdate))=(2016, 12) already exists. * Some of the implementation details of the patch here: The rules about which columns to show or whether to show the DETAIL at all are similar to those in BuildIndexValueDescription(): - if user has SELECT privilege on the whole table, simply go ahead - if user doesn't have SELECT privilege on the table, check that they can see all the columns in the key (no point in showing partial key); however abort on finding an expression for which we don't try finding out privilege situation of whatever columns may be in the expression Thanks, Amit [0] https://www.postgresql.org/message-id/CANP8%2BjJBpWocfKrbJcaf3iBt9E3U%3DWPE_NC8YE6rye%2BYJ1sYnQ%40mail.gmail.com [1] https://www.postgresql.org/message-id/2f8df068-9a49-d74a-30af-7cd17bdee181%40lab.ntt.co.jp -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
В списке pgsql-hackers по дате отправления: