Lack of T_TargetEntry in exprType function

Started by Konstantin Knizhnikalmost 8 years ago4 messages
#1Konstantin Knizhnik
k.knizhnik@postgrespro.ru

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Konstantin Knizhnik (#1)
Re: Lack of T_TargetEntry in exprType function

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

#3Konstantin Knizhnik
k.knizhnik@postgrespro.ru
In reply to: Tom Lane (#2)
Re: Lack of T_TargetEntry in exprType function

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Konstantin Knizhnik (#3)
Re: Lack of T_TargetEntry in exprType function

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