Re: logical column ordering

From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: logical column ordering
Date: 2015-02-28 06:05:29
Message-ID: 54F15AA9.9050103@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28/02/15 18:34, Jim Nasby wrote:
> On 2/27/15 2:49 PM, Alvaro Herrera wrote:
>> Tomas Vondra wrote:
>>
>>> 1) change the order of columns in "SELECT *"
>>>
>>> - display columns so that related ones grouped together
>>> (irrespectedly whether they were added later, etc.)
>
> FWIW, I find the ordering more important for things like \d than
> SELECT *.
>
> Hey, after we get this done the next step is allowing different
> logical ordering for different uses! ;P
[...]

How about CREATE COLUMN SELECTION my_col_sel (a, g, b, e) FROM TABLE
my_table;

Notes:

1. The column names must match those of the table

2. The COLUMN SELECTION is associated with the specified table

3. If a column gets renamed, then the COLUMN SELECTION effectively gets
updated to use the new column name
(This can probably be done automatically, by virtue of storing
references to the appropriate column definitions)

4. Allow fewer columns in the COLUMN SELECTION than the original table

5. Allow the the same column to be duplicated
(trivial, simply don't raise an error for duplicates)

6. Allow the COLUMN SELECTION name to appear instead of the list of
columns after the SELECT key word
(SELECT COLUMN SELECTION my_col_sel FROM my_table WHERE ... - must
match table in FROM clause)

If several tables are defined in the FROM clause, and 2 different tables
have COLUMN SELECTION with identical names, then the COLUMN SELECTION
names in the SELECT must be prefixed either the table name or its alias.

Cheers,
Gavin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Gribanov 2015-02-28 07:34:20 Re: Docs about shared memory
Previous Message Matt Kelly 2015-02-28 06:01:55 Re: logical column ordering