Re: [HACKERS] Re: [COMMITTERS] pgsql: Use MINVALUE/MAXVALUE insteadof UNBOUNDED for range partition b

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [HACKERS] Re: [COMMITTERS] pgsql: Use MINVALUE/MAXVALUE insteadof UNBOUNDED for range partition b
Дата
Msg-id CAKFQuwaSbM3UpxUqqXw0v2-4=XxG30VTb8bHty4J4xnqOfo6Ng@mail.gmail.com
обсуждение исходный текст
Ответ на [HACKERS] Re: [COMMITTERS] pgsql: Use MINVALUE/MAXVALUE instead of UNBOUNDEDfor range partition b  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: [HACKERS] Re: [COMMITTERS] pgsql: Use MINVALUE/MAXVALUE insteadof UNBOUNDED for range partition b  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Список pgsql-hackers
On Tue, Aug 8, 2017 at 4:33 PM, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
On 8 August 2017 at 19:22, Robert Haas <robertmhaas@gmail.com> wrote:
> On Fri, Jul 21, 2017 at 4:24 AM, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
>> Also drop the constraint prohibiting finite values after an unbounded
>> column, and just document the fact that any values after MINVALUE or
>> MAXVALUE are ignored. Previously it was necessary to repeat UNBOUNDED
>> multiple times, which was needlessly verbose.
>
> I would like to (belatedly) complain about this part of this commit.
> Now you can do stuff like this:
>
> rhaas=# create table foo (a int, b text) partition by range (a, b);
> CREATE TABLE
> rhaas=# create table foo1 partition of foo for values from (minvalue,
> 0) to (maxvalue, 0);
> CREATE TABLE
>
> The inclusion of 0 has no effect, but it is still stored in the
> catalog, shows up in \d foo1, and somebody might think it does
> something.  I think we should go back to requiring bounds after
> minvalue or maxvalue to be minvalue or maxvalue.

​The commit message indicates one would just specify "unbounded", not min/maxvalue​, which indeed seems to be a better word for it.

Can we, presently, stick "null" in place of the "0"?

Well perhaps verbosity-reduction isn't sufficient justification but I
still think this is correct because logically any values in the bound
after MINVALUE/MAXVALUE are irrelevant, so it seems overly restrictive
to force all later values to be MINVALUE/MAXVALUE when the code will
just ignore those values.


But semantically using
​unbounded
 is correct - and referencing the principle of "write once, read many" people are probably going to care a lot more about the \d display than the original SQL - and \d showing some randomly chosen value and mentally doing the gymnastics to think "oh, wait, it doesn't actually mater what this value is)" compared to it showing "unbounded" and it being obvious that "any value" will work, seems like a win.
 
I don't think we should allow values after MINVALUE/MAXVALUE to be
omitted altogether because we document multi-column ranges as being
most easily understood according to the rules of row-wise comparisons,
and they require equal numbers of values in each row.

I wouldn't change the underlying representation but from a UX perspective being able to ?omit the explicit specification and let the system default appropriately would be worth considering - though probably not worth the effort.

​The complaint regarding \d could be solved by figuring out on-the-fly whether the particular column is presently bounded or not and diplaying "unbounded" for the later ones regardless of what value is stored in the catalog.  "Unbounded (0)" would communicate both aspects.​  In the "be liberal in what you accept" department that would seem to be a win.

​David J.​

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dean Rasheed
Дата:
Сообщение: [HACKERS] Re: [COMMITTERS] pgsql: Use MINVALUE/MAXVALUE instead of UNBOUNDEDfor range partition b
Следующее
От: "Tsunakawa, Takayuki"
Дата:
Сообщение: [HACKERS] Re: [bug fix] PG10: libpq doesn't connect to alternative hosts whensome errors occur