if( pExpr->pList==0 || pExpr->pList->nExpr!=1 ) return 0;
pList = pExpr->pList; if( pList==0 || pList->nExpr!=1 ) return 0;
static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){  Expr *pExpr;  int iCol;  Table *pTab;  Index *pIdx;  int base;  Vdbe *v;  int seekOp;  int cont;  ExprList eList;  struct ExprList_item eListItem;  /* Check to see if this query is a simple min() or max() query.  Return  ** zero if it is  not.  */  if( p->pGroupBy || p->pHaving || p->pWhere ) return 0;  if( p->pSrc->nSrc!=1 ) return 0;  if( p->pEList->nExpr!=1 ) return 0;  pExpr = p->pEList->a[0].pExpr;  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;  if( pExpr->pList==0 || pExpr->pList->nExpr!=1 ) return 0;  if( pExpr->token.n!=3 ) return 0;  if( sqliteStrNICmp(pExpr->token.z,"min",3)==0 ){    seekOp = OP_Rewind;  }else if( sqliteStrNICmp(pExpr->token.z,"max",3)==0 ){    seekOp = OP_Last;  }else{    return 0;  }  pExpr = pExpr->pList->a[0].pExpr;  if( pExpr->op!=TK_COLUMN ) return 0;  iCol = pExpr->iColumn;  pTab = p->pSrc->a[0].pTab;  /* If we get to here, it means the query is of the correct form.  ** Check to make sure we have an index and make pIdx point to the  ** appropriate index.  If the min() or max() is on an INTEGER PRIMARY  ** key column, no index is necessary so set pIdx to NULL.  If no  ** usable index is found, return 0.  */  if( iCol<0 ){    pIdx = 0;  }else{    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){      assert( pIdx->nColumn>=1 );      if( pIdx->aiColumn[0]==iCol ) break;    }    if( pIdx==0 ) return 0;  }  /* Identify column types if we will be using the callback.  This  ** step is skipped if the output is going to a table or a memory cell.  ** The column names have already been generated in the calling function.  */  v = sqliteGetVdbe(pParse);  if( v==0 ) return 0;  if( eDest==SRT_Callback ){    generateColumnTypes(pParse, p->pSrc, p->pEList);  }  /* If the output is destined for a temporary table, open that table.  */  if( eDest==SRT_TempTable ){    sqliteVdbeAddOp(v, OP_OpenTemp, iParm, 0);  }  /* Generating code to find the min or the max.  Basically all we have  ** to do is find the first or the last entry in the chosen index.  If  ** the min() or max() is on the INTEGER PRIMARY KEY, then find the first  ** or last entry in the main table.  */  sqliteCodeVerifySchema(pParse, pTab->iDb);  base = p->pSrc->a[0].iCursor;  computeLimitRegisters(pParse, p);  sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);  sqliteVdbeOp3(v, OP_OpenRead, base, pTab->tnum, pTab->zName, 0);  cont = sqliteVdbeMakeLabel(v);  if( pIdx==0 ){    sqliteVdbeAddOp(v, seekOp, base, 0);  }else{    sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0);    sqliteVdbeOp3(v, OP_OpenRead, base+1, pIdx->tnum, pIdx->zName, P3_STATIC);    sqliteVdbeAddOp(v, seekOp, base+1, 0);    sqliteVdbeAddOp(v, OP_IdxRecno, base+1, 0);    sqliteVdbeAddOp(v, OP_Close, base+1, 0);    sqliteVdbeAddOp(v, OP_MoveTo, base, 0);  }  eList.nExpr = 1;  memset(&eListItem, 0, sizeof(eListItem));  eList.a = &eListItem;  eList.a[0].pExpr = pExpr;  selectInnerLoop(pParse, p, &eList, 0, 0, 0, -1, eDest, iParm, cont, cont);  sqliteVdbeResolveLabel(v, cont);  sqliteVdbeAddOp(v, OP_Close, base, 0);  return 1;}