Search Postgresql Archives

Understanding "unknown" data type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was working on a test restore and got:
WARNING:  column "astring" has type "unknown"

The restore worked correctly - it was a warning not an error - and we located the cause and corrected it. But I did some playing leading to questions for which I have been unable to locate answers:

steve=# create table foobar as select 'a string' as astring, null as anull;
WARNING:  column "astring" has type "unknown"
DETAIL:  Proceeding with relation creation anyway.
WARNING:  column "anull" has type "unknown"
DETAIL:  Proceeding with relation creation anyway.
SELECT 1

steve=# \d foobar
     Table "public.foobar"
 Column  |  Type   | Modifiers
---------+---------+-----------
 astring | unknown |
 anull   | unknown |

steve=# select * from foobar;
astring  | anull
----------+-------
 a string |

steve=# insert into foobar values ('1','2');
INSERT 0 1

steve=# select * from foobar;
 astring  | anull
----------+-------
 a string |
 1        | 2

steve=# select text (astring), text (anull) from foobar;
   text   | text
----------+------
 a string |
 1        | 2

So for starters...

1. Where can I read up on the purpose and properties of a data-type of unknown? It apparently can be cast to some other types though "unknown" is not shown in the output of \dC.

2. Is there any setting/option that would allow me to force an error instead of allowing creation of tables with type unknown? (And why would such a type be allowed in a table at all - it seems like a foot-gun waiting to happen?)

Cheers,
Steve


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux