Re: Creating a zero-column table

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating a zero-column table
Date: 2002-12-12 21:21:00
Message-ID: 1039728060.1950.8.camel@rh72.home.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane kirjutas R, 13.12.2002 kell 02:08:
> I was bemused to notice that pg_dump is currently unable to dump the
> regression database. The domain regression test leaves an empty table
> (one with zero columns), which causes pg_dump to produce
>
> --
> -- TOC entry 172 (OID 675837)
> -- Name: domnotnull; Type: TABLE; Schema: public; Owner: postgres
> --
>
> CREATE TABLE domnotnull (
> );
>
>
> This is rejected on restore:
>
> ERROR: DefineRelation: please inherit from a relation or define an attribute
>
> I believe that the table would be correctly restored if we simply
> removed that error check in DefineRelation. On the other hand, for
> ordinary hand-entered CREATE TABLE commands it seems like a useful
> error check.
>
> Should we remove this error check, thereby effectively making
> zero-column tables first-class citizens?

I would vote for removing the check. I see no reason why one should not
be able to define a zero-column table. While we cant currently do
anything useful (except select oid :) with it now, it does not mean that
it would not serve as a valid base table for inheritance hierarchies in
future.

I'm probably going to propose an implicit zero-column base table for all
user defined tables (say any_table) so that one can get a list of all
tuple ids in all tables by doing a simple
"select tableoid,oid from any_table". This will of course not be very
useful for tables with no oids and where there is no index on oid.

--
Hannu Krosing <hannu(at)tm(dot)ee>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-12-12 21:22:49 Re: PQnotifies() in 7.3 broken?
Previous Message Bruce Momjian 2002-12-12 21:18:13 Re: PQnotifies() in 7.3 broken?