Re: Improving default column names/aliases of subscript text expressions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Improving default column names/aliases of subscript text expressions
Date
Msg-id 1997166.1734373927@sss.pgh.pa.us
Whole thread Raw
In response to Re: Improving default column names/aliases of subscript text expressions  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Responses Re: Improving default column names/aliases of subscript text expressions
List pgsql-hackers
Jelte Fennema-Nio <postgres@jeltef.nl> writes:
> On Mon, 16 Dec 2024 at 16:34, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> View definition:
>> SELECT data['a'::text] AS data
>> FROM tj;

> Are you sure you ran this with my patch?

No, sorry, I was just illustrating the behavior with HEAD.
The important part of this is not the assigned alias
but the visible cast.

>> regression=# select data['2'], data[3] from t2;
>>  data | data
>> ------+------
>>     2 |    3
>> (1 row)

> So what would you want here? Do you want these columns to be called 2
> and 3?

No!!

> One thing that I didn't see you explicitly say: Do you agree that the
> new column names are actually better than the old ones?

No, I'm not at all convinced of that.  For these examples
I'd prefer something like "data_a", "data_b", etc.

That approach might also make it more palatable to process integer
literals this way (i.e. "data_2" etc), though I am not sure we want
to do that because of the increased blast radius.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Regression tests fail on OpenBSD due to low semmns value
Next
From: Andreas Karlsson
Date:
Subject: Re: Improved psql tab completion for joins