Re: enum bug

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: enum bug
Дата
Msg-id CAKFQuwY-8Lgbp08agWErzjOKF+2qhJ2n_y61b++OovLRNmJuGQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: enum bug  (Elein <elein@varlena.com>)
Ответы Re: enum bug  (Elein <elein@varlena.com>)
Список pgsql-general
On Fri, Mar 11, 2016 at 4:19 PM, Elein <elein@varlena.com> wrote:
An unused (yet) enum type cannot display the enum ranges. An empty table containing that type cannot display enum ranges. 

​Yes, it can.

​CREATE TYPE rainbow AS enum ('red','orange','yellow','blue','purple');
SELECT enum_range(null::rainbow);
enum_range
{red,orange,yellow,blue,purple}

I get the distinction between classes and objects.  But in many cases, like this one, you need to obtain an instance of a class - a null is generally sufficient - and pass that instance to a function.  The function can then use "pg_typeof(instance_value)::oid" to derive the oid for the corresponding class.  This is a common idiom in PostgreSQL.

The only improvement, besides the error handling point, that I see to be had here is your understanding of how the system works.

David J.

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

Предыдущее
От: cchee-ob
Дата:
Сообщение: BDR not catching up
Следующее
От: Chris Ruprecht
Дата:
Сообщение: OS X 10.11.3, psql, bus error 10, 9.5.1