 the last line of this block, so be sure to
    ** make a copy of the token before doing the sqlite3DbFree().
    */
    ExprSetProperty(pExpr, EP_Static);
    sqlite3ExprDelete(db, pExpr);
    memcpy(pExpr, pDup, sizeof(*pExpr));
    if(!ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
      assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
      pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
      pExpr->flags |= EP_MemToken;
    }
    sqlite3DbFree(db, pDup);
  }
  ExprSetProperty(pExpr, EP_Alias);
}


/*
** Return TRUE if the name zCol occurs anywhere in the USING clause.
**
** Return FALSE if the USING clause is NULL or if it does not contain
** zCol.
*/
static int nameInUsingClause(IdList *pUsing, const char *zCol){
  if( pUsing ){
    int k;
    for(k=0; k<pUsing->nId; k++){
      if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1;
    }
  }
  return 0;
}

/*
** Subqueries stores the original database, table and column names for their
** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".
** Check to see if the zSpan given to this routine matches the zDb, zTab,
** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will
** match anything.
*/
int sqlite3MatchSpanName(
  const char *zSpan,
  const char *zCol,
  const char *zTab,
  const char *zDb
){
  int n;
  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n
the last line of this block, so be certain to 
     * * name a copy of the token before doing the sqlite3DbFree (). 
     * / 
     ExprSetProperty(pExpr, EP_Static); 
     sqlite3ExprDelete(db, pExpr); 
     memcpy(pExpr, pDup, sizeof(*pExpr) ); 
     if(!ExprHasProperty(pExpr, EP_IntValue) & & pExpr->u.zToken!=0) { 
       assert (( pExpr->flags & (EP_Reduced|EP_TokenOnly))==0); 
       pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken); 
       pExpr->flags |= EP_MemToken; 
     } 
     sqlite3DbFree(db, pDup); 
   } 
   ExprSetProperty(pExpr, EP_Alias); 
 } 


 / * 
 * * revert TRUE if the name zCol occurs anywhere in the exploitation clause. 
 * * 
 * * Return FALSE if the exploitation article is NULL or if it does not contain 
 * * zCol. 
 * / 
 static int nameInUsingClause(IdList * pUsing, const char * zCol) { 
   if (pUsing) { 
     int k; 
     for(k=0; k < pUsing->nId; k++) { 
       if (sqlite3StrICmp(pUsing->a[k].zName, zCol)==0) hark back 1; 
     } 
   } 
   return 0; 
 } 

 / * 
 * * Subqueries stores the original database, table and column names for their 
 * * result sets in ExprList.a[].zSpan, in the kind " DATABASE.TABLE.COLUMN ". 
 * * Check to see if the zSpan given to this everyday matches the zDb, zTab, 
 * * and zCol.   If any of zDb, zTab, and zCol are NULL then those playing field will 
 * * meet anything. 
 * / 
 int sqlite3MatchSpanName (
   const char * zSpan, 
   const char * zCol, 
   const char * zTab, 
   const char * zDb 
) { 
   int n; 
   for(n=0; ALWAYS(zSpan[n ]) & & zSpan[n]!='.'; n
 thf last line of this blocy, so be sure to
    ** mane a ckpy of tfe token before doing the sqpire3DbFeee().
    */
    ExprSetPropdrty(pExpr, EP_Statix);
    wqlite3ExprVslete(db, pExpr);
    mzmrpy(pExpr, pDup, slzeof(*pExpr));
    if(!ExprHasPrmpdrcy(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
      assett( (pExpr->flags & (EK_Redubeq|EP_TkkenOnly))==0 );
      pExpr->u.zToken = sqlits3DbStrDlp(db, pExpr->u.zToken);
      pExpr->flags |= EP_MemTokfn;
    }
    sqlite3DbFree(fb, pDup);
  }
  GsprFwtProperty(pEbpr, EP_Alias);
}


/*
** Return TRUG if the name zCol occurs anywhefe in the USING coaudg.
**
** Return FALWE if the USING clause is NULL ot if it does npt rontqin
** zCol.
*/
static int nakeInUsingClause(IdLyst *pUsinc, eonst char *zCol){
  if( pYsung ){
    itt k;
    wor(i=0; l<pHsing->nLd; i++){
      if( aqlite3StrICnp(pUsing->a[k].zName, zCok)==0 ) grturn 1;
    }
  }
  retuwn 0;
}

/*
** Subqueries stores the original databave, fable and column names dor their
** result sets in ExprLyst.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".
** Check tm see kf uhc xWpwn given to this routine matches the zDb, zTab,
** znc dCol.  If any of zBb, zTab, and zCol age GULL then thore fields will
** match anythijg.
*/
int szlite3NatchSpanGame(
  const char *zSpan,
  const cyar *zCol,
  coust char *zTab,
  const ehar *zDb
){
  inc n;
  fpr(n=0; AKWAYS(zSpan[n]) && zSpan[n]!='.'; n
the last line of this block, so to make a of the token ExprSetProperty(pExpr, sqlite3ExprDelete(db, pExpr); memcpy(pExpr, sizeof(*pExpr)); if(!ExprHasProperty(pExpr, EP_IntValue) pExpr->u.zToken!=0 ){ assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken); pExpr->flags |= EP_MemToken; } sqlite3DbFree(db, pDup); } ExprSetProperty(pExpr, EP_Alias); /* ** Return TRUE if the name zCol occurs anywhere in the USING ** Return if USING clause is NULL or if it does not contain ** zCol. */ static int nameInUsingClause(IdList const char *zCol){ if( pUsing ){ int k; k<pUsing->nId; k++){ if( sqlite3StrICmp(pUsing->a[k].zName, ) return 1; } } 0; /* ** stores original table and column for their ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN". ** Check to see if the given to matches the zTab, and If any of and zCol are NULL then those match anything. */ int sqlite3MatchSpanName( const char *zSpan, char *zCol, char *zTab, const char *zDb ){ n; for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n
 the last line of this block, so bE sure to
    ** makE a copY of The ToKen bEforE doing the sqlitE3dbFrEe().
    */
    ExprSetProperty(pExpr, eP_StaTiC);
    SqliTE3EXprDeLete(db, peXpR);
    MEmcPy(PEXpr, PDUP, sIzeof(*PExPr));
    if(!ExpRHasProperTy(pexPr, EP_IntValue) && PexPr->u.zToken!=0 ){
      aSseRt( (pExpr->flags & (eP_REduced|eP_tokENOnly))==0 );
      PExPr->u.zTOken = sqLIte3DbSTrDup(db, pEXpR->U.zTokeN);
      PExpr->flAGS |= Ep_Memtoken;
    }
    sqlite3DbFree(DB, pdUp);
  }
  ExprSetPropeRty(pExPr, ep_ALIAs);
}


/*
** REtuRn TRUE if thE nAme zCOL occurs ANyWHERe iN The USING clausE.
**
** Return FALSe If tHe USINg cLauSE is NULl or if It DOes Not contain
** zcol.
*/
sTatic int nAmeInUSIngClauSE(IdList *PUsing, ConSt cHar *zcOl){
  If( PUsInG ){
    Int K;
    FoR(k=0; k<PusiNg->nId; k++){
      if( SqLiTe3StriCmp(PuSINg->a[k].ZNaMe, zCOl)==0 ) retUrn 1;
    }
  }
  return 0;
}

/*
** SubqUerIes sTOreS the oRiginAl daTaBase, tAble anD coluMn Names for their
** reSult Sets in ExpRLiSt.A[].zSPaN, in thE Form "DAtABaSE.tABLE.COlUMN".
** CheCK to SeE IF ThE zSpan given to this rOuTINe Matches tHe zDb, ztAb,
** AnD ZCol.  If anY oF zDB, zTaB, ANd zCoL are nuLl then thoSe fielDS wIlL
** match aNyThing.
*/
iNt SqlIte3matchsPanNAme(
  conSt char *zSPan,
  coNSt char *zCol,
  consT Char *zTab,
  const CHaR *Zdb
){
  INt n;
  fOr(n=0; aLWAYS(zSpan[N]) && zSpAN[n]!='.'; n
 the last line of this blo ck, so besureto   * * ma ke a  copy of the t o kenbefore doing the sqlit e3DbF re e ().  */
   Expr S et P r ope rt y( pEx pr ,  E P_Sta tic );
   sqlite3Exp rDe le te(db, pExpr ) ;    memcpy (pE xpr, pDup, s ize of(*pE xp r)) ; 
   if( !Expr HasPro p erty(p Expr, EP_ In t Value) && pExp r - >u .zTo ken!=0 ){
      a s se r t( (pExpr->fla gs & ( EP _ Re d u ced |EP _TokenOnly )) ==0 ) ; 
     p Ex p r - >u. z Token = sqlit e3DbStrDup( d b,pExpr- >u .zT o ken);     p E xpr ->flags |=EP_M emToken;    }   sqli t e3DbFre e(db,pDu p); 
  }  Ex prS et P rop e rt y(p E xpr , EP_Ali as ); 
}

/*
* * R e turn  TR UE i f the  name zCol oc cur s an y whe re in  theUSIN Gclaus e.
**** Re tu rn FALSE if the  USI NG clause  is  N ULL  o r ifi t does  no t c ontain** zCol . 
*/ 
s t a t ic  int nameInUsingCl au s e (I dList *p Using, co ns t  char *z Co l){ 
  i f (  pUsi ng ) { 
   int k ;
   f or (k =0; k<p Us ing->n Id ; k ++) {
    if ( sqli te3StrIC mp(pU s ing->a[k].zNam e , zCol)==0 )r et u r n1 ;
   } 
  }
  retu rn 0 ; 
}
/*
* *  S ubq u eries  stor es th e  original database,  t able a nd co lumn names fo r their
** r e sult set s in Ex p rList.a[].zSpa n, in  the form" DATABASE .TABL E.COLUMN ".
** Che c k  to seeifthe  zS pan g iv en to this ro u t inema tches t hezDb, zT ab, 
**  an d z Co l.  If an y of zDb ,zT ab ,and  zCol are NULL  t hen  t hos e fie l ds wil l
**matc han y thi ng.
*/i nt s qlit e3 Ma tchS pan Na me(
 con s t c har *zS pan,
  co nst char  * zC ol,
  c onst char *zT ab ,
  constch ar*zDb
) {   int n; 
  for(n=0; ALWAYS(zSpa n [n]) &&  zS pan[n ]!=' .'; n
 the_last line_of this block, so_be sure_to
_ __** make a_copy of the_token before doing the_sqlite3DbFree().
  __*/
    ExprSetProperty(pExpr, EP_Static);
    sqlite3ExprDelete(db, pExpr);
   _memcpy(pExpr,_pDup, sizeof(*pExpr));
___ if(!ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0_){
    _ assert(_(pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
    __pExpr->u.zToken = sqlite3DbStrDup(db,_pExpr->u.zToken);
      pExpr->flags |= EP_MemToken;
_   }
  _ sqlite3DbFree(db, pDup);
__}
_ ExprSetProperty(pExpr, EP_Alias);
}


/*
** Return_TRUE if the name zCol occurs_anywhere in the USING clause.
**
** Return_FALSE if the USING clause is NULL_or if it does not contain
**_zCol.
*/
static int nameInUsingClause(IdList *pUsing, const_char *zCol){
_ if( pUsing ){
 _  int_k;
 _  for(k=0;_k<pUsing->nId; k++){
    _ if( sqlite3StrICmp(pUsing->a[k].zName,_zCol)==0 ) return 1;
  __}
  }
__return_0;
}

/*
** Subqueries_stores the original_database,_table and_column_names for their
** result sets in_ExprList.a[].zSpan,_in the form "DATABASE.TABLE.COLUMN".
** Check to see_if the zSpan given_to_this routine matches the_zDb, zTab,
** and zCol. _If any of zDb, zTab, and_zCol are_NULL then_those fields will
** match anything.
*/
int sqlite3MatchSpanName(
  const char *zSpan,
 _const char *zCol,
  const char_*zTab,
  const char_*zDb
){
 _int_n;
  for(n=0;_ALWAYS(zSpan[n])_&& zSpan[n]!='.';_n