Re: Puzzled by UNION with unknown types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Puzzled by UNION with unknown types
Date: 2017-09-20 19:39:01
Message-ID: 30737.1505936341@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> writes:
> Hi. I've solved my practical problems, and I know unknown types are
> just bad, but am still curious about why some of these cause errors,
> and others don't.

> ag_consulting=> SELECT * FROM (SELECT '1'::unknown) foo UNION ALL
> SELECT * FROM (SELECT '1'::unknown) bar;
> ERROR: failed to find conversion function from unknown to text

FWIW, this succeeds in 9.5 and up, as a result of more aggressive
application of the rule "coerce an unknown value to text if we cannot
find any other interpretation".

> ag_consulting=> CREATE TEMP TABLE t1 AS SELECT '1'::unknown; \d t1
> WARNING: column "unknown" has type "unknown"
> DETAIL: Proceeding with relation creation anyway.
> SELECT 1
> Table "pg_temp_2.t1"
> Column | Type | Modifiers
> ---------+---------+-----------
> unknown | unknown |

As of v10, this will produce a table with a column of type text,
not type unknown, again as a result of more aggressively forcing
unknown to be something else.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vick Khera 2017-09-20 20:46:41 Re: Inserting millions of record in a partitioned Table
Previous Message Ron Johnson 2017-09-20 19:24:52 Re: Up to date conventional wisdom re max shared_buffer size?