From: | Oskari Saarenmaa <os(at)ohmu(dot)fi> |
---|---|
To: | Marko Tiikkaja <marko(at)joh(dot)to>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] parser: optionally warn about missing AS for column and table aliases |
Date: | 2014-09-05 20:56:37 |
Message-ID: | 540A2385.9090501@ohmu.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
05.09.2014 23:45, Marko Tiikkaja kirjoitti:
> On 2014-09-05 22:38, Oskari Saarenmaa wrote:
>> I wrote the attached patch to optionally emit warnings when column or
>> table
>> aliases are used without the AS keyword after errors caused by typos in
>> statements turning unintended things into aliases came up twice this
>> week.
>> First in a discussion with a colleague who was surprised by a 1 row
>> result
>> for the query 'SELECT COUNT(*) files' and again in the "pl/pgsql 2"
>> thread
>> as plpgsql currently doesn't throw an error if there are more result
>> columns
>> than output columns (SELECT a b INTO f1, f2).
>>
>> The patch is still missing documentation and it needs another patch to
>> modify all the statements in psql & co to use AS so you can use things
>> like
>> \d and tab-completion without triggering the warnings. I can implement
>> those changes if others think this patch makes sense.
>
> I think this is only problematic for column aliases. I wouldn't want to
> put these two to be put into the same category, as I always omit the AS
> keyword for tables aliases (and will continue to do so), but never omit
> it for column aliases.
I prefer using AS for both, but I can see the case for requiring AS in
table aliases being a lot weaker. Not emitting warnings for table
aliases would also reduce the changes required in psql & co as they seem
to be using aliases mostly (only?) for tables.
What'd be a good name for the GUC controlling this,
missing_column_as_warning?
/ Oskari
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Tiikkaja | 2014-09-05 21:06:50 | Re: [PATCH] parser: optionally warn about missing AS for column and table aliases |
Previous Message | Marko Tiikkaja | 2014-09-05 20:45:34 | Re: [PATCH] parser: optionally warn about missing AS for column and table aliases |