From: | Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: ExecEvalVar does not have appropriate ExprState? |
Date: | 2011-03-28 07:44:22 |
Message-ID: | AANLkTinzkvThgG3ZdMwOrzE5eU47gvHtqwnBDdK5S1Uy@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thanks for the confirmation. I am happy to have understood some basics of
PG.
Also, I think the similar stands for the Const, Param,
CoerceToDomain and CaseTest nodes, right? They too cast the pointer to
another type.
Thanks for the help Heikki. (I could better call you HL, if you dont mind :P
)
Regards,
Vaibhav
On Mon, Mar 28, 2011 at 1:05 PM, Heikki Linnakangas <
heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> On 28.03.2011 10:02, Vaibhav Kaushal wrote:
>
>> Hi,
>>
>> I see the ExecInitExpr says something like this:
>> ------------
>> case T_Var:
>> state = (ExprState *) makeNode(ExprState);
>> state->evalfunc = ExecEvalVar;
>> ---------------
>>
>>
>> But the ExecEvalVar function definition says:
>>
>> ------------------------
>> Var *variable = (Var *) exprstate->expr;
>> TupleTableSlot *slot;
>> AttrNumber attnum;
>>
>> if (isDone)
>> *isDone = ExprSingleResult;
>>
>> /* Get the input slot and attribute number we want */
>> switch (variable->varno)
>> {
>> case INNER: /* get the tuple
>> from the inner node */
>> -------------------------
>>
>>
>> Since ExprState -> expr in its final form would finally contain only:
>>
>> NodeTag type;
>>
>> I think that the pointer being cast in the ExecEvalVar is actually
>> already a form of Var which is passed around as Expr for sake of
>> function call.
>>
>
> Right, exprstate->expr is a Var in ExecEvalVar.
>
>
> So, was the node in the Expr tree for the corresponding ExprState node
>> of the ExprState tree actually a 'Var'?
>>
>
> Yes.
>
>
> Also, I have tried, but failed to fidn the exact place where the Expr
>> tree is created. Just pointing me to the file / function which does this
>> would be of great help.
>>
>
> A raw expression tree is created in the grammar, src/backend/parser/gram.y.
> It is then transformed in parse analysis phase to the form the planner
> accepts, in transformExpr(). The planner can do some further
> transformations, like replacing immutable function calls with Consts.
>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2011-03-28 08:46:55 | Re: ExecEvalVar does not have appropriate ExprState? |
Previous Message | Heikki Linnakangas | 2011-03-28 07:35:09 | Re: ExecEvalVar does not have appropriate ExprState? |