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

📄 capi3ref.html

📁 嵌入式数据库sqlite 3.5.9的文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</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_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 sqlite3_vfs objects 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 field 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 wouldalso be no-ops, and any attempt to read the journal would returnSQLITE_IOERR.  Or the implementation might recognize that a databasefile will be doing page-aligned sector reads and writes in a randomorder and 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 are 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 bytes 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 causes the calling thread to sleep for atleast the number of microseconds given.  The xCurrentTime()method returns a Julian Day Number for the current date andtime.</p><hr><a name="sqlite3_aggregate_context"></a><h2>Obtain Aggregate Function Context</h2><blockquote><pre>void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);</pre></blockquote><p>The implementation of aggregate SQL functions use this routine to allocatea structure for storing their state.The first time the sqlite3_aggregate_context() routine isis called for a particular aggregate, SQLite allocates nBytes of memoryzeros that memory, and returns a pointer to it.On second and subsequent calls to sqlite3_aggregate_context()for the same aggregate function index, the same buffer is returned.The implementationof the aggregate can use the returned buffer to accumulate data.</p><p>SQLite automatically frees the allocated buffer when the aggregatequery concludes.</p><p>The first parameter should be a copy of the<a href="#sqlite3_context">SQL function context</a> that is the firstparameter to the callback routine that implements the aggregatefunction.</p><p>This routine must be called from the same thread in whichthe aggregate SQL function is running.</p><p><h3>Invariants:</h3><table border="0" cellpadding="5" cellspacing="0"><tr><td valign="top">F16211</td> <td valign="top">The first invocation of <a href="#sqlite3_aggregate_context">sqlite3_aggregate_context(C,N)</a> fora particular instance of an aggregate function (for a particularcontext C) causes SQLite to allocation N bytes of memory,zero that memory, and return a pointer to the allocationedmemory.</td></tr><tr><td valign="top">F16213</td> <td valign="top">If a memory allocation error occurs during<a href="#sqlite3_aggregate_context">sqlite3_aggregate_context(C,N)</a> then the function returns 0.</td></tr><tr><td valign="top">F16215</td> <td valign="top">Second and subsequent invocations of<a href="#sqlite3_aggregate_context">sqlite3_aggregate_context(C,N)</a> for the same context pointer Cignore the N parameter and return a pointer to the sameblock of memory returned by the first invocation.</td></tr><tr><td valign="top">F16217</td> <td valign="top">The memory allocated by <a href="#sqlite3_aggregate_context">sqlite3_aggregate_context(C,N)</a> isautomatically freed on the next call to <a href="#sqlite3_reset">sqlite3_reset()</a>or <a href="#sqlite3_finalize">sqlite3_finalize()</a> for the <a href="#sqlite3_stmt">prepared statement</a> containingthe aggregate function associated with context C.</td></tr></table></p><hr><a name="sqlite3_auto_extension"></a><h2>Make Arrangements To Automatically Load An Extension</h2><blockquote><pre>int sqlite3_auto_extension(void *xEntryPoint);</pre></blockquote><p> This functionregisters an extension entry point that is automatically invokedwhenever a new database connection is opened using<a href="#sqlite3_open">sqlite3_open()</a>, <a href="#sqlite3_open">sqlite3_open16()</a>, or <a href="#sqlite3_open">sqlite3_open_v2()</a>.</p><p>This API can be invoked at program startup in order to registerone or more statically linked extensions that will be availableto all new database connections.</p><p> Duplicate extensions are detected so calling this routine multipletimes with the same extension is harmless.</p><p> This routine stores a pointer to the extension in an arraythat is obtained from sqlite_malloc(). If you run a memory leakchecker on your program and it reports a leak because of thisarray, then invoke <a href="#sqlite3_reset_auto_extension">sqlite3_reset_auto_extension()</a> priorto shutdown to free the memory.</p><p> Automatic extensions apply across all threads.</p><p>This interface is experimental and is subject to change orremoval in future releases of SQLite.</p><hr><a name="sqlite3_bind_parameter_count"></a><h2>Number Of SQL Parameters</h2><blockquote><pre>int sqlite3_bind_parameter_count(sqlite3_stmt*);</pre></blockquote><p>This routine can be used to find the number of SQL parametersin a prepared statement.  SQL parameters are tokens of theform "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve asplace-holders for values that are <a href="#sqlite3_bind_blob">bound</a>to the parameters at a later time.</p><p>This routine actually returns the index of the largest parameter.For all forms except ?NNN, this will correspond to the number ofunique parameters.  If parameters of the ?NNN are used, there maybe gaps in the list.</p><p>See also: <a href="#sqlite3_bind_blob">sqlite3_bind()</a>,<a href="#sqlite3_bind_parameter_name">sqlite3_bind_parameter_name()</a>, and<a href="#sqlite3_bind_parameter_index">sqlite3_bind_parameter_index()</a>.</p><p><h3>Invariants:</h3><table border="0" cellpadding="5" cellspacing="0"><tr><td valign="top">F13601</td> <td valign="top">The <a href="#sqlite3_bind_parameter_count">sqlite3_bind_parameter_count(S)</a> interface returnsthe largest index of all SQL parameters in the<a href="#sqlite3_stmt">prepared statement</a> S, or 0 if Scontains no SQL parameters.</td></tr></table></p><hr><a name="sqlite3_bind_parameter_index"></a><h2>Index Of A Parameter With A Given Name</h2><blockquote><pre>int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);</pre></blockquote><p>Return the index of an SQL parameter given its name.  Theindex value returned is suitable for use as the secondparameter to <a href="#sqlite3_bind_blob">sqlite3_bind()</a>.  A zerois returned if no matching parameter is found.  The parametername must be given in UTF-8 even if the original statementwas prepared from UTF-16 text using <a href="#sqlite3_prepare">sqlite3_prepare16_v2()</a>.</p><p>See also: <a href="#sqlite3_bind_blob">sqlite3_bind()</a>,<a href="#sqlite3_bind_parameter_count">sqlite3_bind_parameter_count()</a>, and<a href="#sqlite3_bind_parameter_index">sqlite3_bind_parameter_index()</a>.</p>

⌨️ 快捷键说明

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