Re: WIP: extensible enums

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: WIP: extensible enums
Дата
Msg-id AANLkTi=hAuym4E8CeMHXYswAsP7Uf8Qg2++8H-H9cNwG@mail.gmail.com
обсуждение исходный текст
Ответ на Re: WIP: extensible enums  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: WIP: extensible enums  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
On 16 October 2010 18:25, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> Are there corner cases the author has failed to consider?
>
> None that I could find.
>
> Are there any assertion failures or crashes?
>

I just thought of another corner case, which can lead to a crash. The
comparison code assumes that the number of elements in the enumeration
is constant during a query, but that's not necessarily the case. For
example the following will crash it:

CREATE TYPE test_enum AS ENUM('Elem 1');

CREATE OR REPLACE FUNCTION test_fn(a int) RETURNS test_enum AS
$$
DECLARE new_label text;
BEGIN new_label := 'Elem '||a; EXECUTE 'ALTER TYPE test_enum ADD '''||new_label||''' BEFORE ''Elem 1'''; RETURN
new_label::test_enum;
END;
$$
LANGUAGE plpgsql;

WITH t(a) AS (SELECT test_fn(i) FROM generate_series(2, 10) g(i)) SELECT MAX(a) from t;

Of course that's a pathalogical example, but we should protect against
it, preferrably without compromising performance in more normal cases.

Regards,
Dean


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

Предыдущее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: How to determine failed connection attempt due to invalid authorization (libpq)?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Keywords in pg_hba.conf should be field-specific