Unexpected custom type behavior using ROW(NULL)

Поиск
Список
Период
Сортировка
От Denver Timothy
Тема Unexpected custom type behavior using ROW(NULL)
Дата
Msg-id A7639483-F6EC-4D5E-8A60-6D3D653B7E79@timothy.io
обсуждение исходный текст
Ответы Re: Unexpected custom type behavior using ROW(NULL)  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
In 9.4.1, I do this:

CREATE TYPE my_test_type as (part1 text, part2 text);

\pset null NULL

WITH test_table(test_col) AS (
    VALUES (NULL::my_test_type), (ROW(NULL, NULL)::my_test_type)
)
SELECT *, (test_col).part1, (test_col).part2, test_col IS NULL AS is_null FROM test_table;

And I get this result:

┌──────────┬───────┬───────┬─────────┐
│ test_col │ part1 │ part2 │ is_null │
├──────────┼───────┼───────┼─────────┤
│ NULL     │ NULL  │ NULL  │ t       │
│ (,)      │ NULL  │ NULL  │ t       │
└──────────┴───────┴───────┴─────────┘

But I expect this result:

┌──────────┬───────┬───────┬─────────┐
│ test_col │ part1 │ part2 │ is_null │
├──────────┼───────┼───────┼─────────┤
│ NULL     │ NULL  │ NULL  │ t       │
│ NULL     │ NULL  │ NULL  │ t       │
└──────────┴───────┴───────┴─────────┘



Is this expected behavior? I do find references in the docs to input/output of NULL values as components of anonymous
recordtypes, but it's still not clear to me if this would be expected behavior after a cast to a custom type. 

Is there a trick to get the result I'm expecting? So far all of the syntactical gymnastics I can think of still produce
thesame result. 

I'm a long time PostgreSQL user, but custom types is fairly new to me, so any insight or pointers to appropriate
readingwould be helpful. 

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

Предыдущее
От: Israel Brewster
Дата:
Сообщение: Re: Group by range in hour of day
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Great Software Opportunities: VP, Front End Developer, etc. (Ruby, Python)