⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capi3ref.html

📁 这是sqlite3.56的文档。拿来给大家阅读使用
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</pre></blockquote><p>An instance of the following opaque structure is used torepresent an blob-handle.  A blob-handle is created by<a href="#sqlite3_blob_open">sqlite3_blob_open()</a> and destroyed by <a href="#sqlite3_blob_close">sqlite3_blob_close()</a>.The <a href="#sqlite3_blob_read">sqlite3_blob_read()</a> and <a href="#sqlite3_blob_write">sqlite3_blob_write()</a> interfacescan be used to read or write small subsections of the blob.The <a href="#sqlite3_blob_bytes">sqlite3_blob_bytes()</a> interface returns the size of theblob in bytes.</p><hr><a name="sqlite3_context"></a><h2>SQL Function Context Object</h2><blockquote><pre>typedef struct sqlite3_context sqlite3_context;</pre></blockquote><p>The context in which an SQL function executes is stored in ansqlite3_context object.  A pointer to an sqlite3_contextobject is always first parameter to application-defined SQL functions.</p><hr><a name="sqlite3_file"></a><h2>OS Interface Open File Handle</h2><blockquote><pre>typedef struct sqlite3_file sqlite3_file;struct sqlite3_file {  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */};</pre></blockquote><p>An <a href="#sqlite3_file">sqlite3_file</a> object represents an open file in the OSinterface layer.  Individual OS interface implementations willwant to subclass this object by appending additional fieldsfor their own use.  The pMethods entry is a pointer to an<a href="#sqlite3_io_methods">sqlite3_io_methods</a> object that defines methods for performingI/O operations on the open file.</p><hr><a name="sqlite3_io_methods"></a><h2>OS Interface File Virtual Methods Object</h2><blockquote><pre>typedef struct sqlite3_io_methods sqlite3_io_methods;struct sqlite3_io_methods {  int iVersion;  int (*xClose)(sqlite3_file*);  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);  int (*xSync)(sqlite3_file*, int flags);  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);  int (*xLock)(sqlite3_file*, int);  int (*xUnlock)(sqlite3_file*, int);  int (*xCheckReservedLock)(sqlite3_file*);  int (*xFileControl)(sqlite3_file*, int op, void *pArg);  int (*xSectorSize)(sqlite3_file*);  int (*xDeviceCharacteristics)(sqlite3_file*);  /* Additional methods may be added in future releases */};</pre></blockquote><p>Every file opened by the <a href="#sqlite3_vfs">sqlite3_vfs</a> xOpen method contains a pointer toan instance of the this object.  This object defines themethods used to perform various operations against the open file.</p><p>The flags argument to xSync may be one of <a href="#SQLITE_SYNC_DATAONLY">SQLITE_SYNC_NORMAL</a> or<a href="#SQLITE_SYNC_DATAONLY">SQLITE_SYNC_FULL</a>.  The first choice is the normal fsync().OS-X style fullsync.  The SQLITE_SYNC_DATA flag may be ORed in toindicate that only the data of the file and not its inode needs to besynced.</p><p>The integer values to xLock() and xUnlock() are one of<ul><li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_NONE</a>,<li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_SHARED</a>,<li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_RESERVED</a>,<li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_PENDING</a>, or<li> <a href="#SQLITE_LOCK_EXCLUSIVE">SQLITE_LOCK_EXCLUSIVE</a>.</ul>xLock() increases the lock. xUnlock() decreases the lock.The xCheckReservedLock() method looksto see if any database connection, either in thisprocess or in some other process, is holding an RESERVED,PENDING, or EXCLUSIVE lock on the file.  It returns trueif such a lock exists and false if not.</p><p>The xFileControl() method is a generic interface that allows customVFS implementations to directly control an open file using the<a href="#sqlite3_file_control">sqlite3_file_control()</a> interface.  The second "op" argumentis an integer opcode.   The thirdargument is a generic pointer which is intended to be a pointerto a structure that may contain arguments or space in which towrite return values.  Potential uses for xFileControl() might befunctions to enable blocking locks with timeouts, to change thelocking strategy (for example to use dot-file locks), to inquireabout the status of a lock, or to break stale locks.  The SQLitecore reserves opcodes less than 100 for its own use.A <a href="#SQLITE_FCNTL_LOCKSTATE">list of opcodes</a> less than 100 is available.Applications that define a custom xFileControl method should use opcodesgreater than 100 to avoid conflicts.</p><p>The xSectorSize() method returns the sector size of thedevice that underlies the file.  The sector size is theminimum write that can be performed without disturbingother bytes in the file.  The xDeviceCharacteristics()method returns a bit vector describing behaviors of theunderlying device:</p><p><ul><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC512</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC1K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC2K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC4K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC8K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC16K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC32K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_ATOMIC64K</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_SAFE_APPEND</a><li> <a href="#SQLITE_IOCAP_ATOMIC">SQLITE_IOCAP_SEQUENTIAL</a></ul></p><p>The SQLITE_IOCAP_ATOMIC property means that all writes ofany size are atomic.  The SQLITE_IOCAP_ATOMICnnn valuesmean that writes of blocks that are nnn bytes in size andare aligned to an address which is an integer multiple ofnnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value meansthat when data is appended to a file, the data is appendedfirst then the size of the file is extended, never the otherway around.  The SQLITE_IOCAP_SEQUENTIAL property means thatinformation is written to disk in the same order as callsto xWrite().</p><hr><a name="sqlite3_mutex"></a><h2>Mutex Handle</h2><blockquote><pre>typedef struct sqlite3_mutex sqlite3_mutex;</pre></blockquote><p>The mutex module within SQLite defines <a href="#sqlite3_mutex">sqlite3_mutex</a> to be anabstract type for a mutex object.  The SQLite core never looksat the internal representation of an <a href="#sqlite3_mutex">sqlite3_mutex</a>.  It onlydeals with pointers to the <a href="#sqlite3_mutex">sqlite3_mutex</a> object.</p><p>Mutexes are created using <a href="#sqlite3_mutex_alloc">sqlite3_mutex_alloc()</a>.</p><hr><a name="sqlite3_temp_directory"></a><h2>Name Of The Folder Holding Temporary Files</h2><blockquote><pre>SQLITE_EXTERN char *sqlite3_temp_directory;</pre></blockquote><p>If this global variable is made to point to a string which isthe name of a folder (a.ka. directory), then all temporary filescreated by SQLite will be placed in that directory.  If this variableis NULL pointer, then SQLite does a search for an appropriate temporaryfile directory.</p><p>It is not safe to modify this variable once a database connectionhas been opened.  It is intended that this variable be set onceas part of process initialization and before any SQLite interfaceroutines have been call and remain unchanged thereafter.</p><hr><a name="sqlite3_value"></a><h2>Dynamically Typed Value Object</h2><blockquote><pre>typedef struct Mem sqlite3_value;</pre></blockquote><p>SQLite uses the sqlite3_value object to represent all valuesthat are or can be stored in a database table.SQLite uses dynamic typing for the values it stores.Values stored in sqlite3_value objects can bebe integers, floating point values, strings, BLOBs, or NULL.</p><hr><a name="sqlite3_vfs"></a><h2>OS Interface Object</h2><blockquote><pre>typedef struct sqlite3_vfs sqlite3_vfs;struct sqlite3_vfs {  int iVersion;            /* Structure version number */  int szOsFile;            /* Size of subclassed sqlite3_file */  int mxPathname;          /* Maximum file pathname length */  sqlite3_vfs *pNext;      /* Next registered VFS */  const char *zName;       /* Name of this virtual file system */  void *pAppData;          /* Pointer to application-specific data */  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,               int flags, int *pOutFlags);  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags);  int (*xGetTempname)(sqlite3_vfs*, int nOut, char *zOut);  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);  void *(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol);  void (*xDlClose)(sqlite3_vfs*, void*);  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);  int (*xSleep)(sqlite3_vfs*, int microseconds);  int (*xCurrentTime)(sqlite3_vfs*, double*);  /* New fields may be appended in figure versions.  The iVersion  ** value will increment whenever this happens. */};</pre></blockquote><p>An instance of this object defines the interface between theSQLite core and the underlying operating system.  The "vfs"in the name of the object stands for "virtual file system".</p><p>The iVersion field is initially 1 but may be larger for futureversions of SQLite.  Additional fields may be appended to thisobject when the iVersion value is increased.</p><p>The szOsFile field is the size of the subclassed <a href="#sqlite3_file">sqlite3_file</a>structure used by this VFS.  mxPathname is the maximum length ofa pathname in this VFS.</p><p>Registered vfs modules are kept on a linked list formed bythe pNext pointer.  The <a href="#sqlite3_vfs_find">sqlite3_vfs_register()</a>and <a href="#sqlite3_vfs_find">sqlite3_vfs_unregister()</a> interfaces manage this listin a thread-safe way.  The <a href="#sqlite3_vfs_find">sqlite3_vfs_find()</a> interfacesearches the list.</p><p>The pNext field is the only fields in the sqlite3_vfsstructure that SQLite will ever modify.  SQLite will only accessor modify this field while holding a particular static mutex.The application should never modify anything within the sqlite3_vfsobject once the object has been registered.</p><p>The zName field holds the name of the VFS module.  The name mustbe unique across all VFS modules.</p><p> SQLite will guarantee that the zFilename string passed toxOpen() is a full pathname as generated by xFullPathname() andthat the string will be valid and unchanged until xClose() iscalled. So the <a href="#sqlite3_file">sqlite3_file</a> can store a pointer to thefilename if it needs to remember the filename for some reason.</p><p> The flags argument to xOpen() includes all bits set inthe flags argument to <a href="#sqlite3_open">sqlite3_open_v2()</a>.  Or if <a href="#sqlite3_open">sqlite3_open()</a>or <a href="#sqlite3_open">sqlite3_open16()</a> is used, then flags includes at least<a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_READWRITE</a> | <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_CREATE</a>.If xOpen() opens a file read-only then it sets *pOutFlags toinclude <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_READONLY</a>.  Other bits in *pOutFlags may beset.</p><p> SQLite will also add one of the following flags to the xOpen()call, depending on the object being opened:</p><p><ul><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_MAIN_DB</a><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_MAIN_JOURNAL</a><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_TEMP_DB</a><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_TEMP_JOURNAL</a><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_TRANSIENT_DB</a><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_SUBJOURNAL</a><li>  <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_MASTER_JOURNAL</a></ul></p><p>The file I/O implementation can use the object type flags tochanges the way it deals with files.  For example, an applicationthat does not care about crash recovery or rollback, might makethe open of a journal file a no-op.  Writes to this journal arealso a no-op.  Any attempt to read the journal return SQLITE_IOERR.Or the implementation might recognize the a database file willbe doing page-aligned sector reads and writes in a random orderand set up its I/O subsystem accordingly.</p><p>SQLite might also add one of the following flags to the xOpenmethod:</p><p><ul><li> <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_DELETEONCLOSE</a><li> <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_EXCLUSIVE</a></ul></p><p> The <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_DELETEONCLOSE</a> flag means the file should bedeleted when it is closed. The <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_DELETEONCLOSE</a>will be set for TEMP  databases, journals and for subjournals. The <a href="#SQLITE_OPEN_CREATE">SQLITE_OPEN_EXCLUSIVE</a> flag means the file should be openedfor exclusive access.  This flag is set for all files exceptfor the main database file.</p><p> At least szOsFile bytes of memory is allocated by SQLiteto hold the  <a href="#sqlite3_file">sqlite3_file</a> structure passed as the thirdargument to xOpen.  The xOpen method does not have toallocate the structure; it should just fill it in.</p><p> The flags argument to xAccess() may be <a href="#SQLITE_ACCESS_EXISTS">SQLITE_ACCESS_EXISTS</a>to test for the existance of a file,or <a href="#SQLITE_ACCESS_EXISTS">SQLITE_ACCESS_READWRITE</a> to test to seeif a file is readable and writable, or <a href="#SQLITE_ACCESS_EXISTS">SQLITE_ACCESS_READ</a>to test to see if a file is at least readable. The file can be adirectory.</p><p> SQLite will always allocate at least mxPathname+1 byte forthe output buffers for xGetTempname and xFullPathname. The exactsize of the output buffer is also passed as a parameter to bothmethods. If the output buffer is not large enough, SQLITE_CANTOPENshould be returned. As this is handled as a fatal error by SQLite,vfs implementations should endeavor to prevent this by settingmxPathname to a sufficiently large value.</p><p>The xRandomness(), xSleep(), and xCurrentTime() interfacesare not strictly a part of the filesystem, but they areincluded in the VFS structure for completeness.The xRandomness() function attempts to return nBytes bytesof good-quality randomness into zOut.  The return value isthe actual number of bytes of randomness obtained.  ThexSleep() method cause the calling thread to sleep for atleast the number of microseconds given.  The xCurrentTime()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -