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

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

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

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

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

示例1: sqlite3CreateFunc

/*** This function is exactly the same as sqlite3_create_function(), except** that it is designed to be called by internal code. The difference is** that if a malloc() fails in sqlite3_create_function(), an error code** is returned and the mallocFailed flag cleared. */int sqlite3CreateFunc(  sqlite3 *db,  const char *zFunctionName,  int nArg,  int enc,  void *pUserData,  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),  void (*xStep)(sqlite3_context*,int,sqlite3_value **),  void (*xFinal)(sqlite3_context*)){  FuncDef *p;  int nName;  assert( sqlite3_mutex_held(db->mutex) );  if( sqlite3SafetyCheck(db) ){    return SQLITE_MISUSE;  }  if( zFunctionName==0 ||      (xFunc && (xFinal || xStep)) ||       (!xFunc && (xFinal && !xStep)) ||      (!xFunc && (!xFinal && xStep)) ||      (nArg<-1 || nArg>127) ||      (255<(nName = strlen(zFunctionName))) ){    sqlite3Error(db, SQLITE_ERROR, "bad parameters");    return SQLITE_ERROR;  }  #ifndef SQLITE_OMIT_UTF16  /* If SQLITE_UTF16 is specified as the encoding type, transform this  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.  **  ** If SQLITE_ANY is specified, add three versions of the function  ** to the hash table.  */  if( enc==SQLITE_UTF16 ){    enc = SQLITE_UTF16NATIVE;  }else if( enc==SQLITE_ANY ){    int rc;    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,         pUserData, xFunc, xStep, xFinal);    if( rc==SQLITE_OK ){      rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,          pUserData, xFunc, xStep, xFinal);    }    if( rc!=SQLITE_OK ){      return rc;    }    enc = SQLITE_UTF16BE;  }#else  enc = SQLITE_UTF8;#endif    /* Check if an existing function is being overridden or deleted. If so,  ** and there are active VMs, then return SQLITE_BUSY. If a function  ** is being overridden/deleted but there are no active VMs, allow the  ** operation to continue but invalidate all precompiled statements.  */  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 0);  if( p && p->iPrefEnc==enc && p->nArg==nArg ){    if( db->activeVdbeCnt ){      sqlite3Error(db, SQLITE_BUSY,         "Unable to delete/modify user-function due to active statements");      assert( !db->mallocFailed );      return SQLITE_BUSY;    }else{      sqlite3ExpirePreparedStatements(db);    }  }  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 1);  assert(p || db->mallocFailed);  if( !p ){    return SQLITE_NOMEM;  }  p->flags = 0;  p->xFunc = xFunc;  p->xStep = xStep;  p->xFinalize = xFinal;  p->pUserData = pUserData;  p->nArg = nArg;  return SQLITE_OK;}
开发者ID:guange2015,项目名称:sqlite-for-symbian,代码行数:90,


示例2: sqlite3_result_int64

SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetInt64(&pCtx->s, iVal);}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:4,


示例3: sqlite3_result_zeroblob

void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);}
开发者ID:bravery,项目名称:sqlite,代码行数:4,


示例4: pcache1TruncateUnsafe

}/*** Discard all pages from cache pCache with a page number (key value) ** greater than or equal to iLimit. Any pinned pages that meet this ** criteria are unpinned before they are discarded.**** The PCache mutex must be held when this function is called.*/static void pcache1TruncateUnsafe(  PCache1 *pCache,             /* The cache to truncate */  unsigned int iLimit          /* Drop pages with this pgno or larger */){  TESTONLY( unsigned int nPage = 0; )  /* To assert pCache->nPage is correct */  unsigned int h;  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );  for(h=0; h<pCache->nHash; h++){    PgHdr1 **pp = &pCache->apHash[h];     PgHdr1 *pPage;    while( (pPage = *pp)!=0 ){      if( pPage->iKey>=iLimit ){        pCache->nPage--;        *pp = pPage->pNext;        pcache1PinPage(pPage);        pcache1FreePage(pPage);      }else{        pp = &pPage->pNext;        TESTONLY( nPage++; )      }    }  }
开发者ID:HuiLi,项目名称:Sqlite3.07.14,代码行数:31,


示例5: sqlite3_result_error16

void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  pCtx->isError = SQLITE_ERROR;  pCtx->fErrorOrAux = 1;  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);}
开发者ID:bravery,项目名称:sqlite,代码行数:6,


示例6: sqlite3_result_null

void sqlite3_result_null(sqlite3_context *pCtx){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetNull(pCtx->pOut);}
开发者ID:bravery,项目名称:sqlite,代码行数:4,


示例7: assert

*/该函数返回至少n字节大小的block,没有则返回null。该函数假设所有必要的互斥锁都上了,所以不安全static void *memsys3MallocUnsafe(int nByte){  u32 i;  u32 nBlock;  u32 toFree;  assert( sqlite3_mutex_held(mem3.mutex) );   //如果不能加锁,则终止程序  assert( sizeof(Mem3Block)==8 );   //若Mem3Block大小为8,继续往下执行  if( nByte<=12 ){                //给nBlock赋值    nBlock = 2;  }else{    nBlock = (nByte + 11)/8;  }  assert( nBlock>=2 );  /* STEP 1:  ** Look for an entry of the correct size in either the small  ** chunk table or in the large chunk hash table.  This is  ** successful most of the time (about 9 times out of 10).  */   //首先在小chunk或者大chunk中寻找正确大小块的入口,一般都会成功  if( nBlock <= MX_SMALL ){        //nBlock小于MX_SMALL,则在小chunk中找    i = mem3.aiSmall[nBlock-2];    if( i>0 ){      memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]);      return memsys3Checkout(i, nBlock);  //返回找到的满足的chunk    }  }else{    //若nBlock大于MX_SMALL,则在大chunk中找    int hash = nBlock % N_HASH;    for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){      if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){        memsys3UnlinkFromList(i, &mem3.aiHash[hash]);        return memsys3Checkout(i, nBlock);   //返回找到的chunk      }    }  }  /* STEP 2:  ** Try to satisfy the allocation by carving a piece off of the end  ** of the master chunk.  This step usually works if step 1 fails.  */     //尝试从master chunk中分裂出合适的空间,第一步失败才执行  if( mem3.szMaster>=nBlock ){    return memsys3FromMaster(nBlock);  //从master chunk中获取chunk  }  /* STEP 3:    ** Loop through the entire memory pool.  Coalesce adjacent free  ** chunks.  Recompute the master chunk as the largest free chunk.  ** Then try again to satisfy the allocation by carving a piece off  ** of the end of the master chunk.  This step happens very  ** rarely (we hope!)  */遍历整个内存池,合并相邻空闲chunk,重新计算主要的chunk大小,再次尝试从master chunk中分裂出满足分配条件的chunk。前面都不行才执行该步骤。  for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){  //遍历内存池    memsys3OutOfMemory(toFree);     //不够分配则释放    if( mem3.iMaster ){               //master chunk存在,将其链接到相应块索引表中              memsys3Link(mem3.iMaster);      mem3.iMaster = 0;      mem3.szMaster = 0;    }    for(i=0; i<N_HASH; i++){      memsys3Merge(&mem3.aiHash[i]);  //链接相邻空chunk到aiHash中    }    for(i=0; i<MX_SMALL-1; i++){      memsys3Merge(&mem3.aiSmall[i]); //链接相邻空chunk到aiSmall中    }    if( mem3.szMaster ){             //当前master chunk不为0,则从索引表中断开      memsys3Unlink(mem3.iMaster);      if( mem3.szMaster>=nBlock ){        return memsys3FromMaster(nBlock); //返回得到的内存空间      }    }  }  /* If none of the above worked, then we fail. */   return 0;  //若上面三步都失败了,那就失败了,返回0}
开发者ID:Guidachengong,项目名称:Sqlite3.07.14,代码行数:76,


示例8: sqlite3InitCallback

/*** This is the callback routine for the code that initializes the** database.  See sqlite3Init() below for additional information.** This routine is also called from the OP_ParseSchema opcode of the VDBE.**** Each callback contains the following information:****     argv[0] = name of thing being created**     argv[1] = root page number for table or index. 0 for trigger or view.**     argv[2] = SQL text for the CREATE statement.***/int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){  InitData *pData = (InitData*)pInit;  sqlite3 *db = pData->db;  int iDb = pData->iDb;  assert( argc==3 );  UNUSED_PARAMETER2(NotUsed, argc);  assert( sqlite3_mutex_held(db->mutex) );  DbClearProperty(db, iDb, DB_Empty);  if( db->mallocFailed ){    corruptSchema(pData, argv[0], 0);    return 1;  }  assert( iDb>=0 && iDb<db->nDb );  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */  if( argv[1]==0 ){    corruptSchema(pData, argv[0], 0);  }else if( argv[2] && argv[2][0] ){    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.    ** But because db->init.busy is set to 1, no VDBE code is generated    ** or executed.  All the parser does is build the internal data    ** structures that describe the table, index, or view.    */    char *zErr;    int rc;    assert( db->init.busy );    db->init.iDb = iDb;    db->init.newTnum = atoi(argv[1]);    db->init.orphanTrigger = 0;    rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);    db->init.iDb = 0;    assert( rc!=SQLITE_OK || zErr==0 );    if( SQLITE_OK!=rc ){      if( db->init.orphanTrigger ){        assert( iDb==1 );      }else{        pData->rc = rc;        if( rc==SQLITE_NOMEM ){          db->mallocFailed = 1;        }else if( rc!=SQLITE_INTERRUPT && rc!=SQLITE_LOCKED ){          corruptSchema(pData, argv[0], zErr);        }      }      sqlite3DbFree(db, zErr);    }  }else if( argv[0]==0 ){    corruptSchema(pData, 0, 0);  }else{    /* If the SQL column is blank it means this is an index that    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE    ** constraint for a CREATE TABLE.  The index should have already    ** been created when we processed the CREATE TABLE.  All we have    ** to do here is record the root page number for that index.    */    Index *pIndex;    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zName);    if( pIndex==0 ){      /* This can occur if there exists an index on a TEMP table which      ** has the same name as another index on a permanent index.  Since      ** the permanent table is hidden by the TEMP table, we can also      ** safely ignore the index on the permanent table.      */      /* Do Nothing */;    }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){      corruptSchema(pData, argv[0], "invalid rootpage");    }  }  return 0;}
开发者ID:biddyweb,项目名称:mediastream-plus,代码行数:82,


示例9: pcache1TruncateUnsafe

}/*** Discard all pages from cache pCache with a page number (key value) ** greater than or equal to iLimit. Any pinned pages that meet this ** criteria are unpinned before they are discarded.**** The global mutex must be held when this function is called.*/static void pcache1TruncateUnsafe(  PCache1 *pCache,   unsigned int iLimit ){  TESTONLY( unsigned int nPage = 0; )      /* Used to assert pCache->nPage is correct */  unsigned int h;  assert( sqlite3_mutex_held(pcache1.mutex) );  for(h=0; h<pCache->nHash; h++){    PgHdr1 **pp = &pCache->apHash[h];     PgHdr1 *pPage;    while( (pPage = *pp)!=0 ){      if( pPage->iKey>=iLimit ){        pCache->nPage--;        *pp = pPage->pNext;        pcache1PinPage(pPage);        pcache1FreePage(pPage);      }else{        pp = &pPage->pNext;        TESTONLY( nPage++; )      }    }  }
开发者ID:Sheridan,项目名称:sqlite,代码行数:31,


示例10: sqlite3VdbeMemTranslate

/*** This routine transforms the internal text encoding used by pMem to** desiredEnc. It is an error if the string is already of the desired** encoding, or if *pMem does not contain a string value.*/int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){  int len;                    /* Maximum length of output string in bytes */  unsigned char *zOut;                  /* Output buffer */  unsigned char *zIn;                   /* Input iterator */  unsigned char *zTerm;                 /* End of input */  unsigned char *z;                     /* Output iterator */  unsigned int c;  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );  assert( pMem->flags&MEM_Str );  assert( pMem->enc!=desiredEnc );  assert( pMem->enc!=0 );  assert( pMem->n>=0 );#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)  {    char zBuf[100];    sqlite3VdbeMemPrettyPrint(pMem, zBuf);    fprintf(stderr, "INPUT:  %s/n", zBuf);  }#endif  /* If the translation is between UTF-16 little and big endian, then   ** all that is required is to swap the byte order. This case is handled  ** differently from the others.  */  if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){    u8 temp;    int rc;    rc = sqlite3VdbeMemMakeWriteable(pMem);    if( rc!=SQLITE_OK ){      assert( rc==SQLITE_NOMEM );      return SQLITE_NOMEM;    }    zIn = (u8*)pMem->z;    zTerm = &zIn[pMem->n&~1];    while( zIn<zTerm ){      temp = *zIn;      *zIn = *(zIn+1);      zIn++;      *zIn++ = temp;    }    pMem->enc = desiredEnc;    goto translate_out;  }  /* Set len to the maximum number of bytes required in the output buffer. */  if( desiredEnc==SQLITE_UTF8 ){    /* When converting from UTF-16, the maximum growth results from    ** translating a 2-byte character to a 4-byte UTF-8 character.    ** A single byte is required for the output string    ** nul-terminator.    */    pMem->n &= ~1;    len = pMem->n * 2 + 1;  }else{    /* When converting from UTF-8 to UTF-16 the maximum growth is caused    ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16    ** character. Two bytes are required in the output buffer for the    ** nul-terminator.    */    len = pMem->n * 2 + 2;  }  /* Set zIn to point at the start of the input buffer and zTerm to point 1  ** byte past the end.  **  ** Variable zOut is set to point at the output buffer, space obtained  ** from sqlite3_malloc().  */  zIn = (u8*)pMem->z;  zTerm = &zIn[pMem->n];  zOut = (unsigned char *) sqlite3DbMallocRaw(pMem->db, len);  if( !zOut ){    return SQLITE_NOMEM;  }  z = zOut;  if( pMem->enc==SQLITE_UTF8 ){    if( desiredEnc==SQLITE_UTF16LE ){      /* UTF-8 -> UTF-16 Little-endian */      while( zIn<zTerm ){        /* c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); */        READ_UTF8(zIn, zTerm, c);        WRITE_UTF16LE(z, c);      }    }else{      assert( desiredEnc==SQLITE_UTF16BE );      /* UTF-8 -> UTF-16 Big-endian */      while( zIn<zTerm ){        /* c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); */        READ_UTF8(zIn, zTerm, c);        WRITE_UTF16BE(z, c);      }    }//.........这里部分代码省略.........
开发者ID:sunyangkobe,项目名称:db_research,代码行数:101,


示例11: sqlite3_result_zeroblob

SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetZeroBlob(&pCtx->s, n);}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:4,


示例12: setResultStrOrError

/**************************** sqlite3_result_  ******************************* ** The following routines are used by user-defined functions to specify ** the function result. ** ** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the ** result as a string or blob but if the string or blob is too large, it ** then sets the error code to SQLITE_TOOBIG */static void setResultStrOrError(                                sqlite3_context *pCtx,  /* Function context */                                const char *z,          /* String pointer */                                int n,                  /* Bytes in string, or negative */                                u8 enc,                 /* Encoding of z.  0 for BLOBs */                                void (*xDel)(void*)     /* Destructor function */){    if( sqlite3VdbeMemSetStr(&pCtx->s, z, n, enc, xDel)==SQLITE_TOOBIG ){        sqlite3_result_error_toobig(pCtx);    }}SQLITE_API void sqlite3_result_blob(                                    sqlite3_context *pCtx,                                    const void *z,                                    int n,                                    void (*xDel)(void *)                                    ){    assert( n>=0 );    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    setResultStrOrError(pCtx, z, n, 0, xDel);}SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetDouble(&pCtx->s, rVal);}SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    pCtx->isError = SQLITE_ERROR;    pCtx->fErrorOrAux = 1;    sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);}#ifndef SQLITE_OMIT_UTF16SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    pCtx->isError = SQLITE_ERROR;    pCtx->fErrorOrAux = 1;    sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);}#endifSQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal);}SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetInt64(&pCtx->s, iVal);}SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetNull(&pCtx->s);}SQLITE_API void sqlite3_result_text(                                    sqlite3_context *pCtx,                                    const char *z,                                    int n,                                    void (*xDel)(void *)                                    ){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);}#ifndef SQLITE_OMIT_UTF16SQLITE_API void sqlite3_result_text16(                                      sqlite3_context *pCtx,                                      const void *z,                                      int n,                                      void (*xDel)(void *)                                      ){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);}SQLITE_API void sqlite3_result_text16be(                                        sqlite3_context *pCtx,                                        const void *z,                                        int n,                                        void (*xDel)(void *)                                        ){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);}SQLITE_API void sqlite3_result_text16le(                                        sqlite3_context *pCtx,                                        const void *z,                                        int n,                                        void (*xDel)(void *)                                        ){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);}#endif /* SQLITE_OMIT_UTF16 */SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemCopy(&pCtx->s, pValue);//.........这里部分代码省略.........
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:101,


示例13: sqlite3_result_null

SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetNull(&pCtx->s);}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:4,


示例14: sqlite3InitOne

/*** Attempt to read the database schema and initialize internal** data structures for a single database file.  The index of the** database file is given by iDb.  iDb==0 is used for the main** database.  iDb==1 should never be used.  iDb>=2 is used for** auxiliary databases.  Return one of the SQLITE_ error codes to** indicate success or failure.*/static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){  int rc;  int i;  int size;  Table *pTab;  Db *pDb;  char const *azArg[4];  int meta[5];  InitData initData;  char const *zMasterSchema;  char const *zMasterName = SCHEMA_TABLE(iDb);  int openedTransaction = 0;  /*  ** The master database table has a structure like this  */  static const char master_schema[] =      "CREATE TABLE sqlite_master(/n"     "  type text,/n"     "  name text,/n"     "  tbl_name text,/n"     "  rootpage integer,/n"     "  sql text/n"     ")"  ;#ifndef SQLITE_OMIT_TEMPDB  static const char temp_master_schema[] =      "CREATE TEMP TABLE sqlite_temp_master(/n"     "  type text,/n"     "  name text,/n"     "  tbl_name text,/n"     "  rootpage integer,/n"     "  sql text/n"     ")"  ;#else  #define temp_master_schema 0#endif  assert( iDb>=0 && iDb<db->nDb );  assert( db->aDb[iDb].pSchema );  assert( sqlite3_mutex_held(db->mutex) );  assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );  /* zMasterSchema and zInitScript are set to point at the master schema  ** and initialisation script appropriate for the database being  ** initialised. zMasterName is the name of the master table.  */  if( !OMIT_TEMPDB && iDb==1 ){    zMasterSchema = temp_master_schema;  }else{    zMasterSchema = master_schema;  }  zMasterName = SCHEMA_TABLE(iDb);  /* Construct the schema tables.  */  azArg[0] = zMasterName;  azArg[1] = "1";  azArg[2] = zMasterSchema;  azArg[3] = 0;  initData.db = db;  initData.iDb = iDb;  initData.rc = SQLITE_OK;  initData.pzErrMsg = pzErrMsg;  (void)sqlite3SafetyOff(db);  sqlite3InitCallback(&initData, 3, (char **)azArg, 0);  (void)sqlite3SafetyOn(db);  if( initData.rc ){    rc = initData.rc;    goto error_out;  }  pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);  if( ALWAYS(pTab) ){    pTab->tabFlags |= TF_Readonly;  }  /* Create a cursor to hold the database open  */  pDb = &db->aDb[iDb];  if( pDb->pBt==0 ){    if( !OMIT_TEMPDB && ALWAYS(iDb==1) ){      DbSetProperty(db, 1, DB_SchemaLoaded);    }    return SQLITE_OK;  }  /* If there is not already a read-only (or read-write) transaction opened  ** on the b-tree database, open one now. If a transaction is opened, it   ** will be closed before this function returns.  */  sqlite3BtreeEnter(pDb->pBt);  if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){    rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);//.........这里部分代码省略.........
开发者ID:biddyweb,项目名称:mediastream-plus,代码行数:101,


示例15: sqlite3_result_error

void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );  pCtx->isError = SQLITE_ERROR;  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);}
开发者ID:77songsong,项目名称:sqlite3,代码行数:5,


示例16: sqlite3Prepare

/*** Compile the UTF-8 encoded SQL statement zSql into a statement handle.*/static int sqlite3Prepare(  sqlite3 *db,              /* Database handle. */  const char *zSql,         /* UTF-8 encoded SQL statement. */  int nBytes,               /* Length of zSql in bytes. */  int saveSqlFlag,          /* True to copy SQL text into the sqlite3_stmt */  Vdbe *pReprepare,         /* VM being reprepared */  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */  const char **pzTail       /* OUT: End of parsed string */){  Parse *pParse;            /* Parsing context */  char *zErrMsg = 0;        /* Error message */  int rc = SQLITE_OK;       /* Result code */  int i;                    /* Loop counter */  /* Allocate the parsing context */  pParse = sqlite3StackAllocZero(db, sizeof(*pParse));  if( pParse==0 ){    rc = SQLITE_NOMEM;    goto end_prepare;  }  pParse->pReprepare = pReprepare;  if( sqlite3SafetyOn(db) ){    rc = SQLITE_MISUSE;    goto end_prepare;  }  assert( ppStmt && *ppStmt==0 );  assert( !db->mallocFailed );  assert( sqlite3_mutex_held(db->mutex) );  /* Check to verify that it is possible to get a read lock on all  ** database schemas.  The inability to get a read lock indicates that  ** some other database connection is holding a write-lock, which in  ** turn means that the other connection has made uncommitted changes  ** to the schema.  **  ** Were we to proceed and prepare the statement against the uncommitted  ** schema changes and if those schema changes are subsequently rolled  ** back and different changes are made in their place, then when this  ** prepared statement goes to run the schema cookie would fail to detect  ** the schema change.  Disaster would follow.  **  ** This thread is currently holding mutexes on all Btrees (because  ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it  ** is not possible for another thread to start a new schema change  ** while this routine is running.  Hence, we do not need to hold   ** locks on the schema, we just need to make sure nobody else is   ** holding them.  **  ** Note that setting READ_UNCOMMITTED overrides most lock detection,  ** but it does *not* override schema lock detection, so this all still  ** works even if READ_UNCOMMITTED is set.  */  for(i=0; i<db->nDb; i++) {    Btree *pBt = db->aDb[i].pBt;    if( pBt ){      assert( sqlite3BtreeHoldsMutex(pBt) );      rc = sqlite3BtreeSchemaLocked(pBt);      if( rc ){        const char *zDb = db->aDb[i].zName;        sqlite3Error(db, rc, "database schema is locked: %s", zDb);        (void)sqlite3SafetyOff(db);        testcase( db->flags & SQLITE_ReadUncommitted );        goto end_prepare;      }    }  }  sqlite3VtabUnlockList(db);  pParse->db = db;  if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){    char *zSqlCopy;    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];    testcase( nBytes==mxLen );    testcase( nBytes==mxLen+1 );    if( nBytes>mxLen ){      sqlite3Error(db, SQLITE_TOOBIG, "statement too long");      (void)sqlite3SafetyOff(db);      rc = sqlite3ApiExit(db, SQLITE_TOOBIG);      goto end_prepare;    }    zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);    if( zSqlCopy ){      sqlite3RunParser(pParse, zSqlCopy, &zErrMsg);      sqlite3DbFree(db, zSqlCopy);      pParse->zTail = &zSql[pParse->zTail-zSqlCopy];    }else{      pParse->zTail = &zSql[nBytes];    }  }else{    sqlite3RunParser(pParse, zSql, &zErrMsg);  }  if( db->mallocFailed ){    pParse->rc = SQLITE_NOMEM;  }//.........这里部分代码省略.........
开发者ID:biddyweb,项目名称:mediastream-plus,代码行数:101,


示例17: sqlite3_result_int

void sqlite3_result_int(sqlite3_context *pCtx, int iVal){  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );  sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal);}
开发者ID:77songsong,项目名称:sqlite3,代码行数:4,


示例18: sqlite3_result_double

void sqlite3_result_double(sqlite3_context *pCtx, double rVal){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);}
开发者ID:bravery,项目名称:sqlite,代码行数:4,


示例19: sqlite3_result_error_toobig

/* Force an SQLITE_TOOBIG error. */void sqlite3_result_error_toobig(sqlite3_context *pCtx){  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );  pCtx->isError = SQLITE_TOOBIG;  sqlite3VdbeMemSetStr(&pCtx->s, "string or blob too big", -1,                        SQLITE_UTF8, SQLITE_STATIC);}
开发者ID:77songsong,项目名称:sqlite3,代码行数:7,


示例20: sqlite3_result_int64

void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);}
开发者ID:bravery,项目名称:sqlite,代码行数:4,


示例21: sqlite3_result_error_nomem

/* An SQLITE_NOMEM error. */void sqlite3_result_error_nomem(sqlite3_context *pCtx){  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );  sqlite3VdbeMemSetNull(&pCtx->s);  pCtx->isError = SQLITE_NOMEM;  pCtx->s.db->mallocFailed = 1;}
开发者ID:77songsong,项目名称:sqlite3,代码行数:7,


示例22: xDel

    /* noop */  }else{    xDel((void*)p);  }  if( pCtx ) sqlite3_result_error_toobig(pCtx);  return SQLITE_TOOBIG;}void sqlite3_result_blob(  sqlite3_context *pCtx,   const void *z,   int n,   void (*xDel)(void *)){  assert( n>=0 );  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  setResultStrOrError(pCtx, z, n, 0, xDel);}void sqlite3_result_blob64(  sqlite3_context *pCtx,   const void *z,   sqlite3_uint64 n,  void (*xDel)(void *)){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  assert( xDel!=SQLITE_DYNAMIC );  if( n>0x7fffffff ){    (void)invokeValueDestructor(z, xDel, pCtx);  }else{    setResultStrOrError(pCtx, z, (int)n, 0, xDel);  }}void sqlite3_result_double(sqlite3_context *pCtx, double rVal){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);}void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  pCtx->isError = SQLITE_ERROR;  pCtx->fErrorOrAux = 1;  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);}#ifndef SQLITE_OMIT_UTF16void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  pCtx->isError = SQLITE_ERROR;  pCtx->fErrorOrAux = 1;  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);}#endifvoid sqlite3_result_int(sqlite3_context *pCtx, int iVal){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);}void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);}void sqlite3_result_null(sqlite3_context *pCtx){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  sqlite3VdbeMemSetNull(pCtx->pOut);}void sqlite3_result_text(  sqlite3_context *pCtx,   const char *z,   int n,  void (*xDel)(void *)){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);}void sqlite3_result_text64(  sqlite3_context *pCtx,   const char *z,   sqlite3_uint64 n,  void (*xDel)(void *),  unsigned char enc){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  assert( xDel!=SQLITE_DYNAMIC );  if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;  if( n>0x7fffffff ){    (void)invokeValueDestructor(z, xDel, pCtx);  }else{    setResultStrOrError(pCtx, z, (int)n, enc, xDel);  }}#ifndef SQLITE_OMIT_UTF16void sqlite3_result_text16(  sqlite3_context *pCtx,   const void *z,   int n,   void (*xDel)(void *)){  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );  setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);}void sqlite3_result_text16be(  sqlite3_context *pCtx,   const void *z,   int n, //.........这里部分代码省略.........
开发者ID:bravery,项目名称:sqlite,代码行数:101,


示例23: sqlite3VdbeMemIntegerify

/*** Convert pMem to type integer.  Invalidate any prior representations.*/int sqlite3VdbeMemIntegerify(Mem *pMem){  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );  pMem->u.i = sqlite3VdbeIntValue(pMem);  setTypeFlag(pMem, MEM_Int);  return SQLITE_OK;}
开发者ID:Jacob-jiangbo,项目名称:my-test,代码行数:9,


示例24: sqlite3VdbeMemSetStr

/* ** Change the value of a Mem to be a string or a BLOB. ** ** The memory management strategy depends on the value of the xDel ** parameter. If the value passed is SQLITE_TRANSIENT, then the ** string is copied into a (possibly existing) buffer managed by the ** Mem structure. Otherwise, any existing buffer is freed and the ** pointer copied. ** ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH ** size limit) then no memory allocation occurs.  If the string can be ** stored without allocating memory, then it is.  If a memory allocation ** is required to store the string, then value of pMem is unchanged.  In ** either case, SQLITE_TOOBIG is returned. */SQLITE_PRIVATE int sqlite3VdbeMemSetStr(                                        Mem *pMem,          /* Memory cell to set to string value */                                        const char *z,      /* String pointer */                                        int n,              /* Bytes in string, or negative */                                        u8 enc,             /* Encoding of z.  0 for BLOBs */                                        void (*xDel)(void*) /* Destructor function */){    int nByte = n;      /* New value for pMem->n */    int iLimit;         /* Maximum allowed string or blob size */    u16 flags = 0;      /* New value for pMem->flags */        assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );    assert( (pMem->flags & MEM_RowSet)==0 );        /* If z is a NULL pointer, set pMem to contain an SQL NULL. */    if( !z ){        sqlite3VdbeMemSetNull(pMem);        return SQLITE_OK;    }        if( pMem->db ){        iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];    }else{        iLimit = SQLITE_MAX_LENGTH;    }    flags = (enc==0?MEM_Blob:MEM_Str);    if( nByte<0 ){        assert( enc!=0 );        if( enc==SQLITE_UTF8 ){            for(nByte=0; nByte<=iLimit && z[nByte]; nByte++){}        }else{            for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}        }        flags |= MEM_Term;    }        /* The following block sets the new values of Mem.z and Mem.xDel. It     ** also sets a flag in local variable "flags" to indicate the memory     ** management (one of MEM_Dyn or MEM_Static).     */    if( xDel==SQLITE_TRANSIENT ){        int nAlloc = nByte;        if( flags&MEM_Term ){            nAlloc += (enc==SQLITE_UTF8?1:2);        }        if( nByte>iLimit ){            return SQLITE_TOOBIG;        }        if( sqlite3VdbeMemGrow(pMem, nAlloc, 0) ){            return SQLITE_NOMEM;        }        memcpy(pMem->z, z, nAlloc);    }else if( xDel==SQLITE_DYNAMIC ){        sqlite3VdbeMemRelease(pMem);        pMem->zMalloc = pMem->z = (char *)z;        pMem->xDel = 0;    }else{        sqlite3VdbeMemRelease(pMem);        pMem->z = (char *)z;        pMem->xDel = xDel;        flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);    }        pMem->n = nByte;    pMem->flags = flags;    pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);    pMem->type = (enc==0 ? SQLITE_BLOB : SQLITE_TEXT);    #ifndef SQLITE_OMIT_UTF16    if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){        return SQLITE_NOMEM;    }#endif        if( nByte>iLimit ){        return SQLITE_TOOBIG;    }        return SQLITE_OK;}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:95,


示例25: sqlite3VdbeMemRealify

/*** Convert pMem so that it is of type MEM_Real.** Invalidate any prior representations.*/int sqlite3VdbeMemRealify(Mem *pMem){  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );  pMem->r = sqlite3VdbeRealValue(pMem);  setTypeFlag(pMem, MEM_Real);  return SQLITE_OK;}
开发者ID:Jacob-jiangbo,项目名称:my-test,代码行数:10,


示例26: sqlite3BtreeEnter

/*** Enter a mutex on the given BTree object.** 在给定的B树对象上输入一个互斥锁。** If the object is not sharable, then no mutex is ever required** and this routine is a no-op.  The underlying mutex is non-recursive.** But we keep a reference count in Btree.wantToLock so the behavior** of this interface is recursive.**** To avoid deadlocks, multiple Btrees are locked in the same order** by all database connections.  The p->pNext is a list of other** Btrees belonging to the same database connection as the p Btree** which need to be locked after p.  If we cannot get a lock on** p, then first unlock all of the others on p->pNext, then wait** for the lock to become available on p, then relock all of the** subsequent Btrees that desire a lock.** 如果对象不可共享,那么不需要互斥锁并且这个程序是无操作的。这个潜在的互斥锁是非递归的。** 但是在Btree.wantToLock中保持对参数的计数,因此这歌接口的操作是递归的。** ** 为了避免死锁,多个btree以相同的顺序被所有数据库连接锁定。p->pNext是其他属于相同数据库连接的B树列表** 作为B树p,p->pNext需要在p后被锁。如果在p上不能的锁,那么首先在p->pNext上解除其他所有锁,然后等待** 直到在p上的锁可用,接着对需要加锁的所有后续B树重新加锁。*/void sqlite3BtreeEnter(Btree *p){  Btree *pLater;  /* Some basic sanity checking on the Btree.  The list of Btrees  ** connected by pNext and pPrev should be in sorted order by  ** Btree.pBt value. All elements of the list should belong to  ** the same connection. Only shared Btrees are on the list.   ** 在B树上进行基本的完整性检查。通过pNext和pPrev连接的B树列表应该  ** 按Btree.pBt的值进行排序。列表的所有元素都应属于相同的连接。只有共享的B树在列表中。  */  assert( p->pNext==0 || p->pNext->pBt>p->pBt );  assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );  assert( p->pNext==0 || p->pNext->db==p->db );  assert( p->pPrev==0 || p->pPrev->db==p->db );  assert( p->sharable || (p->pNext==0 && p->pPrev==0) );  /* Check for locking consistency 检查锁的一致性*/  assert( !p->locked || p->wantToLock>0 );  assert( p->sharable || p->wantToLock==0 );  /* We should already hold a lock on the database connection 在数据库连接上应该已经持有一个锁*/  assert( sqlite3_mutex_held(p->db->mutex) );  /* Unless the database is sharable and unlocked, then BtShared.db  ** should already be set correctly.   ** 如果数据库是可共享的并且没有被锁,那么BtShared.db应该已经被正确设置。  */  assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );  if( !p->sharable ) return;  p->wantToLock++;  if( p->locked ) return;  /* In most cases, we should be able to acquire the lock we  ** want without having to go throught the ascending lock  ** procedure that follows.  Just be sure not to block.  ** 在大多数情况下,我们应该能得到锁,我们想要的这个锁不必通过追溯在其后的锁进程。只是对块不确定。  */  if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){    p->pBt->db = p->db;    p->locked = 1;    return;  }  /* To avoid deadlock, first release all locks with a larger  ** BtShared address.  Then acquire our lock.  Then reacquire  ** the other BtShared locks that we used to hold in ascending  ** order.  ** 为了避免死锁,首先释放所有更大BtShared地址的锁。然后获得我们的锁。  ** 接着再次获取我们曾在提升顺序中持有的其他锁。  */  for(pLater=p->pNext; pLater; pLater=pLater->pNext){    assert( pLater->sharable );    assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );    assert( !pLater->locked || pLater->wantToLock>0 );    if( pLater->locked ){      unlockBtreeMutex(pLater);    }  }  lockBtreeMutex(p);  for(pLater=p->pNext; pLater; pLater=pLater->pNext){    if( pLater->wantToLock ){      lockBtreeMutex(pLater);    }  }}
开发者ID:PengJi,项目名称:Sqlite3.07.14,代码行数:88,


示例27: assert

/*** Return a block of memory of at least nBytes in size.** Return NULL if unable.*/static void *memsys3Malloc(int nByte){  int i;  int nBlock;  int toFree;  assert( sqlite3_mutex_held(mem.mutex) );  assert( sizeof(Mem3Block)==8 );  if( nByte<=0 ){    nBlock = 2;  }else{    nBlock = (nByte + 15)/8;  }  assert( nBlock >= 2 );  /* STEP 1:  ** Look for an entry of the correct size in either the small  ** chunk table or in the large chunk hash table.  This is  ** successful most of the time (about 9 times out of 10).  */  if( nBlock <= MX_SMALL ){    i = mem.aiSmall[nBlock-2];    if( i>0 ){      memsys3UnlinkFromList(i, &mem.aiSmall[nBlock-2]);      return memsys3Checkout(i, nBlock);    }  }else{    int hash = nBlock % N_HASH;    for(i=mem.aiHash[hash]; i>0; i=mem.aPool[i].u.list.next){      if( mem.aPool[i-1].u.hdr.size==nBlock ){        memsys3UnlinkFromList(i, &mem.aiHash[hash]);        return memsys3Checkout(i, nBlock);      }    }  }  /* STEP 2:  ** Try to satisfy the allocation by carving a piece off of the end  ** of the master chunk.  This step usually works if step 1 fails.  */  if( mem.szMaster>=nBlock ){    return memsys3FromMaster(nBlock);  }  /* STEP 3:    ** Loop through the entire memory pool.  Coalesce adjacent free  ** chunks.  Recompute the master chunk as the largest free chunk.  ** Then try again to satisfy the allocation by carving a piece off  ** of the end of the master chunk.  This step happens very  ** rarely (we hope!)  */  for(toFree=nBlock*16; toFree<SQLITE_MEMORY_SIZE*2; toFree *= 2){    memsys3OutOfMemory(toFree);    if( mem.iMaster ){      memsys3Link(mem.iMaster);      mem.iMaster = 0;      mem.szMaster = 0;    }    for(i=0; i<N_HASH; i++){      memsys3Merge(&mem.aiHash[i]);    }    for(i=0; i<MX_SMALL-1; i++){      memsys3Merge(&mem.aiSmall[i]);    }    if( mem.szMaster ){      memsys3Unlink(mem.iMaster);      if( mem.szMaster>=nBlock ){        return memsys3FromMaster(nBlock);      }    }  }  /* If none of the above worked, then we fail. */  return 0;}
开发者ID:soubok,项目名称:libset,代码行数:79,


示例28: createCollation

/*** Create a new collating function for database "db".  The name is zName** and the encoding is enc.*/static int createCollation(  sqlite3* db,   const char *zName,   int enc,   void* pCtx,  int(*xCompare)(void*,int,const void*,int,const void*),  void(*xDel)(void*)){  CollSeq *pColl;  int enc2;    if( sqlite3SafetyCheck(db) ){    return SQLITE_MISUSE;  }  assert( sqlite3_mutex_held(db->mutex) );  /* If SQLITE_UTF16 is specified as the encoding type, transform this  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.  */  enc2 = enc & ~SQLITE_UTF16_ALIGNED;  if( enc2==SQLITE_UTF16 ){    enc2 = SQLITE_UTF16NATIVE;  }  if( (enc2&~3)!=0 ){    sqlite3Error(db, SQLITE_ERROR, "unknown encoding");    return SQLITE_ERROR;  }  /* Check if this call is removing or replacing an existing collation   ** sequence. If so, and there are active VMs, return busy. If there  ** are no active VMs, invalidate any pre-compiled statements.  */  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 0);  if( pColl && pColl->xCmp ){    if( db->activeVdbeCnt ){      sqlite3Error(db, SQLITE_BUSY,         "Unable to delete/modify collation sequence due to active statements");      return SQLITE_BUSY;    }    sqlite3ExpirePreparedStatements(db);    /* If collation sequence pColl was created directly by a call to    ** sqlite3_create_collation, and not generated by synthCollSeq(),    ** then any copies made by synthCollSeq() need to be invalidated.    ** Also, collation destructor - CollSeq.xDel() - function may need    ** to be called.    */     if( (pColl->enc & ~SQLITE_UTF16_ALIGNED)==enc2 ){      CollSeq *aColl = (CollSeq*)sqlite3HashFind(&db->aCollSeq, zName, strlen(zName));      int j;      for(j=0; j<3; j++){        CollSeq *p = &aColl[j];        if( p->enc==pColl->enc ){          if( p->xDel ){            p->xDel(p->pUser);          }          p->xCmp = 0;        }      }    }  }  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 1);  if( pColl ){    pColl->xCmp = xCompare;    pColl->pUser = pCtx;    pColl->xDel = xDel;    pColl->enc = enc2 | (enc & SQLITE_UTF16_ALIGNED);  }  sqlite3Error(db, SQLITE_OK, 0);  return SQLITE_OK;}
开发者ID:guange2015,项目名称:sqlite-for-symbian,代码行数:78,


示例29: sqlite3_result_double

SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){    assert( sqlite3_mutex_held(pCtx->s.db->mutex) );    sqlite3VdbeMemSetDouble(&pCtx->s, rVal);}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:4,



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


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