Обсуждение: What would AggrefExprState nodes' args contain?

Поиск
Список
Период
Сортировка

What would AggrefExprState nodes' args contain?

От
Vaibhav Kaushal
Дата:
Hello all,<br /><br />While examining the executor, I was wondering what the *args part of AggrefExprState nodes
contain.I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is
initializedin ExecInitExpr as:<br /><br />astate->args = (List *) ExecInitExpr((Expr *) aggref->args,<br />   
                                                    parent);<br /><br />This would mean that the args is actually a
ExprStatenode list with one single item (the ExprState node / tree). I believe it potentially contains the execution
treeto determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see
theargs coming into picture at all! I am also unable to find a call to some function for executing the state node
createdin the args list. Also, no value is being extracted from that node! Why is it so? <br /><br />For quick
referenceI am adding the function (may be you don't need it but still... its a small one):<br /><br />/*
----------------------------------------------------------------<br/> *        ExecEvalAggref<br /> *<br />  *       
Returnsa Datum whose value is the value of the precomputed<br /> *        aggregate found in the given expression
context.<br/> * ----------------------------------------------------------------<br /> */<br />static Datum<br />
ExecEvalAggref(AggrefExprState*aggref, ExprContext *econtext,<br />               bool *isNull, ExprDoneCond
*isDone)<br/>{<br />   if (isDone)<br />        *isDone = ExprSingleResult;<br /><br />    if
(econtext->ecxt_aggvalues== NULL)        /* safety check */<br />         elog(ERROR, "no aggregates in this
expressioncontext");<br /><br />    *isNull = econtext->ecxt_aggnulls[aggref->aggno];<br />    return
econtext->ecxt_aggvalues[aggref->aggno];<br/>}<br /><br /><br />What is the use of args in AggrefExprState node
here?Is it there just for some historical reason?<br /><br />Regards,<br />Vaibhav <br /> 

Re: What would AggrefExprState nodes' args contain?

От
Ashutosh Bapat
Дата:
The args in AggrefExprState, are used in the functions ExecAgg, ExecInitAgg and their minions to evaluate the
aggregates.The ExecEvalAggref() merely retrieves the results of aggregation calculated during ExecAgg.<br /><br /><div
class="gmail_quote">On Tue, Apr 26, 2011 at 12:04 PM, Vaibhav Kaushal <span dir="ltr"><<a
href="mailto:vaibhavkaushal123@gmail.com">vaibhavkaushal123@gmail.com</a>></span>wrote:<br /><blockquote
class="gmail_quote"style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Helloall,<br /><br />While examining the executor, I was wondering what the *args part of AggrefExprState nodes
contain.I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is
initializedin ExecInitExpr as:<br /><br />astate->args = (List *) ExecInitExpr((Expr *) aggref->args,<br />   
                                                    parent);<br /><br />This would mean that the args is actually a
ExprStatenode list with one single item (the ExprState node / tree). I believe it potentially contains the execution
treeto determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see
theargs coming into picture at all! I am also unable to find a call to some function for executing the state node
createdin the args list. Also, no value is being extracted from that node! Why is it so? <br /><br />For quick
referenceI am adding the function (may be you don't need it but still... its a small one):<br /><br />/*
----------------------------------------------------------------<br/> *        ExecEvalAggref<br /> *<br />  *       
Returnsa Datum whose value is the value of the precomputed<br /> *        aggregate found in the given expression
context.<br/> * ----------------------------------------------------------------<br /> */<br />static Datum<br />
ExecEvalAggref(AggrefExprState*aggref, ExprContext *econtext,<br />               bool *isNull, ExprDoneCond
*isDone)<br/>{<br />   if (isDone)<br />        *isDone = ExprSingleResult;<br /><br />    if
(econtext->ecxt_aggvalues== NULL)        /* safety check */<br />         elog(ERROR, "no aggregates in this
expressioncontext");<br /><br />    *isNull = econtext->ecxt_aggnulls[aggref->aggno];<br />    return
econtext->ecxt_aggvalues[aggref->aggno];<br/>}<br /><br /><br />What is the use of args in AggrefExprState node
here?Is it there just for some historical reason?<br /><br />Regards,<br /><font color="#888888">Vaibhav <br
/></font></blockquote></div><br/><br clear="all" /><br />-- <br />Best Wishes,<br />Ashutosh Bapat<br />EntepriseDB
Corporation<br/>The Enterprise Postgres Company<br /><br /> 

Re: What would AggrefExprState nodes' args contain?

От
Vaibhav Kaushal
Дата:
Thanks a lot. I was browsing the code and was thinking this would be the most probable scenario. 

But, the point is that even after removing the args initialization part in the ExecInitExpr for AggrefState, the sum() function is working. I believe that is also a aggregate function! If yes, then how is it working if I dd not allow the args to be initialized. The debugger says that ExecEvalAggref was called and the results returned are true.

Regards,
Vaibhav

On Thu, Apr 28, 2011 at 2:38 PM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:
The args in AggrefExprState, are used in the functions ExecAgg, ExecInitAgg and their minions to evaluate the aggregates. The ExecEvalAggref() merely retrieves the results of aggregation calculated during ExecAgg.


On Tue, Apr 26, 2011 at 12:04 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Hello all,

While examining the executor, I was wondering what the *args part of AggrefExprState nodes contain. I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is initialized in ExecInitExpr as:

astate->args = (List *) ExecInitExpr((Expr *) aggref->args,
                                                         parent);

This would mean that the args is actually a ExprState node list with one single item (the ExprState node / tree). I believe it potentially contains the execution tree to determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see the args coming into picture at all! I am also unable to find a call to some function for executing the state node created in the args list. Also, no value is being extracted from that node! Why is it so?

For quick reference I am adding the function (may be you don't need it but still... its a small one):

/* ----------------------------------------------------------------
 *        ExecEvalAggref
 *
 *        Returns a Datum whose value is the value of the precomputed
 *        aggregate found in the given expression context.
 * ----------------------------------------------------------------
 */
static Datum
ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext,
               bool *isNull, ExprDoneCond *isDone)
{
   if (isDone)
        *isDone = ExprSingleResult;

    if (econtext->ecxt_aggvalues == NULL)        /* safety check */
        elog(ERROR, "no aggregates in this expression context");

    *isNull = econtext->ecxt_aggnulls[aggref->aggno];
    return econtext->ecxt_aggvalues[aggref->aggno];
}


What is the use of args in AggrefExprState node here? Is it there just for some historical reason?

Regards,
Vaibhav



--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company


Re: What would AggrefExprState nodes' args contain?

От
Ashutosh Bapat
Дата:


On Thu, Apr 28, 2011 at 4:21 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Thanks a lot. I was browsing the code and was thinking this would be the most probable scenario. 

But, the point is that even after removing the args initialization part in the ExecInitExpr for AggrefState, the sum() function is working. I believe that is also a aggregate function! If yes, then how is it working if I dd not allow the args to be initialized. The debugger says that ExecEvalAggref was called and the results returned are true.


Did you check the same thing with avg, or any statistical aggregates. Sum does not need all the aggregate infrastructure in place, for example finalisation function. May be after removing initialization part you want to run regression (or at least aggregates.sql) to see what it breaks.
 
Regards,
Vaibhav


On Thu, Apr 28, 2011 at 2:38 PM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:
The args in AggrefExprState, are used in the functions ExecAgg, ExecInitAgg and their minions to evaluate the aggregates. The ExecEvalAggref() merely retrieves the results of aggregation calculated during ExecAgg.


On Tue, Apr 26, 2011 at 12:04 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Hello all,

While examining the executor, I was wondering what the *args part of AggrefExprState nodes contain. I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is initialized in ExecInitExpr as:

astate->args = (List *) ExecInitExpr((Expr *) aggref->args,
                                                         parent);

This would mean that the args is actually a ExprState node list with one single item (the ExprState node / tree). I believe it potentially contains the execution tree to determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see the args coming into picture at all! I am also unable to find a call to some function for executing the state node created in the args list. Also, no value is being extracted from that node! Why is it so?

For quick reference I am adding the function (may be you don't need it but still... its a small one):

/* ----------------------------------------------------------------
 *        ExecEvalAggref
 *
 *        Returns a Datum whose value is the value of the precomputed
 *        aggregate found in the given expression context.
 * ----------------------------------------------------------------
 */
static Datum
ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext,
               bool *isNull, ExprDoneCond *isDone)
{
   if (isDone)
        *isDone = ExprSingleResult;

    if (econtext->ecxt_aggvalues == NULL)        /* safety check */
        elog(ERROR, "no aggregates in this expression context");

    *isNull = econtext->ecxt_aggnulls[aggref->aggno];
    return econtext->ecxt_aggvalues[aggref->aggno];
}


What is the use of args in AggrefExprState node here? Is it there just for some historical reason?

Regards,
Vaibhav



--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company





--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company

Re: What would AggrefExprState nodes' args contain?

От
Vaibhav Kaushal
Дата:
I tried all aggregates - min,max,sum,count and avg. all are working. What do you suggest now?

On Fri, Apr 29, 2011 at 11:30 AM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:


On Thu, Apr 28, 2011 at 4:21 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Thanks a lot. I was browsing the code and was thinking this would be the most probable scenario. 

But, the point is that even after removing the args initialization part in the ExecInitExpr for AggrefState, the sum() function is working. I believe that is also a aggregate function! If yes, then how is it working if I dd not allow the args to be initialized. The debugger says that ExecEvalAggref was called and the results returned are true.


Did you check the same thing with avg, or any statistical aggregates. Sum does not need all the aggregate infrastructure in place, for example finalisation function. May be after removing initialization part you want to run regression (or at least aggregates.sql) to see what it breaks.
 
Regards,
Vaibhav


On Thu, Apr 28, 2011 at 2:38 PM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:
The args in AggrefExprState, are used in the functions ExecAgg, ExecInitAgg and their minions to evaluate the aggregates. The ExecEvalAggref() merely retrieves the results of aggregation calculated during ExecAgg.


On Tue, Apr 26, 2011 at 12:04 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Hello all,

While examining the executor, I was wondering what the *args part of AggrefExprState nodes contain. I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is initialized in ExecInitExpr as:

astate->args = (List *) ExecInitExpr((Expr *) aggref->args,
                                                         parent);

This would mean that the args is actually a ExprState node list with one single item (the ExprState node / tree). I believe it potentially contains the execution tree to determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see the args coming into picture at all! I am also unable to find a call to some function for executing the state node created in the args list. Also, no value is being extracted from that node! Why is it so?

For quick reference I am adding the function (may be you don't need it but still... its a small one):

/* ----------------------------------------------------------------
 *        ExecEvalAggref
 *
 *        Returns a Datum whose value is the value of the precomputed
 *        aggregate found in the given expression context.
 * ----------------------------------------------------------------
 */
static Datum
ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext,
               bool *isNull, ExprDoneCond *isDone)
{
   if (isDone)
        *isDone = ExprSingleResult;

    if (econtext->ecxt_aggvalues == NULL)        /* safety check */
        elog(ERROR, "no aggregates in this expression context");

    *isNull = econtext->ecxt_aggnulls[aggref->aggno];
    return econtext->ecxt_aggvalues[aggref->aggno];
}


What is the use of args in AggrefExprState node here? Is it there just for some historical reason?

Regards,
Vaibhav



--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company





--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company


Re: What would AggrefExprState nodes' args contain?

От
Ashutosh Bapat
Дата:
Is regression clean?

Have you looked at how the member is used using some code browsing tool like cscope by examining it's every occurrence? PG uses simulated run time polymorphism a lot, so any Node should examined carefully from that angle too. Even after all of that if you think that it's not being used, you can submit a patch to community removing that member. Somebody from community reviewers will review and commit the patch if they find it correct and useful.

Read http://wiki.postgresql.org/wiki/Submitting_a_Patch before submitting the patch.

On Fri, Apr 29, 2011 at 3:22 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
I tried all aggregates - min,max,sum,count and avg. all are working. What do you suggest now?


On Fri, Apr 29, 2011 at 11:30 AM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:


On Thu, Apr 28, 2011 at 4:21 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Thanks a lot. I was browsing the code and was thinking this would be the most probable scenario. 

But, the point is that even after removing the args initialization part in the ExecInitExpr for AggrefState, the sum() function is working. I believe that is also a aggregate function! If yes, then how is it working if I dd not allow the args to be initialized. The debugger says that ExecEvalAggref was called and the results returned are true.


Did you check the same thing with avg, or any statistical aggregates. Sum does not need all the aggregate infrastructure in place, for example finalisation function. May be after removing initialization part you want to run regression (or at least aggregates.sql) to see what it breaks.
 
Regards,
Vaibhav


On Thu, Apr 28, 2011 at 2:38 PM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:
The args in AggrefExprState, are used in the functions ExecAgg, ExecInitAgg and their minions to evaluate the aggregates. The ExecEvalAggref() merely retrieves the results of aggregation calculated during ExecAgg.


On Tue, Apr 26, 2011 at 12:04 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Hello all,

While examining the executor, I was wondering what the *args part of AggrefExprState nodes contain. I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is initialized in ExecInitExpr as:

astate->args = (List *) ExecInitExpr((Expr *) aggref->args,
                                                         parent);

This would mean that the args is actually a ExprState node list with one single item (the ExprState node / tree). I believe it potentially contains the execution tree to determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see the args coming into picture at all! I am also unable to find a call to some function for executing the state node created in the args list. Also, no value is being extracted from that node! Why is it so?

For quick reference I am adding the function (may be you don't need it but still... its a small one):

/* ----------------------------------------------------------------
 *        ExecEvalAggref
 *
 *        Returns a Datum whose value is the value of the precomputed
 *        aggregate found in the given expression context.
 * ----------------------------------------------------------------
 */
static Datum
ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext,
               bool *isNull, ExprDoneCond *isDone)
{
   if (isDone)
        *isDone = ExprSingleResult;

    if (econtext->ecxt_aggvalues == NULL)        /* safety check */
        elog(ERROR, "no aggregates in this expression context");

    *isNull = econtext->ecxt_aggnulls[aggref->aggno];
    return econtext->ecxt_aggvalues[aggref->aggno];
}


What is the use of args in AggrefExprState node here? Is it there just for some historical reason?

Regards,
Vaibhav



--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company





--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company





--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company

Re: What would AggrefExprState nodes' args contain?

От
Vaibhav Kaushal
Дата:
I have a small db which I am using to test it. Moreover I am new to the terms. What would you mean by 'regression'? 

Also, I am using eclipse for browsing the code. It resolves all references and function calls, declarations, definitions etc.

Regards,
Vaibhav

On Fri, Apr 29, 2011 at 3:31 PM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:
Is regression clean?

Have you looked at how the member is used using some code browsing tool like cscope by examining it's every occurrence? PG uses simulated run time polymorphism a lot, so any Node should examined carefully from that angle too. Even after all of that if you think that it's not being used, you can submit a patch to community removing that member. Somebody from community reviewers will review and commit the patch if they find it correct and useful.

Read http://wiki.postgresql.org/wiki/Submitting_a_Patch before submitting the patch.


On Fri, Apr 29, 2011 at 3:22 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
I tried all aggregates - min,max,sum,count and avg. all are working. What do you suggest now?


On Fri, Apr 29, 2011 at 11:30 AM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:


On Thu, Apr 28, 2011 at 4:21 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Thanks a lot. I was browsing the code and was thinking this would be the most probable scenario. 

But, the point is that even after removing the args initialization part in the ExecInitExpr for AggrefState, the sum() function is working. I believe that is also a aggregate function! If yes, then how is it working if I dd not allow the args to be initialized. The debugger says that ExecEvalAggref was called and the results returned are true.


Did you check the same thing with avg, or any statistical aggregates. Sum does not need all the aggregate infrastructure in place, for example finalisation function. May be after removing initialization part you want to run regression (or at least aggregates.sql) to see what it breaks.
 
Regards,
Vaibhav


On Thu, Apr 28, 2011 at 2:38 PM, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> wrote:
The args in AggrefExprState, are used in the functions ExecAgg, ExecInitAgg and their minions to evaluate the aggregates. The ExecEvalAggref() merely retrieves the results of aggregation calculated during ExecAgg.


On Tue, Apr 26, 2011 at 12:04 PM, Vaibhav Kaushal <vaibhavkaushal123@gmail.com> wrote:
Hello all,

While examining the executor, I was wondering what the *args part of AggrefExprState nodes contain. I found that the Aggref (Expr)'s  args list is a list of TargetEntry nodes. But the state node's args is initialized in ExecInitExpr as:

astate->args = (List *) ExecInitExpr((Expr *) aggref->args,
                                                         parent);

This would mean that the args is actually a ExprState node list with one single item (the ExprState node / tree). I believe it potentially contains the execution tree to determine the state / value of the aggref (sub)expression. But then in the ExecEvalAggref function I do not see the args coming into picture at all! I am also unable to find a call to some function for executing the state node created in the args list. Also, no value is being extracted from that node! Why is it so?

For quick reference I am adding the function (may be you don't need it but still... its a small one):

/* ----------------------------------------------------------------
 *        ExecEvalAggref
 *
 *        Returns a Datum whose value is the value of the precomputed
 *        aggregate found in the given expression context.
 * ----------------------------------------------------------------
 */
static Datum
ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext,
               bool *isNull, ExprDoneCond *isDone)
{
   if (isDone)
        *isDone = ExprSingleResult;

    if (econtext->ecxt_aggvalues == NULL)        /* safety check */
        elog(ERROR, "no aggregates in this expression context");

    *isNull = econtext->ecxt_aggnulls[aggref->aggno];
    return econtext->ecxt_aggvalues[aggref->aggno];
}


What is the use of args in AggrefExprState node here? Is it there just for some historical reason?

Regards,
Vaibhav



--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company





--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company





--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company


Re: What would AggrefExprState nodes' args contain?

От
Heikki Linnakangas
Дата:
On 29.04.2011 13:19, Vaibhav Kaushal wrote:
> I have a small db which I am using to test it. Moreover I am new to the
> terms. What would you mean by 'regression'?

"make check"

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


Re: What would AggrefExprState nodes' args contain?

От
Vaibhav Kaushal
Дата:
<p>Thanks heikki.<p>@ashu: i am in final year undergrad at bangalore under vtu. I know the term regression. Just did
notknow how to do that. Heikki reminded me skmething i tried out while compiling binutils...make check. Will look into
that.<p>Thanks for the help so far both of you. :) <div class="gmail_quote">On 29 Apr 2011 16:24, "Heikki Linnakangas"
<<ahref="mailto:heikki.linnakangas@enterprisedb.com">heikki.linnakangas@enterprisedb.com</a>> wrote:<br
type="attribution"/>> On 29.04.2011 13:19, Vaibhav Kaushal wrote:<br /> >> I have a small db which I am using
totest it. Moreover I am new to the<br />>> terms. What would you mean by 'regression'?<br />> <br />>
"makecheck"<br />> <br />> -- <br />> Heikki Linnakangas<br /> > EnterpriseDB <a
href="http://www.enterprisedb.com">http://www.enterprisedb.com</a><br/></div>