sqliteFree(zTName);
static int fillInColumnList(Parse *pParse, Select *p){  int i, j, k, rc;  SrcList *pTabList;  ExprList *pEList;  Table *pTab;  if( p==0 || p->pSrc==0 ) return 1;  pTabList = p->pSrc;  pEList = p->pEList;  /* Look up every table in the table list.  */  for(i=0; i<pTabList->nSrc; i++){    if( pTabList->a[i].pTab ){      /* This routine has run before!  No need to continue */      return 0;    }    if( pTabList->a[i].zName==0 ){      /* A sub-query in the FROM clause of a SELECT */      assert( pTabList->a[i].pSelect!=0 );      if( pTabList->a[i].zAlias==0 ){        char zFakeName[60];        sprintf(zFakeName, "sqlite_subquery_%p_",           (void*)pTabList->a[i].pSelect);        sqliteSetString(&pTabList->a[i].zAlias, zFakeName, 0);      }      pTabList->a[i].pTab = pTab =         sqliteResultSetOfSelect(pParse, pTabList->a[i].zAlias,                                        pTabList->a[i].pSelect);      if( pTab==0 ){        return 1;      }      /* The isTransient flag indicates that the Table structure has been      ** dynamically allocated and may be freed at any time.  In other words,      ** pTab is not pointing to a persistent table structure that defines      ** part of the schema. */      pTab->isTransient = 1;    }else{      /* An ordinary table or view name in the FROM clause */      pTabList->a[i].pTab = pTab =         sqliteLocateTable(pParse,pTabList->a[i].zName,pTabList->a[i].zDatabase);      if( pTab==0 ){        return 1;      }      if( pTab->pSelect ){        /* We reach here if the named table is a really a view */        if( sqliteViewGetColumnNames(pParse, pTab) ){          return 1;        }        /* If pTabList->a[i].pSelect!=0 it means we are dealing with a        ** view within a view.  The SELECT structure has already been        ** copied by the outer view so we can skip the copy step here        ** in the inner view.        */        if( pTabList->a[i].pSelect==0 ){          pTabList->a[i].pSelect = sqliteSelectDup(pTab->pSelect);        }      }    }  }  /* Process NATURAL keywords, and ON and USING clauses of joins.  */  if( sqliteProcessJoin(pParse, p) ) return 1;  /* For every "*" that occurs in the column list, insert the names of  ** all columns in all tables.  And for every TABLE.* insert the names  ** of all columns in TABLE.  The parser inserted a special expression  ** with the TK_ALL operator for each "*" that it found in the column list.  ** The following code just has to locate the TK_ALL expressions and expand  ** each one to the list of all columns in all tables.  **  ** The first loop just checks to see if there are any "*" operators  ** that need expanding.  */  for(k=0; k<pEList->nExpr; k++){    Expr *pE = pEList->a[k].pExpr;    if( pE->op==TK_ALL ) break;    if( pE->op==TK_DOT && pE->pRight && pE->pRight->op==TK_ALL         && pE->pLeft && pE->pLeft->op==TK_ID ) break;  }  rc = 0;  if( k<pEList->nExpr ){    /*    ** If we get here it means the result set contains one or more "*"    ** operators that need to be expanded.  Loop through each expression    ** in the result set and expand them one by one.    */    struct ExprList_item *a = pEList->a;    ExprList *pNew = 0;    for(k=0; k<pEList->nExpr; k++){      Expr *pE = a[k].pExpr;      if( pE->op!=TK_ALL &&           (pE->op!=TK_DOT || pE->pRight==0 || pE->pRight->op!=TK_ALL) ){        /* This particular expression does not need to be expanded.        */        pNew = sqliteExprListAppend(pNew, a[k].pExpr, 0);        pNew->a[pNew->nExpr-1].zName = a[k].zName;        a[k].pExpr = 0;        a[k].zName = 0;      }else{        /* This expression is a "*" or a "TABLE.*" and needs to be        ** expanded. */        int tableSeen = 0;      /* Set to 1 when TABLE matches */        Token *pName;           /* text of name of TABLE */        if( pE->op==TK_DOT && pE->pLeft ){          pName = &pE->pLeft->token;        }else{          pName = 0;        }        for(i=0; i<pTabList->nSrc; i++){          Table *pTab = pTabList->a[i].pTab;          char *zTabName = pTabList->a[i].zAlias;          if( zTabName==0 || zTabName[0]==0 ){             zTabName = pTab->zName;          }          if( pName && (zTabName==0 || zTabName[0]==0 ||                  sqliteStrNICmp(pName->z, zTabName, pName->n)!=0 ||                 zTabName[pName->n]!=0) ){            continue;          }          tableSeen = 1;          for(j=0; j<pTab->nCol; j++){            Expr *pExpr, *pLeft, *pRight;            char *zName = pTab->aCol[j].zName;            if( i>0 && (pTabList->a[i-1].jointype & JT_NATURAL)!=0 &&                columnIndex(pTabList->a[i-1].pTab, zName)>=0 ){              /* In a NATURAL join, omit the join columns from the               ** table on the right */              continue;            }            if( i>0 && sqliteIdListIndex(pTabList->a[i-1].pUsing, zName)>=0 ){              /* In a join with a USING clause, omit columns in the              ** using clause from the table on the right. */              continue;            }            pRight = sqliteExpr(TK_ID, 0, 0, 0);            if( pRight==0 ) break;            pRight->token.z = zName;            pRight->token.n = strlen(zName);            pRight->token.dyn = 0;            if( zTabName && pTabList->nSrc>1 ){              pLeft = sqliteExpr(TK_ID, 0, 0, 0);              pExpr = sqliteExpr(TK_DOT, pLeft, pRight, 0);              if( pExpr==0 ) break;              pLeft->token.z = zTabName;              pLeft->token.n = strlen(zTabName);              pLeft->token.dyn = 0;              sqliteSetString((char**)&pExpr->span.z, zTabName, ".", zName, 0);              pExpr->span.n = strlen(pExpr->span.z);              pExpr->span.dyn = 1;              pExpr->token.z = 0;              pExpr->token.n = 0;              pExpr->token.dyn = 0;            }else{              pExpr = pRight;              pExpr->span = pExpr->token;            }            pNew = sqliteExprListAppend(pNew, pExpr, 0);          }        }        if( !tableSeen ){          if( pName ){            sqliteErrorMsg(pParse, "no such table: %T", pName);          }else{            sqliteErrorMsg(pParse, "no tables specified");          }          rc = 1;        }      }    }    sqliteExprListDelete(pEList);    p->pEList = pNew;  }  return rc;}