📄 sysreq.html
字号:
<a name="S30000"></a><p> SQLite is designed to work well within embedded devices with very limited resources. To this end, it expects to confront situations where memory is unavailable and where I/O operations fail and it is designed to handle such situations with ease and grace. SQLite also avoids aggravating low-resource situations by correctly freeing rather than leaking resources it uses itself.</p><blockquote><b>S30000:</b> The SQLite library shall be safe for use in long-running, low-resource, high-reliability applications.</blockquote><a name="S30100"></a><p> A "Proper shutdown" means that all resources that the application has allocated from SQLite have been released by the application. The leak-free operation guarantee of SQLite applies even if there have been memory allocation errors or I/O errors during operation.</p><blockquote><b>S30100:</b> The SQLite library shall release all system resources it holds when it is properly shutdown.</blockquote><a name="S30200"></a><p> Safety-critical systems typically disallow the use of malloc() and free() because one never knows when they might fail due to memory fragmentation. However, SQLite makes extensive use of dynamic objects and so it must be able to allocate and deallocate memory to hold those objects.</p> <p>In order to be acceptable for use in safety critical systems, SQLite can be configured to use its own internal memory allocator which, subject to proper usage by the application, guarantees that memory allocation will never fail either due to memory fragmentation or any other cause. The proof of correctness is due to J. M. Robson: "Bounds for Some Functions Concerning Dynamic Storage Allocations", Journal of the ACM, Volume 21, Number 3, July 1974.</p> <p>The internal memory allocator is seeded with a large contiguous block of memory at application start. SQLite makes all of its internal memory allocations from this initial seed. The Robson proof depends on SQLite being coupled to a well-behaved application. The application must not try to use more than a precomputed fraction of the available memory - that fraction depending on the size ratio between the largest and smallest memory allocations. Additional details are provided elsewhere. For the purposes of this document, it is sufficient to state:</p><blockquote><b>S30200:</b> The SQLite library shall be configurable so that it is guaranteed to never fail a memory allocation as long as the application does not request resources in excess of reasonable and published limits.</blockquote><a name="S30210"></a><p> To help insure that an application never fails a memory allocation call, SQLite provides interfaces that can inform the application if its memory usage is growing close to or has exceeded the critical Robson limits. In practice, the memory used by an application can exceed the limits of the Robson proof by a wide margin with no harmful effect. There is plenty of safety margin. But the Robson proof does break down once the limits are exceeded and the guarantee that no memory allocation will fail is lost. Hence it is important to be able to track how close an application has come to reaching critical limits.</p><blockquote><b>S30210:</b> The SQLite library shall be provide instrumentation that can alert the application when its resource usages nears or exceeds the limits of the memory breakdown guarantee.</blockquote><a name="S30220"></a><p> When SQLite comes under memory pressure, it can be configured to recycle memory from one use to another, thus helping to reduce the pressure. "Memory pressure" means that memory available for allocation is becoming less plentiful. In a safety-critical application, memory pressure might mean that the amount of allocated memory is getting close to the point where the Robson proof breaks down. On a workstation, memory pressure might mean that available virtual memory is running low.</p><blockquote><b>S30220:</b> The SQLite library shall be provide facilities to automatically recycle memory when usage nears preset limits.</blockquote><a name="S30230"></a><p> SQLite provides the ability to read and write megabyte or gigabyte blobs and text strings without having to allocate enough memory to hold the entire blob and string in memory all at once. This enables SQLite to read and write BLOBs that are actually larger than the available memory on the device. It also helps reduce the size of the maximum memory allocation which helps keep memory usage below Robson limits and thus helps to guarantee failure-free memory allocation.</p><blockquote><b>S30230:</b> The SQLite library shall be permit BLOB and CLOB objects to be read and written incrementally using small memory buffers.</blockquote><a name="S30300"></a><p> Memory allocation problems do not cause SQLite to fail catastrophically. SQLite recognizes all memory allocation failures and either works around them, or cleanly aborts what it is doing and returns to the application with an error that indicates insufficient memory was available. Assuming new memory becomes available, SQLite is able to continue operating normally after a memory allocation failure.</p><blockquote><b>S30300:</b> When a memory allocation fails, SQLite shall either silently make due without the requested memory or else it shall report the error back to the application.</blockquote><a name="S30400"></a><p> SQLite responses sanely to disk I/O errors. If it is unable to work around the problem, SQLite might have to report the error back up to the application. In either case, SQLite is able to continue functioning, assuming of course that the I/O error was transient.</p><blockquote><b>S30400:</b> When a I/O operation fails, SQLite shall either silently recover or else it shall report the error back to the application.</blockquote><a name="S30500"></a><p> SQLite is able to cleanly abort an operation in progress and afterwards continue functioning normally without any memory or other resource leaks. An example of where this functionality is used occurs in the command-line interface (CLI) program for SQLite. If the user enters a query that has millions of result rows, those rows begin pouring out onto the screen. The operator can then hit the interrupt key sequence (which varies from one operating system to another but it often Control-C) which causes the query to be aborted.</p><blockquote><b>S30500:</b> SQLite shall provide the capability to monitor the progress and interrupt the evaluation of a long-running query.</blockquote><a name="S30600"></a><p> When information is deleted from an SQLite database, the default action is for SQLite to mark the space as unused and then to reuse the space at the next opportune INSERT. On devices where persistent storage is scarce, however, it is sometime desirable to return the unused space back to the operating system. SQLite supports this.</p><blockquote><b>S30600:</b> All unused portions of a well-formed SQLite database file shall be available for reuse.</blockquote><a name="S30700"></a><blockquote><b>S30700:</b> SQLite shall provide the capability to incrementally decrease the size of the persistent storage file as information is removed from the database.</blockquote><a name="S30800"></a><p> In consumer-grade software, it is often acceptable to run tests on an instrumented version of the code. But for high-reliability systems, it is better to test the code exactly as it is deployed. The saying at NASA is "test what you fly and fly what you test." In support of this goal, SQLite includes interfaces whose only purpose is to observe internal state and to place SQLite into internal states for the testing.</p><blockquote><b>S30800:</b> SQLite shall provide the interfaces that support testing and validation of the library code in an as-delivered configuration.</blockquote><a name="S30900"></a><p> On resource-constrained devices, it is desirable to get double-duty out of resources where possible.</p><blockquote><b>S30900:</b> SQLite shall provide the ability for separate database connections within the same process to share resources.</blockquote><h2>4.0 SQLite is safe to use in multi-thread and multi-processapplications.</h2><a name="S40000"></a><p> In nearly all modern digital systems, there are many things happening at once. And many of those things involve SQLite.</p><blockquote><b>S40000:</b> The SQLite library shall be safe for use in applications that make concurrent access to the underlying database from different threads and/or processes.</blockquote><a name="S40100"></a><p> The developers of SQLite believe that "thread-safe" is a self contradiction. No application that includes multiple threads of control within the same address space is every truly "safe". And yet it is recognized that many developers want to create multithreaded applications and to use SQLite in those applications. Therefore, SQLite is engineered to be "thread-safe".</p><blockquote><b>S40100:</b> The SQLite library shall be configurable to operate correctly in a multi-threaded application.</blockquote><a name="S40200"></a><p> Multiple database connections can be created and operated independently within the same thread or process.</p><blockquote><b>S40200:</b> The SQLite library shall support multiple independent database connections per thread and per process.</blockquote><a name="S40300"></a><p> SQLite uses both internal mutexes and external file locking to ensure that two or more threads or processes working on the same database file play nicely with one another.</p><blockquote><b>S40300:</b> The SQLite library shall automatically control access to common databases from different connections in different threads or processes.</blockquote><a name="S40400"></a><blockquote><b>S40400:</b> The SQLite library shall notify the application if an operation can not be completed due to concurrent access constraints.</blockquote><a name="S40410"></a><p> If an SQL statement cannot be completed because another process is holding a lock on the database, then the application needs to be able to take corrective action, such waiting for the lock to clear.</p><blockquote><b>S40410:</b> The SQLite library shall provide interfaces to assist the application in responding appropriately when an operation can not be completed due to concurrent access constraints.</blockquote><h2>5.0 SQLite is cross-platform</h2><a name="S50000"></a><p> Cross-platform in this context means that the SQLite can be used on a wide variety of operating systems and processors, ranging from small, special-purpose embedded systems, to workstations, to servers. Platforms can be 32- or 64-bit, big-endian or little-endian. Cross-platform refers to the source code. Obviously the SQLite would need to be recompiled in order to run on processors with different instruction sets.</p><blockquote><b>S50000:</b> The SQLite library shall be cross-platform.</blockquote><a name="S50100"></a><p> C has been called the "universal assembly language". Nearly all computer systems accept code written in C. Thus, to help make SQLite cross-platform:</p><blockquote><b>S50100:</b> The SQLite library shall be implemented in ANSI-C.</blockquote><a name="S50200"></a><p> SQLite stores text data as unicode. Three separate unicode representations are allowed:</p><blockquote><b>S50200:</b> The SQLite library shall support text encoded as UTF-8, UTF-16le, or UTF-16be.</blockquote><a name="S50300"></a><p> An SQLite database file can be freely moved between machine with different operating systems, different processors, different size integers, and different byte orders. The same database file should work on any machine.</p><blockquote><b>S50300:</b> SQLite database files shall be processor and byte-order independent.</blockquote><h2>6.0 Introspection</h2><a name="S60000"></a><p> Some applications need to be able to discover characteristics of their environment at run-time and to make appropriate adjustments to their processing to accommodate the environment they find themselves in. SQLite attempts to support this need.</p><blockquote><b>S60000:</b> The SQLite library shall provide introspection capabilities to the application.</blockquote><a name="S60100"></a><p> Some applications are designed to work with different versions of SQLite which may or may not enable selected features. For example, SQLite can be compiled to be threadsafe or not. The threadsafe version works in multi-threaded applications. The non-threadsafe build runs faster. When an application is using an unknown version of SQLite it is important that it be able to determine the characteristics of the particular SQLite build it is using.</p><blockquote><b>S60100:</b> The SQLite library shall provide interfaces that an application can use to discover fixed, compile-time characteristics of the SQLite library.</blockquote><a name="S60200"></a><p> In addition to the compile-time characteristics, SQLite allows the run-time settings of the library and of the underlying database file to be interrogated.</p><blockquote><b>S60200:</b> The SQLite library shall provide interfaces that an application can use to find run-time performance characteristics and status of the SQLite library.</blockquote><a name="S60300"></a><blockquote><b>S60300:</b> The SQLite library shall provide interfaces that permit an application to query the schema of a database.</blockquote><a name="S60400"></a><blockquote><b>S60400:</b> The SQLite library shall provide interfaces that allow an application to monitor sequence of queries and progress of submitted to SQLite.</blockquote><a name="S60500"></a><blockquote><b>S60500:</b> The SQLite library shall provide interfaces that allow an application to discover the algorithms that SQLite has chosen to implement specific SQL statements.</blockquote><a name="S60600"></a><p> SQLite objects are often related. For example, every prepared statement is associated with a database connection. And every function context is associated with a prepared statement. Applications and extensions frequently find it useful to be able to discover these relationships at runtime. Hence:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -