Re: [GENERAL] CREATE TABLE with a column of type {table name}

2003-08-01 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes:
> IMNSHO a type is a type is a type.  An instance of anytype
> can go in a column.  However, having worked in some of
> the code to make this recursive definition work correctly
> I understand your "No! Never!"  response.  I don't agree,
> with it, but I understand it :-)

I didn't say "No! Never!".  I said this isn't a matter of fixing
a small bug.  For starters, the apparent support for the feature
needs to be ripped out, because it has nothing in common with actual
support.

regards, tom lane

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [GENERAL] CREATE TABLE with a column of type {table name}

2003-07-31 Thread Stephan Szabo

On Thu, 31 Jul 2003, Ang Chin Han wrote:

> In Postgresql 7.3, a datatype can be int, text, etc, and also
> pseudo-types like RECORD, any, etc.
>
> These pseudo types are mainly used in CREATE FUNCTIONs, but what if it's
> used in a CREATE TABLE, esp. when the name of another table is used as a
> datatype?
[...]
>
> -- Hmmm... What if pseudo-types in CREATE TABLEs?
> -- *** THIS IS THE WHAT I'M INTERESTED IN ***
> CREATE TABLE bar(myfoo foo, c int);
>
> -- The only way I can think of to insert values into the table bar:
> SELECT INTO bar SELECT get_foo1(), 1;

You can write casts as well presumably to allow other inputs.

> -- How to retrieve data from bar?
> SELECT * FROM bar;
> ERROR:  Cannot display a value of type RECORD
>
> SELECT myfoo.a FROM bar;
> ERROR:  Attribute "myfoo.a" not found

However the syntax
 select a(myfoo),b(myfoo) from bar
should work.


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly