Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add documentation on the sqlite_dbpage virtual table. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
86e3ea924535c7096013a4490d53074a |
User & Date: | drh 2018-09-28 20:51:13.143 |
Context
2018-09-28
| ||
20:59 | Fix typos on th enew dbpage.html page. (check-in: 966ccc894f user: drh tags: trunk) | |
20:51 | Add documentation on the sqlite_dbpage virtual table. (check-in: 86e3ea9245 user: drh tags: trunk) | |
17:08 | Add documentation for the geopoly_regular() function. (check-in: 7804034c38 user: drh tags: trunk) | |
Changes
Changes to pages/compile.in.
︙ | ︙ | |||
835 836 837 838 839 840 841 | <li> [sqlite3_column_table_name16()] </li> <li> [sqlite3_column_origin_name()] </li> <li> [sqlite3_column_origin_name16()] </li> </ul> } COMPILE_OPTION {SQLITE_ENABLE_DBPAGE_VTAB} { | | < | 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | <li> [sqlite3_column_table_name16()] </li> <li> [sqlite3_column_origin_name()] </li> <li> [sqlite3_column_origin_name16()] </li> </ul> } COMPILE_OPTION {SQLITE_ENABLE_DBPAGE_VTAB} { This option enables the [SQLITE_DBPAGE virtual table]. } COMPILE_OPTION {SQLITE_ENABLE_DBSTAT_VTAB} { This option enables the [dbstat virtual table]. } COMPILE_OPTION {SQLITE_ENABLE_DESERIALIZE} { |
︙ | ︙ |
Added pages/dbpage.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | <title>The SQLITE_DBPAGE Virtual Table</title> <tcl>hd_keywords sqlite_dbpage {SQLITE_DBPAGE virtual table} \ {the SQLITE_DBPAGE extension}</tcl> <fancy_format> <h1>Overview</h1> <p> The SQLITE_DBPAGE extension implements an [eponymous-only virtual table] that provides direct access to the underlying database file by interacting directly with the page. SQLITE_DBPAGE is capable of both reading and writing any page of the database. Because interaction is through the pager layer, all changes are transactional. </p> <p> <b>Warning:</b> writing to the SQLITE_DBPAGE virtual table can very easily cause unrecoverably database corruption. Do not allow untrusted components to access the SQLITE_DBPAGE table. Use appropriate care while using the SQLITE_DBPAGE table. Back up important data prior to experimenting with the SQLITE_DBPAGE table. <p> The SQLITE_DBPAGE extension is included in the [amalgamation] though it is disabled by default. Use the [SQLITE_ENABLE_DBPAGE_VTAB] compile-time option to enable the SQLITE_DBPAGE extension. The SQLITE_DBPAGE extension makes use of unpublished internal interfaces and is not run-time loadable. The only way to add SQLITE_DBPAGE to an application is to compile it in using the [SQLITE_ENABLE_DBPAGE_VTAB] compile-time option. </p> <p> The SQLITE_DBPAGE extension is enabled in default builds of the [command-line shell]. <h1>Usage</h1> <p> The SQLITE_DBPAGE virtual table read/write table that provides direct access to the underlying disk file on a page-by-page basis. The virtual table appears to have a schema like this: <codeblock> CREATE TABLE sqlite_dbpage( pgno INTEGER PRIMARY KEY, data BLOB ); </codeblock> <p> An SQLite database file is divided into pages. The first page is 1, the second page is 2, and so forth. There is no page 0. Every page is the same size. The size of every page is a power of 2 between 512 and 65536. See the [file format] documentation for further details. <p> The SQLITE_DBPAGE table allows an application to view or replace the raw binary content of each page of the database file. No attempt is made to interpret the content of the page. Content is returned byte-for-byte as it appears on disk. <p> The SQLITE_DBPAGE table has one row for each page in the database file. SQLITE_DBPAGE allows pages to be read or to be overwritten. However the size of the database file cannot be changed. It is not possible to change the number of rows in the SQLITE_DBPAGE table by running DELETE or INSERT operations against that table. <h2>Using SQLITE_DBPAGE On ATTACH-ed Databases</h2> <p> The SQLITE_DBPAGE table schema shown above is incomplete. There is a third [hidden column] named "schema" that determines which [ATTACH|ATTACH-ed database] should be read or written. Because the "schema" column is hidden, it can be used as a parameter when SQLITE_DBPAGE is invoked as a [table-valued function]. <p> For example, suppose an additional database is attached to the database connection using a statement like this: <codeblock> ATTACH 'auxdata1.db' AS aux1; </codeblock> <p> Then to read the first page of that database file, one merely runs: <codeblock> SELECT data FROM sqlite_dbpage('aux1') WHERE pgno=1; </codeblock> <p> If the "schema" is omitted, it defaults to the primary database (usually called 'main', unless renamed using [SQLITE_DBCONFIG_MAINDBNAME]). Hence, the following two queries are normally equivalent: <codeblock> SELECT data FROM sqlite_dbpage('main') WHERE pgno=1; SELECT data FROM sqlite_dbpage WHERE pgno=1; </codeblock> <p> The SQLITE_DBPAGE table can participate in a join just like any other table. Hence, to see the content of the first page to all connected database files, one might run a statement like this: <codeblock> SELECT dbpage.data, dblist.name FROM pragma_database_list AS dblist JOIN sqlite_dbpage(dblist.name) AS dbpage WHERE dbpage.pgno=1; </codeblock> |
Changes to pages/vtablist.in.
︙ | ︙ | |||
29 30 31 32 33 34 35 | <tcl> unset -nocomplain vtab set vtab(sqlite_dbpage) { ifdef SQLITE_ENABLE_DBPAGE_VTAB type eponymous rw 1 src src/dbpage.c | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | <tcl> unset -nocomplain vtab set vtab(sqlite_dbpage) { ifdef SQLITE_ENABLE_DBPAGE_VTAB type eponymous rw 1 src src/dbpage.c doc *sqlite_dbpage supported 1 synopsis { Key/value store for the raw database file content. The key is the page number and the value is binary page content. } } set vtab(dbstat) { |
︙ | ︙ |