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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃视频在线一区| 国产日韩影视精品| www.综合网.com| 国产精选一区二区三区| 国产精品1区2区| 国产aⅴ综合色| 94-欧美-setu| 色综合久久中文综合久久牛| 91蝌蚪porny| 欧美日韩一区在线观看| 欧美日产在线观看| 欧美一区三区二区| 久久网这里都是精品| 久久久91精品国产一区二区三区| 久久久99免费| 亚洲欧美日韩国产手机在线| 亚洲精品欧美综合四区| 视频一区视频二区在线观看| 日韩和欧美一区二区| 久久91精品国产91久久小草| 国产精品自在在线| hitomi一区二区三区精品| 欧美无乱码久久久免费午夜一区| 欧美一级片免费看| 久久久久99精品国产片| 亚洲欧美日韩中文字幕一区二区三区 | 久久97超碰色| 国产91丝袜在线播放0| 97aⅴ精品视频一二三区| 欧美日本免费一区二区三区| 日韩一二三区不卡| 国产精品久久久一本精品| 亚洲综合成人在线| 韩国成人精品a∨在线观看| 不卡的电影网站| 欧美一区二区不卡视频| 国产精品久久久久影院亚瑟| 五月综合激情婷婷六月色窝| 国产精品一线二线三线| 色综合 综合色| 久久亚洲一级片| 亚洲综合精品久久| 丰满少妇久久久久久久| 56国语精品自产拍在线观看| 国产人成亚洲第一网站在线播放| 亚洲h动漫在线| 99re免费视频精品全部| 精品成人在线观看| 亚洲一卡二卡三卡四卡五卡| 国产成人精品影视| 日韩免费一区二区| 亚洲最大成人综合| aaa亚洲精品| 精品国产第一区二区三区观看体验| 18成人在线观看| 国产99久久久国产精品潘金| 91精品国产色综合久久| 亚洲理论在线观看| 97久久精品人人澡人人爽| 久久在线观看免费| 精彩视频一区二区| 精品国产乱码久久久久久牛牛| 亚洲一区二区三区在线看| 99精品视频一区二区三区| 久久久国产一区二区三区四区小说| 免费欧美在线视频| 日韩欧美色电影| 免费的成人av| 日韩一卡二卡三卡四卡| 亚洲成a人在线观看| 欧美三级在线播放| 怡红院av一区二区三区| 色婷婷av一区二区三区大白胸| 亚洲国产激情av| 成人黄色免费短视频| 国产婷婷色一区二区三区在线| 韩国精品在线观看| 久久你懂得1024| 国产一区二区免费视频| 国产日韩欧美综合一区| 国产91在线|亚洲| 亚洲欧洲精品一区二区三区 | 亚洲日本在线天堂| 97久久超碰国产精品电影| 亚洲欧美电影一区二区| 日本乱码高清不卡字幕| 一区二区三区 在线观看视频| 一本大道综合伊人精品热热| 中文字幕亚洲一区二区va在线| 91在线视频18| 午夜视频在线观看一区二区 | 国产综合成人久久大片91| 久久亚区不卡日本| 大桥未久av一区二区三区中文| 最新热久久免费视频| 91久久香蕉国产日韩欧美9色| 性做久久久久久免费观看欧美| 欧美日韩国产欧美日美国产精品| 日本午夜精品视频在线观看| 日韩精品一区二区三区在线播放 | 国产精品天天摸av网| 91女神在线视频| 石原莉奈在线亚洲二区| 精品美女被调教视频大全网站| 懂色av一区二区三区免费观看| 亚洲精品一二三四区| 88在线观看91蜜桃国自产| 精品一区二区三区在线观看 | 欧美一区二区女人| 成人高清视频在线| 日本aⅴ免费视频一区二区三区| 国产欧美精品区一区二区三区 | 欧美精品一二三| 国产一区二区女| 视频一区视频二区中文| 日韩久久一区二区| 久久尤物电影视频在线观看| 91黄色免费版| 岛国av在线一区| 免费在线看一区| 亚洲一区二区三区爽爽爽爽爽| 久久精品网站免费观看| 在线中文字幕一区| 国产91精品在线观看| 日韩福利电影在线观看| 亚洲码国产岛国毛片在线| 精品av久久707| 欧美日本一区二区三区四区| 国产高清在线精品| 美女视频网站久久| 亚洲午夜精品在线| 国产精品麻豆网站| 精品国产三级电影在线观看| 91高清在线观看| 97久久超碰精品国产| 高清日韩电视剧大全免费| 麻豆一区二区在线| 奇米在线7777在线精品| 亚洲精品免费电影| 亚洲品质自拍视频| 中文字幕一区在线| 中文在线一区二区| 欧美极品xxx| 国产欧美一区二区精品性色超碰| 精品久久久影院| 精品国产成人在线影院| 欧美变态tickle挠乳网站| 欧美日韩一区二区三区高清 | 国产乱码字幕精品高清av| 日韩福利电影在线| 青青国产91久久久久久| 午夜精品久久久久久| 亚洲午夜成aⅴ人片| 亚洲一区二区三区爽爽爽爽爽 | 成人性视频网站| 成人免费视频视频在线观看免费| 国产精品亚洲а∨天堂免在线| 国精产品一区一区三区mba桃花| 另类欧美日韩国产在线| 美日韩一区二区三区| 麻豆成人免费电影| 国产一区二区精品久久99| 精品一区二区三区在线观看国产| 国精品**一区二区三区在线蜜桃 | 亚洲黄一区二区三区| 一区二区三区日韩精品视频| 夜夜揉揉日日人人青青一国产精品 | 日韩欧美国产一区二区在线播放 | 一区二区三区电影在线播| 一区二区三区在线免费视频| 一区二区国产视频| 奇米一区二区三区av| 精品一区二区三区日韩| 国产成人h网站| 色综合天天狠狠| 91精品国产麻豆| 欧美激情一区三区| 亚洲永久免费av| 麻豆精品久久久| 成人黄动漫网站免费app| 色综合久久中文字幕综合网| 欧美日韩极品在线观看一区| 精品久久久久久综合日本欧美| 国产农村妇女毛片精品久久麻豆 | 欧美一区二区三区小说| 精品成人免费观看| 1024国产精品| 免费精品视频最新在线| 成人h动漫精品| 555www色欧美视频| 中国色在线观看另类| 午夜影视日本亚洲欧洲精品| 久久9热精品视频| 91玉足脚交白嫩脚丫在线播放| 欧美精品在欧美一区二区少妇| 国产精品色哟哟| 另类小说综合欧美亚洲| 91成人免费网站| 国产精品久久久久三级| 久久av中文字幕片|