Re: Interesting CREATE TABLE AS misbehavior

From: "Jim C(dot) Nasby" <jimn(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Interesting CREATE TABLE AS misbehavior
Date: 2006-09-18 17:56:35
Message-ID: 20060918175635.GC47167@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 18, 2006 at 09:30:43AM -0400, Stephen Frost wrote:
> * Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> > The reason for this behavior is that analyze.c attaches the CREATE TABLE
> > AS aliases to the targetlist (via applyColumnNames) before it processes
> > the ORDER BY clause. (So, "order by z2" works instead.) This seems
> > like a bug: one would expect that the aliases do not change the
> > semantics of the SELECT part of the command.
>
> I'd tend to agree that it seems like a bug but I'm a little mystified as
> to why an 'order by' would be desired (or allowed) for a 'create table as'
> at all. Allowing it seems to imply it has some meaning.

Because if the ORDER BY is honored, the newly created table will be
clustered in a specific order. That can be very useful in certain
applications.
--
Jim Nasby jimn(at)enterprisedb(dot)com
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2006-09-18 17:59:00 Re: minor feature request: Secure defaults during
Previous Message Jim C. Nasby 2006-09-18 17:54:17 Re: 8.2 beta blockers