UNION Types Mismatch

Поиск
Список
Период
Сортировка
От CN
Тема UNION Types Mismatch
Дата
Msg-id 20030423055150.85BD14DC3D@smtp.us2.messagingengine.com
обсуждение исходный текст
Ответы Re: UNION Types Mismatch
Список pgsql-bugs
Thank you very much for the good product!

v7.3.2.

CREATE TABLE ta (c1 CHAR(1));
CREATE TABLE tb (c1 CHAR(1));
CREATE TABLE tc (c1 SMALLINT);

INSERT INTO ta VALUES('a');
INSERT INTO tb VALUES('b');
INSERT INTO tc VALUES(1);

SELECT c1 AS a,NULL AS b,NULL AS c FROM ta
UNION ALL
SELECT NULL,c1,NULL FROM tb
UNION ALL
SELECT NULL,NULL,c1 FROM tc;

ERROR:  UNION types 'text' and 'smallint' not matched

One union is fine:

SELECT c1 AS a,NULL AS c FROM ta
UNION ALL
SELECT NULL,c1 FROM tc;

It's very difficult for me to cast types because this SQL is dynamically
generated by scripts rather than hard coded:

SELECT c1 AS a,NULL AS b,NULL AS c FROM ta
UNION ALL
SELECT NULL,c1,NULL::SMALLINT FROM tb
UNION ALL
SELECT NULL,NULL,c1 FROM tc;

Can postgreSQL be improved to be smarter with such UNION?

CN

--
http://www.fastmail.fm - A no graphics, no pop-ups email service

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

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Bug #953: pg_dump dies on tables with no columns
Следующее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Bug #954: select distinct array