Thread: Lack of T_TargetEntry in exprType function

Lack of T_TargetEntry in exprType function

From
Konstantin Knizhnik
Date:
Is there any reason for not handling T_TargetEntry node kind in 
exprType() function in nodeFuncs.c?
Is it considered as non-valid expression tag?
But why in this case it is handled in the exprLocation function?

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



Re: Lack of T_TargetEntry in exprType function

From
Tom Lane
Date:
Konstantin Knizhnik <k.knizhnik@postgrespro.ru> writes:
> Is there any reason for not handling T_TargetEntry node kind in 
> exprType() function in nodeFuncs.c?

It's intentional because that's not considered an executable
expression.

> But why in this case it is handled in the exprLocation function?

There are lots of things that have syntactic locations but aren't
value-yielding expressions.

            regards, tom lane


Re: Lack of T_TargetEntry in exprType function

From
Konstantin Knizhnik
Date:

On 20.03.2018 17:00, Tom Lane wrote:
> Konstantin Knizhnik <k.knizhnik@postgrespro.ru> writes:
>> Is there any reason for not handling T_TargetEntry node kind in
>> exprType() function in nodeFuncs.c?
> It's intentional because that's not considered an executable
> expression.

I tried to apply this function to the argument of Aggref and it has 
exactly this kind.
Aggref is executable expression. This is why I thought that all its 
arguments also should be considered as executable expressions, shouldn't 
they?
My idea was to capture argument of one aggregate and use  it in another 
aggregate during query transformation.
Certainly it is not a problem for me to handle this case myself, but I 
just wonder will it be more natural to extend exprType to handle this 
node kind as well.

>
>> But why in this case it is handled in the exprLocation function?
> There are lots of things that have syntactic locations but aren't
> value-yielding expressions.
>
>             regards, tom lane

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



Re: Lack of T_TargetEntry in exprType function

From
Tom Lane
Date:
Konstantin Knizhnik <k.knizhnik@postgrespro.ru> writes:
> On 20.03.2018 17:00, Tom Lane wrote:
>> It's intentional because that's not considered an executable
>> expression.

> I tried to apply this function to the argument of Aggref and it has 
> exactly this kind.
> Aggref is executable expression. This is why I thought that all its 
> arguments also should be considered as executable expressions, shouldn't 
> they?

Not really.  They're a list of executable expressions, which is not the
same thing --- in particular, exprType() on the whole list wouldn't give a
useful result.  The TargetEntrys are best thought of as part of the list
superstructure.

            regards, tom lane