"unkown" columns - Mailing list pgsql-hackers

From Russell Smith
Subject "unkown" columns
Date
Msg-id 200411061927.25276.mr-russ@pws.com.au
Whole thread Raw
List pgsql-hackers
Hi Hackers,

I have created a table with an unknown column in it.

CREATE table test AS select 'a' as columna, 'b' as columnb;

will create a table with columna and columnb as an unknown type.

This in itself is not strictly a problem.  However there are not functions in postgresql to convert unknown to another
value.
There are functions if you do explicit casts, but when extracting data from a table it is not possible.
So this creates a problem where you cannot cast the value of the column to anything else.  Attempting to change the
columntype on 8.0b4
 
or even trying to do select columna::text from test results in the following error.

SQL error:

ERROR:  failed to find conversion function from "unknown" to text

In statement:
ALTER TABLE "test" ALTER COLUMN "columna" TYPE text

I would have assumed there was an implicit cast to text for items in the format 'a', but it seems not.

I have spoken to Gavin Sherry on IRC and he has made functions to allow casting from unknown to text in this situation,
howeverhe has
 
not had an opportunity to send a mail to the list about this issue.  So I am doing it.

Neil Conway also made some comments about unknown being as issue that has a low priority, however I think we need to
eitherbe able to cast away from
 
unknown, or at least error when attempting to create a table with an unknown column type.

I get the same error on 7.4.5 and 8.0b4

Regards

Russell Smith


pgsql-hackers by date:

Previous
From: "Andrew Dunstan"
Date:
Subject: Re: [PATCHES] CVS should die
Next
From: Andrew McMillan
Date:
Subject: Re: [PATCHES] CVS should die