BUG #5974: UNION construct type cast gives poor error message

Поиск
Список
Период
Сортировка
От Jeff Wu
Тема BUG #5974: UNION construct type cast gives poor error message
Дата
Msg-id 201104122018.p3CKIlWR042915@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #5974: UNION construct type cast gives poor error message  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      5974
Logged by:          Jeff Wu
Email address:      jwu@atlassian.com
PostgreSQL version: 9.0
Operating system:   Mac OS X
Description:        UNION construct type cast gives poor error message
Details:

The UNION construct (as noted on this page:
http://www.postgresql.org/docs/9.0/static/typeconv-union-case.html) will
cast unknown types to TEXT, however, if you try to do three or more UNIONs
the order in which the UNIONs are executed will cause some columns to be
cast to TEXT prematurely.  The result is a type mismatch error.

For example:
SELECT 1,null,null
UNION
SELECT 2,3,null
UNION
SELECT 3,null,4

will fail while

SELECT 1,null,null::INTEGER
UNION
SELECT 2,3,null
UNION
SELECT 3,null,4

will succeed.

This is not a critical error, but I would say that the error message is
misleading because it is not obvious that Postgres casts unknown columns to
TEXT automatically.

The current error message is:
ERROR: UNION types text and integer cannot be matched

I would suggest something like:
ERROR: UNION types text and integer cannot be matched.  HINT: Postgres casts
unknown types to TEXT by default.


Thanks,

Jeff

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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: BUG #5976: Corrupted pages on the production database
Следующее
От: "John Dickson"
Дата:
Сообщение: BUG #5975: Incorrect result from mod function with cast