Lines Matching refs:Table
1453 #define SQLITE_LOCKED 6 /* A table in the database is locked */
2864 ** the use of covering indices for full table scans in the query optimizer.
2868 ** The ability to disable the use of covering indices for full table scans
3138 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
3142 ** the most recent successful [INSERT] into a rowid table or [virtual table]
3152 ** Some virtual table implementations may INSERT rows into rowid tables as
3156 ** unintuitive results. Virtual table implementations that do write to rowid
3358 ** an attempt is made to access a database table associated with
3360 ** or process has the table locked.
3417 ** for a specified amount of time when a table is locked. ^The handler
3442 ** Definition: A <b>result table</b> is memory data structure created by the
3443 ** [sqlite3_get_table()] interface. A result table records the
3446 ** The table conceptually has a number of rows and columns. But
3447 ** these numbers are not part of the result table itself. These
3451 ** A result table is an array of pointers to zero-terminated UTF-8 strings.
3458 ** A result table might consist of one or more memory allocations.
3459 ** It is not safe to pass a result table directly to [sqlite3_free()].
3460 ** A result table should be deallocated using [sqlite3_free_table()].
3462 ** ^(As an example of the result table format, suppose a query result
3474 ** result table has 8 entries. Suppose the result table is stored
3490 ** string of its 2nd parameter and returns a result table to the
3494 ** it must pass the result table pointer to sqlite3_free_table() in order to
3576 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
3604 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
3616 ** table and column names into a constructed SQL statement.
3752 ** select random [ROWID | ROWIDs] when inserting new records into a table that
3811 ** a NULL value in place of the table column that would have
3814 ** columns of a table.
3815 ** ^When a table is referenced by a [SELECT] but no column values are
3816 ** extracted from that table (for example in a query like
3818 ** is invoked once for that table with a column name that is an empty string.
3901 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
3902 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
3903 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
3904 #define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
3905 #define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
3907 #define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
3909 #define SQLITE_DELETE 9 /* Table Name NULL */
3910 #define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
3911 #define SQLITE_DROP_TABLE 11 /* Table Name NULL */
3912 #define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
3913 #define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
3914 #define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
3916 #define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
3918 #define SQLITE_INSERT 18 /* Table Name NULL */
3920 #define SQLITE_READ 20 /* Table Name Column Name */
3923 #define SQLITE_UPDATE 23 /* Table Name Column Name */
3926 #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
3928 #define SQLITE_ANALYZE 28 /* Table Name NULL */
3929 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
3930 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
4279 ** <table border="1" align=center cellpadding=5>
4304 ** </table>
4512 ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
4518 ** <dd>The maximum number of columns in a table definition or in the
4836 ** that can be stored in a database table. SQLite uses dynamic typing
5106 ** WHERE clause constraints and the table content, it might return no rows.
5146 ** ^These routines provide a means to determine the database, table, and
5147 ** table column that is the origin of a particular result column in
5149 ** ^The name of the database or table or column can be returned as
5151 ** the database name, the _table_ routines return the table name, and
5160 ** database, table, and column.
5170 ** occurs. ^Otherwise, they return the name of the attached database, table,
5201 ** returned result set of that [SELECT] is a table column (not an
5202 ** expression or subquery) then the declared type of the table
5209 ** CREATE TABLE t1(c1 VARIANT);
5371 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5388 ** </table></blockquote>
5480 ** conversion automatically. ^(The following table details the conversions
5484 ** <table border="1">
5503 ** </table>
5804 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5827 ** against a virtual table.
5828 ** </table></blockquote>
5876 ** ^Within the [xUpdate] method of a [virtual table], the
6704 ** a [rowid table].
6709 ** row is updated, inserted or deleted in a rowid table.
6716 ** database and table name containing the affected row.
6885 ** CAPI3REF: Extract Metadata About A Column Of A Table
6889 ** information about column C of table T in database D
6897 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
6898 ** does not. If the table name parameter T in a call to
6905 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
6906 ** for the table using the same algorithm used by the database engine to
6907 ** resolve unqualified table references.
6909 ** ^The third and fourth parameters to this function are the table and column
6917 ** <table border="1">
6925 ** </table>
6932 ** ^If the specified table is actually a view, an [error code] is returned.
6934 ** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
6935 ** is not a [WITHOUT ROWID] table and an
6956 const char *zTableName, /* Table name */
7102 ** The interface to the virtual-table mechanism is currently considered
7106 ** When the virtual-table mechanism stabilizes, we will declare the
7111 ** Structures used by the virtual table interface
7119 ** CAPI3REF: Virtual Table Object
7120 ** KEYWORDS: sqlite3_module {virtual table module}
7122 ** This structure, sometimes called a "virtual table module",
7126 ** ^A virtual table module is created by filling in a persistent
7170 ** CAPI3REF: Virtual Table Indexing Information
7174 ** of the [virtual table] interface to
7176 ** method of a [virtual table module]. The fields under **Inputs** are the
7196 ** relevant to the particular virtual table being queried.
7201 ** The colUsed field indicates which columns of the virtual table may be
7202 ** required by the current scan. Virtual table columns are numbered from
7203 ** zero in the order in which they appear within the CREATE TABLE statement
7206 ** required by SQLite. If the table has at least 64 columns and any column
7217 ** virtual table and is not checked again by SQLite.)^
7230 ** to a linear scan of an SQLite table with N rows. A cost of log(N)
7232 ** binary search on a unique indexed field of an SQLite table with N rows.
7244 ** part of the same statement to delete or update a virtual table row and the
7254 ** If a virtual table extension is
7273 } *aConstraint; /* Table of WHERE clause constraints */
7298 ** CAPI3REF: Virtual Table Scan Flags
7303 ** CAPI3REF: Virtual Table Constraint Operator Codes
7308 ** a query that uses a [virtual table].
7326 ** CAPI3REF: Register A Virtual Table Implementation
7329 ** ^These routines are used to register a new [virtual table module] name.
7331 ** creating a new [virtual table] using the module and before using a
7332 ** preexisting [virtual table] for the module.
7337 ** the implementation of the [virtual table module]. ^The fourth
7339 ** into the [xCreate] and [xConnect] methods of the virtual table module
7340 ** when a new virtual table is be being created or reinitialized.
7366 ** CAPI3REF: Virtual Table Instance Object
7369 ** Every [virtual table module] implementation uses a subclass
7371 ** of the [virtual table]. Each subclass will
7384 const sqlite3_module *pModule; /* The module for this virtual table */
7387 /* Virtual table implementations will typically add additional fields */
7391 ** CAPI3REF: Virtual Table Cursor Object
7392 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
7394 ** Every [virtual table module] implementation uses a subclass of the
7396 ** [virtual table] and are used
7397 ** to loop through the virtual table. Cursors are created using the
7408 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
7409 /* Virtual table implementations will typically add additional fields */
7413 ** CAPI3REF: Declare The Schema Of A Virtual Table
7416 ** [virtual table module] call this interface
7423 ** CAPI3REF: Overload A Function For A Virtual Table
7427 ** using the [xFindFunction] method of the [virtual table module].
7437 ** by a [virtual table].
7442 ** The interface to the virtual-table mechanism defined above (back up
7447 ** When the virtual-table mechanism stabilizes, we will declare the
7471 ** in row iRow, column zColumn, table zTable in database zDb;
7497 ** <li> ^(Table zTable does not exist within database zDb)^,
7498 ** <li> ^(Table zTable is a WITHOUT ROWID table)^,
7500 ** <li> ^(Row iRow is not present in the table)^,
7517 ** different row of the same table using the [sqlite3_blob_reopen()]
7518 ** interface. However, the column, table, or database of a [BLOB handle]
7563 ** to a different row of the same database table. ^The new row is identified
7565 ** changed. ^The database, table and column on which the blob handle is open
7571 ** the nominated column.)^ ^If the new row is not present in the table, or if
8351 ** statements. For example, if the number of table steps greatly exceeds
8352 ** the number of table searches or result rows, that would tend to indicate
8353 ** that the prepared statement is using a full table scan rather than
8380 ** a table as part of a full table scan. Large numbers for this counter
8566 ** <table border=1 width=85% align=center>
8573 ** </table>
8904 ** shared-cache table, and more than one other connection currently holds
8905 ** a read-lock on the same table, then SQLite arbitrarily selects one of
8965 ** <b>The "DROP TABLE" Exception</b>
8969 ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement,
8974 ** invoked immediately. If the application then re-attempts the "DROP TABLE"
8980 ** the special "DROP TABLE/INDEX" case, the extended error code is just
9272 ** CAPI3REF: Virtual Table Interface Configuration
9275 ** of a [virtual table] implementation to configure
9276 ** various facets of the virtual table interface.
9279 ** xCreate virtual table method then the behavior is undefined.
9288 ** CAPI3REF: Virtual Table Configuration Options
9291 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
9298 ** where X is an integer. If X is zero, then the [virtual table] whose
9306 ** If X is non-zero, then the virtual table implementation guarantees
9316 ** Virtual table implementations that are required to handle OR REPLACE
9319 ** CONFLICT policy is REPLACE, the virtual table implementation should
9329 ** CAPI3REF: Determine The Virtual Table Conflict Policy
9332 ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The
9336 ** [virtual table].
9341 ** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
9344 ** method of a [virtual table], then it returns true if and only if the
9360 ** CAPI3REF: Determine The Collation For a Virtual Table Constraint
9363 ** method of a [virtual table].
9379 ** inform a [virtual table] implementation what the [ON CONFLICT] mode
9423 ** to a zero-terminated UTF-8 string containing the name of the index or table
9535 ** on a database table.
9559 ** table that is being modified.
9561 ** For an UPDATE or DELETE operation on a [rowid table], the sixth
9563 ** row being modified or deleted. For an INSERT operation on a rowid table,
9564 ** or any operation on a WITHOUT ROWID table, the value of the sixth
9565 ** parameter is undefined. For an INSERT or UPDATE on a rowid table the
9585 ** the table row before it is updated. The N parameter must be between 0
9594 ** the table row after it is updated. The N parameter must be between 0
9617 char const *zName, /* Table name */
10075 ** CAPI3REF: Attach A Table To A Session Object
10077 ** If argument zTab is not NULL, then it is the name of a table to attach
10079 ** made to the table while the session object is enabled will be recorded. See
10084 ** executing "CREATE TABLE" statements) after this call is made, changes for
10088 ** defined as part of their CREATE TABLE statement. It does not matter if the
10092 ** It is not an error if the named table does not exist in the database. Nor
10093 ** is it an error if the named table does not have a PRIMARY KEY. However,
10104 ** As of SQLite version 3.22.0, the "sqlite_stat1" table is an exception to
10107 ** CREATE TABLE sqlite_stat1(tbl,idx,stat)
10120 ** table. However, if the application calls sqlite3changeset_new(),
10127 ** changes made to the sqlite_stat1 table. Legacy versions of the
10129 ** sqlite_stat1 table that are part of a changeset or patchset.
10133 const char *zTab /* Table name */
10137 ** CAPI3REF: Set a table filter on a Session Object.
10141 ** to determine whether changes to the table's rows should be tracked or not.
10142 ** If xFilter returns 0, changes is not tracked. Note that once a table is
10149 const char *zTab /* Table name */
10165 ** each representing a change to a single row of an attached table. An INSERT
10190 ** single table are grouped together. In other words, when iterating through
10192 ** to a single table are processed before moving on to the next table. Tables
10195 ** a single table are stored is undefined.
10203 ** Once a table has been attached to a session object, the session object
10204 ** records the primary key values of all new rows inserted into the table.
10217 ** original values of other table columns (created when the users deletes
10234 ** the changeset. Or, if no such row is found in the table, a DELETE
10268 ** argument, this function attaches table zTbl in the same manner as the
10275 ** a table compatible with the table attached to the session by this function.
10276 ** A table is considered compatible if it:
10290 ** used to update the table in database zFrom (call this the "from-table")
10291 ** so that its content is the same as the table attached to the session
10292 ** object (call this the "to-table"). Specifically:
10295 ** <li> For each row (primary key) that exists in the to-table but not in
10296 ** the from-table, an INSERT record is added to the session object.
10298 ** <li> For each row (primary key) that exists in the to-table but not in
10299 ** the from-table, a DELETE record is added to the session object.
10312 ** required compatible table.
10353 ** a single table are grouped together, tables appear in the order in which
10372 ** an attached table is modified and then later on the original values
10405 ** that apply to a single table are grouped together. This means that when
10407 ** this function, all changes that relate to a single table are visited
10409 ** the applies to table X, then one for table Y, and then later on visit
10410 ** another change for table X.
10453 ** nul-terminated utf-8 encoded string containing the name of the table
10457 ** set to the number of columns in the table affected by the change. If
10471 const char **pzTab, /* OUT: Pointer to table name */
10472 int *pnCol, /* OUT: Number of columns in table */
10478 ** CAPI3REF: Obtain The Primary Key Definition Of A Table
10480 ** For each modified table, a changeset includes the following:
10483 ** <li> The number of columns in the table, and
10488 ** the table modified by the change that iterator pIter currently points to.
10490 ** nCol is the number of columns in the table. Elements of *pabPK are set to
10495 ** in the table.
10520 ** of columns in the table affected by the current change. Otherwise,
10550 ** of columns in the table affected by the current change. Otherwise,
10581 ** of columns in the table affected by the current change. Otherwise,
10774 ** <table border=1 style="margin-left:8ex;margin-right:8ex">
10814 ** </table>
10816 ** If the new changeset contains changes to a table that is already present
10818 ** primary key columns for the table must be consistent. If this is not the
10839 ** table are grouped together in the output of this function. Tables appear
10872 ** callback". If it is not NULL, then for each table affected by at least one
10874 ** the table name as the second argument, and a copy of the context pointer
10877 ** the table. Otherwise, if the return value is non-zero or the xFilter
10878 ** argument to this function is NULL, all changes related to the table are
10881 ** For each table that is not excluded by the filter callback, this function
10882 ** tests that the target database contains a compatible table. A table is
10886 ** <li> The table has the same name as the name recorded in the
10888 ** <li> The table has at least as many columns as recorded in the
10890 ** <li> The table has primary key columns in the same position as
10894 ** If there is no compatible table, it is not an error, but none of the
10895 ** changes associated with the table are applied. A warning message is issued
10897 ** one such warning is issued for each table in the changeset.
10899 ** For each change for which there is a compatible table, an attempt is made
10900 ** to modify the table contents according to the UPDATE, INSERT or DELETE
10934 ** database table has more columns than are recorded in the changeset,
10936 ** the current database contents - any trailing database table columns
10953 ** database table, the trailing fields are populated with their default
10996 ** table that the callback related to, from within the xConflict callback.
11012 const char *zTab /* Table name */
11124 ** <table border=1 style="margin-left:8ex;margin-right:8ex">
11132 ** </table>
11213 const char *zTab /* Table name */
11303 ** Virtual table implementations may overload SQL functions by implementing
11333 ** to the total number of tokens in the FTS5 table. Or, if iCol is
11334 ** non-negative but less than the number of columns in the table, return
11336 ** the FTS5 table.
11339 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
11344 ** Return the number of columns in the table.
11349 ** non-negative but less than the number of columns in the table, set
11353 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
11357 ** This function may be quite inefficient if used with an FTS5 table
11380 ** This API can be quite slow if used with an FTS5 table created with the
11381 ** "detail=none" or "detail=column" option. If the FTS5 table is created
11383 ** (i.e. if it is a contentless table), then this API always returns 0.
11393 ** first token of the phrase. The exception is if the table was created
11400 ** This API can be quite slow if used with an FTS5 table created with the
11407 ** Tokenize text using the tokenizer belonging to the FTS5 table.
11410 ** This API function is used to query the FTS table for phrase iPhrase
11472 ** This function is used to retrieve the total number of rows in the table.
11499 ** This API can be quite slow if used with an FTS5 table created with the
11500 ** "detail=none" or "detail=column" option. If the FTS5 table is created
11502 ** (i.e. if it is a contentless table), then this API always iterates
11524 ** This API can be quite slow if used with an FTS5 table created with the
11525 ** "detail=none" option. If the FTS5 table is created with either
11526 ** "detail=none" "content=" option (i.e. if it is a contentless table),
11599 ** tokenizer name as part of the CREATE VIRTUAL TABLE statement used
11600 ** to create the FTS5 table.
11624 ** or removed from the FTS table. The tokenizer is being invoked to
11884 ** limits the size of a row in a table or index.
11896 ** * Columns in a table
11906 ** not have more than a dozen or so columns in any table. And if
11968 ** the main database table and for temporary tables.
12444 ** This is the header file for the generic hash-table implementation
12454 /* A complete hash table is an instance of the following structure.
12462 ** All elements of the hash table are on a single doubly-linked list.
12471 ** Hash.ht table is never allocated because if there are few elements
12472 ** in the table, it is faster to do a linear search than to manage
12473 ** the hash table.
12476 unsigned int htsize; /* Number of buckets in the hash table */
12477 unsigned int count; /* Number of entries in this table */
12479 struct _ht { /* the hash table */
12485 /* Each element in the hash table is an instance of the following
12492 HashElem *next, *prev; /* Next and previous elements in the table */
12506 ** Macros for looping over all elements of a hash table. The idiom is
12524 ** Number of entries in a hash table
12917 ** table or index. This is an unsigned integer type. For 99.9% of
13142 ** Name of the master database table. The master database table
13143 ** is a special table that holds the names and attributes of all
13150 ** The root-page of the master database table.
13155 ** The name of the schema table.
13261 typedef struct Table Table;
13396 ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.
13397 ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data
13403 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
13404 #define BTREE_BLOBKEY 2 /* Table has keys only - no data */
13506 ** the main table row automatically deletes corresponding index rows,
13516 Btree*, /* BTree containing table to open */
13548 ** entry in either an index or table btree.
13554 ** Table btrees (used for rowid tables) contain an integer rowid used as
13731 Table *pTab; /* Used when p4type is P4_TABLE */
13786 #define P4_TABLE (-6) /* P4 is a pointer to a Table structure */
15075 Hash fkeyHash; /* All foreign keys by referenced table name */
15076 Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
15149 ** A hash table for built-in function definitions. (Application-defined
15150 ** functions use a regular table table from hash.h.)
15157 FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */
15248 int newTnum; /* Rootpage of table being initialized */
15252 u8 imposterTable; /* Building an imposter table */
15307 Hash aFunc; /* Hash table of connection functions */
15395 #define DBFLAG_SchemaChange 0x0001 /* Uncommitted Hash table changes */
15448 ** structure is held in the db->aHash hash table.
15609 ** Each SQLite module (virtual table definition) is defined by an
15611 ** hash table.
15618 Table *pEpoTab; /* Eponymous table for this module */
15622 ** information about each column of an SQL table is held in an instance
15638 #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
15709 ** An object of this type is created for each virtual table present in
15715 ** instance of the sqlite3_vtab* handle used to access the virtual table
15721 ** then be used by the virtual table implementation to access real tables
15724 ** connection as that used to execute SQL operations on the virtual table.
15726 ** All VTable objects that correspond to a single table in a shared
15728 ** the Table.pVTable member variable of the corresponding Table object.
15730 ** table, it searches the list for the VTable that corresponds to the
15734 ** When an in-memory Table object is deleted (for example when the
15737 ** immediately. Instead, they are moved from the Table.pVTable list to
15751 sqlite3 *db; /* Database connection associated with this table */
15761 ** The schema for each SQL table and view is represented in memory
15764 struct Table {
15765 char *zName; /* Name of the table or view */
15767 Index *pIndex; /* List of SQL indexes on this table. */
15769 FKey *pFKey; /* Linked list of all foreign keys in this table */
15773 int tnum; /* Root BTree page for this table */
15774 u32 nTabRef; /* Number of pointers to this Table */
15777 i16 nCol; /* Number of columns in this table */
15778 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
15779 LogEst szTabRow; /* Estimated size of each table row in bytes */
15781 LogEst costMult; /* Cost multiplier for using this table */
15785 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
15793 Schema *pSchema; /* Schema that contains this table */
15794 Table *pNextZombie; /* Next on the Parse.pZombieTab list */
15798 ** Allowed values for Table.tabFlags.
15801 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
15806 #define TF_Readonly 0x0001 /* Read-only system table */
15807 #define TF_Ephemeral 0x0002 /* An ephemeral table */
15808 #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
15819 ** Test to see whether or not a table is a virtual table. This is
15821 ** table support is omitted from the build.
15847 /* Does the table have a rowid */
15854 ** A foreign key is associated with two tables. The "from" table is
15855 ** the table that contains the REFERENCES clause that creates the foreign
15856 ** key. The "to" table is the table that is named in the REFERENCES clause.
15859 ** CREATE TABLE ex1(
15864 ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2".
15867 ** from-table == child-table
15868 ** to-table == parent-table
15871 ** which is attached to the from-table. The to-table need not exist when
15872 ** the from-table is created. The existence of the to-table is not checked.
15874 ** The list of all parents for child Table X is held at X.pFKey.
15876 ** A list of all children for a table named Z (which might not even exist)
15880 Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */
15882 char *zTo; /* Name of table that the key points to (aka: Parent) */
15915 ** referenced table row is propagated into the row that holds the
15960 ** Records are used to store the content of a table row and to store
16006 ** The columns of the table that are to be indexed are described
16008 ** we have the following table and index:
16010 ** CREATE TABLE Ex1(c1 int, c2 int, c3 text);
16013 ** In the Table structure describing Ex1, nCol==3 because there are
16014 ** three columns in the table. In the Index structure describing
16028 ** While parsing a CREATE TABLE or CREATE INDEX statement in order to
16030 ** table as part of parsing an existing database schema), transient instances
16040 Table *pTable; /* The SQL table being indexed */
16042 table */
16076 #define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
16091 ** Each sample stored in the sqlite_stat3 table is represented in memory
16133 ** than the source table */
16135 int sortingIdxPTab; /* Cursor number of pseudo-table */
16140 Table *pTab; /* Source table */
16141 int iTable; /* Cursor number of the source table */
16142 int iColumn; /* Column number within the source table */
16155 int iDistinct; /* Ephemeral table used to enforce DISTINCT */
16202 ** An expression of the form ID or ID.ID refers to a column in a table.
16204 ** the integer cursor number of a VDBE cursor pointing to that table and
16220 ** If the Expr is of type OP_Column, and the table it is selecting from
16221 ** is a disk table or the "old.*" pseudo-table, then pTab points to the
16222 ** corresponding table definition.
16268 int iTable; /* TK_COLUMN: cursor number of table holding column
16277 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
16282 Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
16367 ** of the result column in the form: DATABASE.TABLE.COLUMN. This later
16378 unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
16399 ** column names after a table name in an INSERT statement. In the statement
16403 ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
16408 int idx; /* Index in some Table.aCol[] of a column named zName */
16440 ** Each table or subquery in the FROM clause is a separate element of
16444 ** can also be used to describe a particular table such as the table that
16446 ** such a table must be a simple name: ID. But in SQLite, the table can
16447 ** now be identified by a database name, a dot, then the table name: ID.ID.
16449 ** The jointype starts out showing the join type between the current table
16450 ** and the next table on the list. The parser builds the list this way.
16452 ** jointype expresses the join between the table and the previous table.
16454 ** In the colUsed field, the high-order bit (bit 63) is set if the table
16462 char *zDatabase; /* Name of database holding this table */
16463 char *zName; /* Name of the table */
16465 Table *pTab; /* An SQL table corresponding to zName */
16466 Select *pSelect; /* A SELECT statement used in place of a table name */
16471 u8 jointype; /* Type of join between this table and the previous */
16474 unsigned isTabFunc :1; /* True if table-valued-function syntax */
16482 int iCursor; /* The VDBE cursor number used to access this table */
16488 ExprList *pFuncArg; /* Arguments to table-valued-function */
16525 #define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */
16540 ** A NameContext defines a context in which to resolve table and column
16544 ** to the table being operated on by INSERT, UPDATE, or DELETE. The
16646 #define SF_HasTypeInfo 0x00080 /* FROM subqueries have Table metadata */
16689 ** row of result as the key in table pDest->iSDParm.
16693 ** SRT_EphemTab Create an temporary table pDest->iSDParm and store
16697 ** the table first.
16705 table pDest->iSDParm.
16706 ** SRT_Fifo This is like SRT_EphemTab except that the table
16711 ** SRT_DistFifo Store results in a temporary table pDest->iSDParm.
16712 ** But also use temporary table pDest->iSDParm+1 as
16758 ** tables, the following information is attached to the Table.u.autoInc.p
16759 ** pointer of each autoincrement table to record some side information that
16760 ** the code generator needs. We have to keep per-table autoincrement
16767 Table *pTab; /* Table this info block refers to */
16836 ** used to store the set of table-locks required by the statement being
16862 int iSelfTab; /* Table associated with an index on expr, or negative
16872 int regRowid; /* Register holding rowid of CREATE TABLE entry */
16881 TableLock *aTableLock; /* Required table locks for shared-cache mode */
16885 Table *pTriggerTab; /* Table triggers are being coded for */
16886 int addrCrTab; /* Address of OP_CreateBtree opcode on CREATE TABLE */
16902 int iTable; /* Table cursor number */
16903 i16 iColumn; /* Table column number */
16935 Table *pNewTable; /* A table being constructed by CREATE TABLE */
16940 Table **apVtabLock; /* Pointer to virtual tables needing locking */
16942 Table *pZombieTab; /* List of Table objects to delete after code gen */
17010 * 1. In the "trigHash" hash table (part of the sqlite3* that represents the
17012 * 2. All triggers associated with a single table form a linked list, using the
17015 * struct Table.
17022 char *table; /* The table or view to which the trigger applies */
17029 Schema *pTabSchema; /* Schema containing the table */
17031 Trigger *pNext; /* Next trigger associated with the table */
17061 * zTarget -> Dequoted name of the table to insert into.
17069 * zTarget -> Dequoted name of the table to delete from.
17074 * zTarget -> Dequoted name of the table to update.
17087 char *zTarget; /* Target table for DELETE, UPDATE, INSERT */
17270 ** (common table expressions) created by a single WITH clause.
17332 ** FTS3 and FTS4 both require virtual table support
17554 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
17556 SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);
17557 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
17559 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
17563 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
17604 SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse*,Table*);
17613 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);
17614 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);
17645 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
17646 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
17647 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
17667 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
17668 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);
17669 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
17692 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
17695 SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
17696 SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);
17737 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
17738 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
17741 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
17744 SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*);
17748 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
17749 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
17755 SQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*);
17776 SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
17785 SQLITE_PRIVATE Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
17786 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *, Table *);
17787 SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
17789 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
17790 void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
17802 SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
17888 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
17891 SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int);
17968 SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
17970 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
18073 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table*);
18074 SQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p);
18083 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
18095 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
18101 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
18136 SQLITE_PRIVATE void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);
18137 SQLITE_PRIVATE void sqlite3FkDropTable(Parse*, SrcList *, Table*);
18138 SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);
18139 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
18140 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
18141 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
18151 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
18152 SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
18181 #define IN_INDEX_ROWID 1 /* Search the rowid of the table */
18185 #define IN_INDEX_NOOP 5 /* No table available. Use comparisons */
18379 ** The following 256 byte lookup table is used to support SQLites built-in
18563 ** Hash table for global functions - functions common to all
18564 ** database connections. After initialization, this table is
18702 ** - On either an index or a table
18704 ** * A virtual table
18718 Bool isEphemeral:1; /* True for an ephemeral table */
18720 Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
18721 Btree *pBtx; /* Separate file holding temporary table */
18723 int *aAltMap; /* Mapping from table to index column numbers */
18972 char *zName; /* Name of table or index */
19074 Table *pTab; /* Schema object being upated */
19139 SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);
19479 sqlite3DeleteTable(db, (Table *)sqliteHashData(p));
20168 ** The following table defines various date transformations of the form
21251 ** fatal. For example, if a malloc fails while resizing a hash table, this
21253 ** hash table will continue to function normally. So a malloc failure
21254 ** during a hash table resize is a benign fault.
22406 ** small chunk list, or into the large chunk hash table.
22577 ** chunk table or in the large chunk hash table. This is
25925 ** The following table is searched linearly, so it is good to put the
27408 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
27409 ** is set to the column of the pseudo-table to read, or to -1 to
27982 ** This lookup table is used to help decode the first byte of
30103 /* Turn bulk memory into a hash table object by initializing the
30106 ** "pNew" is a pointer to the hash table that is to be initialized.
30116 table. Reclaim all memory.
30117 ** Call this routine to delete a hash table or to reset a hash table
30121 HashElem *elem; /* For looping over all elements of the table */
30154 /* Link pNew element into the hash table pH. If pEntry!=0 then also
30158 Hash *pH, /* The complete hash table */
30185 /* Resize the hash table so that it cantains "new_size" buckets.
30187 ** The hash table might fail to resize if sqlite3_malloc() fails or
30192 struct _ht *new_ht; /* The new hash table */
30202 /* The inability to allocates space for a larger hash table is
30207 ** use the actual amount of space allocated for the hash table (which
30228 ** hash table that matches the given key. If no element is found,
30264 /* Remove a single entry from the hash table given a pointer to that
30298 /* Attempt to locate an element of the hash table pH with a key
30308 /* Insert an element into the hash table pH. The key is pKey
30317 ** the new data is returned and the hash table is unchanged.
30320 ** element corresponding to "key" is removed from the hash table.
30323 unsigned int h; /* the hash of the key modulo hash table size */
44799 ** But sometimes (for example when during a DROP of a large table) most
44839 /* Number of u32 values in hash table. */
44841 /* Maximum number of entries in hash table before
44864 ** a hash table that will hold up to BITVEC_MXHASH distinct values.
44885 u32 aHash[BITVEC_NINT]; /* Hash table representation */
45018 ** that BitvecClear can use to rebuilt its hash table.
46169 PgHdr1 *pNext; /* Next in hash table chain */
46238 /* Hash table of all pages. The following variables may only be accessed
46244 PgHdr1 **apHash; /* Hash table for fast lookup by key */
46585 ** This function is used to resize the hash table used by the cache passed
46649 ** Remove the page supplied as an argument from the hash table
46709 ** cache, then there is no point in scanning the entire hash table.
46717 ** It is necessary to scan the entire hash table */
47056 /* Step 1: Search the hash table for an existing entry. */
47060 /* Step 2: If the page was found in the hash table, then return it.
47061 ** If the page was not in the hash table and createFlag is 0, abort.
50764 ** in this case. But for things like temporary table (which will be
55784 ** database page number associated with each wal frame, and a hash-table
55799 ** Even without using the hash table, the last frame for page P
55806 ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
55808 ** hash table for each page number in the mapping section, so the hash
55809 ** table is never more than half full. The expected number of collisions
55810 ** prior to finding a match is 1. Each entry of the hash table is an
55815 ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table
55818 ** To look for page P in the hash table, first compute a hash iKey on
55823 ** Then start scanning entries of the hash table, starting with iKey
55824 ** (wrapping around to the beginning when the end of the hash table is
55827 ** wrap-around.) Because the hash table is never more than half full,
55851 ** Both readers can use the same hash table and mapping section to get
55852 ** the correct result. There may be entries in the hash table with
55854 ** slots in the hash table and so the first reader will get an answer as
55855 ** if no values greater than K0 had ever been inserted into the hash table
55860 ** When a rollback occurs, the value of K is decreased. Hash table entries
55862 ** from the hash table at this point.
56104 ** Each page of the wal-index mapping contains a hash-table made up of
56138 ** is a hash-table following every HASHTABLE_NPAGE page numbers in the
56149 ** The block of page numbers associated with the first hash-table in a
56151 ** hash-table on each aligned 32KB page of the wal-index.
56488 ** Return pointers to the hash table and page number array stored on
56492 ** Set output variable *paHash to point to the start of the hash table
56494 ** number of the first frame indexed by this hash table. If a
56495 ** slot in the hash table is set to N, it refers to frame number
56499 ** first frame indexed by the hash table, frame (*piZero+1).
56503 int iHash, /* Find the iHash'th table */
56534 ** Return the number of the wal-index page that contains the hash-table
56562 ** Remove entries from the hash table that point to WAL slots greater
56568 ** At most only the hash table containing pWal->hdr.mxFrame needs to be
56574 volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
56575 volatile u32 *aPgno = 0; /* Page number array for hash table */
56588 /* Obtain pointers to the hash-table and page-number array containing
56590 ** that the page said hash-table and array reside on is already mapped.
56596 /* Zero all hash-table entries that correspond to frame numbers greater
56615 ** via the hash table even after the cleanup.
56639 volatile ht_slot *aHash = 0; /* Hash table */
56644 ** page number array and hash table entry.
56647 int iKey; /* Hash table key */
56648 int idx; /* Value to write to hash-table slot */
56654 /* If this is the first entry to be added to this hash-table, zero the
56655 ** entire hash table and aPgno[] array before proceeding.
56666 ** the hash-table before writing any new entries.
56673 /* Write the aPgno[] array entry and the hash-table slot. */
56682 /* Verify that the number of entries in the hash table exactly equals
56687 int nEntry = 0; /* Number of entries in the hash table */
56693 ** via the hash table. This turns out to be a really, really expensive
58462 /* Search the hash table or tables for an entry matching page number
58464 ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
58468 ** table). This means the value just read from the hash
58478 ** if we had exclusive access to the hash-table:
58481 ** This condition filters out normal hash-table collisions.
58485 ** table after the current read-transaction had started.
58489 volatile ht_slot *aHash; /* Pointer to hash table */
59695 u8 intKey; /* True if table b-trees. False for index b-trees */
59696 u8 intKeyLeaf; /* True if the leaf of an intKey table */
59727 ** is opened on the table with root page BtShared.iTable. Locks are removed
59733 Pgno iTable; /* Root page of table */
59811 ** table (because there exists one or more read-locks on the table),
59845 u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */
59846 u16 minLeaf; /* Minimum local payload in a LEAFDATA table */
59963 ** because the table is empty or because BtreeCursorFirst() has not been
59975 ** The table that this cursor was opened on still exists, but has been
60019 ** The pointer map is a lookup table that identifies the parent page for
60283 ** a statement since we will be comparing table and column names
60521 ** shared-cache table level locks. If the library is compiled with the
60569 ** table with root page iRoot. Return 1 if it does and 0 if not.
60571 ** For example, when writing to a table with root-page iRoot via
60578 ** the corresponding table. This makes things a bit more complicated,
60579 ** as this module treats each table as a separate structure. To determine
60580 ** the table corresponding to the index being written, this
60583 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
60584 ** hold a write-lock on the schema table (root page 1). This is also
60616 /* Figure out the root-page that the lock should be held on. For table
60619 ** table. */
60639 ** write-lock on the schema table, or (if the client is reading) a
60660 ** table or index rooted at iRoot because other shared connections are
60661 ** simultaneously reading that same table or index.
60665 ** the iRoot table. Except, if the other Btree object has the
60669 ** For example, before writing to any part of the table or index
60690 ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return
60730 ** may hold a WRITE_LOCK on any table in this file (since there can
60750 ** Add a lock on the table with root-page iTable to the shared-btree used
60778 ** table, and that lock is obtained in BtreeBeginTrans(). */
60786 /* First search the list for an existing lock on this table. */
60795 ** with table iTable, allocate one and link it into the list.
60823 ** Release all the table locks (locks obtained via calls to
60937 ** This function is called before modifying the contents of a table
60942 ** table is about to be deleted. In this case invalidate all incrblob
60943 ** cursors open on any row within the table with root-page pgnoRoot.
60951 Pgno pgnoRoot, /* The table that might be changing */
61066 ** If the cursor is open on an intkey table, then the integer key
61068 ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
61079 /* Only the rowid is required for a table btree */
61136 ** the table with root-page iRoot. "Saving the cursor position" means that
61140 ** table, for example in BtreeDelete() or BtreeInsert().
61534 ** btreeParseCellPtr() => table btree leaf nodes
61535 ** btreeParseCellNoPayload() => table btree internal nodes
61681 ** cellSizePtrNoPayload() => table internal nodes
61682 ** cellSizePtr() => all index nodes & table leaf nodes
62204 ** interior table b-tree page. */
62207 ** leaf table b-tree page. */
62299 ** possible for a root page of a table that contains no rows) then the
63067 ** The call to sqlite3BtreeRollback() drops any table-locks held by
64643 ** cursors open with wrFlag==0 on the same table. Otherwise
64656 ** in which index entries are automatically deleted when corresponding table
64670 int iTable, /* Root page of table to open */
64685 ** b-tree database, the connection is holding the required table locks,
64730 int iTable, /* Root page of table to open */
64831 ** that is currently pointing to a row in a (non-empty) table.
64844 ** Return the value of the integer key or "rowid" for a table btree.
64846 ** ordinary table btree. If the cursor points to an index btree or
64873 ** currently pointing to. For table btrees, this will be the amount
65016 ** invalidated if some other cursor writes to the same table, or if
65022 ** * Creating a table (may require moving an overflow page).
65215 ** pCur can be pointing to either a table or an index b-tree.
65216 ** If pointing to a table btree, then the content section is read. If
65220 ** to a valid row in the table. For sqlite3BtreePayloadChecked(), the
65269 ** table btrees (pPage->intKey==1). The number of bytes of available
65409 ** If the table has a virtual root page, then the cursor is moved to point
65410 ** to the virtual root page instead of the actual root page. A table has a
65412 ** single child page. This can only happen with the table rooted at page 1.
65423 ** indicating a table b-tree, or if the caller did specify a KeyInfo
65473 ** NULL, the caller expects a table b-tree. If this is not the case,
65479 ** in such a way that page pRoot is linked into a second b-tree table
65558 /* Move the cursor to the first entry in the table. Return SQLITE_OK
65560 ** or set *pRes to 1 if the table is empty.
65580 /* Move the cursor to the last entry in the table. Return SQLITE_OK
65582 ** or set *pRes to 1 if the table is empty.
65641 ** is smaller than intKey/pIdxKey or if the table is empty
65651 ** exists an entry in the table that exactly matches pIdxKey.
65656 i64 intKey, /* The table key */
65740 ** be the right kind (index or table) of b-tree page. Otherwise
65896 ** Return TRUE if the cursor is not pointing at an entry of the table.
65899 ** past the last entry in the table or sqlite3BtreePrev() moves past
65900 ** the first entry. TRUE is also returned if the table is empty.
65903 /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
65911 ** Return an estimate for the number of rows in the table that pCur is
66045 ** SQLITE_DONE the cursor is already on the first element of the table
67808 /* Verify that all sibling pages are of the same "type" (table-leaf,
67809 ** table-interior, index-leaf, or index-interior).
68049 ** of the table is closer to a linear scan through the file. That in turn
68561 ** define what table the record should be inserted into, and is left
68564 ** For a table btree (used for rowid tables), only the pX.nKey value of
68589 BtCursor *pCur, /* Insert data into the table of this cursor */
68620 ** intkey table, the caller should be inserting integer keys with a
68624 /* Save the positions of any other cursors open on this table.
68627 ** example, when inserting data into a table with auto-generated integer
68642 /* If this is an insert into a table b-tree, invalidate any incrblob
68683 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
68752 ** entry in the table, and the next row inserted has an integer key
68799 ** associated with a single table entry and its indexes. Only one of those
68868 /* Save the positions of any other cursors open on this table before
68875 /* If this is a delete operation to remove a row from a table b-tree,
68971 ** Create a new BTree table. Write into *piTable the page
68972 table.
68986 int ptfFlags; /* Page-type flage for the root page of new table */
69002 /* Creating a new table may probably require moving an existing database
69010 ** root page of the new table should go. meta[3] is the largest root-page
69037 ** the new table (assuming an error did not occur). But we were
69137 BtShared *pBt, /* The BTree that contains the table */
69191 ** Delete all information from a single table in the database. iTable is
69192 ** the page number of the root of the table. After this routine returns,
69196 ** read cursors on the table. Open write cursors are moved to the
69197 ** root of the table.
69199 ** If pnChange is not NULL, then table iTable must be an intkey table. The
69201 ** entries in the table.
69212 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
69213 ** is the root of a table b-tree - if it is not, the following call is
69223 ** Delete all information from the single table that pCur is open on.
69225 ** This routine only work for pCur on an ephemeral table.
69232 ** Erase all information in a table and add the root of the table to
69233 ** the freelist. Except, the root of the principle table (the one on
69237 ** cursors on the table.
69279 /* If the table being dropped is the table with the largest root-page
69288 /* The table being dropped does not have the largest root-page
69995 ** a table. nRoot is the number of entries in aRoot.
70224 ** sqlite_master table. Otherwise SQLITE_OK.
70239 ** Obtain a lock on the table whose root page is iTab. The
70265 ** INTKEY table currently pointing at a valid table entry.
70288 /* Save the positions of all other cursors open on this table. This is
70292 ** Note that pCsr must be open on a INTKEY table and saveCursorPosition()
70293 ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence
70302 ** (c) the connection holds a write-lock on the table (if required),
70304 ** (e) the cursor points at a valid row of an intKey table.
72537 ** on a table column definition, and hence only when pCtx==0. This
72670 ** sqlite_stat3 table to the record format SQLite uses internally.
72775 ** in the sqlite_stat4 table.
73472 ** (for CREATE TABLE AS SELECT ...)
73764 const char *zName /* Name of table or index being scanned */
74557 ** to 6.6 percent. The test case is inserting 1000 rows into a table
76155 ** the blob of data that it corresponds to. In a table record, all serial
76160 ** The following table describes the various storage classes for data:
76433 case 10: { /* Internal use only: NULL with virtual table
76589 ** This function compares two index or table record keys in the same way
76971 ** This function compares the two table rows or index records
77665 Table *pTab, /* Modified table */
78476 ** table, then it returns true if and only if the the call is during an
78481 ** xColumn method of a virtual table, then the return value is meaningless
78484 ** Virtual table implements might use this routine to optimize their
78863 ** 3 The name of the table that the column derives from
78864 ** 4 The name of the table column that the result column derives from
78966 ** Return the name of the table from which a result column derives.
78982 ** Return the name of the table column from which a result column derives.
80094 int nField, /* Number of fields in the table or index */
82393 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
82395 ** The first OP_Column against a pseudo-table after the value of the content
82699 ** use as a data record in a database table or as a key
82795 ** table methods that never invoke sqlite3_result_xxxxx() while
82880 ** Store the number of entries (an integer value) in the table or index
83244 ** are queried from within xNext() and other v-table methods using
83247 ** v-table would have to be ready for the sqlite3_vtab structure itself
83249 ** a v-table method.
83334 ** Open a read-only cursor for the database table whose root page is
83358 ** value, it is set to the number of columns in the table.
83379 ** Open a read/write cursor named P1 on the table or index whose root
83387 ** value, it is set to the number of columns in the table, or to the
83388 ** largest index of any column of the table that is actually used.
83391 ** in read/write mode. For a given table, there can be one or more read-only
83471 testcase( nField==0 ); /* Table with INTEGER PRIMARY KEY and nothing else */
83503 ** Open a new cursor P1 that points to the same ephemeral table as
83535 ** Open a new cursor P1 to a transient table.
83538 ** table is deleted automatically when the cursor is closed.
83540 ** P2 is the number of columns in the ephemeral table.
83541 ** The cursor points to a BTree table if P4==0 and to a BTree index
83583 ** opening it. If a transient table is required, just use the
83584 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
83655 ** Open a new cursor that points to a fake table that contains a single
83660 ** A pseudo-table created by this opcode is used to hold a single
83663 ** is the only cursor opcode that works with a pseudo-table.
83666 ** the pseudo-table.
83704 ** table or index for cursor P1 are used. P4 is a 64-bit integer
83706 ** first 63 columns of the table or index that are actually used
83722 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83747 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83765 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83783 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83968 /* res might be negative because the table is empty. Check to
84130 ** P1 is the index of a cursor open on an SQL table btree (with integer
84154 ** P1 is the index of a cursor open on an SQL table btree (with integer
84242 ** Get a new integer record number (a.k.a "rowid") used as the key to a table.
84244 ** table that cursor P1 points to. The new record number is written
84256 VdbeCursor *pC; /* Cursor of table to get the new rowid */
84280 ** it already exists in the table. If it does not exist, we have
84350 ** an AUTOINCREMENT table. */
84376 ** Write an entry into the table of cursor P1. A new entry is
84397 ** Parameter P4 may point to a Table structure, or may be NULL. If it is
84420 VdbeCursor *pC; /* Cursor to table into which insert is written */
84423 Table *pTab; /* Table structure - used by update and pre-update hooks */
84508 ** record in the table. If it is left pointing at the next record, then
84515 ** delete one of several associated with deleting a table row and all its
84523 ** P1 must not be pseudo-table. It has to be a real table with
84526 ** If P4 is not NULL then it points to a Table object. In this case either
84540 Table *pTab;
84684 ** a register that is the source for a pseudo-table cursor created using
84685 ** OpenPseudo. That pseudo-table cursor is the one that is identified by
84713 ** If cursor P2 is a table, then the content extracted is the data.
84716 ** of a real table, not a pseudo-table.
84722 ** position in order that they can write to the same table. If P3==0
84729 ** by any use of another cursor pointing to the same table.
84778 ** Store in register P2 an integer which is the key of the table entry that
84781 ** P1 can be either an ordinary table or a virtual table. There used to
84783 ** one opcode now works for both table types.
84860 ** will refer to the last entry in the database table or index.
84861 ** If the table or index is empty and P2>0, then jump immediately to P2.
84862 ** If P2 is 0 or if the table or index is not empty, fall through
84906 ** Estimate the number of rows in the table P1. Jump to P2 if that
84965 ** will refer to the first entry in the database table or index.
84966 ** If the table or index is empty, jump immediately to P2.
84967 ** If the table or index is not empty, fall through to the following
85008 ** table or index. If there are no more key/value pairs then fall through
85016 ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have
85040 ** table or index. If there is no previous key/value pairs then fall through
85049 ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is
85237 ** table. This opcode does a deferred seek of the P3 table cursor
85245 ** one entry for each column in the P3 table. If array entry a(i)
85257 ** the rowid of the table entry to which this index entry points.
85264 VdbeCursor *pTabCur; /* The P2 table cursor (OP_DeferredSeek only) */
85407 ** Delete an entire database table or index whose root page in the database
85410 ** The table being destroyed is in the main database file if P3==0. If
85411 ** P3==1 then the table to be clear is in the auxiliary database file
85412 ** that is used to store tables create using CREATE TEMPORARY TABLE.
85419 ** table being dropped was already the last one in the database) then a
85466 ** Delete all contents of the database table or index whose root page
85468 ** remove the table or index from the database file.
85470 ** The table being clear is in the main database file if P2==0. If
85471 ** P2==1 then the table to be clear is in the auxiliary database file
85472 ** that is used to store tables create using CREATE TEMPORARY TABLE.
85474 ** If the P3 value is non-zero, then the table referred to must be an
85475 ** intkey table (an SQL table, not an index). In this case the row change
85476 ** count is incremented by the number of rows in the table being cleared.
85478 ** also incremented by the number of rows in the table being cleared.
85505 ** Delete all contents from the ephemeral table or sorter
85533 ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table
85534 ** it must be 2 (BTREE_BLOBKEY) for a index or WITHOUT ROWID table.
85569 ** Read and parse all entries from the SQLITE_MASTER table of database P1
85628 ** Read the sqlite_stat1 table for database P1 and load the content
85629 ** of that table into the internal index hash table. This will cause
85643 ** the table named P4 in database P1. This is called after a table
86501 ** Obtain a lock on a particular table. This instruction is only used when
86508 ** P2 contains the root-page of the table to lock.
86510 ** P4 contains a pointer to the name of the table being locked. This is only
86524 sqlite3VdbeError(p, "database table is locked: %s", z);
86537 ** xBegin method for that table.
86540 ** within a callback to a virtual table xSync() method. If it is, the error
86556 ** P2 is a register that holds the name of a virtual table in database
86557 ** P1. Call the xCreate method for that table.
86561 const char *zTab; /* Name of the virtual table */
86585 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
86586 ** of that table.
86600 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
86602 ** table and stores that cursor in P1.
86651 ** This opcode invokes the xFilter method on the virtual table specified
86710 ** the current row of the virtual-table of cursor P1.
86716 ** by virtual table implementations to return special "no-change"
86717 ** marks which can be more efficient, depending on the virtual table.
86766 ** Advance virtual table P1 to the next row in its result set and
86767 ** jump to instruction P2. Or, if the virtual table has reached
86790 ** some other method is next invoked on the save virtual table cursor.
86808 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
86840 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
86850 ** row. This can be NULL to have the virtual table select the new
87335 u16 iCol; /* Table column this handle is open on */
87340 Table *pTab; /* Table object */
87429 const char *zTable, /* The table containing the blob */
87439 Table *pTab;
87470 sqlite3ErrorMsg(&sParse, "cannot open virtual table: %s", zTable);
87474 sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable);
87555 ** db/table/row entry. The reason for using a vdbe program instead
87590 /* Make sure a mutex is held on the table to be accessed */
87614 ** think that the table has one more column than it really
87776 ** database table.
90883 ** Table of methods for MemJournal sqlite3_file object.
91184 ** table and column.
91290 ** Subqueries stores the original database, table and column names for their
91291 ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".
91327 ** pExpr->iTable Set to the cursor number for the table obtained
91329 ** pExpr->pTab Points to the Table structure of X.Y (even if
91331 ** pExpr->iColumn Set to the column number within the table.
91338 ** can be used. The zTable variable is the name of the table (the "Y"). This
91340 ** means that the form of the name is Z and that columns from any table
91348 const char *zDb, /* Name of the database containing table, or NULL */
91349 const char *zTab, /* Name of table containing column, or NULL */
91356 int cntTab = 0; /* Number of matching table names */
91364 Table *pTab = 0; /* Table hold the row */
91441 ** is for the right-hand table of a NATURAL JOIN or is in a
91542 ** SELECT a+b AS x FROM table WHERE x<10;
91627 /* If a column from a table in pSrcList is referenced, then record
91781 ** Or table name and column name: ID.ID
91782 ** Or a database, table and column: ID.ID.ID
92454 /* Resolve names in table-valued-function arguments */
92543 ** table columns and result-set columns. At the same time, do error
92547 ** To resolve table columns references we look for nodes (or subtrees) of the
92553 ** Y: The name of a table in a FROM clause. Or in a trigger
92556 ** Z: The name of a column in table Y.
92561 ** Expr.pTab Points to the Table object for X.Y
92570 ** Table-name and function resolution occurs on the substituted expression
92668 ** Resolve names in expressions that can only reference a single table:
92680 Table *pTab, /* The table being referenced */
92725 ** Return the affinity character for a single column of a table.
92727 SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){
92743 ** CREATE TABLE t1(a);
93101 ** not be ready for evaluation because the table cursor has not yet
94095 Table *pTab;
94455 ** in a CREATE TABLE statement. The Walker.eCode value is 5 when parsing
94504 ** of the sqlite_master table */
94556 ** for any single row of the table with cursor iCur. In other words, the
94558 ** table other than iCur.
94779 ** that can be simplified to a direct table access, then return
94782 ** table, then return NULL.
94789 Table *pTab;
94810 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
94825 ** Generate code that checks the left-most column of index table iCur to see if
94873 ** IN_INDEX_ROWID - The cursor was opened on a database table.
94877 ** populated epheremal table.
94884 ** SELECT <column1>, <column2>... FROM <table>
94887 ** an ephemeral table might need to be generated from the RHS and then
94888 ** pX->iTable made to point to the ephemeral table instead of an
94889 ** existing table.
94893 ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast
94899 ** An epheremal table will be created unless the selected columns are guaranteed
94904 ** for fast set membership tests) then an epheremal table must
94948 int eType = 0; /* Type of RHS table. IN_INDEX_* */
94949 int iTab = pParse->nTab++; /* Cursor of the RHS table */
94972 /* Check to see if an existing table or index can be used to
94974 ** ephemeral table. */
94977 Table *pTab; /* Table <table>. */
94987 /* Code an OP_Transaction and OP_TableLock for <table>. */
94994 /* The "x IN (SELECT rowid FROM table)" case */
95008 ** comparison is the same as the affinity of each column in table
95010 ** use any index of the RHS table. */
95014 char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */
95112 ** then it is not worth creating an ephemeral table to evaluate
95124 /* Could not find an existing table or index to use as the RHS b-tree.
95125 ** We will have to generate an ephemeral table to do the job.
95236 ** to some integer key column of a table B-Tree. In this case, use an
95300 ** expression it is handled the same way. An ephemeral table is
95321 ** table allocated and opened above.
95358 ** store it in the temporary table. If <expr> is a column, then use
95395 /* Evaluate the expression and insert it into the temp table */
95573 ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
95687 /* In this case, the RHS is the ROWID of table b-tree and so we also
95850 ** particular table is stored in a particular register.
95978 int iTabCur, /* Cursor pointing to a table row */
95996 ** Generate code to extract the value of the iCol-th column of a table.
96000 Table *pTab, /* The table containing the value */
96001 int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */
96026 ** table pTab and store the column value in a register.
96038 Table *pTab, /* Description of the table we are reading from */
96039 int iColumn, /* Index of the table column */
96040 int iTable, /* The cursor pointing to the table */
96066 Table *pTab, /* Description of the table we are reading from */
96067 int iColumn, /* Index of the table column */
96068 int iTable, /* The cursor pointing to the table */
96237 ** in the index refer to the table to which the index belongs */
96554 ** a virtual table column.
96558 ** see if it is a column in a virtual table. This is done because
96661 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
96662 ** is set to the column of the pseudo-table to read, or to -1 to
96667 ** to reference another column of the old.* pseudo-table, where
96669 ** set to (n+1), where n is the number of columns in each pseudo-table.
96670 ** For a reference to any other column in the new.* pseudo-table, p1
96672 ** example, if the table on which triggers are being fired is
96675 ** CREATE TABLE t1(a, b);
96683 Table *pTab = pExpr->pTab;
97591 ** Expr.iTable<0 then assume a table number given by iTab.
97624 ** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
97625 ** is the cursor for the table.
97629 int iCur; /* Cursor number for the table corresponding to the index */
97633 ** Check to see if there are references to columns in table
97649 ** Determine if an index pIdx on table with cursor iCur contains will
97651 ** expression and false if the pExpr expression references table columns
97656 ** corresponding table entry.
97660 int iCur, /* The cursor number for the corresponding table */
97677 ** to count references to table columns in the arguments of an
97790 /* If we reach this point, it means that pExpr refers to a table
98048 ** that implements the ALTER TABLE command.
98054 ** ALTER TABLE logic from the build.
98061 ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
98062 ** CREATE INDEX command. The second is a table name. The table name in
98063 ** the CREATE TABLE or CREATE INDEX statement is replaced with the third
98066 ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
98067 ** -> 'CREATE TABLE def(a, b, c)'
98090 /* The principle used to locate the table name in the CREATE TABLE
98091 ** statement is that the table name is the first non-space token that
98123 ** generated by the ALTER TABLE ... RENAME command to modify the definition
98124 ** of any foreign key constraints that use the table being renamed as the
98125 ** parent table. It is passed three arguments:
98127 ** 1) The complete text of the CREATE TABLE statement being modified,
98128 ** 2) The old name of the table being renamed, and
98129 ** 3) The new name of the table being renamed.
98131 ** It returns the new CREATE TABLE statement. For example:
98133 ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
98134 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
98188 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
98189 ** statement. The second is a table name. The table name in the CREATE
98192 ** TRIGGER, not CREATE INDEX and CREATE TABLE.
98212 /* The principle used to locate the table name in the CREATE TRIGGER
98213 ** statement is that the table name is the first token that is immediately
98221 /* Ran out of input before finding the table name. Return NULL. */
98243 ** Note that ON cannot be a database, table or column name, so
98253 /* Variable tname now contains the token that is the old table-name
98264 ** Register built-in functions used to help implement ALTER TABLE
98309 ** tables that have foreign key constraints that refer to table pTab (i.e.
98310 ** constraints for which pTab is the parent table) from the sqlite_master
98311 ** table.
98313 static char *whereForeignKeys(Parse *pParse, Table *pTab){
98325 ** temporary triggers on table pTab from the sqlite_temp_master table. If
98326 ** table pTab has no temporary triggers, or is itself stored in the
98329 static char *whereTempTriggers(Parse *pParse, Table *pTab){
98334 /* If the table is not located in the temp-db (in which case NULL is
98356 ** Generate code to drop and reload the internal representation of table
98358 ** Argument zName is the name of the table in the database schema at
98361 ** "ALTER TABLE RENAME TO" statement.
98363 static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
98378 /* Drop any table triggers from the internal schema. */
98386 /* Drop the table and index from the internal schema. */
98389 /* Reload the table, index and permanent trigger schemas. */
98395 /* Now, if the table is not stored in the temp database, reload any temp
98405 ** Parameter zName is the name of a table that is about to be altered
98406 ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
98407 ** If the table is a system table, this function leaves an error message
98410 ** Or, if zName is not a system table, zero is returned.
98414 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
98421 ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
98426 SrcList *pSrc, /* The table to rename. */
98427 Token *pName /* The new table name. */
98429 int iDb; /* Database that contains the table */
98431 Table *pTab; /* Table being renamed */
98435 const char *zTabName; /* Original name of the table */
98454 /* Get a NULL terminated version of the new table name. */
98458 /* Check that a table or index named 'zName' does not already exist
98463 "there is already another table or index with this name: %s", zName);
98467 /* Make sure it is not a system table being altered, or a reserved name
98468 ** that the table is being renamed to.
98504 ** Then modify the schema cookie (since the ALTER TABLE modifies the
98505 ** schema). Open a statement transaction if the table is a virtual
98506 ** table.
98515 /* If this is a virtual table, invoke the xRename() function if
98517 ** of any resources used by the v-table implementation (including other
98518 ** SQLite tables) that are identified by the name of the virtual table.
98535 /* If foreign-key support is enabled, rewrite the CREATE TABLE
98537 ** for which the renamed table is the parent table. */
98548 /* Modify the sqlite_master table to use the new table name. */
98560 "WHEN type='table' THEN %Q "
98565 "(type='table' OR type='index' OR type='trigger');",
98574 /* If the sqlite_sequence table exists in this database, then update
98575 ** it with the new table name.
98585 /* If there are TEMP triggers on this table, modify the sqlite_temp_master
98586 ** table. Don't do this if the table being ALTERed is itself located in
98603 Table *pFrom = p->pFrom;
98611 /* Drop and reload the internal table schema. */
98621 ** This function is called after an "ALTER TABLE ... ADD" statement
98625 ** The Table structure pParse->pNewTable was extended to include
98629 Table *pNew; /* Copy of pParse->pNewTable */
98630 Table *pTab; /* Table being altered */
98633 const char *zTab; /* Table name */
98714 /* Modify the CREATE TABLE statement. */
98726 "WHERE type = 'table' AND name = %Q",
98747 /* Reload the schema of the modified table. */
98752 ** This function is called by the parser after the table-name in
98753 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
98754 ** pSrc is the full-name of the table being altered.
98756 ** This routine makes a (partial) copy of the Table structure
98757 ** for the table being altered and sets Parse.pNewTable to point
98760 ** the copy. The copy of the Table structure is deleted by tokenize.c
98764 ** coding the "ALTER TABLE ... ADD" statement.
98767 Table *pNew;
98768 Table *pTab;
98775 /* Look up the table being altered. */
98801 /* Put a copy of the Table struct in Parse.pNewTable for the
98805 ** table because user table are not allowed to have the "sqlite_"
98808 pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
98866 ** CREATE TABLE sqlite_stat1(tbl, idx, stat);
98867 ** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);
98868 ** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);
98869 ** CREATE TABLE sqlite_stat4(tbl, idx, nEq, nLt, nDLt, sample);
98872 ** The sqlite_stat2 table is not created or used unless the SQLite version
98874 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
98875 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
98890 ** name in the idx column. The tbl column is the name of the table to
98894 ** number of rows in the table, except for partial indices.) The second
98911 ** rows in the table identified by sqlite_stat1.tbl.
98917 ** 3.6.18 and 3.7.8. The "stat2" table contains additional information
98919 ** the "idx" column and the "tbl" column is the name of the table to which
98921 ** table for each index.
98936 ** writes the sqlite_stat2 table. This version of SQLite only supports
98947 ** As with sqlite_stat2, the sqlite_stat4 table contains histogram data
98952 ** The sqlite_stat4 table contains multiple entries for each index.
98953 ** The idx column names the index and the tbl column is the table of the
98980 ** The sqlite_stat3 table is like sqlite_stat4 except that it only
99007 ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now
99013 ** Argument zWhere may be a pointer to a buffer containing a table name,
99015 ** the sqlite_statN tables associated with the named table are deleted.
99016 ** If zWhere==0, then code is generated to delete all stat table entries.
99021 int iStatCur, /* Open the sqlite_stat1 table on this cursor */
99022 const char *zWhere, /* Delete entries for this table or index */
99058 Table *pStat;
99061 /* The sqlite_statN table does not exist. Create it. Note that a
99062 ** side-effect of the CREATE TABLE statement is to leave the rootpage
99063 ** of the new table in register pParse->regRoot. This is important
99066 "CREATE TABLE %Q.%s(%s)", pDb->zDbSName, zTab, aTable[i].zCols
99072 /* The table already exists. If zWhere is not NULL, delete all entries
99073 ** associated with the table zWhere. If zWhere is NULL, delete the
99074 ** entire contents of the table. */
99088 /* The sqlite_stat[134] table already exists. Delete all rows. */
99123 i64 iRowid; /* Rowid in main table of the key */
99133 tRowcnt nRow; /* Number of rows in the entire table */
99230 ** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the
99231 ** total number of columns in the table.
99237 ** PRIMARY KEY of the table. The covering index that implements the
99238 ** original WITHOUT ROWID table as N==K as a special case.
99420 ** iCol occurs many times in the table. However, if we have already
99654 #define STAT_GET_STAT1 0 /* "stat" column of stat1 table */
99677 ** stat1 table entry information.
99699 ** table for this index.
99821 ** a single table.
99825 Table *pTab, /* Table whose indices are to be analyzed */
99827 int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */
99834 int iTabCur; /* Table cursor */
99839 u8 needTableCnt = 1; /* True to count the table */
99847 int regTabname = iMem++; /* Register containing table name */
99852 Table *pStat1 = 0;
99881 pStat1 = (Table*)sqlite3DbMallocZero(db, sizeof(Table) + 13);
99891 /* Establish a read-lock on the table at the shared-cache level.
99892 ** Open a read-only cursor on the table. Also allocate a cursor number
99960 ** the sqlite_stat4 table. */
99972 ** (or for a WITHOUT ROWID table, the number of PK columns),
100086 /* Add the entry to the stat1 table. */
100097 /* Add the entries to the stat3 or stat4 table. */
100196 Table *pTab = (Table*)sqliteHashData(k);
100203 ** Generate code that will do an analysis of a single table in
100207 static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){
100236 ** Form 3 analyzes all indices associated with the named table.
100243 Table *pTab;
100266 /* Form 3: Analyze the table or index named as an argument */
100363 ** sqlite_stat1 table.
100365 ** argv[0] = name of the table
100370 ** the table.
100375 Table *pTable;
100494 ** occur in the stat4 table for this index. Set sumEq to the sum of
100516 ** Look up an index by name. Or, if the name of a WITHOUT ROWID table
100517 ** is supplied instead, find the PRIMARY KEY index for that table.
100526 Table *pTab = sqlite3FindTable(db, zName, zDb);
100533 ** Load the content from either the sqlite_stat4 or sqlite_stat3 table
100583 ** loaded from the stat4 table. In this case ignore stat3 data. */
100633 ** the sqlite_stat4 table. In this case ignore stat3 data. */
100701 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
100703 ** during compilation and the sqlite_stat3/4 table is present, no data is
100707 ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is
100709 ** table (if it is present) before returning.
100728 Table *pTab = sqliteHashData(i);
100740 /* Load new statistics out of the sqlite_stat1 table */
100754 /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
100761 /* Load the statistics from the sqlite_stat4 table. */
101224 ** a specific database to all table references where the database name
101419 ** the table and the column that are being accessed. The auth function
101457 ** table zTab in database zDb. This function assumes that an authorization
101466 const char *zTab, /* Table name */
101492 ** The pExpr should be a TK_COLUMN expression. The table referred to
101493 ** is in pTabList or else it is the NEW or OLD table of a trigger.
101504 SrcList *pTabList /* All table that pExpr might refer to */
101507 Table *pTab = 0; /* The table being read */
101508 const char *zCol; /* Name of the column of the table */
101509 int iSrc; /* Index in pTabList->a[] of table being read */
101511 int iCol; /* Index of column in table */
101517 ** temporary table. */
101650 ** CREATE TABLE
101651 ** DROP TABLE
101667 int iDb; /* The database containing the table to be locked */
101668 int iTab; /* The root page of the table to be locked */
101670 const char *zLockName; /* Name of the table */
101674 ** Record the fact that we want to lock a table at run-time.
101676 ** The table to be locked has root page iTab and is found in database iDb.
101685 int iDb, /* Index of the database containing the table to lock */
101686 int iTab, /* Root page number of the table to be locked */
101688 const char *zName /* Name of the table to be locked */
101722 ** Code an OP_TableLock instruction for each table locked by the
101835 ** obtain the required table-locks. This is a no-op unless the
101912 ** Return TRUE if zTable is the name of the system table that stores the
101922 ** table given the name of that table and (optionally) the name of the
101923 ** database containing the table. Return NULL if not found.
101925 ** If zDatabase is 0, all databases are searched for the table and the
101926 ** first matching table is returned. (No checking for duplicate table
101932 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
101933 Table *p = 0;
101939 /* Only the admin user is allowed to know that the sqlite_user table
101965 ** table given the name of that table and (optionally) the name of the
101966 ** database containing the table. Return NULL if not found. Also leave an
101973 SQLITE_PRIVATE Table *sqlite3LocateTable(
101976 const char *zName, /* Name of the table we are looking for */
101979 Table *p;
101989 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
101992 /* If zName is the not the name of a table in the schema created using
101993 ** CREATE, then check to see if it is the name of an virtual table that
101994 ** can be an eponymous virtual table. */
102018 ** Locate the table identified by *p.
102026 SQLITE_PRIVATE Table *sqlite3LocateTableItem(
102049 ** table and the first matching index is returned. (No checking
102090 ** unlike that index from its Table then remove the index from
102091 ** the index hash table and free all memory structures associated
102201 ** Delete memory allocated for the column names of a table or view (the
102202 ** Table.aCol[] array).
102204 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){
102220 ** Table. No changes are made to disk by this routine.
102223 ** the table data structure from the hash table. But it does destroy
102225 ** the table.
102227 ** The db parameter is optional. It is needed if the Table object
102228 ** contains lookaside memory. (Table objects in the schema do not use
102229 ** lookaside memory, but some ephemeral Table objects do.) Or the
102231 ** used by the Table object.
102233 static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
102246 /* Delete all indices associated with this table. */
102262 /* Delete any foreign keys attached to this table. */
102265 /* Delete the Table structure itself.
102280 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
102281 /* Do not delete the table until the reference count reaches zero. */
102289 ** Unlink the given table from the hash tables and the delete the
102290 ** table structure with all its indices and foreign keys.
102293 Table *p;
102300 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
102332 ** Open the sqlite_master table stored in database number iDb for
102333 ** writing. The table is opened using cursor 0.
102379 /* The table or view or trigger name is passed to this routine via tokens
102380 ** pName1 and pName2. If the table name was fully qualified, for example:
102382 ** CREATE TABLE xxx.yyy (...);
102385 ** the table name is not fully qualified, i.e.:
102387 ** CREATE TABLE yyy(...);
102392 ** pName2) that stores the unqualified table name. The index of the
102427 ** unqualified name for a new schema object (table, index, view or
102443 ** Return the PRIMARY KEY index of a table
102445 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){
102452 ** Return the column of index pIdx that corresponds to table
102464 ** Begin constructing a new table representation in memory. This is
102466 ** to a CREATE TABLE statement. In particular, this routine is called
102467 ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp
102468 ** flag is true if the table should be stored in the auxiliary database
102471 ** CREATE and TABLE.
102473 ** The new table record is initialized and put in pParse->pNewTable.
102474 ** As more of the CREATE TABLE statement is parsed, additional action
102476 ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine
102477 ** is called to complete the construction of the new table record.
102481 Token *pName1, /* First part of the name of the table or view */
102482 Token *pName2, /* Second part of the name of the table or view */
102483 int isTemp, /* True if this is a TEMP table */
102485 int isVirtual, /* True if this is a VIRTUAL table */
102486 int noErr /* Do nothing if table already exists */
102488 Table *pTable;
102489 char *zName = 0; /* The name of the new table */
102492 int iDb; /* Database number to create the table in */
102493 Token *pName; /* Unqualified name of the table to create */
102505 /* If creating a temp table, the name may not be qualified. Unless
102507 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
102540 /* Make sure the new table
102541 ** index or table name in the same database. Issue an error message if
102555 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
102568 pTable = sqlite3DbMallocZero(db, sizeof(Table));
102587 /* If this is the magic sqlite_sequence table used by autoincrement,
102588 ** then record a pointer to this table in the main database structure
102589 ** so that INSERT can find the table easily.
102598 /* Begin generating the code that will insert the table record into
102599 ** the SQLITE_MASTER table. Note in particular that we must go ahead
102600 ** and allocate the record number for the table entry now. Before any
102602 ** indices to be created and the table record must come before the
102603 ** indices. Hence, the record number for the table must be allocated
102635 /* This just creates a place-holder record in the sqlite_master table.
102640 ** The root page number of the new table is left in reg pParse->regRoot.
102670 /* Set properties of a table column based on the (magical)
102674 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
102685 ** Add a new column to the table currently being constructed.
102688 ** in a CREATE TABLE statement. sqlite3StartTable() gets called
102693 Table *p;
102749 ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
102754 Table *p;
102766 ** substrings in the following table. If one of the substrings is
102769 ** the table take priority. For example, if zType is 'BLOBINT',
102783 ** If none of the substrings in the above table are found,
102850 ** of the table currently under construction.
102856 ** parsing a CREATE TABLE statement.
102864 Table *p;
102897 ** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)
102916 ** Designate the PRIMARY KEY for the table. pList is a list of names
102918 ** most recently added column of the table is the primary key.
102920 ** A table can have at most one primary key. If the table already has
102925 ** then we will try to use that column as the rowid. Set the Table.iPKey
102926 ** field of the table under construction to be the index of the
102927 ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is
102940 Table *pTab = pParse->pNewTable;
102947 "table \"%s\" has more than one primary key", pTab->zName);
103001 ** Add a new CHECK constraint to the table currently under construction.
103008 Table *pTab = pParse->pNewTable;
103025 ** Set the collation function of the most recently parsed table column
103029 Table *p;
103175 ** Generate a CREATE TABLE statement appropriate for the given
103176 ** table. Memory to hold the text of the statement is obtained
103179 static char *createTableStmt(sqlite3 *db, Table *p){
103204 sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
103269 ** Estimate the total row width for a table.
103271 static void estimateTableWidth(Table *pTab){
103305 ** This routine runs at the end of parsing a CREATE TABLE statement that
103308 ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
103314 ** (3) Bypass the creation of the sqlite_master table entry
103316 ** identified by the sqlite_master table entry of the table itself.
103318 ** schema to the rootpage from the main table.
103319 ** (5) Add all table columns to the PRIMARY KEY Index object
103328 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
103358 /* Locate the PRIMARY KEY index. Or, if this table was originally
103359 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
103398 ** table entry. This is only required if currently generating VDBE
103399 ** code for a CREATE TABLE (not when parsing one as part of reading
103406 /* The root page of the PRIMARY KEY is the table root page */
103435 /* Add all table columns to the PRIMARY KEY index
103456 ** a CREATE TABLE statement.
103458 ** The table structure that other action routines have been building
103462 ** An entry for the table is made in the master table on disk, unless
103463 ** this is a temporary table or db->init.busy==1. When db->init.busy==1
103464 ** it means we are reading the sqlite_master table because we just
103465 ** connected to the database or because the sqlite_master table has
103466 ** recently changed, so the entry for this table already exists in
103467 ** the sqlite_master table. We do not want to create it again.
103470 ** was called to create a table generated from a
103471 ** "CREATE TABLE ... AS SELECT ..." statement. The column names of
103472 ** the new table will match the result set of the SELECT.
103477 Token *pEnd, /* The ')' before options in the CREATE TABLE */
103478 u8 tabOpts, /* Extra table options. Usually 0. */
103481 Table *p; /* The new table */
103483 int iDb; /* Database in which the table lives */
103484 Index *pIdx; /* An implied index of the table */
103496 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
103498 ** for the table from the db->init.newTnum field. (The page number
103502 ** table itself. So mark it read-only.
103517 sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
103534 /* Estimate the average row size for the table and for all implied indices */
103540 /* If not initializing, then create a record for the new table
103541 ** in the SQLITE_MASTER table of the database.
103543 ** If this is a TEMPORARY table, write the entry into the auxiliary
103549 char *zType; /* "view" or "table" */
103550 char *zType2; /* "VIEW" or "TABLE" */
103551 char *zStmt; /* Text of the CREATE TABLE or CREATE VIEW statement */
103559 ** Initialize zType for the new view or table.
103562 /* A regular table */
103563 zType = "table";
103564 zType2 = "TABLE";
103573 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
103574 ** statement to populate the new table. The root-page number for the
103575 ** new table is in register pParse->regRoot.
103579 ** by the new table.
103581 ** A shared-cache write-lock is not required to write to the new table,
103590 int regRec; /* A record to be insert into the new table */
103593 Table *pSelTab; /* A table that describes the SELECT results */
103643 ** SQLITE_MASTER table. We just need to update that slot with all
103662 /* Check to see if we need to create an sqlite_sequence table for
103670 "CREATE TABLE %Q.sqlite_sequence(name,seq)",
103683 /* Add the table to the in-memory representation of the database.
103686 Table *pOld;
103727 Table *p;
103773 /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */
103785 ** The Table structure pTable is really a VIEW. Fill in the names of
103789 SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
103790 Table *pSelTab; /* A fake table from which we get the result set */
103831 ** CREATE TABLE main.ex1(a);
103841 /* If we get this far, it means we need to compute the table names.
103866 ** The names of the columns in the table are taken from
103868 ** normally holds CHECK constraints on an ordinary table, but for
103914 Table *pTab = sqliteHashData(i);
103929 ** used by SQLite when the btree layer moves a table root page. The
103930 ** root-page of a table or index in database iDb has changed from iFrom
103933 ** Ticket #1728: The symbol table might still contain information
103936 ** have the same rootpage number as the real table or index that is
103939 ** or tables and not the table/index that is actually being moved.
103954 Table *pTab = sqliteHashData(pElem);
103970 ** Write code to erase the table with root-page iTable from database iDb.
103971 ** Also write code to modify the sqlite_master table and internal schema
103972 ** if a root-page of another table is moved by the btree-layer whilst
103983 ** is non-zero, then it is the root page number of a table moved to
103984 ** location iTable. The following code modifies the sqlite_master table to
103999 ** Write VDBE code to erase table pTab and all associated indices on disk.
104001 ** in case a root-page belonging to another table is moved by the btree layer
104004 static void destroyTable(Parse *pParse, Table *pTab){
104007 ** table and index root-pages in order, starting with the numerically
104051 ** after a DROP INDEX or DROP TABLE command.
104057 const char *zName /* Name of index or table */
104074 ** Generate code to drop a table.
104076 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
104092 /* Drop all triggers associated with the table being dropped. Code
104105 /* Remove any entries of the sqlite_sequence table associated with
104106 ** the table being dropped. This is done before the table is dropped
104107 ** at the btree level, in case the sqlite_sequence table needs to
104118 /* Drop all SQLITE_MASTER table and index entries that refer to the
104119 ** table. The program name loops through the master table and deletes
104120 ** every row that refers to a table of the same name as the one being
104122 ** created in the temp database that refers to a table in another
104132 /* Remove the table entry from SQLite's internal schema and modify
104144 ** This routine is called to do the work of a DROP TABLE statement.
104145 ** pName is the name of the table to be dropped.
104148 Table *pTab;
104171 /* If pTab is a virtual table, call ViewGetColumnNames() to ensure
104214 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
104219 /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used
104220 ** on a table.
104223 sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);
104232 /* Generate code to remove the table from the master table
104248 ** This routine is called to create a new foreign key on the table
104250 ** in the current table point to the foreign key. If pFromCol==0 then
104252 ** the table referred to (a.k.a the "parent" table). pToCol is a list
104253 ** of tables in the parent pTo table. flags contains all
104257 ** An FKey structure is created and added to the table currently
104265 ExprList *pFromCol, /* Columns in this table that point to other table */
104266 Token *pTo, /* Name of the other table */
104267 ExprList *pToCol, /* Columns in the other table */
104274 Table *p = pParse->pNewTable;
104287 " should reference only one column of table %T",
104295 "columns in the referenced table");
104365 /* Link the foreign key to the table as the last step.
104386 Table *pTab;
104406 Table *pTab = pIndex->pTable; /* The table that is indexed */
104427 /* Require a write-lock on the table to perform this operation */
104445 /* Open the table. Loop through all rows of the table, inserting index
104521 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
104522 ** and pTblList is the name of the table that is to be indexed. Both will
104525 ** as the table to be indexed. pParse->pNewTable is a table that is
104526 ** currently being constructed by a CREATE TABLE statement.
104530 ** to the table currently under construction.
104536 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
104545 Table *pTab = 0; /* Table to be indexed */
104553 Db *pDb; /* The specific table containing the indexed database */
104573 ** Find the table that is to be indexed. Return early if not found.
104578 ** to search for the table. 'Fix' the table name to this db
104579 ** before looking up the table.
104587 /* If the index name was unqualified, check if the table
104588 ** is a temp table. If so, set the database to 1. Do not do this
104610 "cannot create a TEMP index on non-TEMP table \"%s\"",
104632 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
104650 ** index or table with the same name.
104653 ** sqlite_master table (because some other process changed the schema) and
104654 ** one of the index names collides with the name of a temporary table or
104670 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
104717 ** key out of the last column added to the table under construction.
104781 ** a table column, store that column in aiColumn[]. For general expressions,
104785 ** TODO: Issue a warning if the table primary key is used as part of the
104846 /* Append the table key to the end of the index. For WITHOUT ROWID
104871 /* If this index contains every column of its table, then mark
104891 ** CREATE TABLE t(x PRIMARY KEY, y);
104892 ** CREATE TABLE t(x, y, UNIQUE(x, y));
104894 ** Either way, check to see if the table already has such an index. If
104927 ** constraint specified somewhere in the CREATE TABLE statement.
104947 /* Link the new Index structure to its table and to the other
104968 /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
104971 ** the index in the sqlite_master table and populate the index with
104973 ** table to parse the schema, or if this index is the PRIMARY KEY index
104974 ** of a WITHOUT ROWID table.
104977 ** or UNIQUE index in a CREATE TABLE statement. Since the table
104994 ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
105041 /* When adding an index to the list of indices for a table, make
105078 ** number of rows in the table that match any particular value of the
105101 ** number of rows in the table, or half the number of rows in the table
105155 Table *pTab = pIndex->pTable;
105168 /* Generate code to remove the index and from the master table */
105349 ** Append a new table name to the given SrcList. Create a new SrcList if
105357 ** If pDatabase is not null, it means that the table has an optional
105358 ** database name prefix. Like this: "database.table". The pDatabase
105359 ** points to the table name and the pTable points to the database name.
105360 ** The SrcList.a[].zName field is filled with the table name which might
105369 ** Then B is a table name and the database name is unspecified. If called
105374 ** Then C is the table name and B is the database name. If C is defined
105385 Token *pTable, /* Table to append */
105386 Token *pDatabase /* Database of the table */
105463 ** are the name of the table and database named in the FROM clause term.
105477 Token *pTable, /* Name of the table to add to the FROM clause */
105480 Select *pSubquery, /* A subquery used in place of a table name */
105541 ** table-valued-function.
105741 ** inserting multiple rows in a table, or inserting a row and index entries.)
105804 Table *pTab = pIdx->pTable;
105834 Table *pTab /* The table with the non-unique rowid */
105874 static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
105898 Table *pTab; /* A table in the database */
105904 pTab = (Table*)sqliteHashData(k);
105922 ** indices associated with the named table.
105927 char *z; /* Name of a table or index */
105929 Table *pTab; /* A table in the database */
105933 Token *pObjName; /* Name of the table or index to be reindexed */
106032 Token *pName, /* Name of the common-table */
106033 ExprList *pArglist, /* Optional column name list for the table */
106034 Select *pQuery /* Query used to initialize the table */
106047 sqlite3ErrorMsg(pParse, "duplicate WITH table name: %s", zName);
106234 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
106238 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
106270 ** to the hash table).
106394 ** Insert a new FuncDef into a FuncDefHash hash table.
106498 ** new entry to the hash table and return it.
106547 Table *pTab = sqliteHashData(pElem);
106603 ** the name of a single table, as one might find in an INSERT, DELETE,
106604 ** or UPDATE statement. Look up that table in the symbol table and
106605 ** return a pointer. Set an error message and return NULL if the table
106610 ** pSrc->a[0].pTab Pointer to the Table object
106614 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
106616 Table *pTab;
106631 ** Check to make sure the given table is writable. If it is not
106635 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
106636 /* A table is not writable under the following circumstances:
106638 ** 1) It is a virtual table and no implementation of the xUpdate method
106640 ** 2) It is a system table (i.e. sqlite_master), this call is not
106652 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
106668 ** Evaluate a view and store its result in an ephemeral table. The
106670 ** set of rows in the view that are to be added to the ephemeral table.
106674 Table *pView, /* View definition */
106678 int iCur /* Cursor number for ephemeral table */
106725 Table *pTab;
106806 SrcList *pTabList, /* The table from which we should delete things */
106812 Table *pTab; /* The table from which records will be deleted */
106815 Index *pIdx; /* For looping over indices of the table */
106816 int iTabCur; /* Cursor number for the table */
106829 Index *pPk; /* The PRIMARY KEY index on the table */
106834 int iEphCur = 0; /* Ephemeral table holding all primary key values */
106838 int addrEphOpen = 0; /* Instruction to open the Ephemeral table */
106844 Trigger *pTrigger; /* List of table triggers, if required */
106855 /* Locate the table which we want to delete. This table has to be
106858 ** an SrcList* parameter instead of just a Table* parameter.
106863 /* Figure out if we have any triggers and if the table being
106908 /* Assign cursor numbers to the table and all its indices.
106932 ** an ephemeral table.
106964 ** It is easier just to erase the whole table. Prior to version 3.6.5,
106999 /* For a rowid table, initialize the RowSet to an empty set */
107005 /* For a WITHOUT ROWID table, create an ephemeral table used to
107067 /* Add the PK key for this row to the temporary table */
107088 /* Unless this is a view, open cursors for the table we are
107163 /* Update the sqlite_sequence table by storing the content of the
107204 ** single table to be deleted. Both the original table entry and
107210 ** store for the table. (This will be either the table itself,
107211 ** in the case of a rowid table, or the PRIMARY KEY index in the case
107212 ** of a WITHOUT ROWID table.)
107245 Table *pTab, /* Table containing the row to be deleted */
107293 /* Populate the OLD.* pseudo-table register array. These values will be
107327 ** refer to this table (i.e. constraints attached to other tables)
107332 /* Delete the index and table entries. Skip this step if pTab is really
107338 ** be invoked unless table pTab is a system table. The difference is that
107378 ** index entries associated with a single row of a single table, pTab
107383 ** btree for the table pTab. (This will be either the table itself
107396 Table *pTab, /* Table containing the row to be deleted */
107397 int iDataCur, /* Cursor of table holding data. */
107430 ** iCur is the index of a cursor open on the pTab table and pointing to
107431 ** the entry that needs indexing. If pTab is a WITHOUT ROWID table, then
107455 ** on a table with multiple indices, and especially with the ROWID or
107498 ** might be stored in the table as an integer (using a compact
107998 ** routines in the function table. The noopFunc macro provides this.
109294 ** to the global function hash table. This occurs at start-time (as
109481 ** I.1) For each FK for which the table is the child table, search
109482 ** the parent table for a match. If none is found increment the
109485 ** I.2) For each FK for which the table is the parent table,
109486 ** search the child table for rows that correspond to the new
109487 ** row in the parent table. Decrement the counter for each row
109492 ** D.1) For each FK for which the table is the child table,
109493 ** search the parent table for a row that corresponds to the
109494 ** deleted row in the child table. If such a row is not found,
109497 ** D.2) For each FK for which the table is the parent table, search
109498 ** the child table for rows that correspond to the deleted row
109499 ** in the parent table. For each found increment the counter.
109527 ** TODO: How should dropping a table be handled? How should renaming a
109528 ** table be handled?
109563 ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);
109574 ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
109575 ** Given that pParent is the parent table for foreign key constraint pFKey,
109586 ** array is the index of the child table column that is mapped by the FK
109587 ** constraint to the parent table column stored in the left-most column
109589 ** child table column that corresponds to the second left-most column of
109600 ** foreign key definition, and the parent table does not have a
109604 ** foreign key definition, and the PRIMARY KEY of the parent table
109606 ** the child table.
109614 Table *pParent, /* Parent table of FK constraint pFKey */
109616 Index **ppIdx, /* OUT: Unique index on parent table */
109630 ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
109641 ** mapped to the primary key of table pParent, or
109664 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
109675 ** map to an explicit list of columns in table pParent. Check if this
109723 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
109724 ** on the child table of pFKey, this function is invoked twice for each row
109729 ** row in the parent table that corresponds to the row being inserted into
109730 ** or deleted from the child table. If the parent row can be found, no
109732 ** found in the parent table:
109750 Table *pTab, /* Parent table of FK pFKey */
109753 int *aiCol, /* Map from parent key columns to child table columns */
109754 int regData, /* Address of array containing child table row */
109767 ** Check if any of the key columns in the child table row are NULL. If
109769 ** search for a matching row in the parent table. */
109782 ** column of the parent table (table pTab). */
109795 /* If the parent table is the same as the child table, and we are about
109821 /* If the parent table is the same as the child table, and we are about
109862 ** one row into the table, raise a constraint immediately instead of
109882 ** to column iCol of table pTab.
109890 Table *pTab, /* The table whose content is at r[regBase]... */
109891 int regBase, /* Contents of table pTab */
109917 ** Return an Expr object that refers to column iCol of table pTab which
109922 Table *pTab, /* The table whose column is desired */
109923 int iCursor, /* The open cursor on the table */
109937 ** from the parent table of foreign key constraint pFKey and, if pFKey is
109938 ** deferred, when a row is inserted into the same table. When generating
109947 ** table that correspond to the parent table row being deleted or inserted.
109969 SrcList *pSrc, /* The child table to be scanned */
109970 Table *pTab, /* The parent table */
109973 int *aiCol, /* Map from pIdx cols to child table cols */
110004 Expr *pLeft; /* Value from parent table row */
110005 Expr *pRight; /* Column ref to child table */
110007 i16 iCol; /* Index of column in child table */
110008 const char *zCol; /* Name of column in child table */
110020 /* If the child table is the same as the parent table, then add terms
110033 Expr *pLeft; /* Value from parent table row */
110034 Expr *pRight; /* Column ref to child table */
110082 ** FKey.pNextTo) holding all children of table pTab. For example,
110085 ** CREATE TABLE t1(a PRIMARY KEY);
110086 ** CREATE TABLE t2(b REFERENCES t1(a);
110088 ** Calling this function with table "t1" as an argument returns a pointer
110089 ** to the FKey structure representing the foreign key constraint on table
110092 ** table).
110094 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){
110118 ** This function is called to generate code that runs when table pTab is
110121 ** table pTab.
110125 ** (a) The table is the parent table of a FK constraint, or
110126 ** (b) The table is the child table of a deferred FK constraint and it is
110131 ** the table from the database. Triggers are disabled while running this
110134 SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
110142 /* Search for a deferred foreign key constraint for which this table
110143 ** is the child table. If one cannot be found, return without
110185 ** for which pTab is the child table. An UPDATE statement against pTab
110186 ** is currently being processed. For each column of the table that is
110196 Table *pTab, /* Table being updated */
110212 ** for which pTab is the parent table. An UPDATE statement against pTab
110213 ** is currently being processed. For each column of the table that is
110223 Table *pTab,
110266 ** table pTab to generate VDBE code to perform foreign key constraint
110280 ** the original record is deleted from the table using the calling convention
110286 Table *pTab, /* Row is being deleted from this table */
110308 ** child table (the table that the foreign key definition is part of). */
110310 Table *pTo; /* Parent table of foreign key pFKey */
110325 /* Find the parent table of this foreign key. Also find a unique index
110326 ** on the parent key columns in the parent table. If either of these
110338 /* If isIgnoreErrors is true, then a table is being dropped. In this
110339 ** case SQLite runs a "DELETE FROM xxx" on the table being dropped
110341 ** If the parent table of an FK constraint on the current table is
110343 ** FK counter for each row of the current table with non-NULL keys.
110371 ** values read from the parent table are NULL. */
110381 /* Take a shared-cache advisory read-lock on the parent table. Allocate
110383 ** in the parent table. */
110388 /* A row is being removed from the child table. Search for the parent.
110394 /* A row is being added to the child table. If a parent row cannot
110408 /* Loop through all the foreign key constraints that refer to this table.
110423 /* Inserting a single row into a parent table cannot cause (or fix)
110434 /* Create a SrcList structure containing the child table. We need the
110435 ** child table as a SrcList for sqlite3WhereBegin() */
110464 ** child table to fire. In these cases the fk constraint counters
110482 ** row contained in table pTab.
110486 Table *pTab /* Table being modified */
110512 ** row contained in table pTab. If the operation is a DELETE, then
110514 ** to an array of size N, where N is the number of columns in table pTab.
110518 ** UPDATE statement modifies the rowid fields of the table.
110526 ** * There are any FKs for which pTab is the child and the parent table, or
110534 Table *pTab, /* Table being modified */
110542 ** table in question is either the child or parent table for any
110572 ** compiled on table pTab, which is the parent table of foreign-key pFKey.
110583 ** For example, if pFKey is the foreign key and pTab is table "p" in
110586 ** CREATE TABLE p(pk PRIMARY KEY);
110587 ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);
110601 Table *pTab, /* Table being updated or deleted from */
110617 char const *zFrom; /* Name of child table */
110620 int *aiCol = 0; /* child table cols -> parent key cols */
110634 Token tFromCol; /* Name of column in child table */
110635 Token tToCol; /* Name of column in parent table */
110636 int iFromCol; /* Idx of column in child table */
110650 ** parent table are used for the comparison. */
110783 Table *pTab, /* Table being updated or deleted from */
110790 ** refer to table pTab. If there is an action associated with the FK
110810 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
110811 ** hash table.
110813 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
110821 /* Remove the FK from the fkeyHash hash table. */
110873 ** (1) acquire a lock for table pTab then
110876 ** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index
110877 ** for that table that is actually opened.
110881 int iCur, /* The cursor number of the table */
110883 Table *pTab, /* The table to be opened */
110908 ** the table, according to the affinity of the column:
110936 Table *pTab = pIdx->pTable;
110964 ** Compute the affinity string for table pTab, if it has not already been
110983 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
111013 ** Return non-zero if the table pTab in database iDb or any of its indices
111016 ** run without using a temporary table for the results of the SELECT.
111018 static int readsTable(Parse *p, int iDb, Table *pTab){
111054 ** Locate or create an AutoincInfo structure associated with table pTab
111057 ** table. (Also return zero when doing a VACUUM since we do not want to
111060 ** There is at most one AutoincInfo structure per table even if the
111061 ** same table is autoincremented multiple times due to inserts within
111063 ** first use of table pTab. On 2nd and subsequent uses, the original
111068 ** (1) Register to hold the name of the pTab table.
111078 Table *pTab /* The table we are writing to */
111096 pToplevel->nMem++; /* Register to hold name of table */
111112 Db *pDb; /* Database only autoinc table */
111174 ** table (either directly or through triggers) needs to call this
111228 Table *pDest, /* The table we are inserting into */
111237 ** insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...
111238 ** insert into TABLE (IDLIST) select
111239 ** insert into TABLE (IDLIST) default values
111241 ** The IDLIST following the table name is always optional. If omitted,
111242 ** then a list of all (non-hidden) columns for the table is substituted.
111257 ** open write cursor to <table> and its indices
111259 ** write the resulting record into <table>
111264 ** INSERT INTO <table> SELECT ...
111267 ** in other words if the SELECT pulls all columns from a single table
111275 ** open a write cursor to <table>
111277 ** transfer all records in <table2> over to <table>
111279 ** foreach index on <table>
111280 ** open a write cursor on the <table> index
111287 ** and the SELECT clause does not read from <table> at any time.
111299 ** B: open write cursor to <table> and its indices
111301 ** insert the select result into <table> from R..R+n
111306 ** values from a SELECT but the data is being inserted into a table
111308 ** we have to use an intermediate table to store the results of
111320 ** B: open temp table
111322 ** insert row from R..R+n into temp table
111324 ** M: open write cursor to <table> and its indices
111325 ** rewind temp table
111326 ** C: loop over rows of intermediate table
111327 ** transfer values form intermediate table into <table>
111333 SrcList *pTabList, /* Name of table into which we are inserting */
111339 Table *pTab; /* The table to insert into. aka TABLE */
111342 Index *pIdx; /* For looping over indices of the table */
111344 int nHidden = 0; /* Number of hidden columns if TABLE is virtual */
111353 int iDb; /* Index of database holding TABLE */
111354 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
111356 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
111357 u8 bIdListInOrder; /* True if IDLIST is in table order */
111392 /* Locate the table into which we will be inserting new information.
111407 /* Figure out if we have any triggers and if the table being
111431 /* Cannot insert into a read-only table.
111461 /* If this is an AUTOINCREMENT table, look up the sequence number in the
111462 ** sqlite_sequence table and store it in memory cell regAutoinc.
111478 ** all elements of the IDLIST really are columns of the table and
111481 ** If the table has an INTEGER PRIMARY KEY column and that column
111485 ** is appears in the original table. (The index of the INTEGER
111486 ** PRIMARY KEY in the original table is pTab->iPKey.)
111509 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
111545 ** should be written into a temporary table (template 4). Set to
111547 ** the destination table (template 3).
111549 ** A temp table must be used if the table being updated is also one
111551 ** temp table in the case of row triggers.
111559 ** and add it to a transient table srcTab. The code generated
111562 ** B: open temp table
111564 ** insert row from R..R+n into temp table
111569 int regTempRowid; /* Register to hold temp table ROWID */
111604 /* If there is no IDLIST term but the table has an integer primary
111606 ** column index in the original table definition.
111613 ** of columns to be inserted into the table.
111620 "table %S has %d columns but %d values were supplied",
111636 /* If this is not a view, open the table and and all indices */
111657 ** rewind temp table, if empty goto D
111658 ** C: loop over rows of intermediate table
111659 ** transfer values form intermediate table into <table>
111670 ** insert the select result into <table> from R..R+n
111707 /* Cannot have triggers on a virtual table. If it were possible,
111734 ** If this is a real table, attempt conversions as required by the
111735 ** table column affinities.
111858 ** constraints or (b) there are no triggers and this table is not a
111859 ** parent table in a foreign key constraint. It is safe to set the
111900 /* Update the sqlite_sequence table by storing the content of the
111995 ** on table pTab.
112001 ** case of a WITHOUT ROWID table. The second register in the range will
112002 ** contain the content of the first table column. The third register will
112003 ** contain the content of the second table column. And so forth.
112011 ** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)
112013 ** the iDataCur content table is guaranteed to be unchanged by the UPDATE.
112018 ** that the table is a WITHOUT ROWID table and has no rowid. On an INSERT,
112029 ** table and all applicable indices (that is to say, all indices for which
112030 ** aRegIdx[] is not zero). iDataCur is the cursor for the main table when
112031 ** inserting or updating a rowid table, or the cursor for the PRIMARY KEY
112032 ** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor
112078 Table *pTab, /* The table being inserted or updated */
112080 int iDataCur, /* Canonical data cursor (main table or PK index) */
112110 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
112115 ** pPk index or 1 for a rowid table. In other words, nPkField is the
112116 ** number of fields in the true primary key of the table. */
112212 ** exist in the table.
112248 /* Check to see if the new rowid already exists in the table. Skip
112266 /* If there are DELETE triggers on this table and the
112268 ** remove the conflicting row from the table. This will fire
112269 ** the triggers and remove both the table and index b-tree entries.
112272 ** flag is not set, but the table has one or more indexes, call
112274 ** only. The table b-tree entry will be replaced by the new entry
112286 ** table.
112333 ** WITHOUT ROWID table.
112387 ** of a WITHOUT ROWID table and there has been no change the
112409 ** (2) The table is a WITHOUT ROWID table
112410 ** (3) There are no secondary indexes on the table
112458 ** table, only conflict if the new PRIMARY KEY values are actually
112531 ** to be the number of columns in table pTab that must not be NULL-trimmed.
112535 SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){
112561 Table *pTab, /* the table into which we are inserting */
112574 int regRec; /* Register holding assembled record for the table */
112585 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
112641 ** Allocate cursors for the pTab table and all its indices and generate
112645 ** the table itself, but the PRIMARY KEY index in the case of a WITHOUT
112646 ** ROWID table) is returned in *piDataCur. The first index cursor is
112653 ** For a rowid table, *piDataCur will be exactly one less than *piIdxCur.
112654 ** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range
112658 ** If pTab is a virtual table, then this routine is a no-op and the
112663 Table *pTab, /* Table to be opened */
112666 int iBase, /* Use this for the table cursor, if there is one */
112667 u8 *aToOpen, /* If not NULL: boolean for each table and index */
112789 ** Sometimes the xfer optimization will only work if the destination table
112792 ** does a test to see if the destination table is empty and jumps over the
112802 Table *pDest, /* The table we are inserting into */
112809 Table *pSrc; /* The table in the FROM clause of SELECT */
112828 ** attached to it. Proceeding may generate a false "no such table: xxx"
112837 return 0; /* tab1 must not be a virtual table */
112888 return 0; /* FROM clause does not contain a real table */
112891 return 0; /* tab1 and tab2 may not be the same table */
112898 return 0; /* tab2 must not be a virtual table */
112917 return 0; /* Neither table may have __hidden__ columns */
112958 /* Disallow the transfer optimization if the destination table constains
112975 ** table (tab1) is initially empty.
112996 ** only if the destination table is initially empty. Unless the
112999 ** table is always empty.
113068 ** that the destination table is empty. If all indexed columns use
114683 ** object. This ensures that the aPragmaName[] table is arranged in
114795 /* 36 */ "table",
114801 /* 42 */ "table", /* Used by: foreign_key_check */
115726 /* Locate the pragma in the lookup table */
116382 ** PRAGMA table_info(<table>)
116384 ** Return a single row for each column of the named table. The columns of
116395 Table *pTab;
116437 Table *pTab = sqliteHashData(i);
116459 Table *pTab;
116494 Table *pTab;
116582 Table *pTab;
116616 Table *pTab; /* Child table contain "REFERENCES" keyword */
116617 Table *pParent; /* Parent table that child points to */
116618 Index *pIdx; /* Index in the parent table */
116621 HashElem *k; /* Loop counter: Next table in schema */
116641 pTab = (Table*)sqliteHashData(k);
116801 int mxIdx = 0; /* Maximum number of indexes for any table */
116816 Table *pTab = sqliteHashData(x); /* Current table */
116826 Table *pTab = sqliteHashData(x);
116853 Table *pTab = sqliteHashData(x);
116865 /* reg[7] counts the number of entries in the table.
116930 /* Verify that an index entry exists for the current table row */
117107 ** creating or dropping a table or index). The schema version is used by
117268 ** In the current implementation, a table is analyzed if only if all of
117274 ** more indexes of the table at some point during the lifetime of
117277 ** (3) One or more indexes of the table are currently unanalyzed OR
117278 ** the number of rows in the table has increased by 25 times or more
117286 int iTabCur; /* Cursor for a table whose size needs checking */
117289 Table *pTab; /* A table in the schema */
117290 Index *pIdx; /* An index of the table */
117307 pTab = (Table*)sqliteHashData(k);
117309 /* If table pTab has not been used in a way that would benefit from
117314 /* Reanalyze if the table is 25 times larger than the last analysis */
117488 ** Implementation of an eponymous virtual table that runs a pragma.
117508 ** Pragma virtual table module xConnect method.
117528 sqlite3StrAccumAppendAll(&acc, "CREATE TABLE x");
117571 ** Pragma virtual table module xDisconnect method.
117579 /* Figure out the best index to use to search a pragma virtual table.
117622 /* Create a new cursor for the pragma virtual table */
117633 /* Clear all content from pragma virtual table cursor. */
117644 /* Close a pragma virtual table cursor */
117652 /* Advance the pragma virtual table cursor to the next row */
117669 ** Pragma virtual table module xFilter method.
117719 ** Pragma virtual table module xEof method.
117745 ** Pragma virtual table module xRowid method.
117753 /* The pragma virtual table object */
117756 0, /* xCreate - create a table */
117757 pragmaVtabConnect, /* xConnect - connect to an existing table */
117759 pragmaVtabDisconnect, /* xDisconnect - Disconnect from a table */
117760 0, /* xDestroy - Drop a table */
117774 0, /* xRename - rename the table */
117782 ** then register an eponymous virtual table for that pragma and return
117783 ** a pointer to the Module object for the new virtual table.
117847 ** argv[1] = root page number for table or index. 0 for trigger or view.
117870 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
117873 ** structures that describe the table, index, or view.
117907 ** constraint for a CREATE TABLE. The index should have already
117908 ** been created when we processed the CREATE TABLE. All we have
117914 /* This can occur if there exists an index on a TEMP table which
117916 ** the permanent table is hidden by the TEMP table, we can also
117917 ** safely ignore the index on the permanent table.
117957 ** table name will be inserted automatically by the parser so we can just
117959 ** the schema table as read-only. */
117962 azArg[2] = "CREATE TABLE x(type text,name text,tbl_name text,"
118063 ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN
118123 ** purpose of this is to allow access to the sqlite_master table
118265 ** expr.c is trying to resolve a reference to a transient table (i.e. one
118501 ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error
118743 int tabTnct; /* Ephemeral table used for DISTINCT processing */
118957 ** Return the index of a column in a table. Return -1 if the column
118958 ** is not contained in the table.
118960 static int columnIndex(Table *pTab, const char *zCol){
118970 ** table that has a column named zCol.
118972 ** When found, set *piTab and *piCol to the table index and column index
119008 ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the
119015 int iLeft, /* Index of first table to join in pSrc */
119016 int iColLeft, /* Index of column in first table */
119017 int iRight, /* Index of second table in pSrc */
119018 int iColRight, /* Index of column in second table */
119058 ** expression depends on table iRightJoinTable even if that table is not
119094 ** The left most table is the first entry in Select.pSrc. The right-most
119095 ** table is the last entry. The join operator is held in the entry to
119105 struct SrcList_item *pLeft; /* Left table being joined */
119106 struct SrcList_item *pRight; /* Right table being joined */
119112 Table *pRightTab = pRight->pTab;
119128 char *zName; /* Name of column in the right table */
119129 int iLeft; /* Matching left table */
119130 int iLeftCol; /* Matching column in the left table */
119168 int iLeft; /* Table on the left with matching column name */
119247 KeyInfo *pKI; /* Original KeyInfo on the sorter table */
119373 int srcTab, /* Pull data from this table if non-negative */
119420 ** there are columns in the table on the left. The error will be caught
119528 ** table iParm.
119542 ** the temporary table iParm.
119568 ** output table as well. */
119592 ** item into the set table with bogus data.
119886 int bUseTmp /* True if a temp table was used */
120044 ** original CREATE TABLE statement if the expression is a column. The
120090 /* The expression is a column. Locate the table the column is being
120091 ** extracted from in NameContext.pSrcList. This table may be real
120092 ** database table or a subquery.
120094 Table *pTab = 0; /* Table structure column is extracted from */
120115 ** CREATE TABLE t1(col INTEGER);
120131 /* The "table" is actually a sub-select or a view in the FROM clause
120148 /* A real table or a CTE table */
120269 ** refers directly to a table column, then the
120270 ** result column name is just the table column
120273 ** full=ON, short=ANY: If the result refers directly to a table column,
120274 ** then the result column name with the table name
120275 ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan.
120283 Table *pTab;
120287 int fullName; /* TABLE.COLUMN if no AS clause and is a direct table ref */
120288 int srcName; /* COLUMN or TABLE.COLUMN if no AS clause and is direct */
120350 ** column names for a table that would hold the expression list.
120382 Hash ht; /* Hash table of column names */
120413 Table *pTab = pColExpr->pTab;
120476 Table *pTab, /* Add column type information to this table */
120520 ** Given a SELECT statement, generate a Table structure that describes
120523 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
120524 Table *pTab;
120535 pTab = sqlite3DbMallocZero(db, sizeof(Table) );
120713 ** <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)
120718 ** There is exactly one reference to the recursive-table in the FROM clause
120722 ** into a Queue table. Rows are extracted from the Queue table one by
120724 ** extracted row (now in the iCurrent table) becomes the content of the
120725 ** recursive-table for a recursive-query run. The output of the recursive-query
120726 ** is added back into the Queue table. Then another row is extracted from Queue
120727 ** and the iteration continues until the Queue table is empty.
120730 ** inserted into the Queue table. The iDistinct table keeps a copy of all rows
120734 ** If the query has an ORDER BY, then entries in the Queue table are kept in
120736 ** an ORDER BY, the Queue table is just a FIFO.
120751 int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
120756 int iCurrent = 0; /* The Current table */
120757 int regCurrent; /* Register holding Current table */
120758 int iQueue; /* The Queue table */
120761 SelectDest destQueue; /* SelectDest targetting the Queue table */
120782 /* Locate the cursor number of the Current table */
120791 ** the Distinct table must be exactly one greater than Queue in order
120813 VdbeComment((v, "Queue table"));
120852 ** the value for the recursive-table. Store the results in the Queue.
120994 /* Create the destination temporary table if necessary
121073 int unionTab; /* Cursor number of the temporary table holding result */
121084 /* We can reuse a temporary table generated by a SELECT to our
121090 /* We will need to create our own temporary table to hold the
121141 /* Convert the data in the temporary table into whatever form
121184 /* Code the SELECTs to our left into temporary table "tab1".
121193 /* Code the current SELECT into temporary table "tab2"
121840 ** All references to columns in table iTable are to be replaced by corresponding
121845 int iTable; /* Replace references to this table */
121846 int iNewTable; /* New table number */
121857 ** a column in table number iTable with a copy of the iColumn-th
121865 ** changes to pExpr so that it refers directly to the source table
121972 ** subquery first and store the results in a temporary table, then
121973 ** run the outer query on that temporary table. This requires two
121974 ** passes over the data. Furthermore, because the temporary table
121985 ** exist on the table t1, a complete scan of the data might be
122004 ** table and
122018 ** table sqlite_once that consists of a single row containing a
122123 int iParent; /* VDBE cursor number of the pSub result set temp table */
122124 int iNewParent = -1;/* Replacement table for iParent */
122188 ** the LEFT JOIN table should be all-NULL.
122329 /* Delete the transient table structure associated with the
122340 /* Defer deleting the Table object associated with the
122348 Table *pTabToDel = pSubitem->pTab;
122532 ** (2) The inner query is the recursive part of a common table expression.
122651 ** where table is a database table, not a sub-select or view. If the query
122652 ** does match this pattern, then a pointer to the Table object representing
122655 static Table
122656 Table *pTab;
122688 Table *pTab = pFrom->pTab;
122775 ** Check to see if the FROM clause term pFrom has table-valued function
122777 ** non-zero, since pFrom is not allowed to be a table-valued function.
122790 ** WITH contexts, from inner to outermost. If the table identified by
122791 ** FROM clause element pItem is really a common-table-expression (CTE)
122792 ** then return a pointer to the CTE definition for that table. Otherwise
122867 Table *pTab;
122885 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
122919 pParse, "multiple references to recursive table: %s", pCte->zName
122944 sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
122976 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
123012 ** for instances of the "*" operator or the TABLE.* operator.
123013 ** If found, expand each "*" to be every column in every table
123014 ** and TABLE.* to be every column in TABLE.
123047 /* Look up every table named in the FROM clause of the select. If
123048 ** an entry of the FROM clause is a subquery instead of a table or view,
123049 ** then create a transient table structure to describe the subquery.
123052 Table *pTab;
123067 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
123082 /* An ordinary table or view name in the FROM clause */
123124 ** all columns in all tables. And for every TABLE.* insert the names
123125 ** of all columns in TABLE. The parser inserted a special expression
123173 /* This expression is a "*" or a "TABLE.*" and needs to be
123175 int tableSeen = 0; /* Set to 1 when TABLE matches */
123176 char *zTName = 0; /* text of name of TABLE */
123183 Table *pTab = pFrom->pTab;
123229 ** table to the right of the join */
123234 ** using clause from the table on the right. */
123276 sqlite3ErrorMsg(pParse, "no such table: %s", zTName);
123365 ** information to the Table structure that represents the result set
123368 ** The Table structure that represents the result set was constructed
123385 Table *pTab = pFrom->pTab;
123402 ** the Table structures of all FROM-clause subqueries in a
123424 ** * Ephemeral Table objects are created for all FROM-clause subqueries.
123426 ** * Wildcards "*" and "TABLE.*" in result sets are expanded.
123596 Table *pTab, /* Table being queried */
123601 char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s%s%s",
123743 if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */
123896 Table *pTab = pItem->pTab;
123927 ** are output, rather than every row of the table.
123991 ** The fake column name is an empty string. It is possible for a table to
123993 ** distinguish between an unreferenced table and an actual reference to the
124084 /* Generate a subroutine that will fill an ephemeral table with
124166 ** The second form is preferred as a single index (or temp-table) may be
124168 ** written the query must use a temp-table for at least one of the ORDER
124169 ** BY and DISTINCT, and an index or separate temp-table for the other.
124210 /* If the output is destined for a temporary table, open that table.
124443 ** we do not have to sort. The OP_OpenEphemeral table will be
124501 /* If the index or temporary table used by the GROUP BY sort
124503 ** clause, cancel the ephemeral table open coded earlier.
124617 Table *pTab;
124619 /* If isSimpleCount() returns a pointer to a Table structure, then
124624 ** where the Table structure returned represents table <tbl>.
124627 ** OP_Count instruction is executed either on the intkey table that
124628 ** contains the data for table <tbl> or on one of its indexes. It
124753 /************** Begin file table.c *******************************************/
124791 ** This routine is called once for each row in the result table. Its job
124866 ** Instead, the entire table should be passed to sqlite3_free_table() when
124872 char ***pazResult, /* Write the result table here */
124953 /************** End of table.c ***********************************************/
124989 ** Given table pTab, return a list of all the triggers attached to
124990 ** the table. The list is connected by Trigger.pNext pointers.
125002 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
125016 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
125042 SrcList *pTableName,/* The name of the table/view the trigger applies to */
125048 Table *pTab; /* Table that the trigger fires off of */
125091 /* If the trigger name was unqualified, and the table is a temp table,
125093 ** If sqlite3SrcListLookup() returns 0, indicating the table does not
125102 /* Ensure the table name matches database name and that the table exists */
125111 /* The table does not exist. */
125114 ** Normally, whenever a table is dropped, all associated triggers are
125115 ** dropped too. But if a TEMP trigger is created on a non-TEMP table
125116 ** and the table is dropped by a different database connection, the
125119 ** "orphaned trigger" - a trigger whose associated table is missing.
125147 /* Do not create a trigger on a system table */
125149 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
125163 " trigger on table: %S", pTableName, 0);
125197 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
125259 /* Make an entry in the sqlite_master table */
125268 pTrig->table, z);
125283 Table *pTab;
125284 pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);
125369 Token *pTableName, /* Name of the table into which we insert */
125400 Token *pTableName, /* Name of the table to be updated */
125427 Token *pTableName, /* The table from which rows are deleted */
125450 sqlite3DbFree(db, pTrigger->table);
125503 ** Return a pointer to the Table structure for the table that a trigger
125506 static Table *tableOfTrigger(Trigger *pTrigger){
125507 return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table);
125515 Table *pTable;
125563 Table *pTab = tableOfTrigger(pTrigger);
125592 ** Return a list of all triggers on table pTab if there exists at least
125594 ** performed on the table, and, if that operation is an UPDATE, if at
125599 Table *pTab, /* The table the contains the triggers */
125782 Table *pTab, /* The table pTrigger is attached to */
125897 Table *pTab, /* The table trigger pTrigger is attached to */
125924 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
125931 Table *pTab, /* The table to code triggers from */
125962 ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
125972 ** in the trigger program. If N is the number of columns in table pTab
126002 Trigger *pTrigger, /* List of triggers on table pTab */
126006 Table *pTab, /* The table to code triggers from */
126019 /* Sanity checking: The schema for the trigger and for the table are
126020 ** always defined. The trigger must be in the same schema as the table
126038 ** Triggers may access values stored in the old.* or new.* pseudo-table.
126045 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
126047 ** are more than 32 columns in the table, and at least one of the columns
126054 ** applies to the old.* table. If 1, the new.* table.
126064 Trigger *pTrigger, /* List of triggers on table pTab */
126068 Table *pTab, /* The table to code triggers from */
126115 SrcList *pSrc, /* The virtual table to be modified */
126116 Table *pTab, /* The virtual table */
126127 ** i-th column of table pTab. This routine sets the P4 parameter of the
126131 ** column definition. This was either supplied by the user when the table
126132 ** was created, or added later to the table definition by an ALTER TABLE
126133 ** command. If the latter, then the row-records in the table btree on disk
126139 ** Column definitions created by an ALTER TABLE command may only have
126142 ** when the ALTER TABLE is executed and one of the literal values written
126143 ** into the sqlite_master table.)
126155 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
126185 SrcList *pTabList, /* The table in which we should change things */
126193 Table *pTab; /* The table to be updated */
126206 ** an expression for the i-th column of the table.
126209 u8 chngPk; /* PRIMARY KEY changed in a WITHOUT ROWID table */
126210 u8 chngRowid; /* Rowid changed in a normal table */
126215 int iDb; /* Database containing the table being updated */
126228 int iEph = 0; /* Ephemeral table holding all primary key values */
126240 int regNew = 0; /* Content of the NEW.* table in triggers */
126241 int regOld = 0; /* Content of OLD.* table in triggers */
126252 /* Locate the table which we want to update.
126258 /* Figure out if we have any triggers and if the table being
126292 /* Allocate a cursors for the main database table and for all indices.
126378 ** So reset the colUsed mask. Unless this is a virtual table. In that
126380 ** table implementation makes all columns available).
126386 /* There is one entry in the aRegIdx[] array for each index on the table
126449 ** an ephemeral table.
126503 ** things might disturb a cursor being used to scan through the table
126542 ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
126543 ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table
126646 ** table and index records, and as the values for any new.* references
126816 /* Update the sqlite_sequence table by storing the content of the
126859 ** Generate code for an UPDATE of a virtual table.
126862 ** "onepass" strategy. Onepass is only used if the virtual table
126865 ** The default strategy is to create an ephemeral table that contains
126872 ** Then loop through the contents of this ephemeral table executing a
126873 ** VUpdate for each row. When finished, drop the ephemeral table.
126875 ** The "onepass" strategy does not use an ephemeral table. Instead, it
126881 SrcList *pSrc, /* The virtual table to be modified */
126882 Table *pTab, /* The virtual table */
126890 int ephemTab; /* Table holding the result of the SELECT */
126898 int regRowid; /* Register for ephem table rowid */
126899 int iCsr = pSrc->a[0].iCursor; /* Cursor used for virtual table scan */
126905 ** create and open the ephemeral table in which the records created from
126915 /* Start scanning the virtual table */
126958 ** the ephemeral table. */
126971 /* End the virtual table scan */
126974 /* Begin scannning through the ephemeral table. */
126977 /* Extract arguments from the current row of the ephemeral table and
126988 /* End of the ephemeral table scan. Or, if using the onepass strategy,
127250 " WHERE type='table'AND name<>'sqlite_sequence'"
127271 "WHERE type='table'AND coalesce(rootpage,1)>0",
127281 ** from the SQLITE_MASTER table.
127287 " OR(type='table'AND rootpage=0)",
127393 ** Before a virtual table xCreate() or xConnect() method is invoked, the
127400 VTable *pVTable; /* The virtual table being constructed */
127401 Table *pTab; /* The Table object to which the virtual table belongs */
127407 ** Construct and install a Module object for a virtual table. When this
127471 ** External API function used to create a new virtual-table module.
127486 ** External API function used to create a new virtual-table module.
127502 ** Lock the virtual table so that it cannot be disconnected.
127506 ** If a disconnect is attempted while a virtual table is locked,
127515 ** pTab is a pointer to a Table structure representing a virtual-table.
127517 ** this virtual-table, if one has been created, or NULL otherwise.
127519 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
127527 ** Decrement the ref-count on a virtual table object. When the ref-count
127548 ** Table p is a virtual table. This function moves all elements in the
127554 static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
127560 ** that contains table p is held by the caller. See header comments
127587 ** Table *p is a virtual table. This function removes the VTable object
127588 ** for table *p associated with database connection db from the linked
127594 SQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){
127613 ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
127625 ** associated with the database the virtual table is stored in is held
127626 ** or, if the virtual table is stored in a non-sharable database, then
127650 ** Clear any and all virtual-table information from the Table record.
127651 ** This routine is called, for example, just before deleting the Table
127654 ** Since it is a virtual-table, the Table structure contains a pointer
127663 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
127677 ** string will be freed automatically when the table is
127680 static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
127695 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
127701 Token *pName1, /* Name of new table, or database name */
127702 Token *pName2, /* Name of new table or NULL */
127703 Token *pModuleName, /* Name of the module for the virtual table */
127704 int ifNotExists /* No error if the table already exists */
127706 int iDb; /* The database the table is being created in */
127707 Table *pTable; /* The new virtual table */
127731 /* Creating a virtual table invokes the authorization callback twice.
127733 ** sqlite_master table, has already been made by sqlite3StartTable().
127734 ** The second call, to obtain permission to create the table, is made now.
127746 ** virtual table currently under construction in pParse->pTable.
127758 ** The parser calls this routine after the CREATE VIRTUAL TABLE statement
127762 Table *pTab = pParse->pNewTable; /* The table being constructed */
127770 /* If the CREATE VIRTUAL TABLE statement is being entered for the
127771 ** first time (in other words if the virtual table is actually being
127774 ** in the sqlite_master table.
127783 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
127787 zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
127790 ** SQLITE_MASTER table. We just need to update that slot with all
127794 ** entry in the sqlite_master table tht was created for this vtab
127800 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
127813 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
127821 /* If we are rereading the sqlite_master table create the in-memory
127822 ** record of the table. The xConnect() method is not called until
127823 ** the first time the virtual table is used in an SQL statement. This
127825 ** the required virtual table implementations are registered. */
127827 Table *pOld;
127843 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
127853 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
127867 ** Invoke a virtual table constructor (either xCreate or xConnect). The
127873 Table *pTab,
127888 /* Check that the virtual-table is not already being initialized */
127915 /* Invoke the virtual table constructor */
127952 ** columns of the table to see if any of them contain the token "hidden".
127996 ** of the virtual table pTab. If an error occurs, an error code is returned
127999 ** This call is a no-op if table pTab is not a virtual table.
128001 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
128012 /* Locate the required virtual table module */
128034 ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.
128055 ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should
128066 ** of the virtual table named zTab in database iDb.
128074 Table *pTab;
128081 /* Locate the required virtual table module */
128109 ** This function is used to set the schema of a virtual table. It is only
128111 ** virtual table module.
128116 Table *pTab;
128146 Table *pNew = sParse.pNewTable;
128193 ** of the virtual table named zTab in database iDb. This occurs
128194 ** when a DROP TABLE is mentioned.
128196 ** This call is a no-op if zTab is not a virtual table.
128200 Table *pTab;
128214 assert( xDestroy!=0 ); /* Checked before the virtual table is created */
128301 ** If the virtual table pVtab supports the transaction interface
128356 ** as the second argument to the virtual table method invoked.
128360 ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
128363 ** If any virtual table method returns an error code other than SQLITE_OK,
128365 ** function immediately. If all calls to virtual table methods are successful,
128404 ** If pExpr is a column in a virtual table, then let the virtual
128405 ** table implementation have an opportunity to overload the function.
128407 ** This routine is used to allow virtual table implementations to
128420 Table *pTab;
128431 /* Check to see the left operand is a column in a virtual table */
128443 /* Call the xFindFunction method on the virtual table implementation
128475 ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
128480 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
128483 Table **apVtabLock;
128500 ** Check to see if virtual table module pMod can be have an eponymous
128501 ** virtual table instance. If it can, create one if one does not already
128502 ** exist. Return non-zero if the eponymous virtual table instance exists
128505 ** An eponymous virtual table instance is one that is named after its
128506 ** module, and more importantly, does not require a CREATE VIRTUAL TABLE
128507 ** statement in order to come into existance. Eponymous virtual table
128510 ** Any virtual table module for which xConnect and xCreate are the same
128511 ** method can have an eponymous virtual table instance.
128515 Table *pTab;
128521 pTab = sqlite3DbMallocZero(db, sizeof(Table));
128547 ** Erase the eponymous virtual table instance associated with
128548 ** virtual table module pMod, if it exists.
128551 Table *pTab = pMod->pEpoTab;
128553 /* Mark the table as Ephemeral prior to deleting it, so that the
128564 ** table update operation currently in progress.
128585 ** of the virtual table being implemented.
128707 int iTabCur; /* The VDBE cursor used to access the table */
128756 Bitmask maskSelf; /* Bitmask identifying table iTab */
128760 u8 iTab; /* Position in FROM clause of table for this loop */
129111 SrcList *pTabList, /* Table list this loop refers to */
129192 #define WHERE_IDX_ONLY 0x00000040 /* Use index only - omit table */
129258 ** Argument pLevel describes a strategy for scanning table pTab. This
129259 ** function appends text to pStr that describes the subset of table
129300 ** is added to the output to describe the table scan strategy in pLevel.
129307 SrcList *pTabList, /* Table list this loop refers to */
129342 sqlite3XPrintf(&str, " TABLE %s", pItem->zName);
129389 sqlite3XPrintf(&str, " VIRTUAL TABLE INDEX %d:%s",
129579 ** CREATE TABLE t1(a,b,c,d,e,f);
129799 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
129831 ** CREATE TABLE t1(a TEXT PRIMARY KEY, b);
129987 int iTabCur; /* Cursor for the main table */
129989 Index *pIdx; /* The index used to access the table */
129995 ** the table CCurHint.iTabCur, verify that the same column can be
130012 ** should be included in the cursor-hint for a table that is on the rhs
130046 ** that accesses any table other than the one identified by
130055 ** Also, if the node is a TK_COLUMN that does access the table idenified
130058 ** an access of the index rather than the original table.
130127 ** JOIN for which the current table is not the rhs are omitted
130130 ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
130198 ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
130210 ** containing one entry for each column of the table cursor iCur is open
130211 ** on. For each table column, if the column is the i'th column of the
130232 Table *pTab = pIdx->pTable;
130279 ** mapping from an expression on table columns into a column in an index
130284 int iTabCur; /* The cursor of the corresponding table */
130315 int iTabCur, /* Cursor of the table that is being indexed */
130351 int iCur; /* The VDBE cursor for the table */
130398 /* If this is the right table of a LEFT OUTER JOIN, allocate and
130399 ** initialize a memory cell that records if this table matches any
130400 ** row of the left table of the join.
130408 /* Compute a safe address to jump to if we discover that the table for
130425 /* Case 1: The table is a virtual-table. Use the VFilter and VNext
130897 /* Seek the table cursor, if required */
130899 /* pIdx is a covering index. No need to access the main table. */
130955 ** CREATE TABLE t1(a,b,c,d);
130989 ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then
130995 SrcList *pOrTab; /* Shortened table list or OR-clause generation */
131008 Table *pTab = pTabItem->pTab;
131018 /* Set up a new SrcList in pOrTab containing the table being scanned
131114 /* Loop through table entries that match term pOrTerm. */
131151 /* Check if the temp table already contains this key. If so,
131154 ** insert the key into the temp table and proceed with processing
131159 ** the temp table. And if iSet is -1, assume that there is no
131160 ** need to insert the key into the temp table, as it will never
131186 ** contained one or more AND term from a notReady table. The
131187 ** terms from the notReady table could not be tested and will
131216 /* Finish the loop through table entries that match term pOrTerm. */
131238 ** scan of the entire table.
131367 ** at least one row of the right table has matched the left table.
131626 ** be an ordinary column (not a virtual table column) with TEXT affinity.
131710 ** Expression Virtual Table Operator
131722 ** In every case, "column" must be a column of a virtual table. If there
131726 ** appropriate virtual table operator. The return value is 1 or 2 if there
131728 ** of virtual table in forms (5) or (7) then return 2.
131912 ** a single table T (as shown in example B above) then create a new virtual
131934 ** If all subterms are indexable by a single table T, then set
131937 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
131940 ** "T.C <op> <expr>" where C is any column of table T and
132091 ** something other than == on a column in the single table. The 1-bit
132093 ** "table.column=expr" for some single table. The one bit that is set
132094 ** will correspond to the common table. We still need to check to make
132101 ** Note that terms of the form "table.column1=table.column2" (the
132102 ** same table on both sizes of the ==) cannot be optimized.
132107 int iCursor = -1; /* Table cursor common to all terms */
132110 /* Search for a table and column that appears on one side or the
132111 ** other of the == operator in every subterm. That table and column
132113 ** such table and column. Set okToChngToIN if an appropriate table
132143 /* No candidate table+column was found. This can only occur
132152 /* We have found a candidate table and column. Check to see if that
132153 ** table and column is common to every term in the OR clause */
132283 ** number of the table that is indexed and aiCurCol[1] to the column number
132294 int *aiCurCol, /* Write the referenced table cursor and column here */
132318 int *aiCurCol, /* Write the referenced table cursor & column here */
132337 if( mPrereq==0 ) return 0; /* No table references */
132338 if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
132367 WhereMaskSet *pMaskSet; /* Set of table index masks */
132410 ** on left table of a LEFT JOIN. Ticket #3015 */
132884 ** For table-valued-functions, transform the function arguments into
132888 ** a HIDDEN column in the table.
132895 Table *pTab;
132938 ** generating the code that loops through a table looking for applicable
133032 ** table and iaCur[1] gets the cursor used by an auxiliary index.
133117 ** There is one cursor per table in the FROM clause. The number of
133219 ** for terms of the form "X <op> <expr>" where X is column iColumn of table
133221 ** must be one of the indexes of table iCur.
133272 ** where X is a reference to the iColumn of table iCur or of index pIdx
133276 ** If pIdx!=0 then it must be one of the indexes of table iCur.
133278 ** rather than the iColumn-th column of table iCur.
133291 ** the form "X <op> Y" where Y is a column in another table if no terms of
133332 int iBase, /* Cursor for table associated with pIdx */
133387 Table *pTab;
133392 /* If there is more than one table or sub-select in the FROM clause of
133399 /* If any of the expressions is an IPK column on table iBase, then return
133408 /* Loop through all indices on the table, checking each to see if it makes
133450 ** opcodes into OP_Copy when the table is being accessed via co-routine
133451 ** instead of via table lookup.
133461 int iTabCur, /* OP_Column/OP_Rowid references to this table */
133544 struct SrcList_item *pSrc, /* Table we are trying to access */
133588 Table *pTable; /* The table being indexed */
133623 || pLoop->prereq!=0 ); /* table of a LEFT JOIN */
133659 ** original table never needs to be accessed. Automatic indices must
133661 ** original table changes and the index and table cannot both be used
133802 ** to this virtual table */
133818 ** virtual table then allocate space for the aOrderBy part of
133919 ** The table object reference passed as the second argument to this function
133920 ** must represent a virtual table. This function invokes the xBestIndex()
133921 ** method of the virtual table with the sqlite3_index_info object that
133932 static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
133958 "table %s: xBestIndex returned an invalid plan", pTab->zName);
134681 Table *pTab = pItem->pTab;
135123 ** table statistics.
135132 ** of rows in the table. In other words, assume that x==EXPR will filter
135141 LogEst nRow /* Number of rows in the entire table */
135227 ** the right column of the right source table. And that the sort
135294 LogEst rSize; /* Number of rows in the table */
135295 LogEst rLogSize; /* Logarithm of table size */
135348 ** right table of a LEFT JOIN. Only constraints in the ON clause are
135512 ** visiting the rows in the main table. */
135630 ** the table is used by an index. Only the first 63 columns are considered.
135670 ** Add all WhereLoop objects for a single table of the join where the table
135671 ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be
135672 ** a b-tree table, not a virtual table.
135677 ** For a full scan, assuming the table (or index) contains nRow rows:
135679 ** cost = nRow * 3.0 // full-table scan
135684 ** estimated average size of the index and table records.
135703 ** of a full table scan.
135707 Bitmask mPrereq /* Extra prerequesites for using this table */
135720 LogEst rSize; /* number of rows in the table */
135721 LogEst rLogSize; /* Logarithm of the number of rows in the table */
135723 Table *pTab; /* Table being queried */
135743 Index *pFirst; /* First of real indices on the table */
135756 /* The real indices of the table are only considered if the
135772 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
135774 && !pSrc->fg.isRecursive /* Not a recursive common table expression. */
135789 ** the table being indexed and where X is 7 (LogEst=28) for normal
135801 /* TUNING: Each index lookup yields 20 rows in the table. This
135844 /* Full table scan */
135846 /* TUNING: Cost of full table scan is (N*3.0). */
135879 ** index and table rows. */
135883 ** doing table lookups. The cost will be 3x the number of
135886 ** table lookup. */
135897 ** the expected number of table lookups accordingly */
135938 ** be used by the virtual table identified by pBuilder->pNew->iTab. This
135950 ** virtual table in question. These are added to the plans prerequisites
136004 /* Invoke the virtual table xBestIndex() method */
136040 /* A virtual table that is constrained by an IN clause may not
136107 ** Add all WhereLoop objects for a table of the join identified by
136108 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
136112 ** entries that occur before the virtual table in the FROM clause and are
136115 ** virtual table and are separated from it by at least one LEFT or
136125 ** table. So any terms for which all prerequisites are satisfied by
136128 ** virtual table, so any terms for which the prerequisites overlap with
136198 ** in the set of terms that apply to the current virtual table. */
136359 ** the planner may elect to "OR" together a full-table scan and an
136465 int iColumn; /* A column number within table iCur */
136494 ** The rowid for a table is always UNIQUE and NOT NULL so whenever the
136527 /* Mark off any ORDER BY term X that is a column in the table of
136618 /* Get the column number in the table (iColumn) and sort order
137189 ** Most queries use only a single table (they are not joins) and have
137207 Table *pTab;
137313 ** The basic idea is to do a nested loop, one loop for each table in
137315 ** same as a SELECT with only a single table in the FROM clause.) For
137336 ** There are Btree cursors associated with each table. t1 uses cursor
137349 ** refer to those indices, a complete table scan can be avoided and the
137451 ** only generate code for the first table in pTabList and assume that
137515 ** a table T, then X-1 is the bitmask for all other tables to the left of T.
137647 ** For a table to not affect the result, the following must be true:
137650 ** 2) The table must be the RHS of a LEFT JOIN.
137652 ** must contain a constraint that limits the scan of the table to
137654 ** 4) The table must not be referenced by any part of the query apart
137659 ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
137660 ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
137661 ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
137663 ** then table t2 can be omitted from the following:
137735 ** * the table is not a virtual table, and
137768 Table *pTab; /* Table to open */
137769 int iDb; /* Index of database containing table/index */
137831 ** WITHOUT ROWID table. No need for a separate index */
138050 Table *pTab = pTabItem->pTab;
138054 /* For a co-routine, change all OP_Column references to the table of
138066 ** from the index instead of from the table where possible. In some cases
138067 ** this optimization prevents the table from ever being read, which can
138071 ** sqlite3WhereEnd will have created code that references the table
138073 ** that reference the table and converts them into opcodes that
138428 ** slots in the yy_action[] table.
138433 ** The action table is constructed as a single large table named yy_action[].
138449 ** yy_action[] A single table containing all actions.
138450 ** yy_lookahead[] A table containing the lookahead for each entry in
138930 /* The next table maps tokens (terminal symbols) into fallback tokens.
138962 0, /* TABLE => nothing */
139113 ** are required. The following table supplies these names */
139131 /* 16 */ "TABLE",
139387 /* 13 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
139448 /* 74 */ "cmd ::= DROP TABLE ifexists fullname",
139632 /* 258 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
139633 /* 259 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
139637 /* 263 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
140179 /* The following table contains information about every rule that
140199 { 154, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
140260 { 149, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
140444 { 149, -6 }, /* (258) cmd ::= ALTER TABLE fullname RENAME TO nm */
140445 { 149, -7 }, /* (259) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
140449 { 245, -8 }, /* (263) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
140634 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
140677 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
140839 case 74: /* cmd ::= DROP TABLE ifexists fullname */
141601 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
141684 case 258: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
141689 case 259: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
141707 case 263: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
141805 /* There are no SHIFTREDUCE actions on nonterminals because the table
142098 ** using a lookup table, whereas a switch() directly on c uses a binary search.
142099 ** The lookup table is much faster. To maximize speed, and to ensure that
142100 ** a lookup table is used, all of the classes need to be small integers and
142229 ** might be implemented more directly using a hand-written hash table.
142400 testcase( i==19 ); /* TABLE */
142968 table
142970 ** will take responsibility for freeing the Table structure.
142984 Table *p = pParse->pZombieTab;
143962 ** full table scans in the query optimizer. */
144400 Table *pTab = (Table *)sqliteHashData(p);
144457 ** SQL statements below, as the v-table implementation may be storing
144508 HashElem *i; /* Hash table iterator */
144628 ** but are "saved" in case the table pages are moved around.
144797 /* SQLITE_LOCKED */ "database table is locked",
144848 int count /* Number of times table has been busy */
145030 ** to the hash table.
145180 ** Declare that a function has been overloaded by a virtual table.
145594 ** following table describes the relationship between these two values
146785 ** Return meta information about a specific column of a database table.
146791 const char *zTableName, /* Table name */
146801 Table *pTab = 0;
146825 /* Locate the table in question */
146834 /* Query for existance of table only */
146860 ** 2. The table is not a view and the column name identified an
146892 zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName,
147274 ** table should connect.
147277 ** run a single CREATE TABLE statement to construct the imposter table in
148050 ** the %_segments table in sorted order. This means that when the end
148114 ** The segment directory in table %_segdir stores meta-information for
148154 ** leaf nodes are written in to the %_segments table in order, this
148282 ** When an fts3 table is created, it passes any arguments passed to
148283 ** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the
148287 ** be used for the fts3 table (customized by the tokenizer clause arguments).
148309 ** TABLE statement that created the fts3 table. For example, if
148425 ** This is the header file for the generic hash-table implementation
148427 ** hash table implementation for the full-text indexing module.
148437 /* A complete hash table is an instance of the following structure.
148448 int count; /* Number of entries in this table */
148450 int htsize; /* Number of buckets in the hash table */
148451 struct _fts3ht { /* the hash table */
148457 /* Each element in the hash table is an instance of the following
148464 Fts3HashElem *next, *prev; /* Next and previous elements in the table */
148470 ** There are 2 different modes of operation for a hash table:
148503 ** Macros for looping over all elements of a hash table. The idiom is
148521 ** Number of entries in a hash table
148551 ** Fts3Table.pendingTerms hash table. Normally, the hash table is
148555 ** segment is created and the hash table cleared immediately.
148701 const char *zName; /* virtual table name */
148702 int nColumn; /* number of named columns in virtual table */
148712 ** statements is run and reset within a single virtual table API call.
148722 u8 bHasStat; /* True if %_stat table exists (2==unknown) */
148723 u8 bHasDocsize; /* True if %_docsize table exists */
148727 char *zSegmentsTbl; /* Name of %_segments table */
148728 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
148736 ** A single FTS4 table may have multiple full-text indexes. For each index
148742 ** pending data structures, including hash table overhead, but not including
148750 Fts3Hash hPending; /* Pending terms table for this index */
148760 ** methods of the virtual table are called at appropriate times. These
148776 ** When the core wants to read from the virtual table, it creates a
148777 ** virtual table cursor (an instance of the following structure) using
148798 sqlite3_int64 nDoc; /* Documents in table */
148815 ** CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);
148824 #define FTS3_FULLSCAN_SEARCH 0 /* Linear scan of %_content table */
148825 #define FTS3_DOCID_SEARCH 1 /* Lookup by rowid on %_content table */
148898 ** where nCol is the number of columns in the queried FTS table. The array
149301 ** The xDisconnect() virtual table method.
149367 ** The xDestroy() virtual table method.
149377 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
149379 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
149380 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
149381 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
149382 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
149393 ** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
149412 /* Create a list of user columns for the virtual table */
149418 /* Create the whole "CREATE TABLE" statement to pass to SQLite */
149420 "CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)",
149436 ** Create the %_stat table if it does not already exist.
149440 "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'"
149449 ** required by the FTS3 table passed as the only argument. This is done
149453 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
149463 char *zContentCols; /* Columns of %_content table */
149465 /* Create a list of user columns for the content table */
149476 /* Create the content table */
149478 "CREATE TABLE %Q.'%q_content'(%s)",
149486 "CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);",
149490 "CREATE TABLE %Q.'%q_segdir'("
149503 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
149642 ** table has the three user-defined columns "a", "b", and "c", the following
149694 ** of columns in the %_content table (one for the docid plus one for each
149699 ** bracket. For example, if zFunc is "zip" and the FTS3 table has three
149767 ** representing the indexes maintained by the current FTS table. FTS tables
149770 ** (if any) specified as part of the CREATE VIRTUAL TABLE statement.
149785 struct Fts3Index **apIndex /* OUT: Array of indexes for this table */
149827 ** This function is called when initializing an FTS4 table that uses the
149829 ** of the new FTS4 table.
149833 ** a table of that name. If found, the output variables are populated
149836 ** *pnCol: Set to the number of columns table xxx has,
149842 ** the name of the corresponding column in table xxx. The array
149847 ** If the table cannot be found, an error code is returned and the output
149854 const char *zTbl, /* Name of content table */
149878 int nCol; /* Number of table columns */
149917 ** methods of the FTS3 virtual table.
149923 ** argv[2] -> table name
149929 void *pAux, /* Hash table containing tokenizers */
149942 int nCol = 0; /* Number of columns in the FTS table */
149945 int nName; /* Bytes required to hold table name */
149948 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
149951 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
149954 int bNoDocsize = 0; /* True to omit %_docsize table */
149990 ** + Figures out the number of columns the FTSX table will have, and
150114 ** TABLE statement, use all columns from the content table.
150264 /* Check to see if a legacy fts3 table has been "upgraded" by the
150265 ** addition of a %_stat table so that it can use incremental merge.
150276 /* Declare the table schema to SQLite. */
150303 ** The xConnect() and xCreate() methods for the virtual table. All the
150308 void *pAux, /* Pointer to tokenizer hash table */
150318 void *pAux, /* Pointer to tokenizer hash table */
150359 ** 3. Linear scan of %_content table.
150371 /* By default use a full table scan. This is an expensive option,
150538 ** on the xClose method of the virtual table interface.
150555 ** (or the equivalent for a content=xxx table) and set pCsr->pStmt to
150579 ** of the %_content table that contains the last match. Return
150595 ** table is missing a row that is present in the full-text index.
150651 ** table, then there are always 20 bytes of zeroed padding following the
150748 Fts3Table *p, /* Virtual table handle */
150766 char *zBlob = 0; /* Blob read from %_segments table */
151572 Fts3Table *p, /* FTS table handle */
151669 Fts3Table *p, /* FTS3 table handle */
151685 ** made by an fts4aux module, not an FTS table. In this case calling
151743 Fts3Table *p, /* FTS3 table handle */
151775 Fts3Table *p, /* FTS virtual table handle */
151800 Fts3Cursor *pCsr, /* Virtual table cursor handle */
151866 Fts3Table *p, /* Virtual table handle */
151938 ** Advance the cursor to the next row in the %_content table that
151940 ** the next row that matches. For a full-table scan, this will be
151941 ** simply the next row in the %_content table. For a docid lookup,
151994 ** This is the xFilter interface for the virtual table. See
151995 ** the virtual table xFilter method documentation for additional
151998 ** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against
151999 ** the %_content table.
152002 ** in the %_content table.
152084 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
152085 ** statement loops through all rows of the %_content table. For a
152119 ** This is the xEof method of the virtual table. SQLite calls this
152134 ** exposes %_content.docid as the rowid for the virtual table. The
152150 ** (iCol == p->nColumn) -> Magic column with the same name as the table.
152168 /* The special 'table-name' column */
152190 /* A user column. Or, if this is a full-table scan, possibly the
152209 sqlite3_vtab *pVtab, /* Virtual table handle */
152219 ** hash-table to the database.
152238 ** of blocks from the segments table. But this is not considered overhead
152268 ** If it is currently unknown whether or not the FTS table has an %_stat
152269 ** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat
152305 ** the pending-terms hash-table have already been flushed into the database
152321 ** hash-table. Any changes made to the database are reverted by SQLite.
152470 ** where 't' is the name of an FTS3 table.
152478 Fts3Table *p; /* Virtual table handle */
152524 ** virtual table.
152527 sqlite3_vtab *pVtab, /* Virtual table handle */
152560 ** Implementation of FTS3 xRename method. Rename an fts3 table.
152563 sqlite3_vtab *pVtab, /* Virtual table handle */
152564 const char *zName /* New name of table */
152570 /* At this point it must be known if the %_stat table exists or not.
152574 /* As it happens, the pending terms table is always empty here. This is
152575 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
152577 ** flushes the pending terms table. But leave the (no-op) call to
152587 "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';",
152594 "ALTER TABLE %Q.'%q_docsize' RENAME TO '%q_docsize';",
152600 "ALTER TABLE %Q.'%q_stat' RENAME TO '%q_stat';",
152605 "ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';",
152609 "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';",
152618 ** Flush the contents of the pending-terms table to disk.
152650 ** Discard the contents of the pending terms table.
152691 ** allocated for the tokenizer hash table.
152753 /* Allocate and initialize the hash-table used to store tokenizers. */
152761 /* Load the built-in tokenizers into the hash table */
152783 /* Create the virtual table wrapper around the hash-table and overload
152822 /* An error has occurred. Delete the hash table and return the error code. */
152889 Fts3Table *pTab, /* FTS Table pointer */
153314 Fts3Table *pTab, /* Virtual table handle */
153607 ** of data that will fit on a single leaf page of an intkey table in
153616 ** data from the %_stat table to calculate it.
153618 ** Entry 0 of the %_stat table
153619 ** varints, where nCol is the number of columns in the FTS3 table.
153621 ** the table. The following nCol varints contain the total amount of
153622 ** data stored in all rows of each column of the table, from left
153689 ** table actually contains the same data as the index. To prevent this from
154288 ** 2. After scanning the current FTS table row for the deferred tokens,
154537 ** the FTS table (considering all rows), and
154539 ** 2. For each column, the number of rows in the table for which the
154551 ** values are set to the number of documents in the table. In other
154553 ** column of each row of the table.
154769 ** Initialize API pointer table, if required.
154834 ** Schema of the terms table.
154837 "CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)"
154853 char const *zFts3; /* Name of fts3 table */
154858 Fts3auxTable *p; /* Virtual table object to return */
154864 ** CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);
154865 ** CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);
155436 const char **azCol; /* Array of column names for fts3 table */
156303 char **azCol, /* Array of column names for fts3 table */
156354 ** of each column in the target fts3 table, in order from left to right.
156357 ** The iDefaultCol parameter should be passed the index of the table column
156361 ** match any table column.
156366 char **azCol, /* Array of column names for fts3 table */
156452 ** Function to query the hash-table of tokenizers (see README.tokenizers).
156541 ** of a column of the fts3 table that the query expression may refer to.
156665 ** We've modified it slightly to serve as a standalone hash table
156701 /* Turn bulk memory into a hash table object by initializing the
156704 ** "pNew" is a pointer to the hash table that is to be initialized.
156707 ** determines what kind of key the hash table will use. "copyKey" is
156708 ** true if the hash table should make its own private copy of keys and
156722 /* Remove all entries from a hash table. Reclaim all memory.
156723 ** Call this routine to delete a hash table or to reset a hash table
156727 Fts3HashElem *elem; /* For looping over all elements of the table */
156816 /* Link an element into the hash table
156819 Fts3Hash *pH, /* The complete hash table */
156842 /* Resize the hash table so that it cantains "new_size" buckets.
156843 ** "new_size" must be a power of 2. The hash table might fail
156849 struct _fts3ht *new_ht; /* The new hash table */
156869 ** hash table that matches the given key. The hash for this key has
156897 /* Remove a single entry from the hash table given a pointer to that
156951 ** Attempt to locate an element of the hash table pH with a key
156962 /* Insert an element into the hash table pH. The key is pKey,nKey
156972 ** the new data is returned and the hash table is unchanged.
156975 ** element corresponding to "key" is removed from the hash table.
156978 Fts3Hash *pH, /* The hash table to insert into */
156984 int h; /* the hash of the key modulo hash table size */
157749 ** hash table. This function may be called as follows:
157760 ** the string <key-name> must already exist in the has table. Otherwise,
157765 ** to string <key-name> (after the hash-table is updated, if applicable).
157867 Fts3Hash *pHash, /* Tokenizer hash table */
158161 ** the hash table pointed to by argument pHash. The hash table must
158169 ** defined at compilation time, a temporary virtual table (see header
158174 ** of both the scalar and, if created, the virtual table.
158294 ** else we need to reindex. One solution would be a meta-table to
158472 ** This file contains code for the "fts3tokenize" virtual table module.
158473 ** An fts3tokenize virtual table is created as follows:
158475 ** CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(
158479 ** The table created has the following schema:
158481 ** CREATE TABLE <tbl>(input, token, start, end, position)
158487 ** The virtual table module tokenizes this <string>, using the FTS3
158488 ** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE
158510 ** Virtual table structure.
158519 ** Virtual table cursor structure.
158603 ** Schema of the tokenizer table.
158605 #define FTS3_TOK_SCHEMA "CREATE TABLE x(input, token, start, end, position)"
158614 ** argv[2]: table name
158619 void *pHash, /* Hash table of tokenizers */
158843 /* CREATE TABLE x(input, token, start, end, position) */
158961 ** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()
159126 ** or the pending-terms table being flushed), leaves are written into the
159204 Fts3Table *p, /* Virtual table handle */
159272 ** Read a single entry from the %_segdir table. The entry from absolute
159346 Fts3Table *pTab, /* FTS3 table handle */
159371 Fts3Table *pTab, /* Fts3 table handle */
159392 Fts3Table *pTab, /* Fts3 table handle */
159409 Fts3Table *p, /* The FTS3 table */
159427 ** shared-cache table-lock on the %_segdir table. This is required before
159428 ** writing data to the fts3 table. If this lock is not acquired first, then
159464 ** in the %_segdir table on disk. This function is used to convert three
159466 ** can be used to query the %_segdir table.
159479 Fts3Table *p, /* FTS3 table handle */
159495 ** all rows in the %_segdir table, from oldest to newest. If successful,
159500 ** each FTS3 table.
159502 ** The statement returns the following columns from the %_segdir table:
159511 Fts3Table *p, /* FTS3 table */
159667 Fts3Hash *pHash, /* Pending terms hash table to add entry to */
159696 ** pending-terms hash-table. The docid used is that currently stored in
159702 Fts3Table *p, /* Table into which text will be inserted */
159726 ** zText==0. In this case, add zero token entries to the hash table and
159780 Fts3Table *p, /* Full-text table handle */
159828 ** pendingTerms hash table.
159864 ** apVal[p->nColumn+2] Hidden column with same name as table
159869 Fts3Table *p, /* Full-text table */
159889 ** table. The SQL for this statement is:
159894 ** defined columns in the FTS3 table, plus one for the docid field.
159939 ** Remove all data from the FTS3 table. Clear the hash table containing
159945 /* Discard the contents of the pending-terms hash table. */
159979 Fts3Table *p, /* The FTS table to delete from */
160025 ** This function allocates a new level iLevel index in the segdir table.
160084 ** The %_segments table is declared as follows:
160086 ** CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)
160088 ** This function reads data from a single row of the %_segments table. The
160092 ** identified table row is. Whether or not paBlob is NULL, *pnBlob is set
160095 ** If an error occurs, or the table does not contain the specified row,
160106 ** on the database file for longer than necessary). Thus, any virtual table
160111 Fts3Table *p, /* FTS3 table handle */
160384 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
160560 ** the contents of the pending-terms hash table to the database.
160584 ** through each term in the pending-terms table. Or, if isPrefixIter is
160586 ** the pending terms hash table contains the terms "sqlite", "mysql" and
160599 Fts3Table *p, /* Virtual table handle */
160816 ** Insert a record into the %_segments table.
160819 Fts3Table *p, /* Virtual table handle */
160836 ** Find the largest relative level number in the table. If successful, set
160857 ** Insert a record into the %_segdir table.
160860 Fts3Table *p, /* Virtual table handle */
160916 Fts3Table *p, /* Virtual table handle */
161053 Fts3Table *p, /* Virtual table handle */
161122 Fts3Table *p, /* Virtual table handle */
161151 /* Find the next free blockid in the %_segments table */
161264 Fts3Table *p, /* Virtual table handle */
161287 /* The entire tree fits on the root node. Write it to the segdir table. */
161312 ** pRowid would mean the FTS3 table were empty.
161314 ** If successful, *pisEmpty is set to true if the table is empty except for
161322 /* If using the content=xxx option, assume the table is never empty */
161341 ** Segment levels are stored in the 'level' column of the %_segdir table.
161405 ** Delete all entries in the %_segments table associated with the segment
161407 ** of the %_segdir table.
161410 Fts3Table *p, /* FTS table handle */
161442 Fts3Table *p, /* Virtual table handle */
161561 Fts3Table *p, /* Virtual table handle */
161629 Fts3Table *p, /* Virtual table handle */
161661 Fts3Table *p, /* Virtual table handle */
161670 Fts3Table *p, /* Virtual table handle */
161745 Fts3Table *p, /* Virtual table handle */
161983 Fts3Table *p, /* FTS table handle */
161997 /* Loop through all entries in the %_segdir table corresponding to
162256 Fts3Table *p, /* Table into which to insert */
162284 ** Record 0 of the %_stat table contains a blob consisting of N varints,
162285 ** where N is the number of user defined columns in the fts3 table plus
162289 ** Varint 0: Total number of rows in the table.
162292 ** the column for all rows of the table.
162295 ** columns of all rows of the table.
162300 Fts3Table *p, /* Table being updated */
162409 ** The entire FTS index is discarded and rebuilt. If the table is one
162411 ** the current contents of the xxx table. Otherwise, it is rebuilt based
162412 ** on the contents of the %_content table.
162425 /* Compose and prepare an SQL statement to loop through the content table */
162495 Fts3Table *p, /* FTS3 table handle */
162714 Fts3Table *p, /* Fts3 table handle */
162865 Fts3Table *p, /* Fts3 table handle */
162950 Fts3Table *p, /* FTS3 table handle */
162977 ** table. However, this is not permitted in this case. The problem is that
162978 ** space has already been reserved in the %_segments table, and so the
162979 ** start_block and end_block fields of the %_segdir table must be populated.
162988 ** table until we are sure it is needed.
163054 ** Query to see if the entry in the %_segments table with blockid iEnd is
163062 ** is, then a NULL entry has been inserted into the %_segments table
163097 Fts3Table *p, /* Fts3 table handle */
163134 /* Check for the zero-length marker in the %_segments table */
163229 Fts3Table *p, /* FTS Table handle */
163251 ** In the %_segdir table, a segment is defined by the values in three
163274 Fts3Table *p, /* Fts3 table handle */
163310 /* Insert the marker in the %_segments table to make sure nobody tries
163328 ** Remove an entry from the %_segdir table. This involves running the
163339 Fts3Table *p, /* FTS3 table handle */
163363 Fts3Table *p, /* FTS3 table handle */
163486 ** table, and modifying existing entries in both the %_segments and %_segdir
163493 Fts3Table *p, /* FTS3 table handle */
163578 Fts3Table *p, /* FTS table handle */
163645 ** exists, is stored in the rowid==1 row of the %_stat table.
163648 ** table and return SQLITE_OK. Otherwise, if an error occurs, return an
163742 Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
163759 /* Search the %_segdir table for the absolute level with the smallest
163776 /* If the hint read from the %_stat table is not empty, check if the
163800 ** nMin segments and no hint in the %_stat table. No work to do.
163871 /* Write the hint values into the %_stat table for the next incr-merger */
163900 ** INSERT INTO table(table) VALUES('merge=A,B');
163907 Fts3Table *p, /* FTS3 table handle */
163944 ** INSERT INTO table(table) VALUES('automerge=X');
163950 Fts3Table *p, /* FTS3 table handle */
164008 Fts3Table *p, /* FTS3 table handle */
164074 ** content table. If no error occurs and the contents do match, set *pbOk
164104 /* This block calculates the checksum according to the %_content table */
164190 ** 2. By scanning and tokenizing the content table.
164196 Fts3Table *p /* FTS3 table handle */
164282 ** table, not for all rows.
164287 int i; /* Used to iterate through table columns */
164368 Fts3Cursor *pCsr, /* Fts3 table cursor */
164392 ** present in the FTS3 table. If it is, delete it and adjust the contents
164402 int bFound = 0; /* True if *pRowid really is in the table */
164406 int isEmpty = 0; /* Deleting *pRowid leaves the table empty */
164410 /* Deleting this row means the whole table is empty. In this case
164412 ** data in the pendingTerms hash table. */
164433 ** tables. The schema of the virtual table being:
164435 ** CREATE TABLE <table name>(
164437 ** <table name> HIDDEN,
164458 /* At this point it must be known if the %_stat table exists or not.
164524 ** the %_content table. If we hit the duplicate rowid constraint (or any
164586 ** Flush any data in the pending-terms hash table to disk. If successful,
164700 int nCol; /* Number of columns in table */
165256 Fts3Table *pTab, /* FTS3 table snippet comes from */
165534 ** rows of the table. Y is the number of rows for which column iCol contains
165841 sqlite3_int64 nDoc; /* Number of rows in table */
166056 /* Loop through all columns of the table being considered for snippets.
166058 ** columns of the FTS3 table. Otherwise, only column iCol is considered.
166116 int iCol; /* Column of table to populate aTerm for */
166187 /* Loop through the table columns, appending offset information to
166294 Fts3Cursor *pCsr, /* FTS3 table cursor */
166433 ** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE
166434 ** statement has specified that the tokenizer for this table shall consider
167095 ** algorithms packaged as an SQLite virtual table module.
167102 ** The data structure for a single virtual r-tree table is stored in three
167104 ** in the table name is replaced with the user-supplied name of the r-tree
167105 ** table.
167107 ** CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
167108 ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
167109 ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
167112 ** table. For each node that is not the root node of the r-tree, there is
167113 ** an entry in the %_parent table associating the node with its parent.
167114 ** And for each row of data in the table, there is an entry in the %_rowid
167115 ** table that maps from the entries rowid to the id of the node that it
167118 ** The root node of an r-tree always exists, even if the r-tree table is
167120 ** table must be the same size as the root node. The content of each node
167179 /* Size of hash table Rtree.aHash. This hash table is not expected to
167185 /* The xBestIndex method of this virtual table requires an estimate of
167186 ** the number of rows in the virtual table to calculate the costs of
167188 ** sqlite_stat1 table (with RTREE_MIN_ROWEST as a hard-coded minimum).
167196 ** An rtree virtual-table object.
167201 int iNodeSize; /* Size in bytes of each node in the node table */
167208 char *zDb; /* Name of database containing r-tree table */
167209 char *zName; /* Name of r-tree table */
167211 i64 nRowEst; /* Estimated number of rows in this table */
167239 RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */
167247 ** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will
167622 ** in the Rtree.aHash table.
167629 ** Search the node hash table for node iNode. If found, return a pointer
167639 ** Add node pNode to the node hash table.
167650 ** Remove node pNode from the node hash table.
167705 /* Check if the requested node is already in the hash table. If so,
167957 ** the virtual table module xCreate() and xConnect() methods.
167964 ** Rtree virtual table module xCreate method.
167977 ** Rtree virtual table module xConnect method.
168019 ** Rtree virtual table module xDisconnect method.
168027 ** Rtree virtual table module xDestroy method.
168033 "DROP TABLE '%q'.'%q_node';"
168034 "DROP TABLE '%q'.'%q_rowid';"
168035 "DROP TABLE '%q'.'%q_parent';",
168055 ** Rtree virtual table module xOpen method.
168094 ** Rtree virtual table module xClose method.
168111 ** Rtree virtual table module xEof method.
168636 ** Rtree virtual table module xNext method.
168650 ** Rtree virtual table module xRowid method.
168664 ** Rtree virtual table module xColumn method.
168696 ** return SQLITE_OK. If there is no such record in the table, set
168754 ** Rtree virtual table module xFilter method.
168858 ** Rtree virtual table module xBestIndex method. There are three
168859 ** table scan strategies to choose from (in order from most to
168865 ** 2 See below R-tree query or full-table scan.
169100 Rtree *pRtree, /* Rtree table */
169160 Rtree *pRtree, /* Rtree table */
169186 ** Write mapping (iRowid->iNode) to the <rtree>_rowid table.
169196 ** Write mapping (iNode->iPar) to the <rtree>_parent table.
169683 /* Remove the node from the in-memory hash table and link it into
169965 /* Delete the corresponding entry in the <rtree>_rowid table. */
170046 ** A constraint has failed while inserting a row into an rtree table.
170112 /* Constraint handling. A write operation on an r-tree table may return
170129 ** with "column" that are interpreted as table constraints.
170130 ** Example: CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));
170160 ** the table. If so, the constraint has failed. */
170184 ** record to delete from the r-tree table. The following block does
170252 "ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";"
170253 "ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";"
170254 "ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";"
170272 ** DROP TABLE command - which fortunately always opens a savepoint - cannot
170278 ** DROP TABLE <tablename>; -- Would fail with SQLITE_LOCKED
170293 ** of the number of rows in the virtual table. If possible, this is based
170337 rtreeCreate, /* xCreate - create a table */
170338 rtreeConnect, /* xConnect - connect to an existing table */
170340 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
170341 rtreeDestroy, /* xDestroy - Drop a table */
170355 rtreeRename, /* xRename - rename the table */
170372 /* Write the xxx_node table */
170376 /* Read and write the xxx_rowid table */
170381 /* Read and write the xxx_parent table */
170393 "CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);"
170394 "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);"
170395 "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,"
170458 ** determine the node-size used by the rtree table being created or connected
170463 ** table already exists. In this case the node-size is determined by inspecting
170512 ** methods of the r-tree virtual table.
170516 ** argv[2] -> table name
170522 int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */
170523 sqlite3_vtab **ppVtab, /* OUT: New virtual table */
170535 "Wrong number of columns for an rtree table", /* 1 */
170536 "Too few columns for an rtree table", /* 2 */
170537 "Too many columns for an rtree table" /* 3 */
170572 ** the r-tree table schema.
170578 char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
170701 const char *zDb; /* Database containing rtree table */
170702 const char *zTab; /* Name of rtree table */
170703 int bInt; /* True for rtree_i32 table */
170707 table */
170708 int nNonLeaf; /* Number of non-leaf cells in table */
170787 ** Otherwise, the contents of rtree table node iNode are loaded from
170831 ** (if bLeaf==1) table contains a specified entry. The schemas of the
170834 ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
170835 ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
170866 rtreeCheckAppendMsg(pCheck, "Mapping (%lld -> %lld) missing from %s table",
170873 "Found (%lld -> %lld) in %s table, expected (%lld -> %lld)",
170998 ** %_rowid or %_parent table is exactly nExpect. If not, it adds
171012 rtreeCheckAppendMsg(pCheck, "Wrong number of entries in %%%s table"
171029 const char *zTab, /* Name of rtree table to check */
171033 sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */
171050 /* Find number of dimensions in the rtree table. */
171090 ** rtreecheck(<rtree-table>);
171091 ** rtreecheck(<database>, <rtree-table>);
171094 ** table. The integrity-check verifies the following:
171096 ** 1. For each cell in the r-tree structure (%_node table), that:
171104 ** table corresponding to the cell's rowid value that
171108 ** %_parent table mapping from the cell's child node to the
171111 ** 2. That there are the same number of entries in the %_rowid table
171113 ** is a leaf cell that corresponds to each entry in the %_rowid table.
171115 ** 3. That there are the same number of entries in the %_parent table
171118 ** %_parent table.
171153 ** virtual table module "rtree" and the debugging/analysis scalar
171408 ** This lookup table is used to help decode the first byte of
172161 ** sqlite3rbu.h. Essentially, for each table xyz in the target database
172162 ** that the user wishes to write to, a corresponding data_xyz table is
172164 ** update, insert or delete from the target table.
172219 ** collected in the rbu_xyz table. And for both UPDATEs and DELETEs all
172300 ** KEY fields may not be updated or deleted. If the table being written
172317 ** containing an RBU update is an "RBU database". For each table in the
172318 ** target database to be updated, the RBU database should contain a table
172320 ** target table, and one more - "rbu_control". The data_% table should
172326 ** CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c UNIQUE);
172330 ** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);
172332 ** The order of the columns in the data_% table does not matter.
172334 ** Instead of a regular table, the RBU database may also contain virtual
172346 ** If the target database table is a virtual table or a table that has no
172347 ** PRIMARY KEY declaration, the data_% table must also contain a column
172353 ** CREATE VIRTUAL TABLE x1 USING fts3(a, b);
172354 ** CREATE TABLE x1(a, b)
172358 ** CREATE TABLE data_x1(a, b, rbu_rowid, rbu_control);
172361 ** target table must be present in the input table. For virtual tables,
172363 ** the input table, or not otherwise. For example, to write to an fts4
172364 ** table with a hidden languageid column such as:
172366 ** CREATE VIRTUAL TABLE ft1 USING fts4(a, b, languageid='langid');
172368 ** Either of the following input table schemas may be used:
172370 ** CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control);
172371 ** CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control);
172374 ** update, the corresponding data_% table should contain a single record
172379 ** If the target database table has an INTEGER PRIMARY KEY, it is not
172384 ** update, the corresponding data_% table should contain a single record
172387 ** corresponding columns of the data_% table. The values stored in the
172391 ** update, the corresponding data_% table should contain a single record
172394 ** stored in the corresponding columns of the data_% table row, as should
172397 ** there are columns in the target database table, and must consist entirely
172412 ** target table with the value stored in the corresponding data_% column, the
172414 ** the target table column. rbu_delta() is invoked with two arguments - the
172415 ** original value currently stored in the target table column and the
172416 ** value specified in the data_xxx table.
172427 ** ota_control string, the contents of the data_xxx table column is assumed
172430 ** the existing value within the target database table must be of type BLOB.
172434 ** If the target database table is a virtual table or a table with no PRIMARY
172447 ** table in "rowid" order is roughly the same as reading them sorted by
172448 ** the PRIMARY KEY of the corresponding target database table. In other
172449 ** words, rows should be sorted using the destination table PRIMARY KEY
172460 ** 2) Registers any required virtual table modules with the database
172624 ** register the required virtual table implementations.
172628 ** the rbu update db handle to any required virtual table
172720 ** database contains an "rbu_count" table. The rbu_count table, if it
172723 ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;
172725 ** There must be one row in the table for each source (data_xxx) table within
172727 ** table. The 'cnt' column should contain the number of rows within the
172728 ** source table.
172730 ** If the rbu_count table is present and populated correctly and this
172732 ** permyriadage progress of the same stage. If the rbu_count table does
172734 ** table exists but is not correctly populated, the value of the *pnOne
172862 ** The rbu_state table is used to save the state of a partially applied
172863 ** update so that it can be resumed later. The table consists of integer
172875 ** Only valid if STAGE==1. The target database name of the table
172880 ** currently being written, or NULL if the main table is currently being
172885 ** table/index.
172923 "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"
172951 ** A structure to store values read from the rbu_state table in memory.
172973 ** the target database that require updating. For each such table, the
172976 ** * the table itself,
172977 ** * each index of the table (zero or more points to visit), and
172978 ** * a special "cleanup table" state.
172981 ** If the table has no indexes on it, abIndexed is set to NULL. Otherwise,
172993 int *aiSrcOrder; /* src table col -> target table col */
172997 int eType; /* Table type - an RBU_PK_XXX value */
173001 const char *zTbl; /* Name of target db table */
173002 const char *zDataTbl; /* Name of rbu db table (or null) */
173007 int nIndex; /* Number of aux. indexes on table zTbl */
173023 ** 0: Table does not exist (error)
173024 ** 1: Table has an implicit rowid.
173025 ** 2: Table has an explicit IPK column.
173026 ** 3: Table has an external PK index.
173027 ** 4: Table is WITHOUT ROWID.
173028 ** 5: Table is a virtual table.
173042 #define RBU_INSERT 1 /* Insert on a main table b-tree */
173043 #define RBU_DELETE 2 /* Delete a row from a main table b-tree */
173048 #define RBU_UPDATE 6 /* Update a row in a main table b-tree */
173063 ** If the RBU database contains an rbu_count table, this value is set to
173076 ** of rows in the source table and nIndex the number of indexes on the
173077 ** corresponding target database table.
173083 ** for an UPDATE operation does not exist in the target table, then
173096 ** first pass of each source table. The updated nPhaseOneStep value is
173097 ** stored in the rbu_state table if the RBU update is suspended.
173532 ** the current object (table/index pair).
173638 ** accepts one or two arguments. The first argument is the name of a table -
173639 ** the name of a table in the RBU database. The second, if it is present, is 1
173640 ** for a view or 0 for a table.
173642 ** For a non-vacuum RBU handle, if the table name matches the pattern:
173700 "WHERE type IN ('table', 'view') AND target IS NOT NULL "
173857 /* Determine the type of a table.
173861 ** on the type of the table specified by parameters dbName and zTbl.
173863 ** RBU_PK_NOTABLE: No such table.
173864 ** RBU_PK_NONE: Table has an implicit rowid.
173865 ** RBU_PK_IPK: Table has an explicit IPK column.
173866 ** RBU_PK_EXTERNAL: Table has an external PK index.
173867 ** RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID.
173868 ** RBU_PK_VTAB: Table is a virtual table.
173871 ** parameter. Unless the table has an external primary key index
173873 ** if the table does have an external primary key index, then *piPk
173883 ** }else if( "PRAGMA index_list()" for the table contains a "pk" index ){
173922 /* Either an error, or no such table. */
173926 *peType = RBU_PK_VTAB; /* virtual table */
174021 ** the table (not index) that the iterator currently points to.
174032 int bRbuRowid = 0; /* If input table has column "rbu_rowid" */
174036 /* Figure out the type of table this step will deal with. */
174041 p->zErrmsg = sqlite3_mprintf("no such table: %s", pIter->zTbl);
174052 ** of the input table. Ignore any input table columns that begin with
174081 "table %q %s rbu_rowid column", pIter->zDataTbl,
174086 /* Check that all non-HIDDEN columns in the destination table are also
174087 ** present in the input table. Populate the abTblPk[], azTblType[] and
174154 ** used to read from an data_xxx or rbu_tmp_xxx table while updating the
174163 ** and "t1" is a table with an explicit INTEGER PRIMARY KEY column
174178 char **pzImposterCols, /* OUT: Columns for imposter table */
174209 /* An integer primary key. If the table has an explicit IPK, use
174269 ** Assuming the current table columns are "a", "b" and "c", and the zObj
174302 /* For a table with implicit rowids, append "old._rowid_" to the list. */
174312 ** primary key of the current table. For example, if the table is:
174314 ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c));
174370 ** an UPDATE statement used to update the table object that the iterator
174372 ** column of the data_xxx table entry is set to zMask.
174454 ** The iterator currently points to a table (not index) of type
174456 ** declaration for the corresponding imposter table. For example,
174457 ** if the iterator points to a table created as:
174459 ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID
174506 ** This function creates the second imposter table used when writing to
174507 ** a table b-tree where the table
174509 ** a table (not index) with an external primary key, this function is a
174512 ** Assuming the iterator does point to a table with an external PK, this
174513 ** function creates a WITHOUT ROWID imposter table named "rbu_imposter2"
174514 ** used to access that PK index. For example, if the target table is
174517 ** CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c));
174519 ** then the imposter table schema is:
174521 ** CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID;
174531 char *zCols = 0; /* Used to build up list of table cols */
174532 char *zPk = 0; /* Used to build up table PK declaration */
174534 /* Figure out the name of the primary key index for the current table.
174571 "CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID",
174586 ** a table (not an index) when this function is called. This function
174587 ** attempts to create any imposter table required to write to the main
174588 ** table b-tree of the table before returning. Non-zero is returned if
174589 ** an imposter table are created, or zero otherwise.
174591 ** An imposter table is required in all cases except RBU_PK_VTAB. Only
174592 ** virtual tables are written to directly. The imposter table has the
174593 ** same schema as the actual target table (less any UNIQUE constraints).
174616 /* If the target table column is an "INTEGER PRIMARY KEY", add
174617 ** "PRIMARY KEY" to the imposter table column declaration. */
174635 rbuMPrintfExec(p, p->dbMain, "CREATE TABLE \"rbu_imp_%w\"(%z)%s",
174644 ** Prepare a statement used to insert rows into the "rbu_tmp_xxx" table.
174650 ** the target table, plus one (for the rbu_control column), plus one more
174651 ** (for the rbu_rowid column) if the target table is an implicit IPK or
174652 ** virtual table.
174727 char *zImposterCols = 0; /* Columns for imposter table */
174739 /* Create the imposter table used to write to this index. */
174743 "CREATE TABLE \"rbu_imp_%w\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID",
174806 const char *zTbl = pIter->zTbl; /* Table this step applies to */
174807 const char *zWrite; /* Imposter table name */
174817 /* Create the imposter table or tables (if required). */
174849 /* Create the rbu_tmp_xxx table and the triggers to populate it. */
174851 "CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS "
174922 ** be used to update the imposter table for the main table b-tree of the
174923 ** table object that pIter currently points to, assuming that the
174924 ** rbu_control column of the data_xyz table contains zMask.
175028 ** table into it. Return a pointer to the new object. It is the
175138 /* If it has not already been created, create the rbu_state table */
175695 /* If this is an INSERT into a table b-tree and the table has an
175720 /* For a virtual table, or a table with no primary key, the
175843 ** Update the contents of the rbu_state table within the rbu database. The
175984 /* If this is an RBU vacuum operation and the state table was empty
175995 /* Clean up the rbu_tmp_xxx table for the previous table. It
176116 ** the rbu_state table was empty) it is a no-op. Otherwise, it arranges
176200 ** name of a table expected to appear in the target database. It returns
176201 ** the number of auxilliary indexes on the table.
176238 ** If the RBU database contains the rbu_count table, use it to initialize
176239 ** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table
176242 ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;
176244 ** There should be one row in the table for each data_xxx table in the
176245 ** database. The 'tbl' column should contain the name of a data_xxx table,
176249 ** for all rows in the rbu_count table, where nIndex is the number of
176250 ** indexes on the corresponding target database table.
176263 /* Check for the rbu_count table. If it does not exist, or if an error
176545 ** state table. This causes the next call to sqlite3rbu_vacuum()
177686 ** This file contains an implementation of the "dbstat" virtual table.
177688 ** The dbstat virtual table is used to extract low-level formatting
177733 "CREATE TABLE xx( " \
177734 " name TEXT, /* Name of table or index */" \
177811 ** Connect to or create a statvfs virtual table.
177853 ** Disconnect from or destroy a statvfs virtual table.
177861 ** There is no "best-index". This virtual table always does a linear
177862 ** scan. However, a schema=? constraint should cause this table to
177976 if( flags==0x0D ){ /* Table leaf node */
178037 /* A table interior node. nPayload==0. */
178214 case 0x05: /* table internal */
178218 case 0x0D: /* table leaf */
178274 "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
178346 ** Invoke this routine to register the "dbstat" virtual table module
178394 ** This file contains an implementation of the "sqlite_dbpage" virtual table.
178396 ** The sqlite_dbpage virtual table is used to read or write whole raw
178405 ** This is an eponymous virtual table so it does not need to be created before
178406 ** use. The optional argument to the sqlite_dbpage() table name is the
178410 ** The data field of sqlite_dbpage table can be updated. The new
178445 ** Connect to or create a dbpagevfs virtual table.
178458 "CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)");
178475 ** Disconnect from or destroy a dbpagevfs virtual table.
178485 ** 0 schema=main, full table scan
178487 ** 2 schema=?1, full table scan
178590 ** 0 schema=main, full table scan
178592 ** 2 schema=?1, full table scan
178744 ** written by the sqlite_dbpage virtual table, start a write transaction
178760 ** Invoke this routine to register the "dbpage" virtual table module
178887 char *zTab; /* Current table */
178897 ** for each table the session object is monitoring. The structures are
178900 ** The keys of the SessionTable.aChange[] hash table are all rows that have
178902 ** table.
178904 ** The data associated with each hash-table entry is a structure containing
178910 char *zName; /* Local name of table */
178911 int nCol; /* Number of columns in table zName */
178915 int nEntry; /* Total number of entries in hash table */
178917 SessionChange **apChange; /* Hash table buckets */
178964 ** one or more tables. Operations on a single table are grouped together,
178968 ** Each group of changes begins with a table header:
178971 ** Varint: Number of columns in the table.
178973 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
178975 ** Followed by one or more changes to the table.
178984 ** columns in the table. The i'th field of each record is associated with
178985 ** the i'th column of the table, counting from left to right in the order
178986 ** in which columns were declared in the CREATE TABLE statement.
178996 ** associated with table columns that are not PRIMARY KEY columns and are
179000 ** with table columns modified by the UPDATE change contain the new
179001 ** values. Fields associated with table columns that are not modified
179010 ** Each group of changes begins with a table header:
179013 ** Varint: Number of columns in the table.
179015 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
179017 ** Followed by one or more changes to the table.
179026 ** table column, counting from left to right within the CREATE TABLE
179035 ** PRIMARY KEY fields contain the values identifying the table row to update,
179045 ** this structure stored in a SessionTable.aChange[] hash table.
179052 SessionChange *pNext; /* For hash-table collisions */
179248 SessionTable *pTab, /* Session table handle */
179322 ** hash key. Assume the has table has nBucket buckets. The hash keys
179330 SessionTable *pTab, /* Table handle */
179333 int nBucket /* Assume this many buckets in hash table */
179373 ** Arguments aLeft and aRight are pointers to change records for table pTab.
179379 SessionTable *pTab, /* Table used for PK definition */
179387 int iCol; /* Used to iterate through table columns */
179503 SessionTable *pTab, /* Table change pertains to */
179580 SessionTable *pTab, /* Table associated with change */
179647 ** If required, grow the hash table used to store changes on table pTab
179653 ** that case the hash-table does not grow, but SQLITE_OK is returned anyway.
179654 ** Growing the hash table in this case is a performance optimization only,
179693 ** This function queries the database for the names of the columns of table
179697 ** of columns in the database table and variable *pzTab is set to point to a
179698 ** nul-terminated copy of the table name. *pazCol (if not NULL) is set to
179703 ** For example, if the table is declared as:
179705 ** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z));
179720 const char *zThis, /* Table name */
179723 const char ***pazCol, /* OUT: Array of column names for table */
179823 ** write to table pTab, part of session pSession. If this is the first
179824 ** write to this table, initalize the SessionTable.nCol, azCol[] and
179828 ** non-zero returned. Or, if no error occurs but the table has no primary
179830 ** indicate that updates on this table should be ignored. SessionTable.abPK
179858 ** sqlite_stat1 table. The purpose of this is to substitute a zero-length
179860 ** sqlite_stat1 table.
179899 ** change on table pTab (attached to session pSession). The type of change
179903 ** to the changed-rows hash table associated with table pTab.
179908 SessionTable *pTab /* Table that change applies to */
179917 /* Load table details if required */
179921 ** number of columns in the table. */
179927 /* Grow the hash table if required */
179959 /* Search the hash table for an existing record for this row. */
180019 /* Add the change to the hash-table */
180058 /* Search for an existing table */
180064 /* If there is a table-filter configured, invoke it. If it returns 0,
180065 ** do not automatically add the new table. */
180090 char const *zName, /* Table name */
180250 const char *zTbl, /* Table name */
180351 SessionTable *pTo; /* Table zTbl */
180353 /* Locate and if necessary initialize the target table object */
180361 /* Check the table schemas match */
180383 *pzErrMsg = sqlite3_mprintf("table schemas do not match");
180461 ** Free the list of table objects passed as the first argument. The contents
180507 /* Delete all attached table objects. And the contents of their
180516 ** Set a table filter on a Session Object.
180529 ** Attach a table to a session. All subsequent changes made to the table
180538 const char *zName /* Table name */
180546 SessionTable *pTab; /* New table object (if required) */
180912 int nCol, /* Number of columns in table */
180958 ** Formulate and prepare a SELECT statement to retrieve a row from table
180966 const char *zTab, /* Table name */
180967 int nCol, /* Number of columns in table */
180968 const char **azCol, /* Names of table columns */
181021 int nCol, /* Number of columns in table */
181086 ** is called. Otherwise, append a serialized table header (part of the binary
181093 SessionTable *pTab, /* Table object to append header for */
181096 /* Write a table header */
181145 int nCol; /* Number of columns in table */
181147 const char **azCol = 0; /* Table columns */
181149 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
181153 /* Check the table schema is still Ok. */
181159 /* Write a table header */
181557 ** The input pointer currently points to the second byte of a table-header.
181560 ** + number of columns in table (varint)
181562 ** + table name (nul terminated).
181629 ** The input pointer currently points to the second byte of a table-header.
181632 ** + number of columns in table (varint)
181634 ** + table name (nul terminated).
181636 ** This function decodes the table-header and populates the p->nCol,
181639 ** input pointer is left pointing to the byte following the table header.
181810 const char **pzTab, /* OUT: Pointer to table name */
181811 int *pnCol, /* OUT: Number of columns in table */
181824 ** the database table affected by the change that pIter currently points
181978 int nCol = 0; /* Number of cols in current table */
181979 u8 *abPK = 0; /* PK array for current table */
181981 SessionBuffer sPK = {0, 0, 0}; /* PK array for current table */
182002 /* A 'table' record consists of:
182005 ** * Number of columns in said table (a varint),
182007 ** * A nul-terminated table name.
182176 int bStat1; /* True if table is sqlite_stat1 */
182182 ** Formulate a statement to DELETE a row from database db. Assuming a table
182185 ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
182200 const char *zTab, /* Table name */
182252 ** Assuming a table structure like this:
182254 ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
182267 ** For each column in the table, there are three variables to bind:
182283 const char *zTab, /* Table name */
182348 ** Formulate and prepare an SQL statement to query table zTab by primary
182349 ** key. Assuming the following table structure:
182351 ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
182362 const char *zTab, /* Table name */
182370 ** Formulate and prepare an INSERT statement to add a record to table zTab.
182380 const char *zTab, /* Table name */
182413 ** Prepare statements for applying changes to the sqlite_stat1 table.
182475 ** pStmt. The table being inserted into has nCol columns.
182515 ** iterator pIter points to to the SELECT and attempts to seek to the table
182536 int nCol; /* Number of columns in table */
182713 ** * all columns of the table are PK columns (in this case there is
182762 /* A NOTFOUND or DATA error. Search the table to see if it contains
182934 const char *zTab /* Table name */
182945 const char *zTab = 0; /* Name of current table */
182984 ** xFilter callback returns zero, skip this table. If it returns
183011 "sqlite3changeset_apply(): no such table: %s", zTab
183017 "sqlite3changeset_apply(): table %s has %d columns, "
183025 "primary key mismatch for table %s", zTab
183050 /* If there is a schema mismatch on the current table, proceed to the
183112 const char *zTab /* Table name */
183140 const char *zTab /* Table name */
183172 SessionTable *pTab, /* Table structure */
183323 /* Search the list for a matching table */
183366 /* Search for existing entry. If found, remove it from the hash table.
185488 ** The json_each virtual table
185504 /* Constructor for the json_each virtual table */
185532 "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
185542 /* destructor for json_each virtual table */
185773 ** column. Without such a constraint, the table cannot operate. idxNum is
185894 /* The methods of the json_each virtual table */
185921 table. */
185952 ** functions and the virtual table implemented by this file.
186085 ** Virtual table implementations may overload SQL functions by implementing
186115 ** to the total number of tokens in the FTS5 table. Or, if iCol is
186116 ** non-negative but less than the number of columns in the table, return
186118 ** the FTS5 table.
186121 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
186126 ** Return the number of columns in the table.
186131 ** non-negative but less than the number of columns in the table, set
186135 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
186139 ** This function may be quite inefficient if used with an FTS5 table
186162 ** This API can be quite slow if used with an FTS5 table created with the
186163 ** "detail=none" or "detail=column" option. If the FTS5 table is created
186165 ** (i.e. if it is a contentless table), then this API always returns 0.
186175 ** first token of the phrase. The exception is if the table was created
186182 ** This API can be quite slow if used with an FTS5 table created with the
186189 ** Tokenize text using the tokenizer belonging to the FTS5 table.
186192 ** This API function is used to query the FTS table for phrase iPhrase
186254 ** This function is used to retrieve the total number of rows in the table.
186281 ** This API can be quite slow if used with an FTS5 table created with the
186282 ** "detail=none" or "detail=column" option. If the FTS5 table is created
186284 ** (i.e. if it is a contentless table), then this API always iterates
186306 ** This API can be quite slow if used with an FTS5 table created with the
186307 ** "detail=none" option. If the FTS5 table is created with either
186308 ** "detail=none" "content=" option (i.e. if it is a contentless table),
186381 ** tokenizer name as part of the CREATE VIRTUAL TABLE statement used
186382 ** to create the FTS5 table.
186406 ** or removed from the FTS table. The tokenizer is being invoked to
186690 ** Maximum number of prefix indexes on single FTS5 table. This must be
186750 ** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.
186757 ** be gleaned from the CREATE VIRTUAL TABLE statement.
186759 ** And all information loaded from the %_config table.
186781 ** True if the %_docsize table is created.
186800 char *zContent; /* content table */
186808 /* Values loaded from the %_config table */
186826 /* Current expected value of %_config table 'version' field */
186856 /* Load the contents of the %_config table */
186963 ** to access the data stored in the %_data table.
187088 ** table may have changed on disk. So any in-memory caches of %_data
187113 ** Return the total number of entries read from the %_data table by
187179 ** Create a hash table, free a hash table.
187194 ** Empty (but do not delete) a hash table.
187199 Fts5Hash*, /* Hash table to query */
187206 Fts5Hash*, /* Hash table to query */
187622 ** slots in the fts5yy_action[] table.
187627 ** The action table is constructed as a single large table named fts5yy_action[].
187643 ** fts5yy_action[] A single table containing all actions.
187644 ** fts5yy_lookahead[] A table containing the lookahead for each entry in
187706 /* The next table maps tokens (terminal symbols) into fallback tokens.
187806 ** are required. The following table supplies these names */
188306 /* The following table contains information about every rule that
188569 /* There are no SHIFTREDUCE actions on nonterminals because the table
189374 ** table matched by each individual phrase within the query.
189403 sqlite3_int64 nRow = 0; /* Number of rows in table */
189404 sqlite3_int64 nToken = 0; /* Number of tokens in table */
189421 /* Calculate the average document length for this FTS5 table */
189897 ** designed to produce hash table collisions really do work. */
190170 ** Parse a "special" CREATE VIRTUAL TABLE directive and update
190455 ** or xConnect method of the virtual table. This function attempts to
190469 const char **azArg, /* Array of nArg CREATE VIRTUAL TABLE args */
190495 *pzErr = sqlite3_mprintf("reserved fts5 table name: %s", pRet->zName);
190616 zSql = sqlite3Fts5Mprintf(&rc, "CREATE TABLE x(");
190853 ** Load the contents of the %_config table into memory.
193771 ** This file contains the implementation of an in-memory hash table used
193787 ** Each entry in the hash table is represented by an object of the
193832 ** Allocate a new hash table.
193862 ** Free a hash table object.
193873 ** Empty (but do not delete) a hash table.
193909 ** Resize the hash table by doubling the number of slots.
193972 ** Add an entry to the in-memory hash table. The key is the concatenation
194021 /* Allocate new Fts5HashEntry and add it to the hash table. */
194173 ** Extract all tokens from hash table iHash and link them into a list
194174 ** in sorted order. The hash table is cleared before returning. It is
194221 ** Query the hash table for a doclist associated with term pTerm/nTerm.
194224 Fts5Hash *pHash, /* Hash table to query */
194251 Fts5Hash *p, /* Hash table to query */
194302 ** %_data table. Other parts of the system access this functionality via
194312 ** The %_data table contains all the FTS indexes for an FTS5 virtual table.
194347 ** The %_data table managed by this module,
194349 ** CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB);
194358 ** recorded in a single record within the %_data table. The record consists
194360 ** SQLite varints. If the FTS table features more than one index (because
194382 ** A single record within the %_data table. The data is a list of varints.
194385 ** rows of the table.
194498 ** Rowids for the averages and structure records in the %_data table.
194505 ** and nodes. All nodes and leaves are stored in the %_data table with large
194540 ** Each time a blob is read from the %_data table, it is padded with this
194567 ** One object per %_data table.
194570 Fts5Config *pConfig; /* Virtual table configuration */
194571 char *zDataTbl; /* Name of %_data table */
194578 Fts5Hash *pHash; /* Hash table for in-memory data */
194587 sqlite3_blob *pReader; /* RO incr-blob open on %_data table */
194663 /* Values to insert into the %_idx table */
194664 Fts5Buffer btterm; /* Next term to insert into %_idx table */
194919 ** Retrieve a record from the %_data table.
194956 ** table, missing row, non-blob/text in block column - indicate
195030 ** INSERT OR REPLACE a record into the %_data table.
196723 ** in-memory hash table. If there is no such term in the hash-table, the
197529 ** * the table contains 100 or fewer columns.
197693 /* Add a segment iterator for the current contents of the hash table. */
198582 /* Remove the redundant segments from the %_data table */
198745 ** Flush the contents of in-memory hash table iHash to a new level-0
198781 /* Begin scanning through hash table entries. This loop runs once for each
198782 ** term/doclist currently stored within the hash table. */
198904 /* Unless it is empty, flush the hash table to disk */
199410 /* Allocate the hash table if it has not already been allocated */
199415 /* Flush the hash table to disk if required */
199441 ** table may have changed on disk. So any in-memory caches of %_data
199453 ** The %_data table is completely empty when this function is called. This
199468 ** and initialize the underlying %_data table.
199763 ** the number of user defined columns in the FTS table.
199797 ** table since it was created.
199985 ** This check may only be performed if the hash table is empty. This
199986 ** is because the hash table only supports a single scan query at
200331 ** Decode a segment-data rowid from the %_data table. This function is
200335 i64 iRowid, /* Rowid from %_data table */
200827 ** SQLite invokes the following virtual table methods as transactions are
200903 ** Virtual-table object.
200907 Fts5Config *pConfig; /* Virtual table configuration */
200941 ** Virtual-table cursor object.
201096 ** Return true if pTab is a contentless table.
201103 ** Delete a virtual table handle allocated by fts5InitVtab().
201115 ** The xDisconnect() virtual table method.
201123 ** The xDestroy() virtual table method.
201136 ** methods of the FTS3 virtual table.
201142 ** argv[2] -> table name
201148 void *pAux, /* Hash table containing tokenizers */
201158 Fts5Table *pTab = 0; /* New virtual table object */
201208 ** The xConnect() and xCreate() methods for the virtual table. All the
201213 void *pAux, /* Pointer to tokenizer hash table */
201223 void *pAux, /* Pointer to tokenizer hash table */
201499 ** on the xClose method of the virtual table interface.
201558 ** open on table pTab.
201608 ** Advance the cursor to the next row in the table that matches the
201706 ** is not possible as SQLite reference counts the virtual table objects.
201708 ** table, saving it creates a circular reference.
201784 ** Search for an auxiliary function named zName that can be used with table
201899 ** This is the xFilter interface for the virtual table. See
201900 ** the virtual table xFilter method documentation for additional
201907 ** 3. A full-table scan.
202021 "%s: table does not support scanning", pConfig->zName
202025 /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup
202047 ** This is the xEof method of the virtual table. SQLite calls this
202073 ** exposes %_content.rowid as the rowid for the virtual table. The
202163 Fts5Table *pTab, /* Fts5 table object */
202164 const char *zCmd, /* Text inserted into table-name column */
202175 "contentless or external content fts5 table"
202184 "'rebuild' may not be used with a contentless fts5 table"
202261 sqlite3_vtab *pVtab, /* Virtual table handle */
202323 "cannot %s contentless fts5 table: %s",
202403 ** the pending-terms hash-table have already been flushed into the database
202414 ** hash-table. Any changes made to the database are reverted by SQLite.
203124 ** as the table. Return the cursor integer id number. This value is only
203153 ** virtual table.
203156 sqlite3_vtab *pVtab, /* Virtual table handle */
203178 ** Implementation of FTS5 xRename method. Rename an fts5 table.
203181 sqlite3_vtab *pVtab, /* Virtual table handle */
203182 const char *zName /* New name of table */
203191 ** Flush the contents of the pending-terms table to disk.
203217 ** Discard the contents of the pending terms table.
203559 i64 nTotalRow; /* Total number of rows in FTS table */
203598 /* If there is no %_docsize table, there should be no requests for
203720 "DROP TABLE IF EXISTS %Q.'%q_data';"
203721 "DROP TABLE IF EXISTS %Q.'%q_idx';"
203722 "DROP TABLE IF EXISTS %Q.'%q_config';",
203729 "DROP TABLE IF EXISTS %Q.'%q_docsize';",
203735 "DROP TABLE IF EXISTS %Q.'%q_content';",
203745 const char *zTail, /* Tail of table name e.g. "data", "config" */
203746 const char *zName /* New name of FTS5 table */
203750 "ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';",
203773 ** Create the shadow table named zPost, with definition zDefn. Return
203778 const char *zPost, /* Shadow table to create (e.g. "content") */
203779 const char *zDefn, /* Columns etc. for shadow table */
203786 rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
203795 "fts5: error creating shadow table %q_%s: %s",
203921 ** If a row with rowid iDel is present in the %_content table, add the
203976 ** Insert a record into the %_docsize table. Specifically, do:
203980 ** If there is no %_docsize table (as happens if the columnsize=0 option
203981 ** is specified when the FTS5 table is created), this function is a no-op.
204048 ** Remove a row from the FTS table.
204109 /* Reinitialize the %_data table. This call creates the initial structure
204187 ** by inserting a dummy row into the %_docsize table. The dummy will be
204190 ** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In
204212 ** Insert a new row into the FTS content table.
204222 /* Insert the new row into the %_content table. */
204230 sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */
204247 ** Insert new entries into the FTS index and %_docsize table.
204399 ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return
204419 ** %_content table. This block stores the checksum in ctx.cksum. */
204502 ** %_content table.
204560 ** each table column. This function reads the %_docsize record for the
204567 int nCol = p->pConfig->nCol; /* Number of user columns in table */
206630 ** This is an SQLite virtual table module implementing direct access to an
206635 ** CREATE TABLE vocab(term, col, doc, cnt, PRIMARY KEY(term, col));
206640 ** instances of term $term in column $col (in any row of the fts5 table).
206643 ** CREATE TABLE vocab(term, doc, cnt, PRIMARY KEY(term));
206651 ** CREATE TABLE vocab(term, doc, col, offset, PRIMARY KEY(<all-fields>));
206665 char *zFts5Tbl; /* Name of fts5 table */
206666 char *zFts5Db; /* Db containing fts5 table */
206684 Fts5Config *pConfig; /* Fts5 table configuration */
206690 i64 rowid; /* This table's current rowid value */
206715 ** Translate a string containing an fts5vocab table type to an
206736 *pzErr = sqlite3_mprintf("fts5vocab: unknown table type: %Q", zCopy);
206747 ** The xDisconnect() virtual table method.
206756 ** The xDestroy() virtual table method.
206766 ** methods of the FTS3 virtual table.
206772 ** argv[2] -> table name
206776 ** argv[3] -> name of fts5 table
206777 ** argv[4] -> type of fts5vocab table
206782 ** argv[4] -> name of fts5 table
206783 ** argv[5] -> type of fts5vocab table
206794 "CREATE TABlE vocab(" FTS5_VOCAB_COL_SCHEMA ")",
206795 "CREATE TABlE vocab(" FTS5_VOCAB_ROW_SCHEMA ")",
206796 "CREATE TABlE vocab(" FTS5_VOCAB_INST_SCHEMA ")"
206844 ** The xConnect() and xCreate() methods for the virtual table. All the
206849 void *pAux, /* Pointer to tokenizer hash table */
206859 void *pAux, /* Pointer to tokenizer hash table */
206923 /* This virtual table always delivers results in ascending order of
206975 "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
207011 ** on the xClose method of the virtual table interface.
207072 ** Advance the cursor to the next row in the table.
207193 ** This is the xFilter implementation for the virtual table.
207261 ** This is the xEof method of the virtual table. SQLite calls this
207401 ** This file demonstrates an eponymous virtual table that returns information
207422 ** serve as the underlying representation of a stmt virtual table
207444 ** stmt_vtab that describes the stmt virtual table.
207480 "CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
207616 ** that uses the stmt virtual table. This routine needs to create
207631 ** stmt virtual table.