Re: pgsql: If an index depends on no columns of its table, give it a

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pgsql: If an index depends on no columns of its table, give it a
Дата
Msg-id 15946.1194711773@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pgsql: If an index depends on no columns of its table, give it a  (Simon Riggs <simon@2ndquadrant.com>)
Ответы Re: pgsql: If an index depends on no columns of its table, give it a
Список pgsql-committers
Simon Riggs <simon@2ndquadrant.com> writes:
> Constants in indexes are just a strangeness we don't need.

I disagree.  Here's an example that I don't think you can do with
purely SQL-spec syntax:

    CREATE UNIQUE INDEX fooi ON foo ((1)) WHERE f1 < 0;

This constrains the table to contain no more than one row with
negative f1.  Now admittedly this index does depend on the column f1
so it's not directly an example of the case being patched, but I think
it would be pretty weird to allow this but reject the base case
without a WHERE clause.

I also think that there's no principled reason to reject
    CREATE INDEX fooi ON foo ((1));
if we allow
    CREATE INDEX fooi ON foo ((CASE WHEN false THEN f1 ELSE 1 END));
The second index is certainly without rational use, but on what
grounds will you argue that it's more valid than the other?

Basically, my view is that this may be an edge case, but it's not
utterly useless, and throwing an error for it will violate the
principle of least surprise.  It's not hugely different from the
reasoning that led us to allow zero-column tables.

            regards, tom lane

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

Предыдущее
От: momjian@postgresql.org (Bruce Momjian)
Дата:
Сообщение: pgsql: Use strip -x on OS/X-darwin because non-"-x" causes link
Следующее
От: jurka@pgfoundry.org (User Jurka)
Дата:
Сообщение: jdbc - CVSROOT: Attempt to point commit messages to our own mailing