Lines Matching full:database
124 ** The hard upper limit here is 32676. Most database people will
125 ** tell you that in a well-normalized database, you usually should
187 ** The maximum number of in-memory pages to use for the main database
199 ** checkpointing the database in WAL mode.
228 ** compiled with a different limit. If a process operating on a database
231 ** the aborted transaction. This could lead to database corruption.
240 ** The default size of a database page.
267 ** Maximum number of pages in one database file.
366 ** database connection at the same time.
762 ** CAPI3REF: Database Connection Handle
763 ** KEYWORDS: {database connection} {database connections}
765 ** Each open SQLite database is represented by a pointer to an instance of
814 ** CAPI3REF: Closing A Database Connection
823 ** sqlite3_close() is called on a [database connection] that still has
856 ** in the context of the [database connection] passed in as its 1st
893 ** SQL comments, then no SQL statements are evaluated and the database
900 ** is a valid and open [database connection].
901 ** <li> The application must not close [database connection] specified by
908 sqlite3*, /* An open database */
929 #define SQLITE_ERROR 1 /* SQL error or missing database */
933 #define SQLITE_BUSY 5 /* The database file is locked */
934 #define SQLITE_LOCKED 6 /* A table in the database is locked */
936 #define SQLITE_READONLY 8 /* Attempt to write a readonly database */
939 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
941 #define SQLITE_FULL 13 /* Insertion failed because database is full */
942 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
943 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
944 #define SQLITE_EMPTY 16 /* Database is empty */
945 #define SQLITE_SCHEMA 17 /* The database schema changed */
952 #define SQLITE_FORMAT 24 /* Auxiliary database format error */
954 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
974 ** on a per database connection basis using the
1158 ** The xCheckReservedLock() method checks whether any database connection,
1213 ** database corruption.
1255 ** layer a hint of how large the database file will grow to be during the
1257 ** is often close. The underlying VFS might choose to preallocate database
1258 ** file space based on this hint in order to help writes to the database
1262 ** extends and truncates the database file in chunks of a size specified
1265 ** for the nominated database. Allocating database file space in large
1366 ** SQLITE_IOERR. Or the implementation might recognize that a database
1551 ** single thread. All open [database connections] must be closed and all
1639 ** CAPI3REF: Configure database connections
1642 ** changes to a [database connection]. The interface is similar to
1644 ** [database connection] (specified in the first argument). The
1646 ** the database connection is created using [sqlite3_open()],
1651 ** aspect of the [database connection] is being configured.
1770 ** mutexing on [database connection] and [prepared statement] objects.
1772 ** [database connections] and [prepared statements]. But other mutexes
1775 ** [database connection] at the same time. ^If SQLite is compiled with
1785 ** mutexes on [database connection] and [prepared statement] objects.
1788 ** to [database connections] and [prepared statements] so that the
1789 ** application is free to use the same [database connection] or the
1841 ** times the database page size. ^If SQLite needs needs additional
1847 ** the database page cache with the default page cache implemenation.
1852 ** The sz argument should be the size of the largest database page
1909 ** [database connection]. The first argument is the
1911 ** slots allocated to each database connection.)^ ^(This option sets the
1965 ** CAPI3REF: Database Connection Configuration Options
1980 ** [lookaside memory allocator] configuration for the [database connection].
1992 ** configuration for a database connection can only be changed when that
2025 ** successful [INSERT] into the database from the [database connection]
2027 ** have ever occurred on that database connection, zero is returned.
2051 ** database connection while the [sqlite3_last_insert_rowid()]
2062 ** ^This function returns the number of database rows that were changed
2064 ** on the [database connection] specified by the first parameter.
2107 ** If a separate thread makes changes on the same database connection
2117 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
2133 ** If a separate thread makes changes on the same database connection
2142 ** ^This function causes any pending database operation to abort and
2149 ** thread that is currently running the database operation. But it
2150 ** is not safe to call this routine with a [database connection] that
2163 ** SQL statements on [database connection] D complete. ^Any new SQL statements
2173 ** If the database connection closes while [sqlite3_interrupt()]
2218 ** an attempt is made to open a database table that another thread
2230 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
2232 ** is made to open the database for reading and the cycle repeats.
2254 ** already hold a RESERVED lock on the database file, but it needs
2256 ** pages into the database file without harm to concurrent
2267 ** [database connection]. Setting a new busy handler clears any
2272 ** database connection that invoked the busy handler. Any such actions
2275 ** A busy handler must not close the database connection
2294 ** [database connection] any any given moment. If another busy handler
2373 sqlite3 *db, /* An open database */
2602 ** [database connection], supplied in the first argument.
2644 ** try to execute malicious statements that damage the database. For
2646 ** SQL queries for evaluation by a database. But the application does
2648 ** database. An authorizer could then be put in place while the
2654 ** and limiting database size using the [max_page_count] [PRAGMA]
2657 ** ^(Only a single authorizer can be in place on a database connection
2663 ** the database connection that invoked the authorizer callback.
2665 ** database connections for the meaning of "modify" in this paragraph.
2709 ** authorizer callback is the name of the database ("main", "temp",
2740 #define SQLITE_DETACH 25 /* Database Name NULL */
2741 #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
2785 ** database connection D. An example use for this
2794 ** [database connection]; setting a new progress handler cancels the
2804 ** the database connection that invoked the progress handler.
2806 ** database connections for the meaning of "modify" in this paragraph.
2812 ** CAPI3REF: Opening A New Database Connection
2814 ** ^These routines open an SQLite database file whose name is given by the
2817 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
2821 ** object.)^ ^(If the database is opened (and/or created) successfully, then
2827 ** ^The default encoding for the database will be UTF-8 if
2832 ** associated with the [database connection] handle should be released by
2837 ** over the new database connection. ^(The flags parameter to
2845 ** <dd>The database is opened in read-only mode. If the database does not
2849 ** <dd>The database is opened for reading and writing if possible, or reading
2851 ** case the database must already exist, otherwise an error is returned.</dd>)^
2854 ** <dd>The database is opened for reading and writing, and is creates it if
2865 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2868 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
2871 ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2874 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
2877 ** ^If the filename is ":memory:", then a private, temporary in-memory database
2878 ** is created for the connection. ^This in-memory database will vanish when
2879 ** the database connection is closed. Future versions of SQLite might
2881 ** It is recommended that when a database filename actually does begin with
2886 ** on-disk database will be created. ^This private database will be
2887 ** automatically deleted as soon as the database connection is closed.
2891 ** the new database connection should use. ^If the fourth parameter is
2901 const char *filename, /* Database filename (UTF-8) */
2905 const void *filename, /* Database filename (UTF-16) */
2909 const char *filename, /* Database filename (UTF-8) */
2920 ** associated with a [database connection]. If a prior API call failed
2939 ** this, each thread can obtain exclusive use of the [database connection] D
2984 ** [database connection] whose limit is to be set or queried. The
3004 ** both their own internal database and also databases that are controlled
3012 ** interface to further control untrusted SQL. The size of the database
3089 ** The first argument, "db", is a [database connection] obtained from a
3091 ** [sqlite3_open16()]. The database connection must not have been closed.
3134 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
3163 sqlite3 *db, /* Database handle */
3170 sqlite3 *db, /* Database handle */
3177 sqlite3 *db, /* Database handle */
3184 sqlite3 *db, /* Database handle */
3201 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3219 ** that can be stored in a database table. SQLite uses dynamic typing
3472 ** ^These routines provide a means to determine the database, table, and
3475 ** ^The name of the database or table or column can be returned as
3477 ** the database name, the _table_ routines return the table name, and
3484 ** database, table, and column.
3494 ** occurs. ^Otherwise, they return the name of the attached database, table,
3530 ** ^(For example, given the database schema:
3571 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3572 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3601 ** be the case that the same database connection is being used by two or
3912 ** ^The first parameter is the [database connection] to which the SQL
3913 ** function is to be added. ^If an application uses more than one database
3915 ** to each database connection separately.
3959 ** overloaded or when the database connection closes.)^
3973 ** matches the database encoding is a better
3983 ** close the database connection nor finalize or reset the prepared
4164 ** CAPI3REF: Database Connection For Functions
4167 ** the pointer to the [database connection] (the 1st parameter)
4364 ** with the [database connection] specified as the first argument.
4426 ** [database connection] is closed using [sqlite3_close()].
4465 ** ^To avoid having to register all collation sequences before a database
4467 ** [database connection] to be invoked whenever an undefined collation
4478 ** sqlite3_collation_needed16(). The second argument is the database
4501 ** Specify the key for an encrypted database. This routine should be
4508 sqlite3 *db, /* Database to be rekeyed */
4513 ** Change the key on an open database. If the current database is not
4515 ** database is decrypted.
4521 sqlite3 *db, /* Database to be rekeyed */
4526 ** Specify the activation key for a SEE database. Unless
4536 ** Specify the activation key for a CEROD database. Unless
4575 ** if a [database connection] is being used at the same time in a separate
4599 ** zero if the given database connection is or is not in autocommit mode,
4611 ** If another thread changes the autocommit status of the database
4618 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
4620 ** ^The sqlite3_db_handle interface returns the [database connection] handle
4621 ** to which a [prepared statement] belongs. ^The [database connection]
4622 ** returned by sqlite3_db_handle is the same [database connection]
4633 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
4635 ** associated with the database connection pDb. ^If no prepared statement
4638 ** The [database connection] pointer D in a call to
4639 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4650 ** for the same database connection is overridden.
4654 ** for the same database connection is overridden.
4661 ** on the same [database connection] D, or NULL for
4665 ** the database connection that invoked the callback. Any actions
4666 ** to modify the database connection must be deferred until after the
4670 ** database connections for the meaning of "modify" in this paragraph.
4684 ** automatically rolled back because the database connection is closed.
4695 ** with the [database connection] identified by the first argument
4698 ** for the same database connection is overridden.
4708 ** database and table name containing the affected row.
4723 ** the database connection that invoked the update hook. Any actions
4724 ** to modify the database connection must be deferred until after the
4727 ** database connections for the meaning of "modify" in this paragraph.
4731 ** on the same [database connection] D, or NULL for
4747 ** ^(This routine enables or disables the sharing of the database cache
4748 ** and schema data structures between [database connection | connections]
4749 ** to the same database. Sharing is enabled if the argument is true
4758 ** Existing database connections continue use the sharing mode
4777 ** held by the database library. Memory used to cache database
4853 ** database table accessible using the [database connection] handle
4857 ** this function. ^The second parameter is either the name of the database
4858 ** (i.e. "main", "temp", or an attached database) containing the specified
4860 ** for the table using the same algorithm used by the database engine to
4903 ** ^(This function may load one or more schemas from database files. If an
4906 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
4913 const char *zDbName, /* Database name or NULL */
4949 sqlite3 *db, /* Load the extension into this database connection */
4974 ** each new [database connection] that is created. The idea here is that
4976 ** that is to be automatically loaded into all new database connections.
5001 ** will be called more than once for each database connection that is opened.
5044 ** module or until the [database connection] closes. The content
5046 ** any database connection.
5180 ** ^The module name is registered on the [database connection] specified
5314 ** in row iRow, column zColumn, table zTable in database zDb;
5327 ** ^Note that the database name is not the filename that contains
5328 ** the database but rather the symbolic name of the database that
5329 ** appears after the AS keyword when the database is connected using [ATTACH].
5330 ** ^For the main database file, the database name is "main".
5331 ** ^For TEMP tables, the database name is "temp".
5336 ** ^This function sets the [database connection] error code and message
5380 ** to a different row of the same database table. ^The new row is identified
5382 ** changed. ^The database, table and column on which the blob handle is open
5396 ** ^This function sets the database handle error code and message.
5407 ** database connection is in [autocommit mode].
5791 ** CAPI3REF: Retrieve the mutex for a database connection
5794 ** serializes access to the [database connection] given in the argument
5802 ** CAPI3REF: Low-Level Control Of Database Files
5806 ** with a particular database identified by the second argument. ^The
5807 ** name of the database is "main" for the main database or "temp" for the
5808 ** TEMP database, or the name that appears after the AS keyword for
5811 ** main database file.
5824 ** open database file, then SQLITE_ERROR is returned. ^This error
6005 ** CAPI3REF: Database Connection Status
6008 ** about a single [database connection]. ^The first argument is the
6009 ** database connection object to be interrogated. ^The second argument
6029 ** CAPI3REF: Status Parameters for database connections
6047 ** memory used by all pager caches associated with the database connection.)^
6055 ** schema memory is shared with other database connections due to
6062 ** the database connection.)^
6157 ** determine exactly which parts of a database file are cached and for
6194 ** SQLite will typically create one cache instance for each open database file,
6198 ** will the page size of the database file that is to be cached plus an
6201 ** database page on disk. The value of R depends
6205 ** be used to cache database pages of a file stored on disk, or
6206 ** false if it is used for an in-memory database. The cache implementation
6313 ** The backup API copies the content of one database into another.
6319 ** ^Exclusive access is required to the destination database for the
6320 ** duration of the operation. ^However the source database is only
6323 ** performed on a live source database without preventing other users from
6324 ** reading or writing to the source database while the backup is underway.
6341 ** [database connection] associated with the destination database
6342 ** and the database name, respectively.
6343 ** ^The database name is "main" for the main database, "temp" for the
6344 ** temporary database, or the name specified after the AS keyword in
6345 ** an [ATTACH] statement for an attached database.
6347 ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
6348 ** and database name of the source database, respectively.
6349 ** ^The source and destination [database connections] (parameters S and D)
6355 ** destination [database connection] D.
6382 ** <li> the destination database was opened read-only, or
6383 ** <li> the destination database is using write-ahead-log journaling
6385 ** <li> The destination database is an in-memory database and the
6395 ** [database connection]
6396 ** is being used to write to the source database when sqlite3_backup_step()
6410 ** sqlite3_backup_step() obtains a [shared lock] on the source database that
6412 ** ^Because the source database is not locked between calls to
6413 ** sqlite3_backup_step(), the source database may be modified mid-way
6414 ** through the backup process. ^If the source database is modified by an
6415 ** external process or via a database connection other than the one being
6418 ** database is modified by the using the same database connection as is used
6419 ** by the backup operation, then the backup database is automatically
6430 ** active write-transaction on the destination database is rolled back.
6449 ** up and the total number of pages in the source database file.
6454 ** sqlite3_backup_step(). ^If the source database is modified during a backup
6456 ** pages that need to be updated or the size of the source database file
6459 ** <b>Concurrent Usage of Database Handles</b>
6461 ** ^The source [database connection] may be used by the application for other
6463 ** ^If SQLite is compiled and configured to support threadsafe database
6464 ** connections, then the source database connection may be used concurrently
6468 ** [database connection] is not passed to any other API (by any thread) after
6471 ** if the application incorrectly accesses the destination [database connection]
6473 ** nevertheless. Use of the destination database connection while a
6477 ** guarantee that the shared cache used by the destination database
6491 sqlite3 *pDest, /* Destination database handle */
6492 const char *zDestName, /* Destination database name */
6493 sqlite3 *pSource, /* Source database handle */
6494 const char *zSourceName /* Source database name */
6504 ** ^When running in shared-cache mode, a database operation may fail with
6515 ** ^Shared-cache locks are released when a database connection concludes
6520 ** identity of the database connection (the blocking connection) that
6572 ** related to the set of unblocked database connections.
6577 ** database waits for the callback to be issued before taking any further
6659 ** will be invoked each time a database connection commits data to a
6664 ** the associated write-lock on the database released, so the implementation
6665 ** may read, write or [checkpoint] the database as required.
6669 ** registering the callback. ^The second is a copy of the database handle.
6670 ** ^The third parameter is the name of the database that was written to -
6671 ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
6683 ** A single database handle may have at most a single write-ahead log callback
6700 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
6715 ** ^Every new [database connection] defaults to having the auto-checkpoint
6723 ** CAPI3REF: Checkpoint a database
6725 ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
6726 ** on [database connection] D to be [checkpointed]. ^If X is NULL or an
6728 ** connection D. ^If the database connection D is not in
7276 ** callback for the database handle. Each pager opened via the sqlite
7288 ** Name of the master database table. The master database table
7296 ** The root-page of the master database table.
7440 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
7471 const char *zFilename, /* Name of database file to open */
7472 sqlite3 *db, /* Associated database connection */
7547 ** SQLite database header may be found using the following formula:
7552 ** the database file header. The incr-vacuum-flag field is located at
7685 ** Header file for the Virtual DataBase Engine (VDBE)
7687 ** This header defines the interface to the virtual database engine
7689 ** simple program to access and modify the underlying database.
8139 ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
8155 #define PAGER_MEMORY 0x0004 /* In-memory database */
8252 /* Functions used to truncate the database file. */
8329 ** writing this page to the database */
8802 ** Each database file to be accessed by the system is an instance
8804 ** in the sqlite.aDb[] array. aDb[0] is the main database file and
8805 ** aDb[1] is the database file used to hold temporary tables. Additional
8809 char *zName; /* Name of this database */
8810 Btree *pBt; /* The B*Tree structure for this database file */
8813 Schema *pSchema; /* Pointer to database schema (possibly shared) */
8817 ** An instance of the following structure stores a database schema.
8820 int schema_cookie; /* Database schema version number for this file */
8827 u8 enc; /* Text encoding used by this database */
8844 ** The DB_SchemaLoaded flag is set after the database schema has been
8864 ** associated with a particular database connection. The use of
8875 ** with a particular database connection. Hence, schema information cannot
8877 ** is shared by multiple database connections. Therefore, while parsing
8906 ** Each database connection is an instance of the following structure.
8946 int nTable; /* Number of tables in the database */
9039 ** A macro to discover the encoding of a database.
9092 #define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
9093 #define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
9095 #define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
9319 ** the database schema.
9321 ** If the database schema is shared, then there is one instance of this
9322 ** structure for each database connection (sqlite3*) that uses the shared
9323 ** schema. This is because each database connection requires its own unique
9326 ** database connections, even when the rest of the in-memory database
9327 ** schema is shared, as the implementation often stores the database
9329 ** during initialization internally. This database connection handle may
9331 ** within the database. So that they appear as part of the callers
9332 ** transaction, these accesses need to be made via the same database
9336 ** database schema are initially stored in a linked-list pointed to by
9340 ** database connection doing the preparing so as to use the correct
9360 sqlite3 *db; /* Database connection associated with this table */
9387 ** database file. If Table.iDb is the index of the database table backend
9388 ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that
9499 ** is returned. REPLACE means that preexisting database rows that caused
9534 sqlite3 *db; /* The database connection */
9605 int tnum; /* Page containing root of this index in database file */
9752 ** Expr objects can use a lot of memory space in database schema. To
9947 ** With the addition of multiple database support, the following structure
9951 ** now be identified by a database name, a dot, then the table name: ID.ID.
9965 char *zDatabase; /* Name of database holding this table */
10234 int iDb; /* Index in sqlite3.aDb[] of database holding pTab */
10288 sqlite3 *db; /* The main database structure */
10291 Vdbe *pVdbe; /* An engine for executing database bytecode */
10404 * Each trigger present in the database schema is stored as an instance of
10409 * database). This allows Trigger structures to be retrieved by name.
10495 ** routines as they walk the parse tree to make database references
10501 const char *zDb; /* Make sure all objects are contained in this database */
10511 sqlite3 *db; /* Optional database for lookaside. Can be NULL */
10527 sqlite3 *db; /* The database being initialized */
10528 int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
11516 ** database connections. After initialization, this table is
11532 ** 1-gibabyte boundary) in a compatible database. SQLite never uses
11533 ** the database page that contains the pending byte. It never attempts
11544 ** 0x40000000 results in an incompatible database file format!
12004 ** A cursor is a pointer into a single BTree within a database file.
12020 int iDb; /* Index of cursor database in db->aDb[] (or -1) */
12127 sqlite3 *db; /* The associated database connection */
12149 ** database (see below for exceptions). If the MEM_Term flag is also
12265 sqlite3 *db; /* The database connection that owns this statement */
12295 u8 minWriteFileFormat; /* Minimum file format for writable database files */
12498 ** Query status information for a single database connection
12501 sqlite3 *db, /* The database connection whose status is desired */
12521 ** by all pagers associated with the given database connection. The
13817 sqlite3_file *id, /* Database file handle */
17482 ** cache database pages that are not currently in use.
17942 ** Free memory that might be associated with a particular database
18057 ** failure on the same database connection) then always return 0.
18058 ** Hence for a particular database connection, once malloc starts
18143 ** and set the mallocFailed flag in the database connection.
19269 ** Random numbers are used by some of the database backends in order
20105 ** stored by this function into the database handle using sqlite3Error().
20879 /* We can only reach this point when reading a corrupt database
20973 "API call with %s database connection pointer",
22209 ** a database and its journal file) that the sector size will be the
22858 ** where the database is located.
23018 ** transaction counter in bytes 24-27 of database files are updated
23019 ** whenever any part of the database changes. An assertion fault will
23025 unsigned char dbUpdate; /* True if any part of database file changed */
23641 ** on its own. Whenever a new database is opened, we have to find the
23642 ** specific inode of the database file (the inode is determined by the
23699 ** per database file in the same process and (2) database connections
23920 ** in the header of every SQLite database. In this way, if there
23922 ** the first page of the database, no damage is done.
24046 ** accessing the same database file, in case that is ever required.
24072 ** database.
24322 ** reading the database file again, make sure that the
24323 ** transaction counter was updated if any part of the database
24327 ** cache. The use of a stale cache can lead to database corruption.
24550 ** simplest: locking is ignored. No attempt is made to lock the database
24556 ** prevent simultaneous access of the same database by two or more
24557 ** database connections. But there is a serious risk of database
24559 ** database connections are accessing the same database file at the same
24591 ** files in order to control access to the database. This works on just
24595 ** connections from reading or writing the database.
24604 ** database and with the same name but with a ".lock" extension added.
24751 /* To fully unlock the database, delete the lock file */
24794 ** only a single process can be reading the database at a time.
25009 ** the database file at a time. This reduces potential concurrency, but
25545 ** reading the database file again, make sure that the
25546 ** transaction counter was updated if any part of the database
25550 ** cache. The use of a stale cache can lead to database corruption.
25745 /* If this is a database file (not a journal, master-journal or temp
25822 /* If this is a database file (not a journal, master-journal or temp
25832 /* If we are doing a normal write to a database file (as opposed to
25834 ** normal database file) then record the fact that the database
25839 pFile->dbUpdate = 1; /* The database has been modified */
25914 ** or power failure will likely corrupt the database file.
26010 ** will not roll back - possibly leading to database corruption.
26092 /* If we are doing a normal write to a database file (as opposed to
26094 ** normal database file) and we truncate the file to zero length,
26096 ** when restoring a database using the backup API from a zero-length
26123 /* When opening a zero-size database, the findInodeInfo() procedure
26216 ** a rollback and that the database is therefore unchanged and
26242 ** a database and its journal file) that the sector size will be the
26434 ** Open a shared-memory area associated with open database file pDbFd.
26438 ** as the open database file and has the same name as the open database
26439 ** file with the "-shm" suffix added. For example, if the database file
26445 ** from the database file is used, then differing access permissions
26447 ** database to end up using different files for shared memory -
26449 ** in database corruption. Nevertheless, this tmpfs file usage
26454 ** same database file at the same time, database corruption will likely
26483 struct stat sStat; /* fstat() info for database file */
26485 /* Call fstat() to figure out the permissions on the database file. If
26576 ** shared-memory associated with the database file fd. Shared-memory regions
26594 sqlite3_file *fd, /* Handle open on database file */
26687 sqlite3_file *fd, /* Database file holding the shared memory */
26797 sqlite3_file *fd /* Database file holding the shared memory */
26812 sqlite3_file *fd, /* The underlying database file */
26818 unixFile *pDbFd; /* The underlying database file */
26871 ** sqlite3_io_methods object for a particular database file. The pAppData
27038 ** for the database file "filePath". It then returns the sqlite3_io_methods
27044 const char *filePath, /* name of the database file */
27045 unixFile *pNew /* open file object for the database file */
27104 ** for the database file "filePath". It then returns the sqlite3_io_methods
27110 const char *filePath, /* name of the database file */
27443 ** Search for an unused file descriptor that was opened on the database
27448 ** Such a file descriptor may exist if a database connection was closed
27509 ** is a database or master journal file, it is created with the permissions
27514 ** corresponding database file and sets *pMode to this value. Whenever
27516 ** as the associated database file.
27525 char zDb[MAX_PATHNAME+1]; /* Database file path */
27527 struct stat sStat; /* Output of stat() on database file */
27530 ** the path to the associated database file from zPath. This block handles
27732 ** to be open on a database file. If it were open on a database file,
27777 ** with fd is a database file, and there are other connections open
28164 ** database file to coordinate safe, concurrent access by multiple readers
28185 ** address the requirements for concurrent database access by multiple
28190 ** changes the way database access is controlled by limiting access to a
28191 ** single host at a time and moving file locks off of the database file
28207 ** PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:
28208 ** PRAGMA [database.]lock_proxy_file
28215 ** database file. For example:
28217 ** For database path "/Users/me/foo.db"
28220 ** Once a lock proxy is configured for a database connection, it can not
28231 ** * conch file to limit access to the database file to a single host
28235 ** taken on the database
28241 ** stored in the same directory as the database file and the file name
28242 ** is patterned after the database file name as ".<databasename>-conch".
28251 ** normally taken on the database file. This allows for safe sharing
28252 ** of the database file for multiple readers and writers on the same
28256 ** only taken when the first request to lock database file is made.
28258 ** opening a connection to a database file does not take a lock on it.
28260 ** the connection to the database is closed.
28270 ** Database files accessed on non-local file systems are
28293 ** force proxy locking to be used for every database file opened, and 0
28294 ** will force automatic proxy locking to be disabled for all database
28321 ** The proxy lock file path for the database at dbPath is written into lPath,
28801 ** valid conch file), try to match the permissions of the database
28810 /* try to match the database file R/W permissions, ignore failure */
28923 ** Given the name of a database file, compute the name of its conch file.
28935 int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
28939 ** the name of the original database file. */
29038 char dbPath[MAXPATHLEN+1]; /* Name of the database file */
29355 ** database file and tries to choose an locking method appropriate for
30833 ** a database and its journal file) that the sector size will be the
31064 ** Open the shared-memory area associated with database file pDbFd.
31183 sqlite3_file *fd, /* Database holding shared memory */
31186 winFile *pDbFd; /* Database holding shared-memory */
31224 sqlite3_file *fd, /* Database file holding the shared memory */
31333 sqlite3_file *fd /* Database holding the shared memory */
31343 ** shared-memory associated with the database file fd. Shared-memory regions
31361 sqlite3_file *fd, /* Handle open on database file */
32435 ** A bitmap is used to record which pages of a database file have been
32440 ** or all of the pages in a database can get journalled. In those cases,
32453 ** Bitvec object is the number of pages in the database file at the
32455 ** but can be as large as 2 billion for a really big database.
32955 ** being used for an in-memory database, this function is a no-op.
33312 ** Since there cannot be more than 2^31 distinct pages in a database,
33445 ** open database file (including each in-memory database and each
33446 ** temporary or transient database) has a single page cache which
33964 ** database) there is really no difference between createFlag 1 and 2. So
34375 sqlite3 *db; /* The database connection */
34435 ** The mallocFailed flag of the database connection is set if a
34710 ** The pager is used to access a database disk file. It implements
34712 ** is separate from the database file. The pager also implements file
34713 ** locking to prevent two processes from writing the same database
34714 ** file simultaneously, or one process from reading the database while
34771 ** snapshot is like a read-transaction. It is the state of the database
34783 /* If the WAL is not empty, return the size of the database. */
34804 /* Copy pages from the log to the database file */
34820 ** by the pager layer on the database file.
34848 ** Definition: A page of the database file is said to be "overwriteable" if
34858 ** the database file at the start of the transaction.
34860 ** (1) A page of the database file is never overwritten unless one of the
34870 ** both the content in the database when the rollback journal was written
34871 database at the beginning of the current
34874 ** (3) Writes to the database file are an integer multiple of the page size
34877 ** (4) Reads from the database file are either aligned on a page boundary and
34879 ** first 100 bytes of the database file.
34881 ** (5) All writes to the database file are synced prior to the rollback journal
34884 ** (6) If a master journal file is used, then all writes to the database file
34887 ** Definition: Two databases (or the same database at two points it time)
34891 ** of the database.
34895 ** journal is rolled back, the resulting database file will be logical
34896 ** equivalent to the database file at the beginning of the transaction.
34899 ** is called to restore the database file to the same size it was at
34904 ** (9) Whenever the database file is modified, at least one bit in the range
34907 ** database to flush their caches.
34912 ** (11) A database file is well-formed at the beginning and at the conclusion
34915 ** (12) An EXCLUSIVE lock is held on the database file when writing to
34916 ** the database file.
34918 ** (13) A SHARED lock is held on the database file while reading any
34919 ** content out of the database file.
34986 ** state - the file may or may not be locked and the database size is
34987 ** unknown. The database may not be read or written.
34990 ** * Any lock, or no lock at all, may be held on the database file.
34995 ** In this state all the requirements for reading the database in
34998 ** open. The database size is known in this state.
35001 ** it opens a read-transaction on the database and returns to state
35009 ** * A SHARED or greater lock is held on the database file.
35013 ** * If the database is a WAL database, then the WAL connection is open.
35020 ** is first opened on the database. In WRITER_LOCKED state, all locks
35022 ** modifications to the cache or database have taken place.
35025 ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when
35028 ** in WRITER_LOCKED state, all that is required is to unlock the database
35033 ** is made to obtain an EXCLUSIVE lock on the database file.
35037 ** lock is held on the database file.
35051 ** start of it. The database file on disk has not been modified.
35054 ** * A RESERVED or greater lock is held on the database file.
35062 ** when it modifies the contents of the database file. WAL connections
35063 ** never enter this state (since they do not modify the database file,
35067 ** * An EXCLUSIVE or greater lock is held on the database file.
35079 ** database file. In this state the transaction may be committed simply
35081 ** not possible to modify the database further. At this point, the upper
35085 ** * An EXCLUSIVE or greater lock is held on the database file.
35086 ** * All writing and syncing of journal and database data has finished.
35105 ** report database corruption (due to the inconsistent cache), and if
35106 ** they upgrade to writers, they may inadvertently corrupt the database
35129 ** database file in function pagerStress() in order to free up
35173 ** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
35190 ** The exception is when the database file is unlocked as the pager moves
35203 ** transaction in another process, causing SQLite to read from the database
35207 ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
35212 ** lock on the database
35278 ** For a real on-disk database, the current lock held on the database file -
35281 ** For a temporary or in-memory database (neither of which require any
35294 ** (the 4-byte header field at byte offset 24 of the database file) is
35298 ** can only happen if an exclusive lock is held on the database file.
35300 ** relinquished on the database file. Each time a transaction is committed,
35339 ** When doNotSpill is non-zero, writing to the database from pagerStress()
35345 ** If doNotSyncSpill is non-zero, writing to the database from pagerStress()
35348 ** the database page-size in order to prevent a journal sync from happening
35362 ** Variable dbSize is set to the number of pages in the database file.
35366 ** dbSize is set based on the size of the database file, which may be
35367 ** larger than the size of the database (the value stored at offset
35368 ** 28 of the database header by the btree). If the size of the file
35377 ** Similarly, if the database is truncated using PagerTruncateImage(),
35389 ** to write or truncate the database file on disk.
35394 ** that the database file is larger than the database image (Pager.dbSize),
35396 ** to measure the database file on disk, and then truncates it if required.
35432 u8 readOnly; /* True for a read-only database */
35445 u8 eLock; /* Current lock held on database file */
35451 Pgno dbSize; /* Number of pages in the database */
35453 Pgno dbFileSize; /* Number of pages in the database file */
35459 Bitvec *pInJournal; /* One bit for each page in the database file */
35460 sqlite3_file *fd; /* File descriptor for database */
35468 char dbFileVers[16]; /* Changes whenever database file changes */
35478 Pgno mxPgno; /* Maximum allowed size of the database */
35480 char *zFilename; /* Name of the database file */
35486 int nRead, nWrite; /* Database pages read/written */
35527 ** to roll the journal back, the database could be corrupted. The additional
35559 ** The macro MEMDB is true if we are dealing with an in-memory database.
35628 ** as if it has an exclusive lock on the database file. It never updates
35856 ** Unlock the database file to level eLock, which must be either NO_LOCK
35882 ** Lock the database file to level eLock, which must be either SHARED_LOCK,
35910 ** a database page may be written atomically, and
35916 ** database.
36143 ** - 4 bytes: Initial database page count.
36145 ** - 4 bytes: Database page size.
36207 /* The initial database size */
36236 ** database page size. Since the zHeader buffer is only Pager.pageSize
36259 ** database before the transaction began, in pages. Also, pPager->cksumInit
36272 u32 *pDbSize /* OUT: Value of original database size field */
36306 ** field, the checksum-initializer and the database size at the start
36389 ** If zMaster is a NULL pointer (occurs for a single database transaction),
36524 ** If the pager is not in exclusive-access mode, the database file is
36556 ** close the journal file when dropping the database lock. Otherwise
36572 /* If the pager is in the ERROR state and the call to unlock the database
36625 ** to be replayed to restore the contents of the database file (as if
36648 ** database transaction.
36659 ** or any other database connection. Exactly how a journal is finalized
36689 ** database then the IO error code is returned to the user. If the
36691 ** tries to unlock the database file if not in exclusive mode. If the
36744 ** the database file, it will do so using an in-memory journal.
36777 ** lock held on the database file.
36796 ** database file.
36801 ** the database file and move the pager back to OPEN state. If this
36892 ** to the database file, then the IO error code is returned. If data
36988 ** not the database file. The page is left marked dirty in this case.
36990 ** An exception to the above rule: If the database is in no-sync mode
37007 ** statement we must not write to the original database unless we know
37010 ** database file without an entry in the rollback journal that can
37011 ** restore the database to its original form. Two conditions must be
37012 ** met before writing to the database files. (1) the database must be
37017 ** 2008-04-14: When attempting to vacuum a corrupt database file, it
37018 ** is possible to fail a statement on a database that does not yet exist.
37019 ** Do not attempt to write if database file has never been opened.
37055 ** the database and the page is not in-memory, there is a potential
37057 ** will be read from the database file, which may or may not be
37083 ** database active. However such a page may be rolled back as a result
37096 ** database.
37107 ** be written out into the database file before its journal file
37109 ** database corruption may ensue.
37263 ** This function is used to change the actual size of the database
37267 ** If the main database file is not open, or the pager is not in either
37280 ** the database file, return the error code to the caller.
37312 ** of the open database file. The sector size will be used used
37343 ** Playback the journal and thus restore the database file to
37355 ** database to during a rollback.
37490 ** database file back to its original size.
37501 ** database file and/or page cache.
37518 ** case, the database should have never been written in the
37526 ** process to come along will be able to rollback the database.
37537 /* Following a rollback, the database file should be back in its original
37590 ** Read the content for page pPg out of the database file and into
37591 ** pPg->pData. A shared lock or greater must be held on the database
37595 ** the value read from the database file.
37632 ** of bytes 24..39 of the database. Bytes 28..31 should always be
37633 ** zero or the size of the database in page. Bytes 32..35 and 35..39
37637 ** For an encrypted database, the situation is more complex: bytes
37638 ** 24..39 of the database are white noise. But the probability of
37668 ** references, the page content is reloaded from the database. If the
37669 ** attempt to reload content from the database is required and fails,
37692 ** database. This is not generally possible with a WAL database, as
37704 ** This function is called to rollback a transaction on a WAL database.
37715 ** + Reload page content from the database (if refcount>0).
37764 Pgno nTruncate, /* Database size after this commit */
37805 ** makes a snapshot of the database at the current point in time and preserves
37834 ** to PAGER_READER state to determine the size of the database file
37837 ** If no error occurs, SQLITE_OK is returned and the size of the database
37844 /* Query the WAL sub-system for the database size. The WalDbsize()
37846 ** if the database size is not available. The database size is not
37854 /* If the database size was not available from the WAL sub-system,
37855 ** determine it based on the size of the database file. If the size
37856 ** of the database file is not an integer multiple of the page-size,
37889 ** Check if the *-wal file that corresponds to the database opened by pPager
37890 ** exists if the database is not empy, or verify that the *-wal file does
37891 ** not exist (by deleting it) if the database file is empty.
37893 ** If the database is not empty and the *-wal file exists, open the pager
37894 ** in WAL mode. If the database is empty or if no *-wal file exists and
37900 ** The caller must hold a SHARED lock on the database file to call this
37902 ** a WAL on a none-empty database, this ensures there is no race condition
37913 Pgno nPage; /* Size of the database file */
37991 /* Set the database size back to the value it was before the savepoint
38012 ** greater than the current database size (pPager->dbSize) but those
38090 ** Adjust the robustness of the database to damage due to OS crashes
38098 database. This is normally adequate protection, but
38101 ** in a state which would cause damage to the database
38105 ** database (with some additional information - the nRec field
38110 ** point of causing damage to the database during rollback.
38114 ** prior to the start of checkpoint and that the database file is synced
38116 ** was written back into the database. But no sync operations occur for
38245 ** * the database is either not an in-memory database or it is
38246 ** an in-memory database that currently consists of zero pages.
38313 ** entire content of a database page. This buffer is used internally
38323 ** Attempt to set the maximum database page count if mxPage is positive.
38325 ** maximum page count below the current size of the database.
38369 ** function is used to read database headers, and a new transient or
38370 ** zero sized database has a header than consists entirely of zeroes.
38399 ** the pager. It returns the total number of pages in the database.
38412 ** Try to obtain a lock of type locktype on the database file. If
38449 ** current database image, in pages, OR
38458 ** the database file. If a savepoint transaction were rolled back after
38461 ** the database file or the portion of the rollback journal and
38463 ** database image would become corrupt. It is therefore fortunate that
38479 ** Truncate the in-memory database file image to nPage pages. This
38480 ** function does not actually modify the database file on disk. It
38548 ** file may be played back into the database. If a power failure occurs
38549 ** while this is happening, the database could become corrupt.
38553 ** database and close the journal file without attempting to roll it
38554 ** back or finalize it. The next database user will have to do hot-journal
38555 ** rollback before accessing the database file.
38653 ** that wrote to this database was operating in persistent-journal
38663 ** out-of-date data that follows it. Database corruption.
38747 ** in-memory pages in the list to the database file. The argument may
38752 ** is called. Before writing anything to the database file, this lock
38754 ** SQLITE_BUSY is returned and no data is written to the database file.
38761 ** the pages are written out to the database file in list order. Writing
38767 ** If writing out a page causes the database file to grow, Pager.dbFileSize
38770 ** the database file.
38821 /* Encode the database */
38828 ** the value now stored in the database file. If writing this
38829 ** page caused the database file to grow, update dbFileSize.
38931 ** database). The second argument is a reference to a page that is
38937 ** out to the database file, if possible. This may involve syncing the
38962 ** lead to database corruption. In the current implementaton it
38993 ** the database image, it may need to be written to the sub-journal.
39003 ** <shrink database file to Y pages>
39008 ** out to the database file, but will be dropped from the cache. Then,
39010 ** data from the database file. This will be the copy of page X as it
39025 /* Write the contents of the page out to the database file. */
39047 ** The zFilename argument is the path to the database file to open.
39052 ** This can be used to implement an in-memory database.
39075 const char *zFilename, /* Name of the database file to open */
39088 char *zPathname = 0; /* Full path to database file */
39134 ** the database being opened will be more than pVfs->mxPathname
39135 ** bytes in length. This means the database cannot be opened,
39148 ** three file descriptors, the database file name and the journal
39153 ** Database file handle (pVfs->szOsFile bytes)
39156 ** Database file name (nPathname+1 bytes)
39210 ** database file. The default page size is the maximum of:
39246 ** This branch is also run for an in-memory database. An in-memory
39247 ** database is the same as a temp-file that is never written out to
39342 ** * No process holds a RESERVED or greater lock on the database file, and
39343 ** * The database file itself is greater than 0 bytes in size, and
39346 ** If the current size of the database file is 0 but a journal file
39348 ** database with the same name. In this case the journal file is
39396 Pgno nPage; /* Number of pages in database file */
39398 /* Check the size of the database file. If it consists of 0 pages,
39415 ** or greater lock on the database file. Now check that there is
39456 ** This function is called to obtain a shared lock on the database file.
39464 ** on the database file), then an attempt is made to obtain a
39465 ** SHARED lock on the database file. Immediately after obtaining
39469 ** the 'change-counter' field of the database file header and
39479 ** occurs while locking the database, checking for a hot-journal file or
39510 ** database file, then it either needs to be played back or deleted.
39519 /* Get an EXCLUSIVE lock on the database file. At this point it is
39522 ** database file, detect the RESERVED lock, and conclude that the
39523 ** database is safe to read while this process is still rolling the
39527 ** other process attempting to access the database file will get to
39529 ** on the database file.
39570 /* Playback and delete the journal. Drop the database write
39619 /* The shared-lock has just been acquired on the database file
39621 ** read or write transaction). Check to see if the database
39622 ** has been modified. If the database has changed, flush the
39625 ** Database changes is detected by looking at 15 bytes beginning
39656 /* If there is a WAL file in the file-system, open this database in WAL
39706 ** read from the database file. In some cases, the pcache module may
39715 ** If the database image is smaller than the requested page or if a
39724 ** a) When reading a free-list leaf page from the database, and
39731 ** being read from the database. Additionally, the bits corresponding
39750 Pager *pPager, /* The pager open on the database file */
39877 ** are released, a rollback occurs and the lock on the database is
39890 ** There must already be a RESERVED or EXCLUSIVE lock on the database
39981 ** lock on the database file. If exFlag is true, then acquire at least
39990 ** sub-journal is implemented in-memory if pPager is an in-memory database,
40005 ** exclusive lock on the database is not already held, obtain it now.
40022 /* Obtain a RESERVED lock on the database file. If the exFlag parameter
40039 ** transactions may copy data from the sub-journal into the database
40085 /* Higher-level routines never call this function if database is not
40116 ** EXCLUSIVE lock on the main database file. Write the current page to
40127 ** contains the database locks. The following assert verifies
40139 ** in the database file. And if an IO error occurs while doing so,
40189 /* Update the database size and return.
40223 Pgno nPageCount; /* Total number of pages in database file */
40281 ** before any of them can be written out to the database file.
40338 ** This routine is called to increment the value of the database file
40355 ** if isDirect is non-zero, then the database file is updated directly
40430 ** Sync the database file to disk. This is a no-op for in-memory databases
40451 ** the database file, an attempt is made to obtain one.
40472 ** Sync the database file for the pager pPager. zMaster points to the name
40475 ** journal (a single database transaction).
40479 ** * The database file change-counter is updated,
40481 ** * all dirty pages are written to the database file,
40482 ** * the database file is truncated (if required), and
40483 ** * the database file synced.
40492 ** If the final parameter - noSync - is true, then the database file itself
40494 ** sync the database file before calling CommitPhaseTwo() to delete the
40514 PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n",
40517 /* If no database changes have been made, return early. */
40575 ** directly to the database file. Because of the atomic-write
40590 /* If this transaction has made the database smaller, then all pages
40598 ** reading data from the database file.
40606 const Pgno dbSize = pPager->dbSize; /* Database image size */
40629 /* Sync the journal file and write all dirty pages to the database.
40650 /* If the file on disk is not the same size as the database image,
40660 /* Finally, sync the database file. */
40677 ** When this function is called, the database file has been completely
40705 /* An optimization. If the database was not actually modified during
40712 ** to the database file. So there is no need to zero the journal
40741 ** 1) It rolls back the journal file, restoring all database file and
40753 ** their pre-transaction state by re-reading data from the database or
40789 ** Return TRUE if the database file is opened read-only. Return FALSE
40790 ** if the database is (in theory) writable.
40928 ** the transaction or unlock the database, it just restores the
40929 ** contents of the database to its original state.
40974 ** the database file, so the playback operation can be skipped.
40987 ** Return the full pathname of the database file.
41001 ** Return the file handle for the database file associated
41066 ** moved as part of a database reorganization just before the transaction
41067 ** is being committed. In this case, it is guaranteed that the database page
41085 /* In order to be able to rollback, an in-memory database must journal
41126 ** the journal needs to be sync()ed before database page pPg->pgno
41146 /* Do not discard pages from an in-memory database since we might
41158 /* For an in-memory database, make sure the original page continues
41170 ** sync()ed before any data is written to database file page needSyncPgno.
41179 ** this transaction, it may be written to the database file before
41253 ** * An in-memory database can only have its journal_mode set to _OFF
41284 /* Do allow the journalmode of an in-memory database to be set to
41319 ** database file. This ensures that the journal file is not deleted
41362 ** journalmode. Journalmode changes can only happen when the database
41423 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
41443 ** lock on the database file and use heap-memory to store the wal-index
41475 ** The caller must be holding a SHARED lock on the database file to call
41478 ** If the pager passed as the first argument is open on a real database
41479 ** file (not a temp file or an in-memory database), and the WAL file
41485 ** If the pager is open on a temp-file (or in-memory database), or if
41524 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
41551 ** the database file, the log and log-summary files will be deleted.
41604 ** database file. All changes to the database are recorded by writing
41608 ** transferred back into the database file in an operation called a
41623 ** 8: Database page size. Example: 1024
41636 ** 4: For commit records, the size of the database image in pages
41674 ** WAL is transferred into the database, then the database is VFS.xSync-ed.
41686 ** To read a page from the database (call it page number P), a reader
41692 ** the database file.
41699 ** of the database from a single point in time. This technique allows
41700 ** multiple concurrent readers to view different versions of the database
41716 ** on a network filesystem. All users of the database must be able to
41724 ** Hence, unlike the database and WAL file formats which store all values
41746 ** database page number associated with each wal frame, and a hash-table
41750 ** first index-block contains the database page number corresponding to the
41889 u16 szPage; /* Database page size in bytes. 1==64K */
41891 u32 nPage; /* Size of database in pages */
41903 ** back into the database. (We call the act of moving content from WAL to
41904 ** database "backfilling".) The nBackfill number is never greater than
41917 ** directly from the database.
41924 ** The checkpointer may only transfer frames from WAL to database where
41931 ** in the WAL has been backfilled into the database) then new readers
41933 ** get all their all content directly from the database file and ignore
41938 ** written back into the database) and if no readers are using the WAL
41982 ** assuming a database page size of szPage bytes. The offset returned
41995 sqlite3_file *pDbFd; /* File handle for the database file */
42000 u32 szPage; /* Database page size */
42029 ** all frames in the WAL in database page order. Where two or more frames
42030 ** correspond to the same database page, the iterator visits only the
42227 ** 4: For commit records, the size of the database image in pages
42236 u32 iPage, /* Database page number for frame */
42263 u32 *piPage, /* OUT: Database page number for frame */
42303 ** and the new database size.
42533 ** Set an entry in the wal-index that will map database page number
42674 /* If the database page size is not a power of two, or is greater than
42723 u32 pgno; /* Database page number for frame */
42801 ** Open a connection to the WAL file zWalName. The database file must
42805 ** A SHARED lock should be held on the database file when this function
42817 sqlite3_file *pDbFd, /* The open database file */
43110 ** Copy as much content as we can from the WAL back into the database file
43113 ** The amount of information copies from WAL to database might be limited
43114 ** by active readers. This routine will never overwrite a database page
43123 ** into the database. This ensures that if the new content is persistent
43126 ** Fsync is also called on the database file if (and only if) the entire
43127 ** WAL content is copied into the database file. This second fsync makes
43129 ** database file.
43147 int szPage; /* Database page-size */
43149 u32 iDbpage = 0; /* Next database page to write */
43152 u32 mxPage; /* Max database page to write */
43176 ** safe to write into the database. Frames beyond mxSafeFrame might
43177 ** overwrite database pages that are in use by active readers and thus
43201 i64 nSize; /* Current size of database file */
43209 /* If the database file may grow as a result of this checkpoint, hint
43277 /* If an EXCLUSIVE lock can be obtained on the database file (using the
43280 ** the database. In this case checkpoint the database and unlink both
43476 ** access any database page that is modified by a WAL frame up to and
43480 ** completely and get all content directly from the database file.
43573 ** which implies that the database file contains a trustworthy
43581 ** it finished. Leaving a corrupt image in the database file.
43641 ** copied into the database by a checkpointer. If either of these things
43642 ** happened, then reading the database with the current value of
43667 database.
43675 ** If the database contents have changes since the previous read
43712 ** the WAL and needs to be read out of the database.
43716 Pgno pgno, /* Database page number to read data for */
43828 ** Return the size of the database in pages (or zero, if unknown).
43844 ** If another thread or process has written into the database since
43871 /* If another connection has written to the database file since the
43915 ** was in before the client began writing to the database.
44058 int szPage, /* Database page-size in bytes */
44060 Pgno nTruncate, /* Database size after this commit */
44226 ** we can from WAL into the database.
44249 /* Copy data from the log to the database file. */
44258 ** next time the pager opens a snapshot on this database it knows that
44295 ** lock on the main database file.
44302 ** on the main database file before invoking this operation.
44306 ** should acquire the database exclusive lock prior to invoking
44389 ** This file implements a external (disk-based) database using BTrees.
44396 ** The basic idea is that each page of the file contains N database
44415 ** fixed amount of payload can be carried directly on the database
44462 ** The file change counter is incremented when the database is changed
44599 /* The maximum number of cells on a single page of the database. This
44612 ** SQLite database in order to identify the file as a real database.
44699 ** A database connection contains a pointer to an instance of
44700 ** this object for every database file that it has open. This structure
44701 ** is opaque to the database connection. The database connection cannot
44705 ** For some database files, the same underlying database cache might be
44708 ** points to the same BtShared object. The database cache and the
44709 ** schema associated with the database file are all contained within
44719 sqlite3 *db; /* The database connection holding this btree */
44745 ** An instance of this object represents a single database file.
44747 ** A single database file can be in use as the same time by two
44748 ** or more database connections. When two or more connections are
44749 ** sharing the same database file, each connection has it own
44752 ** connections currently sharing this database file.
44763 ** If a BtShared client fails to obtain a write-lock on a database
44781 sqlite3 *db; /* Database connection currently using this Btree */
44783 MemPage *pPage1; /* First page of the database */
44787 u8 initiallyEmpty; /* Database is empty at start of transaction */
44802 u32 nPage; /* Number of pages in the database */
44838 ** maximum database size of 2^31 pages a minimum fanout of 2 for a
44842 ** assumed that the database is corrupt.
44848 ** b-tree within a database file.
44853 ** A single database file can shared by two more database connections,
44855 ** particular database connection identified BtCursor.pBtree.db.
44915 ** The database page the PENDING_BYTE occupies. This page is never used.
44921 ** database page. The first argument to each is the number of usable
44922 ** bytes on each page of the database (often 1024). The second is the
44925 ** PTRMAP_PAGENO returns the database page number of the pointer-map
44940 ** each child page in the database file. The parent page is the page that
44941 ** contains a pointer to the child. Every page in the database contains
44942 ** 0 or 1 parent pages. (In this context 'database page' refers
44952 ** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not
44955 ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
44958 ** PTRMAP_OVERFLOW1: The database page is the first page in a list of
44962 ** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of
44966 ** PTRMAP_BTREE: The database page is a non-root btree page. The page number
44985 ** if the database supports auto-vacuum or not. Because it is used
45005 Pgno nPage; /* Number of pages in the database */
45028 ** set BtShared.db to the database handle associated with p and the
45064 ** by all database connections. The p->pNext is a list of other
45065 ** Btrees belonging to the same database connection as the p Btree
45088 /* We should already hold a lock on the database connection */
45091 /* Unless the database is sharable and unlocked, then BtShared.db
45177 ** Enter the mutex on every Btree associated with a database
45236 ** Return true if the current thread holds the database connection
45261 ** another database connection.
45312 /* We should already hold a lock on the database connection */
45338 /* We should already hold a lock on the database connection */
45377 ** This file implements a external (disk-based) database using BTrees.
45384 ** SQLite database.
45430 ** This routine has no effect on existing database connections.
45474 ** When writing to an index that resides in a sharable database, the
45479 ** function has to search through the database schema.
45495 /* If this database is not shareable, or if the client is reading
45649 ** database (one with the BtShared.sharable flag set), and
45833 Btree *pBtree, /* The database file to check */
45864 ** a free-list leaf page, the page is not written to the database
45870 ** from the database or written to the journal file (why should it
45880 ** to restore the database to its original configuration.
46094 ** Given a page number of a regular database page, return the page
46699 ** indicates a corrupt database files:
46735 ** not contain a well-formed database page, then return
46778 /* A malformed database page might cause us to read past the end
46823 ** the free-block must lie on the database page. */
46847 ** Set up a raw page so that it looks like a database page holding
46938 ** Return the size of the database file in pages. If there is any kind of
46959 BtShared *pBt, /* The database file */
47036 ** Open a database file.
47038 ** zFilename is the name of the database file. If zFilename is NULL
47039 ** then an ephemeral database is created. The ephemeral database might
47041 ** Either way, the ephemeral database will be automatically deleted
47044 ** If zFilename is ":memory:" then an in-memory database is created
47053 ** If the database is already opened in the same database connection
47056 ** objects in the same database connection since doing so will lead
47060 const char *zFilename, /* Name of the file containing the BTree database */
47061 sqlite3 *db, /* Associated database handle */
47072 unsigned char zDbHeader[100]; /* Database header content */
47074 /* True if opening an ephemeral, temporary database */
47077 /* Set the variable isMemdb to true for an in-memory database, or
47078 ** false for a file-based database.
47091 /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */
47094 /* A BTREE_SINGLE database is always a temporary and/or ephemeral */
47214 /* If the magic name ":memory:" will create an in-memory database, then
47378 ** Close an open database and invalidate all cursors.
47443 ** and the database cannot be corrupted if this program
47445 ** an abrupt power failure when synchronous is off, the database
47447 ** Synchronous is on by default so database corruption is not
47461 ** how well the database resists damage due to OS crashes and power
47510 ** of the database file used for locking (beginning at PENDING_BYTE,
47568 ** Set the maximum page count for a database if mxPage is positive.
47599 ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
47646 ** Get a reference to pPage1 of the database file. This will
47650 ** well-formed database file, then SQLITE_CORRUPT is returned.
47651 ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM
47656 MemPage *pPage1; /* Page 1 of the database file */
47657 int nPage; /* Number of pages in the database */
47658 int nPageFile = 0; /* Number of pages in the database file */
47659 int nPageHeader; /* Number of pages in the database according to hdr */
47669 ** a valid database file.
47700 /* If the write version is set to 2, this database should be accessed
47739 /* After reading the first page of the database assuming a page size
47741 ** actually pageSize. Unlock the database, leave pBt->pPage1 at
47798 ** of a transaction but there is a read lock on the database, then
47799 ** this routine unrefs the first page of the database file which
47818 ** into a new empty database by initializing the first page of
47819 ** the database.
47865 ** to access the database. A preexisting transaction may not be
47870 ** changes to the database. None of the following routines
47882 ** and the database was previously unlocked, then invoke the busy handler
47911 /* Write transactions are not possible on a read-only database */
47918 /* If another database handle has already opened a write transaction
47951 ** reading page 1 it discovers that the page-size of the database
47999 ** client has been writing the database file), update it now. Doing
48000 ** this sooner rather than later means the database size can safely
48001 ** re-read the database size from page 1 if a savepoint or transaction
48136 ** Move the open database page pDbPage to location iFreePage in the
48137 ** database. The pDbPage reference remains valid.
48140 ** the journal needs to be sync()ed before database page pDbPage->pgno
48194 /* Fix the database pointer on page iPtrPage that pointed at iDbPage so
48226 ** database so that the last page of the file currently in use
48232 ** number of pages the database file will contain after this
48369 ** is commited for an auto-vacuum database.
48372 ** the database
48373 ** i.e. the database has been reorganized so that only the first *pnTrunc
48385 Pgno nFin; /* Number of pages in database after autovacuuming */
48390 Pgno nOrig; /* Database size before freeing */
48394 /* It is not possible to create a database for which the final page
48441 ** the database can be restored to its original state by playing back
48444 ** database are written into the database file and flushed to oxide.
48452 ** Otherwise, sync the database file for the btree pBt. zMaster points to
48455 ** (single database transaction).
48461 ** the write-transaction for this database file is to delete the journal.
48493 /* If there are other active statements that belong to this database
48495 ** may still be reading from the database. */
48532 ** This will release the write lock on the database file. If there
48603 ** to other database connections that happen to be sharing
48636 ** This will release the write lock on the database file. If there
48751 /* The database size was written into the offset 28 of the header
48765 ** on the database already. If a write-cursor is requested, then
48776 ** 2: Other database connections that share the same pager cache
48780 ** the read cursors in the other database connection.
48782 ** 3: The database must be writable (not on read-only media)
48806 ** b-tree database, the connection is holding the required table locks,
48880 ** Set the cached rowid value of every cursor in the same database file
48910 ** Close a cursor. The read lock on the database file is released
49044 ** Given the page number of an overflow page in the database (parameter
49063 BtShared *pBt, /* The database file */
49122 ** pPayload is a pointer to data stored on database page pDbPage.
49376 ** page of the database. The data might change or move the next time
49956 ** Advance the cursor to the next entry in the database. If
49958 ** was already pointing to the last entry in the database before
50025 ** Step the cursor to the back to the previous entry in the database. If
50027 ** was already pointing to the first entry in the database before
50085 ** Allocate a new page from the database file.
50098 ** attempt to keep related pages close to each other in the database file,
50099 ** which in turn can make database access faster.
50118 Pgno mxPage; /* Total size of the database file */
50196 /* Value of k is out of range. Database corruption */
50377 ** This function is used to add page iPage to the database file free-list.
50425 /* If the database supports auto-vacuum, write an entry in the pointer-map
50433 /* Now manipulate the actual database free-list structure. There are two
50543 ** file the database must be corrupt. */
50557 ** must not really be an overflow page and the database must be corrupt.
50667 /* If the database supports auto-vacuum, and the second or subsequent
50675 ** wrong pages from the database.
50967 BtShared *const pBt = pPage->pBt; /* B-Tree Database */
50997 /* If this is an auto-vacuum database, update the pointer map
51138 /* If this is an auto-vacuum database, update the pointer-map entries
51171 ** If this routine fails for any reason, it might leave the database
51172 ** in a corrupted state. So if this routine fails, the database should
51193 BtShared *pBt; /* The whole database */
51538 ** When NB==3, this one optimization makes the database
51656 ** If this is an auto-vacuum database, the call to copyNodeContent()
51657 ** sets all pointer-map entries corresponding to database image pages
51662 ** is important if the parent page happens to be page 1 of the database
51768 ** debugging. This is usually disabled because a corrupt database may
51946 ** copied either into the body of a database page or into the new
51954 ** now stored either on real database pages or within the
52289 /* Creating a new table may probably require moving an existing database
52296 /* Read the value of meta[3] from the database to determine where the
52376 ** order either to increase the database filesize, or to decrement the
52412 ** Erase the given database page and all its children. Return
52461 ** Delete all information from a single table in the database. iTable is
52501 ** root page in the database file, then the last root page
52502 ** in the database file is moved into the slot formerly occupied by
52505 ** root pages are kept at the beginning of the database file, which
52521 database. This is because in auto-vacuum mode the backend may
52554 ** number in the database, put the root page on the free list.
52563 ** number in the database. So move the page that does into the
52587 /* Set the new 'max-root-page' value in the database header. This
52608 ** database.
52626 ** has a read or write transaction open on the database.
52628 ** Read the meta-information out of a database file. Meta[0]
52629 ** is the number of free pages currently in the database. Meta[1]
52649 ** database, mark the database as read-only. */
52658 ** Write meta-information back into the database. Meta[0] is
52691 ** Otherwise, if an error is encountered (i.e. an IO error or database
52901 /* If this database supports auto-vacuum and iPage is not the last
53226 /* If the database supports auto-vacuum, make sure no tables contain
53267 ** Return the full pathname of the underlying database file.
53278 ** Return the pathname of the journal file for this database. The return
53472 ** "write version" (single byte at byte offset 19) fields in the database
53533 sqlite3* pDestDb; /* Destination database handle */
53539 sqlite3* pSrcDb; /* Source database handle */
53561 ** backup_finish(). Both these functions obtain the source database
53567 ** the page cache associated with the source database. The mutex
53568 ** associated with the source database BtShared structure will always
53578 ** Depending on the SQLite configuration, the database handles and/or
53585 ** Return a pointer corresponding to database zDb (i.e. "main", "temp")
53586 ** in connection handle pDb. If such a database cannot be found, return
53589 ** If the "temp" database is requested, it may need to be opened by this
53618 sqlite3Error(pErrorDb, SQLITE_ERROR, "unknown database %s", zDb);
53631 ** stored in database handle pDestDb.
53634 sqlite3* pDestDb, /* Database to write to */
53635 const char *zDestDb, /* Name of database within pDestDb */
53636 sqlite3* pSrcDb, /* Database connection to read from */
53637 const char *zSrcDb /* Name of database within pSrcDb */
53641 /* Lock the source database handle. The destination database
53646 ** database connection while a backup is in progress may cause
53707 ** page iSrcPg from the source database. Copy this data into the
53708 ** destination database.
53725 /* Catch the case where the destination is an in-memory database and the
53834 /* Lock the destination database, if it is not locked already. */
53842 /* If there is no open read-transaction on the source database, open
53851 /* Do not allow backup if the destination database is in WAL mode
53860 /* Now that there is a read-lock on the source database, query the
53861 ** source pager for the number of pages in the database.
53887 /* Update the schema version field in the destination database. This
53902 ** database. The complication here is that the destination page
53933 ** pending-byte page in the source database may need to be
53934 ** copied into the destination database.
53969 /* Finish committing the transaction to the destination database. */
53978 ** on the source database. Close the read transaction here. There is
54007 sqlite3_mutex *mutex; /* Mutex to protect source database */
54034 /* Set the error code of the destination database handle. */
54062 ** Return the total number of pages in the source database as of the most
54071 ** source database have been modified. If page iPage has already been
54072 ** copied into the destination database, then the data written to the
54078 ** corresponding to the source database is held when this function is
54101 ** detects that the database has been modified by an external database
54103 ** pages that have been copied into the destination database are still
54107 ** corresponding to the source database is held when this function is
54144 /* 0x7FFFFFFF is the hard limit for the number of pages in a database
55077 ** that both the BtShared and database handle mutexes are held. */
55180 sqlite3 *db, /* The database connection */
55348 ** Create a new virtual database engine.
56381 sqlite3 *db = p->db; /* The database connection */
56942 ** A read or write transaction may or may not be active on database handle
56944 ** write-transaction spanning more than one database file, this routine
56963 ** required, as an xSync() callback may add an attached database
56969 ** (b) how many database files have open write transactions, not
56970 ** including the temp database. (b) is important because if more than
56971 ** one database file has an open write transaction, a master journal
56994 /* The simple case - no more than one database file (not counting the
56995 ** TEMP database) has a transaction active. There is no need for the
56999 ** string, it means the main database is :memory: or a temp file. In
57066 /* Write the name of each database file in the transaction into the new
57196 ** For every Btree that in database connection db which
57201 ** cursor from other VMs in different database connections,
57267 ** database handles deferred constraint counter to the value it had when
57285 ** of all of BtShared structures accessible via the database handle
57304 ** This function is called when a transaction opened by the database
57385 ** transaction must be rolled back to restore the database to a
57390 ** occured while writing to the journal, sub-journal or database
57490 ** has been rolled back, update the database connection change-counter.
57568 ** and error message from the VDBE into the main database structure. But
57570 ** instructions yet, leave the main database error information unchanged.
57589 ** called), set the database error in this case as well.
57666 ** the database connection.
58282 ** pCur might be pointing to text obtained from a corrupt database file.
58296 ** than 2GiB are support - anything large must be database corruption.
58346 /* Jump here if database corruption is detected after m has been
58397 ** sqlite3_changes() on the database handle 'db'.
58414 ** Mark every prepared statement associated with a database connection
58431 ** Return the database associated with the Vdbe.
58909 ** caller. Set the error code in the database handle to the same value.
58926 sqlite3 *db; /* The database connection */
58942 ** into the database handle. This block copies the error message
58943 ** from the database handle into the statement and sets the statement
58977 ** returns a copy of the pointer to the database connection (the 1st
59288 ** 2 The name of the database that the column derives from
59368 ** Return the name of the database from which a result column derives.
59370 ** anything else which is not an unabiguous reference to a database column.
59386 ** anything else which is not an unabiguous reference to a database column.
59402 ** anything else which is not an unabiguous reference to a database column.
59429 ** The error code stored in database p->db is overwritten with the return
59711 ** database connections. But as this is a deprecated interface, we
59735 ** Return the sqlite3* database handle to which the prepared statement given
59736 ** in the argument belongs. This is the same database handle that was
59746 ** database.
59754 ** with database connection pDb. If pStmt is NULL, return the first
59755 ** prepared statement for the database connection. Return NULL if there
59845 sqlite3 *db; /* The database connection */
59937 ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c")
60114 int iDb, /* When database the cursor belongs to, or -1 */
60537 ** If an attempt is made to open a locked database, then this routine
60564 sqlite3 *db = p->db; /* The database */
60566 u8 encoding = ENC(db); /* The database encoding */
60795 const char *zDb; /* database name - used by the update hook */
60924 const char *zFilename; /* Name of database file for pPager */
62629 ** the database file has been corrupted externally.
62633 /* Make sure a corrupt database has not given us an oversize header.
62652 ** allocation, especially if a corrupt database file has caused u.am.offset
62658 ** not exceeded even for corrupt database files.
62713 ** with a corrupt database.
62806 ** use as a data record in a database table or as a key
63016 /* Link the new savepoint into the database handle's list. */
63095 ** constraint violations present in the database to the value stored
63115 ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll
63192 ** P1 is the index of the database file on which the transaction is
63193 ** started. Index 0 is the main database file and index 1 is the
63198 ** obtained on the database file when a write-transaction is started. No
63202 ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
63208 ** More specifically, a statement transaction is opened iff the database
63215 ** If P2 is zero, then a read-lock is obtained on the database file.
63248 /* Store the current value of the database handles deferred constraint
63259 ** Read cookie number P3 from database P1 and write it into register P2.
63260 ** P3==1 is the schema version. P3==2 is the database format.
63262 ** the main database file and P1==1 is the database file used to store
63265 ** There must be a read-lock on the database (either a transaction
63291 ** into cookie number P2 of database P1. P2==1 is the schema version.
63292 ** P2==2 is the database format. P2==3 is the recommended pager cache
63293 ** size, and so forth. P1==0 is the main database file and P1==1 is the
63294 ** database file used to store temporary tables.
63320 /* Invalidate all prepared statements whenever the TEMP database
63330 ** Check the value of global database parameter number 0 (the
63332 ** P1 is the database number which is 0 for the main database file
63336 ** The cookie changes its value whenever the database schema changes.
63359 p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
63360 /* If the schema-cookie from the database file matches the cookie
63362 ** not reload the schema from the database file.
63368 ** discard the database schema, as the user code implementing the
63385 ** Open a read-only cursor for the database table whose root page is
63386 ** P2 in a database file. The database file is determined by P3.
63387 ** P3==0 means the main database, P3==1 means the database used for
63389 ** database. Give the new cursor an identifier of P1. The P1
63396 ** There will be a read lock on the database whenever there is an
63397 ** open cursor. If the database was unlocked prior to this instruction
63399 ** lock allows other processes to read the database but prohibits
63400 ** any other process from modifying the database. The read lock is
63502 ** rooted at page 1 of a zero-byte database. */
63511 ** and report database corruption if they were not, but this check has
63522 ** the main database is read-only. The ephemeral
64117 ** The record number is not previously used as a key in the database
64228 ** largest possible integer (9223372036854775807) then the database
64319 const char *zDb; /* database name - used by the update hook */
64448 ** The value of the change counter is copied to the database handle
64464 ** it is found in the database file.
64474 ** it is found in the database file.
64616 ** will refer to the last entry in the database table or index.
64671 ** will refer to the first entry in the database table or index.
64951 ** Delete an entire database table or index whose root page in the database
64954 ** The table being destroyed is in the main database file if P3==0. If
64955 ** P3==1 then the table to be clear is in the auxiliary database file
64960 ** root pages contiguous at the beginning of the database. The former
64964 ** the last one in the database) then a zero is stored in register P2.
65009 ** Delete all contents of the database table or index whose root page
65010 ** in the database file is given by P1. But, unlike Destroy, do not
65011 ** remove the table or index from the database file.
65013 ** The table being clear is in the main database file if P2==0. If
65014 ** P2==1 then the table to be clear is in the auxiliary database file
65048 ** Allocate a new table in the main database file if P1==0 or in the
65049 ** auxiliary database file if P1==1 or in an attached database if
65061 ** Allocate a new index in the main database file if P1==0 or in the
65062 ** auxiliary database file if P1==1 or in an attached database if
65094 ** Read and parse all entries from the SQLITE_MASTER table of database P1
65123 ** database u.bu.iDb (the database containing the sqlite_master table
65131 ** schema of database u.bu.iDb before the SQL statement runs. The schema
65134 ** database schema" error being returned to the user.
65169 ** Read the sqlite_stat1 table for database P1 and load the content
65183 ** the table named P4 in database P1. This is called after a table
65195 ** the index named P4 in database P1. This is called after an index
65207 ** the trigger named P4 in database P1. This is called after a trigger
65220 ** Do an analysis of the currently open database. Store in
65229 ** The root page numbers of all tables in the database are integer
65233 ** If P5 is not zero, the check is done on the auxiliary database
65234 ** file, not the main database file.
65532 ** If P1 is non-zero, the database constraint counter is incremented
65551 ** If P1 is non-zero, then the jump is taken if the database constraint-counter
65740 ** Checkpoint database P1. This is a no-op if P1 is not currently in
65752 ** Change the journal mode of database P1 to P3. P3 must be one of the
65767 const char *zFilename; /* Name of database file for pPager */
65786 ** iDb index of the database as a parameter, and the database has not
65788 ** until runtime (now) to get the mutex on the newly attached database.
65795 ** database. */
65809 /* Do not allow a transition to journal_mode=WAL for a database
65834 ** file. An EXCLUSIVE lock may still be held on the database file
65847 /* Open a transaction on the database file. Regardless of the journal
65876 ** Vacuum the entire database. This opcode will cause other virtual
65890 ** the P1 database. If the vacuum has finished, jump to instruction
65934 ** P1 is the index of the database in sqlite3.aDb[] of the database
65953 sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z);
65984 ** P4 is the name of a virtual table in database P1. Call the xCreate method
65996 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
66320 ** Write the current number of pages in database P1 to memory cell P2.
66332 ** Try to set the maximum page count for database P1 to the value in P3.
66531 sqlite3 *db; /* The associated database */
66608 sqlite3* db, /* The database connection */
66609 const char *zDb, /* The attached database containing the blob */
66926 ** database table.
66930 ** database handle error code and message set. If this happens, then all
67658 sqlite3 *db; /* The database connection */
67708 ** pExpr->iDb Set the index in db->aDb[] of the database X
67719 ** The zDb variable is the name of the database (the "X"). This value may be
67720 ** NULL meaning that name is of the form Y.Z or Z. Any available database
67731 const char *zDb, /* Name of the database containing table, or NULL */
67740 sqlite3 *db = pParse->db; /* The database connection */
68088 ** Or a database, table and column: ID.ID.ID
68124 u8 enc = ENC(pParse->db); /* The database encoding */
68271 sqlite3 *db; /* Database connection */
68536 sqlite3 *db; /* Database connection */
68702 ** X: The name of a database. Ex: "main" or "temp" or
68703 ** the symbolic name assigned to an ATTACH-ed database.
69649 ** part of the in-memory representation of the database schema.
70189 ** The index of the cursor opened on the b-tree (database table, database index
70193 ** IN_INDEX_ROWID - The cursor was opened on a database table.
70194 ** IN_INDEX_INDEX - The cursor was opened on a database index.
70252 sqlite3 *db = pParse->db; /* Database connection */
70257 int iDb; /* Database idx for pTab */
70668 ** of a "NOT NULL" constraint in the database schema.
71076 sqlite3 *db = pParse->db; /* The database connection */
71343 u8 enc = ENC(db); /* The text encoding used by this database */
72768 ** Note that ON cannot be a database, table or column name, so
72858 ** temporary database, NULL is returned.
72888 ** pTab from the database, including triggers and temporary triggers.
72889 ** Argument zName is the name of the table in the database schema at
72897 int iDb; /* Index of database containing pTab */
72926 /* Now, if the table is not stored in the temp database, reload any temp
72944 int iDb; /* Database that contains the table */
72945 char *zDb; /* Name of database iDb */
72948 sqlite3 *db = pParse->db; /* Database connection */
72974 ** in database iDb. If so, this is an error.
73021 /* Begin a transaction and code the VerifyCookie for database iDb.
73092 /* If the sqlite_sequence table exists in this database, then update
73105 ** the temp database.
73175 int iDb; /* Database number */
73176 const char *zDb; /* Database name */
73181 sqlite3 *db; /* The database connection; */
73409 int iDb, /* The database we are looking in */
73483 sqlite3 *db = pParse->db; /* Database handle */
73492 int iDb; /* Index of database containing pTab */
73740 ** Generate code that will do an analysis of an entire database
73744 Schema *pSchema = db->aDb[iDb].pSchema; /* Schema of database iDb */
73763 ** a database.
73785 ** ANALYZE <database> -- 2
73786 ** ANALYZE ?<database>.?<tablename> -- 3
73789 ** Form 2 analyzes all indices the single database named.
73800 /* Read the database schema. If an error occurs, leave an error message
73811 if( i==1 ) continue; /* Do not analyze the TEMP database */
73815 /* Form 2: Analyze the database or table named */
73934 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
73940 ** sqlite_stat2 table is not present in the database, SQLITE_ERROR is
74089 ** ATTACH DATABASE abc AS def
74096 ** ATTACH DATABASE abc||def AS 'db2'
74121 ** ATTACH DATABASE x AS y KEY z
74152 ** * Specified database name already being used.
74161 zErrDyn = sqlite3MPrintf(db, "cannot ATTACH database within transaction");
74168 zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName);
74188 /* Open the database
74189 ** it to obtain the database schema. At this point the schema may
74197 zErrDyn = sqlite3MPrintf(db, "database is already attached");
74205 "attached databases must use the same text encoding as main database");
74242 /* No key specified. Use the key from the main database */
74250 /* If the file was opened successfully, read the schema for the new database.
74275 zErrDyn = sqlite3MPrintf(db, "unable to open database: %s", zFile);
74295 ** DETACH DATABASE x
74320 sqlite3_snprintf(sizeof(zErr),zErr, "no such database: %s", zName);
74324 sqlite3_snprintf(sizeof(zErr),zErr, "cannot detach database %s", zName);
74329 "cannot DETACH database within transaction");
74333 sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
74356 Expr *pFilename, /* Name of database file */
74357 Expr *pDbname, /* Name of the database to use internally */
74358 Expr *pKey /* Database key for encryption extension */
74468 ** means we do need to fix the database references, FALSE means we do not.
74473 int iDb, /* This is the database that must be used */
74491 ** a specific database to all table references where the database name
74496 ** view in one database does not refer to objects in a different database.
74497 ** (Exception: indices, triggers, and views in the TEMP database are
74499 ** to an object in a different database, an error message is added to
74518 "%s %T cannot reference objects in database %s",
74532 Select *pSelect /* The SELECT statement to be fixed to one database */
74553 Expr *pExpr /* The expression to be fixed to one database */
74571 ExprList *pList /* The expression to be fixed to one database */
74588 TriggerStep *pStep /* The trigger step be fixed to one database */
74636 ** various fields of the database. The first argument to the auth function
74700 ** table zTab in database zDb. This function assumes that an authorization
74711 int iDb /* Index of containing database. */
74713 sqlite3 *db = pParse->db; /* Database handle */
74714 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
74750 int iDb; /* The index of the database the expression refers to */
74807 /* Don't do any authorization checks if the database is initialising
74899 int iDb; /* The database containing the table to be locked */
74908 ** The table to be locked has root page iTab and is found in database iDb.
74917 int iDb, /* Index of the database containing the table to lock */
75001 /* The cookie mask contains one bit for each database file open.
75003 ** set for each database that is used. Generate code to start a
75004 ** transaction on each used database and to verify the schema cookie
75005 ** on each used database.
75112 ** Locate the in-memory structure that describes a particular database
75114 ** database containing the table. Return NULL if not found.
75139 ** Locate the in-memory structure that describes a particular database
75141 ** database containing the table. Return NULL if not found. Also leave an
75152 const char *zDbase /* Name of the database. Might be NULL */
75156 /* Read the database schema. If an error occurs, leave an error message
75178 ** and the name of the database that contains the index.
75214 database iDb,
75246 ** a single database. This routine is called to reclaim memory
75247 ** before the database closes. It is also called during a rollback
75251 ** If iDb==0 then reset the internal schema tables for all database
75275 /* If one or more of the auxiliary database files has been closed,
75276 ** then remove them from the auxiliary database list. We take the
75423 ** Open the sqlite_master table stored in database number iDb for
75438 ** of a database ("main", "temp" or the name of an attached db). This
75439 ** function returns the index of the named database in db->aDb[], or
75443 int i = -1; /* Database number */
75458 ** The token *pName contains the name of a database (either "main" or
75460 ** index of the named database in db->aDb[], or -1 if the named db
75464 int i; /* Database number */
75486 ** database "xxx" is returned.
75494 int iDb; /* Database holding the object */
75499 sqlite3ErrorMsg(pParse, "corrupt database");
75506 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
75540 ** flag is true if the table should be stored in the auxiliary database
75541 ** file instead of in the main database file. This is normally the case
75564 int iDb; /* Database number to create the table in */
75581 ** set to the index of the database that the table or view is to be
75588 ** the database name is "temp" anyway. */
75629 ** index or table name in the same database. Issue an error message if
75669 ** then record a pointer to this table in the main database structure
75698 /* If the file format and encoding in the database have not been set,
76077 ** This function returns the collation sequence for database native text
76081 ** in the database native encoding, the collation factory is invoked to
76118 ** database changes. After each schema change, the cookie value
76120 ** cookie. Thereafter, whenever it goes to access the database,
76271 ** connected to the database or because the sqlite_master table has
76333 ** in the SQLITE_MASTER table of the database.
76336 ** file instead of into the main database file.
76375 ** a schema-lock excludes all other database users, the write-lock would
76451 /* Add the table to the in-memory representation of the database.
76569 sqlite3 *db = pParse->db; /* Database connection for malloc errors */
76656 ** Clear the column names from every VIEW in database idx.
76678 ** root-page of a table or index in database iDb has changed from iFrom
76715 ** Write code to erase the table with root-page iTable from database iDb.
76718 ** erasing iTable (this can happen with an auto-vacuum database).
76746 ** is also added (this can happen with an auto-vacuum database).
76757 /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM
76769 ** database, then root page 5 would be moved to page 4 by the
76933 ** created in the temp database that refers to a table in another
76934 ** database.
77133 sqlite3 *db = pParse->db; /* The database connection */
77226 DbFixer sFix; /* For assigning database names to pTable */
77229 Db *pDb; /* The specific table containing the indexed database */
77230 int iDb; /* Index of the database that is being written */
77251 /* Use the two-part index name to determine the database
77261 ** is a temp table. If so, set the database to 1. Do not do this
77262 ** if initialising a database schema.
77550 ** in-memory database structures.
77573 ** command. db->init.busy is 1 when a database is opened and
77900 sqlite3 *db, /* Database connection to notify of OOM errors */
77957 ** database name prefix. Like this: "database.table". The pDatabase
77958 ** points to the table name and the pTable points to the database name.
77961 ** SrcList.a[].zDatabase is filled with the database name from pTable,
77962 ** or with NULL if no database is specified.
77968 ** Then B is a table name and the database name is unspecified. If called
77973 ** Then C is the table name and B is the database name. If C is defined
77985 Token *pDatabase /* Database of the table */
78056 ** are the name of the table and database named in the FROM clause term.
78057 ** pDatabase is NULL if the database name qualifier is missing - the
78071 Token *pDatabase, /* Name of the database containing pTable */
78238 ** Make sure the TEMP database is open and available for use. Return
78255 sqlite3ErrorMsg(pParse, "unable to open a temporary database "
78272 ** a read-transaction for all named database files.
78281 ** record every database that needs its schema verified in the
78290 ** early in the code, before we know if any database tables will be used.
78320 ** might change the database.
78328 ** can be checked before any changes are made to the database, it is never
78353 ** perform this abort without corrupting the database, we need to make
78428 Db *pDb; /* A single database */
78429 int iDb; /* The database index number */
78430 sqlite3 *db = pParse->db; /* The database connection */
78432 Table *pTab; /* A table in the database */
78449 ** REINDEX ?<database>.?<tablename> -- 3
78450 ** REINDEX ?<database>.?<indexname> -- 4
78461 const char *zDb; /* Name of the database */
78462 Table *pTab; /* A table in the database */
78464 int iDb; /* The database index number */
78465 sqlite3 *db = pParse->db; /* The database connection */
78468 /* Read the database schema. If an error occurs, leave an error message
78514 ** with OP_OpenRead or OP_OpenWrite to access database index pIdx.
78622 ** If it is not NULL, then pColl must point to the database native encoding
78625 ** The return value is either the collation sequence to be used in database
78632 sqlite3* db, /* The database connection */
78660 ** a database is loaded that contains references to collation sequences
78666 ** from the main database is substituted, if one is available.
78699 sqlite3 *db, /* Database connection */
78739 ** for the encoding 'enc' from the database 'db'.
78875 sqlite3 *db, /* An open database */
79224 Vdbe *v; /* The virtual database engine */
79226 const char *zDb; /* Name of database holding pTab */
79232 sqlite3 *db; /* Main database structure */
79235 int iDb; /* Database number */
79380 ** database scan. We have to delete items after the scan is complete
79936 ** the database handle that malloc() has failed and return NULL.
80979 ** returns (void *)db, where db is the sqlite3* database pointer.
81267 ** with the database handle. The counter is set to zero each time a
81268 ** database transaction is opened. Each time a statement is executed
81271 ** the database, the counter is decremented. When the transaction is
81279 ** * If the database contains foreign key violations when the
81552 int iDb, /* Index of database housing pTab */
81703 sqlite3 *db = pParse->db; /* Database handle */
81828 ** the lookaside buffer belonging to database handle dbMem.
81843 ** being dropped from the database. The SrcList passed as the second argument
81852 ** constraint violations in the database,
81855 ** the table from the database. Triggers are disabled while running this
81925 sqlite3 *db = pParse->db; /* Database handle */
81928 int iDb; /* Index of database containing pTab */
81929 const char *zDb; /* Name of database containing pTab */
82184 sqlite3 *db = pParse->db; /* Database handle */
82451 int iDb, /* The database index in sqlite3.aDb[] */
82558 ** Return non-zero if the table pTab in database iDb or any of its indices
82601 ** which is in database iDb. Return the register number for the register
82621 int iDb, /* Index of the database holding pTab */
82653 sqlite3 *db = pParse->db; /* The database connection */
82654 Db *pDb; /* Database only autoinc table */
82754 int iDbDest /* The database of pDest */
82867 sqlite3 *db; /* The main database structure */
82870 const char *zDb; /* Name of the database holding this table */
82885 int iDb; /* Index of database holding TABLE */
82886 Db *pDb; /* The database containing table being inserted into */
84039 int iDbDest /* The database of pDest */
84046 int iDbSrc; /* The database of pSrc */
84291 sqlite3 *db, /* The database on which the SQL executes */
85214 sqlite3 *db, /* Load the extension into this database connection */
85294 sqlite3 *db, /* Load the extension into this database connection */
85308 ** Call this routine when the database connection is closing in order
85379 ** loaded by every new database connection.
85440 ** If anything goes wrong, set an error in the database connection.
85563 ** backed temporary databases, 2 for the Red-Black tree in memory database
85602 ** If the TEMP database is open, close it and mark the database schema
85767 ** PRAGMA [database.]id [= value]
85773 ** If the left side is "database.id" then pId1 is the database name
85779 Token *pId1, /* First part of [database.]id field */
85780 Token *pId2, /* Second part of [database.]id field, or NULL */
85786 const char *zDb = 0; /* The database name */
85788 int iDb; /* Database index for <database> */
85796 /* Interpret the [database.] part of the pragma statement. iDb is the
85797 ** index of the database this pragma is being applied to in db.aDb[]. */
85802 /* If the temp database has been explicitly named as part of the
85825 ** PRAGMA [database.]default_cache_size
85826 ** PRAGMA [database.]default_cache_size=N
85832 ** stored in the database file.
85874 ** PRAGMA [database.]page_size
85875 ** PRAGMA [database.]page_size=N
85878 ** database page size in bytes. The second form sets the
85879 ** database page size value. The value can only be set if
85880 ** the database has not yet been created.
85900 ** PRAGMA [database.]secure_delete
85901 ** PRAGMA [database.]secure_delete=ON/OFF
85925 ** PRAGMA [database.]max_page_count
85926 ** PRAGMA [database.]max_page_count=N
85929 ** maximum number of pages in the database file. The
85933 ** PRAGMA [database.]page_count
85935 ** Return the number of pages in the specified database.
85955 ** PRAGMA [database.]locking_mode
85956 ** PRAGMA [database.]locking_mode = (normal|exclusive)
85965 ** the locking-mode of the main database).
85971 /* This indicates that no database name was specified as part
86002 ** PRAGMA [database.]journal_mode
86003 ** PRAGMA [database.]journal_mode =
86011 ** database files to be opened and the journal_modes set. */
86050 ** PRAGMA [database.]journal_size_limit
86051 ** PRAGMA [database.]journal_size_limit=N
86069 ** PRAGMA [database.]auto_vacuum
86070 ** PRAGMA [database.]auto_vacuum=N
86072 ** Get or set the value of the database 'auto-vacuum' parameter.
86097 ** creates the database file. It is important that it is created
86103 ** "incremental", write the value of meta[6] in the database
86105 ** that this really is an auto-vacuum capable database.
86130 ** PRAGMA [database.]incremental_vacuum(N)
86132 ** Do N steps of incremental vacuuming on a database.
86155 ** PRAGMA [database.]cache_size
86156 ** PRAGMA [database.]cache_size=N
86160 ** the persistent cache size value that is stored in the database
86165 ** to its default value when the database is closed and reopened.
86186 ** value will be restored the next time the database is opened.
86254 ** PRAGMA [database.]lock_proxy_file
86255 ** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
86258 ** the value sets a specific file to be used for database access locks.
86296 ** PRAGMA [database.]synchronous
86297 ** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL
86301 ** default value will be restored the next time the database is
86536 ** integrity_check designed to detect most database corruption
86573 /* Do an integrity check on each database file */
86589 ** for all tables and indices in the database.
86613 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName),
86703 ** database. If the database is not initialized, it is initialized now.
86705 ** The second form of this pragma is a no-op if the main database file
86707 ** encoding that will be used for the main database file if a new file
86708 ** is created. If an existing main database file is opened, then the
86709 ** default text encoding for the existing database is used.
86712 ** created to use the same default text encoding as the main database. If
86713 ** the main database has not been initialized and/or created when ATTACH
86717 ** new database files created using this database handle. It is only
86718 ** useful if invoked immediately after the main database i
86747 /* Only change the value of sqlite.enc if the database handle is not
86748 ** initialized. If the main database exists, the new sqlite.enc value
86772 ** PRAGMA [database.]schema_version
86773 ** PRAGMA [database.]schema_version = <integer>
86775 ** PRAGMA [database.]user_version
86776 ** PRAGMA [database.]user_version = <integer>
86781 ** stored in the database header.
86784 ** is incremented by SQLite whenever the database schema is modified (by
86788 ** the database against which the compiled query is actually executed.
86791 ** crashes or database corruption. Use with caution!
86865 ** PRAGMA [database.]wal_checkpoint
86867 ** Checkpoint the database.
86878 ** Configure a database connection to automatically checkpoint a database
86903 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC);
86999 ** interface, and routines that contribute to loading the database schema
87005 ** that the database is corrupt.
87016 "malformed database schema (%s)", zObj);
87027 ** database. See sqlite3Init() below for additional information.
87112 ** Attempt to read the database schema and initialize internal
87113 ** data structures for a single database file. The index of the
87114 ** database file is given by iDb. iDb==0 is used for the main
87115 ** database. iDb==1 should never be used. iDb>=2 is used for
87133 ** The master database table has a structure like this
87164 ** and initialisation script appropriate for the database being
87193 /* Create a cursor to hold the database open
87204 ** on the b-tree database, open one now. If a transaction is opened, it
87216 /* Get the database meta information.
87238 /* If opening a non-empty database, check the text encoding. For the
87239 ** main database, set sqlite3.enc to the encoding of the main database.
87246 /* If opening the main database, set ENC(db). */
87252 /* If opening an attached database, the encoding much match ENC(db) */
87255 " text encoding as main database");
87289 /* Ticket #2804: When we open a database in the newer file format,
87291 ** not downgrade the database and thus invalidate any descending
87360 ** Initialize all database files - the main database file, the file
87361 ** used to store temporary tables, and any additional database files
87365 ** After a database is initialized, the DB_SchemaLoaded bit is set
87366 ** bit is set in the flags field of the Db structure. If the database
87385 ** for the TEMP database. This is loaded last, as the TEMP database
87407 ** This routine is a no-op if the database schema is already initialised.
87440 Btree *pBt = db->aDb[iDb].pBt; /* Btree database to read cookie from */
87444 ** on the b-tree database, open one now. If a transaction is opened, it
87455 /* Read the schema cookie from the database. If it does not match the
87472 ** which database file in db->aDb[] the schema refers to.
87474 ** If the same database is attached more than once, the first
87475 ** attached database is returned.
87506 sqlite3 *db, /* Database handle. */
87531 ** database schemas. The inability to get a read lock indicates that
87532 ** some other database connection is holding a write-lock, which in
87560 sqlite3Error(db, rc, "database schema is locked: %s", zDb);
87669 sqlite3 *db, /* Database handle. */
87741 sqlite3 *db, /* Database handle. */
87753 sqlite3 *db, /* Database handle. */
87771 sqlite3 *db, /* Database handle. */
87821 sqlite3 *db, /* Database handle. */
87833 sqlite3 *db, /* Database handle. */
88838 ** database table or a subquery.
89069 sqlite3 *db = pParse->db; /* Database connection */
89384 sqlite3 *db; /* Database connection */
90002 sqlite3 *db; /* Database connection */
90919 ** where table is a database table, not a sub-select or view. If the query
91537 sqlite3 *db; /* The database connection */
91731 ** Begin the database scan
91752 /* End the database scan loop.
92384 ** Query the database. But instead of invoking a callback for each row,
92394 sqlite3 *db, /* The database on which the SQL executes */
92511 ** All of the triggers on pTab that are in the same database as pTab
92568 sqlite3 *db = pParse->db; /* The database connection */
92569 int iDb; /* The database to store the trigger in */
92572 int iTabDb; /* Index of the database holding pTab */
92595 ** then set iDb to 1 to create the trigger in the temporary database.
92608 /* Ensure the table name matches database name and that the table exists */
92622 ** and the table is dropped by a different database connection, the
92623 ** trigger is not visible to the database connection that does the
92734 sqlite3 *db = pParse->db; /* The database */
92736 int iDb; /* Database containing the trigger */
92827 sqlite3 *db, /* Database connection */
92852 sqlite3 *db, /* The database connection */
92885 sqlite3 *db, /* The database connection */
92910 sqlite3 *db, /* Database connection */
92939 ** This function is called to drop a trigger from the database schema.
93019 /* Generate code to destroy the database record of the trigger.
93119 ** This routine adds a specific database name, if needed, to the target when
93120 ** forming the SrcList. This prevents a trigger in one database from
93121 ** referring to a target in another database. An exception is when the
93122 ** trigger is in TEMP in which case it can refer to any other database it
93129 int iDb; /* Index of the database to use */
93267 sqlite3 *db = pParse->db; /* Database handle */
93670 Vdbe *v; /* The virtual database engine */
93674 sqlite3 *db; /* The database structure */
93684 int iDb; /* Database containing the table being updated */
93744 /* Allocate a cursors for the main database table and for all indices.
93746 ** need to occur right after the database cursor. So go ahead and
93883 /* Begin the database scan
93898 /* End the database scan loop.
93990 ** the database after the BEFORE triggers are fired anyway (as the trigger
94183 sqlite3 *db = pParse->db; /* Database connection */
94274 ** Execute zSql on database db. Return an error code.
94292 ** Execute zSql on database db. The statement returns exactly
94293 ** one column. Execute this as SQL on the same database.
94314 ** The non-standard VACUUM command is used to clean up the database,
94319 ** gdbm_reorganize() on all the database tables. But beginning
94336 Btree *pMain; /* The database being vacuumed */
94337 Btree *pTemp; /* The temporary database we vacuum into */
94343 Db *pDb = 0; /* Database to detach at end of vacuum */
94344 int isMemDb; /* True if vacuuming a :memory: database */
94357 /* Save the current value of the database flags so that it can be
94371 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
94373 ** occurs anyway. The integrity of the database is maintained by a
94374 ** (possibly synchronous) transaction opened on the main database before
94399 /* The call to execSql() to attach the temp database has left the file
94407 /* A VACUUM cannot change the pagesize of an encrypted database. */
94418 /* Do not attempt to change the page size for a WAL database */
94445 /* Query the schema of the main database. Create a mirror schema
94446 ** in the temporary database.
94463 /* Loop through the tables in the main database. For each, do
94465 ** the contents to the temporary database.
94491 /* Copy the triggers, views, and virtual tables from the main database
94492 ** over to the temporary database. None of these objects has any
94506 ** transaction open on the vacuum database, but not on the main database.
94507 ** Open a btree level transaction on the main database. This allows a
94508 ** call to sqlite3BtreeCopyFile(). The main database btree level
94511 ** temporary database never needs to be committed.
94521 ** connections to the same database will know to reread the schema.
94563 ** database. No locks are held on any other files (since the main file
94566 ** vacuum database. The vacuum_db journal file is deleted when the pager
94606 sqlite3 *db, /* Database in which module is registered */
94648 sqlite3 *db, /* Database in which module is registered */
94660 sqlite3 *db, /* Database in which module is registered */
94718 ** database connections to be disconnected at the next opportunity.
94727 /* Assert that the mutex (if any) associated with the BtShared database
94731 ** database connection that may have an entry in the p->pVTable list. */
94765 ** associated with the database handle itself must be held.
94769 ** associated with the database the virtual table is stored in is held
94770 ** or, if the virtual table is stored in a non-sharable database, then
94771 ** the database handle mutex is held.
94801 ** The reference count of the VTable structure associated with database
94805 ** database connection.
94851 Token *pName1, /* Name of new table, or database name */
94855 int iDb; /* The database the table is being created in */
94857 sqlite3 *db; /* Database connection */
94908 sqlite3 *db = pParse->db; /* The database connection */
95176 ** of the virtual table named zTab in database iDb.
95279 ** of the virtual table named zTab in database iDb. This occurs
95439 sqlite3 *db, /* Database connection for reporting malloc problems */
96171 sqlite3 *db = pParse->db; /* Database connection */
96354 ** to "bitmap indices" in other database engines.
96367 sqlite3 *db = pParse->db; /* Database connection */
96629 sqlite3 *db = pParse->db; /* Database connection */
97743 Parse *pParse, /* Database connection */
98746 sqlite3 *db = pParse->db; /* Database handle */
99599 Vdbe *v = pParse->pVdbe; /* The virtual database engine */
99607 sqlite3 *db; /* Database connection */
99728 ** pWInfo->a[].iTabCur The VDBE cursor for the database table
99953 int iDb; /* Index of database containing table/index */
101013 26, /* DATABASE => ID */
101127 "DATABASE", "DESC", "DETACH", "EACH",
101492 /* 305 */ "database_kw_opt ::= DATABASE",
103374 /* (305) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==305);
103861 testcase( i==16 ); /* DATABASE */
104307 sqlite3 *db = pParse->db; /* The database connection */
105056 ** there are outstanding database connections or memory allocations or
105089 ** database connections or memory allocations. This routine is not
105115 /* Disable mutexing of database connections */
105246 ** Set up the lookaside buffers for a database connection.
105310 ** Return the mutex associated with a database connection.
105317 ** Configuration settings for an individual database connection
105415 ** Return the number of changes since the database handle was opened.
105423 ** database handle object, it does not close any savepoints that may be open
105455 ** Close an existing SQLite database
105569 /* The temp-database schema is allocated differently from the other schema
105572 ** the same sqliteMalloc() as the one that allocates the database
105588 ** Rollback all database files.
105628 /* SQLITE_ERROR */ "SQL logic error or missing database",
105632 /* SQLITE_BUSY */ "database is locked",
105633 /* SQLITE_LOCKED */ "database table is locked",
105635 /* SQLITE_READONLY */ "attempt to write a readonly database",
105638 /* SQLITE_CORRUPT */ "database disk image is malformed",
105640 /* SQLITE_FULL */ "database or disk is full",
105641 /* SQLITE_CANTOPEN */ "unable to open database file",
105644 /* SQLITE_SCHEMA */ "database schema has changed",
105651 /* SQLITE_FORMAT */ "auxiliary database format error",
105653 /* SQLITE_NOTADB */ "file is encrypted or is not a database",
105670 void *ptr, /* Database connection */
105728 ** This routine sets the busy callback for an Sqlite database to the
105746 ** This routine sets the progress callback for an Sqlite database to the
106045 sqlite3 *db, /* Attach the hook to this database */
106060 ** inserted or deleted using this database connection.
106063 sqlite3 *db, /* Attach the hook to this database */
106078 ** back by this database connection.
106081 sqlite3 *db, /* Attach the hook to this database */
106104 const char *zDb, /* Database */
106118 ** a database after committing a transaction if there are nFrame or
106143 ** into the write-ahead-log by this database connection.
106165 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
106182 sqlite3Error(db, SQLITE_ERROR, "unknown database: %s", zDb);
106195 ** Run a checkpoint on database iDb. This is a no-op if database iDb is
106198 ** If a transaction is open on the database being checkpointed, this
106203 ** The mutex on database handle db should be held by the caller. The mutex
106235 ** SQLITE_TEMP_STORE db->temp_store Location of temporary database
106325 ** sqlite3ApiExit(), to avoid setting the database handle error message.
106358 ** Create a new collating function for database "db". The name is zName
106538 ** This routine does the work of opening a database on behalf of
106539 ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
106543 const char *zFilename, /* Database filename UTF-8 encoded */
106544 sqlite3 **ppDb, /* OUT: Returned database handle */
106680 /* Open the backend database driver */
106695 /* The default safety_level for the main database is 'full'; for the temp
106696 ** database it is 'NONE'. This matches the pager layer defaults.
106709 ** database schema yet. This is delayed until the first time the database
106742 ** systems known to have never seen a pre-fts3 database.
106806 ** Open a new database handle.
106816 const char *filename, /* Database filename (UTF-8) */
106826 ** Open a new database handle.
106863 ** Register a new collation sequence with the database handle db.
106882 ** Register a new collation sequence with the database handle db.
106903 ** Register a new collation sequence with the database handle db.
106928 ** Register a collation sequence factory callback with the database handle
106946 ** Register a collation sequence factory callback with the database handle
106974 ** Test to see whether or not the database connection is in autocommit
106999 "database corruption at line %d of [%.10s]",
107032 ** Return meta information about a specific column of a database table.
107038 const char *zDbName, /* Database name or NULL */
107059 /* Ensure the database schema has been loaded */
107171 ** Invoke the xFileControl method on a particular database.
107284 ** an incompatible database file format. Changing the PENDING byte
107285 ** while any database connection is open results in undefined and
107353 ** Set the nReserve size to N for the main database on the database
107616 sqlite3Error(db, rc, (rc?"database is deadlocked":0));
107638 ** the transaction opened by database db has just finished. Locks held
107639 ** by database connection db have been released.
107751 ** This is called when the database connection passed as an argument is
108457 sqlite3 *db; /* The database connection */
108458 const char *zDb; /* logical database name */
108472 int nPgsz; /* Page size for host database */
108508 int nRowAvg; /* Average size of database rows, in pages */
108856 sqlite3 *db, /* Database in which to run SQL */
108948 sqlite3 *db = p->db; /* The database connection */
108997 ** Store the current database page-size in bytes in p->nPgsz.
109063 ** argv[1] -> database name
109069 sqlite3 *db, /* The SQLite database connection */
109085 int nDb; /* Bytes required to hold database name */
109217 ** database. TODO: For xConnect(), it could verify that said tables exist.
109223 /* Figure out the page-size for the database. This is required in order to
109224 ** estimate the cost of loading large doclists from the database (see
109252 sqlite3 *db, /* Database connection */
109262 sqlite3 *db, /* Database connection */
110454 ** prefix) from the database.
110460 ** in the database without the found length specifier at the start of on-disk
111418 ** hash-table to the database.
111437 ** the pending-terms hash-table have already been flushed into the database
111448 ** hash-table. Any changes made to the database are reverted by SQLite.
111626 ** function merges all segments in the database to a single segment.
111728 sqlite3 *db = p->db; /* Database connection */
111788 ** FTS3 enabled database connection is closed). It frees the memory
112832 ** with database connection db.
114294 ** Set up SQL objects in database db used to access the contents of
114304 ** comment above struct HashTableVtab) to the database schema. Both
114427 ** track such information in the database, then we'd only want this
114705 ** database. The internal details of this type are only accessed by the
115437 ** on the database file for longer than necessary). Thus, any virtual table
115665 int pgsz = p->nPgsz; /* Database page size */
115795 ** the contents of the pending-terms hash table to the database.
116148 ** the database contain two terms that share a prefix of almost 2KB,
116243 ** database. Then call this function recursively to write the parent of
116244 ** pTree and its peers to the database.
116246 ** Except, if pTree is a root node, do not write it to the database. Instead,
116250 ** set to the largest blockid written to the database (or zero if no
116378 /* The current leaf node is full. Write it out to the database. */
116386 ** to the database (still available in pWriter->zTerm), and
116457 ** database. This function must be called after all terms have been added
116469 sqlite3_int64 iLast = 0; /* Largest block id written to database */
116529 ** Set *pnSegment to the number of segments of level iLevel in the database.
116548 ** Set *pnSegment to the total number of segments in the database. Set
116549 ** *pnMax to the largest segment level in the database (segment levels
116680 ** of the pending-terms hash table to the database.
116738 ** comes about only when reading from an empty database.
116876 ** Merge all level iLevel segments in the database into a single
116879 ** currently present in the database.
116882 ** segment in the database, SQLITE_DONE is returned immediately.
116899 /* This call is to merge all segments in the database to a single
116901 ** greatest segment level currently present in the database. The index
117011 ** writes each term (along with its doclist) to the database via the
117025 ** database. Then delete the SegmentWriter and Fts3SegReader objects
117455 ** merge all segments in the database (including the new segment, if
117567 sqlite3_int64 nDoc; /* Number of docs in database */
119137 ** Database Format of R-Tree Tables
119261 sqlite3 *db; /* Host database connection */
119266 char *zDb; /* Name of database containing r-tree table */
119560 ** node contents out to the database.
119724 ** If the node is dirty, write it out to the database.
119750 ** count drops to zero, the node data is written to the database.
122057 ** using database connection db. If successful, the integer value returned
122086 ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size.
122087 ** This ensures that each node is stored on a single database page. If the
122088 ** database page-size is so large that more than RTREE_MAXCELLS entries
122092 sqlite3 *db, /* Database handle */
122125 ** argv[1] -> database name
122130 sqlite3 *db, /* Database connection */
122177 /* Create/Connect to the underlying relational database schema. If
122284 ** Register the r-tree module with database handle db. This creates the
122784 ** types to an SQLite database connection. It is intended to be called
122830 ** Register the ICU extension functions with database db.