当前位置: 首页>>代码示例>>C#>>正文


C# SrcList类代码示例

本文整理汇总了C#中SrcList的典型用法代码示例。如果您正苦于以下问题:C# SrcList类的具体用法?C# SrcList怎么用?C# SrcList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SrcList类属于命名空间,在下文中一共展示了SrcList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: sqlite3SelectNew

 static Select sqlite3SelectNew(
 Parse pParse,        /* Parsing context */
 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;
   sqlite3 db = pParse.db;
   pNew = new Select();//sqlite3DbMallocZero(db, sizeof(*pNew) );
   Debug.Assert( //db.mallocFailed != 0 ||
   null == pOffset || pLimit != null ); /* OFFSET implies LIMIT */
   //if( pNew==null   ){
   //  pNew = standin;
   //  memset(pNew, 0, sizeof(*pNew));
   //}
   if ( pEList == null )
   {
     pEList = sqlite3ExprListAppend( pParse, null, sqlite3Expr( db, TK_ALL, null ) );
   }
   pNew.pEList = pEList;
   pNew.pSrc = pSrc;
   pNew.pWhere = pWhere;
   pNew.pGroupBy = pGroupBy;
   pNew.pHaving = pHaving;
   pNew.pOrderBy = pOrderBy;
   pNew.selFlags = (u16)( isDistinct != 0 ? SF_Distinct : 0 );
   pNew.op = TK_SELECT;
   pNew.pLimit = pLimit;
   pNew.pOffset = pOffset;
   Debug.Assert( pOffset == null || pLimit != null );
   pNew.addrOpenEphm[0] = -1;
   pNew.addrOpenEphm[1] = -1;
   pNew.addrOpenEphm[2] = -1;
   //if ( db.mallocFailed != 0 )
   //{
   //  clearSelect( db, pNew );
   //  //if ( pNew != standin ) sqlite3DbFree( db, ref pNew );
   //  pNew = null;
   //}
   return pNew;
 }
开发者ID:CryptoManiac,项目名称:csharpsqlite,代码行数:49,代码来源:select_c.cs

示例2: AuthRead

        private void AuthRead(Expr Expr, Schema Schema, SrcList TabList)
        {
            //sqlite3 *db = pParse->db;
            //Table *pTab = 0;      /* The table being read */
            //const char *zCol;     /* Name of the column of the table */
            //int iSrc;             /* Index in pTabList->a[] of table being read */
            //int iDb;              /* The index of the database the expression refers to */
            //int iCol;             /* Index of column in table */

            //if( db->xAuth==0 ) return;
            //iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
            //if( iDb<0 ){
            //  /* An attempt to read a column out of a subquery or other
            //  ** temporary table. */
            //  return;
            //}

            //assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
            //if( pExpr->op==TK_TRIGGER ){
            //  pTab = pParse->pTriggerTab;
            //}else{
            //  assert( pTabList );
            //  for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){
            //    if( pExpr->iTable==pTabList->a[iSrc].iCursor ){
            //      pTab = pTabList->a[iSrc].pTab;
            //      break;
            //    }
            //  }
            //}
            //iCol = pExpr->iColumn;
            //if( NEVER(pTab==0) ) return;

            //if( iCol>=0 ){
            //  assert( iCol<pTab->nCol );
            //  zCol = pTab->aCol[iCol].zName;
            //}else if( pTab->iPKey>=0 ){
            //  assert( pTab->iPKey<pTab->nCol );
            //  zCol = pTab->aCol[pTab->iPKey].zName;
            //}else{
            //  zCol = "ROWID";
            //}
            //assert( iDb>=0 && iDb<db->nDb );
            //if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){
            //  pExpr->op = TK_NULL;
            //}
        }
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:46,代码来源:Parse+Auth.cs

示例3: sqlite3SrcListLookup

    /*
    ** 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
    ** in order to generate code for DELETE FROM statements.
    *************************************************************************
    **  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
    **  C#-SQLite is an independent reimplementation of the SQLite software library
    **
    **  SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
    **
    *************************************************************************
    */
    //#include "sqliteInt.h"

    /*
    ** Look up every table that is named in pSrc.  If any table is not found,
    ** add an error message to pParse.zErrMsg and return NULL.  If all tables
    ** are found, return a pointer to the last table.
    */
    static Table sqlite3SrcListLookup( Parse pParse, SrcList pSrc )
    {
      SrcList_item pItem = pSrc.a[0];
      Table pTab;
      Debug.Assert( pItem != null && pSrc.nSrc == 1 );
      pTab = sqlite3LocateTable( pParse, 0, pItem.zName, pItem.zDatabase );
      sqlite3DeleteTable( pParse.db, ref pItem.pTab );
      pItem.pTab = pTab;
      if ( pTab != null )
      {
        pTab.nRef++;
      }
      if ( sqlite3IndexedByLookup( pParse, pItem ) != 0 )
      {
        pTab = null;
      }
      return pTab;
    }
开发者ID:pragmat1c,项目名称:coolstorage,代码行数:46,代码来源:delete_c.cs

示例4: New

 public static Select New(Parse parse, ExprList list, SrcList src, Expr where_, ExprList groupBy, Expr having, ExprList orderBy, SF selFlags, Expr limit, Expr offset)
 {
     Context ctx = parse.Ctx;
     Select newSelect = new Select();
     Debug.Assert(ctx.MallocFailed || offset == null || limit != null); // OFFSET implies LIMIT
     // Select standin;
     if (newSelect == null)
     {
         Debug.Assert(ctx.MallocFailed);
         //newSelect = standin;
         //_memset(newSelect, 0, sizeof(newSelect));
     }
     if (list == null)
         list = Expr.ListAppend(parse, null, Expr.Expr_(ctx, TK.ALL, null));
     newSelect.EList = list;
     if (src == null) src = new SrcList();
     newSelect.Src = src;
     newSelect.Where = where_;
     newSelect.GroupBy = groupBy;
     newSelect.Having = having;
     newSelect.OrderBy = orderBy;
     newSelect.SelFlags = selFlags;
     newSelect.OP = TK.SELECT;
     newSelect.Limit = limit;
     newSelect.Offset = offset;
     Debug.Assert(offset == null || limit != null);
     newSelect.AddrOpenEphms[0] = (OP) - 1;
     newSelect.AddrOpenEphms[1] = (OP) - 1;
     newSelect.AddrOpenEphms[2] = (OP) - 1;
     if (ctx.MallocFailed)
     {
         ClearSelect(ctx, newSelect);
         //if (newSelect != standin) C._tagfree(ctx, ref newSelect);
         newSelect = null;
     }
     else
         Debug.Assert(newSelect.Src != null || parse.Errs > 0);
     //Debug.Assert(newSelect != standin);
     return newSelect;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:40,代码来源:Select.cs

示例5: generateColumnNames

    /*
    ** Generate code that will tell the VDBE the names of columns
    ** in the result set.  This information is used to provide the
    ** azCol[] values in the callback.
    */
    static void generateColumnNames(
    Parse pParse,      /* Parser context */
    SrcList pTabList,  /* List of tables */
    ExprList pEList    /* Expressions defining the result set */
    )
    {
      Vdbe v = pParse.pVdbe;
      int i, j;
      sqlite3 db = pParse.db;
      bool fullNames;
      bool shortNames;

#if !SQLITE_OMIT_EXPLAIN
      /* If this is an EXPLAIN, skip this step */
      if ( pParse.explain != 0 )
      {
        return;
      }
#endif

      if ( pParse.colNamesSet != 0 || NEVER( v == null ) /*|| db.mallocFailed != 0 */ )
        return;
      pParse.colNamesSet = 1;
      fullNames = ( db.flags & SQLITE_FullColNames ) != 0;
      shortNames = ( db.flags & SQLITE_ShortColNames ) != 0;
      sqlite3VdbeSetNumCols( v, pEList.nExpr );
      for ( i = 0; i < pEList.nExpr; i++ )
      {
        Expr p;
        p = pEList.a[i].pExpr;
        if ( NEVER( p == null ) )
          continue;
        if ( pEList.a[i].zName != null )
        {
          string zName = pEList.a[i].zName;
          sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT );
        }
        else if ( ( p.op == TK_COLUMN || p.op == TK_AGG_COLUMN ) && pTabList != null )
        {
          Table pTab;
          string zCol;
          int iCol = p.iColumn;
          for ( j = 0; ALWAYS( j < pTabList.nSrc ); j++ )
          {
            if ( pTabList.a[j].iCursor == p.iTable )
              break;
          }
          Debug.Assert( j < pTabList.nSrc );
          pTab = pTabList.a[j].pTab;
          if ( iCol < 0 )
            iCol = pTab.iPKey;
          Debug.Assert( iCol == -1 || ( iCol >= 0 && iCol < pTab.nCol ) );
          if ( iCol < 0 )
          {
            zCol = "rowid";
          }
          else
          {
            zCol = pTab.aCol[iCol].zName;
          }
          if ( !shortNames && !fullNames )
          {
            sqlite3VdbeSetColName( v, i, COLNAME_NAME,
            pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC);
          }
          else if ( fullNames )
          {
            string zName;
            zName = sqlite3MPrintf( db, "%s.%s", pTab.zName, zCol );
            sqlite3VdbeSetColName( v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC );
          }
          else
          {
            sqlite3VdbeSetColName( v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT );
          }
        }
        else
        {
          sqlite3VdbeSetColName( v, i, COLNAME_NAME,
          pEList.a[i].zSpan, SQLITE_DYNAMIC );//sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC);
        }
      }
      generateColumnTypes( pParse, pTabList, pEList );
    }
开发者ID:CryptoManiac,项目名称:csharpsqlite,代码行数:89,代码来源:select_c.cs

示例6: sqlite3AlterRenameTable

/*
** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
** command.
*/
static void sqlite3AlterRenameTable(
Parse pParse,             /* Parser context. */
SrcList pSrc,             /* The table to rename. */
Token pName               /* The new table name. */
)
{
  int iDb;                  /* Database that contains the table */
  string zDb;               /* Name of database iDb */
  Table pTab;               /* Table being renamed */
  string zName = null;      /* NULL-terminated version of pName */
  sqlite3 db = pParse.db;   /* Database connection */
  int nTabName;             /* Number of UTF-8 characters in zTabName */
  string zTabName;          /* Original name of the table */
  Vdbe v;
#if !SQLITE_OMIT_TRIGGER
  string zWhere = "";       /* Where clause to locate temp triggers */
#endif
  VTable pVTab = null;      /* Non-zero if this is a v-tab with an xRename() */
  int savedDbFlags;         /* Saved value of db->flags */

  savedDbFlags = db.flags;

  //if ( NEVER( db.mallocFailed != 0 ) ) goto exit_rename_table;
  Debug.Assert( pSrc.nSrc == 1 );
  Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) );
  pTab = sqlite3LocateTable( pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase );
  if ( pTab == null )
    goto exit_rename_table;
  iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema );
  zDb = db.aDb[iDb].zName;
  db.flags |= SQLITE_PreferBuiltin;

  /* Get a NULL terminated version of the new table name. */
  zName = sqlite3NameFromToken( db, pName );
  if ( zName == null )
    goto exit_rename_table;

  /* Check that a table or index named 'zName' does not already exist
  ** in database iDb. If so, this is an error.
  */
  if ( sqlite3FindTable( db, zName, zDb ) != null || sqlite3FindIndex( db, zName, zDb ) != null )
  {
    sqlite3ErrorMsg( pParse,
    "there is already another table or index with this name: %s", zName );
    goto exit_rename_table;
  }

  /* Make sure it is not a system table being altered, or a reserved name
  ** that the table is being renamed to.
  */
  if ( SQLITE_OK!=isSystemTable(pParse, pTab.zName) )
  {
    goto exit_rename_table;
  }
  if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) )
  {
    goto exit_rename_table;
  }

#if !SQLITE_OMIT_VIEW
  if ( pTab.pSelect != null )
  {
    sqlite3ErrorMsg( pParse, "view %s may not be altered", pTab.zName );
    goto exit_rename_table;
  }
#endif

#if !SQLITE_OMIT_AUTHORIZATION
/* Invoke the authorization callback. */
if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab.zName, 0) ){
goto exit_rename_table;
}
#endif

  if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 )
  {
    goto exit_rename_table;
  }
#if !SQLITE_OMIT_VIRTUALTABLE
  if ( IsVirtual( pTab ) )
  {
    pVTab = sqlite3GetVTable( db, pTab );
    if ( pVTab.pVtab.pModule.xRename == null )
    {
      pVTab = null;
    }
  }
#endif
  /* Begin a transaction and code the VerifyCookie for database iDb.
** Then modify the schema cookie (since the ALTER TABLE modifies the
** schema). Open a statement transaction if the table is a virtual
** table.
*/
  v = sqlite3GetVdbe( pParse );
  if ( v == null )
  {
//.........这里部分代码省略.........
开发者ID:z0rg1nc,项目名称:CsharpSqliteFork,代码行数:101,代码来源:alter_c.cs

示例7: generateColumnTypes

    /*
    ** Generate code that will tell the VDBE the declaration types of columns
    ** in the result set.
    */
    static void generateColumnTypes(
    Parse pParse,      /* Parser context */
    SrcList pTabList,  /* List of tables */
    ExprList pEList    /* Expressions defining the result set */
    )
    {
#if !SQLITE_OMIT_DECLTYPE
      Vdbe v = pParse.pVdbe;
      int i;
      NameContext sNC = new NameContext();
      sNC.pSrcList = pTabList;
      sNC.pParse = pParse;
      for ( i = 0; i < pEList.nExpr; i++ )
      {
        Expr p = pEList.a[i].pExpr;
        string zType;
#if SQLITE_ENABLE_COLUMN_METADATA
        string zOrigDb = null;
        string zOrigTab = null;
        string zOrigCol = null;
        zType = columnType( sNC, p, ref zOrigDb, ref zOrigTab, ref zOrigCol );

        /* The vdbe must make its own copy of the column-type and other
        ** column specific strings, in case the schema is reset before this
        ** virtual machine is deleted.
        */
        sqlite3VdbeSetColName( v, i, COLNAME_DATABASE, zOrigDb, SQLITE_TRANSIENT );
        sqlite3VdbeSetColName( v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT );
        sqlite3VdbeSetColName( v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT );
#else
        string sDummy = null;
        zType = columnType( sNC, p, ref sDummy, ref sDummy, ref sDummy );
#endif
        sqlite3VdbeSetColName( v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT );
      }
#endif //* SQLITE_OMIT_DECLTYPE */
    }
开发者ID:CryptoManiac,项目名称:csharpsqlite,代码行数:41,代码来源:select_c.cs

示例8: sqlite3DropTrigger

    /*
    ** This function is called to drop a trigger from the database schema.
    **
    ** This may be called directly from the parser and therefore identifies
    ** the trigger by name.  The sqlite3DropTriggerPtr() routine does the
    ** same job as this routine except it takes a pointer to the trigger
    ** instead of the trigger name.
    **/
    static void sqlite3DropTrigger( Parse pParse, SrcList pName, int noErr )
    {
      Trigger pTrigger = null;
      int i;
      string zDb;
      string zName;
      int nName;
      sqlite3 db = pParse.db;

      //      if ( db.mallocFailed != 0 ) goto drop_trigger_cleanup;
      if ( SQLITE_OK != sqlite3ReadSchema( pParse ) )
      {
        goto drop_trigger_cleanup;
      }

      Debug.Assert( pName.nSrc == 1 );
      zDb = pName.a[0].zDatabase;
      zName = pName.a[0].zName;
      nName = sqlite3Strlen30( zName );
      Debug.Assert( zDb != null || sqlite3BtreeHoldsAllMutexes( db ) );
      for ( i = OMIT_TEMPDB; i < db.nDb; i++ )
      {
        int j = ( i < 2 ) ? i ^ 1 : i;  /* Search TEMP before MAIN */
        if ( zDb != null && !db.aDb[j].zName.Equals( zDb ,StringComparison.InvariantCultureIgnoreCase )  )
          continue;
        Debug.Assert( sqlite3SchemaMutexHeld( db, j, null ) );
        pTrigger = sqlite3HashFind( ( db.aDb[j].pSchema.trigHash ), zName, nName, (Trigger)null );
        if ( pTrigger != null )
          break;
      }
      if ( pTrigger == null )
      {
        if ( noErr == 0 )
        {
          sqlite3ErrorMsg( pParse, "no such trigger: %S", pName, 0 );
        }
        else
        {
          sqlite3CodeVerifyNamedSchema( pParse, zDb );
        }
        pParse.checkSchema = 1;
        goto drop_trigger_cleanup;
      }
      sqlite3DropTriggerPtr( pParse, pTrigger );

drop_trigger_cleanup:
      sqlite3SrcListDelete( db, ref pName );
    }
开发者ID:z0rg1nc,项目名称:CsharpSqliteFork,代码行数:56,代码来源:trigger_c.cs

示例9: sqlite3Update

    /*
    ** Process an UPDATE statement.
    **
    **   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
    **          \_______/ \________/     \______/       \________________/
    *            onError   pTabList      pChanges             pWhere
    */
    static void sqlite3Update(
    Parse pParse,         /* The parser context */
    SrcList pTabList,     /* The table in which we should change things */
    ExprList pChanges,    /* Things to be changed */
    Expr pWhere,          /* The WHERE clause.  May be null */
    int onError           /* How to handle constraint errors */
    )
    {
      int i, j;                   /* Loop counters */
      Table pTab;                 /* The table to be updated */
      int addr = 0;               /* VDBE instruction address of the start of the loop */
      WhereInfo pWInfo;           /* Information about the WHERE clause */
      Vdbe v;                     /* The virtual database engine */
      Index pIdx;                 /* For looping over indices */
      int nIdx;                   /* Number of indices that need updating */
      int iCur;                   /* VDBE Cursor number of pTab */
      sqlite3 db;                 /* The database structure */
      int[] aRegIdx = null;       /* One register assigned to each index to be updated */
      int[] aXRef = null;         /* aXRef[i] is the index in pChanges.a[] of the
** an expression for the i-th column of the table.
** aXRef[i]==-1 if the i-th column is not changed. */
      bool chngRowid;             /* True if the record number is being changed */
      Expr pRowidExpr = null;     /* Expression defining the new record number */
      bool openAll = false;       /* True if all indices need to be opened */
      AuthContext sContext;       /* The authorization context */
      NameContext sNC;            /* The name-context to resolve expressions in */
      int iDb;                    /* Database containing the table being updated */
      int j1;                     /* Addresses of jump instructions */
      u8 okOnePass;               /* True for one-pass algorithm without the FIFO */

#if !SQLITE_OMIT_TRIGGER
      bool isView = false;         /* Trying to update a view */
      Trigger pTrigger;            /* List of triggers on pTab, if required */
#endif
      int iBeginAfterTrigger = 0;  /* Address of after trigger program */
      int iEndAfterTrigger = 0;    /* Exit of after trigger program */
      int iBeginBeforeTrigger = 0; /* Address of before trigger program */
      int iEndBeforeTrigger = 0;   /* Exit of before trigger program */
      u32 old_col_mask = 0;        /* Mask of OLD.* columns in use */
      u32 new_col_mask = 0;        /* Mask of NEW.* columns in use */

      int newIdx = -1;             /* index of trigger "new" temp table       */
      int oldIdx = -1;             /* index of trigger "old" temp table       */

      /* Register Allocations */
      int regRowCount = 0;         /* A count of rows changed */
      int regOldRowid;             /* The old rowid */
      int regNewRowid;             /* The new rowid */
      int regData;                 /* New data for the row */
      int regRowSet = 0;           /* Rowset of rows to be updated */

      sContext = new AuthContext(); //memset( &sContext, 0, sizeof( sContext ) );
      db = pParse.db;
      if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ )
      {
        goto update_cleanup;
      }
      Debug.Assert( pTabList.nSrc == 1 );

      /* Locate the table which we want to update.
      */
      pTab = sqlite3SrcListLookup( pParse, pTabList );
      if ( pTab == null ) goto update_cleanup;
      iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema );

      /* Figure out if we have any triggers and if the table being
      ** updated is a view
      */
#if !SQLITE_OMIT_TRIGGER
      int iDummy = 0;
      pTrigger = sqlite3TriggersExist( pParse, pTab, TK_UPDATE, pChanges, ref iDummy );
      isView = pTab.pSelect != null;
#else
const Trigger pTrigger = null;
#if !SQLITE_OMIT_VIEW
const bool isView = false;
#endif
#endif
#if SQLITE_OMIT_VIEW
//    # undef isView
const bool isView = false;
#endif

      if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 )
      {
        goto update_cleanup;
      }
      if ( sqlite3IsReadOnly( pParse, pTab, ( pTrigger != null ? 1 : 0 ) ) )
      {
        goto update_cleanup;
      }
      aXRef = new int[pTab.nCol];// sqlite3DbMallocRaw(db, sizeof(int) * pTab.nCol);
      //if ( aXRef == null ) goto update_cleanup;
//.........这里部分代码省略.........
开发者ID:mbahar94,项目名称:fracture,代码行数:101,代码来源:update_c.cs

示例10: sqlite3Select

    static int sqlite3Select(
    Parse pParse,         /* The parser context */
    Select p,             /* The SELECT statement being coded. */
    ref SelectDest pDest /* What to do with the query results */
    )
    {
      int i, j;               /* Loop counters */
      WhereInfo pWInfo;       /* Return from sqlite3WhereBegin() */
      Vdbe v;                 /* The virtual machine under construction */
      bool isAgg;             /* True for select lists like "count()" */
      ExprList pEList = new ExprList();      /* List of columns to extract. */
      SrcList pTabList = new SrcList();     /* List of tables to select from */
      Expr pWhere;            /* The WHERE clause.  May be NULL */
      ExprList pOrderBy;      /* The ORDER BY clause.  May be NULL */
      ExprList pGroupBy;      /* The GROUP BY clause.  May be NULL */
      Expr pHaving;           /* The HAVING clause.  May be NULL */
      bool isDistinct;        /* True if the DISTINCT keyword is present */
      int distinct;           /* Table to use for the distinct set */
      int rc = 1;             /* Value to return from this function */
      int addrSortIndex;      /* Address of an OP_OpenEphemeral instruction */
      AggInfo sAggInfo;       /* Information used by aggregate queries */
      int iEnd;               /* Address of the end of the query */
      sqlite3 db;             /* The database connection */

#if !SQLITE_OMIT_EXPLAIN
      int iRestoreSelectId = pParse.iSelectId;
      pParse.iSelectId = pParse.iNextSelectId++;
#endif

      db = pParse.db;
      if ( p == null /*|| db.mallocFailed != 0 */ || pParse.nErr != 0 )
      {
        return 1;
      }
#if !SQLITE_OMIT_AUTHORIZATION
if (sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0)) return 1;
#endif
      sAggInfo = new AggInfo();// memset(sAggInfo, 0, sAggInfo).Length;

      if ( pDest.eDest <= SRT_Discard ) //IgnorableOrderby(pDest))
      {
        Debug.Assert( pDest.eDest == SRT_Exists || pDest.eDest == SRT_Union ||
        pDest.eDest == SRT_Except || pDest.eDest == SRT_Discard );
        /* If ORDER BY makes no difference in the output then neither does
        ** DISTINCT so it can be removed too. */
        sqlite3ExprListDelete( db, ref p.pOrderBy );
        p.pOrderBy = null;
        p.selFlags = (u16)( p.selFlags & ~SF_Distinct );
      }
      sqlite3SelectPrep( pParse, p, null );
      pOrderBy = p.pOrderBy;
      pTabList = p.pSrc;
      pEList = p.pEList;
      if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ )
      {
        goto select_end;
      }
      isAgg = ( p.selFlags & SF_Aggregate ) != 0;
      Debug.Assert( pEList != null );

      /* Begin generating code.
      */
      v = sqlite3GetVdbe( pParse );
      if ( v == null )
        goto select_end;

      /* If writing to memory or generating a set
      ** only a single column may be output.
      */
#if !SQLITE_OMIT_SUBQUERY
      if ( checkForMultiColumnSelectError( pParse, pDest, pEList.nExpr ) )
      {
        goto select_end;
      }
#endif

      /* Generate code for all sub-queries in the FROM clause
*/
#if !SQLITE_OMIT_SUBQUERY || !SQLITE_OMIT_VIEW
      for ( i = 0; p.pPrior == null && i < pTabList.nSrc; i++ )
      {
        SrcList_item pItem = pTabList.a[i];
        SelectDest dest = new SelectDest();
        Select pSub = pItem.pSelect;
        bool isAggSub;

        if ( pSub == null || pItem.isPopulated != 0 )
          continue;

        /* Increment Parse.nHeight by the height of the largest expression
        ** tree refered to by this, the parent select. The child select
        ** may contain expression trees of at most
        ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit
        ** more conservative than necessary, but much easier than enforcing
        ** an exact limit.
        */
        pParse.nHeight += sqlite3SelectExprHeight( p );

        /* Check to see if the subquery can be absorbed into the parent. */
        isAggSub = ( pSub.selFlags & SF_Aggregate ) != 0;
//.........这里部分代码省略.........
开发者ID:CryptoManiac,项目名称:csharpsqlite,代码行数:101,代码来源:select_c.cs

示例11: sqlite3Insert

 static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, Select pSelect, IdList pColumn, int onError )
 {
   sqlite3Insert( pParse, pTabList, null, pSelect, pColumn, onError );
 }
开发者ID:Gillardo,项目名称:Cordova-SQLitePlugin,代码行数:4,代码来源:insert_c.cs

示例12: sqlite3SrcListDup

    /*
    ** If cursors, triggers, views and subqueries are all omitted from
    ** the build, then none of the following routines, except for
    ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes
    ** called with a NULL argument.
    */
#if !SQLITE_OMIT_VIEW || !SQLITE_OMIT_TRIGGER  || !SQLITE_OMIT_SUBQUERY
    static SrcList sqlite3SrcListDup( sqlite3 db, SrcList p, int flags )
    {
      SrcList pNew;
      int i;
      int nByte;
      if ( p == null )
        return null;
      //nByte = sizeof(*p) + (p.nSrc>0 ? sizeof(p.a[0]) * (p.nSrc-1) : 0);
      pNew = new SrcList();//sqlite3DbMallocRaw(db, nByte );
      if ( p.nSrc > 0 )
        pNew.a = new SrcList_item[p.nSrc];
      if ( pNew == null )
        return null;
      pNew.nSrc = pNew.nAlloc = p.nSrc;
      for ( i = 0; i < p.nSrc; i++ )
      {
        pNew.a[i] = new SrcList_item();
        SrcList_item pNewItem = pNew.a[i];
        SrcList_item pOldItem = p.a[i];
        Table pTab;
        pNewItem.zDatabase = pOldItem.zDatabase;// sqlite3DbStrDup(db, pOldItem.zDatabase);
        pNewItem.zName = pOldItem.zName;// sqlite3DbStrDup(db, pOldItem.zName);
        pNewItem.zAlias = pOldItem.zAlias;// sqlite3DbStrDup(db, pOldItem.zAlias);
        pNewItem.jointype = pOldItem.jointype;
        pNewItem.iCursor = pOldItem.iCursor;
        pNewItem.isPopulated = pOldItem.isPopulated;
        pNewItem.zIndex = pOldItem.zIndex;// sqlite3DbStrDup( db, pOldItem.zIndex );
        pNewItem.notIndexed = pOldItem.notIndexed;
        pNewItem.pIndex = pOldItem.pIndex;
        pTab = pNewItem.pTab = pOldItem.pTab;
        if ( pTab != null )
        {
          pTab.nRef++;
        }
        pNewItem.pSelect = sqlite3SelectDup( db, pOldItem.pSelect, flags );
        pNewItem.pOn = sqlite3ExprDup( db, pOldItem.pOn, flags );
        pNewItem.pUsing = sqlite3IdListDup( db, pOldItem.pUsing );
        pNewItem.colUsed = pOldItem.colUsed;
      }
      return pNew;
    }
开发者ID:laboratoryyingong,项目名称:BARLESS,代码行数:48,代码来源:expr_c.cs

示例13: TableAndColumnIndex

 static bool TableAndColumnIndex(SrcList src, int n, string colName, ref int tableOut, ref int colIdOut)
 {
     for (int i = 0; i < n; i++)
     {
         int colId = ColumnIndex(src.Ids[i].Table, colName); // Index of column matching zCol
         if (colId >= 0)
         {
             tableOut = i;
             colIdOut = colId;
             return true;
         }
     }
     return false;
 }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:14,代码来源:Select.cs

示例14: sqlite3DeleteFrom

        /*
        ** Generate code for a DELETE FROM statement.
        **
        **     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;
        **                 \________/       \________________/
        **                  pTabList              pWhere
        */
        static void sqlite3DeleteFrom(
            Parse pParse,          /* The parser context */
            SrcList pTabList,      /* The table from which we should delete things */
            Expr pWhere            /* The WHERE clause.  May be null */
            )
        {
            Vdbe v;                /* The virtual database engine */
              Table pTab;            /* The table from which records will be deleted */
              string zDb;            /* Name of database holding pTab */
              int end, addr = 0;     /* A couple addresses of generated code */
              int i;                 /* Loop counter */
              WhereInfo pWInfo;      /* Information about the WHERE clause */
              Index pIdx;            /* For looping over indices of the table */
              int iCur;              /* VDBE VdbeCursor number for pTab */
              sqlite3 db;            /* Main database structure */
              AuthContext sContext;  /* Authorization context */
              NameContext sNC;       /* Name context to resolve expressions in */
              int iDb;               /* Database number */
              int memCnt = -1;        /* Memory cell used for change counting */
              int rcauth;            /* Value returned by authorization callback */

            #if !SQLITE_OMIT_TRIGGER
              bool isView;                 /* True if attempting to delete from a view */
              Trigger pTrigger;            /* List of table triggers, if required */
            #endif
              sContext = new AuthContext();//memset(&sContext, 0, sizeof(sContext));

              db = pParse.db;
              if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ )
              {
            goto delete_from_cleanup;
              }
              Debug.Assert( pTabList.nSrc == 1 );

              /* Locate the table which we want to delete.  This table has to be
              ** put in an SrcList structure because some of the subroutines we
              ** will be calling are designed to work with multiple tables and expect
              ** an SrcList* parameter instead of just a Table* parameter.
              */
              pTab = sqlite3SrcListLookup( pParse, pTabList );
              if ( pTab == null )
            goto delete_from_cleanup;

              /* Figure out if we have any triggers and if the table being
              ** deleted from is a view
              */
            #if !SQLITE_OMIT_TRIGGER
              int iDummy = 0;
              pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, ref iDummy );
              isView = pTab.pSelect != null;
            #else
              const Trigger pTrigger = null;
              bool isView = false;
            #endif
            #if SQLITE_OMIT_VIEW
            //# undef isView
            isView = false;
            #endif

              /* If pTab is really a view, make sure it has been initialized.
            */
              if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 )
              {
            goto delete_from_cleanup;
              }

              if ( sqlite3IsReadOnly( pParse, pTab, ( pTrigger != null ? 1 : 0 ) ) )
              {
            goto delete_from_cleanup;
              }
              iDb = sqlite3SchemaToIndex( db, pTab.pSchema );
              Debug.Assert( iDb < db.nDb );
              zDb = db.aDb[iDb].zName;
            #if !SQLITE_OMIT_AUTHORIZATION
            rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);
            #else
              rcauth = SQLITE_OK;
            #endif
              Debug.Assert( rcauth == SQLITE_OK || rcauth == SQLITE_DENY || rcauth == SQLITE_IGNORE );
              if ( rcauth == SQLITE_DENY )
              {
            goto delete_from_cleanup;
              }
              Debug.Assert( !isView || pTrigger != null );

              /* Assign  cursor number to the table and all its indices.
              */
              Debug.Assert( pTabList.nSrc == 1 );
              iCur = pTabList.a[0].iCursor = pParse.nTab++;
              for ( pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext )
              {
            pParse.nTab++;
              }
//.........这里部分代码省略.........
开发者ID:taxilian,项目名称:some_library,代码行数:101,代码来源:delete_c.cs

示例15: sqlite3LimitWhere

        /*
        ** Generate an expression tree to implement the WHERE, ORDER BY,
        ** and LIMIT/OFFSET portion of DELETE and UPDATE statements.
        **
        **     DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;
        **                            \__________________________/
        **                               pLimitWhere (pInClause)
        */
        Expr sqlite3LimitWhere(
            Parse pParse,               /* The parser context */
            SrcList pSrc,               /* the FROM clause -- which tables to scan */
            Expr pWhere,                /* The WHERE clause.  May be null */
            ExprList pOrderBy,          /* The ORDER BY clause.  May be null */
            Expr pLimit,                /* The LIMIT clause.  May be null */
            Expr pOffset,               /* The OFFSET clause.  May be null */
            char zStmtType              /* Either DELETE or UPDATE.  For error messages. */
            )
        {
            Expr pWhereRowid = null;    /* WHERE rowid .. */
            Expr pInClause = null;      /* WHERE rowid IN ( select ) */
            Expr pSelectRowid = null;   /* SELECT rowid ... */
            ExprList pEList = null;     /* Expression list contaning only pSelectRowid */
            SrcList pSelectSrc = null;  /* SELECT rowid FROM x ... (dup of pSrc) */
            Select pSelect = null;      /* Complete SELECT tree */

            /* Check that there isn't an ORDER BY without a LIMIT clause.
            */
            if( pOrderBy!=null && (pLimit == null) ) {
            sqlite3ErrorMsg(pParse, "ORDER BY without LIMIT on %s", zStmtType);
            pParse.parseError = 1;
            goto limit_where_cleanup_2;
            }

            /* We only need to generate a select expression if there
            ** is a limit/offset term to enforce.
            */
            if ( pLimit == null )
            {
            /* if pLimit is null, pOffset will always be null as well. */
            Debug.Assert( pOffset == null );
            return pWhere;
            }

            /* Generate a select expression tree to enforce the limit/offset
            ** term for the DELETE or UPDATE statement.  For example:
            **   DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1
            ** becomes:
            **   DELETE FROM table_a WHERE rowid IN (
            **     SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1
            **   );
            */

            pSelectRowid = sqlite3PExpr( pParse, TK_ROW, null, null, null );
            if( pSelectRowid == null ) goto limit_where_cleanup_2;
            pEList = sqlite3ExprListAppend( pParse, null, pSelectRowid);
            if( pEList == null ) goto limit_where_cleanup_2;

            /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree
            ** and the SELECT subtree. */
            pSelectSrc = sqlite3SrcListDup(pParse.db, pSrc,0);
            if( pSelectSrc == null ) {
            sqlite3ExprListDelete(pParse.db, pEList);
            goto limit_where_cleanup_2;
            }

            /* generate the SELECT expression tree. */
            pSelect = sqlite3SelectNew( pParse, pEList, pSelectSrc, pWhere, null, null,
            pOrderBy, 0, pLimit, pOffset );
            if( pSelect == null ) return null;

            /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */
            pWhereRowid = sqlite3PExpr( pParse, TK_ROW, null, null, null );
            if( pWhereRowid == null ) goto limit_where_cleanup_1;
            pInClause = sqlite3PExpr( pParse, TK_IN, pWhereRowid, null, null );
            if( pInClause == null ) goto limit_where_cleanup_1;

            pInClause->x.pSelect = pSelect;
            pInClause->flags |= EP_xIsSelect;
            sqlite3ExprSetHeight(pParse, pInClause);
            return pInClause;

            /* something went wrong. clean up anything allocated. */
            limit_where_cleanup_1:
            sqlite3SelectDelete(pParse.db, pSelect);
            return null;

            limit_where_cleanup_2:
            sqlite3ExprDelete(pParse.db, ref pWhere);
            sqlite3ExprListDelete(pParse.db, pOrderBy);
            sqlite3ExprDelete(pParse.db, ref pLimit);
            sqlite3ExprDelete(pParse.db, ref pOffset);
            return null;
        }
开发者ID:taxilian,项目名称:some_library,代码行数:93,代码来源:delete_c.cs


注:本文中的SrcList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。