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 */
25539 ** permissions as their original database, unadulterated by the umask.
25540 ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a
25542 ** process that is able to write to the database will also be able to
25931 ** on its own. Whenever a new database is opened, we have to find the
25932 ** specific inode of the database file (the inode is determined by the
25989 ** per database file in the same process and (2) database connections
26217 ** in the header of every SQLite database. In this way, if there
26219 ** the first page of the database, no damage is done.
26320 ** in order to coordinate access between separate database connections
26389 ** accessing the same database file, in case that is ever required.
26415 ** database.
26653 ** reading the database file again, make sure that the
26654 ** transaction counter was updated if any part of the database
26658 ** cache. The use of a stale cache can lead to database corruption.
26865 ** simplest: locking is ignored. No attempt is made to lock the database
26871 ** prevent simultaneous access of the same database by two or more
26872 ** database connections. But there is a serious risk of database
26874 ** database connections are accessing the same database file at the same
26906 ** files (really a directory) to control access to the database. This works
26910 ** connections from reading or writing the database.
26919 ** the database and with the same name but with a ".lock" extension added.
27064 /* To fully unlock the database, delete the lock file */
27109 ** only a single process can be reading the database at a time.
27315 ** the database file at a time. This reduces potential concurrency, but
27852 ** reading the database file again, make sure that the
27853 ** transaction counter was updated if any part of the database
27857 ** cache. The use of a stale cache can lead to database corruption.
28065 /* If this is a database file (not a journal, master-journal or temp
28145 /* If this is a database file (not a journal, master-journal or temp
28155 /* If we are doing a normal write to a database file (as opposed to
28157 ** normal database file) then record the fact that the database
28162 pFile->dbUpdate = 1; /* The database has been modified */
28237 ** or power failure will likely corrupt the database file.
28377 ** will not roll back - possibly leading to database corruption.
28449 /* If we are doing a normal write to a database file (as opposed to
28451 ** normal database file) and we truncate the file to zero length,
28453 ** when restoring a database using the backup API from a zero-length
28480 /* When opening a zero-size database, the findInodeInfo() procedure
28502 ** file-control operation. Enlarge the database to nBytes in size
28503 ** (rounded up to the next chunk-size). If the database is already
28607 ** a rollback and that the database is therefore unchanged and
28633 ** a database and its journal file) that the sector size will be the
28847 ** Open a shared-memory area associated with open database file pDbFd.
28851 ** as the open database file and has the same name as the open database
28852 ** file with the "-shm" suffix added. For example, if the database file
28858 ** from the database file is used, then differing access permissions
28860 ** database to end up using different files for shared memory -
28862 ** in database corruption. Nevertheless, this tmpfs file usage
28867 ** same database file at the same time, database corruption will likely
28875 ** If the original database file (pDbFd) is using the "unix-excl" VFS
28876 ** that means that an exclusive lock is held on the database file and
28877 ** that no other processes are able to read or write the database. In
28902 struct stat sStat; /* fstat() info for database file */
28904 /* Call fstat() to figure out the permissions on the database file. If
28955 ** is owned by the same user that owns the original database. Otherwise,
29013 ** shared-memory associated with the database file fd. Shared-memory regions
29031 sqlite3_file *fd, /* Handle open on database file */
29142 sqlite3_file *fd, /* Database file holding the shared memory */
29254 sqlite3_file *fd /* Database file holding the shared memory */
29269 sqlite3_file *fd, /* The underlying database file */
29275 unixFile *pDbFd; /* The underlying database file */
29328 ** sqlite3_io_methods object for a particular database file. The pAppData
29495 ** for the database file "filePath". It then returns the sqlite3_io_methods
29501 const char *filePath, /* name of the database file */
29502 unixFile *pNew /* open file object for the database file */
29561 ** for the database file "filePath". It then returns the sqlite3_io_methods
29567 const char *filePath, /* name of the database file */
29873 ** Search for an unused file descriptor that was opened on the database
29878 ** Such a file descriptor may exist if a database connection was closed
29942 ** corresponding database file and sets *pMode to this value. Whenever
29944 ** as the associated database file.
29963 char zDb[MAX_PATHNAME+1]; /* Database file path */
29965 struct stat sStat; /* Output of stat() on database file */
29968 ** the path to the associated database file from zPath. This block handles
30112 /* Database
30169 ** the same as the original database. If we are not running as root,
30241 ** with fd is a database file, and there are other connections open
30632 ** database file to coordinate safe, concurrent access by multiple readers
30653 ** address the requirements for concurrent database access by multiple
30658 ** changes the way database access is controlled by limiting access to a
30659 ** single host at a time and moving file locks off of the database file
30675 ** PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:
30676 ** PRAGMA [database.]lock_proxy_file
30683 ** database file. For example:
30685 ** For database path "/Users/me/foo.db"
30688 ** Once a lock proxy is configured for a database connection, it can not
30699 ** * conch file to limit access to the database file to a single host
30703 ** taken on the database
30709 ** stored in the same directory as the database file and the file name
30710 ** is patterned after the database file name as ".<databasename>-conch".
30719 ** normally taken on the database file. This allows for safe sharing
30720 ** of the database file for multiple readers and writers on the same
30724 ** only taken when the first request to lock database file is made.
30726 ** opening a connection to a database file does not take a lock on it.
30728 ** the connection to the database is closed.
30738 ** Database files accessed on non-local file systems are
30761 ** force proxy locking to be used for every database file opened, and 0
30762 ** will force automatic proxy locking to be disabled for all database
30789 ** The proxy lock file path for the database at dbPath is written into lPath,
31274 ** valid conch file), try to match the permissions of the database
31282 /* try to match the database file R/W permissions, ignore failure */
31388 ** Given the name of a database file, compute the name of its conch file.
31400 int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
31404 ** the name of the original database file. */
31503 char dbPath[MAXPATHLEN+1]; /* Name of the database file */
31820 ** database file and tries to choose an locking method appropriate for
34325 ** a database and its journal file) that the sector size will be the
34559 ** Open the shared-memory area associated with database file pDbFd.
34679 sqlite3_file *fd, /* Database holding shared memory */
34682 winFile *pDbFd; /* Database holding shared-memory */
34720 sqlite3_file *fd, /* Database file holding the shared memory */
34829 sqlite3_file *fd /* Database holding the shared memory */
34839 ** shared-memory associated with the database file fd. Shared-memory regions
34857 sqlite3_file *fd, /* Handle open on database file */
35201 /* Database filenames are double-zero terminated if they are not
35828 ** A bitmap is used to record which pages of a database file have been
35833 ** or all of the pages in a database can get journalled. In those cases,
35846 ** Bitvec object is the number of pages in the database file at the
35848 ** but can be as large as 2 billion for a really big database.
36348 ** being used for an in-memory database, this function is a no-op.
36727 ** Since there cannot be more than 2^31 distinct pages in a database,
36902 ** open database file (including each in-memory database and each
36903 ** temporary or transient database) has a single page cache which
37511 ** database) there is really no difference between createFlag 1 and 2. So
37967 sqlite3 *db; /* The database connection */
38027 ** The mallocFailed flag of the database connection is set if a
38302 ** The pager is used to access a database disk file. It implements
38304 ** is separate from the database file. The pager also implements file
38305 ** locking to prevent two processes from writing the same database
38306 ** file simultaneously, or one process from reading the database while
38374 ** snapshot is like a read-transaction. It is the state of the database
38386 /* If the WAL is not empty, return the size of the database. */
38407 /* Copy pages from the log to the database file */
38428 ** by the pager layer on the database file.
38463 ** Definition: A page of the database file is said to be "overwriteable" if
38473 ** the database file at the start of the transaction.
38475 ** (1) A page of the database file is never overwritten unless one of the
38485 ** both the content in the database when the rollback journal was written
38486 ** and the content in the database at the beginning of the current
38489 ** (3) Writes to the database file are an integer multiple of the page size
38492 ** (4) Reads from the database file are either aligned on a page boundary and
38494 ** first 100 bytes of the database file.
38496 ** (5) All writes to the database file are synced prior to the rollback journal
38499 ** (6) If a master journal file is used, then all writes to the database file
38502 ** Definition: Two databases (or the same database at two points it time)
38506 ** of the database.
38510 ** journal is rolled back, the resulting database file will be logical
38511 ** equivalent to the database file at the beginning of the transaction.
38514 ** is called to restore the database file to the same size it was at
38519 ** (9) Whenever the database file is modified, at least one bit in the range
38522 ** database to flush their caches.
38527 ** (11) A database file is well-formed at the beginning and at the conclusion
38530 ** (12) An EXCLUSIVE lock is held on the database file when writing to
38531 ** the database file.
38533 ** (13) A SHARED lock is held on the database file while reading any
38534 ** content out of the database file.
38601 ** state - the file may or may not be locked and the database size is
38602 ** unknown. The database may not be read or written.
38605 ** * Any lock, or no lock at all, may be held on the database file.
38610 ** In this state all the requirements for reading the database in
38613 ** open. The database size is known in this state.
38616 ** it opens a read-transaction on the database and returns to state
38624 ** * A SHARED or greater lock is held on the database file.
38628 ** * If the database is a WAL database, then the WAL connection is open.
38635 ** is first opened on the database. In WRITER_LOCKED state, all locks
38637 ** modifications to the cache or database have taken place.
38640 ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when
38643 ** in WRITER_LOCKED state, all that is required is to unlock the database
38648 ** is made to obtain an EXCLUSIVE lock on the database file.
38652 ** lock is held on the database file.
38666 ** start of it. The database file on disk has not been modified.
38669 ** * A RESERVED or greater lock is held on the database file.
38677 ** when it modifies the contents of the database file. WAL connections
38678 ** never enter this state (since they do not modify the database file,
38682 ** * An EXCLUSIVE or greater lock is held on the database file.
38694 ** database file. In this state the transaction may be committed simply
38696 ** not possible to modify the database further. At this point, the upper
38700 ** * An EXCLUSIVE or greater lock is held on the database file.
38701 ** * All writing and syncing of journal and database data has finished.
38720 ** report database corruption (due to the inconsistent cache), and if
38721 ** they upgrade to writers, they may inadvertently corrupt the database
38744 ** database file in function pagerStress() in order to free up
38788 ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
38805 ** The exception is when the database file is unlocked as the pager moves
38818 ** transaction in another process, causing SQLite to read from the database
38822 ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
38827 ** lock on the database file before attempting to roll it back. See function
38893 ** For a real on-disk database, the current lock held on the database file -
38896 ** For a temporary or in-memory database (neither of which require any
38909 ** (the 4-byte header field at byte offset 24 of the database file) is
38913 ** can only happen if an exclusive lock is held on the database file.
38915 ** relinquished on the database file. Each time a transaction is committed,
38954 ** When doNotSpill is non-zero, writing to the database from pagerStress()
38960 ** If doNotSyncSpill is non-zero, writing to the database from pagerStress()
38963 ** the database page-size in order to prevent a journal sync from happening
38977 ** Variable dbSize is set to the number of pages in the database file.
38981 ** dbSize is set based on the size of the database file, which may be
38982 ** larger than the size of the database (the value stored at offset
38983 ** 28 of the database header by the btree). If the size of the file
38992 ** Similarly, if the database is truncated using PagerTruncateImage(),
39004 ** to write or truncate the database file on disk.
39009 ** that the database file is larger than the database image (Pager.dbSize),
39011 ** to measure the database file on disk, and then truncates it if required.
39047 u8 readOnly; /* True for a read-only database */
39060 u8 eLock; /* Current lock held on database file */
39066 Pgno dbSize; /* Number of pages in the database */
39068 Pgno dbFileSize; /* Number of pages in the database file */
39074 Bitvec *pInJournal; /* One bit for each page in the database file */
39075 sqlite3_file *fd; /* File descriptor for database */
39083 char dbFileVers[16]; /* Changes whenever database file changes */
39093 Pgno mxPgno; /* Maximum allowed size of the database */
39095 char *zFilename; /* Name of the database file */
39101 int nRead, nWrite; /* Database pages read/written */
39142 ** to roll the journal back, the database could be corrupted. The additional
39174 ** The macro MEMDB is true if we are dealing with an in-memory database.
39243 ** as if it has an exclusive lock on the database file. It never updates
39471 ** Unlock the database file to level eLock, which must be either NO_LOCK
39497 ** Lock the database file to level eLock, which must be either SHARED_LOCK,
39525 ** a database page may be written atomically, and
39531 ** database.
39758 ** - 4 bytes: Initial database page count.
39760 ** - 4 bytes: Database page size.
39822 /* The initial database size */
39851 ** database page size. Since the zHeader buffer is only Pager.pageSize
39874 ** database before the transaction began, in pages. Also, pPager->cksumInit
39887 u32 *pDbSize /* OUT: Value of original database size field */
39921 ** field, the checksum-initializer and the database size at the start
40004 ** If zMaster is a NULL pointer (occurs for a single database transaction),
40139 ** If the pager is not in exclusive-access mode, the database file is
40171 ** close the journal file when dropping the database lock. Otherwise
40187 /* If the pager is in the ERROR state and the call to unlock the database
40240 ** to be replayed to restore the contents of the database file (as if
40263 ** database transaction.
40274 ** or any other database connection. Exactly how a journal is finalized
40304 ** database then the IO error code is returned to the user. If the
40306 ** tries to unlock the database file if not in exclusive mode. If the
40359 ** the database file, it will do so using an in-memory journal.
40392 ** lock held on the database file.
40411 ** database file.
40416 ** the database file and move the pager back to OPEN state. If this
40507 ** to the database file, then the IO error code is returned. If data
40603 ** not the database file. The page is left marked dirty in this case.
40605 ** An exception to the above rule: If the database is in no-sync mode
40622 ** statement we must not write to the original database unless we know
40625 ** database file without an entry in the rollback journal that can
40626 ** restore the database to its original form. Two conditions must be
40627 ** met before writing to the database files. (1) the database must be
40632 ** 2008-04-14: When attempting to vacuum a corrupt database file, it
40633 ** is possible to fail a statement on a database that does not yet exist.
40634 ** Do not attempt to write if database file has never been opened.
40670 ** the database and the page is not in-memory, there is a potential
40672 database file, which may or may not be
40698 ** database active. However such a page may be rolled back as a result
40711 ** database.
40722 ** be written out into the database file before its journal file
40724 ** database corruption may ensue.
40878 ** This function is used to change the actual size of the database
40882 ** If the main database file is not open, or the pager is not in either
40895 ** the database file, return the error code to the caller.
40932 ** of the open database file. The sector size will be used used
40976 ** Playback the journal and thus restore the database file to
40988 ** database to during a rollback.
41123 ** database file back to its original size.
41134 ** database file and/or page cache.
41150 ** case, the database should have never been written in the
41158 ** process to come along will be able to rollback the database.
41169 /* Following a rollback, the database file should be back in its original
41223 ** Read the content for page pPg out of the database file and into
41224 ** pPg->pData. A shared lock or greater must be held on the database
41228 ** the value read from the database file.
41265 ** of bytes 24..39 of the database. Bytes 28..31 should always be
41266 ** zero or the size of the database in page. Bytes 32..35 and 35..39
41270 ** For an encrypted database, the situation is more complex: bytes
41271 ** 24..39 of the database are white noise. But the probability of
41323 ** references, the page content is reloaded from the database. If the
41324 ** attempt to reload content from the database is required and fails,
41347 ** database. This is not generally possible with a WAL database, as
41359 ** This function is called to rollback a transaction on a WAL database.
41370 ** + Reload page content from the database (if refcount>0).
41396 Pgno nTruncate, /* Database size after this commit */
41451 ** makes a snapshot of the database at the current point in time and preserves
41480 ** to PAGER_READER state to determine the size of the database file
41483 ** If no error occurs, SQLITE_OK is returned and the size of the database
41490 /* Query the WAL sub-system for the database size. The WalDbsize()
41492 ** if the database size is not available. The database size is not
41500 /* If the database size was not available from the WAL sub-system,
41501 ** determine it based on the size of the database file. If the size
41502 ** of the database file is not an integer multiple of the page-size,
41532 ** Check if the *-wal file that corresponds to the database opened by pPager
41533 ** exists if the database is not empy, or verify that the *-wal file does
41534 ** not exist (by deleting it) if the database file is empty.
41536 ** If the database is not empty and the *-wal file exists, open the pager
41537 ** in WAL mode. If the database is empty or if no *-wal file exists and
41543 ** The caller must hold a SHARED lock on the database file to call this
41545 ** a WAL on a none-empty database, this ensures there is no race condition
41556 Pgno nPage; /* Size of the database file */
41634 /* Set the database size back to the value it was before the savepoint
41655 ** greater than the current database size (pPager->dbSize) but those
41740 ** Adjust the robustness of the database to damage due to OS crashes
41748 ** database. This is normally adequate protection, but
41751 ** in a state which would cause damage to the database
41755 ** database (with some additional information - the nRec field
41760 ** point of causing damage to the database during rollback.
41764 ** prior to the start of checkpoint and that the database file is synced
41766 ** was written back into the database. But no sync operations occur for
41899 ** * the database is either not an in-memory database or it is
41900 ** an in-memory database that currently consists of zero pages.
41967 ** entire content of a database page. This buffer is used internally
41977 ** Attempt to set the maximum database page count if mxPage is positive.
41979 ** maximum page count below the current size of the database.
42023 ** function is used to read database headers, and a new transient or
42024 ** zero sized database has a header than consists entirely of zeroes.
42053 ** the pager. It returns the total number of pages in the database.
42066 ** Try to obtain a lock of type locktype on the database file. If
42103 ** current database image, in pages, OR
42112 ** the database file. If a savepoint transaction were rolled back after
42115 ** the database file or the portion of the rollback journal and
42117 ** database image would become corrupt. It is therefore fortunate that
42133 ** Truncate the in-memory database file image to nPage pages. This
42134 ** function does not actually modify the database file on disk. It
42203 ** file may be played back into the database. If a power failure occurs
42204 ** while this is happening, the database could become corrupt.
42208 ** database and close the journal file without attempting to roll it
42209 ** back or finalize it. The next database user will have to do hot-journal
42210 ** rollback before accessing the database file.
42308 ** that wrote to this database was operating in persistent-journal
42318 ** out-of-date data that follows it. Database corruption.
42402 ** in-memory pages in the list to the database file. The argument may
42407 ** is called. Before writing anything to the database file, this lock
42409 ** SQLITE_BUSY is returned and no data is written to the database file.
42416 ** the pages are written out to the database file in list order. Writing
42422 ** If writing out a page causes the database file to grow, Pager.dbFileSize
42425 ** the database file.
42476 /* Encode the database */
42483 ** the value now stored in the database file. If writing this
42484 ** page caused the database file to grow, update dbFileSize.
42586 ** database). The second argument is a reference to a page that is
42592 ** out to the database file, if possible. This may involve syncing the
42617 ** lead to database corruption. In the current implementaton it
42648 ** the database image, it may need to be written to the sub-journal.
42658 ** <shrink database file to Y pages>
42663 ** out to the database file, but will be dropped from the cache. Then,
42665 ** data from the database file. This will be the copy of page X as it
42680 /* Write the contents of the page out to the database file. */
42702 ** The zFilename argument is the path to the database file to open.
42707 ** This can be used to implement an in-memory database.
42730 const char *zFilename, /* Name of the database file to open */
42743 char *zPathname = 0; /* Full path to database file */
42798 ** the database being opened will be more than pVfs->mxPathname
42799 ** bytes in length. This means the database cannot be opened,
42812 ** three file descriptors, the database file name and the journal
42817 ** Database file handle (pVfs->szOsFile bytes)
42820 ** Database file name (nPathname+1 bytes)
42877 ** database file. The default page size is the maximum of:
42913 ** This branch is also run for an in-memory database. An in-memory
42914 ** database is the same as a temp-file that is never written out to
43016 ** * No process holds a RESERVED or greater lock on the database file, and
43017 ** * The database file itself is greater than 0 bytes in size, and
43020 ** If the current size of the database file is 0 but a journal file
43022 ** database with the same name. In this case the journal file is
43070 Pgno nPage; /* Number of pages in database file */
43072 /* Check the size of the database file. If it consists of 0 pages,
43089 ** or greater lock on the database file. Now check that there is
43130 ** This function is called to obtain a shared lock on the database file.
43138 ** on the database file), then an attempt is made to obtain a
43139 ** SHARED lock on the database file. Immediately after obtaining
43143 ** the 'change-counter' field of the database file header and
43153 ** occurs while locking the database, checking for a hot-journal file or
43181 ** database file, then it either needs to be played back or deleted.
43190 /* Get an EXCLUSIVE lock on the database file. At this point it is
43193 ** database file, detect the RESERVED lock, and conclude that the
43194 ** database is safe to read while this process is still rolling the
43198 ** other process attempting to access the database file will get to
43200 ** on the database file.
43241 /* Playback and delete the journal. Drop the database write
43290 /* The shared-lock has just been acquired on the database file
43292 ** read or write transaction). Check to see if the database
43293 ** has been modified. If the database has changed, flush the
43296 ** Database changes is detected by looking at 15 bytes beginning
43327 /* If there is a WAL file in the file-system, open this database in WAL
43377 ** read from the database file. In some cases, the pcache module may
43386 ** If the database image is smaller than the requested page or if a
43395 ** a) When reading a free-list leaf page from the database, and
43402 ** being read from the database. Additionally, the bits corresponding
43421 Pager *pPager, /* The pager open on the database file */
43548 ** are released, a rollback occurs and the lock on the database is
43561 ** There must already be a RESERVED or EXCLUSIVE lock on the database
43652 ** lock on the database file. If exFlag is true, then acquire at least
43661 ** sub-journal is implemented in-memory if pPager is an in-memory database,
43676 ** exclusive lock on the database is not already held, obtain it now.
43693 /* Obtain a RESERVED lock on the database file. If the exFlag parameter
43710 ** transactions may copy data from the sub-journal into the database
43756 /* Higher-level routines never call this function if database is not
43787 ** EXCLUSIVE lock on the main database file. Write the current page to
43798 ** contains the database locks. The following assert verifies
43810 ** in the database file. And if an IO error occurs while doing so,
43860 /* Update the database size and return.
43894 Pgno nPageCount; /* Total number of pages in database file */
43952 ** before any of them can be written out to the database file.
44009 ** This routine is called to increment the value of the database file
44026 ** if isDirect is non-zero, then the database file is updated directly
44101 ** Sync the database file to disk. This is a no-op for in-memory databases
44126 ** the database file, an attempt is made to obtain one.
44147 ** Sync the database file for the pager pPager. zMaster points to the name
44150 ** journal (a single database transaction).
44154 ** * The database file change-counter is updated,
44156 ** * all dirty pages are written to the database file,
44157 ** * the database file is truncated (if required), and
44158 ** * the database file synced.
44167 ** If the final parameter - noSync - is true, then the database file itself
44169 ** sync the database file before calling CommitPhaseTwo() to delete the
44189 PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n",
44192 /* If no database changes have been made, return early. */
44258 ** directly to the database file. Because of the atomic-write
44273 /* If this transaction has made the database smaller, then all pages
44281 ** reading data from the database file.
44289 const Pgno dbSize = pPager->dbSize; /* Database image size */
44312 /* Sync the journal file and write all dirty pages to the database.
44333 /* If the file on disk is not the same size as the database image,
44343 /* Finally, sync the database file. */
44360 ** When this function is called, the database file has been completely
44388 /* An optimization. If the database was not actually modified during
44395 ** to the database file. So there is no need to zero the journal
44424 ** 1) It rolls back the journal file, restoring all database file and
44436 ** their pre-transaction state by re-reading data from the database or
44483 ** Return TRUE if the database file is opened read-only. Return FALSE
44484 ** if the database is (in theory) writable.
44647 ** the transaction or unlock the database, it just restores the
44648 ** contents of the database to its original state.
44693 ** the database file, so the playback operation can be skipped.
44706 ** Return the full pathname of the database file.
44720 ** Return the file handle for the database file associated
44785 ** moved as part of a database reorganization just before the transaction
44786 ** is being committed. In this case, it is guaranteed that the database page
44804 /* In order to be able to rollback, an in-memory database must journal
44845 ** the journal needs to be sync()ed before database page pPg->pgno
44865 /* Do not discard pages from an in-memory database since we might
44877 /* For an in-memory database, make sure the original page continues
44889 ** sync()ed before any data is written to database file page needSyncPgno.
44898 ** this transaction, it may be written to the database file before
44972 ** * An in-memory database can only have its journal_mode set to _OFF
45003 /* Do allow the journalmode of an in-memory database to be set to
45038 ** database file. This ensures that the journal file is not deleted
45081 ** journalmode. Journalmode changes can only happen when the database
45117 ** Unless this is an in-memory or temporary database, clear the pager cache.
45158 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
45178 ** lock on the database file and use heap-memory to store the wal-index
45211 ** The caller must be holding a SHARED lock on the database file to call
45214 ** If the pager passed as the first argument is open on a real database
45215 ** file (not a temp file or an in-memory database), and the WAL file
45221 ** If the pager is open on a temp-file (or in-memory database), or if
45260 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
45287 ** the database file, the log and log-summary files will be deleted.
45305 ** WAL frames. Otherwise, if this is not a WAL database or the WAL file
45354 ** database file. All changes to the database are recorded by writing
45358 ** transferred back into the database file in an operation called a
45373 ** 8: Database page size. Example: 1024
45386 ** 4: For commit records, the size of the database image in pages
45424 ** WAL is transferred into the database, then the database is VFS.xSync-ed.
45436 ** To read a page from the database (call it page number P), a reader
45442 ** the database file.
45449 ** of the database from a single point in time. This technique allows
45450 ** multiple concurrent readers to view different versions of the database
45466 ** on a network filesystem. All users of the database must be able to
45474 ** Hence, unlike the database and WAL file formats which store all values
45496 ** database page number associated with each wal frame, and a hash-table
45500 ** first index-block contains the database page number corresponding to the
45639 u16 szPage; /* Database page size in bytes. 1==64K */
45641 u32 nPage; /* Size of database in pages */
45653 ** back into the database. (We call the act of moving content from WAL to
45654 ** database "backfilling".) The nBackfill number is never greater than
45667 ** directly from the database.
45674 ** The checkpointer may only transfer frames from WAL to database where
45681 ** in the WAL has been backfilled into the database) then new readers
45683 ** get all their all content directly from the database file and ignore
45688 ** written back into the database) and if no readers are using the WAL
45732 ** assuming a database page size of szPage bytes. The offset returned
45745 database file */
45752 u32 szPage; /* Database page size */
45792 ** all frames in the WAL in database page order. Where two or more frames
45793 ** correspond to the same database page, the iterator visits only the
45994 ** 4: For commit records, the size of the database image in pages
46003 u32 iPage, /* Database page number for frame */
46030 u32 *piPage, /* OUT: Database page number for frame */
46070 ** and the new database size.
46300 ** Set an entry in the wal-index that will map database page number
46442 /* If the database page size is not a power of two, or is greater than
46491 u32 pgno; /* Database page number for frame */
46569 ** Open a connection to the WAL file zWalName. The database file must
46573 ** A SHARED lock should be held on the database file when this function
46585 sqlite3_file *pDbFd, /* The open database file */
46950 ** Return the page-size in bytes used by the database.
46957 ** Copy as much content as we can from the WAL back into the database file
46960 ** The amount of information copies from WAL to database might be limited
46961 ** by active readers. This routine will never overwrite a database page
46970 ** into the database. This ensures that if the new content is persistent
46973 ** Fsync is also called on the database file if (and only if) the entire
46974 ** WAL content is copied into the database file. This second fsync makes
46976 ** database file.
46996 int szPage; /* Database page-size */
46998 u32 iDbpage = 0; /* Next database page to write */
47001 u32 mxPage; /* Max database page to write */
47022 ** safe to write into the database. Frames beyond mxSafeFrame might
47023 ** overwrite database pages that are in use by active readers and thus
47048 i64 nSize; /* Current size of database file */
47056 /* If the database file may grow as a result of this checkpoint, hint
47108 ** file has been copied into the database file, then block until all
47110 ** process to write to the database restarts the wal file.
47161 /* If an EXCLUSIVE lock can be obtained on the database file (using the
47164 ** the database. In this case checkpoint the database and unlink both
47388 ** access any database page that is modified by a WAL frame up to and
47392 ** completely and get all content directly from the database file.
47485 ** which implies that the database file contains a trustworthy
47493 ** it finished. Leaving a corrupt image in the database file.
47555 ** copied into the database by a checkpointer. If either of these things
47556 ** happened, then reading the database with the current value of
47581 ** Begin a read transaction on the database.
47589 ** If the database contents have changes since the previous read
47626 ** the WAL and needs to be read out of the database.
47630 Pgno pgno, /* Database page number to read data for */
47742 ** Return the size of the database in pages (or zero, if unknown).
47758 ** If another thread or process has written into the database since
47785 /* If another connection has written to the database file since the
47830 ** was in before the client began writing to the database.
48043 int szPage, /* Database page-size in bytes */
48045 Pgno nTruncate, /* Database size after this commit */
48113 ** database corruption. See the ticket:
48229 ** we can from WAL into the database.
48287 /* Copy data from the log to the database file. */
48306 ** next time the pager opens a snapshot on this database it knows that
48344 ** lock on the main database file.
48351 ** on the main database file before invoking this operation.
48355 ** should acquire the database exclusive lock prior to invoking
48407 ** read-lock. This function returns the database page-size if it is known,
48450 ** This file implements a external (disk-based) database using BTrees.
48457 ** The basic idea is that each page of the file contains N database
48476 ** fixed amount of payload can be carried directly on the database
48523 ** The file change counter is incremented when the database is changed
48660 /* The maximum number of cells on a single page of the database. This
48673 ** SQLite database in order to identify the file as a real database.
48762 ** A database connection contains a pointer to an instance of
48763 ** this object for every database file that it has open. This structure
48764 ** is opaque to the database connection. The database connection cannot
48768 ** For some database files, the same underlying database cache might be
48771 ** points to the same BtShared object. The database cache and the
48772 ** schema associated with the database file are all contained within
48782 sqlite3 *db; /* The database connection holding this btree */
48808 ** An instance of this object represents a single database file.
48810 ** A single database file can be in use at the same time by two
48811 ** or more database connections. When two or more connections are
48812 ** sharing the same database file, each connection has it own
48815 ** connections currently sharing this database file.
48826 ** If a BtShared client fails to obtain a write-lock on a database
48844 sqlite3 *db; /* Database connection currently using this Btree */
48846 MemPage *pPage1; /* First page of the database */
48862 u32 nPage; /* Number of pages in the database */
48882 #define BTS_INITIALLY_EMPTY 0x0008 /* Database was empty at trans start */
48907 ** maximum database size of 2^31 pages a minimum fanout of 2 for a
48911 ** assumed that the database is corrupt.
48917 ** b-tree within a database file.
48922 ** A single database file can be shared by two more database connections,
48924 ** particular database connection identified BtCursor.pBtree.db.
48986 ** The database page the PENDING_BYTE occupies. This page is never used.
48992 ** database page. The first argument to each is the number of usable
48993 ** bytes on each page of the database (often 1024). The second is the
48996 ** PTRMAP_PAGENO returns the database page number of the pointer-map
49011 ** each child page in the database file. The parent page is the page that
49012 ** contains a pointer to the child. Every page in the database contains
49013 ** 0 or 1 parent pages. (In this context 'database page' refers
49023 ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not
49026 ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
49029 ** PTRMAP_OVERFLOW1: The database page is the first page in a list of
49033 ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of
49037 ** PTRMAP_BTREE: The database page is a non-root btree page. The page number
49056 ** if the database supports auto-vacuum or not. Because it is used
49077 Pgno nPage; /* Number of pages in the database */
49099 ** set BtShared.db to the database handle associated with p and the
49136 ** by all database connections. The p->pNext is a list of other
49137 ** Btrees belonging to the same database connection as the p Btree
49160 /* We should already hold a lock on the database connection */
49163 /* Unless the database is sharable and unlocked, then BtShared.db
49249 ** Enter the mutex on every Btree associated with a database
49291 ** Return true if the current thread holds the database connection
49377 ** This file implements a external (disk-based) database using BTrees.
49384 ** SQLite database.
49430 ** This routine has no effect on existing database connections.
49474 ** When writing to an index that resides in a sharable database, the
49479 ** function has to search through the database schema.
49495 /* If this database is not shareable, or if the client is reading
49649 ** database (one with the BtShared.sharable flag set), and
49831 Btree *pBtree, /* The database file to check */
49862 ** a free-list leaf page, the page is not written to the database
49868 ** from the database or written to the journal file (why should it
49878 ** to restore the database to its original configuration.
50095 ** Given a page number of a regular database page, return the page
50701 ** indicates a corrupt database files:
50738 ** not contain a well-formed database page, then return
50783 /* A malformed database page might cause us to read past the end
50828 ** the free-block must lie on the database page. */
50852 ** Set up a raw page so that it looks like a database page holding
50945 ** Return the size of the database file in pages. If there is any kind of
50966 BtShared *pBt, /* The database file */
51043 ** Open a database file.
51045 ** zFilename is the name of the database file. If zFilename is NULL
51046 ** then an ephemeral database is created. The ephemeral database might
51048 ** Either way, the ephemeral database will be automatically deleted
51051 ** If zFilename is ":memory:" then an in-memory database is created
51057 ** If the database is already opened in the same database connection
51060 ** objects in the same database connection since doing so will lead
51065 const char *zFilename, /* Name of the file containing the BTree database */
51066 sqlite3 *db, /* Associated database handle */
51076 unsigned char zDbHeader[100]; /* Database header content */
51078 /* True if opening an ephemeral, temporary database */
51081 /* Set the variable isMemdb to true for an in-memory database, or
51082 ** false for a file-based database.
51096 /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */
51099 /* A BTREE_SINGLE database is always a temporary and/or ephemeral */
51222 /* If the magic name ":memory:" will create an in-memory database, then
51386 ** Close an open database and invalidate all cursors.
51451 ** and the database cannot be corrupted if this program
51453 ** an abrupt power failure when synchronous is off, the database
51455 ** Synchronous is on by default so database corruption is not
51469 ** how well the database resists damage due to OS crashes and power
51517 ** of the database file used for locking (beginning at PENDING_BYTE,
51576 ** Set the maximum page count for a database if mxPage is positive.
51608 ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
51655 ** Get a reference to pPage1 of the database file. This will
51659 ** well-formed database file, then SQLITE_CORRUPT is returned.
51660 ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM
51665 MemPage *pPage1; /* Page 1 of the database file */
51666 int nPage; /* Number of pages in the database */
51667 int nPageFile = 0; /* Number of pages in the database file */
51668 int nPageHeader; /* Number of pages in the database according to hdr */
51678 ** a valid database file.
51709 /* If the write version is set to 2, this database should be accessed
51748 /* After reading the first page of the database assuming a page size
51750 ** actually pageSize. Unlock the database, leave pBt->pPage1 at
51812 ** of a transaction but there is a read lock on the database, then
51813 ** this routine unrefs the first page of the database file which
51832 ** into a new empty database by initializing the first page of
51833 ** the database.
51879 ** to access the database. A preexisting transaction may not be
51884 ** changes to the database. None of the following routines
51896 ** and the database was previously unlocked, then invoke the busy handler
51925 /* Write transactions are not possible on a read-only database */
51932 /* If another database handle has already opened a write transaction
51968 ** reading page 1 it discovers that the page-size of the database
52017 ** client has been writing the database file), update it now. Doing
52018 ** this sooner rather than later means the database size can safely
52019 ** re-read the database size from page 1 if a savepoint or transaction
52155 ** Move the open database page pDbPage to location iFreePage in the
52156 ** database. The pDbPage reference remains valid.
52159 ** the journal needs to be sync()ed before database page pDbPage->pgno
52213 /* Fix the database pointer on page iPtrPage that pointed at iDbPage so
52245 ** database so that the last page of the file currently in use
52251 ** number of pages the database file will contain after this
52388 ** is commited for an auto-vacuum database.
52391 ** the database file should be truncated to during the commit process.
52392 ** i.e. the database has been reorganized so that only the first *pnTrunc
52404 Pgno nFin; /* Number of pages in database after autovacuuming */
52409 Pgno nOrig; /* Database size before freeing */
52413 /* It is not possible to create a database for which the final page
52460 ** the database can be restored to its original state by playing back
52463 ** database are written into the database file and flushed to oxide.
52471 ** Otherwise, sync the database file for the btree pBt. zMaster points to
52474 ** (single database transaction).
52480 ** the write-transaction for this database file is to delete the journal.
52512 /* If there are other active statements that belong to this database
52514 ** may still be reading from the database. */
52562 ** This will release the write lock on the database file. If there
52633 ** to other database connections that happen to be sharing
52667 ** This will release the write lock on the database file. If there
52779 /* The database size was written into the offset 28 of the header
52793 ** on the database already. If a write-cursor is requested, then
52804 ** 2: Other database connections that share the same pager cache
52808 ** the read cursors in the other database connection.
52810 ** 3: The database must be writable (not on read-only media)
52834 ** b-tree database, the connection is holding the required table locks,
52909 ** Set the cached rowid value of every cursor in the same database file
52939 ** Close a cursor. The read lock on the database file is released
53073 ** Given the page number of an overflow page in the database (parameter
53092 BtShared *pBt, /* The database file */
53151 ** pPayload is a pointer to data stored on database page pDbPage.
53328 ** 3) the database is file-backed, and
53330 ** 5) the database is not a WAL database,
53332 ** then data can be read directly from the database file into the
53439 ** page of the database. The data might change or move the next time
53584 ** below to be untrue if the database file is corrupt. This can occur if
53587 ** into more than one b-tree structure in a corrupt database. */
54036 ** Advance the cursor to the next entry in the database. If
54038 database before
54067 /* If the database file is corrupt, it is possible for the value of idx
54070 ** only happen if the database is corrupt in such a way as to link the
54111 ** Step the cursor to the back to the previous entry in the database. If
54113 ** was already pointing to the first entry in the database before
54171 ** Allocate a new page from the database file.
54184 ** attempt to keep related pages close to each other in the database file,
54185 ** which in turn can make database access faster.
54204 Pgno mxPage; /* Total size of the database file */
54284 /* Value of k is out of range. Database corruption */
54461 ** This function is used to add page iPage to the database file free-list.
54509 /* If the database supports auto-vacuum, write an entry in the pointer-map
54517 /* Now manipulate the actual database free-list structure. There are two
54630 ** file the database must be corrupt. */
54644 ** must not really be an overflow page and the database must be corrupt.
54754 /* If the database supports auto-vacuum, and the second or subsequent
54762 ** wrong pages from the database.
55063 BtShared *const pBt = pPage->pBt; /* B-Tree Database */
55093 /* If this is an auto-vacuum database, update the pointer map
55234 /* If this is an auto-vacuum database, update the pointer-map entries
55267 ** If this routine fails for any reason, it might leave the database
55268 ** in a corrupted state. So if this routine fails, the database should
55289 BtShared *pBt; /* The whole database */
55586 ** UPDATE: The assert() below is not necessarily true if the database
55654 ** When NB==3, this one optimization makes the database
55770 ** If this is an auto-vacuum database, the call to copyNodeContent()
55771 ** sets all pointer-map entries corresponding to database image pages
55776 ** is important if the parent page happens to be page 1 of the database
55883 ** debugging. This is usually disabled because a corrupt database may
56064 ** copied either into the body of a database page or into the new
56072 ** now stored either on real database pages or within the
56408 /* Creating a new table may probably require moving an existing database
56415 /* Read the value of meta[3] from the database to determine where the
56495 ** order either to increase the database filesize, or to decrement the
56531 ** Erase the given database page and all its children. Return
56580 ** Delete all information from a single table in the database. iTable is
56620 ** root page in the database file, then the last root page
56621 ** in the database file is moved into the slot formerly occupied by
56624 ** root pages are kept at the beginning of the database file, which
56640 ** database. This is because in auto-vacuum mode the backend may
56673 ** number in the database, put the root page on the free list.
56682 ** number in the database. So move the page that does into the
56706 /* Set the new 'max-root-page' value in the database header. This
56727 ** database.
56745 ** has a read or write transaction open on the database.
56747 ** Read the meta-information out of a database file. Meta[0]
56748 ** is the number of free pages currently in the database. Meta[1]
56768 ** database, mark the database as read-only. */
56779 database. Meta[0] is
56812 ** Otherwise, if an error is encountered (i.e. an IO error or database
57027 /* If this database supports auto-vacuum and iPage is not the last
57352 /* If the database supports auto-vacuum, make sure no tables contain
57393 ** Return the full pathname of the underlying database file.
57404 ** Return the pathname of the journal file for this database. The return
57601 ** "write version" (single byte at byte offset 19) fields in the database
57662 sqlite3* pDestDb; /* Destination database handle */
57668 sqlite3* pSrcDb; /* Source database handle */
57690 ** backup_finish(). Both these functions obtain the source database
57696 ** the page cache associated with the source database. The mutex
57697 ** associated with the source database BtShared structure will always
57707 ** Depending on the SQLite configuration, the database handles and/or
57714 ** Return a pointer corresponding to database zDb (i.e. "main", "temp")
57715 ** in connection handle pDb. If such a database cannot be found, return
57718 ** If the "temp" database is requested, it may need to be opened by this
57747 sqlite3Error(pErrorDb, SQLITE_ERROR, "unknown database %s", zDb);
57770 ** stored in database handle pDestDb.
57773 sqlite3* pDestDb, /* Database to write to */
57774 const char *zDestDb, /* Name of database within pDestDb */
57775 sqlite3* pSrcDb, /* Database connection to read from */
57776 const char *zSrcDb /* Name of database within pSrcDb */
57780 /* Lock the source databasedatabase
57785 ** database connection while a backup is in progress may cause
57847 ** page iSrcPg from the source database. Copy this data into the
57848 ** destination database.
57869 /* Catch the case where the destination is an in-memory database and the
57989 /* Lock the destination database, if it is not locked already. */
57997 /* If there is no open read-transaction on the source database, open
58006 /* Do not allow backup if the destination database is in WAL mode
58015 /* Now that there is a read-lock on the source database, query the
58016 ** source pager for the number of pages in the database.
58042 /* Update the schema version field in the destination database. This
58060 ** database. The complication here is that the destination page
58091 ** pending-byte page in the source database may need to be
58092 ** copied into the destination database.
58106 ** database has been stored in the journal for pDestPager and the
58108 ** the database file in any way, knowing that if a power failure
58109 ** occurs, the original database will be reconstructed from the
58113 /* Write the extra pages and truncate the database file as required */
58133 /* Sync the database file to disk. */
58141 /* Finish committing the transaction to the destination database. */
58151 ** on the source database. Close the read transaction here. There is
58180 MUTEX_LOGIC( sqlite3_mutex *mutex; ) /* Mutex to protect source database */
58207 /* Set the error code of the destination database handle. */
58235 ** Return the total number of pages in the source database as of the most
58244 ** source database have been modified. If page iPage has already been
58245 ** copied into the destination database, then the data written to the
58251 ** corresponding to the source database is held when this function is
58278 ** detects that the database has been modified by an external database
58280 ** pages that have been copied into the destination database are still
58284 ** corresponding to the source database is held when this function is
58306 sqlite3_file *pFd; /* File descriptor for database pTo */
58331 /* 0x7FFFFFFF is the hard limit for the number of pages in a database
59264 ** that both the BtShared and database handle mutexes are held. */
59367 sqlite3 *db, /* The database connection */
59543 ** Create a new virtual database engine.
60497 ** of all of BtShared structures accessible via the database handle
60651 sqlite3 *db = p->db; /* The database connection */
60977 sqlite3 *db; /* The database connection */
61246 ** A read or write transaction may or may not be active on database handle
61248 ** write-transaction spanning more than one database file, this routine
61267 ** required, as an xSync() callback may add an attached database
61273 ** (b) how many database files have open write transactions, not
61274 ** including the temp database. (b) is important because if more than
61275 ** one database file has an open write transaction, a master journal
61298 /* The simple case - no more than one database file (not counting the
61299 ** TEMP database) has a transaction active. There is no need for the
61303 ** string, it means the main database is :memory: or a temp file. In
61386 /* Write the name of each database file in the transaction into the new
61570 ** database handles deferred constraint counter to the value it had when
61580 ** This function is called when a transaction opened by the database
61662 ** transaction must be rolled back to restore the database to a
61667 ** occured while writing to the journal, sub-journal or database
61763 ** has been rolled back, update the database connection change-counter.
61815 ** as the first argument to its database handle (so that they will be
61819 ** copies them to the database handle.
61859 ** and error message from the VDBE into the main database structure. But
61861 ** instructions yet, leave the main database error information unchanged.
61871 ** called), set the database error in this case as well.
61948 ** the database connection.
62554 ** pCur might be pointing to text obtained from a corrupt database file.
62568 ** than 2GiB are support - anything large must be database corruption.
62618 /* Jump here if database corruption is detected after m has been
62669 ** sqlite3_changes() on the database handle 'db'.
62686 ** Mark every prepared statement associated with a database connection
62703 ** Return the database associated with the Vdbe.
63202 ** caller. Set the error code in the database handle to the same value.
63227 sqlite3 *db; /* The database connection */
63243 ** into the database handle. This block copies the error message
63244 ** from the database handle into the statement and sets the statement
63278 ** returns a copy of the pointer to the database connection (the 1st
63591 ** 2 The name of the database that the column derives from
63671 ** Return the name of the database from which a result column derives.
63673 ** anything else which is not an unabiguous reference to a database column.
63689 ** anything else which is not an unabiguous reference to a database column.
63705 ** anything else which is not an unabiguous reference to a database column.
63732 ** The error code stored in database p->db is overwritten with the return
63986 ** database connections. But as this is a deprecated interface, we
64010 ** Return the sqlite3* database handle to which the prepared statement given
64011 ** in the argument belongs. This is the same database handle that was
64021 ** database.
64037 ** with database connection pDb. If pStmt is NULL, return the first
64038 ** prepared statement for the database connection. Return NULL if there
64133 sqlite3 *db; /* The database connection */
64349 ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c")
64527 int iDb, /* Database the cursor belongs to, or -1 */
64950 ** If an attempt is made to open a locked database
64977 sqlite3 *db = p->db; /* The database */
64979 u8 encoding = ENC(db); /* The database encoding */
65220 const char *zDb; /* database name - used by the update hook */
65360 const char *zFilename; /* Name of database file for pPager */
67095 ** nullRow or because of a corrupt database. */
67144 ** the database file has been corrupted externally.
67148 /* Make sure a corrupt database has not given us an oversize header.
67167 ** allocation, especially if a corrupt database file has caused u.an.offset
67173 ** not exceeded even for corrupt database files.
67234 ** with a corrupt database.
67327 ** use as a data record in a database table or as a key
67547 /* Link the new savepoint into the database handle's list. */
67625 ** constraint violations present in the database to the value stored
67650 ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll
67730 ** P1 is the index of the database file on which the transaction is
67731 ** started. Index 0 is the main database file and index 1 is the
67736 ** obtained on the database file when a write-transaction is started. No
67740 ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
67746 ** More specifically, a statement transaction is opened iff the database
67753 ** If P2 is zero, then a read-lock is obtained on the database file.
67790 /* Store the current value of the database handles deferred constraint
67801 ** Read cookie number P3 from database P1 and write it into register P2.
67802 ** P3==1 is the schema version. P3==2 is the database format.
67804 ** the main database file and P1==1 is the database file used to store
67807 database (either a transaction
67833 ** into cookie number P2 of database P1. P2==1 is the schema version.
67834 ** P2==2 is the database format. P2==3 is the recommended pager cache
67835 ** size, and so forth. P1==0 is the main database file and P1==1 is the
67836 ** database file used to store temporary tables.
67863 /* Invalidate all prepared statements whenever the TEMP database
67873 ** Check the value of global database parameter number 0 (the
67877 ** P1 is the database number which is 0 for the main database file
67881 ** The cookie changes its value whenever the database schema changes.
67908 p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
67909 /* If the schema-cookie from the database file matches the cookie
67911 ** not reload the schema from the database file.
67917 ** discard the database schema, as the user code implementing the
67934 ** Open a read-only cursor for the database table whose root page is
67935 ** P2 in a database file. The database file is determined by P3.
67936 ** P3==0 means the main database, P3==1 means the database used for
67938 ** database. Give the new cursor an identifier of P1. The P1
67945 ** There will be a read lock on the database whenever there is an
67946 ** open cursor. If the database was unlocked prior to this instruction
67948 ** lock allows other processes to read the database but prohibits
67949 ** any other process from modifying the database. The read lock is
68055 ** and report database corruption if they were not, but this check has
68066 ** the main database is read-only. The ephemeral
68691 ** The record number is not previously used as a key in the database
68801 ** largest possible integer (9223372036854775807) then the database
68892 const char *zDb; /* database name - used by the update hook */
69021 ** The value of the change counter is copied to the database handle
69080 ** it is found in the database file.
69090 ** it is found in the database file.
69235 ** will refer to the last entry in the database table or index.
69293 ** will refer to the first entry in the database table or index.
69599 ** Delete an entire database table or index whose root page in the database
69602 ** The table being destroyed is in the main database file if P3==0. If
69603 ** P3==1 then the table to be clear is in the auxiliary database file
69608 ** root pages contiguous at the beginning of the database. The former
69612 ** the last one in the database) then a zero is stored in register P2.
69659 ** Delete all contents of the database table or index whose root page
69660 ** in the database file is given by P1. But, unlike Destroy, do not
69661 ** remove the table or index from the database file.
69663 ** The table being clear is in the main database file if P2==0. If
69664 ** P2==1 then the table to be clear is in the auxiliary database file
69698 ** Allocate a new table in the main database file if P1==0 or in the
69699 ** auxiliary database file if P1==1 or in an attached database if
69711 ** Allocate a new index in the main database file if P1==0 or in the
69712 ** auxiliary database file if P1==1 or in an attached database if
69744 ** Read and parse all entries from the SQLITE_MASTER table of database P1
69802 ** Read the sqlite_stat1 table for database P1 and load the content
69816 ** the table named P4 in database P1. This is called after a table
69828 ** the index named P4 in database P1. This is called after an index
69840 ** the trigger named P4 in database P1. This is called after a trigger
69853 ** Do an analysis of the currently open database. Store in
69862 ** The root page numbers of all tables in the database are integer
69866 ** If P5 is not zero, the check is done on the auxiliary database
69867 ** file, not the main database file.
70170 ** If P1 is non-zero, the database constraint counter is incremented
70189 ** If P1 is non-zero, then the jump is taken if the database constraint-counter
70386 ** Checkpoint database P1. This is a no-op if P1 is not currently in
70423 ** Change the journal mode of database P1 to P3. P3 must be one of the
70438 const char *zFilename; /* Name of database file for pPager */
70461 /* Do not allow a transition to journal_mode=WAL for a database
70486 ** file. An EXCLUSIVE lock may still be held on the database file
70499 /* Open a transaction on the database file. Regardless of the journal
70528 ** Vacuum the entire database. This opcode will cause other virtual
70542 ** the P1 database. If the vacuum has finished, jump to instruction
70586 ** P1 is the index of the database in sqlite3.aDb[] of the database
70605 sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z);
70636 ** P4 is the name of a virtual table in database P1. Call the xCreate method
70648 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
70991 ** Write the current number of pages in database P1 to memory cell P2.
71003 ** Try to set the maximum page count for database P1 to the value in P3.
71205 sqlite3 *db; /* The associated database */
71282 sqlite3* db, /* The database connection */
71283 const char *zDb, /* The attached database containing the blob */
71604 ** database table.
71608 ** database handle error code and message set. If this happens, then all
71798 sqlite3 *db, /* Database handle (for sqlite3DbMalloc() ) */
71904 sqlite3 *db, /* Database handle */
72030 int pgsz; /* Page size of main database */
72253 sqlite3 *db, /* Database handle */
72299 sqlite3 *db, /* Database handle */
73223 sqlite3 *db; /* The database connection */
73291 ** pExpr->iDb Set the index in db->aDb[] of the database X
73302 ** The zDb variable is the name of the database (the "X"). This value may be
73303 ** NULL meaning that name is of the form Y.Z or Z. Any available database
73314 const char *zDb, /* Name of the database containing table, or NULL */
73323 sqlite3 *db = pParse->db; /* The database connection */
73658 ** Or a database, table and column: ID.ID.ID
73694 u8 enc = ENC(pParse->db); /* The database encoding */
73841 sqlite3 *db; /* Database connection */
74106 sqlite3 *db; /* Database connection */
74286 ** X: The name of a database. Ex: "main" or "temp" or
74287 ** the symbolic name assigned to an ATTACH-ed database.
75237 ** part of the in-memory representation of the database schema.
75786 ** The index of the cursor opened on the b-tree (database table, database index
75790 ** IN_INDEX_ROWID - The cursor was opened on a database table.
75791 ** IN_INDEX_INDEX - The cursor was opened on a database index.
75850 sqlite3 *db = pParse->db; /* Database connection */
75854 int iDb; /* Database idx for pTab */
76268 ** of a "NOT NULL" constraint in the database schema.
76677 sqlite3 *db = pParse->db; /* The database connection */
76946 u8 enc = ENC(db); /* The text encoding used by this database */
78637 ** Note that ON cannot be a database, table or column name, so
78727 ** temporary database, NULL is returned.
78757 ** pTab from the database, including triggers and temporary triggers.
78758 ** Argument zName is the name of the table in the database schema at
78766 int iDb; /* Index of database containing pTab */
78795 /* Now, if the table is not stored in the temp database, reload any temp
78829 int iDb; /* Database that contains the table */
78830 char *zDb; /* Name of database iDb */
78833 sqlite3 *db = pParse->db; /* Database connection */
78859 ** in database iDb. If so, this is an error.
78903 /* Begin a transaction and code the VerifyCookie for database iDb.
78974 /* If the sqlite_sequence table exists in this database, then update
78987 ** the temp database.
79057 int iDb; /* Database number */
79058 const char *zDb; /* Database name */
79063 sqlite3 *db; /* The database connection; */
79396 int iDb, /* The database we are looking in */
79695 sqlite3 *db = pParse->db; /* Database handle */
79703 int iDb; /* Index of database containing pTab */
79975 ** Generate code that will do an analysis of an entire database
79979 Schema *pSchema = db->aDb[iDb].pSchema; /* Schema of database iDb */
79999 ** a database. If pOnlyIdx is not NULL then it is a single index
80026 ** ANALYZE <database> -- 2
80027 ** ANALYZE ?<database>.?<tablename> -- 3
80030 ** Form 2 analyzes all indices the single database named.
80042 /* Read the database schema. If an error occurs, leave an error message
80053 if( i==1 ) continue; /* Do not analyze the TEMP database */
80057 /* Form 2: Analyze the database or table named */
80315 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
80321 ** sqlite_stat3 table is not present in the database, SQLITE_ERROR is
80410 ** ATTACH DATABASE abc AS def
80417 ** ATTACH DATABASE abc||def AS 'db2'
80442 ** ATTACH DATABASE x AS y KEY z
80477 ** * Specified database name already being used.
80486 zErrDyn = sqlite3MPrintf(db, "cannot ATTACH database within transaction");
80493 zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName);
80513 /* Open the database file. If the btree is successfully opened, use
80514 ** it to obtain the database schema. At this point the schema may
80532 zErrDyn = sqlite3MPrintf(db, "database is already attached");
80540 "attached databases must use the same text encoding as main database");
80577 /* No key specified. Use the key from the main database */
80587 /* If the file was opened successfully, read the schema for the new database.
80612 zErrDyn = sqlite3MPrintf(db, "unable to open database: %s", zFile);
80632 ** DETACH DATABASE x
80657 sqlite3_snprintf(sizeof(zErr),zErr, "no such database: %s", zName);
80661 sqlite3_snprintf(sizeof(zErr),zErr, "cannot detach database %s", zName);
80666 "cannot DETACH database within transaction");
80670 sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
80693 Expr *pFilename, /* Name of database file */
80694 Expr *pDbname, /* Name of the database to use internally */
80695 Expr *pKey /* Database key for encryption extension */
80807 ** means we do need to fix the database references, FALSE means we do not.
80812 int iDb, /* This is the database that must be used */
80830 ** a specific database to all table references where the database name
80835 ** view in one database does not refer to objects in a different database.
80836 ** (Exception: indices, triggers, and views in the TEMP database are
80838 ** to an object in a different database, an error message is added to
80857 "%s %T cannot reference objects in database %s",
80871 Select *pSelect /* The SELECT statement to be fixed to one database */
80892 Expr *pExpr /* The expression to be fixed to one database */
80910 ExprList *pList /* The expression to be fixed to one database */
80927 database */
80975 ** various fields of the database. The first argument to the auth function
81039 ** table zTab in database zDb. This function assumes that an authorization
81050 int iDb /* Index of containing database. */
81052 sqlite3 *db = pParse->db; /* Database handle */
81053 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
81089 int iDb; /* The index of the database the expression refers to */
81146 /* Don't do any authorization checks if the database is initialising
81238 int iDb; /* The database containing the table to be locked */
81247 ** The table to be locked has root page iTab and is found in database iDb.
81256 int iDb, /* Index of the database containing the table to lock */
81340 /* The cookie mask contains one bit for each database file open.
81342 ** set for each database that is used. Generate code to start a
81343 ** transaction on each used database and to verify the schema cookie
81344 ** on each used database.
81452 ** Locate the in-memory structure that describes a particular database
81454 ** database containing the table. Return NULL if not found.
81482 ** Locate the in-memory structure that describes a particular database
81484 ** database containing the table. Return NULL if not found. Also leave an
81495 const char *zDbase /* Name of the database. Might be NULL */
81499 /* Read the database schema. If an error occurs, leave an error message
81521 ** and the name of the database that contains the index.
81560 ** For the index called zIdxName which is found in the database iDb,
81594 ** a single database. This routine is called to reclaim memory
81595 ** before the database closes. It is also called during a rollback
81599 ** If iDb<0 then reset the internal schema tables for all database
81614 /* If any database other than TEMP is reset, then also reset TEMP
81616 ** other database.
81639 /* If one or more of the auxiliary database files has been closed,
81640 ** then remove them from the auxiliary database list. We take the
81789 ** Open the sqlite_master table stored in database number iDb for
81804 ** of a database ("main", "temp" or the name of an attached db). This
81805 ** function returns the index of the named database in db->aDb[], or
81809 int i = -1; /* Database number */
81824 ** The token *pName contains the name of a database (either "main" or
81826 ** index of the named database in db->aDb[], or -1 if the named db
81830 int i; /* Database number */
81852 ** database "xxx" is returned.
81860 int iDb; /* Database holding the object */
81865 sqlite3ErrorMsg(pParse, "corrupt database");
81872 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
81906 ** flag is true if the table should be stored in the auxiliary database
81907 ** file instead of in the main database file. This is normally the case
81930 int iDb; /* Database number to create the table in */
81947 ** set to the index of the database that the table or view is to be
81954 ** the database name is "temp" anyway. */
81995 ** index or table name in the same database. Issue an error message if
82038 ** then record a pointer to this table in the main database structure
82068 /* If the file format and encoding in the database have not been set,
82447 ** This function returns the collation sequence for database native text
82451 ** in the database native encoding, the collation factory is invoked to
82488 ** database changes. After each schema change, the cookie value
82490 ** cookie. Thereafter, whenever it goes to access the database,
82642 ** connected to the database or because the sqlite_master table has
82704 ** in the SQLITE_MASTER table of the database.
82707 ** file instead of into the main database file.
82746 ** a schema-lock excludes all other database users, the write-lock would
82823 /* Add the table to the in-memory representation of the database.
82941 sqlite3 *db = pParse->db; /* Database connection for malloc errors */
83029 ** Clear the column names from every VIEW in database idx.
83052 ** root-page of a table or index in database iDb has changed from iFrom
83092 ** Write code to erase the table with root-page iTable from database iDb.
83095 ** erasing iTable (this can happen with an auto-vacuum database).
83123 ** is also added (this can happen with an auto-vacuum database).
83134 /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM
83146 ** database, then root page 5 would be moved to page 4 by the
83184 int iDb, /* The database number */
83251 ** created in the temp database that refers to a table in another
83252 ** database.
83547 sqlite3 *db = pParse->db; /* The database connection */
83677 DbFixer sFix; /* For assigning database names to pTable */
83680 Db *pDb; /* The specific table containing the indexed database */
83681 int iDb; /* Index of the database that is being written */
83702 /* Use the two-part index name to determine the database
83713 ** is a temp table. If so, set the database to 1. Do not do this
83714 ** if initialising a database schema.
84012 ** in-memory database structures.
84036 ** command. db->init.busy is 1 when a database is opened and
84351 sqlite3 *db, /* Database connection to notify of OOM errors */
84408 ** database name prefix. Like this: "database.table". The pDatabase
84409 ** points to the table name and the pTable points to the database name.
84412 ** SrcList.a[].zDatabase is filled with the database name from pTable,
84413 ** or with NULL if no database is specified.
84419 ** Then B is a table name and the database name is unspecified. If called
84424 ** Then C is the table name and B is the database name. If C is defined
84436 Token *pDatabase /* Database of the table */
84507 ** are the name of the table and database named in the FROM clause term.
84508 ** pDatabase is NULL if the database name qualifier is missing - the
84522 Token *pDatabase, /* Name of the database containing pTable */
84684 ** Make sure the TEMP database is open and available for use. Return
84701 sqlite3ErrorMsg(pParse, "unable to open a temporary database "
84718 ** a read-transaction for all named database files.
84727 ** record every database that needs its schema verified in the
84736 ** early in the code, before we know if any database tables will be used.
84767 ** attached database. Otherwise, invoke it for the database named zDb only.
84782 ** might change the database.
84790 ** can be checked before any changes are made to the database, it is never
84815 ** perform this abort without corrupting the database, we need to make
84890 Db *pDb; /* A single database */
84891 int iDb; /* The database index number */
84892 sqlite3 *db = pParse->db; /* The database connection */
84894 Table *pTab; /* A table in the database */
84912 ** REINDEX ?<database>.?<tablename> -- 3
84913 ** REINDEX ?<database>.?<indexname> -- 4
84924 const char *zDb; /* Name of the database */
84925 Table *pTab; /* A table in the database */
84927 int iDb; /* The database index number */
84928 sqlite3 *db = pParse->db; /* The database connection */
84931 /* Read the database schema. If an error occurs, leave an error message
84977 ** with OP_OpenRead or OP_OpenWrite to access database index pIdx.
85085 ** If it is not NULL, then pColl must point to the database native encoding
85088 ** The return value is either the collation sequence to be used in database
85095 sqlite3* db, /* The database connection */
85123 ** a database is loaded that contains references to collation sequences
85129 ** from the main database is substituted, if one is available.
85162 sqlite3 *db, /* Database connection */
85202 ** for the encoding 'enc' from the database 'db'.
85338 sqlite3 *db, /* An open database */
85698 Vdbe *v; /* The virtual database engine */
85700 const char *zDb; /* Name of database holding pTab */
85706 sqlite3 *db; /* Main database structure */
85709 int iDb; /* Database number */
85856 ** database scan. We have to delete items after the scan is complete
86429 ** the database handle that malloc() has failed and return NULL.
87481 ** returns (void *)db, where db is the sqlite3* database pointer.
87772 ** with the database handle. The counter is set to zero each time a
87773 ** database transaction is opened. Each time a statement is executed
87776 ** the database, the counter is decremented. When the transaction is
87784 ** * If the database contains foreign key violations when the
88057 int iDb, /* Index of database housing pTab */
88220 sqlite3 *db = pParse->db; /* Database handle */
88345 ** the lookaside buffer belonging to database handle dbMem.
88360 ** being dropped from the database. The SrcList passed as the second argument
88369 ** constraint violations in the database,
88372 ** the table from the database. Triggers are disabled while running this
88442 sqlite3 *db = pParse->db; /* Database handle */
88444 int iDb; /* Index of database containing pTab */
88445 const char *zDb; /* Name of database containing pTab */
88716 sqlite3 *db = pParse->db; /* Database handle */
88985 int iDb, /* The database index in sqlite3.aDb[] */
89092 ** Return non-zero if the table pTab in database iDb or any of its indices
89135 ** which is in database iDb. Return the register number for the register
89155 int iDb, /* Index of the database holding pTab */
89187 sqlite3 *db = pParse->db; /* The database connection */
89188 Db *pDb; /* Database only autoinc table */
89291 int iDbDest /* The database of pDest */
89404 sqlite3 *db; /* The main database structure */
89407 const char *zDb; /* Name of the database holding this table */
89422 int iDb; /* Index of database holding TABLE */
89423 Db *pDb; /* The database containing table being inserted into */
90569 int iDbDest /* The database of pDest */
90576 int iDbSrc; /* The database of pSrc */
90837 sqlite3 *db, /* The database on which the SQL executes */
91799 sqlite3 *db, /* Load the extension into this database connection */
91880 sqlite3 *db, /* Load the extension into this database connection */
91894 ** Call this routine when the database connection is closing in order
91965 ** loaded by every new database connection.
92026 ** If anything goes wrong, set an error in the database connection.
92153 ** backed temporary databases, 2 for the Red-Black tree in memory database
92192 ** If the TEMP database is open, close it and mark the database schema
92356 ** PRAGMA [database.]id [= value]
92362 ** If the left side is "database.id" then pId1 is the database name
92368 Token *pId1, /* First part of [database.]id field */
92369 Token *pId2, /* Second part of [database.]id field, or NULL */
92375 const char *zDb = 0; /* The database name */
92377 int iDb; /* Database index for <database> */
92380 sqlite3 *db = pParse->db; /* The database connection */
92381 Db *pDb; /* The specific database being pragmaed */
92388 /* Interpret the [database.] part of the pragma statement. iDb is the
92389 ** index of the database this pragma is being applied to in db.aDb[]. */
92394 /* If the temp database has been explicitly named as part of the
92445 ** PRAGMA [database.]default_cache_size
92446 ** PRAGMA [database.]default_cache_size=N
92452 ** stored in the database file.
92496 ** PRAGMA [database.]page_size
92497 ** PRAGMA [database.]page_size=N
92500 ** database page size in bytes. The second form sets the
92501 ** database page size value. The value can only be set if
92502 ** the database has not yet been created.
92522 ** PRAGMA [database.]secure_delete
92523 ** PRAGMA [database.]secure_delete=ON/OFF
92547 ** PRAGMA [database.]max_page_count
92548 ** PRAGMA [database.]max_page_count=N
92551 ** maximum number of pages in the database file. The
92559 ** PRAGMA [database.]page_count
92561 ** Return the number of pages in the specified database.
92582 ** PRAGMA [database.]locking_mode
92583 ** PRAGMA [database.]locking_mode = (normal|exclusive)
92592 ** the locking-mode of the main database).
92598 /* This indicates that no database name was specified as part
92629 ** PRAGMA [database.]journal_mode
92630 ** PRAGMA [database.]journal_mode =
92638 ** database files to be opened and the journal_modes set. This is
92679 ** PRAGMA [database.]journal_size_limit
92680 ** PRAGMA [database.]journal_size_limit=N
92698 ** PRAGMA [database.]auto_vacuum
92699 ** PRAGMA [database.]auto_vacuum=N
92701 ** Get or set the value of the database 'auto-vacuum' parameter.
92726 ** creates the database file. It is important that it is created
92732 ** "incremental", write the value of meta[6] in the database
92734 ** that this really is an auto-vacuum capable database.
92759 ** PRAGMA [database.]incremental_vacuum(N)
92761 ** Do N steps of incremental vacuuming on a database.
92784 ** PRAGMA [database.]cache_size
92785 ** PRAGMA [database.]cache_size=N
92812 ** value will be restored the next time the database is opened.
92879 ** PRAGMA [database.]lock_proxy_file
92880 ** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
92883 ** the value sets a specific file to be used for database access locks.
92921 ** PRAGMA [database.]synchronous
92922 ** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL
92926 ** default value will be restored the next time the database is
93161 ** integrity_check designed to detect most database corruption
93198 /* Do an integrity check on each database file */
93214 ** for all tables and indices in the database.
93239 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName),
93329 ** database. If the database is not initialized, it is initialized now.
93331 ** The second form of this pragma is a no-op if the main database file
93333 ** encoding that will be used for the main database file if a new file
93334 ** is created. If an existing main database file is opened, then the
93335 ** default text encoding for the existing database is used.
93338 ** created to use the same default text encoding as the main database. If
93339 ** the main database has not been initialized and/or created when ATTACH
93343 ** new database files created using this database handle. It is only
93344 ** useful if invoked immediately after the main database i
93373 /* Only change the value of sqlite.enc if the database handle is not
93374 ** initialized. If the main database exists, the new sqlite.enc value
93398 ** PRAGMA [database.]schema_version
93399 ** PRAGMA [database.]schema_version = <integer>
93401 ** PRAGMA [database.]user_version
93402 ** PRAGMA [database.]user_version = <integer>
93407 ** stored in the database header.
93410 ** is incremented by SQLite whenever the database schema is modified (by
93414 ** the database against which the compiled query is actually executed.
93417 ** crashes or database corruption. Use with caution!
93491 ** PRAGMA [database.]wal_checkpoint = passive|full|restart
93493 ** Checkpoint the database.
93520 ** Configure a database connection to automatically checkpoint a database
93538 ** current database connection.
93555 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC);
93651 ** interface, and routines that contribute to loading the database schema
93657 ** that the database is corrupt.
93668 "malformed database schema (%s)", zObj);
93679 ** database. See sqlite3Init() below for additional information.
93764 ** Attempt to read the database schema and initialize internal
93765 ** data structures for a single database file. The index of the
93766 ** database file is given by iDb. iDb==0 is used for the main
93767 ** database. iDb==1 should never be used. iDb>=2 is used for
93785 ** The master database table has a structure like this
93816 ** and initialisation script appropriate for the database being
93845 /* Create a cursor to hold the database open
93856 ** on the b-tree database, open one now. If a transaction is opened, it
93868 /* Get the database meta information.
93890 /* If opening a non-empty database, check the text encoding. For the
93891 ** main database, set sqlite3.enc to the encoding of the main database.
93898 /* If opening the main database, set ENC(db). */
93904 /* If opening an attached database, the encoding much match ENC(db) */
93907 " text encoding as main database");
93944 /* Ticket #2804: When we open a database in the newer file format,
93946 ** not downgrade the database and thus invalidate any descending
94015 ** Initialize all database files - the main database file, the file
94016 ** used to store temporary tables, and any additional database files
94020 ** After a database is initialized, the DB_SchemaLoaded bit is set
94021 ** bit is set in the flags field of the Db structure. If the database
94040 ** for the TEMP database. This is loaded last, as the TEMP database
94062 ** This routine is a no-op if the database schema is already initialised.
94095 Btree *pBt = db->aDb[iDb].pBt; /* Btree database to read cookie from */
94099 ** on the b-tree database, open one now. If a transaction is opened, it
94110 /* Read the schema cookie from the database. If it does not match the
94129 ** which database file in db->aDb[] the schema refers to.
94131 ** If the same database is attached more than once, the first
94132 ** attached database is returned.
94163 sqlite3 *db, /* Database handle. */
94188 ** database schemas. The inability to get a read lock indicates that
94189 ** some other database connection is holding a write-lock, which in
94217 sqlite3Error(db, rc, "database schema is locked: %s", zDb);
94323 sqlite3 *db, /* Database handle. */
94395 sqlite3 *db, /* Database handle. */
94407 sqlite3 *db, /* Database handle. */
94425 sqlite3 *db, /* Database handle. */
94475 sqlite3 *db, /* Database handle. */
94487 sqlite3 *db, /* Database handle. */
95522 ** database table or a subquery.
95753 sqlite3 *db = pParse->db; /* Database connection */
96071 sqlite3 *db; /* Database connection */
96693 sqlite3 *db; /* Database connection */
97623 ** where table is a database table, not a sub-select or view. If the query
98277 sqlite3 *db; /* The database connection */
98515 /* Begin the database scan. */
98577 /* End the database scan loop.
99224 ** Query the database. But instead of invoking a callback for each row,
99234 sqlite3 *db, /* The database on which the SQL executes */
99351 ** All of the triggers on pTab that are in the same database as pTab
99409 sqlite3 *db = pParse->db; /* The database connection */
99410 int iDb; /* The database to store the trigger in */
99413 int iTabDb; /* Index of the database holding pTab */
99443 ** To maintain backwards compatibility, ignore the database
99452 ** then set iDb to 1 to create the trigger in the temporary database.
99462 /* Ensure the table name matches database name and that the table exists */
99476 ** and the table is dropped by a different database connection, the
99477 ** trigger is not visible to the database connection that does the
99592 sqlite3 *db = pParse->db; /* The database */
99594 int iDb; /* Database containing the trigger */
99684 sqlite3 *db, /* Database connection */
99709 sqlite3 *db, /* The database connection */
99742 sqlite3 *db, /* The database connection */
99767 sqlite3 *db, /* Database connection */
99796 ** This function is called to drop a trigger from the database schema.
99880 /* Generate code to destroy the database record of the trigger.
99987 ** This routine adds a specific database
99988 ** forming the SrcList. This prevents a trigger in one database from
99989 ** referring to a target in another database. An exception is when the
99990 ** trigger is in TEMP in which case it can refer to any other database it
99997 int iDb; /* Index of the database to use */
100135 sqlite3 *db = pParse->db; /* Database handle */
100540 Vdbe *v; /* The virtual database engine */
100544 sqlite3 *db; /* The database structure */
100554 int iDb; /* Database containing the table being updated */
100613 /* Allocate a cursors for the main database table and for all indices.
100615 ** need to occur right after the database cursor. So go ahead and
100752 /* Begin the database scan
100768 /* End the database scan loop.
100861 ** the database after the BEFORE triggers are fired anyway (as the trigger
101057 sqlite3 *db = pParse->db; /* Database connection */
101149 ** Execute zSql on database db. Return an error code.
101167 ** Execute zSql on database db. The statement returns exactly
101168 ** one column. Execute this as SQL on the same database.
101189 ** The non-standard VACUUM command is used to clean up the database,
101194 ** gdbm_reorganize() on all the database tables. But beginning
101211 Btree *pMain; /* The database being vacuumed */
101212 Btree *pTemp; /* The temporary database we vacuum into */
101218 Db *pDb = 0; /* Database to detach at end of vacuum */
101219 int isMemDb; /* True if vacuuming a :memory: database */
101232 /* Save the current value of the database flags so that it can be
101246 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
101248 ** occurs anyway. The integrity of the database is maintained by a
101249 ** (possibly synchronous) transaction opened on the main database before
101274 /* The call to execSql() to attach the temp database has left the file
101282 /* A VACUUM cannot change the pagesize of an encrypted database. */
101296 /* Begin a transaction and take an exclusive lock on the main database
101298 ** to ensure that we do not try to change the page-size on a WAL database.
101305 /* Do not attempt to change the page size for a WAL database */
101324 /* Query the schema of the main database. Create a mirror schema
101325 ** in the temporary database.
101342 /* Loop through the tables in the main database. For each, do
101344 ** the contents to the temporary database.
101370 /* Copy the triggers, views, and virtual tables from the main database
101371 ** over to the temporary database. None of these objects has any
101385 ** vacuum database and the main database. Assuming no error occurs,
101386 ** both transactions are closed by this block - the main database
101398 ** connections to the same database will know to reread the schema.
101440 ** database. No locks are held on any other files (since the main file
101443 ** vacuum database. The vacuum_db journal file is deleted when the pager
101498 sqlite3 *db, /* Database in which module is registered */
101540 sqlite3 *db, /* Database in which module is registered */
101552 sqlite3 *db, /* Database in which module is registered */
101610 ** database connections to be disconnected at the next opportunity.
101619 /* Assert that the mutex (if any) associated with the BtShared database
101623 ** database connection that may have an entry in the p->pVTable list.
101656 ** associated with the database handle itself must be held.
101660 ** associated with the database the virtual table is stored in is held
101661 ** or, if the virtual table is stored in a non-sharable database, then
101662 ** the database handle mutex is held.
101692 ** The reference count of the VTable structure associated with database
101696 ** database connection.
101742 Token *pName1, /* Name of new table, or database name */
101747 int iDb; /* The database the table is being created in */
101749 sqlite3 *db; /* Database connection */
101800 sqlite3 *db = pParse->db; /* The database connection */
102078 ** of the virtual table named zTab in database iDb.
102183 ** of the virtual table named zTab in database iDb. This occurs
102395 sqlite3 *db, /* Database connection for reporting malloc problems */
103209 sqlite3 *db = pParse->db; /* Database connection */
103392 ** to "bitmap indices" in other database engines.
103405 sqlite3 *db = pParse->db; /* Database connection */
103668 sqlite3 *db = pParse->db; /* Database connection */
104054 ** is redundant. A DISTINCT list is redundant if the database contains a
104992 Parse *pParse, /* Database connection */
106262 sqlite3 *db = pParse->db; /* Database handle */
107159 Vdbe *v = pParse->pVdbe; /* The virtual database engine */
107167 sqlite3 *db; /* Database connection */
107301 ** pWInfo->a[].iTabCur The VDBE cursor for the database table
107532 int iDb; /* Index of database containing table/index */
108605 26, /* DATABASE => ID */
108720 "DATABASE", "DESC", "DETACH", "EACH",
109083 /* 303 */ "database_kw_opt ::= DATABASE",
110994 /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);
111484 testcase( i==16 ); /* DATABASE */
111929 sqlite3 *db = pParse->db; /* The database connection */
112688 ** there are outstanding database connections or memory allocations or
112725 ** database connections or memory allocations. This routine is not
112751 /* Disable mutexing of database connections */
112903 ** Set up the lookaside buffers for a database connection.
112967 ** Return the mutex associated with a database connection.
112974 ** Free up as much memory as we can from the given database
112994 ** Configuration settings for an individual database connection
113120 ** Return the number of changes since the database handle was opened.
113128 ** database handle object, it does not close any savepoints that may be open
113160 ** Close an existing SQLite database
113269 /* The temp-database schema is allocated differently from the other schema
113272 ** the same sqliteMalloc() as the one that allocates the database
113288 ** Rollback all database files. If tripCode is not SQLITE_OK, then
113332 /* SQLITE_ERROR */ "SQL logic error or missing database",
113336 /* SQLITE_BUSY */ "database is locked",
113337 /* SQLITE_LOCKED */ "database table is locked",
113339 /* SQLITE_READONLY */ "attempt to write a readonly database",
113342 /* SQLITE_CORRUPT */ "database disk image is malformed",
113344 /* SQLITE_FULL */ "database or disk is full",
113345 /* SQLITE_CANTOPEN */ "unable to open database file",
113348 /* SQLITE_SCHEMA */ "database schema has changed",
113355 /* SQLITE_FORMAT */ "auxiliary database format error",
113357 /* SQLITE_NOTADB */ "file is encrypted or is not a database",
113383 void *ptr, /* Database connection */
113441 ** This routine sets the busy callback for an Sqlite database to the
113459 ** This routine sets the progress callback for an Sqlite database to the
113757 sqlite3 *db, /* Attach the hook to this database */
113772 ** inserted or deleted using this database connection.
113775 sqlite3 *db, /* Attach the hook to this database */
113790 ** back by this database connection.
113793 sqlite3 *db, /* Attach the hook to this database */
113816 const char *zDb, /* Database */
113830 ** a database after committing a transaction if there are nFrame or
113855 ** into the write-ahead-log by this database connection.
113876 ** Checkpoint database zDb.
113879 sqlite3 *db, /* Database handle */
113880 const char *zDb, /* Name of attached database (or NULL) */
113908 sqlite3Error(db, SQLITE_ERROR, "unknown database: %s", zDb);
113921 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
113931 ** Run a checkpoint on database iDb. This is a no-op if database iDb is
113934 ** If a transaction is open on the database being checkpointed, this
113939 ** The mutex on database handle db should be held by the caller. The mutex
113982 ** SQLITE_TEMP_STORE db->temp_store Location of temporary database
114072 ** sqlite3ApiExit(), to avoid setting the database handle error message.
114105 ** Create a new collating function for database "db". The name is zName
114284 ** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database
114291 ** the default flags to open the database handle with. The value stored in
114296 ** the VFS that should be used to open the database file. *pzFile is set to
114513 ** This routine does the work of opening a database on behalf of
114514 ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
114518 const char *zFilename, /* Database filename UTF-8 encoded */
114519 sqlite3 **ppDb, /* OUT: Returned database handle */
114659 /* Open the backend database driver */
114673 /* The default safety_level for the main database is 'full'; for the temp
114674 ** database it is 'NONE'. This matches the pager layer defaults.
114687 ** database schema yet. This is delayed until the first time the database
114774 ** Open a new database handle.
114784 const char *filename, /* Database filename (UTF-8) */
114794 ** Open a new database handle.
114831 ** Register a new collation sequence with the database handle db.
114850 ** Register a new collation sequence with the database handle db.
114871 ** Register a new collation sequence with the database handle db.
114896 ** Register a collation sequence factory callback with the database handle
114914 ** Register a collation sequence factory callback with the database handle
114942 ** Test to see whether or not the database connection is in autocommit
114967 "database corruption at line %d of [%.10s]",
115000 ** Return meta information about a specific column of a database table.
115006 const char *zDbName, /* Database name or NULL */
115027 /* Ensure the database schema has been loaded */
115139 ** Invoke the xFileControl method on a particular database.
115246 ** an incompatible database file format. Changing the PENDING byte
115247 ** while any database connection is open results in undefined and
115315 ** Set the nReserve size to N for the main database on the database
115412 ** to see if a database file was a URI that contained a specific query
115474 ** Return the filename of the database associated with a database
115483 ** Return 1 if database is read-only or 0 if read/write. Return -1 if
115484 ** no such database exists.
115677 sqlite3Error(db, rc, (rc?"database is deadlocked":0));
115699 ** the transaction opened by database db has just finished. Locks held
115700 ** by database connection db have been released.
115812 ** This is called when the database connection passed as an argument is
116583 sqlite3 *db; /* The database connection */
116584 const char *zDb; /* logical database name */
116604 int nPgsz; /* Page size for host database */
116664 int nRowAvg; /* Average size of database rows, in pages */
117121 sqlite3 *db, /* Database in which to run SQL */
117145 const char *zDb = p->zDb; /* Name of database (e.g. "main", "temp") */
117146 sqlite3 *db = p->db; /* Database handle */
117220 sqlite3 *db = p->db; /* The database connection */
117278 ** Store the current database page-size in bytes in p->nPgsz.
117584 ** config=xxx option (i.e. "xxx"). This function queries the database for
117604 sqlite3 *db, /* Database handle */
117670 ** argv[1] -> database name
117676 sqlite3 *db, /* The SQLite database connection */
117692 int nDb; /* Bytes required to hold database name */
117960 ** database. TODO: For xConnect(), it could verify that said tables exist.
117966 /* Figure out the page-size for the database. This is required in order to
117967 ** estimate the cost of loading large doclists from the database. */
118000 sqlite3 *db, /* Database connection */
118010 sqlite3 *db, /* Database connection */
119433 ** prefix) from the database.
119737 ** hash-table to the database.
119761 ** the pending-terms hash-table have already been flushed into the database
119777 ** hash-table. Any changes made to the database are reverted by SQLite.
119900 ** function merges all segments in the database to a single segment.
120002 sqlite3 *db = p->db; /* Database connection */
120115 ** FTS3 enabled database connection is closed). It frees the memory
120766 ** this database, then the average docsize is 1. Otherwise, it is 1 plus
121074 ** point to the next matching row in the database. Expressions iterate through
121866 sqlite3 *db, /* Database connection */
121873 char const *zDb; /* Name of database (e.g. "main") */
122249 ** Register the fts3aux module with database connection db. Return SQLITE_OK
123290 ** with database connection db.
124758 ** Set up SQL objects in database db used to access the contents of
124768 ** comment above struct HashTableVtab) to the database schema. Both
124894 ** track such information in the database, then we'd only want this
125208 ** database. The internal details of this type are only accessed by the
125238 ** When a b+tree is written to the database (either as a result of a merge
125240 ** database file as soon as they are completely populated. The interior of
126131 ** on the database file for longer than necessary). Thus, any virtual table
126572 ** the contents of the pending-terms hash table to the database.
126927 ** the database contain two terms that share a prefix of almost 2KB,
127022 ** database. Then call this function recursively to write the parent of
127023 ** pTree and its peers to the database.
127025 ** Except, if pTree is a root node, do not write it to the database. Instead,
127029 ** set to the largest blockid written to the database (or zero if no
127157 /* The current leaf node is full. Write it out to the database. */
127165 ** to the database (still available in pWriter->zTerm), and
127236 ** database. This function must be called after all terms have been added
127248 sqlite3_int64 iLast = 0; /* Largest block id written to database */
127314 ** Set *pnMax to the largest segment level in the database for the index
127862 ** Merge all level iLevel segments in the database into a single
127865 ** currently present in the database.
127868 ** segment in the database, SQLITE_DONE is returned immediately.
127897 /* This call is to merge all segments in the database to a single
127899 ** greatest segment level currently present in the database for this
128116 ** Merge the entire database so that there is one segment for each
128502 ** should be deleted from the database before inserting the new row. Or,
128505 ** modify the database file.
128588 ** merge all segments in the database (including the new segment, if
128700 sqlite3_int64 nDoc; /* Number of docs in database */
130132 ** Database Format of R-Tree Tables
130258 sqlite3 *db; /* Host database connection */
130263 char *zDb; /* Name of database containing r-tree table */
130557 ** node contents out to the database.
130721 ** If the node is dirty, write it out to the database.
130747 ** count drops to zero, the node data is written to the database.
133070 ** using database connection db. If successful, the integer value returned
133099 ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size.
133100 ** This ensures that each node is stored on a single database page. If the
133101 ** database page-size is so large that more than RTREE_MAXCELLS entries
133105 sqlite3 *db, /* Database handle */
133138 ** argv[1] -> database name
133143 sqlite3 *db, /* Database connection */
133192 /* Create/Connect to the underlying relational database schema. If
133299 ** Register the r-tree module with database handle db. This creates the
133802 ** types to an SQLite database connection. It is intended to be called
133848 ** Register the ICU extension functions with database db.