pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #10674: syntax error with CREATE TABLE table AS SELECT (column1, column 2) FROM table2
2+ messages / 2 participants
[nested] [flat]

* BUG #10674: syntax error with CREATE TABLE table AS SELECT (column1, column 2) FROM table2
@ 2014-06-16 22:03  professor@gmail.com
  0 siblings, 1 reply; 2+ messages in thread

From: professor@gmail.com @ 2014-06-16 22:03 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      10674
Logged by:          Todd Sedano
Email address:      professor@gmail.com
PostgreSQL version: 9.3.3
Operating system:   Mac OS 10.8.5
Description:        



Note: I feel like I must be doing something wrong, but I've been able to
reproduce this in two very different environments.

The following SQL is valid postgres, see
http://www.postgresql.org/docs/9.3/static/sql-createtableas.html
"CREATE TABLE retail_demo.imported_table AS SELECT (column1, column2) FROM
retail_demo.external_table;"

However, it generates the odd message "ERROR:  column "row" has pseudo-type
record"

We were able to get around this issue, by removing the () around (column1,
column2)
"CREATE TABLE retail_demo.imported_table AS SELECT column1, column2 FROM
retail_demo.external_table;"

This is reproducible with this sequence....

create table source_table (column1 text, column2 text, column3 text);
insert into source_table values ('value 1', 'value 2', 'value 3');
create table destination_table AS SELECT (column1, column2) from
source_table;  
ERROR:  column "row" has pseudo-type record
create table destination_table AS SELECT column1, column2 from source_table;


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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #10674: syntax error with CREATE TABLE table AS SELECT (column1, column 2) FROM table2
@ 2014-06-17 04:43  Michael Paquier <michael.paquier@gmail.com>
  parent: professor@gmail.com
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2014-06-17 04:43 UTC (permalink / raw)
  To: professor@gmail.com; +Cc: pgsql-bugs

On Tue, Jun 17, 2014 at 7:03 AM,  <professor@gmail.com> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      10674
> Logged by:          Todd Sedano
> Email address:      professor@gmail.com
> PostgreSQL version: 9.3.3
> Operating system:   Mac OS 10.8.5
> Description:
>
>
>
> Note: I feel like I must be doing something wrong, but I've been able to
> reproduce this in two very different environments.
>
> The following SQL is valid postgres, see
> http://www.postgresql.org/docs/9.3/static/sql-createtableas.html
> "CREATE TABLE retail_demo.imported_table AS SELECT (column1, column2) FROM
> retail_demo.external_table;"
> However, it generates the odd message "ERROR:  column "row" has pseudo-type
> record"
This is not a bug. Writing a list of columns within parentheses in a
SELECT list represents them as a row (this is valid SQL).

> We were able to get around this issue, by removing the () around (column1,
> column2)
> "CREATE TABLE retail_demo.imported_table AS SELECT column1, column2 FROM
> retail_demo.external_table;"
And you are right, simply remove the parentheses in the SELECT list
and the columns will be selected one by one, which is what you are
looking for.
-- 
Michael


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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2014-06-17 04:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-06-16 22:03 BUG #10674: syntax error with CREATE TABLE table AS SELECT (column1, column 2) FROM table2 professor@gmail.com
2014-06-17 04:43 ` Michael Paquier <michael.paquier@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox