您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sqlite3AuthCheck函数代码示例

51自学网 2021-06-03 08:13:17
  C++
这篇教程C++ sqlite3AuthCheck函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了sqlite3AuthCheck函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: analyzeOneTable

/*** Generate code to do an analysis of all indices associated with** a single table.*/static void analyzeOneTable(  Parse *pParse,   /* Parser context */  Table *pTab,     /* Table whose indices are to be analyzed */  Index *pOnlyIdx, /* If not NULL, only analyze this one index */  int iStatCur,    /* Index of VdbeCursor that writes the sqlite_stat1 table */  int iMem         /* Available memory locations begin here */){  sqlite3 *db = pParse->db;    /* Database handle */  Index *pIdx;                 /* An index to being analyzed */  int iIdxCur;                 /* Cursor open on index being analyzed */  Vdbe *v;                     /* The virtual machine being built up */  int i;                       /* Loop counter */  int topOfLoop;               /* The top of the loop */  int endOfLoop;               /* The end of the loop */  int jZeroRows = -1;          /* Jump from here if number of rows is zero */  int iDb;                     /* Index of database containing pTab */  int regTabname = iMem++;     /* Register containing table name */  int regIdxname = iMem++;     /* Register containing index name */  int regSampleno = iMem++;    /* Register containing next sample number */  int regCol = iMem++;         /* Content of a column analyzed table */  int regRec = iMem++;         /* Register holding completed record */  int regTemp = iMem++;        /* Temporary use register */  int regRowid = iMem++;       /* Rowid for the inserted record */#ifdef SQLITE_ENABLE_STAT2  int addr = 0;                /* Instruction address */  int regTemp2 = iMem++;       /* Temporary use register */  int regSamplerecno = iMem++; /* Index of next sample to record */  int regRecno = iMem++;       /* Current sample index */  int regLast = iMem++;        /* Index of last sample to record */  int regFirst = iMem++;       /* Index of first sample to record */#endif  v = sqlite3GetVdbe(pParse);  if( v==0 || NEVER(pTab==0) ){    return;  }  if( pTab->tnum==0 ){    /* Do not gather statistics on views or virtual tables */    return;  }  if( memcmp(pTab->zName, "sqlite_", 7)==0 ){    /* Do not gather statistics on system tables */    return;  }  assert( sqlite3BtreeHoldsAllMutexes(db) );  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb>=0 );  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );#ifndef SQLITE_OMIT_AUTHORIZATION  if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,      db->aDb[iDb].zName ) ){    return;  }#endif  /* Establish a read-lock on the table at the shared-cache level. */  sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);  iIdxCur = pParse->nTab++;  sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0);  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){    int nCol;    KeyInfo *pKey;    if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;    nCol = pIdx->nColumn;    pKey = sqlite3IndexKeyinfo(pParse, pIdx);    if( iMem+1+(nCol*2)>pParse->nMem ){      pParse->nMem = iMem+1+(nCol*2);    }    /* Open a cursor to the index to be analyzed. */    assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );    sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb,        (char *)pKey, P4_KEYINFO_HANDOFF);    VdbeComment((v, "%s", pIdx->zName));    /* Populate the register containing the index name. */    sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0);#ifdef SQLITE_ENABLE_STAT2    /* If this iteration of the loop is generating code to analyze the    ** first index in the pTab->pIndex list, then register regLast has    ** not been populated. In this case populate it now.  */    if( pTab->pIndex==pIdx ){      sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regSamplerecno);      sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2-1, regTemp);      sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2, regTemp2);      sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regLast);      sqlite3VdbeAddOp2(v, OP_Null, 0, regFirst);      addr = sqlite3VdbeAddOp3(v, OP_Lt, regSamplerecno, 0, regLast);      sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regFirst);      sqlite3VdbeAddOp3(v, OP_Multiply, regLast, regTemp, regLast);//.........这里部分代码省略.........
开发者ID:sunyangkobe,项目名称:db_research,代码行数:101,


示例2: sqlite3Update

//.........这里部分代码省略.........  /* Resolve the column names in all the expressions of the  ** of the UPDATE statement.  Also find the column index  ** for each column to be updated in the pChanges array.  For each  ** column to be updated, make sure we have authorization to change  ** that column.  */  chngRecno = 0;  for(i=0; i<pChanges->nExpr; i++){    if( sqlite3ExprResolveNames(&sNC, pChanges->a[i].pExpr) ){      goto update_cleanup;    }    for(j=0; j<pTab->nCol; j++){      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){        if( j==pTab->iPKey ){          chngRecno = 1;          pRecnoExpr = pChanges->a[i].pExpr;        }        aXRef[j] = i;        break;      }    }    if( j>=pTab->nCol ){      if( sqlite3IsRowid(pChanges->a[i].zName) ){        chngRecno = 1;        pRecnoExpr = pChanges->a[i].pExpr;      }else{        sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);        goto update_cleanup;      }    }#ifndef SQLITE_OMIT_AUTHORIZATION    {      int rc;      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,                           pTab->aCol[j].zName, db->aDb[pTab->iDb].zName);      if( rc==SQLITE_DENY ){        goto update_cleanup;      }else if( rc==SQLITE_IGNORE ){        aXRef[j] = -1;      }    }#endif  }  /* Allocate memory for the array apIdx[] and fill it with pointers to every  ** index that needs to be updated.  Indices only need updating if their  ** key includes one of the columns named in pChanges or if the record  ** number of the original table entry is changing.  */  for(nIdx=nIdxTotal=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdxTotal++){    if( chngRecno ){      i = 0;    }else {      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ) break;      }    }    if( i<pIdx->nColumn ) nIdx++;  }  if( nIdxTotal>0 ){    apIdx = sqliteMallocRaw( sizeof(Index*) * nIdx + nIdxTotal );    if( apIdx==0 ) goto update_cleanup;    aIdxUsed = (char*)&apIdx[nIdx];  }  for(nIdx=j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    if( chngRecno ){
开发者ID:BackupTheBerlios,项目名称:kslovar-svn,代码行数:67,


示例3: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */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 */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  int nTabName;             /* Number of UTF-8 characters in zTabName */  const char *zTabName;     /* Original name of the table */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif  int isVirtualRename = 0;  /* True if this is a v-table with an xRename() */    if( db->mallocFailed ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  pTab = sqlite3LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(db, pName);  if( !zName ) 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) || sqlite3FindIndex(db, zName, zDb) ){    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( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto exit_rename_table;  }#ifndef SQLITE_OMIT_VIEW  if( pTab->pSelect ){    sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_VIRTUALTABLE  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto exit_rename_table;  }  if( IsVirtual(pTab) && pTab->pMod->pModule->xRename ){    isVirtualRename = 1;  }#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==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, isVirtualRename, iDb);  sqlite3ChangeCookie(pParse, iDb);  /* If this is a virtual table, invoke the xRename() function if  ** one is defined. The xRename() callback will modify the names  ** of any resources used by the v-table implementation (including other  ** SQLite tables) that are identified by the name of the virtual table.  */#ifndef SQLITE_OMIT_VIRTUALTABLE  if( isVirtualRename ){    int i = ++pParse->nMem;    sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0);    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pTab->pVtab, P4_VTAB);//.........这里部分代码省略.........
开发者ID:oddstr,项目名称:bathyscaphe-mirror,代码行数:101,


示例4: codeAttach

/*** This procedure generates VDBE code for a single invocation of either the** sqlite_detach() or sqlite_attach() SQL user functions.*/static void codeAttach(  Parse *pParse,       /* The parser context */  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */  const char *zFunc,   /* Either "sqlite_attach" or "sqlite_detach */  int nFunc,           /* Number of args to pass to zFunc */  Expr *pAuthArg,      /* Expression to pass to authorization callback */  Expr *pFilename,     /* Name of database file */  Expr *pDbname,       /* Name of the database to use internally */  Expr *pKey           /* Database key for encryption extension */){  int rc;  NameContext sName;  Vdbe *v;  FuncDef *pFunc;  sqlite3* db = pParse->db;#ifndef SQLITE_OMIT_AUTHORIZATION  assert( sqlite3ThreadDataReadOnly()->mallocFailed || pAuthArg );  if( pAuthArg ){    char *zAuthArg = sqlite3NameFromToken(&pAuthArg->span);    if( !zAuthArg ){      goto attach_end;    }    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);    sqliteFree(zAuthArg);    if(rc!=SQLITE_OK ){      goto attach_end;    }  }#endif /* SQLITE_OMIT_AUTHORIZATION */  memset(&sName, 0, sizeof(NameContext));  sName.pParse = pParse;  if(       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))  ){    pParse->nErr++;    goto attach_end;  }  v = sqlite3GetVdbe(pParse);  sqlite3ExprCode(pParse, pFilename);  sqlite3ExprCode(pParse, pDbname);  sqlite3ExprCode(pParse, pKey);  assert(v || sqlite3ThreadDataReadOnly()->mallocFailed);  if( v ){    sqlite3VdbeAddOp(v, OP_Function, 0, nFunc);    pFunc = sqlite3FindFunction(db, zFunc, strlen(zFunc), nFunc, SQLITE_UTF8,0);    sqlite3VdbeChangeP3(v, -1, (char *)pFunc, P3_FUNCDEF);    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this    ** statement only). For DETACH, set it to false (expire all existing    ** statements).    */    sqlite3VdbeAddOp(v, OP_Expire, (type==SQLITE_ATTACH), 0);  }  attach_end:  sqlite3ExprDelete(pFilename);  sqlite3ExprDelete(pDbname);  sqlite3ExprDelete(pKey);}
开发者ID:MagicalTux,项目名称:nezumi,代码行数:70,


示例5: sqlite3DeleteFrom

/*** Generate code for a DELETE FROM statement.****     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;**                 /________/       /________________/**                  pTabList              pWhere*/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 */  const char *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 Cursor 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 */#ifndef SQLITE_OMIT_TRIGGER  int isView;                  /* True if attempting to delete from a view */  Trigger *pTrigger;           /* List of table triggers, if required */#endif  memset(&sContext, 0, sizeof(sContext));  db = pParse->db;  if( pParse->nErr || db->mallocFailed ){    goto delete_from_cleanup;  }  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==0 )  goto delete_from_cleanup;  /* Figure out if we have any triggers and if the table being  ** deleted from is a view  */#ifndef SQLITE_OMIT_TRIGGER  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);  isView = pTab->pSelect!=0;#else# define pTrigger 0# define isView 0#endif#ifdef SQLITE_OMIT_VIEW# undef isView# define isView 0#endif  /* If pTab is really a view, make sure it has been initialized.  */  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto delete_from_cleanup;  }  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){    goto delete_from_cleanup;  }  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb<db->nDb );  zDb = db->aDb[iDb].zName;  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );  if( rcauth==SQLITE_DENY ){    goto delete_from_cleanup;  }  assert(!isView || pTrigger);  /* Assign  cursor number to the table and all its indices.  */  assert( pTabList->nSrc==1 );  iCur = pTabList->a[0].iCursor = pParse->nTab++;  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){    pParse->nTab++;  }  /* Start the view context  */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }  /* Begin generating code.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto delete_from_cleanup;//.........这里部分代码省略.........
开发者ID:Mars-Wu,项目名称:djyos,代码行数:101,


示例6: sqlite3BeginTrigger

//.........这里部分代码省略.........  if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName) &&       sqlite3FixSrcList(&sFix, pTableName) ){    goto trigger_cleanup;  }  pTab = sqlite3SrcListLookup(pParse, pTableName);  if( !pTab ){    /* The table does not exist. */    goto trigger_cleanup;  }  if( IsVirtual(pTab) ){    sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables");    goto trigger_cleanup;  }  /* Check that the trigger name is not reserved and that no trigger of the  ** specified name exists */  zName = sqlite3NameFromToken(db, pName);  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto trigger_cleanup;  }  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,strlen(zName)) ){    if( !noErr ){      sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);    }    goto trigger_cleanup;  }  /* Do not create a trigger on a system table */  if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){    sqlite3ErrorMsg(pParse, "cannot create trigger on system table");    pParse->nErr++;    goto trigger_cleanup;  }  /* INSTEAD of triggers are only for views and views only support INSTEAD  ** of triggers.  */  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){    sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",         (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);    goto trigger_cleanup;  }  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){    sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"        " trigger on table: %S", pTableName, 0);    goto trigger_cleanup;  }  iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);#ifndef SQLITE_OMIT_AUTHORIZATION  {    int code = SQLITE_CREATE_TRIGGER;    const char *zDb = db->aDb[iTabDb].zName;    const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;    if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){      goto trigger_cleanup;    }    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){      goto trigger_cleanup;    }  }#endif  /* INSTEAD OF triggers can only appear on views and BEFORE triggers  ** cannot appear on views.  So we might as well translate every  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code  ** elsewhere.  */  if (tr_tm == TK_INSTEAD){    tr_tm = TK_BEFORE;  }  /* Build the Trigger object */  pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));  if( pTrigger==0 ) goto trigger_cleanup;  pTrigger->name = zName;  zName = 0;  pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);  pTrigger->pSchema = db->aDb[iDb].pSchema;  pTrigger->pTabSchema = pTab->pSchema;  pTrigger->op = op;  pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;  pTrigger->pWhen = sqlite3ExprDup(db, pWhen);  pTrigger->pColumns = sqlite3IdListDup(db, pColumns);  sqlite3TokenCopy(db, &pTrigger->nameToken,pName);  assert( pParse->pNewTrigger==0 );  pParse->pNewTrigger = pTrigger;trigger_cleanup:  sqlite3_free(zName);  sqlite3SrcListDelete(pTableName);  sqlite3IdListDelete(pColumns);  sqlite3ExprDelete(pWhen);  if( !pParse->pNewTrigger ){    sqlite3DeleteTrigger(pTrigger);  }else{    assert( pParse->pNewTrigger==pTrigger );  }}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:101,


示例7: codeAttach

/*** This procedure generates VDBE code for a single invocation of either the** sqlite_detach() or sqlite_attach() SQL user functions.*/static void codeAttach(  Parse *pParse,       /* The parser context */  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */  Expr *pAuthArg,      /* Expression to pass to authorization callback */  Expr *pFilename,     /* Name of database file */  Expr *pDbname,       /* Name of the database to use internally */  Expr *pKey           /* Database key for encryption extension */){  int rc;  NameContext sName;  Vdbe *v;  sqlite3* db = pParse->db;  int regArgs;  memset(&sName, 0, sizeof(NameContext));  sName.pParse = pParse;  if(       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))  ){    goto attach_end;  }#ifndef SQLITE_OMIT_AUTHORIZATION  if( pAuthArg ){    char *zAuthArg;    if( pAuthArg->op==TK_STRING ){      zAuthArg = pAuthArg->u.zToken;    }else{      zAuthArg = 0;    }    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);    if(rc!=SQLITE_OK ){      goto attach_end;    }  }#endif /* SQLITE_OMIT_AUTHORIZATION */  v = sqlite3GetVdbe(pParse);  regArgs = sqlite3GetTempRange(pParse, 4);  sqlite3ExprCode(pParse, pFilename, regArgs);  sqlite3ExprCode(pParse, pDbname, regArgs+1);  sqlite3ExprCode(pParse, pKey, regArgs+2);  assert( v || db->mallocFailed );  if( v ){    sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3,                      (char *)pFunc, P4_FUNCDEF);    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));     /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this    ** statement only). For DETACH, set it to false (expire all existing    ** statements).    */    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));  }  attach_end:  sqlite3ExprDelete(db, pFilename);  sqlite3ExprDelete(db, pDbname);  sqlite3ExprDelete(db, pKey);}
开发者ID:yongningfu,项目名称:sqlite,代码行数:71,


示例8: codeAttach

static void codeAttach(  Parse *pParse,         int type,              FuncDef const *pFunc,  Expr *pAuthArg,        Expr *pFilename,       Expr *pDbname,         Expr *pKey           ){  int rc;  NameContext sName;  Vdbe *v;  sqlite3* db = pParse->db;  int regArgs;  memset(&sName, 0, sizeof(NameContext));  sName.pParse = pParse;  if(       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))  ){    pParse->nErr++;    goto attach_end;  }#ifndef SQLITE_OMIT_AUTHORIZATION  if( pAuthArg ){    char *zAuthArg;    if( pAuthArg->op==TK_STRING ){      zAuthArg = pAuthArg->u.zToken;    }else{      zAuthArg = 0;    }    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);    if(rc!=SQLITE_OK ){      goto attach_end;    }  }#endif   v = sqlite3GetVdbe(pParse);  regArgs = sqlite3GetTempRange(pParse, 4);  sqlite3ExprCode(pParse, pFilename, regArgs);  sqlite3ExprCode(pParse, pDbname, regArgs+1);  sqlite3ExprCode(pParse, pKey, regArgs+2);  assert( v || db->mallocFailed );  if( v ){    sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3);    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));    sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF);    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));  }  attach_end:  sqlite3ExprDelete(db, pFilename);  sqlite3ExprDelete(db, pDbname);  sqlite3ExprDelete(db, pKey);}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:64,


示例9: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */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 */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif    if( sqlite3MallocFailed() ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(pName);  if( !zName ) 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) || sqlite3FindIndex(db, zName, zDb) ){    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( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto exit_rename_table;  }#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif  /* Begin a transaction and code the VerifyCookie for database iDb.   ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema).  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, 0, iDb);  sqlite3ChangeCookie(db, v, iDb);  /* Modify the sqlite_master table to use the new table name. */  sqlite3NestedParse(pParse,      "UPDATE %Q.%s SET "#ifdef SQLITE_OMIT_TRIGGER          "sql = sqlite_rename_table(sql, %Q), "#else          "sql = CASE "            "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"            "ELSE sqlite_rename_table(sql, %Q) END, "#endif          "tbl_name = %Q, "          "name = CASE "            "WHEN type='table' THEN %Q "            "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "              "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) "            "ELSE name END "      "WHERE tbl_name=%Q AND "          "(type='table' OR type='index' OR type='trigger');",       zDb, SCHEMA_TABLE(iDb), zName, zName, zName, #ifndef SQLITE_OMIT_TRIGGER      zName,#endif      zName, strlen(pTab->zName), pTab->zName  );#ifndef SQLITE_OMIT_AUTOINCREMENT  /* If the sqlite_sequence table exists in this database, then update   ** it with the new table name.  */  if( sqlite3FindTable(db, "sqlite_sequence", zDb) ){    sqlite3NestedParse(pParse,//.........这里部分代码省略.........
开发者ID:DrEastex,项目名称:Platinum,代码行数:101,


示例10: resolveExprStep

//.........这里部分代码省略.........      notValidPartIdxWhere(pParse, pNC, "functions");      zId = pExpr->u.zToken;      nId = sqlite3Strlen30(zId);      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);      if( pDef==0 ){        pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);        if( pDef==0 ){          no_such_func = 1;        }else{          wrong_num_args = 1;        }      }else{        is_agg = pDef->xFunc==0;        if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){          ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);          if( n==2 ){            pExpr->iTable = exprProbability(pList->a[1].pExpr);            if( pExpr->iTable<0 ){              sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "                                      "constant between 0.0 and 1.0");              pNC->nErr++;            }          }else{            /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to            ** likelihood(X, 0.0625).            ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for            ** likelihood(X,0.0625). */            pExpr->iTable = 62;  /* TUNING:  Default 2nd arg to unlikely() is 0.0625 */          }                     }      }#ifndef SQLITE_OMIT_AUTHORIZATION      if( pDef ){        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);        if( auth!=SQLITE_OK ){          if( auth==SQLITE_DENY ){            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",                                    pDef->zName);            pNC->nErr++;          }          pExpr->op = TK_NULL;          return WRC_Prune;        }        if( pDef->funcFlags & SQLITE_FUNC_CONSTANT ) ExprSetProperty(pExpr,EP_Constant);      }#endif      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);        pNC->nErr++;        is_agg = 0;      }else if( no_such_func && pParse->db->init.busy==0 ){        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);        pNC->nErr++;      }else if( wrong_num_args ){        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",             nId, zId);        pNC->nErr++;      }      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;      sqlite3WalkExprList(pWalker, pList);      if( is_agg ){        NameContext *pNC2 = pNC;        pExpr->op = TK_AGG_FUNCTION;        pExpr->op2 = 0;        while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){          pExpr->op2++;
开发者ID:Oceanwings,项目名称:sqlcipher,代码行数:67,


示例11: sqlite3Update

//.........这里部分代码省略.........  /* Resolve the column names in all the expressions of the  ** of the UPDATE statement.  Also find the column index  ** for each column to be updated in the pChanges array.  For each  ** column to be updated, make sure we have authorization to change  ** that column.  */  chngRowid = 0;  for(i=0; i<pChanges->nExpr; i++){    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){      goto update_cleanup;    }    for(j=0; j<pTab->nCol; j++){      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){        if( j==pTab->iPKey ){          chngRowid = 1;          pRowidExpr = pChanges->a[i].pExpr;        }        aXRef[j] = i;        break;      }    }    if( j>=pTab->nCol ){      if( sqlite3IsRowid(pChanges->a[i].zName) ){        chngRowid = 1;        pRowidExpr = pChanges->a[i].pExpr;      }else{        sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);        goto update_cleanup;      }    }#ifndef SQLITE_OMIT_AUTHORIZATION    {      int rc;      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,                           pTab->aCol[j].zName, db->aDb[iDb].zName);      if( rc==SQLITE_DENY ){        goto update_cleanup;      }else if( rc==SQLITE_IGNORE ){        aXRef[j] = -1;      }    }#endif  }  /* Allocate memory for the array aRegIdx[].  There is one entry in the  ** array for each index associated with table being updated.  Fill in  ** the value with a register number for indices that are to be used  ** and with zero for unused indices.  */  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}  if( nIdx>0 ){    aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );    if( aRegIdx==0 ) goto update_cleanup;  }  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngRowid ){      reg = ++pParse->nMem;    }else{      reg = 0;      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ){          reg = ++pParse->nMem;          break;        }      }
开发者ID:DoganA,项目名称:nightingale-deps,代码行数:67,


示例12: sqlite3DeleteFrom

/*** Generate code for a DELETE FROM statement.****     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;**                 /________/       /________________/**                  pTabList              pWhere*/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 */  const char *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 Cursor number for pTab */  sqlite3 *db;           /* Main database structure */  AuthContext sContext;  /* Authorization context */  int oldIdx = -1;       /* Cursor for the OLD table of AFTER triggers */  NameContext sNC;       /* Name context to resolve expressions in */  int iDb;               /* Database number */  int memCnt = 0;        /* Memory cell used for change counting */#ifndef SQLITE_OMIT_TRIGGER  int isView;                  /* True if attempting to delete from a view */  int triggers_exist = 0;      /* True if any triggers exist */#endif  sContext.pParse = 0;  db = pParse->db;  if( pParse->nErr || db->mallocFailed ){    goto delete_from_cleanup;  }  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==0 )  goto delete_from_cleanup;  /* Figure out if we have any triggers and if the table being  ** deleted from is a view  */#ifndef SQLITE_OMIT_TRIGGER  triggers_exist = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0);  isView = pTab->pSelect!=0;#else# define triggers_exist 0# define isView 0#endif#ifdef SQLITE_OMIT_VIEW# undef isView# define isView 0#endif  if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){    goto delete_from_cleanup;  }  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb<db->nDb );  zDb = db->aDb[iDb].zName;  if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){    goto delete_from_cleanup;  }  /* If pTab is really a view, make sure it has been initialized.  */  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto delete_from_cleanup;  }  /* Allocate a cursor used to store the old.* data for a trigger.  */  if( triggers_exist ){     oldIdx = pParse->nTab++;  }  /* Resolve the column names in the WHERE clause.  */  assert( pTabList->nSrc==1 );  iCur = pTabList->a[0].iCursor = pParse->nTab++;  memset(&sNC, 0, sizeof(sNC));  sNC.pParse = pParse;  sNC.pSrcList = pTabList;  if( sqlite3ExprResolveNames(&sNC, pWhere) ){    goto delete_from_cleanup;  }  /* Start the view context  */  if( isView ){    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);  }//.........这里部分代码省略.........
开发者ID:Nephyrin,项目名称:-furry-octo-nemesis,代码行数:101,


示例13: resolveExprStep

/*** This routine is callback for sqlite3WalkExpr().**** Resolve symbolic names into TK_COLUMN operators for the current** node in the expression tree.  Return 0 to continue the search down** the tree or 2 to abort the tree walk.**** This routine also does error checking and name resolution for** function names.  The operator for aggregate functions is changed** to TK_AGG_FUNCTION.*/static int resolveExprStep(Walker *pWalker, Expr *pExpr){  NameContext *pNC;  Parse *pParse;  pNC = pWalker->u.pNC;  assert( pNC!=0 );  pParse = pNC->pParse;  assert( pParse==pWalker->pParse );  if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;  ExprSetProperty(pExpr, EP_Resolved);#ifndef NDEBUG  if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){    SrcList *pSrcList = pNC->pSrcList;    int i;    for(i=0; i<pNC->pSrcList->nSrc; i++){      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);    }  }#endif  switch( pExpr->op ){    /* A lone identifier is the name of a column.    */    case TK_ID: {      lookupName(pParse, 0, 0, &pExpr->token, pNC, pExpr);      return WRC_Prune;    }      /* A table name and column name:     ID.ID    ** Or a database, table and column:  ID.ID.ID    */    case TK_DOT: {      Token *pColumn;      Token *pTable;      Token *pDb;      Expr *pRight;      /* if( pSrcList==0 ) break; */      pRight = pExpr->pRight;      if( pRight->op==TK_ID ){        pDb = 0;        pTable = &pExpr->pLeft->token;        pColumn = &pRight->token;      }else{        assert( pRight->op==TK_DOT );        pDb = &pExpr->pLeft->token;        pTable = &pRight->pLeft->token;        pColumn = &pRight->pRight->token;      }      lookupName(pParse, pDb, pTable, pColumn, pNC, pExpr);      return WRC_Prune;    }    /* Resolve function names    */    case TK_CONST_FUNC:    case TK_FUNCTION: {      ExprList *pList = pExpr->pList;    /* The argument list */      int n = pList ? pList->nExpr : 0;  /* Number of arguments */      int no_such_func = 0;       /* True if no such function exists */      int wrong_num_args = 0;     /* True if wrong number of arguments */      int is_agg = 0;             /* True if is an aggregate function */      int auth;                   /* Authorization to use the function */      int nId;                    /* Number of characters in function name */      const char *zId;            /* The function name. */      FuncDef *pDef;              /* Information about the function */      int enc = ENC(pParse->db);  /* The database encoding */      zId = (char*)pExpr->token.z;      nId = pExpr->token.n;      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);      if( pDef==0 ){        pDef = sqlite3FindFunction(pParse->db, zId, nId, -1, enc, 0);        if( pDef==0 ){          no_such_func = 1;        }else{          wrong_num_args = 1;        }      }else{        is_agg = pDef->xFunc==0;      }#ifndef SQLITE_OMIT_AUTHORIZATION      if( pDef ){        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);        if( auth!=SQLITE_OK ){          if( auth==SQLITE_DENY ){            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",                                    pDef->zName);            pNC->nErr++;//.........这里部分代码省略.........
开发者ID:shenjian74,项目名称:Bitcoin-History,代码行数:101,


示例14: analyzeOneTable

/*** Generate code to do an analysis of all indices associated with** a single table.*/static void analyzeOneTable(  Parse *pParse,   /* Parser context */  Table *pTab,     /* Table whose indices are to be analyzed */  int iStatCur,    /* Cursor that writes to the sqlite_stat1 table */  int iMem         /* Available memory locations begin here */){  Index *pIdx;     /* An index to being analyzed */  int iIdxCur;     /* Cursor number for index being analyzed */  int nCol;        /* Number of columns in the index */  Vdbe *v;         /* The virtual machine being built up */  int i;           /* Loop counter */  int topOfLoop;   /* The top of the loop */  int endOfLoop;   /* The end of the loop */  int addr;        /* The address of an instruction */  int iDb;         /* Index of database containing pTab */  v = sqlite3GetVdbe(pParse);  if( v==0 || pTab==0 || pTab->pIndex==0 ){    /* Do no analysis for tables that have no indices */    return;  }  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  assert( iDb>=0 );#ifndef SQLITE_OMIT_AUTHORIZATION  if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,      pParse->db->aDb[iDb].zName ) ){    return;  }#endif  /* Establish a read-lock on the table at the shared-cache level. */  sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);  iIdxCur = pParse->nTab;  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){    KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);    /* Open a cursor to the index to be analyzed    */    assert( iDb==sqlite3SchemaToIndex(pParse->db, pIdx->pSchema) );    sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);    VdbeComment((v, "# %s", pIdx->zName));    sqlite3VdbeOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum,        (char *)pKey, P3_KEYINFO_HANDOFF);    nCol = pIdx->nColumn;    if( iMem+nCol*2>=pParse->nMem ){      pParse->nMem = iMem+nCol*2+1;    }    sqlite3VdbeAddOp(v, OP_SetNumColumns, iIdxCur, nCol+1);    /* Memory cells are used as follows:    **    **    mem[iMem]:             The total number of rows in the table.    **    mem[iMem+1]:           Number of distinct values in column 1    **    ...    **    mem[iMem+nCol]:        Number of distinct values in column N    **    mem[iMem+nCol+1]       Last observed value of column 1    **    ...    **    mem[iMem+nCol+nCol]:   Last observed value of column N    **    ** Cells iMem through iMem+nCol are initialized to 0.  The others    ** are initialized to NULL.    */    for(i=0; i<=nCol; i++){      sqlite3VdbeAddOp(v, OP_MemInt, 0, iMem+i);    }    for(i=0; i<nCol; i++){      sqlite3VdbeAddOp(v, OP_MemNull, iMem+nCol+i+1, 0);    }    /* Do the analysis.    */    endOfLoop = sqlite3VdbeMakeLabel(v);    sqlite3VdbeAddOp(v, OP_Rewind, iIdxCur, endOfLoop);    topOfLoop = sqlite3VdbeCurrentAddr(v);    sqlite3VdbeAddOp(v, OP_MemIncr, 1, iMem);    for(i=0; i<nCol; i++){      sqlite3VdbeAddOp(v, OP_Column, iIdxCur, i);      sqlite3VdbeAddOp(v, OP_MemLoad, iMem+nCol+i+1, 0);      sqlite3VdbeAddOp(v, OP_Ne, 0x100, 0);    }    sqlite3VdbeAddOp(v, OP_Goto, 0, endOfLoop);    for(i=0; i<nCol; i++){      addr = sqlite3VdbeAddOp(v, OP_MemIncr, 1, iMem+i+1);      sqlite3VdbeChangeP2(v, topOfLoop + 3*i + 3, addr);      sqlite3VdbeAddOp(v, OP_Column, iIdxCur, i);      sqlite3VdbeAddOp(v, OP_MemStore, iMem+nCol+i+1, 1);    }    sqlite3VdbeResolveLabel(v, endOfLoop);    sqlite3VdbeAddOp(v, OP_Next, iIdxCur, topOfLoop);    sqlite3VdbeAddOp(v, OP_Close, iIdxCur, 0);    /* Store the results.      **    ** The result is a single row of the sqlite_stat1 table.  The first//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:Reclass-2015,代码行数:101,


示例15: sqlite3Update

//.........这里部分代码省略.........    memset(&sNC, 0, sizeof(sNC));  sNC.pParse = pParse;  sNC.pSrcList = pTabList;  chngRowid = 0;  for(i=0; i<pChanges->nExpr; i++){    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){      goto update_cleanup;    }    for(j=0; j<pTab->nCol; j++){      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){        if( j==pTab->iPKey ){          chngRowid = 1;          pRowidExpr = pChanges->a[i].pExpr;        }        aXRef[j] = i;        break;      }    }    if( j>=pTab->nCol ){      if( sqlite3IsRowid(pChanges->a[i].zName) ){        chngRowid = 1;        pRowidExpr = pChanges->a[i].pExpr;      }else{        sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);        pParse->checkSchema = 1;        goto update_cleanup;      }    }#ifndef SQLITE_OMIT_AUTHORIZATION    {      int rc;      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,                           pTab->aCol[j].zName, db->aDb[iDb].zName);      if( rc==SQLITE_DENY ){        goto update_cleanup;      }else if( rc==SQLITE_IGNORE ){        aXRef[j] = -1;      }    }#endif  }  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}  if( nIdx>0 ){    aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );    if( aRegIdx==0 ) goto update_cleanup;  }  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngRowid ){      reg = ++pParse->nMem;    }else{      reg = 0;      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ){          reg = ++pParse->nMem;          break;        }      }    }    aRegIdx[j] = reg;  }
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:67,


示例16: sqlite3DeleteFrom

/*** Process a DELETE FROM statement.*/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 */    const char *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 Cursor number for pTab */    sqlite *db;            /* Main database structure */    int isView;            /* True if attempting to delete from a view */    AuthContext sContext;  /* Authorization context */    int row_triggers_exist = 0;  /* True if any triggers exist */    int before_triggers;         /* True if there are BEFORE triggers */    int after_triggers;          /* True if there are AFTER triggers */    int oldIdx = -1;             /* Cursor for the OLD table of AFTER triggers */    sContext.pParse = 0;    if( pParse->nErr || sqlite3_malloc_failed ) {        pTabList = 0;        goto delete_from_cleanup;    }    db = pParse->db;    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==0 )  goto delete_from_cleanup;    before_triggers = sqlite3TriggersExist(pParse, pTab->pTrigger,                                           TK_DELETE, TK_BEFORE, TK_ROW, 0);    after_triggers = sqlite3TriggersExist(pParse, pTab->pTrigger,                                          TK_DELETE, TK_AFTER, TK_ROW, 0);    row_triggers_exist = before_triggers || after_triggers;    isView = pTab->pSelect!=0;    if( sqlite3IsReadOnly(pParse, pTab, before_triggers) ) {        goto delete_from_cleanup;    }    assert( pTab->iDb<db->nDb );    zDb = db->aDb[pTab->iDb].zName;    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ) {        goto delete_from_cleanup;    }    /* If pTab is really a view, make sure it has been initialized.    */    if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ) {        goto delete_from_cleanup;    }    /* Allocate a cursor used to store the old.* data for a trigger.    */    if( row_triggers_exist ) {        oldIdx = pParse->nTab++;    }    /* Resolve the column names in all the expressions.    */    assert( pTabList->nSrc==1 );    iCur = pTabList->a[0].iCursor = pParse->nTab++;    if( pWhere ) {        if( sqlite3ExprResolveIds(pParse, pTabList, 0, pWhere) ) {            goto delete_from_cleanup;        }        if( sqlite3ExprCheck(pParse, pWhere, 0, 0) ) {            goto delete_from_cleanup;        }    }    /* Start the view context    */    if( isView ) {        sqlite3AuthContextPush(pParse, &sContext, pTab->zName);    }    /* Begin generating code.    */    v = sqlite3GetVdbe(pParse);    if( v==0 ) {        goto delete_from_cleanup;    }    sqlite3VdbeCountChanges(v);    sqlite3BeginWriteOperation(pParse, row_triggers_exist, pTab->iDb);    /* If we are trying to delete from a view, construct that view into    ** a temporary table.    */    if( isView ) {        Select *pView = sqlite3SelectDup(pTab->pSelect);//.........这里部分代码省略.........
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:101,


示例17: resolveExprStep

//.........这里部分代码省略.........    /* Resolve function names    */    case TK_CONST_FUNC:    case TK_FUNCTION: {      ExprList *pList = pExpr->x.pList;    /* The argument list */      int n = pList ? pList->nExpr : 0;    /* Number of arguments */      int no_such_func = 0;       /* True if no such function exists */      int wrong_num_args = 0;     /* True if wrong number of arguments */      int is_agg = 0;             /* True if is an aggregate function */      int auth;                   /* Authorization to use the function */      int nId;                    /* Number of characters in function name */      const char *zId;            /* The function name. */      FuncDef *pDef;              /* Information about the function */      u8 enc = ENC(pParse->db);   /* The database encoding */      testcase( pExpr->op==TK_CONST_FUNC );      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );      zId = pExpr->u.zToken;      nId = sqlite3Strlen30(zId);      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);      if( pDef==0 ){        pDef = sqlite3FindFunction(pParse->db, zId, nId, -1, enc, 0);        if( pDef==0 ){          no_such_func = 1;        }else{          wrong_num_args = 1;        }      }else{        is_agg = pDef->xFunc==0;      }#ifndef SQLITE_OMIT_AUTHORIZATION      if( pDef ){        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);        if( auth!=SQLITE_OK ){          if( auth==SQLITE_DENY ){            sqlite3ErrorMsg(pParse, "not authorized to use function: %s",                                    pDef->zName);            pNC->nErr++;          }          pExpr->op = TK_NULL;          return WRC_Prune;        }      }#endif      if( is_agg && !pNC->allowAgg ){        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);        pNC->nErr++;        is_agg = 0;      }else if( no_such_func ){        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);        pNC->nErr++;      }else if( wrong_num_args ){        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",             nId, zId);        pNC->nErr++;      }      if( is_agg ){        pExpr->op = TK_AGG_FUNCTION;        pNC->hasAgg = 1;      }      if( is_agg ) pNC->allowAgg = 0;      sqlite3WalkExprList(pWalker, pList);      if( is_agg ) pNC->allowAgg = 1;      /* FIX ME:  Compute pExpr->affinity based on the expected return      ** type of the function 
开发者ID:Wushaowei001,项目名称:omnibus,代码行数:67,


示例18: sqlite3Attach

/*** This routine is called by the parser to process an ATTACH statement:****     ATTACH DATABASE filename AS dbname**** The pFilename and pDbname arguments are the tokens that define the** filename and dbname in the ATTACH statement.*/void sqlite3Attach(  Parse *pParse,       /* The parser context */  Token *pFilename,    /* Name of database file */  Token *pDbname,      /* Name of the database to use internally */  int keyType,         /* 0: no key.  1: TEXT,  2: BLOB */  Token *pKey          /* Text of the key for keytype 1 and 2 */){  Db *aNew;  int rc, i;  char *zFile, *zName;  sqlite3 *db;  Vdbe *v;  v = sqlite3GetVdbe(pParse);  if( !v ) return;  sqlite3VdbeAddOp(v, OP_Halt, 0, 0);  if( pParse->explain ) return;  db = pParse->db;  if( db->nDb>=MAX_ATTACHED+2 ){    sqlite3ErrorMsg(pParse, "too many attached databases - max %d",        MAX_ATTACHED);    pParse->rc = SQLITE_ERROR;    return;  }  if( !db->autoCommit ){    sqlite3ErrorMsg(pParse, "cannot ATTACH database within transaction");    pParse->rc = SQLITE_ERROR;    return;  }  zFile = sqlite3NameFromToken(pFilename);;  if( zFile==0 ) return;#ifndef SQLITE_OMIT_AUTHORIZATION  if( sqlite3AuthCheck(pParse, SQLITE_ATTACH, zFile, 0, 0)!=SQLITE_OK ){    sqliteFree(zFile);    return;  }#endif /* SQLITE_OMIT_AUTHORIZATION */  zName = sqlite3NameFromToken(pDbname);  if( zName==0 ) return;  for(i=0; i<db->nDb; i++){    char *z = db->aDb[i].zName;    if( z && sqlite3StrICmp(z, zName)==0 ){      sqlite3ErrorMsg(pParse, "database %z is already in use", zName);      pParse->rc = SQLITE_ERROR;      sqliteFree(zFile);      return;    }  }  if( db->aDb==db->aDbStatic ){    aNew = sqliteMalloc( sizeof(db->aDb[0])*3 );    if( aNew==0 ) return;    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);  }else{    aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );    if( aNew==0 ) return;  }  db->aDb = aNew;  aNew = &db->aDb[db->nDb++];  memset(aNew, 0, sizeof(*aNew));  sqlite3HashInit(&aNew->tblHash, SQLITE_HASH_STRING, 0);  sqlite3HashInit(&aNew->idxHash, SQLITE_HASH_STRING, 0);  sqlite3HashInit(&aNew->trigHash, SQLITE_HASH_STRING, 0);  sqlite3HashInit(&aNew->aFKey, SQLITE_HASH_STRING, 1);  aNew->zName = zName;  aNew->safety_level = 3;  rc = sqlite3BtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt);  if( rc ){    sqlite3ErrorMsg(pParse, "unable to open database: %s", zFile);  }#if SQLITE_HAS_CODEC  {    extern int sqlite3CodecAttach(sqlite3*, int, void*, int);    char *zKey;    int nKey;    if( keyType==0 ){      /* No key specified.  Use the key from the main database */      extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);      sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);    }else if( keyType==1 ){      /* Key specified as text */      zKey = sqlite3NameFromToken(pKey);      nKey = strlen(zKey);    }else{      /* Key specified as a BLOB */      char *zTemp;      assert( keyType==2 );      pKey->z++;      pKey->n--;//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,


示例19: sqlite3BeginTrigger

//.........这里部分代码省略.........             */            db->init.orphanTrigger = 1;        }        goto trigger_cleanup;    }    if( IsVirtual(pTab) ){        sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables");        goto trigger_cleanup;    }        /* Check that the trigger name is not reserved and that no trigger of the     ** specified name exists */    zName = sqlite3NameFromToken(db, pName);    if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){        goto trigger_cleanup;    }    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );    if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),                        zName, sqlite3Strlen30(zName)) ){        if( !noErr ){            sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);        }else{            assert( !db->init.busy );            sqlite3CodeVerifySchema(pParse, iDb);        }        goto trigger_cleanup;    }        /* Do not create a trigger on a system table */    if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){        sqlite3ErrorMsg(pParse, "cannot create trigger on system table");        pParse->nErr++;        goto trigger_cleanup;    }        /* INSTEAD of triggers are only for views and views only support INSTEAD     ** of triggers.     */    if( pTab->pSelect && tr_tm!=TK_INSTEAD ){        sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",                        (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);        goto trigger_cleanup;    }    if( !pTab->pSelect && tr_tm==TK_INSTEAD ){        sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"                        " trigger on table: %S", pTableName, 0);        goto trigger_cleanup;    }    iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);    #ifndef SQLITE_OMIT_AUTHORIZATION    {        int code = SQLITE_CREATE_TRIGGER;        const char *zDb = db->aDb[iTabDb].zName;        const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;        if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;        if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){            goto trigger_cleanup;        }        if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){            goto trigger_cleanup;        }    }#endif        /* INSTEAD OF triggers can only appear on views and BEFORE triggers     ** cannot appear on views.  So we might as well translate every     ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code     ** elsewhere.     */    if (tr_tm == TK_INSTEAD){        tr_tm = TK_BEFORE;    }        /* Build the Trigger object */    pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));    if( pTrigger==0 ) goto trigger_cleanup;    pTrigger->zName = zName;    zName = 0;    pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);    pTrigger->pSchema = db->aDb[iDb].pSchema;    pTrigger->pTabSchema = pTab->pSchema;    pTrigger->op = (u8)op;    pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;    pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);    pTrigger->pColumns = sqlite3IdListDup(db, pColumns);    assert( pParse->pNewTrigger==0 );    pParse->pNewTrigger = pTrigger;    trigger_cleanup:    sqlite3DbFree(db, zName);    sqlite3SrcListDelete(db, pTableName);    sqlite3IdListDelete(db, pColumns);    sqlite3ExprDelete(db, pWhen);    if( !pParse->pNewTrigger ){        sqlite3DeleteTrigger(db, pTrigger);    }else{        assert( pParse->pNewTrigger==pTrigger );    }}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:101,


示例20: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */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 */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  int nTabName;             /* Number of UTF-8 characters in zTabName */  const char *zTabName;     /* Original name of the table */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif  VTable *pVTab = 0;        /* 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) ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zDbSName;  db->flags |= SQLITE_PreferBuiltin;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(db, pName);  if( !zName ) 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) || sqlite3FindIndex(db, zName, zDb) ){    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;  }#ifndef SQLITE_OMIT_VIEW  if( pTab->pSelect ){    sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_VIRTUALTABLE  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto exit_rename_table;  }  if( IsVirtual(pTab) ){    pVTab = sqlite3GetVTable(db, pTab);    if( pVTab->pVtab->pModule->xRename==0 ){      pVTab = 0;    }  }#endif  /* Begin a transaction 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==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);  sqlite3ChangeCookie(pParse, iDb);  /* If this is a virtual table, invoke the xRename() function if  ** one is defined. The xRename() callback will modify the names  ** of any resources used by the v-table implementation (including other  ** SQLite tables) that are identified by the name of the virtual table.  *///.........这里部分代码省略.........
开发者ID:chinesemanbobo,项目名称:PPDemo,代码行数:101,


示例21: sqlite3Pragma

/*** Process a pragma statement.  **** Pragmas are of this form:****      PRAGMA [database.]id [= value]**** The identifier might also be a string.  The value is a string, and** identifier, or a number.  If minusFlag is true, then the value is** a number that was preceded by a minus sign.**** If the left side is "database.id" then pId1 is the database name** and pId2 is the id.  If the left side is just "id" then pId1 is the** id and pId2 is any empty string.*/void sqlite3Pragma(  Parse *pParse,   Token *pId1,        /* First part of [database.]id field */  Token *pId2,        /* Second part of [database.]id field, or NULL */  Token *pValue,      /* Token for <value>, or NULL */  int minusFlag       /* True if a '-' sign preceded <value> */){  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */  const char *zDb = 0;   /* The database name */  Token *pId;            /* Pointer to <id> token */  int iDb;               /* Database index for <database> */  sqlite3 *db = pParse->db;  Db *pDb;  Vdbe *v = sqlite3GetVdbe(pParse);  if( v==0 ) return;  /* Interpret the [database.] part of the pragma statement. iDb is the  ** index of the database this pragma is being applied to in db.aDb[]. */  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);  if( iDb<0 ) return;  pDb = &db->aDb[iDb];  /* If the temp database has been explicitly named as part of the   ** pragma, make sure it is open.   */  if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){    return;  }  zLeft = sqlite3NameFromToken(db, pId);  if( !zLeft ) return;  if( minusFlag ){    zRight = sqlite3MPrintf(db, "-%T", pValue);  }else{    zRight = sqlite3NameFromToken(db, pValue);  }  zDb = ((iDb>0)?pDb->zName:0);  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){    goto pragma_out;  } #ifndef SQLITE_OMIT_PAGER_PRAGMAS  /*  **  PRAGMA [database.]default_cache_size  **  PRAGMA [database.]default_cache_size=N  **  ** The first form reports the current persistent setting for the  ** page cache size.  The value returned is the maximum number of  ** pages in the page cache.  The second form sets both the current  ** page cache size value and the persistent page cache size value  ** stored in the database file.  **  ** The default cache size is stored in meta-value 2 of page 1 of the  ** database file.  The cache size is actually the absolute value of  ** this memory location.  The sign of meta-value 2 determines the  ** synchronous setting.  A negative value means synchronous is off  ** and a positive value means synchronous is on.  */  if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){    static const VdbeOpList getCacheSize[] = {      { OP_ReadCookie,  0, 2,        0},  /* 0 */      { OP_AbsValue,    0, 0,        0},      { OP_Dup,         0, 0,        0},      { OP_Integer,     0, 0,        0},      { OP_Ne,          0, 6,        0},      { OP_Integer,     0, 0,        0},  /* 5 */      { OP_Callback,    1, 0,        0},    };    int addr;    if( sqlite3ReadSchema(pParse) ) goto pragma_out;    sqlite3VdbeUsesBtree(v, iDb);    if( !zRight ){      sqlite3VdbeSetNumCols(v, 1);      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", P3_STATIC);      addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);      sqlite3VdbeChangeP1(v, addr, iDb);      sqlite3VdbeChangeP1(v, addr+5, SQLITE_DEFAULT_CACHE_SIZE);    }else{      int size = atoi(zRight);      if( size<0 ) size = -size;      sqlite3BeginWriteOperation(pParse, 0, iDb);      sqlite3VdbeAddOp(v, OP_Integer, size, 0);      sqlite3VdbeAddOp(v, OP_ReadCookie, iDb, 2);//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:Reclass-2015,代码行数:101,


示例22: sqlite3AlterFinishAddColumn

/*** This function is called after an "ALTER TABLE ... ADD" statement** has been parsed. Argument pColDef contains the text of the new** column definition.**** The Table structure pParse->pNewTable was extended to include** the new column during parsing.*/void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){  Table *pNew;              /* Copy of pParse->pNewTable */  Table *pTab;              /* Table being altered */  int iDb;                  /* Database number */  const char *zDb;          /* Database name */  const char *zTab;         /* Table name */  char *zCol;               /* Null-terminated column definition */  Column *pCol;             /* The new column */  Expr *pDflt;              /* Default value for the new column */  sqlite3 *db;              /* The database connection; */  Vdbe *v = pParse->pVdbe;  /* The prepared statement under construction */  int r1;                   /* Temporary registers */  db = pParse->db;  if( pParse->nErr || db->mallocFailed ) return;  assert( v!=0 );  pNew = pParse->pNewTable;  assert( pNew );  assert( sqlite3BtreeHoldsAllMutexes(db) );  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);  zDb = db->aDb[iDb].zDbSName;  zTab = &pNew->zName[16];  /* Skip the "sqlite_altertab_" prefix on the name */  pCol = &pNew->aCol[pNew->nCol-1];  pDflt = pCol->pDflt;  pTab = sqlite3FindTable(db, zTab, zDb);  assert( pTab );#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    return;  }#endif  /* If the default value for the new column was specified with a   ** literal NULL, then set pDflt to 0. This simplifies checking  ** for an SQL NULL default below.  */  assert( pDflt==0 || pDflt->op==TK_SPAN );  if( pDflt && pDflt->pLeft->op==TK_NULL ){    pDflt = 0;  }  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.  ** If there is a NOT NULL constraint, then the default value for the  ** column must not be NULL.  */  if( pCol->colFlags & COLFLAG_PRIMKEY ){    sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column");    return;  }  if( pNew->pIndex ){    sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");    return;  }  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){    sqlite3ErrorMsg(pParse,         "Cannot add a REFERENCES column with non-NULL default value");    return;  }  if( pCol->notNull && !pDflt ){    sqlite3ErrorMsg(pParse,         "Cannot add a NOT NULL column with default value NULL");    return;  }  /* Ensure the default expression is something that sqlite3ValueFromExpr()  ** can handle (i.e. not CURRENT_TIME etc.)  */  if( pDflt ){    sqlite3_value *pVal = 0;    int rc;    rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );    if( rc!=SQLITE_OK ){      assert( db->mallocFailed == 1 );      return;    }    if( !pVal ){      sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");      return;    }    sqlite3ValueFree(pVal);  }  /* Modify the CREATE TABLE statement. */  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);  if( zCol ){    char *zEnd = &zCol[pColDef->n-1];    int savedDbFlags = db->flags;    while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){//.........这里部分代码省略.........
开发者ID:chinesemanbobo,项目名称:PPDemo,代码行数:101,


示例23: sqlite3DeleteFrom

/*** Generate code for a DELETE FROM statement.****     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;**                 /________/       /________________/**                  pTabList              pWhere*/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 */  const char *zDb;       /* Name of database holding pTab */  int i;                 /* Loop counter */  WhereInfo *pWInfo;     /* Information about the WHERE clause */  Index *pIdx;           /* For looping over indices of the table */  int iTabCur;           /* Cursor number for the table */  int iDataCur;          /* VDBE cursor for the canonical data source */  int iIdxCur;           /* Cursor number of the first index */  int nIdx;              /* Number of indices */  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 */  int okOnePass;         /* True for one-pass algorithm without the FIFO */  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */  u8 *aToOpen = 0;       /* Open cursor iTabCur+j if aToOpen[j] is true */  Index *pPk;            /* The PRIMARY KEY index on the table */  int iPk = 0;           /* First of nPk registers holding PRIMARY KEY value */  i16 nPk = 1;           /* Number of columns in the PRIMARY KEY */  int iKey;              /* Memory cell holding key of row to be deleted */  i16 nKey;              /* Number of memory cells in the row key */  int iEphCur = 0;       /* Ephemeral table holding all primary key values */  int iRowSet = 0;       /* Register for rowset of rows to delete */  int addrBypass = 0;    /* Address of jump over the delete logic */  int addrLoop = 0;      /* Top of the delete loop */  int addrDelete = 0;    /* Jump directly to the delete logic */  int addrEphOpen = 0;   /* Instruction to open the Ephermeral table */ #ifndef SQLITE_OMIT_TRIGGER  int isView;                  /* True if attempting to delete from a view */  Trigger *pTrigger;           /* List of table triggers, if required */#endif  memset(&sContext, 0, sizeof(sContext));  db = pParse->db;  if( pParse->nErr || db->mallocFailed ){    goto delete_from_cleanup;  }  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==0 )  goto delete_from_cleanup;  /* Figure out if we have any triggers and if the table being  ** deleted from is a view  */#ifndef SQLITE_OMIT_TRIGGER  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);  isView = pTab->pSelect!=0;#else# define pTrigger 0# define isView 0#endif#ifdef SQLITE_OMIT_VIEW# undef isView# define isView 0#endif  /* If pTab is really a view, make sure it has been initialized.  */  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto delete_from_cleanup;  }  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){    goto delete_from_cleanup;  }  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb<db->nDb );  zDb = db->aDb[iDb].zName;  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );  if( rcauth==SQLITE_DENY ){    goto delete_from_cleanup;  }  assert(!isView || pTrigger);  /* Assign cursor numbers to the table and all its indices.  */  assert( pTabList->nSrc==1 );//.........这里部分代码省略.........
开发者ID:xluoly,项目名称:raw-os_sqlite,代码行数:101,


示例24: sqlite3Pragma

/*** Process a pragma statement.  **** Pragmas are of this form:****      PRAGMA [database.]id [= value]**** The identifier might also be a string.  The value is a string, and** identifier, or a number.  If minusFlag is true, then the value is** a number that was preceded by a minus sign.**** If the left side is "database.id" then pId1 is the database name** and pId2 is the id.  If the left side is just "id" then pId1 is the** id and pId2 is any empty string.*/void sqlite3Pragma(  Parse *pParse,   Token *pId1,        /* First part of [database.]id field */  Token *pId2,        /* Second part of [database.]id field, or NULL */  Token *pValue,      /* Token for <value>, or NULL */  int minusFlag       /* True if a '-' sign preceded <value> */){  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */  const char *zDb = 0;   /* The database name */  Token *pId;            /* Pointer to <id> token */  int iDb;               /* Database index for <database> */  sqlite3 *db = pParse->db;  Db *pDb;  Vdbe *v = sqlite3GetVdbe(pParse);  if( v==0 ) return;  /* Interpret the [database.] part of the pragma statement. iDb is the  ** index of the database this pragma is being applied to in db.aDb[]. */  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);  if( iDb<0 ) return;  pDb = &db->aDb[iDb];  zLeft = sqlite3NameFromToken(pId);  if( !zLeft ) return;  if( minusFlag ){    zRight = sqlite3MPrintf("-%T", pValue);  }else{    zRight = sqlite3NameFromToken(pValue);  }  zDb = ((iDb>0)?pDb->zName:0);  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){    goto pragma_out;  } #ifndef SQLITE_OMIT_PAGER_PRAGMAS  /*  **  PRAGMA [database.]default_cache_size  **  PRAGMA [database.]default_cache_size=N  **  ** The first form reports the current persistent setting for the  ** page cache size.  The value returned is the maximum number of  ** pages in the page cache.  The second form sets both the current  ** page cache size value and the persistent page cache size value  ** stored in the database file.  **  ** The default cache size is stored in meta-value 2 of page 1 of the  ** database file.  The cache size is actually the absolute value of  ** this memory location.  The sign of meta-value 2 determines the  ** synchronous setting.  A negative value means synchronous is off  ** and a positive value means synchronous is on.  */  if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){    static const VdbeOpList getCacheSize[] = {      { OP_ReadCookie,  0, 2,        0},  /* 0 */      { OP_AbsValue,    0, 0,        0},      { OP_Dup,         0, 0,        0},      { OP_Integer,     0, 0,        0},      { OP_Ne,          0, 6,        0},      { OP_Integer,     0, 0,        0},  /* 5 */      { OP_Callback,    1, 0,        0},    };    int addr;    if( sqlite3ReadSchema(pParse) ) goto pragma_out;    if( !zRight ){      sqlite3VdbeSetNumCols(v, 1);      sqlite3VdbeSetColName(v, 0, "cache_size", P3_STATIC);      addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);      sqlite3VdbeChangeP1(v, addr, iDb);      sqlite3VdbeChangeP1(v, addr+5, MAX_PAGES);    }else{      int size = atoi(zRight);      if( size<0 ) size = -size;      sqlite3BeginWriteOperation(pParse, 0, iDb);      sqlite3VdbeAddOp(v, OP_Integer, size, 0);      sqlite3VdbeAddOp(v, OP_ReadCookie, iDb, 2);      addr = sqlite3VdbeAddOp(v, OP_Integer, 0, 0);      sqlite3VdbeAddOp(v, OP_Ge, 0, addr+3);      sqlite3VdbeAddOp(v, OP_Negative, 0, 0);      sqlite3VdbeAddOp(v, OP_SetCookie, iDb, 2);      pDb->cache_size = size;      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->cache_size);    }  }else//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:snalp-svn,代码行数:101,


示例25: sqlite3Update

//.........这里部分代码省略.........  ** that column.  */  chngRowid = chngPk = 0;  for(i=0; i<pChanges->nExpr; i++){    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){      goto update_cleanup;    }    for(j=0; j<pTab->nCol; j++){      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){        if( j==pTab->iPKey ){          chngRowid = 1;          pRowidExpr = pChanges->a[i].pExpr;        }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){          chngPk = 1;        }        aXRef[j] = i;        break;      }    }    if( j>=pTab->nCol ){      if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zName) ){        j = -1;        chngRowid = 1;        pRowidExpr = pChanges->a[i].pExpr;      }else{        sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);        pParse->checkSchema = 1;        goto update_cleanup;      }    }#ifndef SQLITE_OMIT_AUTHORIZATION    {      int rc;      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,                            j<0 ? "ROWID" : pTab->aCol[j].zName,                            db->aDb[iDb].zName);      if( rc==SQLITE_DENY ){        goto update_cleanup;      }else if( rc==SQLITE_IGNORE ){        aXRef[j] = -1;      }    }#endif  }  assert( (chngRowid & chngPk)==0 );  assert( chngRowid==0 || chngRowid==1 );  assert( chngPk==0 || chngPk==1 );  chngKey = chngRowid + chngPk;  /* The SET expressions are not actually used inside the WHERE loop.  ** So reset the colUsed mask  */  pTabList->a[0].colUsed = 0;  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);  /* There is one entry in the aRegIdx[] array for each index on the table  ** being updated.  Fill in aRegIdx[] with a register number that will hold  ** the key for accessing each index.  **  ** FIXME:  Be smarter about omitting indexes that use expressions.  */  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngKey || hasFK || pIdx->pPartIdxWhere || pIdx==pPk ){      reg = ++pParse->nMem;
开发者ID:hoangdoanh,项目名称:sqlite,代码行数:67,


示例26: sqlite3Update

//.........这里部分代码省略.........  ** of the UPDATE statement.  Also find the column index  ** for each column to be updated in the pChanges array.  For each  ** column to be updated, make sure we have authorization to change  ** that column.  */  chngRowid = 0;  for(i=0; i<pChanges->nExpr; i++){    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){      goto update_cleanup;    }    for(j=0; j<pTab->nCol; j++){      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){        if( j==pTab->iPKey ){          chngRowid = 1;          pRowidExpr = pChanges->a[i].pExpr;        }        aXRef[j] = i;        break;      }    }    if( j>=pTab->nCol ){      if( sqlite3IsRowid(pChanges->a[i].zName) ){        chngRowid = 1;        pRowidExpr = pChanges->a[i].pExpr;      }else{        sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);        pParse->checkSchema = 1;        goto update_cleanup;      }    }#ifndef SQLITE_OMIT_AUTHORIZATION    {      int rc;      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,                           pTab->aCol[j].zName, db->aDb[iDb].zName);      if( rc==SQLITE_DENY ){        goto update_cleanup;      }else if( rc==SQLITE_IGNORE ){        aXRef[j] = -1;      }    }#endif  }  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);  /* Allocate memory for the array aRegIdx[].  There is one entry in the  ** array for each index associated with table being updated.  Fill in  ** the value with a register number for indices that are to be used  ** and with zero for unused indices.  */  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}  if( nIdx>0 ){    aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );    if( aRegIdx==0 ) goto update_cleanup;  }  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){    int reg;    if( chngRowid ){      reg = ++pParse->nMem;    }else{      reg = 0;      for(i=0; i<pIdx->nColumn; i++){        if( aXRef[pIdx->aiColumn[i]]>=0 ){          reg = ++pParse->nMem;          break;
开发者ID:Sheridan,项目名称:sqlite,代码行数:67,


示例27: sqlite3DeleteFrom

/*** Generate code for a DELETE FROM statement.****     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;**                 /________/       /________________/**                  pTabList              pWhere*/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 */  const char *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 Cursor number for pTab */  sqlite3 *db;           /* Main database structure */  AuthContext sContext;  /* Authorization context */  int oldIdx = -1;       /* Cursor for the OLD table of AFTER triggers */  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 */#ifndef SQLITE_OMIT_TRIGGER  int isView;                  /* True if attempting to delete from a view */  int triggers_exist = 0;      /* True if any triggers exist */#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 */  sContext.pParse = 0;  db = pParse->db;  if( pParse->nErr || db->mallocFailed ){    goto delete_from_cleanup;  }  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==0 )  goto delete_from_cleanup;  /* Figure out if we have any triggers and if the table being  ** deleted from is a view  */#ifndef SQLITE_OMIT_TRIGGER  triggers_exist = sqlite3TriggersExist(pTab, TK_DELETE, 0);  isView = pTab->pSelect!=0;#else# define triggers_exist 0# define isView 0#endif#ifdef SQLITE_OMIT_VIEW# undef isView# define isView 0#endif  if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){    goto delete_from_cleanup;  }  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  assert( iDb<db->nDb );  zDb = db->aDb[iDb].zName;  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );  if( rcauth==SQLITE_DENY ){    goto delete_from_cleanup;  }  assert(!isView || triggers_exist);  /* If pTab is really a view, make sure it has been initialized.  */  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto delete_from_cleanup;  }  /* Allocate a cursor used to store the old.* data for a trigger.  */  if( triggers_exist ){     oldIdx = pParse->nTab++;  }  /* Assign  cursor number to the table and all its indices.  */  assert( pTabList->nSrc==1 );  iCur = pTabList->a[0].iCursor = pParse->nTab++;  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){    pParse->nTab++;  }//.........这里部分代码省略.........
开发者ID:kfengbest,项目名称:GenericDB,代码行数:101,


示例28: sqlite3AlterFinishAddColumn

/*** This function is called after an "ALTER TABLE ... ADD" statement** has been parsed. Argument pColDef contains the text of the new** column definition.**** The Table structure pParse->pNewTable was extended to include** the new column during parsing.*/void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){  Table *pNew;              /* Copy of pParse->pNewTable */  Table *pTab;              /* Table being altered */  int iDb;                  /* Database number */  const char *zDb;          /* Database name */  const char *zTab;         /* Table name */  char *zCol;               /* Null-terminated column definition */  Column *pCol;             /* The new column */  Expr *pDflt;              /* Default value for the new column */  sqlite3 *db;              /* The database connection; */  if( pParse->nErr ) return;  pNew = pParse->pNewTable;  assert( pNew );  db = pParse->db;  assert( sqlite3BtreeHoldsAllMutexes(db) );  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);  zDb = db->aDb[iDb].zName;  zTab = pNew->zName;  pCol = &pNew->aCol[pNew->nCol-1];  pDflt = pCol->pDflt;  pTab = sqlite3FindTable(db, zTab, zDb);  assert( pTab );#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    return;  }#endif  /* If the default value for the new column was specified with a   ** literal NULL, then set pDflt to 0. This simplifies checking  ** for an SQL NULL default below.  */  if( pDflt && pDflt->op==TK_NULL ){    pDflt = 0;  }  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.  ** If there is a NOT NULL constraint, then the default value for the  ** column must not be NULL.  */  if( pCol->isPrimKey ){    sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column");    return;  }  if( pNew->pIndex ){    sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");    return;  }  if( pCol->notNull && !pDflt ){    sqlite3ErrorMsg(pParse,         "Cannot add a NOT NULL column with default value NULL");    return;  }  /* Ensure the default expression is something that sqlite3ValueFromExpr()  ** can handle (i.e. not CURRENT_TIME etc.)  */  if( pDflt ){    sqlite3_value *pVal;    if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){      db->mallocFailed = 1;      return;    }    if( !pVal ){      sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");      return;    }    sqlite3ValueFree(pVal);  }  /* Modify the CREATE TABLE statement. */  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);  if( zCol ){    char *zEnd = &zCol[pColDef->n-1];    while( (zEnd>zCol && *zEnd==';') || isspace(*(unsigned char *)zEnd) ){      *zEnd-- = '/0';    }    sqlite3NestedParse(pParse,         "UPDATE /"%w/".%s SET "          "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) "        "WHERE type = 'table' AND name = %Q",       zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,      zTab    );    sqlite3_free(zCol);  }  /* If the default value of the new column is NULL, then set the file//.........这里部分代码省略.........
开发者ID:oddstr,项目名称:bathyscaphe-mirror,代码行数:101,



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


C++ sqlite3BeginWriteOperation函数代码示例
C++ sqlite3ApiExit函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。