"unkown" columns

From: Russell Smith <mr-russ(at)pws(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: "unkown" columns
Date: 2004-11-06 08:27:25
Message-ID: 200411061927.25276.mr-russ@pws.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 column type 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, however he 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 either be 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew McMillan 2004-11-06 09:36:25 Re: [PATCHES] CVS should die
Previous Message Andrew Dunstan 2004-11-06 07:25:43 Re: [PATCHES] CVS should die