Re: Allowing empty target list in SELECT (1b4f7f93b4693858cb983af3cd557f6097dab67b) - Mailing list pgsql-hackers

From Rajeev rastogi
Subject Re: Allowing empty target list in SELECT (1b4f7f93b4693858cb983af3cd557f6097dab67b)
Date
Msg-id BF2827DCCE55594C8D7A8F7FFD3AB7713DDE577B@SZXEML508-MBX.china.huawei.com
Whole thread Raw
In response to Re: Allowing empty target list in SELECT (1b4f7f93b4693858cb983af3cd557f6097dab67b)  (Amit Langote <amitlangote09@gmail.com>)
List pgsql-hackers
On 02 May 2014 10:00, Amit Longote Wrote:

> > I
> > s the following behavior perceived fix-worthy?
> >
> >
> > -- note the
> > '
> > 1's
> >  in the output
> > s
> >
> > po
> > stgres=# CREATE TABLE test AS SELECT;
> > SELECT 1
> >
> > postgres=# insert into test select;
> > INSERT 0 1
> >
> 
> Or maybe, it just means 1 'null' row/record and not no row at all?

It just creates an item pointer and corresponding to that heap tuple header (without data or bitmask for NULL) gets
storedas part of this insertion.
 
So though it does not insert anything (not even NULL) but still it reserve one row position. 
So while SELECT, it will not display anything but it will show actual number of rows.

Even below syntax is also allowed:
CREATE TABLE no_column_table();

IMO, this might be useful for dynamic use of table (later column might be added using 'ALTER') or to use as abstract
ancestorin class hierarchy.
 


Thanks and Regards,
Kumar Rajeev Rastogi


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: is there a hook by which we can modify input query before postgresql builds raw parse tree
Next
From: Ian Barwick
Date:
Subject: pgaudit - an auditing extension for PostgreSQL