Re: logical column ordering - Mailing list pgsql-hackers

From Gavin Flower
Subject Re: logical column ordering
Date
Msg-id 54F15AA9.9050103@archidevsys.co.nz
Whole thread Raw
In response to Re: logical column ordering  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List 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
canprobably 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
COLUMNSELECTION 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



pgsql-hackers by date:

Previous
From: Matt Kelly
Date:
Subject: Re: logical column ordering
Next
From: Vadim Gribanov
Date:
Subject: Re: Docs about shared memory