Re: [sqlite] Sqlite 3.3.13; expr.c; analyzeAggregate

2007-03-12 Thread drh
"Noah Hart" <[EMAIL PROTECTED]> wrote:
> In expr.c, around line 2253, there is a nested loop which reads:
> 
> for(i=0; inSrc; i++, pItem++){
>   if( pExpr->iTable==pItem->iCursor ){
> for(i=0; inSrc; i++, pItem++){
>   if( pCol->iTable==pExpr->iTable &&
>   pCol->iColumn==pExpr->iColumn ){
> break;
>   }
> }
> if( i>=pAggInfo->nColumn ... ){
> }
> break;
>   }
> }
> 
> In this final line, which loop variable does the i refer to?
> the first one: for(i=0; inSrc; i++, pItem++){
> Or then next : for(i=0; inSrc; i++, pItem++){
> 
> are the two "i" the same variable, and it is intended that the
> second loop reset the Outer loop variable each time the inner 
> loop is run, and that the assignment statement affect the outer 
> loop as well?
> 

Once the first "if" statement fires, the outer loop is done, and 
it is ok to reuse the outer loop variable inside the "if".  So the 
code is correct as written. Nevertheless, I have changed the loop 
variable on the inner loop to avoid unnecessary confusion.

--
D. Richard Hipp  <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Sqlite 3.3.13; expr.c; analyzeAggregate

2007-03-12 Thread Noah Hart
In expr.c, around line 2253, there is a nested loop which reads:

 switch( pExpr->op ){
case TK_AGG_COLUMN:
case TK_COLUMN: {
  /* Check to see if the column is in one of the tables in the FROM
  ** clause of the aggregate query */
  if( pSrcList ){
struct SrcList_item *pItem = pSrcList->a;
for(i=0; inSrc; i++, pItem++){
  struct AggInfo_col *pCol;
  if( pExpr->iTable==pItem->iCursor ){
/* If we reach this point, it means that pExpr refers to a
table
** that is in the FROM clause of the aggregate query.  
**
** Make an entry for the column in pAggInfo->aCol[] if there
** is not an entry there already.
*/
pCol = pAggInfo->aCol;
for(i=0; inSrc; i++, pItem++){
  if( pCol->iTable==pExpr->iTable &&
  pCol->iColumn==pExpr->iColumn ){
break;
  }
}
if( i>=pAggInfo->nColumn && (i =
addAggInfoColumn(pAggInfo))>=0 ){


In this final line, which loop variable does the i refer to?
the first one: for(i=0; inSrc; i++, pItem++){
Or then next : for(i=0; inSrc; i++, pItem++){

are the two "i" the same variable, and it is intended that the second
loop reset the 
Outer loop variable each time the inner loop is run, and that the
assignment statement affect the outer loop as well?



Thanks for the clarification,

Noah Hart



CONFIDENTIALITY NOTICE: 
This message may contain confidential and/or privileged information. If you are 
not the addressee or authorized to receive this for the addressee, you must not 
use, copy, disclose, or take any action based on this message or any 
information herein. If you have received this message in error, please advise 
the sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation.




-
To unsubscribe, send email to [EMAIL PROTECTED]
-