Re: Improving default column names/aliases of subscript text expressions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improving default column names/aliases of subscript text expressions
Date: 2024-12-16 18:32:07
Message-ID: 1997166.1734373927@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> writes:
> On Mon, 16 Dec 2024 at 16:34, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2024-12-16 18:35:18 Re: Improved psql tab completion for joins
Previous Message Tom Lane 2024-12-16 18:26:36 Re: Regression tests fail on OpenBSD due to low semmns value