本文整理汇总了C#中Community.CsharpSqlite.Pager类的典型用法代码示例。如果您正苦于以下问题:C# Pager类的具体用法?C# Pager怎么用?C# Pager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pager类属于Community.CsharpSqlite命名空间,在下文中一共展示了Pager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Clear
public void Clear()
{
sqlite3_free(ref this.pData);
this.pData = null;
this.pExtra = null;
this.pDirty = null;
this.pgno = 0;
this.pPager = null;
#if SQLITE_CHECK_PAGES
this.pageHash=0;
#endif
this.flags = 0;
this.nRef = 0;
this.pCache = null;
this.pDirtyNext = null;
this.pDirtyPrev = null;
this.pPgHdr1 = null;
}
开发者ID:arissetyawan,项目名称:rhodes,代码行数:18,代码来源:pcache_h.cs
示例2: sqlite3PagerOpenSavepoint
/*
** Check that there are at least nSavepoint savepoints open. If there are
** currently less than nSavepoints open, then open one or more savepoints
** to make up the difference. If the number of savepoints is already
** equal to nSavepoint, then this function is a no-op.
**
** If a memory allocation fails, SQLITE_NOMEM is returned. If an error
** occurs while opening the sub-journal file, then an IO error code is
** returned. Otherwise, SQLITE_OK.
*/
static int sqlite3PagerOpenSavepoint( Pager pPager, int nSavepoint )
{
int rc = SQLITE_OK; /* Return code */
int nCurrent = pPager.nSavepoint; /* Current number of savepoints */
if ( nSavepoint > nCurrent && pPager.useJournal != 0 )
{
int ii; /* Iterator variable */
PagerSavepoint[] aNew; /* New Pager.aSavepoint array */
/* Either there is no active journal or the sub-journal is open or
** the journal is always stored in memory */
Debug.Assert( pPager.nSavepoint == 0 || isOpen( pPager.sjfd ) ||
pPager.journalMode == PAGER_JOURNALMODE_MEMORY );
/* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
** if the allocation fails. Otherwise, zero the new portion in case a
** malloc failure occurs while populating it in the for(...) loop below.
*/
//aNew = (PagerSavepoint *)sqlite3Realloc(
// pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint
//);
Array.Resize( ref pPager.aSavepoint, nSavepoint );
aNew = pPager.aSavepoint;
//if( null==aNew ){
// return SQLITE_NOMEM;
//}
// memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));
// pPager.aSavepoint = aNew;
pPager.nSavepoint = nSavepoint;
/* Populate the PagerSavepoint structures just allocated. */
for ( ii = nCurrent; ii < nSavepoint; ii++ )
{
Debug.Assert( pPager.dbSizeValid );
aNew[ii] = new PagerSavepoint();
aNew[ii].nOrig = pPager.dbSize;
if ( isOpen( pPager.jfd ) && ALWAYS( pPager.journalOff > 0 ) )
{
aNew[ii].iOffset = pPager.journalOff;
}
else
{
aNew[ii].iOffset = (int)JOURNAL_HDR_SZ( pPager );
}
aNew[ii].iSubRec = pPager.nSubRec;
aNew[ii].pInSavepoint = sqlite3BitvecCreate( pPager.dbSize );
if ( null == aNew[ii].pInSavepoint )
{
return SQLITE_NOMEM;
}
}
/* Open the sub-journal, if it is not already opened. */
rc = openSubJournal( pPager );
assertTruncateConstraint( pPager );
}
return rc;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:70,代码来源:pager_c.cs
示例3: CODEC2
//# define CODEC2(P,D,N,X,E,O) O=(char*)D
static bool CODEC2( Pager P, byte[] D, uint N, int X, ref byte[] O ) { O = D; return false; }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:2,代码来源:pager_c.cs
示例4: PAGERID
/*
** The following two macros are used within the PAGERTRACE() macros above
** to print out file-descriptors.
**
** PAGERID() takes a pointer to a Pager struct as its argument. The
** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file
** struct as its argument.
*/
//#define PAGERID(p) ((int)(p.fd))
static int PAGERID( Pager p )
{
return p.GetHashCode();
}
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:13,代码来源:pager_c.cs
示例5: sqlite3Pager_get_fd
static sqlite3_file sqlite3Pager_get_fd( Pager pPager )
{
return ( isOpen( pPager.fd ) ) ? pPager.fd : null;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:4,代码来源:crypto.cs
示例6: sqlite3pager_get_codec
/* BEGIN CRYPTO */
static void sqlite3pager_get_codec( Pager pPager, ref codec_ctx ctx )
{
ctx = pPager.pCodec;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:5,代码来源:crypto.cs
示例7: zeroJournalHdr
/*
** The journal file must be open when this function is called.
**
** This function is a no-op if the journal file has not been written to
** within the current transaction (i.e. if Pager.journalOff==0).
**
** If doTruncate is non-zero or the Pager.journalSizeLimit variable is
** set to 0, then truncate the journal file to zero bytes in size. Otherwise,
** zero the 28-byte header at the start of the journal file. In either case,
** if the pager is not in no-sync mode, sync the journal file immediately
** after writing or truncating it.
**
** If Pager.journalSizeLimit is set to a positive, non-zero value, and
** following the truncation or zeroing described above the size of the
** journal file in bytes is larger than this value, then truncate the
** journal file to Pager.journalSizeLimit bytes. The journal file does
** not need to be synced following this operation.
**
** If an IO error occurs, abandon processing and return the IO error code.
** Otherwise, return SQLITE_OK.
*/
static int zeroJournalHdr( Pager pPager, int doTruncate )
{
int rc = SQLITE_OK; /* Return code */
Debug.Assert( isOpen( pPager.jfd ) );
if ( pPager.journalOff != 0 )
{
i64 iLimit = pPager.journalSizeLimit; /* Local cache of jsl */
IOTRACE( "JZEROHDR %p\n", pPager );
if ( doTruncate != 0 || iLimit == 0 )
{
rc = sqlite3OsTruncate( pPager.jfd, 0 );
}
else
{
byte[] zeroHdr = new byte[28];// = {0};
rc = sqlite3OsWrite( pPager.jfd, zeroHdr, zeroHdr.Length, 0 );
}
if ( rc == SQLITE_OK && !pPager.noSync )
{
rc = sqlite3OsSync( pPager.jfd, SQLITE_SYNC_DATAONLY | pPager.sync_flags );
}
/* At this point the transaction is committed but the write lock
** is still held on the file. If there is a size limit configured for
** the persistent journal and the journal file currently consumes more
** space than that limit allows for, truncate it now. There is no need
** to sync the file following this operation.
*/
if ( rc == SQLITE_OK && iLimit > 0 )
{
i64 sz = 0;
rc = sqlite3OsFileSize( pPager.jfd, ref sz );
if ( rc == SQLITE_OK && sz > iLimit )
{
rc = sqlite3OsTruncate( pPager.jfd, iLimit );
}
}
}
return rc;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:62,代码来源:pager_c.cs
示例8: sqlite3PagerSetCodec
/*
** Set or retrieve the codec for this pager
*/
static void sqlite3PagerSetCodec(
Pager pPager,
dxCodec xCodec, //void *(*xCodec)(void*,void*,Pgno,int),
dxCodecSizeChng xCodecSizeChng, //void (*xCodecSizeChng)(void*,int,int),
dxCodecFree xCodecFree, //void (*xCodecFree)(void*),
codec_ctx pCodec
)
{
if ( pPager.xCodecFree != null ) pPager.xCodecFree( ref pPager.pCodec );
pPager.xCodec = (pPager.memDb!=0) ? null : xCodec;
pPager.xCodecSizeChng = xCodecSizeChng;
pPager.xCodecFree = xCodecFree;
pPager.pCodec = pCodec;
pagerReportSize( pPager );
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:18,代码来源:pager_c.cs
示例9: sqlite3PagerNosync
/*
** Return true if fsync() calls are disabled for this pager. Return FALSE
** if fsync()s are executed normally.
*/
static bool sqlite3PagerNosync( Pager pPager )
{
return pPager.noSync;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:8,代码来源:pager_c.cs
示例10: sqlite3PagerJournalname
/*
** Return the full pathname of the journal file.
*/
static string sqlite3PagerJournalname( Pager pPager )
{
return pPager.zJournal;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:7,代码来源:pager_c.cs
示例11: sqlite3PagerFile
/*
** Return the file handle for the database file associated
** with the pager. This might return NULL if the file has
** not yet been opened.
*/
static sqlite3_file sqlite3PagerFile( Pager pPager )
{
return pPager.fd;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:9,代码来源:pager_c.cs
示例12: sqlite3PagerVfs
/*
** Return the VFS structure for the pager.
*/
static sqlite3_vfs sqlite3PagerVfs( Pager pPager )
{
return pPager.pVfs;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:7,代码来源:pager_c.cs
示例13: sqlite3PagerFilename
/*
** Return the full pathname of the database file.
*/
static string sqlite3PagerFilename( Pager pPager )
{
return pPager.zFilename;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:7,代码来源:pager_c.cs
示例14: sqlite3PagerSavepoint
/*
** This function is called to rollback or release (commit) a savepoint.
** The savepoint to release or rollback need not be the most recently
** created savepoint.
**
** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.
** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with
** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes
** that have occurred since the specified savepoint was created.
**
** The savepoint to rollback or release is identified by parameter
** iSavepoint. A value of 0 means to operate on the outermost savepoint
** (the first created). A value of (Pager.nSavepoint-1) means operate
** on the most recently created savepoint. If iSavepoint is greater than
** (Pager.nSavepoint-1), then this function is a no-op.
**
** If a negative value is passed to this function, then the current
** transaction is rolled back. This is different to calling
** sqlite3PagerRollback() because this function does not terminate
** the transaction or unlock the database, it just restores the
** contents of the database to its original state.
**
** In any case, all savepoints with an index greater than iSavepoint
** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),
** then savepoint iSavepoint is also destroyed.
**
** This function may return SQLITE_NOMEM if a memory allocation fails,
** or an IO error code if an IO error occurs while rolling back a
** savepoint. If no errors occur, SQLITE_OK is returned.
*/
static int sqlite3PagerSavepoint( Pager pPager, int op, int iSavepoint )
{
int rc = SQLITE_OK;
Debug.Assert( op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK );
Debug.Assert( iSavepoint >= 0 || op == SAVEPOINT_ROLLBACK );
if ( iSavepoint < pPager.nSavepoint )
{
int ii; /* Iterator variable */
int nNew; /* Number of remaining savepoints after this op. */
/* Figure out how many savepoints will still be active after this
** operation. Store this value in nNew. Then free resources associated
** with any savepoints that are destroyed by this operation.
*/
nNew = iSavepoint + ((op == SAVEPOINT_RELEASE) ? 0 : 1);
for (ii = nNew; ii < pPager.nSavepoint; ii++)
{
sqlite3BitvecDestroy( ref pPager.aSavepoint[ii].pInSavepoint );
}
pPager.nSavepoint = nNew;
/* If this is a release of the outermost savepoint, truncate
** the sub-journal to zero bytes in size. */
if (op == SAVEPOINT_RELEASE)
{
if (nNew == 0 && isOpen(pPager.sjfd))
{
/* Only truncate if it is an in-memory sub-journal. */
if (sqlite3IsMemJournal(pPager.sjfd))
{
rc = sqlite3OsTruncate(pPager.sjfd, 0);
Debug.Assert(rc == SQLITE_OK);
}
pPager.nSubRec = 0;
}
}
/* Else this is a rollback operation, playback the specified savepoint.
** If this is a temp-file, it is possible that the journal file has
** not yet been opened. In this case there have been no changes to
** the database file, so the playback operation can be skipped.
*/
else if ( isOpen( pPager.jfd ) )
{
PagerSavepoint pSavepoint = ( nNew == 0 ) ? null : pPager.aSavepoint[nNew - 1];
rc = pagerPlaybackSavepoint( pPager, pSavepoint );
Debug.Assert( rc != SQLITE_DONE );
}
}
return rc;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:82,代码来源:pager_c.cs
示例15: journalHdrOffset
/*
** Return the offset of the sector boundary at or immediately
** following the value in pPager.journalOff, assuming a sector
** size of pPager.sectorSize bytes.
**
** i.e for a sector size of 512:
**
** Pager.journalOff Return value
** ---------------------------------------
** 0 0
** 512 512
** 100 512
** 2000 2048
**
*/
static i64 journalHdrOffset( Pager pPager )
{
i64 offset = 0;
i64 c = pPager.journalOff;
if ( c != 0 )
{
offset = (int)( ( ( c - 1 ) / pPager.sectorSize + 1 ) * pPager.sectorSize );//offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager);
}
Debug.Assert( offset % pPager.sectorSize == 0 ); //Debug.Assert(offset % JOURNAL_HDR_SZ(pPager) == 0);
Debug.Assert( offset >= c );
Debug.Assert( ( offset - c ) < pPager.sectorSize );//Debug.Assert( (offset-c)<JOURNAL_HDR_SZ(pPager) );
return offset;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:28,代码来源:pager_c.cs
示例16: seekJournalHdr
static void seekJournalHdr( Pager pPager )
{
pPager.journalOff = journalHdrOffset( pPager );
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:4,代码来源:pager_c.cs
示例17: sqlite3PagerGetCodec
static object sqlite3PagerGetCodec( Pager pPager )
{
return pPager.pCodec;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:4,代码来源:pager_c.cs
示例18: writeJournalHdr
/*
** The journal file must be open when this routine is called. A journal
** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the
** current location.
**
** The format for the journal header is as follows:
** - 8 bytes: Magic identifying journal format.
** - 4 bytes: Number of records in journal, or -1 no-sync mode is on.
** - 4 bytes: Random number used for page hash.
** - 4 bytes: Initial database page count.
** - 4 bytes: Sector size used by the process that wrote this journal.
** - 4 bytes: Database page size.
**
** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space.
*/
static int writeJournalHdr( Pager pPager )
{
int rc = SQLITE_OK; /* Return code */
byte[] zHeader = pPager.pTmpSpace; /* Temporary space used to build header */
u32 nHeader = (u32)pPager.pageSize; /* Size of buffer pointed to by zHeader */
u32 nWrite; /* Bytes of header sector written */
int ii; /* Loop counter */
Debug.Assert( isOpen( pPager.jfd ) ); /* Journal file must be open. */
if ( nHeader > JOURNAL_HDR_SZ( pPager ) )
{
nHeader = JOURNAL_HDR_SZ( pPager );
}
/* If there are active savepoints and any of them were created
** since the most recent journal header was written, update the
** PagerSavepoint.iHdrOffset fields now.
*/
for ( ii = 0; ii < pPager.nSavepoint; ii++ )
{
if ( pPager.aSavepoint[ii].iHdrOffset == 0 )
{
pPager.aSavepoint[ii].iHdrOffset = pPager.journalOff;
}
}
pPager.journalHdr = pPager.journalOff = journalHdrOffset( pPager );
/*
** Write the nRec Field - the number of page records that follow this
** journal header. Normally, zero is written to this value at this time.
** After the records are added to the journal (and the journal synced,
** if in full-sync mode), the zero is overwritten with the true number
** of records (see syncJournal()).
**
** A faster alternative is to write 0xFFFFFFFF to the nRec field. When
** reading the journal this value tells SQLite to assume that the
** rest of the journal file contains valid page records. This assumption
** is dangerous, as if a failure occurred whilst writing to the journal
** file it may contain some garbage data. There are two scenarios
** where this risk can be ignored:
**
** * When the pager is in no-sync mode. Corruption can follow a
** power failure in this case anyway.
**
** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees
** that garbage data is never appended to the journal file.
*/
Debug.Assert( isOpen( pPager.fd ) || pPager.noSync );
if ( ( pPager.noSync ) || ( pPager.journalMode == PAGER_JOURNALMODE_MEMORY )
|| ( sqlite3OsDeviceCharacteristics( pPager.fd ) & SQLITE_IOCAP_SAFE_APPEND ) != 0
)
{
aJournalMagic.CopyTo( zHeader, 0 );// memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));
put32bits( zHeader, aJournalMagic.Length, 0xffffffff );
}
else
{
Array.Clear( zHeader, 0, aJournalMagic.Length + 4 );//memset(zHeader, 0, sizeof(aJournalMagic)+4);
}
/* The random check-hash initialiser */
i64 i64Temp = 0;
sqlite3_randomness( sizeof( i64 ), ref i64Temp );
pPager.cksumInit = (u32)i64Temp;
put32bits( zHeader, aJournalMagic.Length + 4, pPager.cksumInit );
/* The initial database size */
put32bits( zHeader, aJournalMagic.Length + 8, pPager.dbOrigSize );
/* The assumed sector size for this process */
put32bits( zHeader, aJournalMagic.Length + 12, pPager.sectorSize );
/* The page size */
put32bits( zHeader, aJournalMagic.Length + 16, (u32)pPager.pageSize );
/* Initializing the tail of the buffer is not necessary. Everything
** works find if the following memset() is omitted. But initializing
** the memory prevents valgrind from complaining, so we are willing to
** take the performance hit.
*/
// memset(&zHeader[sizeof(aJournalMagic)+20], 0,
// nHeader-(sizeof(aJournalMagic)+20));
Array.Clear( zHeader, aJournalMagic.Length + 20, (int)nHeader - ( aJournalMagic.Length + 20 ) );
/* In theory, it is only necessary to write the 28 bytes that the
** journal header consumes to the journal file here. Then increment the
** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:pager_c.cs
示例19: sqlite3PagerMovepage
/*
** Move the page pPg to location pgno in the file.
**
** There must be no references to the page previously located at
** pgno (which we call pPgOld) though that page is allowed to be
** in cache. If the page previously located at pgno is not already
** in the rollback journal, it is not put there by by this routine.
**
** References to the page pPg remain valid. Updating any
** meta-data associated with pPg (i.e. data stored in the nExtra bytes
** allocated along with the page) is the responsibility of the caller.
**
** A transaction must be active when this routine is called. It used to be
** required that a statement transaction was not active, but this restriction
** has been removed (CREATE INDEX needs to move a page when a statement
** transaction is active).
**
** If the fourth argument, isCommit, is non-zero, then this page is being
** moved as part of a database reorganization just before the transaction
** is being committed. In this case, it is guaranteed that the database page
** pPg refers to will not be written to again within this transaction.
**
** This function may return SQLITE_NOMEM or an IO error code if an error
** occurs. Otherwise, it returns SQLITE_OK.
*/
static int sqlite3PagerMovepage( Pager pPager, DbPage pPg, u32 pgno, int isCommit )
{
PgHdr pPgOld; /* The page being overwritten. */
u32 needSyncPgno = 0; /* Old value of pPg.pgno, if sync is required */
int rc; /* Return code */
Pgno origPgno; /* The original page number */
Debug.Assert( pPg.nRef > 0 );
/* In order to be able to rollback, an in-memory database must journal
** the page we are moving from.
*/
if (
#if SQLITE_OMIT_MEMORYDB
1==MEMDB
#else
pPager.memDb != 0
#endif
)
{
rc = sqlite3PagerWrite( pPg );
if ( rc != 0 ) return rc;
}
/* If the page being moved is dirty and has not been saved by the latest
** savepoint, then save the current contents of the page into the
** sub-journal now. This is required to handle the following scenario:
**
** BEGIN;
** <journal page X, then modify it in memory>
** SAVEPOINT one;
** <Move page X to location Y>
** ROLLBACK TO one;
**
** If page X were not written to the sub-journal here, it would not
** be possible to restore its contents when the "ROLLBACK TO one"
** statement were is processed.
**
** subjournalPage() may need to allocate space to store pPg.pgno into
** one or more savepoint bitvecs. This is the reason this function
** may return SQLITE_NOMEM.
*/
if ( ( pPg.flags & PGHDR_DIRTY ) != 0
&& subjRequiresPage( pPg )
&& SQLITE_OK != ( rc = subjournalPage( pPg ) )
)
{
return rc;
}
PAGERTRACE( "MOVE %d page %d (needSync=%d) moves to %d\n",
PAGERID( pPager ), pPg.pgno, ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ? 1 : 0, pgno );
IOTRACE( "MOVE %p %d %d\n", pPager, pPg.pgno, pgno );
/* If the journal needs to be sync()ed before page pPg.pgno can
** be written to, store pPg.pgno in local variable needSyncPgno.
**
** If the isCommit flag is set, there is no need to remember that
** the journal needs to be sync()ed before database page pPg.pgno
** can be written to. The caller has already promised not to write to it.
*/
if ( ( ( pPg.flags & PGHDR_NEED_SYNC ) != 0 ) && 0 == isCommit )
{
needSyncPgno = pPg.pgno;
Debug.Assert( pageInJournal( pPg ) || pPg.pgno > pPager.dbOrigSize );
Debug.Assert( ( pPg.flags & PGHDR_DIRTY ) != 0 );
Debug.Assert( pPager.needSync );
}
/* If the cache contains a page with page-number pgno, remove it
** from its hash chain. Also, if the PgHdr.needSync was set for
** page pgno before the 'move' operation, it needs to be retained
** for the page moved there.
*/
pPg.flags &= ~PGHDR_NEED_SYNC;
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:pager_c.cs
示例20: sqlite3pager_is_mj_pgno
static int sqlite3pager_is_mj_pgno( Pager pPager, Pgno pgno )
{
return ( PAGER_MJ_PGNO( pPager ) == pgno ) ? 1 : 0;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:4,代码来源:crypto.cs
注:本文中的Community.CsharpSqlite.Pager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论