Home | History | Annotate | Download | only in dist

Lines Matching full:database

120 ** The hard upper limit here is 32676.  Most database people will
121 ** tell you that in a well-normalized database, you usually should
183 ** The maximum number of in-memory pages to use for the main database
195 ** checkpointing the database in WAL mode.
224 ** compiled with a different limit. If a process operating on a database
227 ** the aborted transaction. This could lead to database corruption.
236 ** The default size of a database page.
263 ** Maximum number of pages in one database file.
355 ** database connection at the same time.
765 ** CAPI3REF: Database Connection Handle
766 ** KEYWORDS: {database connection} {database connections}
768 ** Each open SQLite database is represented by a pointer to an instance of
817 ** CAPI3REF: Closing A Database Connection
826 ** sqlite3_close() is called on a [database connection] that still has
859 ** in the context of the [database connection] passed in as its 1st
896 ** SQL comments, then no SQL statements are evaluated and the database
903 ** is a valid and open [database connection].
904 ** <li> The application must not close [database connection] specified by
911 sqlite3*, /* An open database */
933 #define SQLITE_ERROR 1 /* SQL error or missing database */
937 #define SQLITE_BUSY 5 /* The database file is locked */
938 #define SQLITE_LOCKED 6 /* A table in the database is locked */
940 #define SQLITE_READONLY 8 /* Attempt to write a readonly database */
943 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
945 #define SQLITE_FULL 13 /* Insertion failed because database is full */
946 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
947 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
948 #define SQLITE_EMPTY 16 /* Database is empty */
949 #define SQLITE_SCHEMA 17 /* The database schema changed */
956 #define SQLITE_FORMAT 24 /* Auxiliary database format error */
958 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
975 ** on a per database connection basis using the
1173 ** The xCheckReservedLock() method checks whether any database connection,
1230 ** database corruption.
1273 ** layer a hint of how large the database file will grow to be during the
1275 ** is often close. The underlying VFS might choose to preallocate database
1276 ** file space based on this hint in order to help writes to the database
1281 ** extends and truncates the database file in chunks of a size specified
1284 ** for the nominated database. Allocating database file space in large
1290 ** to the [sqlite3_file] object associated with a particular database
1297 ** when the database connection has [PRAGMA synchronous] set to OFF.)^
1314 ** to be adjusted. The values are changed for all database connections
1326 ** are automatically deleted when the latest connection to the database
1329 ** have write permission on the directory containing the database file want
1330 ** to read the database file, as the WAL and shared memory files must exist
1331 ** in order for the database to be readable. The fourth parameter to
1350 ** reason, the entire database file will be overwritten by the current
1368 ** to the database file to which the pragma statement refers. ^The argument
1494 ** SQLITE_IOERR. Or the implementation might recognize that a database
1700 ** single thread. All open [database connections] must be closed and all
1788 ** CAPI3REF: Configure database connections
1791 ** changes to a [database connection]. The interface is similar to
1793 ** [database connection] (specified in the first argument).
1797 ** that indicates what aspect of the [database connection] is being configured.
1909 ** mutexing on [database connection] and [prepared statement] objects.
1911 ** [database connections] and [prepared statements]. But other mutexes
1914 ** [database connection] at the same time. ^If SQLite is compiled with
1924 ** mutexes on [database connection] and [prepared statement] objects.
1927 ** to [database connections] and [prepared statements] so that the
1928 ** application is free to use the same [database connection] or the
1980 ** times the database page size. ^If SQLite needs needs additional
1986 ** the database page cache with the default page cache implementation.
1991 ** The sz argument should be the size of the largest database page
2050 ** [database connection]. The first argument is the
2052 ** slots allocated to each database connection.)^ ^(This option sets the
2092 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
2095 ** database connection is opened. By default, URI handling is globally
2126 ** CAPI3REF: Database Connection Configuration Options
2141 ** [lookaside memory allocator] configuration for the [database connection].
2153 ** configuration for a database connection can only be changed when that
2208 ** successful [INSERT] into the database from the [database connection]
2212 ** have ever occurred on that database connection, zero is returned.
2238 ** database connection while the [sqlite3_last_insert_rowid()]
2249 ** ^This function returns the number of database rows that were changed
2251 ** on the [database connection] specified by the first parameter.
2294 ** If a separate thread makes changes on the same database connection
2304 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
2320 ** If a separate thread makes changes on the same database connection
2329 ** ^This function causes any pending database operation to abort and
2336 ** thread that is currently running the database operation. But it
2337 ** is not safe to call this routine with a [database connection] that
2350 ** SQL statements on [database connection] D complete. ^Any new SQL statements
2360 ** If the database connection closes while [sqlite3_interrupt()]
2405 ** an attempt is made to open a database table that another thread
2417 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
2419 ** is made to open the database for reading and the cycle repeats.
2441 ** already hold a RESERVED lock on the database file, but it needs
2443 ** pages into the database file without harm to concurrent
2454 ** [database connection]. Setting a new busy handler clears any
2459 ** database connection that invoked the busy handler. Any such actions
2462 ** A busy handler must not close the database connection
2481 ** [database connection] any any given moment. If another busy handler
2560 sqlite3 *db, /* An open database */
2792 ** [database connection], supplied in the first argument.
2834 ** try to execute malicious statements that damage the database. For
2836 ** SQL queries for evaluation by a database. But the application does
2838 ** database. An authorizer could then be put in place while the
2844 ** and limiting database size using the [max_page_count] [PRAGMA]
2847 ** ^(Only a single authorizer can be in place on a database connection
2853 ** the database connection that invoked the authorizer callback.
2855 ** database connections for the meaning of "modify" in this paragraph.
2902 ** authorizer callback is the name of the database ("main", "temp",
2933 #define SQLITE_DETACH 25 /* Database Name NULL */
2934 #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
2978 ** database connection D. An example use for this
2987 ** [database connection]; setting a new progress handler cancels the
2997 ** the database connection that invoked the progress handler.
2999 ** database connections for the meaning of "modify" in this paragraph.
3005 ** CAPI3REF: Opening A New Database Connection
3007 ** ^These routines open an SQLite database file as specified by the
3010 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
3014 ** object.)^ ^(If the database is opened (and/or created) successfully, then
3020 ** ^The default encoding for the database will be UTF-8 if
3025 ** associated with the [database connection] handle should be released by
3030 ** over the new database connection. ^(The flags parameter to
3038 ** <dd>The database is opened in read-only mode. If the database does not
3042 ** <dd>The database is opened for reading and writing if possible, or reading
3044 ** case the database must already exist, otherwise an error is returned.</dd>)^
3047 ** <dd>The database is opened for reading and writing, and is created if
3057 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
3060 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
3063 ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
3066 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
3071 ** the new database connection should use. ^If the fourth parameter is
3074 ** ^If the filename is ":memory:", then a private, temporary in-memory database
3075 ** is created for the connection. ^This in-memory database will vanish when
3076 ** the database connection is closed. Future versions of SQLite might
3078 ** It is recommended that when a database filename actually does begin with
3083 ** on-disk database will be created. ^This private database will be
3084 ** automatically deleted as soon as the database connection is closed.
3106 ** which contains the database. ^If the path begins with a '/' character,
3121 ** be used to access the database file on disk. ^If this option is set to
3129 ** ^If "ro" is specified, then the database is opened for read-only
3132 ** "rw", then the database is opened for read-write (but not create)
3164 ** Open the database file "/home/fred/data.db".
3199 const char *filename, /* Database filename (UTF-8) */
3203 const void *filename, /* Database filename (UTF-16) */
3207 const char *filename, /* Database filename (UTF-8) */
3217 ** to see if a database file was a URI that contained a specific query
3220 ** If F is the database filename pointer passed into the xOpen() method of
3248 ** is not a database file pathname pointer that SQLite passed into the xOpen
3262 ** associated with a [database connection]. If a prior API call failed
3281 ** this, each thread can obtain exclusive use of the [database connection] D
3326 ** [database connection] whose limit is to be set or queried. The
3346 ** both their own internal database and also databases that are controlled
3354 ** interface to further control untrusted SQL. The size of the database
3433 ** The first argument, "db", is a [database connection] obtained from a
3435 ** [sqlite3_open16()]. The database connection must not have been closed.
3479 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
3508 sqlite3 *db, /* Database handle */
3515 sqlite3 *db, /* Database handle */
3522 sqlite3 *db, /* Database handle */
3529 sqlite3 *db, /* Database handle */
3546 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3550 ** the content of the database file.
3553 ** [virtual tables] might change the database indirectly as a side effect.
3556 ** change the database file through side-effects:
3562 ** But because the [SELECT] statement does not change the database file
3567 ** since the statements themselves do not actually modify the database but
3569 ** database. ^The [ATTACH] and [DETACH] statements also cause
3571 ** change the configuration of a database connection, they do not make
3572 ** changes to the content of the database files on disk.
3588 ** to locate all prepared statements associated with a database
3600 ** that can be stored in a database table. SQLite uses dynamic typing
3862 ** ^These routines provide a means to determine the database, table, and
3865 ** ^The name of the database or table or column can be returned as
3867 ** the database name, the _table_ routines return the table name, and
3876 ** database, table, and column.
3886 ** occurs. ^Otherwise, they return the name of the attached database, table,
3922 ** ^(For example, given the database schema:
3963 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3964 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3993 ** be the case that the same database connection is being used by two or
4314 ** ^The first parameter is the [database connection] to which the SQL
4315 ** function is to be added. ^If an application uses more than one database
4317 ** to each database connection separately.
4361 ** overloaded or when the database connection closes.)^
4375 ** matches the database encoding is a better
4385 ** close the database connection nor finalize or reset the prepared
4566 ** CAPI3REF: Database Connection For Functions
4569 ** the pointer to the [database connection] (the 1st parameter)
4771 ** with the [database connection] specified as the first argument.
4833 ** [database connection] is closed using [sqlite3_close()].
4872 ** ^To avoid having to register all collation sequences before a database
4874 ** [database connection] to be invoked whenever an undefined collation
4885 ** sqlite3_collation_needed16(). The second argument is the database
4908 ** Specify the key for an encrypted database. This routine should be
4915 sqlite3 *db, /* Database to be rekeyed */
4920 ** Change the key on an open database. If the current database is not
4922 ** database is decrypted.
4928 sqlite3 *db, /* Database to be rekeyed */
4933 ** Specify the activation key for a SEE database. Unless
4943 ** Specify the activation key for a CEROD database. Unless
4982 ** if a [database connection] is being used at the same time in a separate
5006 ** zero if the given database connection is or is not in autocommit mode,
5018 ** If another thread changes the autocommit status of the database
5025 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
5027 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5028 ** to which a [prepared statement] belongs. ^The [database connection]
5029 ** returned by sqlite3_db_handle is the same [database connection]
5037 ** CAPI3REF: Return The Filename For A Database Connection
5040 ** associated with database N of connection D. ^The main database file
5041 ** has the name "main". If there is no attached database N on the database
5042 ** connection D, or if database N is a temporary or in-memory database, then
5048 ** to open the database originally was a URI or relative pathname.
5053 ** CAPI3REF: Determine if a database is read-only
5055 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
5057 ** the name of a database on connection D.
5065 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
5067 ** associated with the database connection pDb. ^If no prepared statement
5070 ** The [database connection] pointer D in a call to
5071 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5082 ** for the same database connection is overridden.
5086 ** for the same database connection is overridden.
5093 ** on the same [database connection] D, or NULL for
5098 ** the database connection that invoked the callback. Any actions
5099 ** to modify the database connection must be deferred until after the
5104 ** the database connections for the meaning of "modify" in this paragraph.
5118 ** automatically rolled back because the database connection is closed.
5129 ** with the [database connection] identified by the first argument
5132 ** for the same database connection is overridden.
5142 ** database and table name containing the affected row.
5157 ** the database connection that invoked the update hook. Any actions
5158 ** to modify the database connection must be deferred until after the
5161 ** database connections for the meaning of "modify" in this paragraph.
5165 ** on the same [database connection] D, or NULL for
5181 ** ^(This routine enables or disables the sharing of the database cache
5182 ** and schema data structures between [database connection | connections]
5183 ** to the same database. Sharing is enabled if the argument is true
5192 ** Existing database connections continue use the sharing mode
5211 ** held by the database library. Memory used to cache database
5223 ** CAPI3REF: Free Memory Used By A Database Connection
5226 ** memory as possible from database connection D. Unlike the
5303 ** database table accessible using the [database connection] handle
5307 ** this function. ^The second parameter is either the name of the database
5308 ** (i.e. "main", "temp", or an attached database) containing the specified
5310 ** for the table using the same algorithm used by the database engine to
5353 ** ^(This function may load one or more schemas from database files. If an
5356 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
5363 const char *zDbName, /* Database name or NULL */
5399 sqlite3 *db, /* Load the extension into this database connection */
5424 ** each new [database connection] that is created. The idea here is that
5426 ** that is to be automatically loaded into all new database connections.
5451 ** will be called more than once for each database connection that is opened.
5494 ** module or until the [database connection] closes. The content
5496 ** any database connection.
5635 ** ^The module name is registered on the [database connection] specified
5769 ** in row iRow, column zColumn, table zTable in database zDb;
5782 ** ^Note that the database name is not the filename that contains
5783 ** the database but rather the symbolic name of the database that
5784 ** appears after the AS keyword when the database is connected using [ATTACH].
5785 ** ^For the main database file, the database name is "main".
5786 ** ^For TEMP tables, the database name is "temp".
5791 ** ^This function sets the [database connection] error code and message
5835 ** to a different row of the same database table. ^The new row is identified
5837 ** changed. ^The database, table and column on which the blob handle is open
5851 ** ^This function sets the database handle error code and message.
5862 ** database connection is in [autocommit mode].
6247 ** CAPI3REF: Retrieve the mutex for a database connection
6250 ** serializes access to the [database connection] given in the argument
6258 ** CAPI3REF: Low-Level Control Of Database Files
6262 ** with a particular database identified by the second argument. ^The
6263 ** name of the database is "main" for the main database or "temp" for the
6264 ** TEMP database, or the name that appears after the AS keyword for
6267 ** main database file.
6280 ** open database file, then SQLITE_ERROR is returned. ^This error
6465 ** CAPI3REF: Database Connection Status
6468 ** about a single [database connection]. ^The first argument is the
6469 ** database connection object to be interrogated. ^The second argument
6489 ** CAPI3REF: Status Parameters for database connections
6529 ** memory used by all pager caches associated with the database connection.)^
6537 ** schema memory is shared with other database connections due to
6544 ** the database connection.)^
6672 ** determine exactly which parts of a database file are cached and for
6712 ** SQLite will typically create one cache instance for each open database file,
6720 ** database page on disk. The value passed into szExtra depends
6723 ** created will be used to cache database pages of a file stored on disk, or
6724 ** false if it is used for an in-memory database. The cache implementation
6750 ** single database page. The pExtra element of sqlite3_pcache_page will be
6872 ** The backup API copies the content of one database into another.
6878 ** ^SQLite holds a write transaction open on the destination database file
6880 ** ^The source database is read-locked only while it is being read;
6882 ** ^Thus, the backup may be performed on a live source database without
6883 ** preventing other database connections from
6884 ** reading or writing to the source database while the backup is underway.
6901 ** [database connection] associated with the destination database
6902 ** and the database name, respectively.
6903 ** ^The database name is "main" for the main database, "temp" for the
6904 ** temporary database, or the name specified after the AS keyword in
6905 ** an [ATTACH] statement for an attached database.
6907 ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
6908 ** and database name of the source database, respectively.
6909 ** ^The source and destination [database connections] (parameters S and D)
6915 ** destination [database connection] D.
6942 ** <li> the destination database was opened read-only, or
6943 ** <li> the destination database is using write-ahead-log journaling
6945 ** <li> the destination database is an in-memory database and the
6955 ** [database connection]
6956 ** is being used to write to the source database when sqlite3_backup_step()
6970 ** sqlite3_backup_step() obtains a [shared lock] on the source database that
6972 ** ^Because the source database is not locked between calls to
6973 ** sqlite3_backup_step(), the source database may be modified mid-way
6974 ** through the backup process. ^If the source database is modified by an
6975 ** external process or via a database connection other than the one being
6978 ** database is modified by the using the same database connection as is used
6979 ** by the backup operation, then the backup database is automatically
6990 ** active write-transaction on the destination database is rolled back.
7010 ** up and the total number of pages in the source database file.
7015 ** sqlite3_backup_step(). ^If the source database is modified during a backup
7017 ** pages that need to be updated or the size of the source database file
7020 ** <b>Concurrent Usage of Database Handles</b>
7022 ** ^The source [database connection] may be used by the application for other
7024 ** ^If SQLite is compiled and configured to support threadsafe database
7025 ** connections, then the source database connection may be used concurrently
7029 ** [database connection] is not passed to any other API (by any thread) after
7032 ** if the application incorrectly accesses the destination [database connection]
7034 ** nevertheless. Use of the destination database connection while a
7038 ** guarantee that the shared cache used by the destination database
7052 sqlite3 *pDest, /* Destination database handle */
7053 const char *zDestName, /* Destination database name */
7054 sqlite3 *pSource, /* Source database handle */
7055 const char *zSourceName /* Source database name */
7065 ** ^When running in shared-cache mode, a database operation may fail with
7076 ** ^Shared-cache locks are released when a database connection concludes
7081 ** identity of the database connection (the blocking connection) that
7133 ** related to the set of unblocked database connections.
7138 ** database waits for the callback to be issued before taking any further
7221 ** will be invoked each time a database connection commits data to a
7226 ** the associated write-lock on the database released, so the implementation
7227 ** may read, write or [checkpoint] the database as required.
7231 ** registering the callback. ^The second is a copy of the database handle.
7232 ** ^The third parameter is the name of the database that was written to -
7233 ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
7245 ** A single database handle may have at most a single write-ahead log callback
7262 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
7277 ** ^Every new [database connection] defaults to having the auto-checkpoint
7286 ** CAPI3REF: Checkpoint a database
7288 ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
7289 ** on [database connection] D to be [checkpointed]. ^If X is NULL or an
7291 ** connection D. ^If the database connection D is not in
7304 ** CAPI3REF: Checkpoint a database
7306 database zDb attached to database
7312 ** Checkpoint as many frames as possible without waiting for any database
7319 ** database writer and all readers are reading from the most recent database
7321 ** database file. This call blocks database writers while it is running,
7322 ** but not database readers.
7327 ** until all readers are reading from the database file only. This ensures
7328 ** that the next client to write to the database file restarts the log file
7329 ** from the beginning. This call blocks database writers while it is running,
7330 ** but not database readers.
7341 ** All calls obtain an exclusive "checkpoint" lock on the database file. If
7347 ** "writer" lock on the database file. If the writer lock cannot be obtained
7351 ** database readers as described above. If the busy-handler returns 0 before
7352 ** the writer lock is obtained or while waiting for database readers, the
7363 ** error occurs while processing an attached database, processing is abandoned
7368 ** If database zDb is the name of an attached database that is not in WAL
7371 ** attached database, SQLITE_ERROR is returned to the caller.
7374 sqlite3 *db, /* Database handle */
7375 const char *zDb, /* Name of attached database (or NULL) */
7432 ** is able to roll back a statement or database transaction, and abandon
8031 ** callback for the database handle. Each pager opened via the sqlite
8043 ** Name of the master database table. The master database table
8051 ** The root-page of the master database table.
8200 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
8220 const char *zFilename, /* Name of database file to open */
8221 sqlite3 *db, /* Associated database connection */
8295 ** SQLite database header may be found using the following formula:
8300 ** the database file header. The incr-vacuum-flag field is located at
8431 ** Header file for the Virtual DataBase Engine (VDBE)
8433 ** This header defines the interface to the virtual database engine
8435 ** simple program to access and modify the underlying database.
8894 database (it is
8909 #define PAGER_MEMORY 0x0002 /* In-memory database */
9012 /* Functions used to truncate the database file. */
9090 ** writing this page to the database */
9591 ** Each database file to be accessed by the system is an instance
9593 ** in the sqlite.aDb[] array. aDb[0] is the main database file and
9594 ** aDb[1] is the database file used to hold temporary tables. Additional
9598 char *zName; /* Name of this database */
9599 Btree *pBt; /* The B*Tree structure for this database file */
9602 Schema *pSchema; /* Pointer to database schema (possibly shared) */
9606 ** An instance of the following structure stores a database schema.
9623 int schema_cookie; /* Database schema version number for this file */
9631 u8 enc; /* Text encoding used by this database */
9648 ** The DB_SchemaLoaded flag is set after the database schema has been
9668 ** associated with a particular database connection. The use of
9679 ** with a particular database connection. Hence, schema information cannot
9681 ** is shared by multiple database connections. Therefore, while parsing
9711 ** Each database connection is an instance of the following structure.
9822 ** A macro to discover the encoding of a database.
9877 #define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
9878 #define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
9880 #define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
10094 ** the database schema.
10096 ** If the database schema is shared, then there is one instance of this
10097 ** structure for each database connection (sqlite3*) that uses the shared
10098 ** schema. This is because each database connection requires its own unique
10101 ** database connections, even when the rest of the in-memory database
10102 ** schema is shared, as the implementation often stores the database
10104 ** during initialization internally. This database connection handle may
10106 ** within the database. So that they appear as part of the callers
10107 ** transaction, these accesses need to be made via the same database
10111 ** database schema are initially stored in a linked-list pointed to by
10115 ** database connection doing the preparing so as to use the correct
10135 sqlite3 *db; /* Database connection associated with this table */
10164 ** database file. If Table.iDb is the index of the database table backend
10165 ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that
10274 ** is returned. REPLACE means that preexisting database rows that caused
10309 sqlite3 *db; /* The database connection */
10382 int tnum; /* Page containing root of this index in database file */
10533 ** Expr objects can use a lot of memory space in database schema. To
10726 database support, the following structure
10730 ** now be identified by a database name, a dot, then the table name: ID.ID.
10744 char *zDatabase; /* Name of database holding this table */
11021 int iDb; /* Index in sqlite3.aDb[] of database holding pTab */
11084 sqlite3 *db; /* The main database structure */
11086 Vdbe *pVdbe; /* An engine for executing database bytecode */
11201 * Each trigger present in the database schema is stored as an instance of
11206 * database). This allows Trigger structures to be retrieved by name.
11292 ** routines as they walk the parse tree to make database references
11298 const char *zDb; /* Make sure all objects are contained in this database */
11308 sqlite3 *db; /* Optional database for lookaside. Can be NULL */
11324 sqlite3 *db; /* The database being initialized */
11326 int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
12364 ** database connections. After initialization, this table is
12380 ** 1-gibabyte boundary) in a compatible database. SQLite never uses
12381 ** the database page that contains the pending byte. It never attempts
12392 ** 0x40000000 results in an incompatible database file format!
12867 ** A cursor is a pointer into a single BTree within a database file.
12880 int iDb; /* Index of cursor database in db->aDb[] (or -1) */
12975 sqlite3 *db; /* The associated database connection */
13005 ** database (see below for exceptions). If the MEM_Term flag is also
13119 sqlite3 *db; /* The database connection that owns this statement */
13148 u8 minWriteFileFormat; /* Minimum file format for writable database files */
13385 ** Query status information for a single database connection
13388 sqlite3 *db, /* The database connection whose status is desired */
13424 ** by all pagers associated with the given database connection. The
13510 ** pagers the database handle is connected to. *pHighwater is always set
14802 sqlite3_file *id, /* Database file handle */
18606 ** cache database pages that are not currently in use.
19067 ** Free memory that might be associated with a particular database
19183 ** failure on the same database connection) then always return 0.
19184 ** Hence for a particular database connection, once malloc starts
19275 ** and set the mallocFailed flag in the database connection.
20353 ** Random numbers are used by some of the database backends in order
21191 ** stored by this function into the database handle using sqlite3Error().
21991 /* We can only reach this point when reading a corrupt database
22083 "API call with %s database connection pointer",
22203 ** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database
23470 ** a database and its journal file) that the sector size will be the
23574 ** Use main database file for interprocess locking. If un-defined
23930 ** shared-memory associated with the database file id. Shared-memory regions
23948 sqlite3_file *id, /* Handle open on database file */
24040 sqlite3_file *id, /* The underlying database file */
24088 sqlite3_file *id, /* Database file holding the shared memory */
24206 sqlite3_file *id /* Database file holding the shared memory */
24871 ** where the database is located.
25039 ** transaction counter in bytes 24-27 of database files are updated
25040 ** whenever any part of the database changes. An assertion fault will
25046 unsigned char dbUpdate; /* True if any part of database file changed */
25550 ** permissions as their original database, unadulterated by the umask.
25551 ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a
25553 ** process that is able to write to the database will also be able to
25942 ** on its own. Whenever a new database is opened, we have to find the
25943 ** specific inode of the database file (the inode is determined by the
26000 ** per database file in the same process and (2) database connections
26228 ** in the header of every SQLite database. In this way, if there
26230 ** the first page of the database, no damage is done.
26331 ** in order to coordinate access between separate database connections
26400 ** accessing the same database file, in case that is ever required.
26426 ** database.
26664 ** reading the database file again, make sure that the
26665 ** transaction counter was updated if any part of the database
26669 ** cache. The use of a stale cache can lead to database corruption.
26876 ** simplest: locking is ignored. No attempt is made to lock the database
26882 ** prevent simultaneous access of the same database by two or more
26883 ** database connections. But there is a serious risk of database
26885 ** database connections are accessing the same database file at the same
26917 ** files (really a directory) to control access to the database. This works
26921 ** connections from reading or writing the database.
26930 ** the database and with the same name but with a ".lock" extension added.
27075 /* To fully unlock the database, delete the lock file */
27120 ** only a single process can be reading the database at a time.
27326 ** the database file at a time. This reduces potential concurrency, but
27863 ** reading the database file again, make sure that the
27864 ** transaction counter was updated if any part of the database
27868 ** cache. The use of a stale cache can lead to database corruption.
28076 /* If this is a database file (not a journal, master-journal or temp
28156 /* If this is a database file (not a journal, master-journal or temp
28166 /* If we are doing a normal write to a database file (as opposed to
28168 ** normal database file) then record the fact that the database
28173 pFile->dbUpdate = 1; /* The database has been modified */
28248 ** or power failure will likely corrupt the database file.
28388 ** will not roll back - possibly leading to database corruption.
28460 /* If we are doing a normal write to a database file (as opposed to
28462 ** normal database file) and we truncate the file to zero length,
28464 ** when restoring a database using the backup API from a zero-length
28491 /* When opening a zero-size database, the findInodeInfo() procedure
28513 ** file-control operation. Enlarge the database to nBytes in size
28514 ** (rounded up to the next chunk-size). If the database is already
28618 ** a rollback and that the database is therefore unchanged and
28644 ** a database and its journal file) that the sector size will be the
28858 ** Open a shared-memory area associated with open database file pDbFd.
28862 ** as the open database file and has the same name as the open database
28863 ** file with the "-shm" suffix added. For example, if the database file
28869 ** from the database file is used, then differing access permissions
28871 ** database to end up using different files for shared memory -
28873 ** in database corruption. Nevertheless, this tmpfs file usage
28878 ** same database file at the same time, database corruption will likely
28886 ** If the original database file (pDbFd) is using the "unix-excl" VFS
28887 ** that means that an exclusive lock is held on the database file and
28888 ** that no other processes are able to read or write the database. In
28913 struct stat sStat; /* fstat() info for database file */
28915 /* Call fstat() to figure out the permissions on the database file. If
28966 ** is owned by the same user that owns the original database. Otherwise,
29024 ** shared-memory associated with the database file fd. Shared-memory regions
29042 sqlite3_file *fd, /* Handle open on database file */
29153 sqlite3_file *fd, /* Database file holding the shared memory */
29265 sqlite3_file *fd /* Database file holding the shared memory */
29280 sqlite3_file *fd, /* The underlying database file */
29286 unixFile *pDbFd; /* The underlying database file */
29339 ** sqlite3_io_methods object for a particular database file. The pAppData
29506 ** for the database file "filePath". It then returns the sqlite3_io_methods
29512 const char *filePath, /* name of the database file */
29513 unixFile *pNew /* open file object for the database file */
29572 ** for the database file "filePath". It then returns the sqlite3_io_methods
29578 const char *filePath, /* name of the database file */
29884 ** Search for an unused file descriptor that was opened on the database
29889 ** Such a file descriptor may exist if a database connection was closed
29953 ** corresponding database file and sets *pMode to this value. Whenever
29955 ** as the associated database file.
29974 char zDb[MAX_PATHNAME+1]; /* Database file path */
29976 struct stat sStat; /* Output of stat() on database file */
29979 ** the path to the associated database file from zPath. This block handles
30123 /* Database filenames are double-zero terminated if they are not
30180 ** the same as the original database. If we are not running as root,
30252 ** with fd is a database file, and there are other connections open
30643 ** database file to coordinate safe, concurrent access by multiple readers
30664 ** address the requirements for concurrent database access by multiple
30669 ** changes the way database access is controlled by limiting access to a
30670 ** single host at a time and moving file locks off of the database file
30686 ** PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:
30687 ** PRAGMA [database.]lock_proxy_file
30694 ** database file. For example:
30696 ** For database path "/Users/me/foo.db"
30699 ** Once a lock proxy is configured for a database connection, it can not
30710 ** * conch file to limit access to the database file to a single host
30714 ** taken on the database
30720 ** stored in the same directory as the database file and the file name
30721 ** is patterned after the database file name as ".<databasename>-conch".
30730 ** normally taken on the database file. This allows for safe sharing
30731 ** of the database file for multiple readers and writers on the same
30735 ** only taken when the first request to lock database file is made.
30737 ** opening a connection to a database file does not take a lock on it.
30739 ** the connection to the database is closed.
30749 ** Database files accessed on non-local file systems are
30772 ** force proxy locking to be used for every database file opened, and 0
30773 ** will force automatic proxy locking to be disabled for all database
30800 ** The proxy lock file path for the database at dbPath is written into lPath,
31285 ** valid conch file), try to match the permissions of the database
31293 /* try to match the database file R/W permissions, ignore failure */
31399 ** Given the name of a database file, compute the name of its conch file.
31411 int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
31415 ** the name of the original database file. */
31514 char dbPath[MAXPATHLEN+1]; /* Name of the database file */
31831 ** database file and tries to choose an locking method appropriate for
34336 ** a database and its journal file) that the sector size will be the
34570 ** Open the shared-memory area associated with database file pDbFd.
34690 sqlite3_file *fd, /* Database holding shared memory */
34693 winFile *pDbFd; /* Database holding shared-memory */
34731 sqlite3_file *fd, /* Database file holding the shared memory */
34840 sqlite3_file *fd /* Database holding the shared memory */
34850 ** shared-memory associated with the database file fd. Shared-memory regions
34868 sqlite3_file *fd, /* Handle open on database file */
35212 /* Database filenames are double-zero terminated if they are not
35839 ** A bitmap is used to record which pages of a database file have been
35844 ** or all of the pages in a database can get journalled. In those cases,
35857 ** Bitvec object is the number of pages in the database file at the
35859 ** but can be as large as 2 billion for a really big database.
36359 ** being used for an in-memory database, this function is a no-op.
36738 ** Since there cannot be more than 2^31 distinct pages in a database,
36913 ** open database file (including each in-memory database and each
36914 ** temporary or transient database) has a single page cache which
37522 ** database) there is really no difference between createFlag 1 and 2. So
37978 sqlite3 *db; /* The database connection */
38038 ** The mallocFailed flag of the database connection is set if a
38313 ** The pager is used to access a database disk file. It implements
38315 ** is separate from the database file. The pager also implements file
38316 ** locking to prevent two processes from writing the same database
38317 ** file simultaneously, or one process from reading the database while
38385 ** snapshot is like a read-transaction. It is the state of the database
38397 /* If the WAL is not empty, return the size of the database. */
38418 /* Copy pages from the log to the database file */
38439 ** by the pager layer on the database file.
38474 ** Definition: A page of the database file is said to be "overwriteable" if
38484 ** the database file at the start of the transaction.
38486 ** (1) A page of the database file is never overwritten unless one of the
38496 ** both the content in the database when the rollback journal was written
38497 ** and the content in the database at the beginning of the current
38500 ** (3) Writes to the database file are an integer multiple of the page size
38503 ** (4) Reads from the database file are either aligned on a page boundary and
38505 ** first 100 bytes of the database file.
38507 ** (5) All writes to the database file are synced prior to the rollback journal
38510 ** (6) If a master journal file is used, then all writes to the database file
38513 ** Definition: Two databases (or the same database at two points it time)
38517 ** of the database.
38521 ** journal is rolled back, the resulting database file will be logical
38522 ** equivalent to the database file at the beginning of the transaction.
38525 ** is called to restore the database file to the same size it was at
38530 ** (9) Whenever the database file is modified, at least one bit in the range
38533 ** database to flush their caches.
38538 ** (11) A database file is well-formed at the beginning and at the conclusion
38541 ** (12) An EXCLUSIVE lock is held on the database file when writing to
38542 ** the database file.
38544 ** (13) A SHARED lock is held on the database file while reading any
38545 ** content out of the database file.
38612 ** state - the file may or may not be locked and the database size is
38613 ** unknown. The database may not be read or written.
38616 ** * Any lock, or no lock at all, may be held on the database file.
38621 ** In this state all the requirements for reading the database in
38624 ** open. The database size is known in this state.
38627 ** it opens a read-transaction on the database and returns to state
38635 ** * A SHARED or greater lock is held on the database file.
38639 ** * If the database is a WAL database, then the WAL connection is open.
38646 ** is first opened on the database. In WRITER_LOCKED state, all locks
38648 ** modifications to the cache or database have taken place.
38651 ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when
38654 ** in WRITER_LOCKED state, all that is required is to unlock the database
38659 ** is made to obtain an EXCLUSIVE lock on the database file.
38663 ** lock is held on the database file.
38677 ** start of it. The database file on disk has not been modified.
38680 ** * A RESERVED or greater lock is held on the database file.
38688 ** when it modifies the contents of the database file. WAL connections
38689 ** never enter this state (since they do not modify the database file,
38693 ** * An EXCLUSIVE or greater lock is held on the database file.
38705 ** database file. In this state the transaction may be committed simply
38707 ** not possible to modify the database further. At this point, the upper
38711 ** * An EXCLUSIVE or greater lock is held on the database file.
38712 ** * All writing and syncing of journal and database data has finished.
38731 ** report database corruption (due to the inconsistent cache), and if
38732 ** they upgrade to writers, they may inadvertently corrupt the database
38755 ** database file in function pagerStress() in order to free up
38799 ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
38816 ** The exception is when the database file is unlocked as the pager moves
38829 ** transaction in another process, causing SQLite to read from the database
38833 ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
38838 ** lock on the database file before attempting to roll it back. See function
38904 ** For a real on-disk database, the current lock held on the database file -
38907 ** For a temporary or in-memory database (neither of which require any
38920 ** (the 4-byte header field at byte offset 24 of the database file) is
38924 ** can only happen if an exclusive lock is held on the database file.
38926 ** relinquished on the database file. Each time a transaction is committed,
38965 ** When doNotSpill is non-zero, writing to the database from pagerStress()
38971 ** If doNotSyncSpill is non-zero, writing to the database from pagerStress()
38974 ** the database page-size in order to prevent a journal sync from happening
38988 ** Variable dbSize is set to the number of pages in the database file.
38992 ** dbSize is set based on the size of the database file, which may be
38993 ** larger than the size of the database (the value stored at offset
38994 ** 28 of the database header by the btree). If the size of the file
39003 ** Similarly, if the database is truncated using PagerTruncateImage(),
39015 ** to write or truncate the database file on disk.
39020 ** that the database file is larger than the database image (Pager.dbSize),
39022 ** to measure the database
39058 u8 readOnly; /* True for a read-only database */
39071 u8 eLock; /* Current lock held on database file */
39077 Pgno dbSize; /* Number of pages in the database */
39079 Pgno dbFileSize; /* Number of pages in the database file */
39085 Bitvec *pInJournal; /* One bit for each page in the database file */
39086 sqlite3_file *fd; /* File descriptor for database */
39094 char dbFileVers[16]; /* Changes whenever database file changes */
39104 Pgno mxPgno; /* Maximum allowed size of the database */
39106 char *zFilename; /* Name of the database file */
39112 int nRead, nWrite; /* Database pages read/written */
39153 ** to roll the journal back, the database could be corrupted. The additional
39185 ** The macro MEMDB is true if we are dealing with an in-memory database.
39254 ** as if it has an exclusive lock on the database file. It never updates
39482 ** Unlock the database file to level eLock, which must be either NO_LOCK
39508 ** Lock the database file to level eLock, which must be either SHARED_LOCK,
39536 ** a database page may be written atomically, and
39542 ** database.
39769 ** - 4 bytes: Initial database page count.
39771 ** - 4 bytes: Database page size.
39833 /* The initial database size */
39862 ** database
39885 ** database before the transaction began, in pages. Also, pPager->cksumInit
39898 u32 *pDbSize /* OUT: Value of original database size field */
39932 ** field, the checksum-initializer and the database size at the start
40015 ** If zMaster is a NULL pointer (occurs for a single database transaction),
40150 ** If the pager is not in exclusive-access mode, the database file is
40182 ** close the journal file when dropping the database lock. Otherwise
40198 /* If the pager is in the ERROR state and the call to unlock the database
40251 ** to be replayed to restore the contents of the database file (as if
40274 ** database transaction.
40285 ** or any other database connection. Exactly how a journal is finalized
40315 ** database then the IO error code is returned to the user. If the
40317 ** tries to unlock the database file if not in exclusive mode. If the
40370 ** the database file, it will do so using an in-memory journal.
40403 ** lock held on the database file.
40422 ** database file.
40427 ** the database file and move the pager back to OPEN state. If this
40518 ** to the database file, then the IO error code is returned. If data
40614 ** not the database file. The page is left marked dirty in this case.
40616 ** An exception to the above rule: If the database is in no-sync mode
40633 ** statement we must not write to the original database unless we know
40636 ** database file without an entry in the rollback journal that can
40637 ** restore the database to its original form. Two conditions must be
40638 ** met before writing to the database files. (1) the database must be
40643 ** 2008-04-14: When attempting to vacuum a corrupt database file, it
40644 ** is possible to fail a statement on a database that does not yet exist.
40645 ** Do not attempt to write if database file has never been opened.
40681 ** the database and the page is not in-memory, there is a potential
40683 ** will be read from the database file, which may or may not be
40709 ** database active. However such a page may be rolled back as a result
40722 ** database.
40733 ** be written out into the database file before its journal file
40735 ** database corruption may ensue.
40889 ** This function is used to change the actual size of the database
40893 ** If the main database file is not open, or the pager is not in either
40906 ** the database file, return the error code to the caller.
40943 ** of the open database file. The sector size will be used used
40987 ** Playback the journal and thus restore the database file to
40999 ** database to during a rollback.
41134 ** database file back to its original size.
41145 ** database file and/or page cache.
41161 ** case, the database should have never been written in the
41169 ** process to come along will be able to rollback the database.
41180 /* Following a rollback, the database file should be back in its original
41234 ** Read the content for page pPg out of the database file and into
41235 ** pPg->pData. A shared lock or greater must be held on the database
41239 ** the value read from the database file.
41276 ** of bytes 24..39 of the database. Bytes 28..31 should always be
41277 ** zero or the size of the database in page. Bytes 32..35 and 35..39
41281 ** For an encrypted database, the situation is more complex: bytes
41282 ** 24..39 of the database are white noise. But the probability of
41334 ** references, the page content is reloaded from the database. If the
41335 ** attempt to reload content from the database is required and fails,
41358 ** database. This is not generally possible with a WAL database, as
41370 ** This function is called to rollback a transaction on a WAL database.
41381 ** + Reload page content from the database (if refcount>0).
41407 Pgno nTruncate, /* Database size after this commit */
41462 ** makes a snapshot of the database at the current point in time and preserves
41491 ** to PAGER_READER state to determine the size of the database file
41494 ** If no error occurs, SQLITE_OK is returned and the size of the database
41501 /* Query the WAL sub-system for the database size. The WalDbsize()
41503 ** if the database size is not available. The database size is not
41511 /* If the database size was not available from the WAL sub-system,
41512 ** determine it based on the size of the database file. If the size
41513 ** of the database file is not an integer multiple of the page-size,
41543 ** Check if the *-wal file that corresponds to the database opened by pPager
41544 ** exists if the database is not empy, or verify that the *-wal file does
41545 ** not exist (by deleting it) if the database file is empty.
41547 ** If the database is not empty and the *-wal file exists, open the pager
41548 ** in WAL mode. If the database is empty or if no *-wal file exists and
41554 ** The caller must hold a SHARED lock on the database file to call this
41556 ** a WAL on a none-empty database, this ensures there is no race condition
41567 Pgno nPage; /* Size of the database file */
41645 /* Set the database size back to the value it was before the savepoint
41666 ** greater than the current database size (pPager->dbSize) but those
41751 ** Adjust the robustness of the database to damage due to OS crashes
41759 ** database. This is normally adequate protection, but
41762 ** in a state which would cause damage to the database
41766 ** database (with some additional information - the nRec field
41771 ** point of causing damage to the database during rollback.
41775 ** prior to the start of checkpoint and that the database file is synced
41777 ** was written back into the database. But no sync operations occur for
41910 ** * the database is either not an in-memory database or it is
41911 ** an in-memory database that currently consists of zero pages.
41978 ** entire content of a database page. This buffer is used internally
41988 ** Attempt to set the maximum database page count if mxPage is positive.
41990 ** maximum page count below the current size of the database.
42034 ** function is used to read database headers, and a new transient or
42035 ** zero sized database has a header than consists entirely of zeroes.
42064 ** the pager. It returns the total number of pages in the database.
42077 ** Try to obtain a lock of type locktype on the database file. If
42114 ** current database image, in pages, OR
42123 ** the database file. If a savepoint transaction were rolled back after
42126 ** the database file or the portion of the rollback journal and
42128 ** database image would become corrupt. It is therefore fortunate that
42144 ** Truncate the in-memory database file image to nPage pages. This
42145 ** function does not actually modify the database file on disk. It
42214 ** file may be played back into the database. If a power failure occurs
42215 ** while this is happening, the database could become corrupt.
42219 ** database and close the journal file without attempting to roll it
42220 ** back or finalize it. The next database user will have to do hot-journal
42221 ** rollback before accessing the database file.
42319 ** that wrote to this database was operating in persistent-journal
42329 ** out-of-date data that follows it. Database corruption.
42413 ** in-memory pages in the list to the database file. The argument may
42418 ** is called. Before writing anything to the database file, this lock
42420 ** SQLITE_BUSY is returned and no data is written to the database file.
42427 ** the pages are written out to the database file in list order. Writing
42433 ** If writing out a page causes the database file to grow, Pager.dbFileSize
42436 ** the database file.
42487 /* Encode the database */
42494 ** the value now stored in the database file. If writing this
42495 ** page caused the database file to grow, update dbFileSize.
42597 ** database). The second argument is a reference to a page that is
42603 ** out to the database file, if possible. This may involve syncing the
42628 ** lead to database corruption. In the current implementaton it
42659 ** the database image, it may need to be written to the sub-journal.
42669 ** <shrink database file to Y pages>
42674 ** out to the database file, but will be dropped from the cache. Then,
42676 ** data from the database file. This will be the copy of page X as it
42691 /* Write the contents of the page out to the database file. */
42713 ** The zFilename argument is the path to the database file to open.
42718 ** This can be used to implement an in-memory database.
42741 const char *zFilename, /* Name of the database file to open */
42754 char *zPathname = 0; /* Full path to database file */
42809 ** the database being opened will be more than pVfs->mxPathname
42810 ** bytes in length. This means the database cannot be opened,
42823 ** three file descriptors, the database file name and the journal
42828 ** Database file handle (pVfs->szOsFile bytes)
42831 ** Database file name (nPathname+1 bytes)
42888 ** database file. The default page size is the maximum of:
42924 ** This branch is also run for an in-memory database. An in-memory
42925 ** database is the same as a temp-file that is never written out to
43027 ** * No process holds a RESERVED or greater lock on the database file, and
43028 ** * The database file itself is greater than 0 bytes in size, and
43031 ** If the current size of the database file is 0 but a journal file
43033 ** database with the same name. In this case the journal file is
43081 Pgno nPage; /* Number of pages in database file */
43083 /* Check the size of the database file. If it consists of 0 pages,
43100 ** or greater lock on the database file. Now check that there is
43141 ** This function is called to obtain a shared lock on the database file.
43149 ** on the database file), then an attempt is made to obtain a
43150 ** SHARED lock on the database file. Immediately after obtaining
43154 ** the 'change-counter' field of the database file header and
43164 ** occurs while locking the database, checking for a hot-journal file or
43192 ** database file, then it either needs to be played back or deleted.
43201 /* Get an EXCLUSIVE lock on the database file. At this point it is
43204 ** database file, detect the RESERVED lock, and conclude that the
43205 ** database is safe to read while this process is still rolling the
43209 ** other process attempting to access the database file will get to
43211 ** on the database file.
43252 /* Playback and delete the journal. Drop the database write
43301 /* The shared-lock has just been acquired on the database file
43303 ** read or write transaction). Check to see if the database
43304 ** has been modified. If the database has changed, flush the
43307 ** Database changes is detected by looking at 15 bytes beginning
43338 /* If there is a WAL file in the file-system, open this database in WAL
43388 ** read from the database file. In some cases, the pcache module may
43397 ** If the database image is smaller than the requested page or if a
43406 ** a) When reading a free-list leaf page from the database, and
43413 ** being read from the database. Additionally, the bits corresponding
43432 Pager *pPager, /* The pager open on the database file */
43559 ** are released, a rollback occurs and the lock on the database is
43572 ** There must already be a RESERVED or EXCLUSIVE lock on the database
43663 ** lock on the database file. If exFlag is true, then acquire at least
43672 ** sub-journal is implemented in-memory if pPager is an in-memory database,
43687 ** exclusive lock on the database is not already held, obtain it now.
43704 /* Obtain a RESERVED lock on the database file. If the exFlag parameter
43721 ** transactions may copy data from the sub-journal into the database
43767 /* Higher-level routines never call this function if database is not
43798 ** EXCLUSIVE lock on the main database file. Write the current page to
43809 ** contains the database locks. The following assert verifies
43821 ** in the database file. And if an IO error occurs while doing so,
43871 /* Update the database size and return.
43905 Pgno nPageCount; /* Total number of pages in database file */
43963 ** before any of them can be written out to the database file.
44020 ** This routine is called to increment the value of the database file
44037 ** if isDirect is non-zero, then the database file is updated directly
44112 ** Sync the database file to disk. This is a no-op for in-memory databases
44137 ** the database file, an attempt is made to obtain one.
44158 ** Sync the database file for the pager pPager. zMaster points to the name
44161 ** journal (a single database transaction).
44165 ** * The database file change-counter is updated,
44167 ** * all dirty pages are written to the database file,
44168 ** * the database file is truncated (if required), and
44169 ** * the database file synced.
44178 ** If the final parameter - noSync - is true, then the database file itself
44180 ** sync the database file before calling CommitPhaseTwo() to delete the
44200 PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n",
44203 /* If no database changes have been made, return early. */
44269 ** directly to the database file. Because of the atomic-write
44284 /* If this transaction has made the database smaller, then all pages
44292 ** reading data from the database file.
44300 const Pgno dbSize = pPager->dbSize; /* Database image size */
44323 /* Sync the journal file and write all dirty pages to the database.
44344 /* If the file on disk is not the same size as the database image,
44354 /* Finally, sync the database file. */
44371 ** When this function is called, the database file has been completely
44399 /* An optimization. If the database was not actually modified during
44406 ** to the database file. So there is no need to zero the journal
44435 ** 1) It rolls back the journal file, restoring all database file and
44447 ** their pre-transaction state by re-reading data from the database or
44494 ** Return TRUE if the database file is opened read-only. Return FALSE
44495 ** if the database is (in theory) writable.
44658 ** the transaction or unlock the database, it just restores the
44659 ** contents of the database to its original state.
44704 ** the database file, so the playback operation can be skipped.
44717 ** Return the full pathname of the database file.
44731 ** Return the file handle for the database file associated
44796 ** moved as part of a database reorganization just before the transaction
44797 ** is being committed. In this case, it is guaranteed that the database page
44815 /* In order to be able to rollback, an in-memory database must journal
44856 ** the journal needs to be sync()ed before database page pPg->pgno
44876 /* Do not discard pages from an in-memory database since we might
44888 /* For an in-memory database, make sure the original page continues
44900 ** sync()ed before any data is written to database file page needSyncPgno.
44909 ** this transaction, it may be written to the database file before
44983 ** * An in-memory database can only have its journal_mode set to _OFF
45014 /* Do allow the journalmode of an in-memory database to be set to
45049 ** database file. This ensures that the journal file is not deleted
45092 ** journalmode. Journalmode changes can only happen when the database
45128 ** Unless this is an in-memory or temporary database, clear the pager cache.
45169 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
45189 ** lock on the database file and use heap-memory to store the wal-index
45222 ** The caller must be holding a SHARED lock on the database file to call
45225 ** If the pager passed as the first argument is open on a real database
45226 ** file (not a temp file or an in-memory database), and the WAL file
45232 ** If the pager is open on a temp-file (or in-memory database), or if
45271 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
45298 ** the database file, the log and log-summary files will be deleted.
45316 ** WAL frames. Otherwise, if this is not a WAL database or the WAL file
45365 ** database file. All changes to the database are recorded by writing
45369 ** transferred back into the database file in an operation called a
45384 ** 8: Database page size. Example: 1024
45397 ** 4: For commit records, the size of the database image in pages
45435 ** WAL is transferred into the database, then the database is VFS.xSync-ed.
45447 ** To read a page from the database (call it page number P), a reader
45453 ** the database file.
45460 ** of the database from a single point in time. This technique allows
45461 ** multiple concurrent readers to view different versions of the database
45477 ** on a network filesystem. All users of the database must be able to
45485 ** Hence, unlike the database and WAL file formats which store all values
45507 ** database page number associated with each wal frame, and a hash-table
45511 ** first index-block contains the database page number corresponding to the
45650 u16 szPage; /* Database page size in bytes. 1==64K */
45652 u32 nPage; /* Size of database in pages */
45664 ** back into the database. (We call the act of moving content from WAL to
45665 ** database "backfilling".) The nBackfill number is never greater than
45678 ** directly from the database.
45685 ** The checkpointer may only transfer frames from WAL to database where
45692 ** in the WAL has been backfilled into the database) then new readers
45694 ** get all their all content directly from the database file and ignore
45699 ** written back into the database) and if no readers are using the WAL
45743 ** assuming a database page size of szPage bytes. The offset returned
45756 sqlite3_file *pDbFd; /* File handle for the database file */
45763 u32 szPage; /* Database page size */
45803 ** all frames in the WAL in database page order. Where two or more frames
45804 ** correspond to the same database page, the iterator visits only the
46005 ** 4: For commit records, the size of the database image in pages
46014 u32 iPage, /* Database page number for frame */
46041 u32 *piPage, /* OUT: Database page number for frame */
46081 ** and the new database size.
46311 ** Set an entry in the wal-index that will map database page number
46453 /* If the database page size is not a power of two, or is greater than
46502 u32 pgno; /* Database page number for frame */
46580 ** Open a connection to the WAL file zWalName. The database file must
46584 ** A SHARED lock should be held on the database file when this function
46596 sqlite3_file *pDbFd, /* The open database file */
46961 ** Return the page-size in bytes used by the database.
46968 ** Copy as much content as we can from the WAL back into the database file
46971 ** The amount of information copies from WAL to database might be limited
46972 ** by active readers. This routine will never overwrite a database page
46981 ** into the database. This ensures that if the new content is persistent
46984 ** Fsync is also called on the database file if (and only if) the entire
46985 ** WAL content is copied into the database file. This second fsync makes
46987 ** database file.
47007 int szPage; /* Database page-size */
47009 u32 iDbpage = 0; /* Next database page to write */
47012 u32 mxPage; /* Max database page to write */
47033 ** safe to write into the database. Frames beyond mxSafeFrame might
47034 ** overwrite database pages that are in use by active readers and thus
47059 i64 nSize; /* Current size of database file */
47067 /* If the database file may grow as a result of this checkpoint, hint
47119 ** file has been copied into the database file, then block until all
47121 ** process to write to the database restarts the wal file.
47172 /* If an EXCLUSIVE lock can be obtained on the database file (using the
47175 ** the database. In this case checkpoint the database and unlink both
47399 ** access any database page that is modified by a WAL frame up to and
47403 ** completely and get all content directly from the database file.
47496 ** which implies that the database file contains a trustworthy
47504 ** it finished. Leaving a corrupt image in the database file.
47566 ** copied into the database by a checkpointer. If either of these things
47567 ** happened, then reading the database with the current value of
47592 ** Begin a read transaction on the database.
47600 ** If the database contents have changes since the previous read
47637 ** the WAL and needs to be read out of the database.
47641 Pgno pgno, /* Database page number to read data for */
47753 ** Return the size of the database in pages (or zero, if unknown).
47769 ** If another thread or process has written into the database since
47796 /* If another connection has written to the database file since the
47841 ** was in before the client began writing to the database.
48054 int szPage, /* Database page-size in bytes */
48056 Pgno nTruncate, /* Database size after this commit */
48124 ** database corruption. See the ticket:
48240 ** we can from WAL into the database.
48298 /* Copy data from the log to the database file. */
48317 ** next time the pager opens a snapshot on this database it knows that
48355 ** lock on the main database file.
48362 ** on the main database file before invoking this operation.
48366 ** should acquire the database exclusive lock prior to invoking
48418 ** read-lock. This function returns the database page-size if it is known,
48461 ** This file implements a external (disk-based) database using BTrees.
48468 ** The basic idea is that each page of the file contains N database
48487 ** fixed amount of payload can be carried directly on the database
48534 ** The file change counter is incremented when the database is changed
48671 /* The maximum number of cells on a single page of the database. This
48684 ** SQLite database in order to identify the file as a real database.
48773 ** A database connection contains a pointer to an instance of
48774 ** this object for every database file that it has open. This structure
48775 ** is opaque to the database connection. The database connection cannot
48779 ** For some database files, the same underlying database cache might be
48782 ** points to the same BtShared object. The database cache and the
48783 ** schema associated with the database file are all contained within
48793 sqlite3 *db; /* The database connection holding this btree */
48819 ** An instance of this object represents a single database file.
48821 ** A single database file can be in use at the same time by two
48822 ** or more database connections. When two or more connections are
48823 ** sharing the same database file, each connection has it own
48826 ** connections currently sharing this database file.
48837 ** If a BtShared client fails to obtain a write-lock on a database
48855 sqlite3 *db; /* Database connection currently using this Btree */
48857 MemPage *pPage1; /* First page of the database */
48873 u32 nPage; /* Number of pages in the database */
48893 #define BTS_INITIALLY_EMPTY 0x0008 /* Database was empty at trans start */
48918 ** maximum database size of 2^31 pages a minimum fanout of 2 for a
48922 ** assumed that the database is corrupt.
48928 ** b-tree within a database file.
48933 ** A single database file can be shared by two more database connections,
48935 ** particular database connection identified BtCursor.pBtree.db.
48997 ** The database page the PENDING_BYTE occupies. This page is never used.
49003 ** database page. The first argument to each is the number of usable
49004 ** bytes on each page of the database (often 1024). The second is the
49007 ** PTRMAP_PAGENO returns the database page number of the pointer-map
49022 ** each child page in the database file. The parent page is the page that
49023 ** contains a pointer to the child. Every page in the database contains
49024 ** 0 or 1 parent pages. (In this context 'database page' refers
49034 ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not
49037 ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
49040 ** PTRMAP_OVERFLOW1: The database page is the first page in a list of
49044 ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of
49048 ** PTRMAP_BTREE: The database page is a non-root btree page. The page number
49067 ** if the database supports auto-vacuum or not. Because it is used
49088 Pgno nPage; /* Number of pages in the database */
49110 ** set BtShared.db to the database handle associated with p and the
49147 ** by all database connections. The p->pNext is a list of other
49148 ** Btrees belonging to the same database connection as the p Btree
49171 /* We should already hold a lock on the database connection */
49174 /* Unless the database is sharable and unlocked, then BtShared.db
49260 ** Enter the mutex on every Btree associated with a database
49302 ** Return true if the current thread holds the database connection
49388 ** This file implements a external (disk-based) database using BTrees.
49395 ** SQLite database.
49441 ** This routine has no effect on existing database connections.
49485 ** When writing to an index that resides in a sharable database, the
49490 ** function has to search through the database schema.
49506 /* If this database is not shareable, or if the client is reading
49660 ** database (one with the BtShared.sharable flag set), and
49842 Btree *pBtree, /* The database file to check */
49873 ** a free-list leaf page, the page is not written to the database
49879 ** from the database or written to the journal file (why should it
49889 ** to restore the database to its original configuration.
50106 ** Given a page number of a regular database page, return the page
50712 ** indicates a corrupt database files:
50749 ** not contain a well-formed database page, then return
50794 /* A malformed database page might cause us to read past the end
50839 ** the free-block must lie on the database page. */
50863 ** Set up a raw page so that it looks like a database page holding
50956 ** Return the size of the database file in pages. If there is any kind of
50977 BtShared *pBt, /* The database file */
51054 ** Open a database file.
51056 ** zFilename is the name of the database file. If zFilename is NULL
51057 ** then an ephemeral database is created. The ephemeral database might
51059 ** Either way, the ephemeral database will be automatically deleted
51062 ** If zFilename is ":memory:" then an in-memory database is created
51068 ** If the database is already opened in the same database connection
51071 ** objects in the same database connection since doing so will lead
51076 const char *zFilename, /* Name of the file containing the BTree database */
51077 sqlite3 *db, /* Associated database handle */
51087 unsigned char zDbHeader[100]; /* Database header content */
51089 /* True if opening an ephemeral, temporary database */
51092 /* Set the variable isMemdb to true for an in-memory database, or
51093 ** false for a file-based database.
51107 /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */
51110 /* A BTREE_SINGLE database is always a temporary and/or ephemeral */
51233 /* If the magic name ":memory:" will create an in-memory database, then
51397 ** Close an open database and invalidate all cursors.
51462 ** and the database cannot be corrupted if this program
51464 ** an abrupt power failure when synchronous is off, the database
51466 ** Synchronous is on by default so database corruption is not
51480 ** how well the database resists damage due to OS crashes and power
51528 ** of the database file used for locking (beginning at PENDING_BYTE,
51587 ** Set the maximum page count for a database if mxPage is positive.
51619 ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
51666 ** Get a reference to pPage1 of the database file. This will
51670 ** well-formed database file, then SQLITE_CORRUPT is returned.
51671 ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM
51676 MemPage *pPage1; /* Page 1 of the database file */
51677 int nPage; /* Number of pages in the database */
51678 int nPageFile = 0; /* Number of pages in the database file */
51679 int nPageHeader; /* Number of pages in the database according to hdr */
51689 ** a valid database file.
51720 /* If the write version is set to 2, this database should be accessed
51759 /* After reading the first page of the database assuming a page size
51761 ** actually pageSize. Unlock the database, leave pBt->pPage1 at
51823 ** of a transaction but there is a read lock on the database, then
51824 ** this routine unrefs the first page of the database file which
51843 ** into a new empty database by initializing the first page of
51844 ** the database.
51890 ** to access the database. A preexisting transaction may not be
51895 ** changes to the database. None of the following routines
51907 ** and the database was previously unlocked, then invoke the busy handler
51936 /* Write transactions are not possible on a read-only database */
51943 /* If another database handle has already opened a write transaction
51979 ** reading page 1 it discovers that the page-size of the database
52028 ** client has been writing the database file), update it now. Doing
52029 ** this sooner rather than later means the database size can safely
52030 ** re-read the database size from page 1 if a savepoint or transaction
52166 ** Move the open database page pDbPage to location iFreePage in the
52167 ** database. The pDbPage reference remains valid.
52170 ** the journal needs to be sync()ed before database page pDbPage->pgno
52224 /* Fix the database pointer on page iPtrPage that pointed at iDbPage so
52256 ** database so that the last page of the file currently in use
52262 ** number of pages the database file will contain after this
52399 ** is commited for an auto-vacuum database.
52402 ** the database file should be truncated to during the commit process.
52403 ** i.e. the database has been reorganized so that only the first *pnTrunc
52415 Pgno nFin; /* Number of pages in database after autovacuuming */
52420 Pgno nOrig; /* Database size before freeing */
52424 /* It is not possible to create a database for which the final page
52471 ** the database can be restored to its original state by playing back
52474 ** database are written into the database file and flushed to oxide.
52482 ** Otherwise, sync the database file for the btree pBt. zMaster points to
52485 ** (single database transaction).
52491 ** the write-transaction for this database file is to delete the journal.
52523 /* If there are other active statements that belong to this database
52525 ** may still be reading from the database. */
52573 ** This will release the write lock on the database file. If there
52644 ** to other database connections that happen to be sharing
52678 ** This will release the write lock on the database file. If there
52790 /* The database size was written into the offset 28 of the header
52804 ** on the database already. If a write-cursor is requested, then
52815 ** 2: Other database connections that share the same pager cache
52819 ** the read cursors in the other database connection.
52821 ** 3: The database must be writable (not on read-only media)
52845 ** b-tree database, the connection is holding the required table locks,
52920 ** Set the cached rowid value of every cursor in the same database file
52950 ** Close a cursor. The read lock on the database file is released
53084 ** Given the page number of an overflow page in the database (parameter
53103 BtShared *pBt, /* The database file */
53162 ** pPayload is a pointer to data stored on database page pDbPage.
53339 ** 3) the database is file-backed, and
53341 ** 5) the database is not a WAL database,
53343 ** then data can be read directly from the database file into the
53450 ** page of the database. The data might change or move the next time
53595 ** below to be untrue if the database file is corrupt. This can occur if
53598 ** into more than one b-tree structure in a corrupt database. */
54047 ** Advance the cursor to the next entry in the database. If
54049 ** was already pointing to the last entry in the database before
54078 /* If the database file is corrupt, it is possible for the value of idx
54081 ** only happen if the database is corrupt in such a way as to link the
54122 ** Step the cursor to the back to the previous entry in the database. If
54124 ** was already pointing to the first entry in the database before
54182 ** Allocate a new page from the database file.
54195 ** attempt to keep related pages close to each other in the database file,
54196 ** which in turn can make database access faster.
54215 Pgno mxPage; /* Total size of the database file */
54295 /* Value of k is out of range. Database corruption */
54472 ** This function is used to add page iPage to the database file free-list.
54520 /* If the database supports auto-vacuum, write an entry in the pointer-map
54528 /* Now manipulate the actual database free-list structure. There are two
54641 ** file the database must be corrupt. */
54655 ** must not really be an overflow page and the database must be corrupt.
54765 /* If the database supports auto-vacuum, and the second or subsequent
54773 ** wrong pages from the database.
55074 BtShared *const pBt = pPage->pBt; /* B-Tree Database */
55104 /* If this is an auto-vacuum database, update the pointer map
55245 /* If this is an auto-vacuum database, update the pointer-map entries
55278 ** If this routine fails for any reason, it might leave the database
55279 ** in a corrupted state. So if this routine fails, the database should
55300 BtShared *pBt; /* The whole database */
55597 ** UPDATE: The assert() below is not necessarily true if the database
55665 ** When NB==3, this one optimization makes the database
55781 ** If this is an auto-vacuum database, the call to copyNodeContent()
55782 ** sets all pointer-map entries corresponding to database image pages
55787 ** is important if the parent page happens to be page 1 of the database
55894 ** debugging. This is usually disabled because a corrupt database may
56075 ** copied either into the body of a database page or into the new
56083 ** now stored either on real database pages or within the
56419 /* Creating a new table may probably require moving an existing database
56426 /* Read the value of meta[3] from the database to determine where the
56506 ** order either to increase the database filesize, or to decrement the
56542 ** Erase the given database page and all its children. Return
56591 ** Delete all information from a single table in the database. iTable is
56631 ** root page in the database file, then the last root page
56632 ** in the database file is moved into the slot formerly occupied by
56635 ** root pages are kept at the beginning of the database file, which
56651 ** database. This is because in auto-vacuum mode the backend may
56684 ** number in the database, put the root page on the free list.
56693 ** number in the database. So move the page that does into the
56717 /* Set the new 'max-root-page' value in the database header. This
56738 ** database.
56756 ** has a read or write transaction open on the database.
56758 ** Read the meta-information out of a database file. Meta[0]
56759 ** is the number of free pages currently in the database. Meta[1]
56779 ** database, mark the database as read-only. */
56790 ** Write meta-information back into the database. Meta[0] is
56823 ** Otherwise, if an error is encountered (i.e. an IO error or database
57038 /* If this database supports auto-vacuum and iPage is not the last
57363 /* If the database supports auto-vacuum, make sure no tables contain
57404 ** Return the full pathname of the underlying database file.
57415 ** Return the pathname of the journal file for this database. The return
57612 ** "write version" (single byte at byte offset 19) fields in the database
57673 sqlite3* pDestDb; /* Destination database handle */
57679 sqlite3* pSrcDb; /* Source database handle */
57701 ** backup_finish(). Both these functions obtain the source database
57707 ** the page cache associated with the source database. The mutex
57708 ** associated with the source database BtShared structure will always
57718 ** Depending on the SQLite configuration, the database handles and/or
57725 ** Return a pointer corresponding to database zDb (i.e. "main", "temp")
57726 ** in connection handle pDb. If such a database cannot be found, return
57729 ** If the "temp" database is requested, it may need to be opened by this
57758 sqlite3Error(pErrorDb, SQLITE_ERROR, "unknown database %s", zDb);
57781 ** stored in database handle pDestDb.
57784 sqlite3* pDestDb, /* Database to write to */
57785 database within pDestDb */
57786 sqlite3* pSrcDb, /* Database connection to read from */
57787 const char *zSrcDb /* Name of database within pSrcDb */
57791 /* Lock the source database handle. The destination database
57796 ** database connection while a backup is in progress may cause
57858 ** page iSrcPg from the source database. Copy this data into the
57859 ** destination database.
57880 /* Catch the case where the destination is an in-memory database and the
58000 /* Lock the destination database, if it is not locked already. */
58008 /* If there is no open read-transaction on the source database, open
58017 /* Do not allow backup if the destination database is in WAL mode
58026 /* Now that there is a read-lock on the source database, query the
58027 ** source pager for the number of pages in the database.
58053 /* Update the schema version field in the destination database. This
58071 ** database. The complication here is that the destination page
58102 ** pending-byte page in the source database may need to be
58103 ** copied into the destination database.
58117 ** database has been stored in the journal for pDestPager and the
58119 ** the database file in any way, knowing that if a power failure
58120 ** occurs, the original database will be reconstructed from the
58124 /* Write the extra pages and truncate the database file as required */
58144 /* Sync the database file to disk. */
58152 /* Finish committing the transaction to the destination database. */
58162 ** on the source database. Close the read transaction here. There is
58191 MUTEX_LOGIC( sqlite3_mutex *mutex; ) /* Mutex to protect source database */
58218 /* Set the error code of the destination database handle. */
58246 ** Return the total number of pages in the source database as of the most
58255 ** source database have been modified. If page iPage has already been
58256 ** copied into the destination database, then the data written to the
58262 ** corresponding to the source database is held when this function is
58289 ** detects that the database has been modified by an external database
58291 ** pages that have been copied into the destination database are still
58295 ** corresponding to the source database is held when this function is
58317 sqlite3_file *pFd; /* File descriptor for database pTo */
58342 /* 0x7FFFFFFF is the hard limit for the number of pages in a database
59275 ** that both the BtShared and database handle mutexes are held. */
59378 sqlite3 *db, /* The database connection */
59554 ** Create a new virtual database engine.
60508 ** of all of BtShared structures accessible via the database handle
60662 sqlite3 *db = p->db; /* The database connection */
60988 sqlite3 *db; /* The database connection */
61257 ** A read or write transaction may or may not be active on database handle
61259 ** write-transaction spanning more than one database file, this routine
61278 ** required, as an xSync() callback may add an attached database
61284 ** (b) how many database files have open write transactions, not
61285 ** including the temp database. (b) is important because if more than
61286 ** one database file has an open write transaction, a master journal
61309 /* The simple case - no more than one database file (not counting the
61310 ** TEMP database) has a transaction active. There is no need for the
61314 ** string, it means the main database is :memory: or a temp file. In
61397 /* Write the name of each database file in the transaction into the new
61581 ** database handles deferred constraint counter to the value it had when
61591 ** This function is called when a transaction opened by the database
61673 ** transaction must be rolled back to restore the database to a
61678 ** occured while writing to the journal, sub-journal or database
61774 ** has been rolled back, update the database connection change-counter.
61826 ** as the first argument to its database handle (so that they will be
61830 ** copies them to the database handle.
61870 ** and error message from the VDBE into the main database structure. But
61872 ** instructions yet, leave the main database error information unchanged.
61882 ** called), set the database error in this case as well.
61959 ** the database connection.
62565 ** pCur might be pointing to text obtained from a corrupt database file.
62579 ** than 2GiB are support - anything large must be database corruption.
62629 /* Jump here if database corruption is detected after m has been
62680 ** sqlite3_changes() on the database handle 'db'.
62697 ** Mark every prepared statement associated with a database connection
62714 ** Return the database associated with the Vdbe.
63213 ** caller. Set the error code in the database handle to the same value.
63238 sqlite3 *db; /* The database connection */
63254 ** into the database handle. This block copies the error message
63255 ** from the database handle into the statement and sets the statement
63289 ** returns a copy of the pointer to the database connection (the 1st
63602 ** 2 The name of the database that the column derives from
63682 ** Return the name of the database from which a result column derives.
63684 ** anything else which is not an unabiguous reference to a database column.
63700 ** anything else which is not an unabiguous reference to a database column.
63716 ** anything else which is not an unabiguous reference to a database column.
63743 ** The error code stored in database p->db is overwritten with the return
63997 ** database connections. But as this is a deprecated interface, we
64021 ** Return the sqlite3* database handle to which the prepared statement given
64022 ** in the argument belongs. This is the same database handle that was
64032 ** database.
64048 ** with database connection pDb. If pStmt is NULL, return the first
64049 ** prepared statement for the database connection. Return NULL if there
64144 sqlite3 *db; /* The database connection */
64360 ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c")
64538 int iDb, /* Database the cursor belongs to, or -1 */
64961 ** If an attempt is made to open a locked database, then this routine
64988 sqlite3 *db = p->db; /* The database */
64990 u8 encoding = ENC(db); /* The database encoding */
65231 const char *zDb; /* database name - used by the update hook */
65371 const char *zFilename; /* Name of database file for pPager */
67106 ** nullRow or because of a corrupt database. */
67155 ** the database file has been corrupted externally.
67159 /* Make sure a corrupt database has not given us an oversize header.
67178 ** allocation, especially if a corrupt database file has caused u.an.offset
67184 ** not exceeded even for corrupt database files.
67245 ** with a corrupt database.
67338 ** use as a data record in a database table or as a key
67558 /* Link the new savepoint into the database handle's list. */
67636 ** constraint violations present in the database to the value stored
67661 ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll
67741 ** P1 is the index of the database file on which the transaction is
67742 ** started. Index 0 is the main database file and index 1 is the
67747 ** obtained on the database file when a write-transaction is started. No
67751 ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
67757 ** More specifically, a statement transaction is opened iff the database
67764 ** If P2 is zero, then a read-lock is obtained on the database file.
67801 /* Store the current value of the database handles deferred constraint
67812 ** Read cookie number P3 from database P1 and write it into register P2.
67813 ** P3==1 is the schema version. P3==2 is the database format.
67815 ** the main database file and P1==1 is the database file used to store
67818 ** There must be a read-lock on the database (either a transaction
67844 ** into cookie number P2 of database P1. P2==1 is the schema version.
67845 ** P2==2 is the database format. P2==3 is the recommended pager cache
67846 ** size, and so forth. P1==0 is the main database file and P1==1 is the
67847 ** database file used to store temporary tables.
67874 /* Invalidate all prepared statements whenever the TEMP database
67884 ** Check the value of global database parameter number 0 (the
67888 ** P1 is the database number which is 0 for the main database file
67892 ** The cookie changes its value whenever the database schema changes.
67919 p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
67920 /* If the schema-cookie from the database file matches the cookie
67922 ** not reload the schema from the database file.
67928 ** discard the database schema, as the user code implementing the
67945 ** Open a read-only cursor for the database table whose root page is
67946 ** P2 in a database file. The database file is determined by P3.
67947 ** P3==0 means the main database, P3==1 means the database used for
67949 ** database. Give the new cursor an identifier of P1. The P1
67956 ** There will be a read lock on the database whenever there is an
67957 ** open cursor. If the database was unlocked prior to this instruction
67959 ** lock allows other processes to read the database but prohibits
67960 ** any other process from modifying the database. The read lock is
68066 ** and report database corruption if they were not, but this check has
68077 ** the main database is read-only. The ephemeral
68702 ** The record number is not previously used as a key in the database
68812 ** largest possible integer (9223372036854775807) then the database
68903 const char *zDb; /* database name - used by the update hook */
69032 ** The value of the change counter is copied to the database handle
69091 ** it is found in the database file.
69101 ** it is found in the database file.
69246 ** will refer to the last entry in the database table or index.
69304 ** will refer to the first entry in the database table or index.
69610 ** Delete an entire database table or index whose root page in the database
69613 ** The table being destroyed is in the main database file if P3==0. If
69614 ** P3==1 then the table to be clear is in the auxiliary database file
69619 ** root pages contiguous at the beginning of the database. The former
69623 ** the last one in the database) then a zero is stored in register P2.
69670 ** Delete all contents of the database table or index whose root page
69671 ** in the database file is given by P1. But, unlike Destroy, do not
69672 ** remove the table or index from the database file.
69674 ** The table being clear is in the main database file if P2==0. If
69675 ** P2==1 then the table to be clear is in the auxiliary database file
69709 ** Allocate a new table in the main database file if P1==0 or in the
69710 ** auxiliary database file if P1==1 or in an attached database if
69722 ** Allocate a new index in the main database file if P1==0 or in the
69723 ** auxiliary database file if P1==1 or in an attached database if
69755 ** Read and parse all entries from the SQLITE_MASTER table of database P1
69813 ** Read the sqlite_stat1 table for database P1 and load the content
69827 ** the table named P4 in database P1. This is called after a table
69839 ** the index named P4 in database P1. This is called after an index
69851 ** the trigger named P4 in database P1. This is called after a trigger
69864 ** Do an analysis of the currently open database. Store in
69873 ** The root page numbers of all tables in the database are integer
69877 ** If P5 is not zero, the check is done on the auxiliary database
69878 ** file, not the main database file.
70181 ** If P1 is non-zero, the database constraint counter is incremented
70200 ** If P1 is non-zero, then the jump is taken if the database constraint-counter
70397 ** Checkpoint database P1. This is a no-op if P1 is not currently in
70434 ** Change the journal mode of database P1 to P3. P3 must be one of the
70449 const char *zFilename; /* Name of database file for pPager */
70472 /* Do not allow a transition to journal_mode=WAL for a database
70497 ** file. An EXCLUSIVE lock may still be held on the database file
70510 /* Open a transaction on the database file. Regardless of the journal
70539 ** Vacuum the entire database. This opcode will cause other virtual
70553 ** the P1 database. If the vacuum has finished, jump to instruction
70597 ** P1 is the index of the database in sqlite3.aDb[] of the database
70616 sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z);
70647 ** P4 is the name of a virtual table in database P1. Call the xCreate method
70659 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
71002 ** Write the current number of pages in database P1 to memory cell P2.
71014 ** Try to set the maximum page count for database P1 to the value in P3.
71216 sqlite3 *db; /* The associated database */
71293 sqlite3* db, /* The database connection */
71294 const char *zDb, /* The attached database containing the blob */
71615 ** database table.
71619 ** database handle error code and message set. If this happens, then all
71809 sqlite3 *db, /* Database handle (for sqlite3DbMalloc() ) */
71915 sqlite3 *db, /* Database handle */
72041 int pgsz; /* Page size of main database */
72264 sqlite3 *db, /* Database handle */
72310 sqlite3 *db, /* Database handle */
73234 database connection */
73302 ** pExpr->iDb Set the index in db->aDb[] of the database X
73313 ** The zDb variable is the name of the database (the "X"). This value may be
73314 ** NULL meaning that name is of the form Y.Z or Z. Any available database
73325 const char *zDb, /* Name of the database containing table, or NULL */
73334 sqlite3 *db = pParse->db; /* The database connection */
73669 ** Or a database, table and column: ID.ID.ID
73705 u8 enc = ENC(pParse->db); /* The database encoding */
73852 sqlite3 *db; /* Database connection */
74117 sqlite3 *db; /* Database connection */
74297 ** X: The name of a database. Ex: "main" or "temp" or
74298 ** the symbolic name assigned to an ATTACH-ed database.
75248 ** part of the in-memory representation of the database schema.
75797 ** The index of the cursor opened on the b-tree (database table, database index
75801 ** IN_INDEX_ROWID - The cursor was opened on a database table.
75802 ** IN_INDEX_INDEX - The cursor was opened on a database index.
75861 sqlite3 *db = pParse->db; /* Database connection */
75865 int iDb; /* Database idx for pTab */
76279 ** of a "NOT NULL" constraint in the database schema.
76688 sqlite3 *db = pParse->db; /* The database connection */
76957 u8 enc = ENC(db); /* The text encoding used by this database */
78648 ** Note that ON cannot be a database, table or column name, so
78738 ** temporary database, NULL is returned.
78768 ** pTab from the database, including triggers and temporary triggers.
78769 ** Argument zName is the name of the table in the database schema at
78777 int iDb; /* Index of database containing pTab */
78806 /* Now, if the table is not stored in the temp database, reload any temp
78840 int iDb; /* Database that contains the table */
78841 char *zDb; /* Name of database iDb */
78844 sqlite3 *db = pParse->db; /* Database connection */
78870 ** in database iDb. If so, this is an error.
78914 /* Begin a transaction and code the VerifyCookie for database iDb.
78985 database, then update
78998 ** the temp database.
79068 int iDb; /* Database number */
79069 const char *zDb; /* Database name */
79074 sqlite3 *db; /* The database connection; */
79407 int iDb, /* The database
79706 sqlite3 *db = pParse->db; /* Database handle */
79714 int iDb; /* Index of database containing pTab */
79986 ** Generate code that will do an analysis of an entire database
79990 Schema *pSchema = db->aDb[iDb].pSchema; /* Schema of database iDb */
80010 ** a database. If pOnlyIdx is not NULL then it is a single index
80037 ** ANALYZE <database> -- 2
80038 ** ANALYZE ?<database>.?<tablename> -- 3
80041 ** Form 2 analyzes all indices the single database named.
80053 /* Read the database schema. If an error occurs, leave an error message
80064 if( i==1 ) continue; /* Do not analyze the TEMP database */
80068 /* Form 2: Analyze the database or table named */
80326 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
80332 ** sqlite_stat3 table is not present in the database, SQLITE_ERROR is
80421 ** ATTACH DATABASE abc AS def
80428 ** ATTACH DATABASE abc||def AS 'db2'
80453 ** ATTACH DATABASE x AS y KEY z
80488 ** * Specified database name already being used.
80497 zErrDyn = sqlite3MPrintf(db, "cannot ATTACH database within transaction");
80504 zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName);
80524 /* Open the database file. If the btree is successfully opened, use
80525 ** it to obtain the database schema. At this point the schema may
80543 zErrDyn = sqlite3MPrintf(db, "database is already attached");
80551 "attached databases must use the same text encoding as main database");
80588 /* No key specified. Use the key from the main database */
80598 /* If the file was opened successfully, read the schema for the new database.
80623 zErrDyn = sqlite3MPrintf(db, "unable to open database: %s", zFile);
80643 ** DETACH DATABASE x
80668 sqlite3_snprintf(sizeof(zErr),zErr, "no such database: %s", zName);
80672 sqlite3_snprintf(sizeof(zErr),zErr, "cannot detach database %s", zName);
80677 "cannot DETACH database within transaction");
80681 sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
80704 Expr *pFilename, /* Name of database file */
80705 Expr *pDbname, /* Name of the database to use internally */
80706 Expr *pKey /* Database key for encryption extension */
80818 ** means we do need to fix the database references, FALSE means we do not.
80823 int iDb, /* This is the database that must be used */
80841 ** a specific database to all table references where the database name
80846 ** view in one database does not refer to objects in a different database.
80847 ** (Exception: indices, triggers, and views in the TEMP database are
80849 ** to an object in a different database, an error message is added to
80868 "%s %T cannot reference objects in database %s",
80882 Select *pSelect /* The SELECT statement to be fixed to one database */
80903 Expr *pExpr /* The expression to be fixed to one database */
80921 ExprList *pList /* The expression to be fixed to one database */
80938 TriggerStep *pStep /* The trigger step be fixed to one database */
80986 ** various fields of the database. The first argument to the auth function
81050 ** table zTab in database zDb. This function assumes that an authorization
81061 int iDb /* Index of containing database. */
81063 sqlite3 *db = pParse->db; /* Database handle */
81064 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
81100 int iDb; /* The index of the database the expression refers to */
81157 /* Don't do any authorization checks if the database is initialising
81249 int iDb; /* The database containing the table to be locked */
81258 ** The table to be locked has root page iTab and is found in database iDb.
81267 int iDb, /* Index of the database containing the table to lock */
81351 /* The cookie mask contains one bit for each database file open.
81353 ** set for each database that is used. Generate code to start a
81354 ** transaction on each used database and to verify the schema cookie
81355 ** on each used database.
81463 ** Locate the in-memory structure that describes a particular database
81465 ** database containing the table. Return NULL if not found.
81493 ** Locate the in-memory structure that describes a particular database
81495 ** database containing the table. Return NULL if not found. Also leave an
81506 const char *zDbase /* Name of the database. Might be NULL */
81510 /* Read the database schema. If an error occurs, leave an error message
81532 ** and the name of the database that contains the index.
81571 ** For the index called zIdxName which is found in the database iDb,
81605 ** a single database. This routine is called to reclaim memory
81606 ** before the database closes. It is also called during a rollback
81610 ** If iDb<0 then reset the internal schema tables for all database
81625 /* If any database other than TEMP is reset, then also reset TEMP
81627 ** other database.
81650 /* If one or more of the auxiliary database files has been closed,
81651 ** then remove them from the auxiliary database list. We take the
81800 ** Open the sqlite_master table stored in database number iDb for
81815 ** of a database ("main", "temp" or the name of an attached db). This
81816 ** function returns the index of the named database in db->aDb[], or
81820 int i = -1; /* Database number */
81835 ** The token *pName contains the name of a database (either "main" or
81837 ** index of the named database in db->aDb[], or -1 if the named db
81841 int i; /* Database number */
81863 ** database "xxx" is returned.
81871 int iDb; /* Database holding the object */
81876 sqlite3ErrorMsg(pParse, "corrupt database");
81883 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
81917 ** flag is true if the table should be stored in the auxiliary database
81918 ** file instead of in the main database file. This is normally the case
81941 int iDb; /* Database number to create the table in */
81958 ** set to the index of the database that the table or view is to be
81965 ** the database name is "temp" anyway. */
82006 ** index or table name in the same database. Issue an error message if
82049 ** then record a pointer to this table in the main database structure
82079 /* If the file format and encoding in the database have not been set,
82458 ** This function returns the collation sequence for database native text
82462 ** in the database native encoding, the collation factory is invoked to
82499 ** database changes. After each schema change, the cookie value
82501 ** cookie. Thereafter, whenever it goes to access the database,
82653 ** connected to the database or because the sqlite_master table has
82715 ** in the SQLITE_MASTER table of the database.
82718 ** file instead of into the main database file.
82757 ** a schema-lock excludes all other database users, the write-lock would
82834 /* Add the table to the in-memory representation of the database.
82952 sqlite3 *db = pParse->db; /* Database connection for malloc errors */
83040 ** Clear the column names from every VIEW in database idx.
83063 ** root-page of a table or index in database iDb has changed from iFrom
83103 ** Write code to erase the table with root-page iTable from database iDb.
83106 ** erasing iTable (this can happen with an auto-vacuum database).
83134 ** is also added (this can happen with an auto-vacuum database).
83145 /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM
83157 ** database, then root page 5 would be moved to page 4 by the
83195 int iDb, /* The database number */
83262 ** created in the temp database that refers to a table in another
83263 ** database.
83558 sqlite3 *db = pParse->db; /* The database connection */
83688 DbFixer sFix; /* For assigning database names to pTable */
83691 Db *pDb; /* The specific table containing the indexed database */
83692 int iDb; /* Index of the database that is being written */
83713 /* Use the two-part index name to determine the database
83724 ** is a temp table. If so, set the database to 1. Do not do this
83725 ** if initialising a database schema.
84023 ** in-memory database structures.
84047 ** command. db->init.busy is 1 when a database is opened and
84362 sqlite3 *db, /* Database connection to notify of OOM errors */
84419 ** database name prefix. Like this: "database.table". The pDatabase
84420 ** points to the table name and the pTable points to the database name.
84423 ** SrcList.a[].zDatabase is filled with the database name from pTable,
84424 ** or with NULL if no database is specified.
84430 ** Then B is a table name and the database name is unspecified. If called
84435 ** Then C is the table name and B is the database name. If C is defined
84447 Token *pDatabase /* Database of the table */
84518 ** are the name of the table and database named in the FROM clause term.
84519 ** pDatabase is NULL if the database name qualifier is missing - the
84533 Token *pDatabase, /* Name of the database containing pTable */
84695 ** Make sure the TEMP database is open and available for use. Return
84712 sqlite3ErrorMsg(pParse, "unable to open a temporary database "
84729 ** a read-transaction for all named database files.
84738 ** record every database that needs its schema verified in the
84747 ** early in the code, before we know if any database tables will be used.
84778 ** attached database. Otherwise, invoke it for the database named zDb only.
84793 ** might change the database.
84801 ** can be checked before any changes are made to the database, it is never
84826 ** perform this abort without corrupting the database, we need to make
84901 Db *pDb; /* A single database */
84902 int iDb; /* The database index number */
84903 sqlite3 *db = pParse->db; /* The database connection */
84905 Table *pTab; /* A table in the database */
84923 ** REINDEX ?<database>.?<tablename> -- 3
84924 ** REINDEX ?<database>.?<indexname> -- 4
84935 const char *zDb; /* Name of the database */
84936 Table *pTab; /* A table in the database */
84938 int iDb; /* The database index number */
84939 sqlite3 *db = pParse->db; /* The database connection */
84942 /* Read the database schema. If an error occurs, leave an error message
84988 ** with OP_OpenRead or OP_OpenWrite to access database index pIdx.
85096 ** If it is not NULL, then pColl must point to the database native encoding
85099 ** The return value is either the collation sequence to be used in database
85106 sqlite3* db, /* The database connection */
85134 ** a database is loaded that contains references to collation sequences
85140 ** from the main database is substituted, if one is available.
85173 sqlite3 *db, /* Database connection */
85213 ** for the encoding 'enc' from the database 'db'.
85349 sqlite3 *db, /* An open database */
85709 Vdbe *v; /* The virtual database engine */
85711 const char *zDb; /* Name of database holding pTab */
85717 sqlite3 *db; /* Main database structure */
85720 int iDb; /* Database number */
85867 ** database scan. We have to delete items after the scan is complete
86440 ** the database handle that malloc() has failed and return NULL.
87492 ** returns (void *)db, where db is the sqlite3* database pointer.
87783 ** with the database handle. The counter is set to zero each time a
87784 ** database transaction is opened. Each time a statement is executed
87787 ** the database, the counter is decremented. When the transaction is
87795 ** * If the database contains foreign key violations when the
88068 int iDb, /* Index of database housing pTab */
88231 sqlite3 *db = pParse->db; /* Database handle */
88356 ** the lookaside buffer belonging to database handle dbMem.
88371 ** being dropped from the database. The SrcList passed as the second argument
88380 ** constraint violations in the database,
88383 ** the table from the database. Triggers are disabled while running this
88453 sqlite3 *db = pParse->db; /* Database handle */
88455 int iDb; /* Index of database containing pTab */
88456 const char *zDb; /* Name of database containing pTab */
88727 sqlite3 *db = pParse->db; /* Database handle */
88996 int iDb, /* The database index in sqlite3.aDb[] */
89103 ** Return non-zero if the table pTab in database iDb or any of its indices
89146 ** which is in database iDb. Return the register number for the register
89166 int iDb, /* Index of the database holding pTab */
89198 sqlite3 *db = pParse->db; /* The database connection */
89199 Db *pDb; /* Database only autoinc table */
89302 int iDbDest /* The database of pDest */
89415 sqlite3 *db; /* The main database structure */
89418 const char *zDb; /* Name of the database holding this table */
89433 int iDb; /* Index of database holding TABLE */
89434 Db *pDb; /* The database containing table being inserted into */
90580 int iDbDest /* The database of pDest */
90587 int iDbSrc; /* The database of pSrc */
90848 sqlite3 *db, /* The database on which the SQL executes */
91810 sqlite3 *db, /* Load the extension into this database connection */
91891 sqlite3 *db, /* Load the extension into this database connection */
91905 ** Call this routine when the database connection is closing in order
91976 ** loaded by every new database connection.
92037 ** If anything goes wrong, set an error in the database connection.
92164 ** backed temporary databases, 2 for the Red-Black tree in memory database
92203 ** If the TEMP database is open, close it and mark the database schema
92367 ** PRAGMA [database.]id [= value]
92373 ** If the left side is "database.id" then pId1 is the database name
92379 Token *pId1, /* First part of [database.]id field */
92380 Token *pId2, /* Second part of [database.]id field, or NULL */
92386 const char *zDb = 0; /* The database name */
92388 int iDb; /* Database index for <database> */
92391 sqlite3 *db = pParse->db; /* The database connection */
92392 Db *pDb; /* The specific database being pragmaed */
92399 /* Interpret the [database.] part of the pragma statement. iDb is the
92400 ** index of the database this pragma is being applied to in db.aDb[]. */
92405 /* If the temp database has been explicitly named as part of the
92456 ** PRAGMA [database.]default_cache_size
92457 ** PRAGMA [database.]default_cache_size=N
92463 ** stored in the database file.
92507 ** PRAGMA [database.]page_size
92508 ** PRAGMA [database.]page_size=N
92511 ** database page size in bytes. The second form sets the
92512 ** database page size value. The value can only be set if
92513 ** the database has not yet been created.
92533 ** PRAGMA [database.]secure_delete
92534 ** PRAGMA [database.]secure_delete=ON/OFF
92558 ** PRAGMA [database.]max_page_count
92559 ** PRAGMA [database.]max_page_count=N
92562 ** maximum number of pages in the database file. The
92570 ** PRAGMA [database.]page_count
92572 ** Return the number of pages in the specified database.
92593 ** PRAGMA [database.]locking_mode
92594 ** PRAGMA [database.]locking_mode = (normal|exclusive)
92603 ** the locking-mode of the main database).
92609 /* This indicates that no database name was specified as part
92640 ** PRAGMA [database.]journal_mode
92641 ** PRAGMA [database.]journal_mode =
92649 ** database files to be opened and the journal_modes set. This is
92690 ** PRAGMA [database.]journal_size_limit
92691 ** PRAGMA [database.]journal_size_limit=N
92709 ** PRAGMA [database.]auto_vacuum
92710 ** PRAGMA [database.]auto_vacuum=N
92712 ** Get or set the value of the database 'auto-vacuum' parameter.
92737 ** creates the database file. It is important that it is created
92743 ** "incremental", write the value of meta[6] in the database
92745 ** that this really is an auto-vacuum capable database.
92770 ** PRAGMA [database.]incremental_vacuum(N)
92772 ** Do N steps of incremental vacuuming on a database.
92795 ** PRAGMA [database.]cache_size
92796 ** PRAGMA [database.]cache_size=N
92823 ** value will be restored the next time the database is opened.
92890 ** PRAGMA [database.]lock_proxy_file
92891 ** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
92894 ** the value sets a specific file to be used for database access locks.
92932 ** PRAGMA [database.]synchronous
92933 ** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL
92937 ** default value will be restored the next time the database is
93172 ** integrity_check designed to detect most database corruption
93209 /* Do an integrity check on each database file */
93225 ** for all tables and indices in the database.
93250 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName),
93340 ** database. If the database is not initialized, it is initialized now.
93342 ** The second form of this pragma is a no-op if the main database file
93344 ** encoding that will be used for the main database file if a new file
93345 ** is created. If an existing main database file is opened, then the
93346 ** default text encoding for the existing database is used.
93349 ** created to use the same default text encoding as the main database. If
93350 ** the main database has not been initialized and/or created when ATTACH
93354 ** new database files created using this database handle. It is only
93355 ** useful if invoked immediately after the main database i
93384 /* Only change the value of sqlite.enc if the database handle is not
93385 ** initialized. If the main database exists, the new sqlite.enc value
93409 ** PRAGMA [database.]schema_version
93410 ** PRAGMA [database.]schema_version = <integer>
93412 ** PRAGMA [database.]user_version
93413 ** PRAGMA [database.]user_version = <integer>
93418 ** stored in the database header.
93421 ** is incremented by SQLite whenever the database schema is modified (by
93425 ** the database against which the compiled query is actually executed.
93428 ** crashes or database corruption. Use with caution!
93502 ** PRAGMA [database.]wal_checkpoint = passive|full|restart
93504 ** Checkpoint the database.
93531 ** Configure a database connection to automatically checkpoint a database
93549 ** current database connection.
93566 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC);
93662 ** interface, and routines that contribute to loading the database schema
93668 ** that the database is corrupt.
93679 "malformed database schema (%s)", zObj);
93690 ** database. See sqlite3Init() below for additional information.
93775 ** Attempt to read the database schema and initialize internal
93776 ** data structures for a single database file. The index of the
93777 ** database file is given by iDb. iDb==0 is used for the main
93778 ** database. iDb==1 should never be used. iDb>=2 is used for
93796 ** The master database table has a structure like this
93827 ** and initialisation script appropriate for the database being
93856 /* Create a cursor to hold the database open
93867 ** on the b-tree database, open one now. If a transaction is opened, it
93879 /* Get the database meta information.
93901 /* If opening a non-empty database, check the text encoding. For the
93902 ** main database, set sqlite3.enc to the encoding of the main database.
93909 /* If opening the main database, set ENC(db). */
93915 /* If opening an attached database, the encoding much match ENC(db) */
93918 " text encoding as main database");
93955 /* Ticket #2804: When we open a database in the newer file format,
93957 ** not downgrade the database and thus invalidate any descending
94026 ** Initialize all database files - the main database file, the file
94027 ** used to store temporary tables, and any additional database files
94031 ** After a database is initialized, the DB_SchemaLoaded bit is set
94032 ** bit is set in the flags field of the Db structure. If the database
94051 ** for the TEMP database. This is loaded last, as the TEMP database
94073 ** This routine is a no-op if the database schema is already initialised.
94106 Btree *pBt = db->aDb[iDb].pBt; /* Btree database to read cookie from */
94110 ** on the b-tree database, open one now. If a transaction is opened, it
94121 /* Read the schema cookie from the database. If it does not match the
94140 ** which database file in db->aDb[] the schema refers to.
94142 ** If the same database is attached more than once, the first
94143 ** attached database is returned.
94174 sqlite3 *db, /* Database handle. */
94199 ** database schemas. The inability to get a read lock indicates that
94200 ** some other database connection is holding a write-lock, which in
94228 sqlite3Error(db, rc, "database schema is locked: %s", zDb);
94334 sqlite3 *db, /* Database handle. */
94406 sqlite3 *db, /* Database handle. */
94418 sqlite3 *db, /* Database handle. */
94436 sqlite3 *db, /* Database handle. */
94486 sqlite3 *db, /* Database handle. */
94498 sqlite3 *db, /* Database handle. */
95533 ** database table or a subquery.
95764 sqlite3 *db = pParse->db; /* Database connection */
96082 sqlite3 *db; /* Database connection */
96704 sqlite3 *db; /* Database connection */
97634 ** where table is a database table, not a sub-select or view. If the query
98288 sqlite3 *db; /* The database connection */
98526 /* Begin the database scan. */
98588 /* End the database scan loop.
99235 ** Query the database. But instead of invoking a callback for each row,
99245 sqlite3 *db, /* The database on which the SQL executes */
99362 ** All of the triggers on pTab that are in the same database as pTab
99420 sqlite3 *db = pParse->db; /* The database connection */
99421 int iDb; /* The database to store the trigger in */
99424 int iTabDb; /* Index of the database holding pTab */
99454 ** To maintain backwards compatibility, ignore the database
99463 ** then set iDb to 1 to create the trigger in the temporary database.
99473 /* Ensure the table name matches database name and that the table exists */
99487 ** and the table is dropped by a different database connection, the
99488 ** trigger is not visible to the database connection that does the
99603 sqlite3 *db = pParse->db; /* The database */
99605 int iDb; /* Database containing the trigger */
99695 sqlite3 *db, /* Database connection */
99720 sqlite3 *db, /* The database connection */
99753 sqlite3 *db, /* The database connection */
99778 sqlite3 *db, /* Database connection */
99807 ** This function is called to drop a trigger from the database schema.
99891 /* Generate code to destroy the database record of the trigger.
99998 ** This routine adds a specific database name, if needed, to the target when
99999 ** forming the SrcList. This prevents a trigger in one database from
100000 ** referring to a target in another database. An exception is when the
100001 ** trigger is in TEMP in which case it can refer to any other database it
100008 int iDb; /* Index of the database to use */
100146 sqlite3 *db = pParse->db; /* Database handle */
100551 Vdbe *v; /* The virtual database engine */
100555 sqlite3 *db; /* The database structure */
100565 int iDb; /* Database containing the table being updated */
100624 /* Allocate a cursors for the main database table and for all indices.
100626 ** need to occur right after the database cursor. So go ahead and
100763 /* Begin the database scan
100779 /* End the database scan loop.
100872 ** the database after the BEFORE triggers are fired anyway (as the trigger
101068 sqlite3 *db = pParse->db; /* Database connection */
101160 ** Execute zSql on database db. Return an error code.
101178 ** Execute zSql on database db. The statement returns exactly
101179 ** one column. Execute this as SQL on the same database.
101200 ** The non-standard VACUUM command is used to clean up the database,
101205 ** gdbm_reorganize() on all the database tables. But beginning
101222 Btree *pMain; /* The database being vacuumed */
101223 Btree *pTemp; /* The temporary database we vacuum into */
101229 Db *pDb = 0; /* Database to detach at end of vacuum */
101230 int isMemDb; /* True if vacuuming a :memory: database */
101243 /* Save the current value of the database flags so that it can be
101257 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
101259 ** occurs anyway. The integrity of the database is maintained by a
101260 ** (possibly synchronous) transaction opened on the main database before
101285 /* The call to execSql() to attach the temp database has left the file
101293 /* A VACUUM cannot change the pagesize of an encrypted database. */
101307 /* Begin a transaction and take an exclusive lock on the main database
101309 ** to ensure that we do not try to change the page-size on a WAL database.
101316 database */
101335 /* Query the schema of the main database. Create a mirror schema
101336 ** in the temporary database.
101353 /* Loop through the tables in the main database. For each, do
101355 ** the contents to the temporary database.
101381 /* Copy the triggers, views, and virtual tables from the main database
101382 ** over to the temporary database. None of these objects has any
101396 ** vacuum database and the main database. Assuming no error occurs,
101397 ** both transactions are closed by this block - the main database
101409 ** connections to the same database will know to reread the schema.
101451 ** database. No locks are held on any other files (since the main file
101454 ** vacuum database. The vacuum_db journal file is deleted when the pager
101509 sqlite3 *db, /* Database in which module is registered */
101551 sqlite3 *db, /* Database in which module is registered */
101563 sqlite3 *db, /* Database in which module is registered */
101621 ** database connections to be disconnected at the next opportunity.
101630 /* Assert that the mutex (if any) associated with the BtShared database
101634 ** database connection that may have an entry in the p->pVTable list.
101667 ** associated with the database handle itself must be held.
101671 ** associated with the database the virtual table is stored in is held
101672 ** or, if the virtual table is stored in a non-sharable database, then
101673 ** the database handle mutex is held.
101703 ** The reference count of the VTable structure associated with database
101707 ** database connection.
101753 Token *pName1, /* Name of new table, or database name */
101758 int iDb; /* The database the table is being created in */
101760 sqlite3 *db; /* Database connection */
101811 sqlite3 *db = pParse->db; /* The database connection */
102089 ** of the virtual table named zTab in database iDb.
102194 ** of the virtual table named zTab in database iDb. This occurs
102406 sqlite3 *db, /* Database connection for reporting malloc problems */
103220 sqlite3 *db = pParse->db; /* Database connection */
103403 ** to "bitmap indices" in other database engines.
103416 sqlite3 *db = pParse->db; /* Database connection */
103679 sqlite3 *db = pParse->db; /* Database connection */
104065 ** is redundant. A DISTINCT list is redundant if the database contains a
105003 Parse *pParse, /* Database connection */
106273 sqlite3 *db = pParse->db; /* Database handle */
107170 Vdbe *v = pParse->pVdbe; /* The virtual database engine */
107178 sqlite3 *db; /* Database connection */
107312 ** pWInfo->a[].iTabCur The VDBE cursor for the database table
107543 int iDb; /* Index of database containing table/index */
108616 26, /* DATABASE => ID */
108731 "DATABASE", "DESC", "DETACH", "EACH",
109094 /* 303 */ "database_kw_opt ::= DATABASE",
111005 /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);
111495 testcase( i==16 ); /* DATABASE */
111940 sqlite3 *db = pParse->db; /* The database connection */
112699 ** there are outstanding database connections or memory allocations or
112736 ** database connections or memory allocations. This routine is not
112762 /* Disable mutexing of database connections */
112914 ** Set up the lookaside buffers for a database connection.
112978 ** Return the mutex associated with a database connection.
112985 ** Free up as much memory as we can from the given database
113005 ** Configuration settings for an individual database connection
113131 ** Return the number of changes since the database handle was opened.
113139 ** database handle object, it does not close any savepoints that may be open
113171 ** Close an existing SQLite database
113280 /* The temp-database schema is allocated differently from the other schema
113283 ** the same sqliteMalloc() as the one that allocates the database
113299 ** Rollback all database files. If tripCode is not SQLITE_OK, then
113343 /* SQLITE_ERROR */ "SQL logic error or missing database",
113347 /* SQLITE_BUSY */ "database is locked",
113348 /* SQLITE_LOCKED */ "database table is locked",
113350 /* SQLITE_READONLY */ "attempt to write a readonly database",
113353 /* SQLITE_CORRUPT */ "database disk image is malformed",
113355 /* SQLITE_FULL */ "database or disk is full",
113356 /* SQLITE_CANTOPEN */ "unable to open database file",
113359 /* SQLITE_SCHEMA */ "database schema has changed",
113366 /* SQLITE_FORMAT */ "auxiliary database format error",
113368 /* SQLITE_NOTADB */ "file is encrypted or is not a database",
113394 void *ptr, /* Database connection */
113452 ** This routine sets the busy callback for an Sqlite database to the
113470 ** This routine sets the progress callback for an Sqlite database to the
113768 sqlite3 *db, /* Attach the hook to this database */
113783 ** inserted or deleted using this database connection.
113786 sqlite3 *db, /* Attach the hook to this database */
113801 ** back by this database connection.
113804 sqlite3 *db, /* Attach the hook to this database */
113827 const char *zDb, /* Database */
113841 ** a database after committing a transaction if there are nFrame or
113866 ** into the write-ahead-log by this database connection.
113887 ** Checkpoint database zDb.
113890 sqlite3 *db, /* Database handle */
113891 const char *zDb, /* Name of attached database (or NULL) */
113919 database: %s", zDb);
113932 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
113942 ** Run a checkpoint on database iDb. This is a no-op if database iDb is
113945 ** If a transaction is open on the database being checkpointed, this
113950 ** The mutex on database handle db should be held by the caller. The mutex
113993 ** SQLITE_TEMP_STORE db->temp_store Location of temporary database
114083 ** sqlite3ApiExit(), to avoid setting the database handle error message.
114116 ** Create a new collating function for database "db". The name is zName
114295 ** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database
114302 ** the default flags to open the database handle with. The value stored in
114307 ** the VFS that should be used to open the database file. *pzFile is set to
114524 ** This routine does the work of opening a database on behalf of
114525 ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
114529 const char *zFilename, /* Database filename UTF-8 encoded */
114530 sqlite3 **ppDb, /* OUT: Returned database handle */
114670 /* Open the backend database driver */
114684 /* The default safety_level for the main database is 'full'; for the temp
114685 ** database it is 'NONE'. This matches the pager layer defaults.
114698 ** database schema yet. This is delayed until the first time the database
114734 ** systems known to have never seen a pre-fts3 database.
114800 ** Open a new database handle.
114810 const char *filename, /* Database filename (UTF-8) */
114820 ** Open a new database handle.
114857 ** Register a new collation sequence with the database handle db.
114876 ** Register a new collation sequence with the database handle db.
114897 ** Register a new collation sequence with the database handle db.
114922 ** Register a collation sequence factory callback with the database handle
114940 ** Register a collation sequence factory callback with the database handle
114968 ** Test to see whether or not the database connection is in autocommit
114993 "database corruption at line %d of [%.10s]",
115026 ** Return meta information about a specific column of a database table.
115032 const char *zDbName, /* Database name or NULL */
115053 /* Ensure the database schema has been loaded */
115165 ** Invoke the xFileControl method on a particular database.
115272 ** an incompatible database file format. Changing the PENDING byte
115273 ** while any database connection is open results in undefined and
115341 ** Set the nReserve size to N for the main database on the database
115438 ** to see if a database file was a URI that contained a specific query
115500 ** Return the filename of the database associated with a database
115509 ** Return 1 if database is read-only or 0 if read/write. Return -1 if
115510 ** no such database exists.
115703 sqlite3Error(db, rc, (rc?"database is deadlocked":0));
115725 ** the transaction opened by database db has just finished. Locks held
115726 ** by database connection db have been released.
115838 ** This is called when the database connection passed as an argument is
116609 sqlite3 *db; /* The database connection */
116610 const char *zDb; /* logical database name */
116630 int nPgsz; /* Page size for host database */
116690 int nRowAvg; /* Average size of database rows, in pages */
117147 sqlite3 *db, /* Database in which to run SQL */
117171 const char *zDb = p->zDb; /* Name of database (e.g. "main", "temp") */
117172 sqlite3 *db = p->db; /* Database handle */
117246 sqlite3 *db = p->db; /* The database connection */
117304 ** Store the current database page-size in bytes in p->nPgsz.
117610 ** config=xxx option (i.e. "xxx"). This function queries the database for
117630 sqlite3 *db, /* Database handle */
117696 ** argv[1] -> database name
117702 sqlite3 *db, /* The SQLite database connection */
117718 int nDb; /* Bytes required to hold database name */
117986 ** database. TODO: For xConnect(), it could verify that said tables exist.
117992 /* Figure out the page-size for the database. This is required in order to
117993 ** estimate the cost of loading large doclists from the database. */
118026 sqlite3 *db, /* Database connection */
118036 sqlite3 *db, /* Database connection */
119459 ** prefix) from the database.
119763 ** hash-table to the database.
119787 ** the pending-terms hash-table have already been flushed into the database
119803 ** hash-table. Any changes made to the database are reverted by SQLite.
119926 ** function merges all segments in the database to a single segment.
120028 sqlite3 *db = p->db; /* Database connection */
120141 ** FTS3 enabled database
120795 ** this database, then the average docsize is 1. Otherwise, it is 1 plus
121103 ** point to the next matching row in the database. Expressions iterate through
121895 sqlite3 *db, /* Database connection */
121902 char const *zDb; /* Name of database (e.g. "main") */
122278 ** Register the fts3aux module with database connection db. Return SQLITE_OK
123319 ** with database connection db.
124787 database db used to access the contents of
124797 ** comment above struct HashTableVtab) to the database schema. Both
124923 ** track such information in the database, then we'd only want this
125237 ** database. The internal details of this type are only accessed by the
125267 ** When a b+tree is written to the database (either as a result of a merge
125269 ** database file as soon as they are completely populated. The interior of
126160 ** on the database file for longer than necessary). Thus, any virtual table
126601 ** the contents of the pending-terms hash table to the database.
126956 ** the database contain two terms that share a prefix of almost 2KB,
127051 ** database. Then call this function recursively to write the parent of
127052 ** pTree and its peers to the database.
127054 ** Except, if pTree is a root node, do not write it to the database. Instead,
127058 ** set to the largest blockid written to the database (or zero if no
127186 /* The current leaf node is full. Write it out to the database. */
127194 ** to the database (still available in pWriter->zTerm), and
127265 ** database. This function must be called after all terms have been added
127277 sqlite3_int64 iLast = 0; /* Largest block id written to database */
127343 ** Set *pnMax to the largest segment level in the database for the index
127891 ** Merge all level iLevel segments in the database into a single
127894 ** currently present in the database.
127897 ** segment in the database, SQLITE_DONE is returned immediately.
127926 /* This call is to merge all segments in the database to a single
127928 ** greatest segment level currently present in the database for this
128145 ** Merge the entire database so that there is one segment for each
128531 ** should be deleted from the database before inserting the new row. Or,
128534 ** modify the database file.
128617 ** merge all segments in the database (including the new segment, if
128729 sqlite3_int64 nDoc; /* Number of docs in database */
130161 ** Database Format of R-Tree Tables
130287 sqlite3 *db; /* Host database connection */
130292 char *zDb; /* Name of database containing r-tree table */
130586 ** node contents out to the database.
130750 ** If the node is dirty, write it out to the database.
130776 ** count drops to zero, the node data is written to the database.
133099 ** using database connection db. If successful, the integer value returned
133128 ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size.
133129 ** This ensures that each node is stored on a single database page. If the
133130 ** database page-size is so large that more than RTREE_MAXCELLS entries
133134 sqlite3 *db, /* Database handle */
133167 ** argv[1] -> database name
133172 sqlite3 *db, /* Database connection */
133221 /* Create/Connect to the underlying relational database schema. If
133328 ** Register the r-tree module with database handle db. This creates the
133831 ** types to an SQLite database connection. It is intended to be called
133877 ** Register the ICU extension functions with database db.