Lines Matching defs:Schema
713 #define SQLITE_SCHEMA 17 /* The database schema changed */
2268 ** schema. ^The sole argument is a pointer to a constant UTF8 string
2269 ** which will become the new schema name in place of "main". ^SQLite
2270 ** does not make a copy of the new main schema name string, so the application
3025 ** schema change. Hence, the application should ensure that the
3032 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
3798 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
3817 ** a schema change, on the first [sqlite3_step()] call following any change
4310 ** ^(For example, given the database schema:
5749 ** and schema data structures between [database connection | connections]
5942 ** any errors are encountered while loading the schema.
6399 ** CAPI3REF: Declare The Schema Of A Virtual Table
7285 ** memory used to store the schema for all databases associated
7288 ** schema memory is shared with other database connections due to
8623 ** schema S in database connection D. ^On success, the
8626 ** If there is not already a read-transaction open on schema S when
8637 ** <li> Schema S of [database connection] D must be a [WAL mode] database.
8639 ** <li> There must not be a write transaction open on schema S of database
8651 ** whether or not a read transaction is opened on schema S is undefined.
8671 ** read transaction for schema S of
8679 ** the first operation following the [BEGIN] that takes the schema S
8681 ** ^In other words, schema S must not currently be in
8688 ** schema S is in [WAL mode]. A database connection might not know
9103 ** a database with a compatible schema using the [sqlite3changeset_apply()]
12049 ** The name of the schema table.
12129 typedef struct Schema Schema;
12541 SQLITE_PRIVATE int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);
13912 char *zDbSName; /* Name of this database. (schema name, not filename) */
13916 Schema *pSchema; /* Pointer to database schema (possibly shared) */
13920 ** An instance of the following structure stores a database schema.
13922 ** Most Schema objects are associated with a Btree. The exception is
13923 ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.
13924 ** In shared cache mode, a single Schema object can be shared by multiple
13927 ** Schema objects are automatically deallocated when the last Btree that
13928 ** references them is destroyed. The TEMP Schema is manually freed by
13932 ** to access Schema content. This implies that the thread must also be
13934 ** For a TEMP Schema, only the connection mutex is required.
13936 struct Schema {
13937 int schema_cookie; /* Database schema version number for this file */
13944 u8 file_format; /* Schema format version for this file */
13946 u16 schemaFlags; /* Flags associated with this schema */
13962 ** The DB_SchemaLoaded flag is set after the database schema has been
13966 ** have been filled out. If the schema changes, these column names might
13969 #define DB_SchemaLoaded 0x0001 /* The schema has been loaded */
13993 ** with a particular database connection. Hence, schema information cannot
13994 ** be stored in lookaside because in shared cache mode the schema information
13996 ** schema information, the Lookaside.bEnabled flag is cleared so that
13997 ** lookaside allocations are not used to construct the schema objects.
14237 #define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
14555 ** the database schema.
14557 ** If the database schema is shared, then there is one instance of this
14559 ** schema. This is because each database connection requires its own unique
14563 ** schema is shared, as the implementation often stores the database
14572 ** database schema are initially stored in a linked-list pointed to by
14580 ** schema is being reloaded for some reason), the VTable objects are not
14606 ** The schema for each SQL table and view is represented in memory
14634 char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */
14638 Schema *pSchema; /* Schema that contains this table */
14722 ** is held in Schema.fkeyHash with a hash key of Z.
14875 ** table as part of parsing an existing database schema), transient instances
14888 Schema *pSchema; /* Schema containing this index */
15070 ** Expr objects can use a lot of memory space in database schema. To
15314 Schema *pSchema; /* Schema to which this item is fixed */
15698 u8 checkSchema; /* Causes schema cookie check after an error */
15723 yDbMask cookieMask; /* Bitmask of schema verified databases */
15762 Token sNameToken; /* Token with unqualified schema object name */
15857 * Each trigger present in the database schema is stored as an instance of
15879 Schema *pSchema; /* Schema containing the trigger */
15880 Schema *pTabSchema; /* Schema containing the table */
15954 Schema *pSchema; /* Fix items to this schema */
16653 SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
16810 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
16811 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
18346 Table *pTab; /* Schema object being upated */
18693 ** to store the schema for all databases (main, temp, and any ATTACHed
18703 Schema *pSchema = db->aDb[i].pSchema;
58033 ** 40 4 Schema cookie
58034 ** 44 4 File format of schema layer
58296 ** schema associated with the database file are all contained within
58890 ** db->aDb[iDb].pSchema structure. The mutexes required for schema
58899 SQLITE_PRIVATE int sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *pSchema){
59041 ** Enable or disable the shared pager and schema features.
59092 ** function has to search through the database schema.
59095 ** hold a write-lock on the schema table (root page 1). This is also
59104 Schema *pSchema = (Schema *)pBtree->pBt->pSchema;
59118 /* If the client is reading or writing an index and the schema is
59150 ** write-lock on the schema table, or (if the client is reading) a
62118 ** consisting of a single page and no schema objects). Return SQLITE_OK
62901 ** rolled back modified the database schema. In this case b-tree root
67767 ** The schemaschema
68608 ** purposes (for example, to store a high-level schema associated with
68842 u32 iDestSchema; /* Original schema cookie in destination */
69261 /* Update the schema version field in the destination database. This
69262 ** is to make sure that the schema-version really does change in
69264 ** same schema version.
76525 ** schema change has occurred. That detail is handled by the
76655 ** sqlite3Step() to do most of the work. If a schema error occurs,
77266 ** as if there had been a schema change, on the first sqlite3_step() call
78757 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
80993 ** as the schema format is 2 or more and none of the omitted columns
81374 ** If P5!=0 then this opcode also checks the schema cookie against P3
81375 ** and the schema generation counter against P4.
81376 ** The cookie changes its value whenever the database schema changes.
81378 ** and that the current process needs to reread the schema. If the schema
81379 ** cookie in P3 differs from the schema cookie in the database header or
81380 ** if the schema generation counter in P4 differs from the current
81435 /* Gather the schema version number for checking:
81436 ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema
81437 ** version is checked to ensure that the schema has not changed since the
81448 p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
81449 /* If the schema-cookie from the database file matches the cookie
81450 ** stored with the in-memory representation of the schema, do
81451 ** not reload the schema from the database file.
81457 ** discard the database schema, as the user code implementing the
81475 ** P3==1 is the schema version. P3==2 is the database format.
81506 ** P2==1 is the schema version. P2==2 is the database format.
81525 /* When the schema cookie changes, record the new cookie internally */
81534 ** schema is changed. Ticket #1644 */
83820 ** schema consistent with what is on disk.
83833 ** schema consistent with what is on disk.
83846 ** schema consistent with what is on disk.
89382 Schema *pSchema = 0; /* Schema of the expression */
89396 /* Translate the schema name in zDb into a pointer to the corresponding
89397 ** schema. If not found, pSchema will remain NULL and nothing will match
92032 ** part of the in-memory representation of the database schema.
92453 ** an existing schema and 4 when processing a new statement. A bound
92458 ** malformed schema error.
92898 ** to NOT NULL constraints in the schema). If no NULL values are possible,
96176 const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
96180 ** that is not part of the temp-db schema, add a clause to the WHERE
96202 ** Argument zName is the name of the table in the database schema at
96222 /* Drop any table triggers from the internal schema. */
96230 /* Drop the table and index from the internal schema. */
96348 ** Then modify the schema cookie (since the ALTER TABLE modifies the
96349 ** schema). Open a statement transaction if the table is a virtual
96455 /* Drop and reload the internal table schema. */
96578 /* Make sure the schema version is at least 3. But do not upgrade
96591 /* Reload the schema of the modified table. */
96677 /* Begin a transaction and increment the schema cookie. */
98001 Schema *pSchema = db->aDb[iDb].pSchema; /* Schema of database iDb */
98067 /* Read the database schema. If an error occurs, leave an error message
98082 /* Analyze the schema named as the argument */
98539 Schema *pSchema = db->aDb[iDb].pSchema;
98712 /* Allocate the new entry in the db->aDb[] array and initialize the schema
98728 ** it to obtain the database schema. At this point the schema may
98808 /* If the file was opened successfully, read the schema for the new database.
99301 char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */
99335 Schema *pSchema, /* The schema of the expression */
99621 ** transaction on each used database and to verify the schema cookie
99631 Schema *pSchema;
99756 /* All mutexes are required for schema access. Make sure we hold them. */
99801 /* Read the database schema. If an error occurs, leave an error message
99812 /* If zName is the not the name of a table in the schema created using
99842 ** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be
99877 /* All mutexes are required for schema access. Make sure we hold them. */
99881 Schema *pSchema = db->aDb[j].pSchema;
99970 ** Reset the schema for the database at index iDb. Also reset the
99971 ** TEMP schema.
99977 /* Case 1: Reset the single schema identified by iDb */
99996 ** Erase all schema information from all attached databases (including
100049 ** contains lookaside memory. (Table objects in the schema do not use
100056 TESTONLY( int nLookaside; ) /* Used to verify lookaside not used for schema */
100058 /* Record the number of outstanding lookaside allocations in schema Tables
100059 ** prior to doing any free() operations. Since schema Tables do not use
100095 /* Verify that no lookaside memory was used by schema tables */
100244 ** unqualified name for a new schema object (table, index, view or
100313 /* Special case: Parsing the sqlite_master or sqlite_temp_master schema */
100907 ** Generate code that will increment the schema cookie.
100909 ** The schema cookie is used to determine when the schema for the
100910 ** database changes. After each schema change, the cookie value
100911 ** changes. When a process first reads the schema it records the
100913 ** it checks the cookie to make sure the schema has not changed
100917 ** the schema to change multiple times and for the cookie to be
100918 ** set back to prior value. But schema changes are infrequent
100923 ** the schema-version whenever the schema changes.
101118 ** internal schema data structures and the generated VDBE code so that they
101122 ** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
101130 ** schema to the rootpage from the main table.
101194 ** a database schema). */
101395 ** as a schema-lock must have already been obtained to create it. Since
101396 ** a schema-lock excludes all other database users, the write-lock would
101499 Schema *pSchema = p->pSchema;
101734 ** This function is called by the VDBE to adjust the internal schema
101777 ** Also write code to modify the sqlite_master table and internal schema
101806 ** Code to update the sqlite_master tables and internal schema definitions
101947 /* Remove the table entry from SQLite's internal schema and modify
101948 ** the schema cookie.
102404 ** if initialising a database schema.
102468 ** sqlite_master table (because some other process changed the schema) and
102788 ** table to parse the schema, or if this index is the PRIMARY KEY index
102842 /* Fill the index with data and reparse the schema. Code an OP_Expire
103506 ** Record the fact that the schema cookie will need to be verified
103507 ** for database iDb. The code to actually verify the schema cookie
103721 assert( sqlite3BtreeHoldsAllMutexes(db) ); /* Needed for schema access */
103756 /* Read the database schema. If an error occurs, leave an error message
104332 ** Free all resources held by the schema structure. The void* argument points
104333 ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the
104335 ** of the schema hash tables).
104337 ** The Schema.cache_size variable is not cleared.
104343 Schema *pSchema = (Schema *)p;
104368 ** Find and return the schema associated with a BTree. Create
104371 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
104372 Schema * p;
104374 p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);
104376 p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));
107311 ** search the schema for a unique index on the parent key columns.
107816 ** given the following schema:
107895 ** any modifications to the schema are made. This is because statement
107896 ** transactions are not able to rollback schema changes.
108060 ** schema items cannot be located, set an error in pParse and return
108302 ** the following schema:
108528 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
110255 /* Records with omitted columns are only allowed for schema format
112429 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
112435 #define PragFlg_SchemaOpt 0x40 /* Schema restricts name search if present */
112436 #define PragFlg_SchemaReq 0x80 /* Schema required - "main" is default */
113112 ** If the TEMP database is open, close it and mark the database schema
113282 ** PRAGMA [schema.]id [= value]
113294 Token *pId1, /* First part of [schema.]id field */
113295 Token *pId2, /* Second part of [schema.]id field, or NULL */
113315 /* Interpret the [schema.] part of the pragma statement. iDb is the
113384 /* Make sure the database schema is loaded if the pragma requires that */
113401 ** PRAGMA [schema.]default_cache_size
113402 ** PRAGMA [schema.]default_cache_size=N
113453 ** PRAGMA [schema.]page_size
113454 ** PRAGMA [schema.]page_size=N
113480 ** PRAGMA [schema.]secure_delete
113481 ** PRAGMA [schema.]secure_delete=ON/OFF
113506 ** PRAGMA [schema.]max_page_count
113507 ** PRAGMA [schema.]max_page_count=N
113518 ** PRAGMA [schema.]page_count
113537 ** PRAGMA [schema.]locking_mode
113538 ** PRAGMA [schema.]locking_mode = (normal|exclusive)
113583 ** PRAGMA [schema.]journal_mode
113584 ** PRAGMA [schema.]journal_mode =
113623 ** PRAGMA [schema.]journal_size_limit
113624 ** PRAGMA [schema.]journal_size_limit=N
113643 ** PRAGMA [schema.]auto_vacuum
113644 ** PRAGMA [schema.]auto_vacuum=N
113697 ** PRAGMA [schema.]incremental_vacuum(N)
113720 ** PRAGMA [schema.]cache_size
113721 ** PRAGMA [schema.]cache_size=N
113743 ** PRAGMA [schema.]cache_spill
113745 ** PRAGMA [schema.]cache_spill=N
113762 ** not just the schema specified.
113786 ** PRAGMA [schema.]mmap_size(N)
113930 ** PRAGMA [schema.]lock_proxy_file
113931 ** PRAGMA [schema.]lock_proxy_file = ":auto:"|"lock_file_path"
113966 ** PRAGMA [schema.]synchronous
113967 ** PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA
114007 /* Do not allow non-admin users to modify the schema arbitrarily */
114236 HashElem *k; /* Loop counter: Next table in schema */
114661 ** will be overwritten when the schema is next loaded. If it does not
114686 ** PRAGMA [schema.]schema_version
114687 ** PRAGMA [schema.]schema_version = <integer>
114689 ** PRAGMA [schema.]user_version
114690 ** PRAGMA [schema.]user_version = <integer>
114692 ** PRAGMA [schema.]freelist_count
114694 ** PRAGMA [schema.]data_version
114696 ** PRAGMA [schema.]application_id
114697 ** PRAGMA [schema.]application_id = <integer>
114700 ** the value of the schema-version and user-version, respectively. Both
114701 ** the schema-version and the user-version are 32-bit signed integers
114704 ** The schema-cookie is usually only manipulated internally by SQLite. It
114705 ** is incremented by SQLite whenever the database schema is modified (by
114706 ** creating or dropping a table or index). The schema version is used by
114708 ** of the schema used when compiling the SQL query matches the schema of
114711 ** the schema-version is potentially dangerous and may lead to program
114776 ** PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate
114832 ** PRAGMA schema.optimize
114833 ** PRAGMA schema.optimize(MASK)
114836 ** two forms, and only the specified schema is optimized in the latter two.
114883 int iDbLast; /* Loop termination point for the schema loop */
114885 HashElem *k; /* Loop over tables of a schema */
114886 Schema *pSchema; /* The current schema */
114887 Table *pTab; /* A table in the schema */
115103 char *azArg[2]; /* Value of the argument and schema */
115143 sqlite3StrAccumAppendAll(&acc, ",schema HIDDEN");
115408 ** interface, and routines that contribute to loading the database schema
115426 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
115523 ** Attempt to read the database schema and initialize internal
115548 /* Construct the in-memory representation schema tables (sqlite_master or
115552 ** the schema table as read-only. */
115594 ** meta[0] Schema cookie. Changes with each schema change.
115595 ** meta[1] File format of schema layer.
115679 /* Read the schema information out of the schema tables
115712 ** the schema loaded, even if errors occurred. In this situation the
115715 ** of the schema was loaded before the error occurred. The primary
115768 /* Once all the other databases have been initialized, load the schema
115770 ** schema may contain references to objects in other databases.
115791 ** This routine is a no-op if the database schema is already initialized.
115792 ** Otherwise, the schema is loaded. An error code is returned.
115810 ** Check schema cookies in all databases. If any cookie is out
115811 ** of date set pParse->rc to SQLITE_SCHEMA. If all schema cookies
115839 /* Read the schema cookie from the database. If it does not match the
115840 ** value stored as part of the in-memory schema representation,
115857 ** Convert a schema pointer into the iDb index that indicates
115858 ** which database file in db->aDb[] the schema refers to.
115863 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){
115932 ** to the schema.
115935 ** schema changes and if those schema changes are subsequently rolled
115937 ** prepared statement goes to run the schema cookie would fail to detect
115938 ** the schema change. Disaster would follow.
115942 ** is not possible for another thread to start a new schema change
115944 ** locks on the schema, we just need to make sure nobody else is
115948 ** but it does *not* override schema lock detection, so this all still
115958 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116090 ** Rerun the compilation of a statement after a schema change.
116129 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
116131 ** and the statement is automatically recompiled if an schema change
116217 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
116219 ** and the statement is automatically recompiled if an schema change
117793 ** column specific strings, in case the schema is reset before this
122224 ** triggers on pTab in the TEMP schema. This routine prepends all
122233 Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;
122660 ** This function is called to drop a trigger from the database schema.
123212 /* Sanity checking: The schema for the trigger and for the table are
123213 ** always defined. The trigger must be in the same schema as the table
124298 const char *zDbMain; /* Schema name of database to vacuum */
124310 ** restored before returning. Then set the writable-schema flag, and
124349 ** to read the schema was concluded. Unlock it here so that this doesn't
124398 /* Query the schema of the main database. Create a mirror schema
124459 ** The increment is used to increase the schema cookie so that other
124460 ** connections to the same database will know to reread the schema.
124463 BTREE_SCHEMA_VERSION, 1, /* Add one to the old schema cookie */
124742 ** objects without disturbing the rest of the Schema object (which may
124807 ** structure is associated with a single sqlite3* user of the schema.
124975 ** allows a schema that contains virtual tables to be loaded before
124979 Schema *pSchema = pTab->pSchema;
125093 const char *zFormat = "vtable constructor did not declare schema: %s";
125258 ** This function is used to set the schema of a virtual table. It is only
125704 ** the schema. */
132663 ** those objects, since there is no opportunity to add schema
135043 ** error while parsing a legacy schema.
140914 Schema *pSchema = db->aDb[i].pSchema;
141046 ** the pager rollback and schema reset an atomic operation. */
141063 /* Clear the TEMP schema separately and last */
141123 /* The temp-database schema is allocated differently from the other schema
141125 ** So it needs to be freed here. Todo: Why not roll the temp schema into
141156 ** modified the database schema. If the b-tree mutexes are not taken
141158 ** the database rollback and schema reset, which can cause false
141324 /* SQLITE_SCHEMA */ "database schema has changed",
142891 ** database schema yet. This is delayed until the first time the database
143299 /* Ensure the database schema has been loaded */
143774 ** Enable imposter mode only when the schema has already been parsed. Then
143776 ** the parsed schema. Then turn imposter mode back off again.
143778 ** If onOff==0 and tnum>0 then reset the schema for all databases, causing
143779 ** the schema to be reparsed the next time it is needed. This has the
143965 ** schema zDb of database db.
145821 ** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
146703 /* Declare the table schema to SQLite. */
151245 ** Schema of the terms table.
154581 ** comment above struct HashTableVtab) to the database schema. Both
154890 ** The table created has the following schema:
155014 ** Schema of the tokenizer table.
160834 ** tables. The schema of the virtual table being:
166965 /* Create/Connect to the underlying relational database schema. If
166967 ** the r-tree table schema.
170402 ** then the imposter table schema is:
170476 ** same schema as the actual target table (less any UNIQUE constraints).
170477 ** More precisely, the "same schema" means the same columns, types,
171693 ** Increment the schema cookie of the main database opened by p->dbMain.
171695 ** Or, if this is an RBU vacuum, set the schema cookie of the main db
171696 ** opened by p->dbMain to one more than the schema cookie of the main
171807 ** RBU vacuum operation, create the schema in the target db.
171868 ** when this handle was opened, create the target database schema. */
172121 ** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table
173529 " schema TEXT HIDDEN /* Database schema being analyzed */" \
173567 int iDb; /* Schema used for this query */
173647 ** scan. However, a schema=? constraint should cause this table to
173648 ** operate on a different database schema, so check for it.
173650 ** idxNum is normally 0, but will be 1 if a schema=? constraint exists.
173657 /* Look for a valid schema=? constraint. If found, change the idxNum to
174048 pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase);
174114 default: { /* schema */
175060 ** zThis, in schema zDb. It is expected that the table has nCol columns. If
176427 /* Check the table schema is still Ok. */
178259 /* If there is a schema mismatch on the current table, proceed to the
201606 ** or, for tables in the TEMP schema only.