internal static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, Token pTable, Token pDatabase, Token pAlias, Select pSubquery, Expr pOn, IdList pUsing) { var db = pParse.db; if (null == p && (pOn != null || pUsing != null)) { sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", pOn != null ? "ON" : "USING"); goto append_from_error; } p = sqlite3SrcListAppend(db, p, pTable, pDatabase); var pItem = p.a[p.nSrc - 1]; Debug.Assert(pAlias != null); if (pAlias.n != 0) pItem.zAlias = sqlite3NameFromToken(db, pAlias); pItem.pSelect = pSubquery; pItem.pOn = pOn; pItem.pUsing = pUsing; return p; append_from_error: Debug.Assert(p == null); sqlite3ExprDelete(db, ref pOn); sqlite3IdListDelete(db, ref pUsing); sqlite3SelectDelete(db, ref pSubquery); return null; }
static IdList sqlite3IdListDup(sqlite3 db, IdList p) { IdList pNew; int i; if (p == null) return null; pNew = new IdList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); if (pNew == null) return null; pNew.nId = pNew.nAlloc = p.nId; pNew.a = new IdList_item[p.nId];//sqlite3DbMallocRaw(db, p.nId*sizeof(p.a[0]) ); if (pNew.a == null) { sqlite3DbFree(db, ref pNew); return null; } for (i = 0; i < p.nId; i++) { pNew.a[i] = new IdList_item(); IdList_item pNewItem = pNew.a[i]; IdList_item pOldItem = p.a[i]; pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName); pNewItem.idx = pOldItem.idx; } return pNew; }
internal static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, Token pTable, Token pDatabase, Token pAlias, int null_6, Expr pOn, IdList pUsing) { return sqlite3SrcListAppendFromTerm(pParse, p, pTable, pDatabase, pAlias, null, pOn, pUsing); }
// This routine is called by the parser to add a new term to the end of a growing FROM clause. The "p" parameter is the part of // the FROM clause that has already been constructed. "p" is NULL if this is the first term of the FROM clause. pTable and pDatabase // are the name of the table and database named in the FROM clause term. pDatabase is NULL if the database name qualifier is missing - the // usual case. If the term has a alias, then pAlias points to the alias token. If the term is a subquery, then pSubquery is the // SELECT statement that the subquery encodes. The pTable and pDatabase parameters are NULL for subqueries. The pOn and pUsing // parameters are the content of the ON and USING clauses. // // Return a new SrcList which encodes is the FROM with the new term added. internal static SrcList sqlite3SrcListAppendFromTerm(Parse pParse, SrcList p, int null_3, int null_4, Token pAlias, Select pSubquery, Expr pOn, IdList pUsing) { return sqlite3SrcListAppendFromTerm(pParse, p, null, null, pAlias, pSubquery, pOn, pUsing); }