本文整理汇总了C#中Community.CsharpSqlite.Pager类的典型用法代码示例。如果您正苦于以下问题:C# Pager类的具体用法?C# Pager怎么用?C# Pager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pager类属于Community.CsharpSqlite命名空间,在下文中一共展示了Pager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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; }
示例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();
}
示例5: sqlite3Pager_get_fd
static sqlite3_file sqlite3Pager_get_fd( Pager pPager )
{
return ( isOpen( pPager.fd ) ) ? pPager.fd : null;
}
示例6: sqlite3pager_get_codec
/* BEGIN CRYPTO */
static void sqlite3pager_get_codec( Pager pPager, ref codec_ctx ctx )
{
ctx = pPager.pCodec;
}
示例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;
}
示例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 );
}
示例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;
}
示例10: sqlite3PagerJournalname
/*
** Return the full pathname of the journal file.
*/
static string sqlite3PagerJournalname( Pager pPager )
{
return pPager.zJournal;
}
示例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;
}
示例12: sqlite3PagerVfs
/*
** Return the VFS structure for the pager.
*/
static sqlite3_vfs sqlite3PagerVfs( Pager pPager )
{
return pPager.pVfs;
}
示例13: sqlite3PagerFilename
/*
** Return the full pathname of the database file.
*/
static string sqlite3PagerFilename( Pager pPager )
{
return pPager.zFilename;
}
示例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;
}
示例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;
}