亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? select.c

?? sqlite 3.3.8 支持加密的版本
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.25 2006/10/12 21:34:22 rmsimpson Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
*/
static void clearSelect(Select *p){
  sqlite3ExprListDelete(p->pEList);
  sqlite3SrcListDelete(p->pSrc);
  sqlite3ExprDelete(p->pWhere);
  sqlite3ExprListDelete(p->pGroupBy);
  sqlite3ExprDelete(p->pHaving);
  sqlite3ExprListDelete(p->pOrderBy);
  sqlite3SelectDelete(p->pPrior);
  sqlite3ExprDelete(p->pLimit);
  sqlite3ExprDelete(p->pOffset);
}


/*
** Allocate a new Select structure and return a pointer to that
** structure.
*/
Select *sqlite3SelectNew(
  ExprList *pEList,     /* which columns to include in the result */
  SrcList *pSrc,        /* the FROM clause -- which tables to scan */
  Expr *pWhere,         /* the WHERE clause */
  ExprList *pGroupBy,   /* the GROUP BY clause */
  Expr *pHaving,        /* the HAVING clause */
  ExprList *pOrderBy,   /* the ORDER BY clause */
  int isDistinct,       /* true if the DISTINCT keyword is present */
  Expr *pLimit,         /* LIMIT value.  NULL means not used */
  Expr *pOffset         /* OFFSET value.  NULL means no offset */
){
  Select *pNew;
  Select standin;
  pNew = sqliteMalloc( sizeof(*pNew) );
  assert( !pOffset || pLimit );   /* Can't have OFFSET without LIMIT. */
  if( pNew==0 ){
    pNew = &standin;
    memset(pNew, 0, sizeof(*pNew));
  }
  if( pEList==0 ){
    pEList = sqlite3ExprListAppend(0, sqlite3Expr(TK_ALL,0,0,0), 0);
  }
  pNew->pEList = pEList;
  pNew->pSrc = pSrc;
  pNew->pWhere = pWhere;
  pNew->pGroupBy = pGroupBy;
  pNew->pHaving = pHaving;
  pNew->pOrderBy = pOrderBy;
  pNew->isDistinct = isDistinct;
  pNew->op = TK_SELECT;
  pNew->pLimit = pLimit;
  pNew->pOffset = pOffset;
  pNew->iLimit = -1;
  pNew->iOffset = -1;
  pNew->addrOpenEphm[0] = -1;
  pNew->addrOpenEphm[1] = -1;
  pNew->addrOpenEphm[2] = -1;
  if( pNew==&standin) {
    clearSelect(pNew);
    pNew = 0;
  }
  return pNew;
}

/*
** Delete the given Select structure and all of its substructures.
*/
void sqlite3SelectDelete(Select *p){
  if( p ){
    clearSelect(p);
    sqliteFree(p);
  }
}

/*
** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the
** type of join.  Return an integer constant that expresses that type
** in terms of the following bit values:
**
**     JT_INNER
**     JT_CROSS
**     JT_OUTER
**     JT_NATURAL
**     JT_LEFT
**     JT_RIGHT
**
** A full outer join is the combination of JT_LEFT and JT_RIGHT.
**
** If an illegal or unsupported join type is seen, then still return
** a join type, but put an error in the pParse structure.
*/
int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
  int jointype = 0;
  Token *apAll[3];
  Token *p;
  static const struct {
    const char zKeyword[8];
    u8 nChar;
    u8 code;
  } keywords[] = {
    { "natural", 7, JT_NATURAL },
    { "left",    4, JT_LEFT|JT_OUTER },
    { "right",   5, JT_RIGHT|JT_OUTER },
    { "full",    4, JT_LEFT|JT_RIGHT|JT_OUTER },
    { "outer",   5, JT_OUTER },
    { "inner",   5, JT_INNER },
    { "cross",   5, JT_INNER|JT_CROSS },
  };
  int i, j;
  apAll[0] = pA;
  apAll[1] = pB;
  apAll[2] = pC;
  for(i=0; i<3 && apAll[i]; i++){
    p = apAll[i];
    for(j=0; j<sizeof(keywords)/sizeof(keywords[0]); j++){
      if( p->n==keywords[j].nChar 
          && sqlite3StrNICmp((char*)p->z, keywords[j].zKeyword, p->n)==0 ){
        jointype |= keywords[j].code;
        break;
      }
    }
    if( j>=sizeof(keywords)/sizeof(keywords[0]) ){
      jointype |= JT_ERROR;
      break;
    }
  }
  if(
     (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
     (jointype & JT_ERROR)!=0
  ){
    const char *zSp1 = " ";
    const char *zSp2 = " ";
    if( pB==0 ){ zSp1++; }
    if( pC==0 ){ zSp2++; }
    sqlite3ErrorMsg(pParse, "unknown or unsupported join type: "
       "%T%s%T%s%T", pA, zSp1, pB, zSp2, pC);
    jointype = JT_INNER;
  }else if( jointype & JT_RIGHT ){
    sqlite3ErrorMsg(pParse, 
      "RIGHT and FULL OUTER JOINs are not currently supported");
    jointype = JT_INNER;
  }
  return jointype;
}

/*
** Return the index of a column in a table.  Return -1 if the column
** is not contained in the table.
*/
static int columnIndex(Table *pTab, const char *zCol){
  int i;
  for(i=0; i<pTab->nCol; i++){
    if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
  }
  return -1;
}

/*
** Set the value of a token to a '\000'-terminated string.
*/
static void setToken(Token *p, const char *z){
  p->z = (u8*)z;
  p->n = z ? strlen(z) : 0;
  p->dyn = 0;
}

/*
** Create an expression node for an identifier with the name of zName
*/
Expr *sqlite3CreateIdExpr(const char *zName){
  Token dummy;
  setToken(&dummy, zName);
  return sqlite3Expr(TK_ID, 0, 0, &dummy);
}


/*
** Add a term to the WHERE expression in *ppExpr that requires the
** zCol column to be equal in the two tables pTab1 and pTab2.
*/
static void addWhereTerm(
  const char *zCol,        /* Name of the column */
  const Table *pTab1,      /* First table */
  const char *zAlias1,     /* Alias for first table.  May be NULL */
  const Table *pTab2,      /* Second table */
  const char *zAlias2,     /* Alias for second table.  May be NULL */
  int iRightJoinTable,     /* VDBE cursor for the right table */
  Expr **ppExpr            /* Add the equality term to this expression */
){
  Expr *pE1a, *pE1b, *pE1c;
  Expr *pE2a, *pE2b, *pE2c;
  Expr *pE;

  pE1a = sqlite3CreateIdExpr(zCol);
  pE2a = sqlite3CreateIdExpr(zCol);
  if( zAlias1==0 ){
    zAlias1 = pTab1->zName;
  }
  pE1b = sqlite3CreateIdExpr(zAlias1);
  if( zAlias2==0 ){
    zAlias2 = pTab2->zName;
  }
  pE2b = sqlite3CreateIdExpr(zAlias2);
  pE1c = sqlite3ExprOrFree(TK_DOT, pE1b, pE1a, 0);
  pE2c = sqlite3ExprOrFree(TK_DOT, pE2b, pE2a, 0);
  pE = sqlite3ExprOrFree(TK_EQ, pE1c, pE2c, 0);
  if( pE ){
    ExprSetProperty(pE, EP_FromJoin);
    pE->iRightJoinTable = iRightJoinTable;
  }
  pE = sqlite3ExprAnd(*ppExpr, pE);
  if( pE ){
    *ppExpr = pE;
  }
}

/*
** Set the EP_FromJoin property on all terms of the given expression.
** And set the Expr.iRightJoinTable to iTable for every term in the
** expression.
**
** The EP_FromJoin property is used on terms of an expression to tell
** the LEFT OUTER JOIN processing logic that this term is part of the
** join restriction specified in the ON or USING clause and not a part
** of the more general WHERE clause.  These terms are moved over to the
** WHERE clause during join processing but we need to remember that they
** originated in the ON or USING clause.
**
** The Expr.iRightJoinTable tells the WHERE clause processing that the
** expression depends on table iRightJoinTable even if that table is not
** explicitly mentioned in the expression.  That information is needed
** for cases like this:
**
**    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5
**
** The where clause needs to defer the handling of the t1.x=5
** term until after the t2 loop of the join.  In that way, a
** NULL t2 row will be inserted whenever t1.x!=5.  If we do not
** defer the handling of t1.x=5, it will be processed immediately
** after the t1 loop and rows with t1.x!=5 will never appear in
** the output, which is incorrect.
*/
static void setJoinExpr(Expr *p, int iTable){
  while( p ){
    ExprSetProperty(p, EP_FromJoin);
    p->iRightJoinTable = iTable;
    setJoinExpr(p->pLeft, iTable);
    p = p->pRight;
  } 
}

/*
** This routine processes the join information for a SELECT statement.
** ON and USING clauses are converted into extra terms of the WHERE clause.
** NATURAL joins also create extra WHERE clause terms.
**
** The terms of a FROM clause are contained in the Select.pSrc structure.
** The left most table is the first entry in Select.pSrc.  The right-most
** table is the last entry.  The join operator is held in the entry to
** the left.  Thus entry 0 contains the join operator for the join between
** entries 0 and 1.  Any ON or USING clauses associated with the join are
** also attached to the left entry.
**
** This routine returns the number of errors encountered.
*/
static int sqliteProcessJoin(Parse *pParse, Select *p){
  SrcList *pSrc;                  /* All tables in the FROM clause */
  int i, j;                       /* Loop counters */
  struct SrcList_item *pLeft;     /* Left table being joined */
  struct SrcList_item *pRight;    /* Right table being joined */

  pSrc = p->pSrc;
  pLeft = &pSrc->a[0];
  pRight = &pLeft[1];
  for(i=0; i<pSrc->nSrc-1; i++, pRight++, pLeft++){
    Table *pLeftTab = pLeft->pTab;
    Table *pRightTab = pRight->pTab;

    if( pLeftTab==0 || pRightTab==0 ) continue;

    /* When the NATURAL keyword is present, add WHERE clause terms for
    ** every column that the two tables have in common.
    */
    if( pLeft->jointype & JT_NATURAL ){
      if( pLeft->pOn || pLeft->pUsing ){
        sqlite3ErrorMsg(pParse, "a NATURAL join may not have "
           "an ON or USING clause", 0);
        return 1;
      }
      for(j=0; j<pLeftTab->nCol; j++){
        char *zName = pLeftTab->aCol[j].zName;
        if( columnIndex(pRightTab, zName)>=0 ){
          addWhereTerm(zName, pLeftTab, pLeft->zAlias, 
                              pRightTab, pRight->zAlias,
                              pRight->iCursor, &p->pWhere);
          
        }
      }
    }

    /* Disallow both ON and USING clauses in the same join
    */
    if( pLeft->pOn && pLeft->pUsing ){
      sqlite3ErrorMsg(pParse, "cannot have both ON and USING "
        "clauses in the same join");
      return 1;
    }

    /* Add the ON clause to the end of the WHERE clause, connected by
    ** an AND operator.
    */
    if( pLeft->pOn ){
      setJoinExpr(pLeft->pOn, pRight->iCursor);
      p->pWhere = sqlite3ExprAnd(p->pWhere, pLeft->pOn);
      pLeft->pOn = 0;
    }

    /* Create extra terms on the WHERE clause for each column named
    ** in the USING clause.  Example: If the two tables to be joined are 
    ** A and B and the USING clause names X, Y, and Z, then add this
    ** to the WHERE clause:    A.X=B.X AND A.Y=B.Y AND A.Z=B.Z
    ** Report an error if any column mentioned in the USING clause is
    ** not contained in both tables to be joined.
    */
    if( pLeft->pUsing ){
      IdList *pList = pLeft->pUsing;
      for(j=0; j<pList->nId; j++){
        char *zName = pList->a[j].zName;
        if( columnIndex(pLeftTab, zName)<0 || columnIndex(pRightTab, zName)<0 ){
          sqlite3ErrorMsg(pParse, "cannot join using column %s - column "
            "not present in both tables", zName);
          return 1;
        }
        addWhereTerm(zName, pLeftTab, pLeft->zAlias, 
                            pRightTab, pRight->zAlias,
                            pRight->iCursor, &p->pWhere);
      }
    }
  }
  return 0;
}

/*
** Insert code into "v" that will push the record on the top of the
** stack into the sorter.
*/
static void pushOntoSorter(
  Parse *pParse,         /* Parser context */
  ExprList *pOrderBy,    /* The ORDER BY clause */
  Select *pSelect        /* The whole SELECT statement */
){
  Vdbe *v = pParse->pVdbe;
  sqlite3ExprCodeExprList(pParse, pOrderBy);
  sqlite3VdbeAddOp(v, OP_Sequence, pOrderBy->iECursor, 0);
  sqlite3VdbeAddOp(v, OP_Pull, pOrderBy->nExpr + 1, 0);
  sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr + 2, 0);
  sqlite3VdbeAddOp(v, OP_IdxInsert, pOrderBy->iECursor, 0);
  if( pSelect->iLimit>=0 ){
    int addr1, addr2;
    addr1 = sqlite3VdbeAddOp(v, OP_IfMemZero, pSelect->iLimit+1, 0);
    sqlite3VdbeAddOp(v, OP_MemIncr, -1, pSelect->iLimit+1);
    addr2 = sqlite3VdbeAddOp(v, OP_Goto, 0, 0);
    sqlite3VdbeJumpHere(v, addr1);
    sqlite3VdbeAddOp(v, OP_Last, pOrderBy->iECursor, 0);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
强制捆绑调教一区二区| 久久精品亚洲精品国产欧美| 亚洲欧美日韩中文播放| 99精品黄色片免费大全| 亚洲视频一区二区在线观看| 色琪琪一区二区三区亚洲区| 亚洲一区二区三区自拍| 欧美精品日日鲁夜夜添| 国产综合久久久久影院| 国产欧美日韩一区二区三区在线观看| 成人a区在线观看| 亚洲精品网站在线观看| 欧美日韩激情在线| 久久电影网站中文字幕| 中文幕一区二区三区久久蜜桃| 99国内精品久久| 亚洲成人tv网| 久久久欧美精品sm网站| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲综合区在线| 欧美本精品男人aⅴ天堂| voyeur盗摄精品| 亚洲国产成人av网| 久久在线观看免费| 色香色香欲天天天影视综合网| 天天色图综合网| 国产女主播一区| 制服丝袜中文字幕亚洲| 国产成人亚洲综合a∨婷婷图片| 国产精品久久777777| 欧美精品视频www在线观看| 国模少妇一区二区三区| 一区二区三区**美女毛片| 日韩久久久久久| 色悠悠久久综合| 韩国成人福利片在线播放| 一区二区三区日韩精品视频| 精品国产乱码久久久久久牛牛| 91免费版在线看| 国产一区二区免费视频| 亚洲成人精品一区二区| 国产日韩高清在线| 91麻豆精品国产无毒不卡在线观看| 成人app网站| 久草在线在线精品观看| 亚洲一区二区偷拍精品| 欧美韩国一区二区| 欧美电视剧在线看免费| 欧美三区免费完整视频在线观看| 国产成人在线观看免费网站| 免费观看在线综合色| 亚洲精品日日夜夜| 国产欧美日韩另类视频免费观看 | 精品理论电影在线| 在线精品国精品国产尤物884a| 国产麻豆9l精品三级站| 蜜桃视频一区二区三区在线观看 | 亚洲午夜在线观看视频在线| 国产午夜精品一区二区| 欧美v亚洲v综合ⅴ国产v| 欧美日韩免费视频| 在线精品视频免费播放| 色噜噜狠狠成人中文综合| 成人国产一区二区三区精品| 国产一区二区不卡老阿姨| 久久精品噜噜噜成人av农村| 日韩高清欧美激情| 婷婷一区二区三区| 无码av中文一区二区三区桃花岛| 亚洲综合色自拍一区| 一区二区三区在线观看网站| 亚洲码国产岛国毛片在线| 国产精品久久久久久一区二区三区| 欧美精品一区二区三区蜜桃| 精品国产一区二区三区忘忧草| 3d动漫精品啪啪一区二区竹菊| 欧美日韩久久久| 3d动漫精品啪啪| 欧美tickle裸体挠脚心vk| 91精品国产欧美一区二区成人| 欧美另类z0zxhd电影| 911精品产国品一二三产区| 欧美丰满少妇xxxbbb| 欧美一区二区视频在线观看2020| 777久久久精品| 日韩一区二区不卡| 久久久久9999亚洲精品| 国产日产欧美精品一区二区三区| 亚洲欧美另类图片小说| 国产精品乱码一区二区三区软件 | av中文字幕一区| 一本久久精品一区二区| 欧美性一区二区| 在线播放欧美女士性生活| 欧美大胆一级视频| 久久亚区不卡日本| 一区视频在线播放| 亚洲自拍偷拍av| 美女视频黄免费的久久| 国产成人在线视频播放| 色呦呦一区二区三区| 日韩三级中文字幕| 日本一区二区视频在线观看| 亚洲男人的天堂av| 日韩电影一二三区| 国产成人精品午夜视频免费| 日本韩国欧美一区二区三区| 欧美一区二区三区在线| 国产精品污污网站在线观看| 亚洲一区二区三区国产| 麻豆久久久久久久| www.在线欧美| 欧美丰满美乳xxx高潮www| 久久你懂得1024| 亚洲制服欧美中文字幕中文字幕| 毛片一区二区三区| 91丨porny丨中文| 日韩欧美你懂的| 一级精品视频在线观看宜春院| 免费日韩伦理电影| 91美女福利视频| 精品福利二区三区| 亚洲一区二区三区四区在线观看 | 青草av.久久免费一区| 成人黄动漫网站免费app| 69久久99精品久久久久婷婷| 欧美高清在线精品一区| 日产国产欧美视频一区精品| 99久久99久久综合| 欧美一区二区三区播放老司机| 国产精品久久久久久久久图文区 | 亚洲欧洲一区二区三区| 理论片日本一区| 在线观看成人免费视频| 久久久国产午夜精品| 日韩极品在线观看| 91丨porny丨户外露出| 欧美精品一区二区在线播放| 亚洲国产综合色| 91麻豆国产福利在线观看| 久久久欧美精品sm网站| 免费看欧美女人艹b| 欧美肥妇bbw| 亚洲一区二区av在线| 97se亚洲国产综合自在线| 久久久精品免费观看| 国内精品伊人久久久久av影院| 欧美日韩成人综合天天影院| 一区二区三区视频在线观看| av成人免费在线观看| 久久久久99精品一区| 国产一区二区三区在线看麻豆| 欧美福利电影网| 无吗不卡中文字幕| 欧美酷刑日本凌虐凌虐| 亚洲精品国产品国语在线app| 成人动漫一区二区三区| 国产亚洲精品7777| 国内一区二区在线| 26uuu国产在线精品一区二区| 日本不卡一二三| 91精品国产91久久久久久最新毛片| 亚洲国产三级在线| 欧美亚洲高清一区二区三区不卡| 亚洲黄色免费网站| 在线观看一区不卡| 亚洲午夜久久久久久久久电影院| 色呦呦国产精品| 亚洲成人一区二区| 欧美电影一区二区| 日韩成人伦理电影在线观看| 91精品国产免费| 日本美女一区二区| 精品99久久久久久| 国产a级毛片一区| 国产精品初高中害羞小美女文| 波多野结衣在线aⅴ中文字幕不卡| 国产精品麻豆欧美日韩ww| 99久久精品一区| 亚洲最新在线观看| 在线不卡中文字幕播放| 久久精品国产精品亚洲综合| 精品国产sm最大网站免费看| 国产精品亚洲а∨天堂免在线| 国产日本一区二区| 色综合天天综合色综合av| 亚洲一区视频在线| 欧美一区二区久久久| 国产一区福利在线| 国产精品久久久99| 欧美日本在线观看| 极品少妇xxxx偷拍精品少妇| 国产农村妇女毛片精品久久麻豆| 99久久久国产精品| 日韩av一级片| 日本一区二区三区dvd视频在线| a4yy欧美一区二区三区| 日韩国产在线观看| 日本一区二区三区久久久久久久久不 | 在线中文字幕不卡|