Home | History | Annotate | Download | only in orig

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 ** &nbsp; 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 */
44783 ** But sometimes (for example when during a DROP of a large table) most
44823 /* Number of u32 values in hash table. */
44825 /* Maximum number of entries in hash table before
44848 ** a hash table that will hold up to BITVEC_MXHASH distinct values.
44869 u32 aHash[BITVEC_NINT]; /* Hash table representation */
45002 ** that BitvecClear can use to rebuilt its hash table.
46153 PgHdr1 *pNext; /* Next in hash table chain */
46222 /* Hash table of all pages. The following variables may only be accessed
46228 PgHdr1 **apHash; /* Hash table for fast lookup by key */
46569 ** This function is used to resize the hash table used by the cache passed
46633 ** Remove the page supplied as an argument from the hash table
46693 ** cache, then there is no point in scanning the entire hash table.
46701 ** It is necessary to scan the entire hash table */
47040 /* Step 1: Search the hash table for an existing entry. */
47044 /* Step 2: If the page was found in the hash table, then return it.
47045 ** If the page was not in the hash table and createFlag is 0, abort.
50748 ** in this case. But for things like temporary table (which will be
55768 ** database page number associated with each wal frame, and a hash-table
55783 ** Even without using the hash table, the last frame for page P
55790 ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
55792 ** hash table for each page number in the mapping section, so the hash
55793 ** table is never more than half full. The expected number of collisions
55794 ** prior to finding a match is 1. Each entry of the hash table is an
55799 ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table
55802 ** To look for page P in the hash table, first compute a hash iKey on
55807 ** Then start scanning entries of the hash table, starting with iKey
55808 ** (wrapping around to the beginning when the end of the hash table is
55811 ** wrap-around.) Because the hash table is never more than half full,
55835 ** Both readers can use the same hash table and mapping section to get
55836 ** the correct result. There may be entries in the hash table with
55838 ** slots in the hash table and so the first reader will get an answer as
55839 ** if no values greater than K0 had ever been inserted into the hash table
55844 ** When a rollback occurs, the value of K is decreased. Hash table entries
55846 ** from the hash table at this point.
56088 ** Each page of the wal-index mapping contains a hash-table made up of
56122 ** is a hash-table following every HASHTABLE_NPAGE page numbers in the
56133 ** The block of page numbers associated with the first hash-table in a
56135 ** hash-table on each aligned 32KB page of the wal-index.
56472 ** Return pointers to the hash table and page number array stored on
56476 ** Set output variable *paHash to point to the start of the hash table
56478 ** number of the first frame indexed by this hash table. If a
56479 ** slot in the hash table is set to N, it refers to frame number
56483 ** first frame indexed by the hash table, frame (*piZero+1).
56487 int iHash, /* Find the iHash'th table */
56518 ** Return the number of the wal-index page that contains the hash-table
56546 ** Remove entries from the hash table that point to WAL slots greater
56552 ** At most only the hash table containing pWal->hdr.mxFrame needs to be
56558 volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
56559 volatile u32 *aPgno = 0; /* Page number array for hash table */
56572 /* Obtain pointers to the hash-table and page-number array containing
56574 ** that the page said hash-table and array reside on is already mapped.
56580 /* Zero all hash-table entries that correspond to frame numbers greater
56599 ** via the hash table even after the cleanup.
56623 volatile ht_slot *aHash = 0; /* Hash table */
56628 ** page number array and hash table entry.
56631 int iKey; /* Hash table key */
56632 int idx; /* Value to write to hash-table slot */
56638 /* If this is the first entry to be added to this hash-table, zero the
56639 ** entire hash table and aPgno[] array before proceeding.
56650 ** the hash-table before writing any new entries.
56657 /* Write the aPgno[] array entry and the hash-table slot. */
56666 /* Verify that the number of entries in the hash table exactly equals
56671 int nEntry = 0; /* Number of entries in the hash table */
56677 ** via the hash table. This turns out to be a really, really expensive
58446 /* Search the hash table or tables for an entry matching page number
58448 ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
58452 ** table). This means the value just read from the hash
58462 ** if we had exclusive access to the hash-table:
58465 ** This condition filters out normal hash-table collisions.
58469 ** table after the current read-transaction had started.
58473 volatile ht_slot *aHash; /* Pointer to hash table */
59679 u8 intKey; /* True if table b-trees. False for index b-trees */
59680 u8 intKeyLeaf; /* True if the leaf of an intKey table */
59711 ** is opened on the table with root page BtShared.iTable. Locks are removed
59717 Pgno iTable; /* Root page of table */
59795 ** table (because there exists one or more read-locks on the table),
59829 u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */
59830 u16 minLeaf; /* Minimum local payload in a LEAFDATA table */
59947 ** because the table is empty or because BtreeCursorFirst() has not been
59959 ** The table that this cursor was opened on still exists, but has been
60003 ** The pointer map is a lookup table that identifies the parent page for
60267 ** a statement since we will be comparing table and column names
60505 ** shared-cache table level locks. If the library is compiled with the
60553 ** table with root page iRoot. Return 1 if it does and 0 if not.
60555 ** For example, when writing to a table with root-page iRoot via
60562 ** the corresponding table. This makes things a bit more complicated,
60563 ** as this module treats each table as a separate structure. To determine
60564 ** the table corresponding to the index being written, this
60567 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
60568 ** hold a write-lock on the schema table (root page 1). This is also
60600 /* Figure out the root-page that the lock should be held on. For table
60603 ** table. */
60623 ** write-lock on the schema table, or (if the client is reading) a
60644 ** table or index rooted at iRoot because other shared connections are
60645 ** simultaneously reading that same table or index.
60649 ** the iRoot table. Except, if the other Btree object has the
60653 ** For example, before writing to any part of the table or index
60674 ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return
60714 ** may hold a WRITE_LOCK on any table in this file (since there can
60734 ** Add a lock on the table with root-page iTable to the shared-btree used
60762 ** table, and that lock is obtained in BtreeBeginTrans(). */
60770 /* First search the list for an existing lock on this table. */
60779 ** with table iTable, allocate one and link it into the list.
60807 ** Release all the table locks (locks obtained via calls to
60921 ** This function is called before modifying the contents of a table
60926 ** table is about to be deleted. In this case invalidate all incrblob
60927 ** cursors open on any row within the table with root-page pgnoRoot.
60935 Pgno pgnoRoot, /* The table that might be changing */
61050 ** If the cursor is open on an intkey table, then the integer key
61052 ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
61063 /* Only the rowid is required for a table btree */
61120 ** the table with root-page iRoot. "Saving the cursor position" means that
61124 ** table, for example in BtreeDelete() or BtreeInsert().
61518 ** btreeParseCellPtr() => table btree leaf nodes
61519 ** btreeParseCellNoPayload() => table btree internal nodes
61665 ** cellSizePtrNoPayload() => table internal nodes
61666 ** cellSizePtr() => all index nodes & table leaf nodes
62188 ** interior table b-tree page. */
62191 ** leaf table b-tree page. */
62283 ** possible for a root page of a table that contains no rows) then the
63051 ** The call to sqlite3BtreeRollback() drops any table-locks held by
64627 ** cursors open with wrFlag==0 on the same table. Otherwise
64640 ** in which index entries are automatically deleted when corresponding table
64654 int iTable, /* Root page of table to open */
64669 ** b-tree database, the connection is holding the required table locks,
64714 int iTable, /* Root page of table to open */
64815 ** that is currently pointing to a row in a (non-empty) table.
64828 ** Return the value of the integer key or "rowid" for a table btree.
64830 ** ordinary table btree. If the cursor points to an index btree or
64857 ** currently pointing to. For table btrees, this will be the amount
65000 ** invalidated if some other cursor writes to the same table, or if
65006 ** * Creating a table (may require moving an overflow page).
65199 ** pCur can be pointing to either a table or an index b-tree.
65200 ** If pointing to a table btree, then the content section is read. If
65204 ** to a valid row in the table. For sqlite3BtreePayloadChecked(), the
65253 ** table btrees (pPage->intKey==1). The number of bytes of available
65393 ** If the table has a virtual root page, then the cursor is moved to point
65394 ** to the virtual root page instead of the actual root page. A table has a
65396 ** single child page. This can only happen with the table rooted at page 1.
65407 ** indicating a table b-tree, or if the caller did specify a KeyInfo
65457 ** NULL, the caller expects a table b-tree. If this is not the case,
65463 ** in such a way that page pRoot is linked into a second b-tree table
65542 /* Move the cursor to the first entry in the table. Return SQLITE_OK
65544 ** or set *pRes to 1 if the table is empty.
65564 /* Move the cursor to the last entry in the table. Return SQLITE_OK
65566 ** or set *pRes to 1 if the table is empty.
65625 ** is smaller than intKey/pIdxKey or if the table is empty
65635 ** exists an entry in the table that exactly matches pIdxKey.
65640 i64 intKey, /* The table key */
65724 ** be the right kind (index or table) of b-tree page. Otherwise
65880 ** Return TRUE if the cursor is not pointing at an entry of the table.
65883 ** past the last entry in the table or sqlite3BtreePrev() moves past
65884 ** the first entry. TRUE is also returned if the table is empty.
65887 /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
65895 ** Return an estimate for the number of rows in the table that pCur is
66029 ** SQLITE_DONE the cursor is already on the first element of the table
67792 /* Verify that all sibling pages are of the same "type" (table-leaf,
67793 ** table-interior, index-leaf, or index-interior).
68033 ** of the table is closer to a linear scan through the file. That in turn
68545 ** define what table the record should be inserted into, and is left
68548 ** For a table btree (used for rowid tables), only the pX.nKey value of
68573 BtCursor *pCur, /* Insert data into the table of this cursor */
68604 ** intkey table, the caller should be inserting integer keys with a
68608 /* Save the positions of any other cursors open on this table.
68611 ** example, when inserting data into a table with auto-generated integer
68626 /* If this is an insert into a table b-tree, invalidate any incrblob
68667 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
68736 ** entry in the table, and the next row inserted has an integer key
68783 ** associated with a single table entry and its indexes. Only one of those
68852 /* Save the positions of any other cursors open on this table before
68859 /* If this is a delete operation to remove a row from a table b-tree,
68955 ** Create a new BTree table. Write into *piTable the page
68956 ** number for the root page of the new table.
68970 int ptfFlags; /* Page-type flage for the root page of new table */
68986 /* Creating a new table may probably require moving an existing database
68994 ** root page of the new table should go. meta[3] is the largest root-page
69021 ** the new table (assuming an error did not occur). But we were
69121 BtShared *pBt, /* The BTree that contains the table */
69175 ** Delete all information from a single table in the database. iTable is
69176 ** the page number of the root of the table. After this routine returns,
69180 ** read cursors on the table. Open write cursors are moved to the
69181 ** root of the table.
69183 ** If pnChange is not NULL, then table iTable must be an intkey table. The
69185 ** entries in the table.
69196 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
69197 ** is the root of a table b-tree - if it is not, the following call is
69207 ** Delete all information from the single table that pCur is open on.
69209 ** This routine only work for pCur on an ephemeral table.
69216 ** Erase all information in a table and add the root of the table to
69217 ** the freelist. Except, the root of the principle table (the one on
69221 ** cursors on the table.
69263 /* If the table being dropped is the table with the largest root-page
69272 /* The table being dropped does not have the largest root-page
69979 ** a table. nRoot is the number of entries in aRoot.
70208 ** sqlite_master table. Otherwise SQLITE_OK.
70223 ** Obtain a lock on the table whose root page is iTab. The
70249 ** INTKEY table currently pointing at a valid table entry.
70272 /* Save the positions of all other cursors open on this table. This is
70276 ** Note that pCsr must be open on a INTKEY table and saveCursorPosition()
70277 ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence
70286 ** (c) the connection holds a write-lock on the table (if required),
70288 ** (e) the cursor points at a valid row of an intKey table.
72521 ** on a table column definition, and hence only when pCtx==0. This
72654 ** sqlite_stat3 table to the record format SQLite uses internally.
72759 ** in the sqlite_stat4 table.
73456 ** (for CREATE TABLE AS SELECT ...)
73748 const char *zName /* Name of table or index being scanned */
74541 ** to 6.6 percent. The test case is inserting 1000 rows into a table
76139 ** the blob of data that it corresponds to. In a table record, all serial
76144 ** The following table describes the various storage classes for data:
76417 case 10: { /* Internal use only: NULL with virtual table
76573 ** This function compares two index or table record keys in the same way
76955 ** This function compares the two table rows or index records
77649 Table *pTab, /* Modified table */
78460 ** table, then it returns true if and only if the the call is during an
78465 ** xColumn method of a virtual table, then the return value is meaningless
78468 ** Virtual table implements might use this routine to optimize their
78847 ** 3 The name of the table that the column derives from
78848 ** 4 The name of the table column that the result column derives from
78950 ** Return the name of the table from which a result column derives.
78966 ** Return the name of the table column from which a result column derives.
80078 int nField, /* Number of fields in the table or index */
82377 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
82379 ** The first OP_Column against a pseudo-table after the value of the content
82683 ** use as a data record in a database table or as a key
82779 ** table methods that never invoke sqlite3_result_xxxxx() while
82864 ** Store the number of entries (an integer value) in the table or index
83228 ** are queried from within xNext() and other v-table methods using
83231 ** v-table would have to be ready for the sqlite3_vtab structure itself
83233 ** a v-table method.
83318 ** Open a read-only cursor for the database table whose root page is
83342 ** value, it is set to the number of columns in the table.
83363 ** Open a read/write cursor named P1 on the table or index whose root
83371 ** value, it is set to the number of columns in the table, or to the
83372 ** largest index of any column of the table that is actually used.
83375 ** in read/write mode. For a given table, there can be one or more read-only
83455 testcase( nField==0 ); /* Table with INTEGER PRIMARY KEY and nothing else */
83487 ** Open a new cursor P1 that points to the same ephemeral table as
83519 ** Open a new cursor P1 to a transient table.
83522 ** table is deleted automatically when the cursor is closed.
83524 ** P2 is the number of columns in the ephemeral table.
83525 ** The cursor points to a BTree table if P4==0 and to a BTree index
83567 ** opening it. If a transient table is required, just use the
83568 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
83639 ** Open a new cursor that points to a fake table that contains a single
83644 ** A pseudo-table created by this opcode is used to hold a single
83647 ** is the only cursor opcode that works with a pseudo-table.
83650 ** the pseudo-table.
83688 ** table or index for cursor P1 are used. P4 is a 64-bit integer
83690 ** first 63 columns of the table or index that are actually used
83706 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83731 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83749 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83767 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
83952 /* res might be negative because the table is empty. Check to
84114 ** P1 is the index of a cursor open on an SQL table btree (with integer
84138 ** P1 is the index of a cursor open on an SQL table btree (with integer
84226 ** Get a new integer record number (a.k.a "rowid") used as the key to a table.
84228 ** table that cursor P1 points to. The new record number is written
84240 VdbeCursor *pC; /* Cursor of table to get the new rowid */
84264 ** it already exists in the table. If it does not exist, we have
84334 ** an AUTOINCREMENT table. */
84360 ** Write an entry into the table of cursor P1. A new entry is
84381 ** Parameter P4 may point to a Table structure, or may be NULL. If it is
84404 VdbeCursor *pC; /* Cursor to table into which insert is written */
84407 Table *pTab; /* Table structure - used by update and pre-update hooks */
84492 ** record in the table. If it is left pointing at the next record, then
84499 ** delete one of several associated with deleting a table row and all its
84507 ** P1 must not be pseudo-table. It has to be a real table with
84510 ** If P4 is not NULL then it points to a Table object. In this case either
84524 Table *pTab;
84668 ** a register that is the source for a pseudo-table cursor created using
84669 ** OpenPseudo. That pseudo-table cursor is the one that is identified by
84697 ** If cursor P2 is a table, then the content extracted is the data.
84700 ** of a real table, not a pseudo-table.
84706 ** position in order that they can write to the same table. If P3==0
84713 ** by any use of another cursor pointing to the same table.
84762 ** Store in register P2 an integer which is the key of the table entry that
84765 ** P1 can be either an ordinary table or a virtual table. There used to
84767 ** one opcode now works for both table types.
84844 ** will refer to the last entry in the database table or index.
84845 ** If the table or index is empty and P2>0, then jump immediately to P2.
84846 ** If P2 is 0 or if the table or index is not empty, fall through
84890 ** Estimate the number of rows in the table P1. Jump to P2 if that
84949 ** will refer to the first entry in the database table or index.
84950 ** If the table or index is empty, jump immediately to P2.
84951 ** If the table or index is not empty, fall through to the following
84992 ** table or index. If there are no more key/value pairs then fall through
85000 ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have
85024 ** table or index. If there is no previous key/value pairs then fall through
85033 ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is
85221 ** table. This opcode does a deferred seek of the P3 table cursor
85229 ** one entry for each column in the P3 table. If array entry a(i)
85241 ** the rowid of the table entry to which this index entry points.
85248 VdbeCursor *pTabCur; /* The P2 table cursor (OP_DeferredSeek only) */
85391 ** Delete an entire database table or index whose root page in the database
85394 ** The table being destroyed is in the main database file if P3==0. If
85395 ** P3==1 then the table to be clear is in the auxiliary database file
85396 ** that is used to store tables create using CREATE TEMPORARY TABLE.
85403 ** table being dropped was already the last one in the database) then a
85450 ** Delete all contents of the database table or index whose root page
85452 ** remove the table or index from the database file.
85454 ** The table being clear is in the main database file if P2==0. If
85455 ** P2==1 then the table to be clear is in the auxiliary database file
85456 ** that is used to store tables create using CREATE TEMPORARY TABLE.
85458 ** If the P3 value is non-zero, then the table referred to must be an
85459 ** intkey table (an SQL table, not an index). In this case the row change
85460 ** count is incremented by the number of rows in the table being cleared.
85462 ** also incremented by the number of rows in the table being cleared.
85489 ** Delete all contents from the ephemeral table or sorter
85517 ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table
85518 ** it must be 2 (BTREE_BLOBKEY) for a index or WITHOUT ROWID table.
85553 ** Read and parse all entries from the SQLITE_MASTER table of database P1
85612 ** Read the sqlite_stat1 table for database P1 and load the content
85613 ** of that table into the internal index hash table. This will cause
85627 ** the table named P4 in database P1. This is called after a table
86485 ** Obtain a lock on a particular table. This instruction is only used when
86492 ** P2 contains the root-page of the table to lock.
86494 ** P4 contains a pointer to the name of the table being locked. This is only
86508 sqlite3VdbeError(p, "database table is locked: %s", z);
86521 ** xBegin method for that table.
86524 ** within a callback to a virtual table xSync() method. If it is, the error
86540 ** P2 is a register that holds the name of a virtual table in database
86541 ** P1. Call the xCreate method for that table.
86545 const char *zTab; /* Name of the virtual table */
86569 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
86570 ** of that table.
86584 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
86586 ** table and stores that cursor in P1.
86635 ** This opcode invokes the xFilter method on the virtual table specified
86694 ** the current row of the virtual-table of cursor P1.
86700 ** by virtual table implementations to return special "no-change"
86701 ** marks which can be more efficient, depending on the virtual table.
86750 ** Advance virtual table P1 to the next row in its result set and
86751 ** jump to instruction P2. Or, if the virtual table has reached
86774 ** some other method is next invoked on the save virtual table cursor.
86792 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
86824 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
86834 ** row. This can be NULL to have the virtual table select the new
87319 u16 iCol; /* Table column this handle is open on */
87324 Table *pTab; /* Table object */
87413 const char *zTable, /* The table containing the blob */
87423 Table *pTab;
87454 sqlite3ErrorMsg(&sParse, "cannot open virtual table: %s", zTable);
87458 sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable);
87539 ** db/table/row entry. The reason for using a vdbe program instead
87574 /* Make sure a mutex is held on the table to be accessed */
87598 ** think that the table has one more column than it really
87760 ** database table.
90867 ** Table of methods for MemJournal sqlite3_file object.
91168 ** table and column.
91274 ** Subqueries stores the original database, table and column names for their
91275 ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".
91311 ** pExpr->iTable Set to the cursor number for the table obtained
91313 ** pExpr->pTab Points to the Table structure of X.Y (even if
91315 ** pExpr->iColumn Set to the column number within the table.
91322 ** can be used. The zTable variable is the name of the table (the "Y"). This
91324 ** means that the form of the name is Z and that columns from any table
91332 const char *zDb, /* Name of the database containing table, or NULL */
91333 const char *zTab, /* Name of table containing column, or NULL */
91340 int cntTab = 0; /* Number of matching table names */
91348 Table *pTab = 0; /* Table hold the row */
91425 ** is for the right-hand table of a NATURAL JOIN or is in a
91526 ** SELECT a+b AS x FROM table WHERE x<10;
91611 /* If a column from a table in pSrcList is referenced, then record
91765 ** Or table name and column name: ID.ID
91766 ** Or a database, table and column: ID.ID.ID
92438 /* Resolve names in table-valued-function arguments */
92527 ** table columns and result-set columns. At the same time, do error
92531 ** To resolve table columns references we look for nodes (or subtrees) of the
92537 ** Y: The name of a table in a FROM clause. Or in a trigger
92540 ** Z: The name of a column in table Y.
92545 ** Expr.pTab Points to the Table object for X.Y
92554 ** Table-name and function resolution occurs on the substituted expression
92652 ** Resolve names in expressions that can only reference a single table:
92664 Table *pTab, /* The table being referenced */
92709 ** Return the affinity character for a single column of a table.
92711 SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){
92727 ** CREATE TABLE t1(a);
93085 ** not be ready for evaluation because the table cursor has not yet
94079 Table *pTab;
94439 ** in a CREATE TABLE statement. The Walker.eCode value is 5 when parsing
94488 ** of the sqlite_master table */
94540 ** for any single row of the table with cursor iCur. In other words, the
94542 ** table other than iCur.
94763 ** that can be simplified to a direct table access, then return
94766 ** table, then return NULL.
94773 Table *pTab;
94794 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
94809 ** Generate code that checks the left-most column of index table iCur to see if
94857 ** IN_INDEX_ROWID - The cursor was opened on a database table.
94861 ** populated epheremal table.
94868 ** SELECT <column1>, <column2>... FROM <table>
94871 ** an ephemeral table might need to be generated from the RHS and then
94872 ** pX->iTable made to point to the ephemeral table instead of an
94873 ** existing table.
94877 ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast
94883 ** An epheremal table will be created unless the selected columns are guaranteed
94888 ** for fast set membership tests) then an epheremal table must
94932 int eType = 0; /* Type of RHS table. IN_INDEX_* */
94933 int iTab = pParse->nTab++; /* Cursor of the RHS table */
94956 /* Check to see if an existing table or index can be used to
94958 ** ephemeral table. */
94961 Table *pTab; /* Table <table>. */
94971 /* Code an OP_Transaction and OP_TableLock for <table>. */
94978 /* The "x IN (SELECT rowid FROM table)" case */
94992 ** comparison is the same as the affinity of each column in table
94994 ** use any index of the RHS table. */
94998 char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */
95096 ** then it is not worth creating an ephemeral table to evaluate
95108 /* Could not find an existing table or index to use as the RHS b-tree.
95109 ** We will have to generate an ephemeral table to do the job.
95220 ** to some integer key column of a table B-Tree. In this case, use an
95284 ** expression it is handled the same way. An ephemeral table is
95305 ** table allocated and opened above.
95342 ** store it in the temporary table. If <expr> is a column, then use
95379 /* Evaluate the expression and insert it into the temp table */
95557 ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
95671 /* In this case, the RHS is the ROWID of table b-tree and so we also
95834 ** particular table is stored in a particular register.
95962 int iTabCur, /* Cursor pointing to a table row */
95980 ** Generate code to extract the value of the iCol-th column of a table.
95984 Table *pTab, /* The table containing the value */
95985 int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */
96010 ** table pTab and store the column value in a register.
96022 Table *pTab, /* Description of the table we are reading from */
96023 int iColumn, /* Index of the table column */
96024 int iTable, /* The cursor pointing to the table */
96050 Table *pTab, /* Description of the table we are reading from */
96051 int iColumn, /* Index of the table column */
96052 int iTable, /* The cursor pointing to the table */
96221 ** in the index refer to the table to which the index belongs */
96538 ** a virtual table column.
96542 ** see if it is a column in a virtual table. This is done because
96645 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
96646 ** is set to the column of the pseudo-table to read, or to -1 to
96651 ** to reference another column of the old.* pseudo-table, where
96653 ** set to (n+1), where n is the number of columns in each pseudo-table.
96654 ** For a reference to any other column in the new.* pseudo-table, p1
96656 ** example, if the table on which triggers are being fired is
96659 ** CREATE TABLE t1(a, b);
96667 Table *pTab = pExpr->pTab;
97575 ** Expr.iTable<0 then assume a table number given by iTab.
97608 ** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
97609 ** is the cursor for the table.
97613 int iCur; /* Cursor number for the table corresponding to the index */
97617 ** Check to see if there are references to columns in table
97633 ** Determine if an index pIdx on table with cursor iCur contains will
97635 ** expression and false if the pExpr expression references table columns
97640 ** corresponding table entry.
97644 table */
97661 ** to count references to table columns in the arguments of an
97774 /* If we reach this point, it means that pExpr refers to a table
98032 ** that implements the ALTER TABLE command.
98038 ** ALTER TABLE logic from the build.
98045 ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
98046 ** CREATE INDEX command. The second is a table name. The table name in
98047 ** the CREATE TABLE or CREATE INDEX statement is replaced with the third
98050 ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
98051 ** -> 'CREATE TABLE def(a, b, c)'
98074 /* The principle used to locate the table name in the CREATE TABLE
98075 ** statement is that the table name is the first non-space token that
98107 ** generated by the ALTER TABLE ... RENAME command to modify the definition
98108 ** of any foreign key constraints that use the table being renamed as the
98109 ** parent table. It is passed three arguments:
98111 ** 1) The complete text of the CREATE TABLE statement being modified,
98112 ** 2) The old name of the table being renamed, and
98113 ** 3) The new name of the table being renamed.
98115 ** It returns the new CREATE TABLE statement. For example:
98117 ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
98118 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
98172 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
98173 ** statement. The second is a table name. The table name in the CREATE
98176 ** TRIGGER, not CREATE INDEX and CREATE TABLE.
98196 /* The principle used to locate the table name in the CREATE TRIGGER
98197 ** statement is that the table name is the first token that is immediately
98205 /* Ran out of input before finding the table name. Return NULL. */
98227 ** Note that ON cannot be a database, table or column name, so
98237 /* Variable tname now contains the token that is the old table-name
98248 ** Register built-in functions used to help implement ALTER TABLE
98293 ** tables that have foreign key constraints that refer to table pTab (i.e.
98294 ** constraints for which pTab is the parent table) from the sqlite_master
98295 ** table.
98297 static char *whereForeignKeys(Parse *pParse, Table *pTab){
98309 ** temporary triggers on table pTab from the sqlite_temp_master table. If
98310 ** table pTab has no temporary triggers, or is itself stored in the
98313 static char *whereTempTriggers(Parse *pParse, Table *pTab){
98318 /* If the table is not located in the temp-db (in which case NULL is
98340 ** Generate code to drop and reload the internal representation of table
98342 ** Argument zName is the name of the table in the database schema at
98345 ** "ALTER TABLE RENAME TO" statement.
98347 static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
98362 /* Drop any table triggers from the internal schema. */
98370 /* Drop the table and index from the internal schema. */
98373 /* Reload the table, index and permanent trigger schemas. */
98379 /* Now, if the table is not stored in the temp database, reload any temp
98389 ** Parameter zName is the name of a table that is about to be altered
98390 ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
98391 ** If the table is a system table, this function leaves an error message
98394 ** Or, if zName is not a system table, zero is returned.
98398 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
98405 ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
98410 SrcList *pSrc, /* The table to rename. */
98411 Token *pName /* The new table name. */
98413 int iDb; /* Database that contains the table */
98415 Table *pTab; /* Table being renamed */
98419 const char *zTabName; /* Original name of the table */
98438 /* Get a NULL terminated version of the new table name. */
98442 /* Check that a table or index named 'zName' does not already exist
98447 "there is already another table or index with this name: %s", zName);
98451 /* Make sure it is not a system table being altered, or a reserved name
98452 ** that the table is being renamed to.
98488 ** Then modify the schema cookie (since the ALTER TABLE modifies the
98489 ** schema). Open a statement transaction if the table is a virtual
98490 ** table.
98499 /* If this is a virtual table, invoke the xRename() function if
98501 ** of any resources used by the v-table implementation (including other
98502 ** SQLite tables) that are identified by the name of the virtual table.
98519 /* If foreign-key support is enabled, rewrite the CREATE TABLE
98521 ** for which the renamed table is the parent table. */
98532 /* Modify the sqlite_master table to use the new table name. */
98544 "WHEN type='table' THEN %Q "
98549 "(type='table' OR type='index' OR type='trigger');",
98558 /* If the sqlite_sequence table exists in this database, then update
98559 ** it with the new table name.
98569 /* If there are TEMP triggers on this table, modify the sqlite_temp_master
98570 ** table. Don't do this if the table being ALTERed is itself located in
98587 Table *pFrom = p->pFrom;
98595 /* Drop and reload the internal table schema. */
98605 ** This function is called after an "ALTER TABLE ... ADD" statement
98609 ** The Table structure pParse->pNewTable was extended to include
98613 Table *pNew; /* Copy of pParse->pNewTable */
98614 Table *pTab; /* Table being altered */
98617 const char *zTab; /* Table name */
98698 /* Modify the CREATE TABLE statement. */
98710 "WHERE type = 'table' AND name = %Q",
98731 /* Reload the schema of the modified table. */
98736 ** This function is called by the parser after the table-name in
98737 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
98738 ** pSrc is the full-name of the table being altered.
98740 ** This routine makes a (partial) copy of the Table structure
98741 ** for the table being altered and sets Parse.pNewTable to point
98744 ** the copy. The copy of the Table structure is deleted by tokenize.c
98748 ** coding the "ALTER TABLE ... ADD" statement.
98751 Table *pNew;
98752 Table *pTab;
98759 /* Look up the table being altered. */
98785 /* Put a copy of the Table struct in Parse.pNewTable for the
98789 ** table because user table are not allowed to have the "sqlite_"
98792 pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
98850 ** CREATE TABLE sqlite_stat1(tbl, idx, stat);
98851 ** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);
98852 ** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);
98853 ** CREATE TABLE sqlite_stat4(tbl, idx, nEq, nLt, nDLt, sample);
98856 ** The sqlite_stat2 table is not created or used unless the SQLite version
98858 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
98859 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
98874 ** name in the idx column. The tbl column is the name of the table to
98878 ** number of rows in the table, except for partial indices.) The second
98895 ** rows in the table identified by sqlite_stat1.tbl.
98901 ** 3.6.18 and 3.7.8. The "stat2" table contains additional information
98903 ** the "idx" column and the "tbl" column is the name of the table to which
98905 ** table for each index.
98920 ** writes the sqlite_stat2 table. This version of SQLite only supports
98931 ** As with sqlite_stat2, the sqlite_stat4 table contains histogram data
98936 ** The sqlite_stat4 table contains multiple entries for each index.
98937 ** The idx column names the index and the tbl column is the table of the
98964 ** The sqlite_stat3 table is like sqlite_stat4 except that it only
98991 ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now
98997 ** Argument zWhere may be a pointer to a buffer containing a table name,
98999 ** the sqlite_statN tables associated with the named table are deleted.
99000 ** If zWhere==0, then code is generated to delete all stat table entries.
99005 int iStatCur, /* Open the sqlite_stat1 table on this cursor */
99006 const char *zWhere, /* Delete entries for this table or index */
99042 Table *pStat;
99045 /* The sqlite_statN table does not exist. Create it. Note that a
99046 ** side-effect of the CREATE TABLE statement is to leave the rootpage
99047 ** of the new table in register pParse->regRoot. This is important
99050 "CREATE TABLE %Q.%s(%s)", pDb->zDbSName, zTab, aTable[i].zCols
99056 /* The table already exists. If zWhere is not NULL, delete all entries
99057 ** associated with the table zWhere. If zWhere is NULL, delete the
99058 ** entire contents of the table. */
99072 /* The sqlite_stat[134] table already exists. Delete all rows. */
99107 i64 iRowid; /* Rowid in main table of the key */
99117 tRowcnt nRow; /* Number of rows in the entire table */
99214 ** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the
99215 ** total number of columns in the table.
99221 ** PRIMARY KEY of the table. The covering index that implements the
99222 ** original WITHOUT ROWID table as N==K as a special case.
99404 ** iCol occurs many times in the table. However, if we have already
99638 #define STAT_GET_STAT1 0 /* "stat" column of stat1 table */
99661 ** stat1 table entry information.
99683 ** table for this index.
99805 ** a single table.
99809 Table *pTab, /* Table whose indices are to be analyzed */
99811 int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */
99818 int iTabCur; /* Table cursor */
99823 u8 needTableCnt = 1; /* True to count the table */
99831 int regTabname = iMem++; /* Register containing table name */
99836 Table *pStat1 = 0;
99865 pStat1 = (Table*)sqlite3DbMallocZero(db, sizeof(Table) + 13);
99875 /* Establish a read-lock on the table at the shared-cache level.
99876 ** Open a read-only cursor on the table. Also allocate a cursor number
99944 ** the sqlite_stat4 table. */
99956 ** (or for a WITHOUT ROWID table, the number of PK columns),
100070 /* Add the entry to the stat1 table. */
100081 /* Add the entries to the stat3 or stat4 table. */
100180 Table *pTab = (Table*)sqliteHashData(k);
100187 ** Generate code that will do an analysis of a single table in
100191 static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){
100220 ** Form 3 analyzes all indices associated with the named table.
100227 Table *pTab;
100250 /* Form 3: Analyze the table or index named as an argument */
100347 ** sqlite_stat1 table.
100349 ** argv[0] = name of the table
100354 ** the table.
100359 Table *pTable;
100478 ** occur in the stat4 table for this index. Set sumEq to the sum of
100500 ** Look up an index by name. Or, if the name of a WITHOUT ROWID table
100501 ** is supplied instead, find the PRIMARY KEY index for that table.
100510 Table *pTab = sqlite3FindTable(db, zName, zDb);
100517 ** Load the content from either the sqlite_stat4 or sqlite_stat3 table
100567 ** loaded from the stat4 table. In this case ignore stat3 data. */
100617 ** the sqlite_stat4 table. In this case ignore stat3 data. */
100685 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
100687 ** during compilation and the sqlite_stat3/4 table is present, no data is
100691 ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is
100693 ** table (if it is present) before returning.
100712 Table *pTab = sqliteHashData(i);
100724 /* Load new statistics out of the sqlite_stat1 table */
100738 /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
100745 /* Load the statistics from the sqlite_stat4 table. */
101208 ** a specific database to all table references where the database name
101403 ** the table and the column that are being accessed. The auth function
101441 ** table zTab in database zDb. This function assumes that an authorization
101450 const char *zTab, /* Table name */
101476 ** The pExpr should be a TK_COLUMN expression. The table referred to
101477 ** is in pTabList or else it is the NEW or OLD table of a trigger.
101488 SrcList *pTabList /* All table that pExpr might refer to */
101491 Table *pTab = 0; /* The table being read */
101492 const char *zCol; /* Name of the column of the table */
101493 int iSrc; /* Index in pTabList->a[] of table being read */
101495 int iCol; /* Index of column in table */
101501 ** temporary table. */
101634 ** CREATE TABLE
101635 ** DROP TABLE
101651 int iDb; /* The database containing the table to be locked */
101652 int iTab; /* The root page of the table to be locked */
101654 const char *zLockName; /* Name of the table */
101658 ** Record the fact that we want to lock a table at run-time.
101660 ** The table to be locked has root page iTab and is found in database iDb.
101669 int iDb, /* Index of the database containing the table to lock */
101670 int iTab, /* Root page number of the table to be locked */
101672 const char *zName /* Name of the table to be locked */
101706 ** Code an OP_TableLock instruction for each table locked by the
101819 ** obtain the required table-locks. This is a no-op unless the
101896 ** Return TRUE if zTable is the name of the system table that stores the
101906 ** table given the name of that table and (optionally) the name of the
101907 ** database containing the table. Return NULL if not found.
101909 ** If zDatabase is 0, all databases are searched for the table and the
101910 ** first matching table is returned. (No checking for duplicate table
101916 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
101917 Table *p = 0;
101923 /* Only the admin user is allowed to know that the sqlite_user table
101949 ** table given the name of that table and (optionally) the name of the
101950 ** database containing the table. Return NULL if not found. Also leave an
101957 SQLITE_PRIVATE Table *sqlite3LocateTable(
101960 const char *zName, /* Name of the table we are looking for */
101963 Table *p;
101973 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
101976 /* If zName is the not the name of a table in the schema created using
101977 ** CREATE, then check to see if it is the name of an virtual table that
101978 ** can be an eponymous virtual table. */
102002 ** Locate the table identified by *p.
102010 SQLITE_PRIVATE Table *sqlite3LocateTableItem(
102033 ** table and the first matching index is returned. (No checking
102074 ** unlike that index from its Table then remove the index from
102075 ** the index hash table and free all memory structures associated
102185 ** Delete memory allocated for the column names of a table or view (the
102186 ** Table.aCol[] array).
102188 SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){
102204 ** Table. No changes are made to disk by this routine.
102207 ** the table data structure from the hash table. But it does destroy
102209 ** the table.
102211 ** The db parameter is optional. It is needed if the Table object
102212 ** contains lookaside memory. (Table objects in the schema do not use
102213 ** lookaside memory, but some ephemeral Table objects do.) Or the
102215 ** used by the Table object.
102217 static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
102230 /* Delete all indices associated with this table. */
102246 /* Delete any foreign keys attached to this table. */
102249 /* Delete the Table structure itself.
102264 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
102265 /* Do not delete the table until the reference count reaches zero. */
102273 ** Unlink the given table from the hash tables and the delete the
102274 ** table structure with all its indices and foreign keys.
102277 Table *p;
102284 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
102316 ** Open the sqlite_master table stored in database number iDb for
102317 ** writing. The table is opened using cursor 0.
102363 /* The table or view or trigger name is passed to this routine via tokens
102364 ** pName1 and pName2. If the table name was fully qualified, for example:
102366 ** CREATE TABLE xxx.yyy (...);
102369 ** the table name is not fully qualified, i.e.:
102371 ** CREATE TABLE yyy(...);
102376 ** pName2) that stores the unqualified table name. The index of the
102411 ** unqualified name for a new schema object (table, index, view or
102427 ** Return the PRIMARY KEY index of a table
102429 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){
102436 ** Return the column of index pIdx that corresponds to table
102448 ** Begin constructing a new table representation in memory. This is
102450 ** to a CREATE TABLE statement. In particular, this routine is called
102451 ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp
102452 ** flag is true if the table should be stored in the auxiliary database
102455 ** CREATE and TABLE.
102457 ** The new table record is initialized and put in pParse->pNewTable.
102458 ** As more of the CREATE TABLE statement is parsed, additional action
102460 ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine
102461 ** is called to complete the construction of the new table record.
102465 Token *pName1, /* First part of the name of the table or view */
102466 Token *pName2, /* Second part of the name of the table or view */
102467 int isTemp, /* True if this is a TEMP table */
102469 int isVirtual, /* True if this is a VIRTUAL table */
102470 int noErr /* Do nothing if table already exists */
102472 Table *pTable;
102473 char *zName = 0; /* The name of the new table */
102476 int iDb; /* Database number to create the table in */
102477 Token *pName; /* Unqualified name of the table to create */
102489 /* If creating a temp table, the name may not be qualified. Unless
102491 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
102524 /* Make sure the new table name does not collide with an existing
102525 ** index or table name in the same database. Issue an error message if
102539 table %T already exists", pName);
102552 pTable = sqlite3DbMallocZero(db, sizeof(Table));
102571 /* If this is the magic sqlite_sequence table used by autoincrement,
102572 ** then record a pointer to this table in the main database structure
102573 ** so that INSERT can find the table easily.
102582 /* Begin generating the code that will insert the table record into
102583 ** the SQLITE_MASTER table. Note in particular that we must go ahead
102584 ** and allocate the record number for the table entry now. Before any
102586 ** indices to be created and the table record must come before the
102587 ** indices. Hence, the record number for the table must be allocated
102619 /* This just creates a place-holder record in the sqlite_master table.
102624 ** The root page number of the new table is left in reg pParse->regRoot.
102654 /* Set properties of a table column based on the (magical)
102658 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
102669 ** Add a new column to the table currently being constructed.
102672 ** in a CREATE TABLE statement. sqlite3StartTable() gets called
102677 Table *p;
102733 ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
102738 Table *p;
102750 ** substrings in the following table. If one of the substrings is
102753 ** the table take priority. For example, if zType is 'BLOBINT',
102767 ** If none of the substrings in the above table are found,
102834 ** of the table currently under construction.
102840 ** parsing a CREATE TABLE statement.
102848 Table *p;
102881 ** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)
102900 ** Designate the PRIMARY KEY for the table. pList is a list of names
102902 ** most recently added column of the table is the primary key.
102904 ** A table can have at most one primary key. If the table already has
102909 ** then we will try to use that column as the rowid. Set the Table.iPKey
102910 ** field of the table under construction to be the index of the
102911 ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is
102924 Table *pTab = pParse->pNewTable;
102931 "table \"%s\" has more than one primary key", pTab->zName);
102985 ** Add a new CHECK constraint to the table currently under construction.
102992 Table *pTab = pParse->pNewTable;
103009 ** Set the collation function of the most recently parsed table column
103013 Table *p;
103159 ** Generate a CREATE TABLE statement appropriate for the given
103160 ** table. Memory to hold the text of the statement is obtained
103163 static char *createTableStmt(sqlite3 *db, Table *p){
103188 sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
103253 ** Estimate the total row width for a table.
103255 static void estimateTableWidth(Table *pTab){
103289 ** This routine runs at the end of parsing a CREATE TABLE statement that
103292 ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
103298 ** (3) Bypass the creation of the sqlite_master table entry
103300 ** identified by the sqlite_master table entry of the table itself.
103302 ** schema to the rootpage from the main table.
103303 ** (5) Add all table columns to the PRIMARY KEY Index object
103312 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
103342 /* Locate the PRIMARY KEY index. Or, if this table was originally
103343 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
103382 ** table entry. This is only required if currently generating VDBE
103383 ** code for a CREATE TABLE (not when parsing one as part of reading
103390 /* The root page of the PRIMARY KEY is the table root page */
103419 /* Add all table columns to the PRIMARY KEY index
103440 ** a CREATE TABLE statement.
103442 ** The table structure that other action routines have been building
103446 ** An entry for the table is made in the master table on disk, unless
103447 ** this is a temporary table or db->init.busy==1. When db->init.busy==1
103448 ** it means we are reading the sqlite_master table because we just
103449 ** connected to the database or because the sqlite_master table has
103450 ** recently changed, so the entry for this table already exists in
103451 ** the sqlite_master table. We do not want to create it again.
103454 ** was called to create a table generated from a
103455 ** "CREATE TABLE ... AS SELECT ..." statement. The column names of
103456 ** the new table will match the result set of the SELECT.
103461 Token *pEnd, /* The ')' before options in the CREATE TABLE */
103462 u8 tabOpts, /* Extra table options. Usually 0. */
103465 Table *p; /* The new table */
103467 int iDb; /* Database in which the table lives */
103468 Index *pIdx; /* An implied index of the table */
103480 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
103482 ** for the table from the db->init.newTnum field. (The page number
103486 ** table itself. So mark it read-only.
103501 sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
103518 /* Estimate the average row size for the table and for all implied indices */
103524 table
103525 ** in the SQLITE_MASTER table of the database.
103527 ** If this is a TEMPORARY table, write the entry into the auxiliary
103533 char *zType; /* "view" or "table" */
103534 char *zType2; /* "VIEW" or "TABLE" */
103535 char *zStmt; /* Text of the CREATE TABLE or CREATE VIEW statement */
103543 ** Initialize zType for the new view or table.
103546 /* A regular table */
103547 zType = "table";
103548 zType2 = "TABLE";
103557 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
103558 ** statement to populate the new table. The root-page number for the
103559 ** new table is in register pParse->regRoot.
103563 ** by the new table.
103565 ** A shared-cache write-lock is not required to write to the new table,
103574 int regRec; /* A record to be insert into the new table */
103577 Table *pSelTab; /* A table that describes the SELECT results */
103627 ** SQLITE_MASTER table. We just need to update that slot with all
103646 /* Check to see if we need to create an sqlite_sequence table for
103654 "CREATE TABLE %Q.sqlite_sequence(name,seq)",
103667 /* Add the table to the in-memory representation of the database.
103670 Table *pOld;
103711 Table *p;
103757 /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */
103769 ** The Table structure pTable is really a VIEW. Fill in the names of
103773 SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
103774 Table *pSelTab; /* A fake table from which we get the result set */
103815 ** CREATE TABLE main.ex1(a);
103825 /* If we get this far, it means we need to compute the table names.
103850 ** The names of the columns in the table are taken from
103852 ** normally holds CHECK constraints on an ordinary table, but for
103898 Table *pTab = sqliteHashData(i);
103913 ** used by SQLite when the btree layer moves a table root page. The
103914 ** root-page of a table or index in database iDb has changed from iFrom
103917 ** Ticket #1728: The symbol table might still contain information
103920 ** have the same rootpage number as the real table or index that is
103923 ** or tables and not the table/index that is actually being moved.
103938 Table *pTab = sqliteHashData(pElem);
103954 ** Write code to erase the table with root-page iTable from database iDb.
103955 ** Also write code to modify the sqlite_master table and internal schema
103956 ** if a root-page of another table is moved by the btree-layer whilst
103967 ** is non-zero, then it is the root page number of a table moved to
103968 ** location iTable. The following code modifies the sqlite_master table to
103983 ** Write VDBE code to erase table pTab and all associated indices on disk.
103985 ** in case a root-page belonging to another table is moved by the btree layer
103988 static void destroyTable(Parse *pParse, Table *pTab){
103991 ** table and index root-pages in order, starting with the numerically
104035 ** after a DROP INDEX or DROP TABLE command.
104041 const char *zName /* Name of index or table */
104058 ** Generate code to drop a table.
104060 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
104076 /* Drop all triggers associated with the table being dropped. Code
104089 /* Remove any entries of the sqlite_sequence table associated with
104090 ** the table being dropped. This is done before the table is dropped
104091 ** at the btree level, in case the sqlite_sequence table needs to
104102 /* Drop all SQLITE_MASTER table and index entries that refer to the
104103 ** table. The program name loops through the master table and deletes
104104 ** every row that refers to a table of the same name as the one being
104106 ** created in the temp database that refers to a table in another
104116 /* Remove the table entry from SQLite's internal schema and modify
104128 ** This routine is called to do the work of a DROP TABLE statement.
104129 ** pName is the name of the table to be dropped.
104132 Table *pTab;
104155 /* If pTab is a virtual table, call ViewGetColumnNames() to ensure
104198 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
104203 /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used
104204 ** on a table.
104207 sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);
104216 /* Generate code to remove the table from the master table
104232 ** This routine is called to create a new foreign key on the table
104234 ** in the current table point to the foreign key. If pFromCol==0 then
104236 ** the table referred to (a.k.a the "parent" table). pToCol is a list
104237 ** of tables in the parent pTo table. flags contains all
104241 ** An FKey structure is created and added to the table currently
104249 ExprList *pFromCol, /* Columns in this table that point to other table */
104250 Token *pTo, /* Name of the other table */
104251 ExprList *pToCol, /* Columns in the other table */
104258 Table *p = pParse->pNewTable;
104271 " should reference only one column of table %T",
104279 "columns in the referenced table");
104349 /* Link the foreign key to the table as the last step.
104370 Table *pTab;
104390 Table *pTab = pIndex->pTable; /* The table that is indexed */
104411 /* Require a write-lock on the table to perform this operation */
104429 /* Open the table. Loop through all rows of the table, inserting index
104505 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
104506 ** and pTblList is the name of the table that is to be indexed. Both will
104509 ** as the table to be indexed. pParse->pNewTable is a table that is
104510 ** currently being constructed by a CREATE TABLE statement.
104514 ** to the table currently under construction.
104520 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
104529 Table *pTab = 0; /* Table to be indexed */
104537 Db *pDb; /* The specific table containing the indexed database */
104557 ** Find the table that is to be indexed. Return early if not found.
104562 ** to search for the table. 'Fix' the table name to this db
104563 ** before looking up the table.
104571 /* If the index name was unqualified, check if the table
104572 ** is a temp table. If so, set the database to 1. Do not do this
104594 "cannot create a TEMP index on non-TEMP table \"%s\"",
104616 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
104634 ** index or table with the same name.
104637 ** sqlite_master table (because some other process changed the schema) and
104638 ** one of the index names collides with the name of a temporary table or
104654 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
104701 ** key out of the last column added to the table under construction.
104765 ** a table column, store that column in aiColumn[]. For general expressions,
104769 ** TODO: Issue a warning if the table primary key is used as part of the
104830 /* Append the table key to the end of the index. For WITHOUT ROWID
104855 /* If this index contains every column of its table, then mark
104875 ** CREATE TABLE t(x PRIMARY KEY, y);
104876 ** CREATE TABLE t(x, y, UNIQUE(x, y));
104878 ** Either way, check to see if the table already has such an index. If
104911 ** constraint specified somewhere in the CREATE TABLE statement.
104931 /* Link the new Index structure to its table and to the other
104952 /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
104955 ** the index in the sqlite_master table and populate the index with
104957 ** table to parse the schema, or if this index is the PRIMARY KEY index
104958 ** of a WITHOUT ROWID table.
104961 ** or UNIQUE index in a CREATE TABLE statement. Since the table
104978 ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
105025 /* When adding an index to the list of indices for a table, make
105062 ** number of rows in the table that match any particular value of the
105085 ** number of rows in the table, or half the number of rows in the table
105139 Table *pTab = pIndex->pTable;
105152 /* Generate code to remove the index and from the master table */
105333 ** Append a new table name to the given SrcList. Create a new SrcList if
105341 ** If pDatabase is not null, it means that the table has an optional
105342 ** database name prefix. Like this: "database.table". The pDatabase
105343 ** points to the table name and the pTable points to the database name.
105344 ** The SrcList.a[].zName field is filled with the table name which might
105353 ** Then B is a table name and the database name is unspecified. If called
105358 ** Then C is the table name and B is the database name. If C is defined
105369 Token *pTable, /* Table to append */
105370 Token *pDatabase /* Database of the table */
105447 ** are the name of the table and database named in the FROM clause term.
105461 Token *pTable, /* Name of the table to add to the FROM clause */
105464 Select *pSubquery, /* A subquery used in place of a table name */
105525 ** table-valued-function.
105725 ** inserting multiple rows in a table, or inserting a row and index entries.)
105788 Table *pTab = pIdx->pTable;
105818 Table *pTab /* The table with the non-unique rowid */
105858 static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
105882 Table *pTab; /* A table in the database */
105888 pTab = (Table*)sqliteHashData(k);
105906 ** indices associated with the named table.
105911 table or index */
105913 Table *pTab; /* A table in the database */
105917 Token *pObjName; /* Name of the table or index to be reindexed */
106016 Token *pName, /* Name of the common-table */
106017 ExprList *pArglist, /* Optional column name list for the table */
106018 Select *pQuery /* Query used to initialize the table */
106031 sqlite3ErrorMsg(pParse, "duplicate WITH table name: %s", zName);
106218 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
106222 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
106254 ** to the hash table).
106378 ** Insert a new FuncDef into a FuncDefHash hash table.
106482 ** new entry to the hash table and return it.
106531 Table *pTab = sqliteHashData(pElem);
106587 ** the name of a single table, as one might find in an INSERT, DELETE,
106588 ** or UPDATE statement. Look up that table in the symbol table and
106589 ** return a pointer. Set an error message and return NULL if the table
106594 ** pSrc->a[0].pTab Pointer to the Table object
106598 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
106600 Table *pTab;
106615 ** Check to make sure the given table is writable. If it is not
106619 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
106620 /* A table is not writable under the following circumstances:
106622 ** 1) It is a virtual table and no implementation of the xUpdate method
106624 ** 2) It is a system table (i.e. sqlite_master), this call is not
106636 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
106652 ** Evaluate a view and store its result in an ephemeral table. The
106654 ** set of rows in the view that are to be added to the ephemeral table.
106658 Table *pView, /* View definition */
106662 int iCur /* Cursor number for ephemeral table */
106709 Table *pTab;
106790 SrcList *pTabList, /* The table from which we should delete things */
106796 Table *pTab; /* The table from which records will be deleted */
106799 Index *pIdx; /* For looping over indices of the table */
106800 int iTabCur; /* Cursor number for the table */
106813 Index *pPk; /* The PRIMARY KEY index on the table */
106818 int iEphCur = 0; /* Ephemeral table holding all primary key values */
106822 int addrEphOpen = 0; /* Instruction to open the Ephemeral table */
106828 Trigger *pTrigger; /* List of table triggers, if required */
106839 /* Locate the table which we want to delete. This table has to be
106842 ** an SrcList* parameter instead of just a Table* parameter.
106847 /* Figure out if we have any triggers and if the table being
106892 /* Assign cursor numbers to the table and all its indices.
106916 ** an ephemeral table.
106948 ** It is easier just to erase the whole table. Prior to version 3.6.5,
106983 /* For a rowid table, initialize the RowSet to an empty set */
106989 /* For a WITHOUT ROWID table, create an ephemeral table used to
107051 /* Add the PK key for this row to the temporary table */
107072 /* Unless this is a view, open cursors for the table we are
107147 /* Update the sqlite_sequence table by storing the content of the
107188 ** single table to be deleted. Both the original table entry and
107194 ** store for the table. (This will be either the table itself,
107195 ** in the case of a rowid table, or the PRIMARY KEY index in the case
107196 ** of a WITHOUT ROWID table.)
107229 Table *pTab, /* Table containing the row to be deleted */
107277 /* Populate the OLD.* pseudo-table register array. These values will be
107311 ** refer to this table (i.e. constraints attached to other tables)
107316 /* Delete the index and table entries. Skip this step if pTab is really
107322 ** be invoked unless table pTab is a system table. The difference is that
107362 ** index entries associated with a single row of a single table, pTab
107367 ** btree for the table pTab. (This will be either the table itself
107380 Table *pTab, /* Table containing the row to be deleted */
107381 int iDataCur, /* Cursor of table holding data. */
107414 ** iCur is the index of a cursor open on the pTab table and pointing to
107415 ** the entry that needs indexing. If pTab is a WITHOUT ROWID table, then
107439 ** on a table with multiple indices, and especially with the ROWID or
107482 ** might be stored in the table as an integer (using a compact
107982 ** routines in the function table. The noopFunc macro provides this.
109278 ** to the global function hash table. This occurs at start-time (as
109465 ** I.1) For each FK for which the table is the child table, search
109466 ** the parent table for a match. If none is found increment the
109469 ** I.2) For each FK for which the table is the parent table,
109470 ** search the child table for rows that correspond to the new
109471 ** row in the parent table. Decrement the counter for each row
109476 ** D.1) For each FK for which the table is the child table,
109477 ** search the parent table for a row that corresponds to the
109478 ** deleted row in the child table. If such a row is not found,
109481 ** D.2) For each FK for which the table is the parent table, search
109482 ** the child table for rows that correspond to the deleted row
109483 ** in the parent table. For each found increment the counter.
109511 ** TODO: How should dropping a table be handled? How should renaming a
109512 ** table be handled?
109547 ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);
109558 ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
109559 ** Given that pParent is the parent table for foreign key constraint pFKey,
109570 ** array is the index of the child table column that is mapped by the FK
109571 ** constraint to the parent table column stored in the left-most column
109573 ** child table column that corresponds to the second left-most column of
109584 ** foreign key definition, and the parent table does not have a
109588 ** foreign key definition, and the PRIMARY KEY of the parent table
109590 ** the child table.
109598 Table *pParent, /* Parent table of FK constraint pFKey */
109600 Index **ppIdx, /* OUT: Unique index on parent table */
109614 ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
109625 ** mapped to the primary key of table pParent, or
109648 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
109659 ** map to an explicit list of columns in table pParent. Check if this
109707 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
109708 ** on the child table of pFKey, this function is invoked twice for each row
109713 ** row in the parent table that corresponds to the row being inserted into
109714 ** or deleted from the child table. If the parent row can be found, no
109716 ** found in the parent table:
109734 Table *pTab, /* Parent table of FK pFKey */
109737 int *aiCol, /* Map from parent key columns to child table columns */
109738 int regData, /* Address of array containing child table row */
109751 ** Check if any of the key columns in the child table row are NULL. If
109753 ** search for a matching row in the parent table. */
109766 ** column of the parent table (table pTab). */
109779 /* If the parent table is the same as the child table, and we are about
109805 /* If the parent table is the same as the child table, and we are about
109846 ** one row into the table, raise a constraint immediately instead of
109866 ** to column iCol of table pTab.
109874 Table *pTab, /* The table whose content is at r[regBase]... */
109875 int regBase, /* Contents of table pTab */
109901 ** Return an Expr object that refers to column iCol of table pTab which
109906 Table *pTab, /* The table whose column is desired */
109907 int iCursor, /* The open cursor on the table */
109921 ** from the parent table of foreign key constraint pFKey and, if pFKey is
109922 ** deferred, when a row is inserted into the same table. When generating
109931 ** table that correspond to the parent table row being deleted or inserted.
109953 SrcList *pSrc, /* The child table to be scanned */
109954 Table *pTab, /* The parent table */
109957 int *aiCol, /* Map from pIdx cols to child table cols */
109988 Expr *pLeft; /* Value from parent table row */
109989 Expr *pRight; /* Column ref to child table */
109991 i16 iCol; /* Index of column in child table */
109992 const char *zCol; /* Name of column in child table */
110004 /* If the child table is the same as the parent table, then add terms
110017 Expr *pLeft; /* Value from parent table row */
110018 Expr *pRight; /* Column ref to child table */
110066 ** FKey.pNextTo) holding all children of table pTab. For example,
110069 ** CREATE TABLE t1(a PRIMARY KEY);
110070 ** CREATE TABLE t2(b REFERENCES t1(a);
110072 ** Calling this function with table "t1" as an argument returns a pointer
110073 ** to the FKey structure representing the foreign key constraint on table
110076 ** table).
110078 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){
110102 ** This function is called to generate code that runs when table pTab is
110105 ** table pTab.
110109 ** (a) The table is the parent table of a FK constraint, or
110110 ** (b) The table is the child table of a deferred FK constraint and it is
110115 ** the table from the database. Triggers are disabled while running this
110118 SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
110126 /* Search for a deferred foreign key constraint for which this table
110127 ** is the child table. If one cannot be found, return without
110169 ** for which pTab is the child table. An UPDATE statement against pTab
110170 ** is currently being processed. For each column of the table that is
110180 Table *pTab, /* Table being updated */
110196 ** for which pTab is the parent table. An UPDATE statement against pTab
110197 ** is currently being processed. For each column of the table that is
110207 Table *pTab,
110250 ** table pTab to generate VDBE code to perform foreign key constraint
110264 ** the original record is deleted from the table using the calling convention
110270 Table *pTab, /* Row is being deleted from this table */
110292 ** child table (the table that the foreign key definition is part of). */
110294 Table *pTo; /* Parent table of foreign key pFKey */
110309 /* Find the parent table of this foreign key. Also find a unique index
110310 ** on the parent key columns in the parent table. If either of these
110322 /* If isIgnoreErrors is true, then a table is being dropped. In this
110323 ** case SQLite runs a "DELETE FROM xxx" on the table being dropped
110325 ** If the parent table of an FK constraint on the current table is
110327 ** FK counter for each row of the current table with non-NULL keys.
110355 ** values read from the parent table are NULL. */
110365 /* Take a shared-cache advisory read-lock on the parent table. Allocate
110367 ** in the parent table. */
110372 /* A row is being removed from the child table. Search for the parent.
110378 /* A row is being added to the child table. If a parent row cannot
110392 /* Loop through all the foreign key constraints that refer to this table.
110407 /* Inserting a single row into a parent table cannot cause (or fix)
110418 /* Create a SrcList structure containing the child table. We need the
110419 ** child table as a SrcList for sqlite3WhereBegin() */
110448 ** child table to fire. In these cases the fk constraint counters
110466 ** row contained in table pTab.
110470 Table *pTab /* Table being modified */
110496 ** row contained in table pTab. If the operation is a DELETE, then
110498 ** to an array of size N, where N is the number of columns in table pTab.
110502 ** UPDATE statement modifies the rowid fields of the table.
110510 table, or
110518 Table *pTab, /* Table being modified */
110526 ** table in question is either the child or parent table for any
110556 ** compiled on table pTab, which is the parent table of foreign-key pFKey.
110567 ** For example, if pFKey is the foreign key and pTab is table "p" in
110570 ** CREATE TABLE p(pk PRIMARY KEY);
110571 ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);
110585 Table *pTab, /* Table being updated or deleted from */
110601 char const *zFrom; /* Name of child table */
110604 int *aiCol = 0; /* child table cols -> parent key cols */
110618 Token tFromCol; /* Name of column in child table */
110619 Token tToCol; /* Name of column in parent table */
110620 int iFromCol; /* Idx of column in child table */
110634 ** parent table are used for the comparison. */
110767 Table *pTab, /* Table being updated or deleted from */
110774 ** refer to table pTab. If there is an action associated with the FK
110794 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
110795 ** hash table.
110797 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
110805 /* Remove the FK from the fkeyHash hash table. */
110857 ** (1) acquire a lock for table pTab then
110860 ** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index
110861 ** for that table that is actually opened.
110865 int iCur, /* The cursor number of the table */
110867 Table *pTab, /* The table to be opened */
110892 ** the table, according to the affinity of the column:
110920 Table *pTab = pIdx->pTable;
110948 ** Compute the affinity string for table pTab, if it has not already been
110967 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
110997 ** Return non-zero if the table pTab in database iDb or any of its indices
111000 ** run without using a temporary table for the results of the SELECT.
111002 static int readsTable(Parse *p, int iDb, Table *pTab){
111038 ** Locate or create an AutoincInfo structure associated with table pTab
111041 ** table. (Also return zero when doing a VACUUM since we do not want to
111044 ** There is at most one AutoincInfo structure per table even if the
111045 ** same table is autoincremented multiple times due to inserts within
111047 ** first use of table pTab. On 2nd and subsequent uses, the original
111052 ** (1) Register to hold the name of the pTab table.
111062 Table *pTab /* The table we are writing to */
111080 pToplevel->nMem++; /* Register to hold name of table */
111096 Db *pDb; /* Database only autoinc table */
111158 ** table (either directly or through triggers) needs to call this
111212 Table *pDest, /* The table we are inserting into */
111221 ** insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...
111222 ** insert into TABLE (IDLIST) select
111223 ** insert into TABLE (IDLIST) default values
111225 ** The IDLIST following the table name is always optional. If omitted,
111226 ** then a list of all (non-hidden) columns for the table is substituted.
111241 ** open write cursor to <table> and its indices
111243 ** write the resulting record into <table>
111248 ** INSERT INTO <table> SELECT ...
111251 ** in other words if the SELECT pulls all columns from a single table
111259 ** open a write cursor to <table>
111261 ** transfer all records in <table2> over to <table>
111263 ** foreach index on <table>
111264 ** open a write cursor on the <table> index
111271 ** and the SELECT clause does not read from <table> at any time.
111283 ** B: open write cursor to <table> and its indices
111285 ** insert the select result into <table> from R..R+n
111290 ** values from a SELECT but the data is being inserted into a table
111292 ** we have to use an intermediate table to store the results of
111304 ** B: open temp table
111306 ** insert row from R..R+n into temp table
111308 ** M: open write cursor to <table> and its indices
111309 ** rewind temp table
111310 ** C: loop over rows of intermediate table
111311 ** transfer values form intermediate table into <table>
111317 SrcList *pTabList, /* Name of table into which we are inserting */
111323 Table *pTab; /* The table to insert into. aka TABLE */
111326 Index *pIdx; /* For looping over indices of the table */
111328 int nHidden = 0; /* Number of hidden columns if TABLE is virtual */
111337 int iDb; /* Index of database holding TABLE */
111338 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
111340 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
111341 u8 bIdListInOrder; /* True if IDLIST is in table order */
111376 /* Locate the table into which we will be inserting new information.
111391 /* Figure out if we have any triggers and if the table being
111415 /* Cannot insert into a read-only table.
111445 /* If this is an AUTOINCREMENT table, look up the sequence number in the
111446 ** sqlite_sequence table and store it in memory cell regAutoinc.
111462 ** all elements of the IDLIST really are columns of the table and
111465 ** If the table has an INTEGER PRIMARY KEY column and that column
111469 ** is appears in the original table. (The index of the INTEGER
111470 ** PRIMARY KEY in the original table is pTab->iPKey.)
111493 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
111529 ** should be written into a temporary table (template 4). Set to
111531 ** the destination table (template 3).
111533 ** A temp table must be used if the table being updated is also one
111535 ** temp table in the case of row triggers.
111543 ** and add it to a transient table srcTab. The code generated
111546 ** B: open temp table
111548 ** insert row from R..R+n into temp table
111553 int regTempRowid; /* Register to hold temp table ROWID */
111588 /* If there is no IDLIST term but the table has an integer primary
111590 ** column index in the original table definition.
111597 ** of columns to be inserted into the table.
111604 "table %S has %d columns but %d values were supplied",
111620 /* If this is not a view, open the table and and all indices */
111641 ** rewind temp table, if empty goto D
111642 ** C: loop over rows of intermediate table
111643 ** transfer values form intermediate table into <table>
111654 ** insert the select result into <table> from R..R+n
111691 /* Cannot have triggers on a virtual table. If it were possible,
111718 ** If this is a real table, attempt conversions as required by the
111719 ** table column affinities.
111842 ** constraints or (b) there are no triggers and this table is not a
111843 ** parent table in a foreign key constraint. It is safe to set the
111884 /* Update the sqlite_sequence table by storing the content of the
111979 ** on table pTab.
111985 ** case of a WITHOUT ROWID table. The second register in the range will
111986 ** contain the content of the first table column. The third register will
111987 ** contain the content of the second table column. And so forth.
111995 ** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)
111997 ** the iDataCur content table is guaranteed to be unchanged by the UPDATE.
112002 ** that the table is a WITHOUT ROWID table and has no rowid. On an INSERT,
112013 ** table and all applicable indices (that is to say, all indices for which
112014 ** aRegIdx[] is not zero). iDataCur is the cursor for the main table when
112015 ** inserting or updating a rowid table, or the cursor for the PRIMARY KEY
112016 ** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor
112062 Table *pTab, /* The table being inserted or updated */
112064 int iDataCur, /* Canonical data cursor (main table or PK index) */
112094 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
112099 ** pPk index or 1 for a rowid table. In other words, nPkField is the
112100 ** number of fields in the true primary key of the table. */
112196 ** exist in the table.
112232 /* Check to see if the new rowid already exists in the table. Skip
112250 /* If there are DELETE triggers on this table and the
112252 ** remove the conflicting row from the table. This will fire
112253 ** the triggers and remove both the table and index b-tree entries.
112256 ** flag is not set, but the table has one or more indexes, call
112258 ** only. The table
112270 ** table.
112317 ** WITHOUT ROWID table.
112371 ** of a WITHOUT ROWID table and there has been no change the
112393 ** (2) The table is a WITHOUT ROWID table
112394 ** (3) There are no secondary indexes on the table
112442 ** table, only conflict if the new PRIMARY KEY values are actually
112515 ** to be the number of columns in table pTab that must not be NULL-trimmed.
112519 SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){
112545 Table *pTab, /* the table into which we are inserting */
112558 int regRec; /* Register holding assembled record for the table */
112569 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
112625 ** Allocate cursors for the pTab table and all its indices and generate
112629 ** the table itself, but the PRIMARY KEY index in the case of a WITHOUT
112630 ** ROWID table) is returned in *piDataCur. The first index cursor is
112637 ** For a rowid table, *piDataCur will be exactly one less than *piIdxCur.
112638 ** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range
112642 ** If pTab is a virtual table, then this routine is a no-op and the
112647 Table *pTab, /* Table to be opened */
112650 int iBase, /* Use this for the table cursor, if there is one */
112651 u8 *aToOpen, /* If not NULL: boolean for each table and index */
112773 ** Sometimes the xfer optimization will only work if the destination table
112776 ** does a test to see if the destination table is empty and jumps over the
112786 Table *pDest, /* The table we are inserting into */
112793 Table *pSrc; /* The table in the FROM clause of SELECT */
112812 ** attached to it. Proceeding may generate a false "no such table: xxx"
112821 return 0; /* tab1 must not be a virtual table */
112872 return 0; /* FROM clause does not contain a real table */
112875 return 0; /* tab1 and tab2 may not be the same table */
112882 return 0; /* tab2 must not be a virtual table */
112901 return 0; /* Neither table may have __hidden__ columns */
112942 /* Disallow the transfer optimization if the destination table constains
112959 ** table (tab1) is initially empty.
112980 ** only if the destination table is initially empty. Unless the
112983 ** table is always empty.
113052 ** that the destination table is empty. If all indexed columns use
114667 ** object. This ensures that the aPragmaName[] table is arranged in
114779 /* 36 */ "table",
114785 /* 42 */ "table", /* Used by: foreign_key_check */
115710 /* Locate the pragma in the lookup table */
116366 ** PRAGMA table_info(<table>)
116368 ** Return a single row for each column of the named table. The columns of
116379 Table *pTab;
116421 Table *pTab = sqliteHashData(i);
116443 Table *pTab;
116478 Table *pTab;
116566 Table *pTab;
116600 Table *pTab; /* Child table contain "REFERENCES" keyword */
116601 Table *pParent; /* Parent table that child points to */
116602 Index *pIdx; /* Index in the parent table */
116605 HashElem *k; /* Loop counter: Next table in schema */
116625 pTab = (Table*)sqliteHashData(k);
116785 int mxIdx = 0; /* Maximum number of indexes for any table */
116800 Table *pTab = sqliteHashData(x); /* Current table */
116810 Table *pTab = sqliteHashData(x);
116837 Table *pTab = sqliteHashData(x);
116849 /* reg[7] counts the number of entries in the table.
116914 /* Verify that an index entry exists for the current table row */
117091 ** creating or dropping a table or index). The schema version is used by
117252 ** In the current implementation, a table is analyzed if only if all of
117258 ** more indexes of the table at some point during the lifetime of
117261 ** (3) One or more indexes of the table are currently unanalyzed OR
117262 ** the number of rows in the table has increased by 25 times or more
117270 int iTabCur; /* Cursor for a table whose size needs checking */
117273 Table *pTab; /* A table in the schema */
117274 Index *pIdx; /* An index of the table */
117291 pTab = (Table*)sqliteHashData(k);
117293 /* If table pTab has not been used in a way that would benefit from
117298 /* Reanalyze if the table is 25 times larger than the last analysis */
117472 ** Implementation of an eponymous virtual table that runs a pragma.
117492 ** Pragma virtual table module xConnect method.
117512 sqlite3StrAccumAppendAll(&acc, "CREATE TABLE x");
117555 ** Pragma virtual table module xDisconnect method.
117563 /* Figure out the best index to use to search a pragma virtual table.
117606 /* Create a new cursor for the pragma virtual table */
117617 /* Clear all content from pragma virtual table cursor. */
117628 /* Close a pragma virtual table cursor */
117636 /* Advance the pragma virtual table cursor to the next row */
117653 ** Pragma virtual table module xFilter method.
117703 ** Pragma virtual table module xEof method.
117729 ** Pragma virtual table module xRowid method.
117737 /* The pragma virtual table object */
117740 0, /* xCreate - create a table */
117741 pragmaVtabConnect, /* xConnect - connect to an existing table */
117743 pragmaVtabDisconnect, /* xDisconnect - Disconnect from a table */
117744 0, /* xDestroy - Drop a table */
117758 0, /* xRename - rename the table */
117766 ** then register an eponymous virtual table for that pragma and return
117767 ** a pointer to the Module object for the new virtual table.
117831 ** argv[1] = root page number for table or index. 0 for trigger or view.
117854 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
117857 ** structures that describe the table, index, or view.
117891 ** constraint for a CREATE TABLE. The index should have already
117892 ** been created when we processed the CREATE TABLE. All we have
117898 /* This can occur if there exists an index on a TEMP table which
117900 ** the permanent table is hidden by the TEMP table, we can also
117901 ** safely ignore the index on the permanent table.
117941 ** table name will be inserted automatically by the parser so we can just
117943 ** the schema table as read-only. */
117946 azArg[2] = "CREATE TABLE x(type text,name text,tbl_name text,"
118047 ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN
118107 ** purpose of this is to allow access to the sqlite_master table
118249 ** expr.c is trying to resolve a reference to a transient table (i.e. one
118485 ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error
118727 int tabTnct; /* Ephemeral table used for DISTINCT processing */
118941 ** Return the index of a column in a table. Return -1 if the column
118942 ** is not contained in the table.
118944 static int columnIndex(Table *pTab, const char *zCol){
118954 ** table that has a column named zCol.
118956 ** When found, set *piTab and *piCol to the table index and column index
118992 ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the
118999 int iLeft, /* Index of first table to join in pSrc */
119000 int iColLeft, /* Index of column in first table */
119001 int iRight, /* Index of second table in pSrc */
119002 int iColRight, /* Index of column in second table */
119042 ** expression depends on table iRightJoinTable even if that table is not
119078 ** The left most table is the first entry in Select.pSrc. The right-most
119079 ** table is the last entry. The join operator is held in the entry to
119089 struct SrcList_item *pLeft; /* Left table being joined */
119090 struct SrcList_item *pRight; /* Right table being joined */
119096 Table *pRightTab = pRight->pTab;
119112 char *zName; /* Name of column in the right table */
119113 int iLeft; /* Matching left table */
119114 int iLeftCol; /* Matching column in the left table */
119152 int iLeft; /* Table on the left with matching column name */
119231 KeyInfo *pKI; /* Original KeyInfo on the sorter table */
119357 int srcTab, /* Pull data from this table if non-negative */
119404 ** there are columns in the table on the left. The error will be caught
119512 ** table iParm.
119526 ** the temporary table iParm.
119552 ** output table as well. */
119576 ** item into the set table with bogus data.
119870 int bUseTmp /* True if a temp table was used */
120028 ** original CREATE TABLE statement if the expression is a column. The
120074 /* The expression is a column. Locate the table the column is being
120075 ** extracted from in NameContext.pSrcList. This table may be real
120076 ** database table or a subquery.
120078 Table *pTab = 0; /* Table structure column is extracted from */
120099 ** CREATE TABLE t1(col INTEGER);
120115 /* The "table" is actually a sub-select or a view in the FROM clause
120132 /* A real table or a CTE table */
120253 ** refers directly to a table column, then the
120254 ** result column name is just the table column
120257 ** full=ON, short=ANY: If the result refers directly to a table column,
120258 ** then the result column name with the table name
120259 ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan.
120267 Table *pTab;
120271 int fullName; /* TABLE.COLUMN if no AS clause and is a direct table ref */
120272 int srcName; /* COLUMN or TABLE.COLUMN if no AS clause and is direct */
120334 ** column names for a table that would hold the expression list.
120366 Hash ht; /* Hash table of column names */
120397 Table *pTab = pColExpr->pTab;
120460 Table *pTab, /* Add column type information to this table */
120504 ** Given a SELECT statement, generate a Table structure that describes
120507 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
120508 Table *pTab;
120519 pTab = sqlite3DbMallocZero(db, sizeof(Table) );
120697 ** <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)
120702 ** There is exactly one reference to the recursive-table in the FROM clause
120706 ** into a Queue table. Rows are extracted from the Queue table one by
120708 ** extracted row (now in the iCurrent table) becomes the content of the
120709 ** recursive-table for a recursive-query run. The output of the recursive-query
120710 ** is added back into the Queue table. Then another row is extracted from Queue
120711 ** and the iteration continues until the Queue table is empty.
120714 ** inserted into the Queue table. The iDistinct table keeps a copy of all rows
120718 ** If the query has an ORDER BY, then entries in the Queue table are kept in
120720 ** an ORDER BY, the Queue table is just a FIFO.
120735 int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
120740 int iCurrent = 0; /* The Current table */
120741 int regCurrent; /* Register holding Current table */
120742 int iQueue; /* The Queue table */
120745 SelectDest destQueue; /* SelectDest targetting the Queue table */
120766 /* Locate the cursor number of the Current table */
120775 ** the Distinct table must be exactly one greater than Queue in order
120797 VdbeComment((v, "Queue table"));
120836 ** the value for the recursive-table. Store the results in the Queue.
120978 /* Create the destination temporary table if necessary
121057 int unionTab; /* Cursor number of the temporary table holding result */
121068 /* We can reuse a temporary table generated by a SELECT to our
121074 /* We will need to create our own temporary table to hold the
121125 /* Convert the data in the temporary table into whatever form
121168 /* Code the SELECTs to our left into temporary table "tab1".
121177 /* Code the current SELECT into temporary table "tab2"
121824 ** All references to columns in table iTable are to be replaced by corresponding
121829 int iTable; /* Replace references to this table */
121830 int iNewTable; /* New table number */
121841 ** a column in table number iTable with a copy of the iColumn-th
121849 ** changes to pExpr so that it refers directly to the source table
121956 ** subquery first and store the results in a temporary table, then
121957 ** run the outer query on that temporary table. This requires two
121958 ** passes over the data. Furthermore, because the temporary table
121969 ** exist on the table t1, a complete scan of the data might be
121988 ** table and
122002 ** table sqlite_once that consists of a single row containing a
122107 int iParent; /* VDBE cursor number of the pSub result set temp table */
122108 int iNewParent = -1;/* Replacement table for iParent */
122172 ** the LEFT JOIN table should be all-NULL.
122313 /* Delete the transient table structure associated with the
122324 /* Defer deleting the Table object associated with the
122332 Table *pTabToDel = pSubitem->pTab;
122516 ** (2) The inner query is the recursive part of a common table expression.
122635 ** where table is a database table, not a sub-select or view. If the query
122636 ** does match this pattern, then a pointer to the Table object representing
122639 static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
122640 Table *pTab;
122672 Table *pTab = pFrom->pTab;
122759 ** Check to see if the FROM clause term pFrom has table-valued function
122761 ** non-zero, since pFrom is not allowed to be a table-valued function.
122774 ** WITH contexts, from inner to outermost. If the table identified by
122775 ** FROM clause element pItem is really a common-table-expression (CTE)
122776 ** then return a pointer to the CTE definition for that table. Otherwise
122851 Table *pTab;
122869 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
122903 pParse, "multiple references to recursive table: %s", pCte->zName
122928 sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
122960 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
122996 ** for instances of the "*" operator or the TABLE.* operator.
122997 ** If found, expand each "*" to be every column in every table
122998 ** and TABLE.* to be every column in TABLE.
123031 /* Look up every table named in the FROM clause of the select. If
123032 ** an entry of the FROM clause is a subquery instead of a table or view,
123033 ** then create a transient table structure to describe the subquery.
123036 Table *pTab;
123051 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
123066 /* An ordinary table or view name in the FROM clause */
123108 ** all columns in all tables. And for every TABLE.* insert the names
123109 ** of all columns in TABLE. The parser inserted a special expression
123157 /* This expression is a "*" or a "TABLE.*" and needs to be
123159 int tableSeen = 0; /* Set to 1 when TABLE matches */
123160 char *zTName = 0; /* text of name of TABLE */
123167 Table *pTab = pFrom->pTab;
123213 ** table to the right of the join */
123218 ** using clause from the table on the right. */
123260 sqlite3ErrorMsg(pParse, "no such table: %s", zTName);
123349 ** information to the Table structure that represents the result set
123352 ** The Table structure that represents the result set was constructed
123369 Table *pTab = pFrom->pTab;
123386 ** the Table structures of all FROM-clause subqueries in a
123408 ** * Ephemeral Table objects are created for all FROM-clause subqueries.
123410 ** * Wildcards "*" and "TABLE.*" in result sets are expanded.
123580 Table *pTab, /* Table being queried */
123585 char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s%s%s",
123727 if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */
123880 Table *pTab = pItem->pTab;
123911 ** are output, rather than every row of the table.
123975 ** The fake column name is an empty string. It is possible for a table to
123977 ** distinguish between an unreferenced table and an actual reference to the
124068 /* Generate a subroutine that will fill an ephemeral table with
124150 ** The second form is preferred as a single index (or temp-table) may be
124152 ** written the query must use a temp-table for at least one of the ORDER
124153 ** BY and DISTINCT, and an index or separate temp-table for the other.
124194 /* If the output is destined for a temporary table, open that table.
124427 ** we do not have to sort. The OP_OpenEphemeral table will be
124485 /* If the index or temporary table used by the GROUP BY sort
124487 ** clause, cancel the ephemeral table open coded earlier.
124601 Table *pTab;
124603 /* If isSimpleCount() returns a pointer to a Table structure, then
124608 ** where the Table structure returned represents table <tbl>.
124611 ** OP_Count instruction is executed either on the intkey table that
124612 ** contains the data for table <tbl> or on one of its indexes. It
124737 /************** Begin file table.c *******************************************/
124775 ** This routine is called once for each row in the result table. Its job
124850 ** Instead, the entire table should be passed to sqlite3_free_table() when
124856 char ***pazResult, /* Write the result table here */
124937 /************** End of table.c ***********************************************/
124973 ** Given table pTab, return a list of all the triggers attached to
124974 ** the table. The list is connected by Trigger.pNext pointers.
124986 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
125000 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
125026 SrcList *pTableName,/* The name of the table/view the trigger applies to */
125032 Table *pTab; /* Table that the trigger fires off of */
125075 /* If the trigger name was unqualified, and the table is a temp table,
125077 ** If sqlite3SrcListLookup() returns 0, indicating the table does not
125086 /* Ensure the table name matches database name and that the table exists */
125095 /* The table does not exist. */
125098 ** Normally, whenever a table is dropped, all associated triggers are
125099 ** dropped too. But if a TEMP trigger is created on a non-TEMP table
125100 ** and the table is dropped by a different database connection, the
125103 ** "orphaned trigger" - a trigger whose associated table is missing.
125131 /* Do not create a trigger on a system table */
125133 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
125147 " trigger on table: %S", pTableName, 0);
125181 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
125243 /* Make an entry in the sqlite_master table */
125252 pTrig->table, z);
125267 Table *pTab;
125268 pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);
125353 Token *pTableName, /* Name of the table into which we insert */
125384 Token *pTableName, /* Name of the table to be updated */
125411 Token *pTableName, /* The table from which rows are deleted */
125434 sqlite3DbFree(db, pTrigger->table);
125487 ** Return a pointer to the Table structure for the table that a trigger
125490 static Table *tableOfTrigger(Trigger *pTrigger){
125491 return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table);
125499 Table *pTable;
125547 Table *pTab = tableOfTrigger(pTrigger);
125576 ** Return a list of all triggers on table pTab if there exists at least
125578 ** performed on the table, and, if that operation is an UPDATE, if at
125583 Table *pTab, /* The table the contains the triggers */
125766 Table *pTab, /* The table pTrigger is attached to */
125881 Table *pTab, /* The table trigger pTrigger is attached to */
125908 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
125915 Table *pTab, /* The table to code triggers from */
125946 ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
125956 ** in the trigger program. If N is the number of columns in table pTab
125986 Trigger *pTrigger, /* List of triggers on table pTab */
125990 Table *pTab, /* The table to code triggers from */
126003 /* Sanity checking: The schema for the trigger and for the table are
126004 ** always defined. The trigger must be in the same schema as the table
126022 ** Triggers may access values stored in the old.* or new.* pseudo-table.
126029 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
126031 ** are more than 32 columns in the table, and at least one of the columns
126038 ** applies to the old.* table. If 1, the new.* table.
126048 Trigger *pTrigger, /* List of triggers on table pTab */
126052 Table *pTab, /* The table to code triggers from */
126099 SrcList *pSrc, /* The virtual table to be modified */
126100 Table *pTab, /* The virtual table */
126111 ** i-th column of table pTab. This routine sets the P4 parameter of the
126115 ** column definition. This was either supplied by the user when the table
126116 ** was created, or added later to the table definition by an ALTER TABLE
126117 ** command. If the latter, then the row-records in the table btree on disk
126123 ** Column definitions created by an ALTER TABLE command may only have
126126 ** when the ALTER TABLE is executed and one of the literal values written
126127 ** into the sqlite_master table.)
126139 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
126169 SrcList *pTabList, /* The table in which we should change things */
126177 Table *pTab; /* The table to be updated */
126190 ** an expression for the i-th column of the table.
126193 u8 chngPk; /* PRIMARY KEY changed in a WITHOUT ROWID table */
126194 u8 chngRowid; /* Rowid changed in a normal table */
126199 int iDb; /* Database containing the table being updated */
126212 int iEph = 0; /* Ephemeral table holding all primary key values */
126224 int regNew = 0; /* Content of the NEW.* table in triggers */
126225 int regOld = 0; /* Content of OLD.* table in triggers */
126236 /* Locate the table which we want to update.
126242 /* Figure out if we have any triggers and if the table being
126276 /* Allocate a cursors for the main database table and for all indices.
126362 ** So reset the colUsed mask. Unless this is a virtual table. In that
126364 ** table implementation makes all columns available).
126370 /* There is one entry in the aRegIdx[] array for each index on the table
126433 ** an ephemeral table.
126487 ** things might disturb a cursor being used to scan through the table
126526 ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
126527 ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table
126630 ** table and index records, and as the values for any new.* references
126800 /* Update the sqlite_sequence table by storing the content of the
126843 ** Generate code for an UPDATE of a virtual table.
126846 ** "onepass" strategy. Onepass is only used if the virtual table
126849 ** The default strategy is to create an ephemeral table that contains
126856 ** Then loop through the contents of this ephemeral table executing a
126857 ** VUpdate for each row. When finished, drop the ephemeral table.
126859 ** The "onepass" strategy does not use an ephemeral table. Instead, it
126865 SrcList *pSrc, /* The virtual table to be modified */
126866 Table *pTab, /* The virtual table */
126874 int ephemTab; /* Table holding the result of the SELECT */
126882 int regRowid; /* Register for ephem table rowid */
126883 int iCsr = pSrc->a[0].iCursor; /* Cursor used for virtual table scan */
126889 ** create and open the ephemeral table in which the records created from
126899 /* Start scanning the virtual table */
126942 ** the ephemeral table. */
126955 /* End the virtual table scan */
126958 /* Begin scannning through the ephemeral table. */
126961 /* Extract arguments from the current row of the ephemeral table and
126972 /* End of the ephemeral table scan. Or, if using the onepass strategy,
127234 " WHERE type='table'AND name<>'sqlite_sequence'"
127255 "WHERE type='table'AND coalesce(rootpage,1)>0",
127265 ** from the SQLITE_MASTER table.
127271 " OR(type='table'AND rootpage=0)",
127377 ** Before a virtual table xCreate() or xConnect() method is invoked, the
127384 VTable *pVTable; /* The virtual table being constructed */
127385 Table *pTab; /* The Table object to which the virtual table belongs */
127391 ** Construct and install a Module object for a virtual table. When this
127455 ** External API function used to create a new virtual-table module.
127470 ** External API function used to create a new virtual-table module.
127486 ** Lock the virtual table so that it cannot be disconnected.
127490 ** If a disconnect is attempted while a virtual table is locked,
127499 ** pTab is a pointer to a Table structure representing a virtual-table.
127501 ** this virtual-table, if one has been created, or NULL otherwise.
127503 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
127511 ** Decrement the ref-count on a virtual table object. When the ref-count
127532 ** Table p is a virtual table. This function moves all elements in the
127538 static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
127544 ** that contains table p is held by the caller. See header comments
127571 ** Table *p is a virtual table. This function removes the VTable object
127572 ** for table *p associated with database connection db from the linked
127578 SQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){
127597 ** Disconnect all the virtual table
127609 ** associated with the database the virtual table is stored in is held
127610 ** or, if the virtual table is stored in a non-sharable database, then
127634 ** Clear any and all virtual-table information from the Table record.
127635 ** This routine is called, for example, just before deleting the Table
127638 ** Since it is a virtual-table, the Table structure contains a pointer
127647 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
127661 ** string will be freed automatically when the table is
127664 static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
127679 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
127685 Token *pName1, /* Name of new table, or database name */
127686 Token *pName2, /* Name of new table or NULL */
127687 Token *pModuleName, /* Name of the module for the virtual table */
127688 int ifNotExists /* No error if the table already exists */
127690 int iDb; /* The database the table is being created in */
127691 Table *pTable; /* The new virtual table */
127715 /* Creating a virtual table invokes the authorization callback twice.
127717 ** sqlite_master table, has already been made by sqlite3StartTable().
127718 ** The second call, to obtain permission to create the table, is made now.
127730 ** virtual table currently under construction in pParse->pTable.
127742 ** The parser calls this routine after the CREATE VIRTUAL TABLE statement
127746 Table *pTab = pParse->pNewTable; /* The table being constructed */
127754 /* If the CREATE VIRTUAL TABLE statement is being entered for the
127755 ** first time (in other words if the virtual table is actually being
127758 ** in the sqlite_master table.
127767 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
127771 zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
127774 ** SQLITE_MASTER table. We just need to update that slot with all
127778 ** entry in the sqlite_master table tht was created for this vtab
127784 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
127797 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
127805 /* If we are rereading the sqlite_master table create the in-memory
127806 ** record of the table. The xConnect() method is not called until
127807 ** the first time the virtual table is used in an SQL statement. This
127809 ** the required virtual table implementations are registered. */
127811 Table *pOld;
127827 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
127837 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
127851 ** Invoke a virtual table constructor (either xCreate or xConnect). The
127857 Table *pTab,
127872 /* Check that the virtual-table is not already being initialized */
127899 /* Invoke the virtual table constructor */
127936 ** columns of the table to see if any of them contain the token "hidden".
127980 ** of the virtual table pTab. If an error occurs, an error code is returned
127983 ** This call is a no-op if table pTab is not a virtual table.
127985 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
127996 /* Locate the required virtual table module */
128018 ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.
128039 ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should
128050 ** of the virtual table named zTab in database iDb.
128058 Table *pTab;
128065 /* Locate the required virtual table module */
128093 ** This function is used to set the schema of a virtual table. It is only
128095 ** virtual table module.
128100 Table *pTab;
128130 Table *pNew = sParse.pNewTable;
128177 ** of the virtual table named zTab in database iDb. This occurs
128178 ** when a DROP TABLE is mentioned.
128180 ** This call is a no-op if zTab is not a virtual table.
128184 Table *pTab;
128198 assert( xDestroy!=0 ); /* Checked before the virtual table is created */
128285 ** If the virtual table pVtab supports the transaction interface
128340 ** as the second argument to the virtual table method invoked.
128344 ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
128347 ** If any virtual table method returns an error code other than SQLITE_OK,
128349 ** function immediately. If all calls to virtual table methods are successful,
128388 ** If pExpr is a column in a virtual table, then let the virtual
128389 ** table implementation have an opportunity to overload the function.
128391 ** This routine is used to allow virtual table implementations to
128404 Table *pTab;
128415 /* Check to see the left operand is a column in a virtual table */
128427 /* Call the xFindFunction method on the virtual table implementation
128459 ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
128464 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
128467 Table **apVtabLock;
128484 ** Check to see if virtual table module pMod can be have an eponymous
128485 ** virtual table instance. If it can, create one if one does not already
128486 ** exist. Return non-zero if the eponymous virtual table instance exists
128489 ** An eponymous virtual table instance is one that is named after its
128490 ** module, and more importantly, does not require a CREATE VIRTUAL TABLE
128491 ** statement in order to come into existance. Eponymous virtual table
128494 ** Any virtual table module for which xConnect and xCreate are the same
128495 ** method can have an eponymous virtual table instance.
128499 Table *pTab;
128505 pTab = sqlite3DbMallocZero(db, sizeof(Table));
128531 ** Erase the eponymous virtual table instance associated with
128532 ** virtual table module pMod, if it exists.
128535 Table *pTab = pMod->pEpoTab;
128537 /* Mark the table as Ephemeral prior to deleting it, so that the
128548 ** table update operation currently in progress.
128569 ** of the virtual table being implemented.
128691 int iTabCur; /* The VDBE cursor used to access the table */
128740 Bitmask maskSelf; /* Bitmask identifying table iTab */
128744 u8 iTab; /* Position in FROM clause of table for this loop */
129095 SrcList *pTabList, /* Table list this loop refers to */
129176 #define WHERE_IDX_ONLY 0x00000040 /* Use index only - omit table */
129242 ** Argument pLevel describes a strategy for scanning table pTab. This
129243 ** function appends text to pStr that describes the subset of table
129284 ** is added to the output to describe the table scan strategy in pLevel.
129291 SrcList *pTabList, /* Table list this loop refers to */
129326 sqlite3XPrintf(&str, " TABLE %s", pItem->zName);
129373 sqlite3XPrintf(&str, " VIRTUAL TABLE INDEX %d:%s",
129563 ** CREATE TABLE t1(a,b,c,d,e,f);
129783 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
129815 ** CREATE TABLE t1(a TEXT PRIMARY KEY, b);
129971 int iTabCur; /* Cursor for the main table */
129973 Index *pIdx; /* The index used to access the table */
129979 ** the table CCurHint.iTabCur, verify that the same column can be
129996 ** should be included in the cursor-hint for a table that is on the rhs
130030 ** that accesses any table other than the one identified by
130039 ** Also, if the node is a TK_COLUMN that does access the table idenified
130042 ** an access of the index rather than the original table.
130111 ** JOIN for which the current table is not the rhs are omitted
130114 ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
130182 ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
130194 ** containing one entry for each column of the table cursor iCur is open
130195 ** on. For each table column, if the column is the i'th column of the
130216 Table *pTab = pIdx->pTable;
130263 ** mapping from an expression on table columns into a column in an index
130268 int iTabCur; /* The cursor of the corresponding table */
130299 int iTabCur, /* Cursor of the table that is being indexed */
130335 int iCur; /* The VDBE cursor for the table */
130382 /* If this is the right table of a LEFT OUTER JOIN, allocate and
130383 ** initialize a memory cell that records if this table matches any
130384 ** row of the left table of the join.
130392 /* Compute a safe address to jump to if we discover that the table for
130409 /* Case 1: The table is a virtual-table. Use the VFilter and VNext
130881 /* Seek the table cursor, if required */
130883 /* pIdx is a covering index. No need to access the main table. */
130939 ** CREATE TABLE t1(a,b,c,d);
130973 ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then
130979 SrcList *pOrTab; /* Shortened table list or OR-clause generation */
130992 Table *pTab = pTabItem->pTab;
131002 /* Set up a new SrcList in pOrTab containing the table being scanned
131098 /* Loop through table entries that match term pOrTerm. */
131135 /* Check if the temp table already contains this key. If so,
131138 ** insert the key into the temp table and proceed with processing
131143 ** the temp table. And if iSet is -1, assume that there is no
131144 ** need to insert the key into the temp table, as it will never
131170 ** contained one or more AND term from a notReady table. The
131171 ** terms from the notReady table could not be tested and will
131200 /* Finish the loop through table entries that match term pOrTerm. */
131222 ** scan of the entire table.
131351 ** at least one row of the right table has matched the left table.
131610 ** be an ordinary column (not a virtual table column) with TEXT affinity.
131694 ** Expression Virtual Table Operator
131706 ** In every case, "column" must be a column of a virtual table. If there
131710 ** appropriate virtual table operator. The return value is 1 or 2 if there
131712 ** of virtual table in forms (5) or (7) then return 2.
131896 ** a single table T (as shown in example B above) then create a new virtual
131918 ** If all subterms are indexable by a single table T, then set
131921 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
131924 ** "T.C <op> <expr>" where C is any column of table T and
132075 ** something other than == on a column in the single table. The 1-bit
132077 ** "table.column=expr" for some single table. The one bit that is set
132078 ** will correspond to the common table. We still need to check to make
132085 ** Note that terms of the form "table.column1=table.column2" (the
132086 ** same table on both sizes of the ==) cannot be optimized.
132091 int iCursor = -1; /* Table cursor common to all terms */
132094 /* Search for a table and column that appears on one side or the
132095 ** other of the == operator in every subterm. That table and column
132097 ** such table and column. Set okToChngToIN if an appropriate table
132127 /* No candidate table+column was found. This can only occur
132136 /* We have found a candidate table and column. Check to see if that
132137 ** table and column is common to every term in the OR clause */
132267 ** number of the table that is indexed and aiCurCol[1] to the column number
132278 int *aiCurCol, /* Write the referenced table cursor and column here */
132302 int *aiCurCol, /* Write the referenced table cursor & column here */
132321 if( mPrereq==0 ) return 0; /* No table references */
132322 if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
132351 WhereMaskSet *pMaskSet; /* Set of table index masks */
132394 ** on left table of a LEFT JOIN. Ticket #3015 */
132868 ** For table-valued-functions, transform the function arguments into
132872 ** a HIDDEN column in the table.
132879 Table *pTab;
132922 ** generating the code that loops through a table looking for applicable
133016 ** table and iaCur[1] gets the cursor used by an auxiliary index.
133101 ** There is one cursor per table in the FROM clause. The number of
133203 ** for terms of the form "X <op> <expr>" where X is column iColumn of table
133205 ** must be one of the indexes of table iCur.
133256 ** where X is a reference to the iColumn of table iCur or of index pIdx
133260 ** If pIdx!=0 then it must be one of the indexes of table iCur.
133262 ** rather than the iColumn-th column of table iCur.
133275 ** the form "X <op> Y" where Y is a column in another table if no terms of
133316 int iBase, /* Cursor for table associated with pIdx */
133371 Table *pTab;
133376 /* If there is more than one table or sub-select in the FROM clause of
133383 /* If any of the expressions is an IPK column on table iBase, then return
133392 /* Loop through all indices on the table, checking each to see if it makes
133434 ** opcodes into OP_Copy when the table is being accessed via co-routine
133435 ** instead of via table lookup.
133445 int iTabCur, /* OP_Column/OP_Rowid references to this table */
133528 struct SrcList_item *pSrc, /* Table we are trying to access */
133572 Table *pTable; /* The table being indexed */
133607 || pLoop->prereq!=0 ); /* table of a LEFT JOIN */
133643 ** original table never needs to be accessed. Automatic indices must
133645 ** original table changes and the index and table cannot both be used
133786 ** to this virtual table */
133802 ** virtual table then allocate space for the aOrderBy part of
133903 ** The table object reference passed as the second argument to this function
133904 ** must represent a virtual table. This function invokes the xBestIndex()
133905 ** method of the virtual table with the sqlite3_index_info object that
133916 static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
133942 "table %s: xBestIndex returned an invalid plan", pTab->zName);
134665 Table *pTab = pItem->pTab;
135107 ** table statistics.
135116 ** of rows in the table. In other words, assume that x==EXPR will filter
135125 LogEst nRow /* Number of rows in the entire table */
135211 ** the right column of the right source table. And that the sort
135278 LogEst rSize; /* Number of rows in the table */
135279 LogEst rLogSize; /* Logarithm of table size */
135332 ** right table of a LEFT JOIN. Only constraints in the ON clause are
135496 ** visiting the rows in the main table. */
135614 ** the table is used by an index. Only the first 63 columns are considered.
135654 ** Add all WhereLoop objects for a single table of the join where the table
135655 ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be
135656 ** a b-tree table, not a virtual table.
135661 ** For a full scan, assuming the table (or index) contains nRow rows:
135663 ** cost = nRow * 3.0 // full-table scan
135668 ** estimated average size of the index and table records.
135687 ** of a full table scan.
135691 Bitmask mPrereq /* Extra prerequesites for using this table */
135704 LogEst rSize; /* number of rows in the table */
135705 LogEst rLogSize; /* Logarithm of the number of rows in the table */
135707 Table *pTab; /* Table being queried */
135727 Index *pFirst; /* First of real indices on the table */
135740 /* The real indices of the table are only considered if the
135756 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
135758 && !pSrc->fg.isRecursive /* Not a recursive common table expression. */
135773 ** the table being indexed and where X is 7 (LogEst=28) for normal
135785 /* TUNING: Each index lookup yields 20 rows in the table. This
135828 /* Full table scan */
135830 /* TUNING: Cost of full table scan is (N*3.0). */
135863 ** index and table rows. */
135867 ** doing table lookups. The cost will be 3x the number of
135870 ** table lookup. */
135881 ** the expected number of table lookups accordingly */
135922 ** be used by the virtual table identified by pBuilder->pNew->iTab. This
135934 ** virtual table in question. These are added to the plans prerequisites
135988 /* Invoke the virtual table xBestIndex() method */
136024 /* A virtual table that is constrained by an IN clause may not
136091 ** Add all WhereLoop objects for a table of the join identified by
136092 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
136096 ** entries that occur before the virtual table in the FROM clause and are
136099 ** virtual table and are separated from it by at least one LEFT or
136109 ** table. So any terms for which all prerequisites are satisfied by
136112 ** virtual table, so any terms for which the prerequisites overlap with
136182 ** in the set of terms that apply to the current virtual table. */
136343 ** the planner may elect to "OR" together a full-table scan and an
136449 int iColumn; /* A column number within table iCur */
136478 ** The rowid for a table is always UNIQUE and NOT NULL so whenever the
136511 /* Mark off any ORDER BY term X that is a column in the table of
136602 /* Get the column number in the table (iColumn) and sort order
137173 ** Most queries use only a single table (they are not joins) and have
137191 Table *pTab;
137297 ** The basic idea is to do a nested loop, one loop for each table in
137299 ** same as a SELECT with only a single table in the FROM clause.) For
137320 ** There are Btree cursors associated with each table. t1 uses cursor
137333 ** refer to those indices, a complete table scan can be avoided and the
137435 ** only generate code for the first table in pTabList and assume that
137499 ** a table T, then X-1 is the bitmask for all other tables to the left of T.
137631 ** For a table to not affect the result, the following must be true:
137634 ** 2) The table must be the RHS of a LEFT JOIN.
137636 ** must contain a constraint that limits the scan of the table to
137638 ** 4) The table must not be referenced by any part of the query apart
137643 ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
137644 ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
137645 ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
137647 ** then table t2 can be omitted from the following:
137719 ** * the table is not a virtual table, and
137752 Table *pTab; /* Table to open */
137753 int iDb; /* Index of database containing table/index */
137815 ** WITHOUT ROWID table. No need for a separate index */
138034 Table *pTab = pTabItem->pTab;
138038 /* For a co-routine, change all OP_Column references to the table of
138050 ** from the index instead of from the table where possible. In some cases
138051 ** this optimization prevents the table from ever being read, which can
138055 ** sqlite3WhereEnd will have created code that references the table
138057 ** that reference the table and converts them into opcodes that
138412 ** slots in the yy_action[] table.
138417 ** The action table is constructed as a single large table named yy_action[].
138433 ** yy_action[] A single table containing all actions.
138434 ** yy_lookahead[] A table containing the lookahead for each entry in
138914 /* The next table maps tokens (terminal symbols) into fallback tokens.
138946 0, /* TABLE => nothing */
139097 ** are required. The following table supplies these names */
139115 /* 16 */ "TABLE",
139371 /* 13 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
139432 /* 74 */ "cmd ::= DROP TABLE ifexists fullname",
139616 /* 258 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
139617 /* 259 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
139621 /* 263 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
140163 /* The following table contains information about every rule that
140183 { 154, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
140244 { 149, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
140428 { 149, -6 }, /* (258) cmd ::= ALTER TABLE fullname RENAME TO nm */
140429 { 149, -7 }, /* (259) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
140433 { 245, -8 }, /* (263) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
140618 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
140661 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
140823 case 74: /* cmd ::= DROP TABLE ifexists fullname */
141585 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
141668 case 258: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
141673 case 259: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
141691 case 263: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
141789 /* There are no SHIFTREDUCE actions on nonterminals because the table
142082 ** using a lookup table, whereas a switch() directly on c uses a binary search.
142083 ** The lookup table is much faster. To maximize speed, and to ensure that
142084 ** a lookup table is used, all of the classes need to be small integers and
142213 ** might be implemented more directly using a hand-written hash table.
142384 testcase( i==19 ); /* TABLE */
142952 /* If the pParse->declareVtab flag is set, do not delete any table
142954 ** will take responsibility for freeing the Table structure.
142968 Table *p = pParse->pZombieTab;
143946 ** full table scans in the query optimizer. */
144384 Table *pTab = (Table *)sqliteHashData(p);
144441 ** SQL statements below, as the v-table implementation may be storing
144492 HashElem *i; /* Hash table iterator */
144612 ** but are "saved" in case the table pages are moved around.
144781 /* SQLITE_LOCKED */ "database table is locked",
144832 int count /* Number of times table has been busy */
145014 ** to the hash table.
145164 ** Declare that a function has been overloaded by a virtual table.
145578 ** following table describes the relationship between these two values
146769 ** Return meta information about a specific column of a database table.
146775 const char *zTableName, /* Table name */
146785 Table *pTab = 0;
146809 /* Locate the table in question */
146818 /* Query for existance of table only */
146844 ** 2. The table is not a view and the column name identified an
146876 zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName,
147258 ** table should connect.
147261 ** run a single CREATE TABLE statement to construct the imposter table in
148034 ** the %_segments table in sorted order. This means that when the end
148098 ** The segment directory in table %_segdir stores meta-information for
148138 ** leaf nodes are written in to the %_segments table in order, this
148266 ** When an fts3 table is created, it passes any arguments passed to
148267 ** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the
148271 ** be used for the fts3 table (customized by the tokenizer clause arguments).
148293 ** TABLE statement that created the fts3 table. For example, if
148409 ** This is the header file for the generic hash-table implementation
148411 ** hash table implementation for the full-text indexing module.
148421 /* A complete hash table is an instance of the following structure.
148432 int count; /* Number of entries in this table */
148434 int htsize; /* Number of buckets in the hash table */
148435 struct _fts3ht { /* the hash table */
148441 /* Each element in the hash table is an instance of the following
148448 Fts3HashElem *next, *prev; /* Next and previous elements in the table */
148454 ** There are 2 different modes of operation for a hash table:
148487 ** Macros for looping over all elements of a hash table. The idiom is
148505 ** Number of entries in a hash table
148535 ** Fts3Table.pendingTerms hash table. Normally, the hash table is
148539 ** segment is created and the hash table cleared immediately.
148685 const char *zName; /* virtual table name */
148686 int nColumn; /* number of named columns in virtual table */
148696 ** statements is run and reset within a single virtual table API call.
148706 u8 bHasStat; /* True if %_stat table exists (2==unknown) */
148707 u8 bHasDocsize; /* True if %_docsize table exists */
148711 char *zSegmentsTbl; /* Name of %_segments table */
148712 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
148720 ** A single FTS4 table may have multiple full-text indexes. For each index
148726 ** pending data structures, including hash table overhead, but not including
148734 Fts3Hash hPending; /* Pending terms table for this index */
148744 ** methods of the virtual table are called at appropriate times. These
148760 ** When the core wants to read from the virtual table, it creates a
148761 ** virtual table cursor (an instance of the following structure) using
148782 sqlite3_int64 nDoc; /* Documents in table */
148799 ** CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);
148808 #define FTS3_FULLSCAN_SEARCH 0 /* Linear scan of %_content table */
148809 #define FTS3_DOCID_SEARCH 1 /* Lookup by rowid on %_content table */
148882 ** where nCol is the number of columns in the queried FTS table. The array
149285 ** The xDisconnect() virtual table method.
149351 ** The xDestroy() virtual table method.
149361 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
149363 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
149364 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
149365 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
149366 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
149377 ** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
149396 /* Create a list of user columns for the virtual table */
149402 /* Create the whole "CREATE TABLE" statement to pass to SQLite */
149404 "CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)",
149420 ** Create the %_stat table if it does not already exist.
149424 "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'"
149433 ** required by the FTS3 table passed as the only argument. This is done
149437 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
149447 char *zContentCols; /* Columns of %_content table */
149449 /* Create a list of user columns for the content table */
149460 /* Create the content table */
149462 "CREATE TABLE %Q.'%q_content'(%s)",
149470 "CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);",
149474 "CREATE TABLE %Q.'%q_segdir'("
149487 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
149626 ** table has the three user-defined columns "a", "b", and "c", the following
149678 ** of columns in the %_content table (one for the docid plus one for each
149683 ** bracket. For example, if zFunc is "zip" and the FTS3 table has three
149751 ** representing the indexes maintained by the current FTS table. FTS tables
149754 ** (if any) specified as part of the CREATE VIRTUAL TABLE statement.
149769 struct Fts3Index **apIndex /* OUT: Array of indexes for this table */
149811 ** This function is called when initializing an FTS4 table that uses the
149813 ** of the new FTS4 table.
149817 ** a table of that name. If found, the output variables are populated
149820 ** *pnCol: Set to the number of columns table xxx has,
149826 ** the name of the corresponding column in table xxx. The array
149831 ** If the table cannot be found, an error code is returned and the output
149838 const char *zTbl, /* Name of content table */
149862 int nCol; /* Number of table columns */
149901 ** methods of the FTS3 virtual table.
149907 ** argv[2] -> table name
149913 void *pAux, /* Hash table containing tokenizers */
149926 int nCol = 0; /* Number of columns in the FTS table */
149929 int nName; /* Bytes required to hold table name */
149932 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
149935 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
149938 int bNoDocsize = 0; /* True to omit %_docsize table */
149974 ** + Figures out the number of columns the FTSX table will have, and
150098 ** TABLE statement, use all columns from the content table.
150248 /* Check to see if a legacy fts3 table has been "upgraded" by the
150249 ** addition of a %_stat table so that it can use incremental merge.
150260 /* Declare the table schema to SQLite. */
150287 ** The xConnect() and xCreate() methods for the virtual table. All the
150292 void *pAux, /* Pointer to tokenizer hash table */
150302 void *pAux, /* Pointer to tokenizer hash table */
150343 ** 3. Linear scan of %_content table.
150355 /* By default use a full table scan. This is an expensive option,
150522 ** on the xClose method of the virtual table interface.
150539 ** (or the equivalent for a content=xxx table) and set pCsr->pStmt to
150563 ** of the %_content table that contains the last match. Return
150579 ** table is missing a row that is present in the full-text index.
150635 ** table, then there are always 20 bytes of zeroed padding following the
150732 Fts3Table *p, /* Virtual table handle */
150750 char *zBlob = 0; /* Blob read from %_segments table */
151556 Fts3Table *p, /* FTS table handle */
151653 Fts3Table *p, /* FTS3 table handle */
151669 ** made by an fts4aux module, not an FTS table. In this case calling
151727 Fts3Table *p, /* FTS3 table handle */
151759 Fts3Table *p, /* FTS virtual table handle */
151784 Fts3Cursor *pCsr, /* Virtual table cursor handle */
151850 Fts3Table *p, /* Virtual table handle */
151922 ** Advance the cursor to the next row in the %_content table that
151924 ** the next row that matches. For a full-table scan, this will be
151925 ** simply the next row in the %_content table. For a docid lookup,
151978 ** This is the xFilter interface for the virtual table. See
151979 ** the virtual table xFilter method documentation for additional
151982 ** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against
151983 ** the %_content table.
151986 ** in the %_content table.
152068 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
152069 ** statement loops through all rows of the %_content table. For a
152103 ** This is the xEof method of the virtual table. SQLite calls this
152118 ** exposes %_content.docid as the rowid for the virtual table. The
152134 ** (iCol == p->nColumn) -> Magic column with the same name as the table.
152152 /* The special 'table-name' column */
152174 /* A user column. Or, if this is a full-table scan, possibly the
152193 sqlite3_vtab *pVtab, /* Virtual table handle */
152203 ** hash-table to the database.
152222 ** of blocks from the segments table. But this is not considered overhead
152252 ** If it is currently unknown whether or not the FTS table has an %_stat
152253 ** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat
152289 ** the pending-terms hash-table have already been flushed into the database
152305 ** hash-table. Any changes made to the database are reverted by SQLite.
152454 ** where 't' is the name of an FTS3 table.
152462 Fts3Table *p; /* Virtual table handle */
152508 ** virtual table.
152511 sqlite3_vtab *pVtab, /* Virtual table handle */
152544 ** Implementation of FTS3 xRename method. Rename an fts3 table.
152547 sqlite3_vtab *pVtab, /* Virtual table handle */
152548 const char *zName /* New name of table */
152554 /* At this point it must be known if the %_stat table exists or not.
152558 /* As it happens, the pending terms table is always empty here. This is
152559 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
152561 ** flushes the pending terms table. But leave the (no-op) call to
152571 "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';",
152578 "ALTER TABLE %Q.'%q_docsize' RENAME TO '%q_docsize';",
152584 "ALTER TABLE %Q.'%q_stat' RENAME TO '%q_stat';",
152589 "ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';",
152593 "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';",
152602 ** Flush the contents of the pending-terms table to disk.
152634 ** Discard the contents of the pending terms table.
152675 ** allocated for the tokenizer hash table.
152737 /* Allocate and initialize the hash-table used to store tokenizers. */
152745 /* Load the built-in tokenizers into the hash table */
152767 /* Create the virtual table wrapper around the hash-table and overload
152794 /* An error has occurred. Delete the hash table and return the error code. */
152861 Fts3Table *pTab, /* FTS Table pointer */
153286 Fts3Table *pTab, /* Virtual table handle */
153579 ** of data that will fit on a single leaf page of an intkey table in
153588 ** data from the %_stat table to calculate it.
153590 ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3
153591 ** varints, where nCol is the number of columns in the FTS3 table.
153593 ** the table. The following nCol varints contain the total amount of
153594 ** data stored in all rows of each column of the table, from left
153661 ** table actually contains the same data as the index. To prevent this from
154260 ** 2. After scanning the current FTS table row for the deferred tokens,
154509 ** the FTS table (considering all rows), and
154511 ** 2. For each column, the number of rows in the table for which the
154523 ** values are set to the number of documents in the table. In other
154525 ** column of each row of the table.
154741 ** Initialize API pointer table, if required.
154806 ** Schema of the terms table.
154809 "CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)"
154825 char const *zFts3; /* Name of fts3 table */
154830 Fts3auxTable *p; /* Virtual table object to return */
154836 ** CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);
154837 ** CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);
155408 const char **azCol; /* Array of column names for fts3 table */
156275 char **azCol, /* Array of column names for fts3 table */
156326 ** of each column in the target fts3 table, in order from left to right.
156329 ** The iDefaultCol parameter should be passed the index of the table column
156333 ** match any table column.
156338 char **azCol, /* Array of column names for fts3 table */
156424 ** Function to query the hash-table of tokenizers (see README.tokenizers).
156513 ** of a column of the fts3 table that the query expression may refer to.
156637 ** We've modified it slightly to serve as a standalone hash table
156673 /* Turn bulk memory into a hash table object by initializing the
156676 ** "pNew" is a pointer to the hash table that is to be initialized.
156679 ** determines what kind of key the hash table will use. "copyKey" is
156680 ** true if the hash table should make its own private copy of keys and
156694 /* Remove all entries from a hash table. Reclaim all memory.
156695 ** Call this routine to delete a hash table or to reset a hash table
156699 Fts3HashElem *elem; /* For looping over all elements of the table */
156788 /* Link an element into the hash table
156791 Fts3Hash *pH, /* The complete hash table */
156814 /* Resize the hash table so that it cantains "new_size" buckets.
156815 ** "new_size" must be a power of 2. The hash table might fail
156821 struct _fts3ht *new_ht; /* The new hash table */
156841 ** hash table that matches the given key. The hash for this key has
156869 /* Remove a single entry from the hash table given a pointer to that
156923 ** Attempt to locate an element of the hash table pH with a key
156934 /* Insert an element into the hash table pH. The key is pKey,nKey
156944 ** the new data is returned and the hash table is unchanged.
156947 ** element corresponding to "key" is removed from the hash table.
156950 Fts3Hash *pH, /* The hash table to insert into */
156956 int h; /* the hash of the key modulo hash table size */
157721 ** hash table. This function may be called as follows:
157732 ** the string <key-name> must already exist in the has table. Otherwise,
157737 ** to string <key-name> (after the hash-table is updated, if applicable).
157839 Fts3Hash *pHash, /* Tokenizer hash table */
158133 ** the hash table pointed to by argument pHash. The hash table must
158141 ** defined at compilation time, a temporary virtual table (see header
158146 ** of both the scalar and, if created, the virtual table.
158266 ** else we need to reindex. One solution would be a meta-table to
158444 ** This file contains code for the "fts3tokenize" virtual table module.
158445 ** An fts3tokenize virtual table is created as follows:
158447 ** CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(
158451 ** The table created has the following schema:
158453 ** CREATE TABLE <tbl>(input, token, start, end, position)
158459 ** The virtual table module tokenizes this <string>, using the FTS3
158460 ** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE
158482 ** Virtual table structure.
158491 ** Virtual table cursor structure.
158575 ** Schema of the tokenizer table.
158577 #define FTS3_TOK_SCHEMA "CREATE TABLE x(input, token, start, end, position)"
158586 ** argv[2]: table name
158591 void *pHash, /* Hash table of tokenizers */
158815 /* CREATE TABLE x(input, token, start, end, position) */
158933 ** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()
159098 ** or the pending-terms table being flushed), leaves are written into the
159176 Fts3Table *p, /* Virtual table handle */
159244 ** Read a single entry from the %_segdir table. The entry from absolute
159318 Fts3Table *pTab, /* FTS3 table handle */
159343 Fts3Table *pTab, /* Fts3 table handle */
159364 Fts3Table *pTab, /* Fts3 table handle */
159381 Fts3Table *p, /* The FTS3 table */
159399 ** shared-cache table-lock on the %_segdir table. This is required before
159400 ** writing data to the fts3 table. If this lock is not acquired first, then
159436 ** in the %_segdir table on disk. This function is used to convert three
159438 ** can be used to query the %_segdir table.
159451 Fts3Table *p, /* FTS3 table handle */
159467 ** all rows in the %_segdir table, from oldest to newest. If successful,
159472 ** each FTS3 table.
159474 ** The statement returns the following columns from the %_segdir table:
159483 Fts3Table *p, /* FTS3 table */
159639 Fts3Hash *pHash, /* Pending terms hash table to add entry to */
159668 ** pending-terms hash-table. The docid used is that currently stored in
159674 Fts3Table *p, /* Table into which text will be inserted */
159698 ** zText==0. In this case, add zero token entries to the hash table and
159752 Fts3Table *p, /* Full-text table handle */
159800 ** pendingTerms hash table.
159836 ** apVal[p->nColumn+2] Hidden column with same name as table
159841 Fts3Table *p, /* Full-text table */
159861 ** table. The SQL for this statement is:
159866 ** defined columns in the FTS3 table, plus one for the docid field.
159911 ** Remove all data from the FTS3 table. Clear the hash table containing
159917 /* Discard the contents of the pending-terms hash table. */
159951 Fts3Table *p, /* The FTS table to delete from */
159997 ** This function allocates a new level iLevel index in the segdir table.
160056 ** The %_segments table is declared as follows:
160058 ** CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)
160060 ** This function reads data from a single row of the %_segments table. The
160064 ** identified table row is. Whether or not paBlob is NULL, *pnBlob is set
160067 ** If an error occurs, or the table does not contain the specified row,
160078 ** on the database file for longer than necessary). Thus, any virtual table
160083 Fts3Table *p, /* FTS3 table handle */
160356 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
160532 ** the contents of the pending-terms hash table to the database.
160556 ** through each term in the pending-terms table. Or, if isPrefixIter is
160558 ** the pending terms hash table contains the terms "sqlite", "mysql" and
160571 Fts3Table *p, /* Virtual table handle */
160788 ** Insert a record into the %_segments table.
160791 Fts3Table *p, /* Virtual table handle */
160808 ** Find the largest relative level number in the table. If successful, set
160829 ** Insert a record into the %_segdir table.
160832 Fts3Table *p, /* Virtual table handle */
160888 Fts3Table *p, /* Virtual table handle */
161025 Fts3Table *p, /* Virtual table handle */
161094 Fts3Table *p, /* Virtual table handle */
161123 /* Find the next free blockid in the %_segments table */
161236 Fts3Table *p, /* Virtual table handle */
161259 /* The entire tree fits on the root node. Write it to the segdir table. */
161284 ** pRowid would mean the FTS3 table were empty.
161286 table is empty except for
161294 /* If using the content=xxx option, assume the table is never empty */
161313 ** Segment levels are stored in the 'level' column of the %_segdir table.
161377 ** Delete all entries in the %_segments table associated with the segment
161379 ** of the %_segdir table.
161382 Fts3Table *p, /* FTS table handle */
161414 Fts3Table *p, /* Virtual table handle */
161533 Fts3Table *p, /* Virtual table handle */
161601 Fts3Table *p, /* Virtual table handle */
161633 Fts3Table *p, /* Virtual table handle */
161642 Fts3Table *p, /* Virtual table handle */
161717 Fts3Table *p, /* Virtual table handle */
161955 Fts3Table *p, /* FTS table handle */
161969 /* Loop through all entries in the %_segdir table corresponding to
162228 Fts3Table *p, /* Table into which to insert */
162256 ** Record 0 of the %_stat table contains a blob consisting of N varints,
162257 ** where N is the number of user defined columns in the fts3 table plus
162261 ** Varint 0: Total number of rows in the table.
162264 ** the column for all rows of the table.
162267 ** columns of all rows of the table.
162272 Fts3Table *p, /* Table being updated */
162381 ** The entire FTS index is discarded and rebuilt. If the table is one
162383 ** the current contents of the xxx table. Otherwise, it is rebuilt based
162384 ** on the contents of the %_content table.
162397 /* Compose and prepare an SQL statement to loop through the content table */
162467 Fts3Table *p, /* FTS3 table handle */
162686 Fts3Table *p, /* Fts3 table handle */
162837 Fts3Table *p, /* Fts3 table handle */
162922 Fts3Table *p, /* FTS3 table handle */
162949 ** table. However, this is not permitted in this case. The problem is that
162950 ** space has already been reserved in the %_segments table, and so the
162951 ** start_block and end_block fields of the %_segdir table must be populated.
162960 ** table until we are sure it is needed.
163026 ** Query to see if the entry in the %_segments table with blockid iEnd is
163034 ** is, then a NULL entry has been inserted into the %_segments table
163069 Fts3Table *p, /* Fts3 table handle */
163106 /* Check for the zero-length marker in the %_segments table */
163201 Fts3Table *p, /* FTS Table handle */
163223 ** In the %_segdir table, a segment is defined by the values in three
163246 Fts3Table *p, /* Fts3 table handle */
163282 /* Insert the marker in the %_segments table to make sure nobody tries
163300 ** Remove an entry from the %_segdir table. This involves running the
163311 Fts3Table *p, /* FTS3 table handle */
163335 Fts3Table *p, /* FTS3 table handle */
163458 ** table, and modifying existing entries in both the %_segments and %_segdir
163465 Fts3Table *p, /* FTS3 table handle */
163550 Fts3Table *p, /* FTS table handle */
163617 ** exists, is stored in the rowid==1 row of the %_stat table.
163620 ** table and return SQLITE_OK. Otherwise, if an error occurs, return an
163714 Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
163731 /* Search the %_segdir table for the absolute level with the smallest
163748 /* If the hint read from the %_stat table is not empty, check if the
163772 ** nMin segments and no hint in the %_stat table. No work to do.
163843 /* Write the hint values into the %_stat table for the next incr-merger */
163872 ** INSERT INTO table(table) VALUES('merge=A,B');
163879 Fts3Table *p, /* FTS3 table handle */
163916 ** INSERT INTO table(table) VALUES('automerge=X');
163922 Fts3Table *p, /* FTS3 table handle */
163980 Fts3Table *p, /* FTS3 table handle */
164046 ** content table. If no error occurs and the contents do match, set *pbOk
164076 /* This block calculates the checksum according to the %_content table */
164162 ** 2. By scanning and tokenizing the content table.
164168 Fts3Table *p /* FTS3 table handle */
164254 ** table, not for all rows.
164259 int i; /* Used to iterate through table columns */
164340 Fts3Cursor *pCsr, /* Fts3 table cursor */
164364 ** present in the FTS3 table. If it is, delete it and adjust the contents
164374 int bFound = 0; /* True if *pRowid really is in the table */
164378 int isEmpty = 0; /* Deleting *pRowid leaves the table empty */
164382 /* Deleting this row means the whole table is empty. In this case
164384 ** data in the pendingTerms hash table. */
164405 ** tables. The schema of the virtual table being:
164407 ** CREATE TABLE <table name>(
164409 ** <table name> HIDDEN,
164430 /* At this point it must be known if the %_stat table exists or not.
164496 ** the %_content table. If we hit the duplicate rowid constraint (or any
164558 ** Flush any data in the pending-terms hash table to disk. If successful,
164672 int nCol; /* Number of columns in table */
165228 Fts3Table *pTab, /* FTS3 table snippet comes from */
165506 ** rows of the table. Y is the number of rows for which column iCol contains
165813 sqlite3_int64 nDoc; /* Number of rows in table */
166028 /* Loop through all columns of the table being considered for snippets.
166030 ** columns of the FTS3 table. Otherwise, only column iCol is considered.
166088 int iCol; /* Column of table to populate aTerm for */
166159 /* Loop through the table columns, appending offset information to
166266 Fts3Cursor *pCsr, /* FTS3 table cursor */
166405 ** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE
166406 ** statement has specified that the tokenizer for this table shall consider
167067 ** algorithms packaged as an SQLite virtual table module.
167074 ** The data structure for a single virtual r-tree table is stored in three
167076 ** in the table name is replaced with the user-supplied name of the r-tree
167077 ** table.
167079 ** CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
167080 ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
167081 ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
167084 ** table. For each node that is not the root node of the r-tree, there is
167085 ** an entry in the %_parent table associating the node with its parent.
167086 ** And for each row of data in the table, there is an entry in the %_rowid
167087 ** table that maps from the entries rowid to the id of the node that it
167090 ** The root node of an r-tree always exists, even if the r-tree table is
167092 ** table must be the same size as the root node. The content of each node
167151 /* Size of hash table Rtree.aHash. This hash table is not expected to
167157 /* The xBestIndex method of this virtual table requires an estimate of
167158 ** the number of rows in the virtual table to calculate the costs of
167160 ** sqlite_stat1 table (with RTREE_MIN_ROWEST as a hard-coded minimum).
167168 ** An rtree virtual-table object.
167173 int iNodeSize; /* Size in bytes of each node in the node table */
167180 char *zDb; /* Name of database containing r-tree table */
167181 char *zName; /* Name of r-tree table */
167183 i64 nRowEst; /* Estimated number of rows in this table */
167211 RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */
167219 ** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will
167594 ** in the Rtree.aHash table.
167601 ** Search the node hash table for node iNode. If found, return a pointer
167611 ** Add node pNode to the node hash table.
167622 ** Remove node pNode from the node hash table.
167677 /* Check if the requested node is already in the hash table. If so,
167929 ** the virtual table module xCreate() and xConnect() methods.
167936 ** Rtree virtual table module xCreate method.
167949 ** Rtree virtual table module xConnect method.
167991 ** Rtree virtual table module xDisconnect method.
167999 ** Rtree virtual table module xDestroy method.
168005 "DROP TABLE '%q'.'%q_node';"
168006 "DROP TABLE '%q'.'%q_rowid';"
168007 "DROP TABLE '%q'.'%q_parent';",
168027 ** Rtree virtual table module xOpen method.
168066 ** Rtree virtual table module xClose method.
168083 ** Rtree virtual table module xEof method.
168608 ** Rtree virtual table module xNext method.
168622 ** Rtree virtual table module xRowid method.
168636 ** Rtree virtual table module xColumn method.
168668 ** return SQLITE_OK. If there is no such record in the table, set
168726 ** Rtree virtual table module xFilter method.
168830 ** Rtree virtual table module xBestIndex method. There are three
168831 ** table scan strategies to choose from (in order from most to
168837 ** 2 See below R-tree query or full-table scan.
169072 Rtree *pRtree, /* Rtree table */
169132 Rtree *pRtree, /* Rtree table */
169158 ** Write mapping (iRowid->iNode) to the <rtree>_rowid table.
169168 ** Write mapping (iNode->iPar) to the <rtree>_parent table.
169655 /* Remove the node from the in-memory hash table and link it into
169937 /* Delete the corresponding entry in the <rtree>_rowid table. */
170018 ** A constraint has failed while inserting a row into an rtree table.
170084 /* Constraint handling. A write operation on an r-tree table may return
170101 ** with "column" that are interpreted as table constraints.
170102 ** Example: CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));
170132 ** the table. If so, the constraint has failed. */
170156 ** record to delete from the r-tree table. The following block does
170224 "ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";"
170225 "ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";"
170226 "ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";"
170244 ** DROP TABLE command - which fortunately always opens a savepoint - cannot
170250 ** DROP TABLE <tablename>; -- Would fail with SQLITE_LOCKED
170265 ** of the number of rows in the virtual table. If possible, this is based
170309 rtreeCreate, /* xCreate - create a table */
170310 rtreeConnect, /* xConnect - connect to an existing table */
170312 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
170313 rtreeDestroy, /* xDestroy - Drop a table */
170327 rtreeRename, /* xRename - rename the table */
170344 /* Write the xxx_node table */
170348 /* Read and write the xxx_rowid table */
170353 /* Read and write the xxx_parent table */
170365 "CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);"
170366 "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);"
170367 "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,"
170430 ** determine the node-size used by the rtree table being created or connected
170435 ** table already exists. In this case the node-size is determined by inspecting
170484 ** methods of the r-tree virtual table.
170488 ** argv[2] -> table name
170494 int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */
170495 sqlite3_vtab **ppVtab, /* OUT: New virtual table */
170507 "Wrong number of columns for an rtree table", /* 1 */
170508 "Too few columns for an rtree table", /* 2 */
170509 "Too many columns for an rtree table" /* 3 */
170544 ** the r-tree table schema.
170550 char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
170673 const char *zDb; /* Database containing rtree table */
170674 const char *zTab; /* Name of rtree table */
170675 int bInt; /* True for rtree_i32 table */
170679 int nLeaf; /* Number of leaf cells in table */
170680 int nNonLeaf; /* Number of non-leaf cells in table */
170759 ** Otherwise, the contents of rtree table node iNode are loaded from
170803 ** (if bLeaf==1) table contains a specified entry. The schemas of the
170806 ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
170807 ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
170838 rtreeCheckAppendMsg(pCheck, "Mapping (%lld -> %lld) missing from %s table",
170845 "Found (%lld -> %lld) in %s table, expected (%lld -> %lld)",
170970 ** %_rowid or %_parent table is exactly nExpect. If not, it adds
170984 rtreeCheckAppendMsg(pCheck, "Wrong number of entries in %%%s table"
171001 const char *zTab, /* Name of rtree table to check */
171005 sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */
171022 /* Find number of dimensions in the rtree table. */
171062 ** rtreecheck(<rtree-table>);
171063 ** rtreecheck(<database>, <rtree-table>);
171066 ** table. The integrity-check verifies the following:
171068 ** 1. For each cell in the r-tree structure (%_node table), that:
171076 ** table corresponding to the cell's rowid value that
171080 ** %_parent table mapping from the cell's child node to the
171083 ** 2. That there are the same number of entries in the %_rowid table
171085 ** is a leaf cell that corresponds to each entry in the %_rowid table.
171087 ** 3. That there are the same number of entries in the %_parent table
171090 ** %_parent table.
171125 ** virtual table module "rtree" and the debugging/analysis scalar
171380 ** This lookup table is used to help decode the first byte of
172133 ** sqlite3rbu.h. Essentially, for each table xyz in the target database
172134 ** that the user wishes to write to, a corresponding data_xyz table is
172136 ** update, insert or delete from the target table.
172191 ** collected in the rbu_xyz table. And for both UPDATEs and DELETEs all
172272 ** KEY fields may not be updated or deleted. If the table being written
172289 ** containing an RBU update is an "RBU database". For each table in the
172290 ** target database to be updated, the RBU database should contain a table
172292 ** target table, and one more - "rbu_control". The data_% table should
172298 ** CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c UNIQUE);
172302 ** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);
172304 ** The order of the columns in the data_% table does not matter.
172306 ** Instead of a regular table, the RBU database may also contain virtual
172318 ** If the target database table is a virtual table or a table that has no
172319 ** PRIMARY KEY declaration, the data_% table must also contain a column
172325 ** CREATE VIRTUAL TABLE x1 USING fts3(a, b);
172326 ** CREATE TABLE x1(a, b)
172330 ** CREATE TABLE data_x1(a, b, rbu_rowid, rbu_control);
172333 ** target table must be present in the input table. For virtual tables,
172335 ** the input table, or not otherwise. For example, to write to an fts4
172336 ** table with a hidden languageid column such as:
172338 ** CREATE VIRTUAL TABLE ft1 USING fts4(a, b, languageid='langid');
172340 ** Either of the following input table schemas may be used:
172342 ** CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control);
172343 ** CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control);
172346 ** update, the corresponding data_% table should contain a single record
172351 ** If the target database table has an INTEGER PRIMARY KEY, it is not
172356 ** update, the corresponding data_% table should contain a single record
172359 ** corresponding columns of the data_% table. The values stored in the
172363 ** update, the corresponding data_% table should contain a single record
172366 ** stored in the corresponding columns of the data_% table row, as should
172369 ** there are columns in the target database table, and must consist entirely
172384 ** target table with the value stored in the corresponding data_% column, the
172386 ** the target table column. rbu_delta() is invoked with two arguments - the
172387 ** original value currently stored in the target table column and the
172388 ** value specified in the data_xxx table.
172399 ** ota_control string, the contents of the data_xxx table column is assumed
172402 ** the existing value within the target database table must be of type BLOB.
172406 ** If the target database table is a virtual table or a table with no PRIMARY
172419 ** table in "rowid" order is roughly the same as reading them sorted by
172420 ** the PRIMARY KEY of the corresponding target database table. In other
172421 ** words, rows should be sorted using the destination table PRIMARY KEY
172432 ** 2) Registers any required virtual table modules with the database
172596 ** register the required virtual table implementations.
172600 ** the rbu update db handle to any required virtual table
172692 ** database contains an "rbu_count" table. The rbu_count table, if it
172695 ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;
172697 ** There must be one row in the table for each source (data_xxx) table within
172699 ** table. The 'cnt' column should contain the number of rows within the
172700 ** source table.
172702 ** If the rbu_count table is present and populated correctly and this
172704 ** permyriadage progress of the same stage. If the rbu_count table does
172706 ** table exists but is not correctly populated, the value of the *pnOne
172834 ** The rbu_state table is used to save the state of a partially applied
172835 ** update so that it can be resumed later. The table consists of integer
172847 ** Only valid if STAGE==1. The target database name of the table
172852 ** currently being written, or NULL if the main table is currently being
172857 ** table/index.
172895 "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"
172923 ** A structure to store values read from the rbu_state table in memory.
172945 ** the target database that require updating. For each such table, the
172948 ** * the table itself,
172949 ** * each index of the table (zero or more points to visit), and
172950 ** * a special "cleanup table" state.
172953 ** If the table has no indexes on it, abIndexed is set to NULL. Otherwise,
172965 int *aiSrcOrder; /* src table col -> target table col */
172969 int eType; /* Table type - an RBU_PK_XXX value */
172973 const char *zTbl; /* Name of target db table */
172974 const char *zDataTbl; /* Name of rbu db table (or null) */
172979 int nIndex; /* Number of aux. indexes on table zTbl */
172995 ** 0: Table does not exist (error)
172996 ** 1: Table has an implicit rowid.
172997 ** 2: Table has an explicit IPK column.
172998 ** 3: Table has an external PK index.
172999 ** 4: Table is WITHOUT ROWID.
173000 ** 5: Table is a virtual table.
173014 #define RBU_INSERT 1 /* Insert on a main table b-tree */
173015 #define RBU_DELETE 2 /* Delete a row from a main table b-tree */
173020 #define RBU_UPDATE 6 /* Update a row in a main table b-tree */
173035 ** If the RBU database contains an rbu_count table, this value is set to
173048 ** of rows in the source table and nIndex the number of indexes on the
173049 ** corresponding target database table.
173055 ** for an UPDATE operation does not exist in the target table, then
173068 ** first pass of each source table. The updated nPhaseOneStep value is
173069 ** stored in the rbu_state table if the RBU update is suspended.
173504 ** the current object (table/index pair).
173610 ** accepts one or two arguments. The first argument is the name of a table -
173611 ** the name of a table in the RBU database. The second, if it is present, is 1
173612 ** for a view or 0 for a table.
173614 ** For a non-vacuum RBU handle, if the table name matches the pattern:
173672 "WHERE type IN ('table', 'view') AND target IS NOT NULL "
173829 /* Determine the type of a table.
173833 ** on the type of the table specified by parameters dbName and zTbl.
173835 ** RBU_PK_NOTABLE: No such table.
173836 ** RBU_PK_NONE: Table has an implicit rowid.
173837 ** RBU_PK_IPK: Table has an explicit IPK column.
173838 ** RBU_PK_EXTERNAL: Table has an external PK index.
173839 ** RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID.
173840 ** RBU_PK_VTAB: Table is a virtual table.
173843 ** parameter. Unless the table has an external primary key index
173845 ** if the table does have an external primary key index, then *piPk
173855 ** }else if( "PRAGMA index_list()" for the table contains a "pk" index ){
173894 /* Either an error, or no such table. */
173898 *peType = RBU_PK_VTAB; /* virtual table */
173993 ** the table (not index) that the iterator currently points to.
174004 int bRbuRowid = 0; /* If input table has column "rbu_rowid" */
174008 /* Figure out the type of table this step will deal with. */
174013 table: %s", pIter->zTbl);
174024 ** of the input table. Ignore any input table columns that begin with
174053 "table %q %s rbu_rowid column", pIter->zDataTbl,
174058 /* Check that all non-HIDDEN columns in the destination table are also
174059 ** present in the input table. Populate the abTblPk[], azTblType[] and
174126 ** used to read from an data_xxx or rbu_tmp_xxx table while updating the
174135 ** and "t1" is a table with an explicit INTEGER PRIMARY KEY column
174150 char **pzImposterCols, /* OUT: Columns for imposter table */
174181 /* An integer primary key. If the table has an explicit IPK, use
174241 ** Assuming the current table columns are "a", "b" and "c", and the zObj
174274 /* For a table with implicit rowids, append "old._rowid_" to the list. */
174284 ** primary key of the current table. For example, if the table is:
174286 ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c));
174342 ** an UPDATE statement used to update the table object that the iterator
174344 ** column of the data_xxx table entry is set to zMask.
174426 ** The iterator currently points to a table (not index) of type
174428 ** declaration for the corresponding imposter table. For example,
174429 ** if the iterator points to a table created as:
174431 ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID
174478 ** This function creates the second imposter table used when writing to
174479 ** a table b-tree where the table has an external primary key. If the
174481 ** a table (not index) with an external primary key, this function is a
174484 ** Assuming the iterator does point to a table with an external PK, this
174485 ** function creates a WITHOUT ROWID imposter table named "rbu_imposter2"
174486 ** used to access that PK index. For example, if the target table is
174489 ** CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c));
174491 ** then the imposter table schema is:
174493 ** CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID;
174503 char *zCols = 0; /* Used to build up list of table cols */
174504 char *zPk = 0; /* Used to build up table PK declaration */
174506 /* Figure out the name of the primary key index for the current table.
174543 "CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID",
174558 ** a table (not an index) when this function is called. This function
174559 ** attempts to create any imposter table required to write to the main
174560 ** table b-tree of the table before returning. Non-zero is returned if
174561 ** an imposter table are created, or zero otherwise.
174563 ** An imposter table is required in all cases except RBU_PK_VTAB. Only
174564 ** virtual tables are written to directly. The imposter table has the
174565 ** same schema as the actual target table (less any UNIQUE constraints).
174588 /* If the target table column is an "INTEGER PRIMARY KEY", add
174589 ** "PRIMARY KEY" to the imposter table column declaration. */
174607 rbuMPrintfExec(p, p->dbMain, "CREATE TABLE \"rbu_imp_%w\"(%z)%s",
174616 ** Prepare a statement used to insert rows into the "rbu_tmp_xxx" table.
174622 ** the target table, plus one (for the rbu_control column), plus one more
174623 ** (for the rbu_rowid column) if the target table is an implicit IPK or
174624 ** virtual table.
174699 char *zImposterCols = 0; /* Columns for imposter table */
174711 /* Create the imposter table used to write to this index. */
174715 "CREATE TABLE \"rbu_imp_%w\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID",
174778 const char *zTbl = pIter->zTbl; /* Table this step applies to */
174779 const char *zWrite; /* Imposter table name */
174789 /* Create the imposter table or tables (if required). */
174821 /* Create the rbu_tmp_xxx table and the triggers to populate it. */
174823 "CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS "
174894 ** be used to update the imposter table for the main table b-tree of the
174895 ** table object that pIter currently points to, assuming that the
174896 ** rbu_control column of the data_xyz table contains zMask.
175000 ** table into it. Return a pointer to the new object. It is the
175110 /* If it has not already been created, create the rbu_state table */
175667 /* If this is an INSERT into a table b-tree and the table has an
175692 /* For a virtual table, or a table with no primary key, the
175815 ** Update the contents of the rbu_state table within the rbu database. The
175956 /* If this is an RBU vacuum operation and the state table was empty
175967 /* Clean up the rbu_tmp_xxx table for the previous table. It
176088 ** the rbu_state table was empty) it is a no-op. Otherwise, it arranges
176172 ** name of a table expected to appear in the target database. It returns
176173 ** the number of auxilliary indexes on the table.
176210 ** If the RBU database contains the rbu_count table, use it to initialize
176211 ** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table
176214 ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;
176216 ** There should be one row in the table for each data_xxx table in the
176217 ** database. The 'tbl' column should contain the name of a data_xxx table,
176221 ** for all rows in the rbu_count table, where nIndex is the number of
176222 ** indexes on the corresponding target database table.
176235 /* Check for the rbu_count table. If it does not exist, or if an error
176517 ** state table. This causes the next call to sqlite3rbu_vacuum()
177658 ** This file contains an implementation of the "dbstat" virtual table.
177660 ** The dbstat virtual table is used to extract low-level formatting
177705 "CREATE TABLE xx( " \
177706 " name TEXT, /* Name of table or index */" \
177783 ** Connect to or create a statvfs virtual table.
177825 ** Disconnect from or destroy a statvfs virtual table.
177833 ** There is no "best-index". This virtual table always does a linear
177834 ** scan. However, a schema=? constraint should cause this table to
177948 if( flags==0x0D ){ /* Table leaf node */
178009 /* A table interior node. nPayload==0. */
178186 case 0x05: /* table internal */
178190 case 0x0D: /* table leaf */
178246 "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
178318 ** Invoke this routine to register the "dbstat" virtual table module
178366 ** This file contains an implementation of the "sqlite_dbpage" virtual table.
178368 ** The sqlite_dbpage virtual table is used to read or write whole raw
178377 ** This is an eponymous virtual table so it does not need to be created before
178378 ** use. The optional argument to the sqlite_dbpage() table name is the
178382 ** The data field of sqlite_dbpage table can be updated. The new
178417 ** Connect to or create a dbpagevfs virtual table.
178430 "CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)");
178447 ** Disconnect from or destroy a dbpagevfs virtual table.
178457 ** 0 schema=main, full table scan
178459 ** 2 schema=?1, full table scan
178562 ** 0 schema=main, full table scan
178564 ** 2 schema=?1, full table scan
178716 ** written by the sqlite_dbpage virtual table, start a write transaction
178732 ** Invoke this routine to register the "dbpage" virtual table module
178859 char *zTab; /* Current table */
178869 ** for each table the session object is monitoring. The structures are
178872 ** The keys of the SessionTable.aChange[] hash table are all rows that have
178874 ** table.
178876 ** The data associated with each hash-table entry is a structure containing
178882 char *zName; /* Local name of table */
178883 int nCol; /* Number of columns in table zName */
178887 int nEntry; /* Total number of entries in hash table */
178889 SessionChange **apChange; /* Hash table buckets */
178936 ** one or more tables. Operations on a single table are grouped together,
178940 ** Each group of changes begins with a table header:
178943 ** Varint: Number of columns in the table.
178945 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
178947 ** Followed by one or more changes to the table.
178956 ** columns in the table. The i'th field of each record is associated with
178957 ** the i'th column of the table, counting from left to right in the order
178958 ** in which columns were declared in the CREATE TABLE statement.
178968 ** associated with table columns that are not PRIMARY KEY columns and are
178972 ** with table columns modified by the UPDATE change contain the new
178973 ** values. Fields associated with table columns that are not modified
178982 ** Each group of changes begins with a table header:
178985 ** Varint: Number of columns in the table.
178987 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
178989 ** Followed by one or more changes to the table.
178998 ** table column, counting from left to right within the CREATE TABLE
179007 ** PRIMARY KEY fields contain the values identifying the table row to update,
179017 ** this structure stored in a SessionTable.aChange[] hash table.
179024 SessionChange *pNext; /* For hash-table collisions */
179220 SessionTable *pTab, /* Session table handle */
179294 ** hash key. Assume the has table has nBucket buckets. The hash keys
179302 SessionTable *pTab, /* Table handle */
179305 int nBucket /* Assume this many buckets in hash table */
179345 ** Arguments aLeft and aRight are pointers to change records for table pTab.
179351 SessionTable *pTab, /* Table used for PK definition */
179359 int iCol; /* Used to iterate through table columns */
179475 SessionTable *pTab, /* Table change pertains to */
179552 SessionTable *pTab, /* Table associated with change */
179619 ** If required, grow the hash table used to store changes on table pTab
179625 ** that case the hash-table does not grow, but SQLITE_OK is returned anyway.
179626 ** Growing the hash table in this case is a performance optimization only,
179665 ** This function queries the database for the names of the columns of table
179669 ** of columns in the database table and variable *pzTab is set to point to a
179670 ** nul-terminated copy of the table name. *pazCol (if not NULL) is set to
179675 ** For example, if the table is declared as:
179677 ** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z));
179692 const char *zThis, /* Table name */
179695 const char ***pazCol, /* OUT: Array of column names for table */
179795 ** write to table pTab, part of session pSession. If this is the first
179796 ** write to this table, initalize the SessionTable.nCol, azCol[] and
179800 ** non-zero returned. Or, if no error occurs but the table has no primary
179802 ** indicate that updates on this table should be ignored. SessionTable.abPK
179830 ** sqlite_stat1 table. The purpose of this is to substitute a zero-length
179832 ** sqlite_stat1 table.
179871 ** change on table pTab (attached to session pSession). The type of change
179875 ** to the changed-rows hash table associated with table pTab.
179880 SessionTable *pTab /* Table that change applies to */
179889 /* Load table details if required */
179893 ** number of columns in the table. */
179899 /* Grow the hash table if required */
179931 /* Search the hash table for an existing record for this row. */
179991 /* Add the change to the hash-table */
180030 /* Search for an existing table */
180036 /* If there is a table-filter configured, invoke it. If it returns 0,
180037 ** do not automatically add the new table. */
180062 char const *zName, /* Table name */
180222 const char *zTbl, /* Table name */
180323 SessionTable *pTo; /* Table zTbl */
180325 /* Locate and if necessary initialize the target table object */
180333 /* Check the table schemas match */
180355 *pzErrMsg = sqlite3_mprintf("table schemas do not match");
180433 ** Free the list of table objects passed as the first argument. The contents
180479 /* Delete all attached table objects. And the contents of their
180488 ** Set a table filter on a Session Object.
180501 ** Attach a table to a session. All subsequent changes made to the table
180510 const char *zName /* Table name */
180518 SessionTable *pTab; /* New table object (if required) */
180884 int nCol, /* Number of columns in table */
180930 ** Formulate and prepare a SELECT statement to retrieve a row from table
180938 const char *zTab, /* Table name */
180939 int nCol, /* Number of columns in table */
180940 const char **azCol, /* Names of table columns */
180993 int nCol, /* Number of columns in table */
181058 ** is called. Otherwise, append a serialized table header (part of the binary
181065 SessionTable *pTab, /* Table object to append header for */
181068 /* Write a table header */
181117 int nCol; /* Number of columns in table */
181119 const char **azCol = 0; /* Table columns */
181121 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
181125 /* Check the table schema is still Ok. */
181131 /* Write a table header */
181529 ** The input pointer currently points to the second byte of a table-header.
181532 ** + number of columns in table (varint)
181534 ** + table name (nul terminated).
181601 ** The input pointer currently points to the second byte of a table-header.
181604 ** + number of columns in table (varint)
181606 ** + table name (nul terminated).
181608 ** This function decodes the table-header and populates the p->nCol,
181611 ** input pointer is left pointing to the byte following the table header.
181782 const char **pzTab, /* OUT: Pointer to table name */
181783 int *pnCol, /* OUT: Number of columns in table */
181796 ** the database table affected by the change that pIter currently points
181950 int nCol = 0; /* Number of cols in current table */
181951 u8 *abPK = 0; /* PK array for current table */
181953 SessionBuffer sPK = {0, 0, 0}; /* PK array for current table */
181974 /* A 'table' record consists of:
181977 ** * Number of columns in said table (a varint),
181979 ** * A nul-terminated table name.
182148 int bStat1; /* True if table is sqlite_stat1 */
182154 ** Formulate a statement to DELETE a row from database db. Assuming a table
182157 ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
182172 const char *zTab, /* Table name */
182224 ** Assuming a table structure like this:
182226 ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
182239 ** For each column in the table, there are three variables to bind:
182255 const char *zTab, /* Table name */
182320 ** Formulate and prepare an SQL statement to query table zTab by primary
182321 ** key. Assuming the following table structure:
182323 ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
182334 const char *zTab, /* Table name */
182342 ** Formulate and prepare an INSERT statement to add a record to table zTab.
182352 const char *zTab, /* Table name */
182385 ** Prepare statements for applying changes to the sqlite_stat1 table.
182447 ** pStmt. The table being inserted into has nCol columns.
182487 ** iterator pIter points to to the SELECT and attempts to seek to the table
182508 int nCol; /* Number of columns in table */
182685 ** * all columns of the table are PK columns (in this case there is
182734 /* A NOTFOUND or DATA error. Search the table to see if it contains
182906 const char *zTab /* Table name */
182917 const char *zTab = 0; /* Name of current table */
182956 ** xFilter callback returns zero, skip this table. If it returns
182983 "sqlite3changeset_apply(): no such table: %s", zTab
182989 "sqlite3changeset_apply(): table %s has %d columns, "
182997 "primary key mismatch for table %s", zTab
183022 /* If there is a schema mismatch on the current table, proceed to the
183084 const char *zTab /* Table name */
183112 const char *zTab /* Table name */
183144 SessionTable *pTab, /* Table structure */
183295 /* Search the list for a matching table */
183338 /* Search for existing entry. If found, remove it from the hash table.
185460 ** The json_each virtual table
185476 /* Constructor for the json_each virtual table */
185504 "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
185514 /* destructor for json_each virtual table */
185745 ** column. Without such a constraint, the table cannot operate. idxNum is
185866 /* The methods of the json_each virtual table */
185893 /* The methods of the json_tree virtual table. */
185924 ** functions and the virtual table implemented by this file.
186057 ** Virtual table implementations may overload SQL functions by implementing
186087 ** to the total number of tokens in the FTS5 table. Or, if iCol is
186088 ** non-negative but less than the number of columns in the table, return
186090 ** the FTS5 table.
186093 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
186098 ** Return the number of columns in the table.
186103 ** non-negative but less than the number of columns in the table, set
186107 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
186111 ** This function may be quite inefficient if used with an FTS5 table
186134 ** This API can be quite slow if used with an FTS5 table created with the
186135 ** "detail=none" or "detail=column" option. If the FTS5 table is created
186137 ** (i.e. if it is a contentless table), then this API always returns 0.
186147 ** first token of the phrase. The exception is if the table was created
186154 ** This API can be quite slow if used with an FTS5 table created with the
186161 ** Tokenize text using the tokenizer belonging to the FTS5 table.
186164 ** This API function is used to query the FTS table for phrase iPhrase
186226 ** This function is used to retrieve the total number of rows in the table.
186253 ** This API can be quite slow if used with an FTS5 table created with the
186254 ** "detail=none" or "detail=column" option. If the FTS5 table is created
186256 ** (i.e. if it is a contentless table), then this API always iterates
186278 ** This API can be quite slow if used with an FTS5 table created with the
186279 ** "detail=none" option. If the FTS5 table is created with either
186280 ** "detail=none" "content=" option (i.e. if it is a contentless table),
186353 ** tokenizer name as part of the CREATE VIRTUAL TABLE statement used
186354 ** to create the FTS5 table.
186378 ** or removed from the FTS table. The tokenizer is being invoked to
186662 ** Maximum number of prefix indexes on single FTS5 table. This must be
186722 ** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.
186729 ** be gleaned from the CREATE VIRTUAL TABLE statement.
186731 ** And all information loaded from the %_config table.
186753 ** True if the %_docsize table is created.
186772 char *zContent; /* content table */
186780 /* Values loaded from the %_config table */
186798 /* Current expected value of %_config table 'version' field */
186828 /* Load the contents of the %_config table */
186935 ** to access the data stored in the %_data table.
187060 ** table may have changed on disk. So any in-memory caches of %_data
187085 ** Return the total number of entries read from the %_data table by
187151 ** Create a hash table, free a hash table.
187166 ** Empty (but do not delete) a hash table.
187171 Fts5Hash*, /* Hash table to query */
187178 Fts5Hash*, /* Hash table to query */
187594 ** slots in the fts5yy_action[] table.
187599 ** The action table is constructed as a single large table named fts5yy_action[].
187615 ** fts5yy_action[] A single table containing all actions.
187616 ** fts5yy_lookahead[] A table containing the lookahead for each entry in
187678 /* The next table maps tokens (terminal symbols) into fallback tokens.
187778 ** are required. The following table supplies these names */
188278 /* The following table contains information about every rule that
188541 /* There are no SHIFTREDUCE actions on nonterminals because the table
189346 ** table matched by each individual phrase within the query.
189375 sqlite3_int64 nRow = 0; /* Number of rows in table */
189376 sqlite3_int64 nToken = 0; /* Number of tokens in table */
189393 /* Calculate the average document length for this FTS5 table */
189869 ** designed to produce hash table collisions really do work. */
190142 ** Parse a "special" CREATE VIRTUAL TABLE directive and update
190427 ** or xConnect method of the virtual table. This function attempts to
190441 const char **azArg, /* Array of nArg CREATE VIRTUAL TABLE args */
190467 *pzErr = sqlite3_mprintf("reserved fts5 table name: %s", pRet->zName);
190588 zSql = sqlite3Fts5Mprintf(&rc, "CREATE TABLE x(");
190825 ** Load the contents of the %_config table into memory.
193743 ** This file contains the implementation of an in-memory hash table used
193759 ** Each entry in the hash table is represented by an object of the
193804 ** Allocate a new hash table.
193834 ** Free a hash table object.
193845 ** Empty (but do not delete) a hash table.
193881 ** Resize the hash table by doubling the number of slots.
193944 ** Add an entry to the in-memory hash table. The key is the concatenation
193993 /* Allocate new Fts5HashEntry and add it to the hash table. */
194145 ** Extract all tokens from hash table iHash and link them into a list
194146 ** in sorted order. The hash table is cleared before returning. It is
194193 ** Query the hash table for a doclist associated with term pTerm/nTerm.
194196 Fts5Hash *pHash, /* Hash table to query */
194223 Fts5Hash *p, /* Hash table to query */
194274 ** %_data table. Other parts of the system access this functionality via
194284 ** The %_data table contains all the FTS indexes for an FTS5 virtual table.
194319 ** The %_data table managed by this module,
194321 ** CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB);
194330 ** recorded in a single record within the %_data table. The record consists
194332 ** SQLite varints. If the FTS table features more than one index (because
194354 ** A single record within the %_data table. The data is a list of varints.
194357 ** rows of the table.
194470 ** Rowids for the averages and structure records in the %_data table.
194477 ** and nodes. All nodes and leaves are stored in the %_data table with large
194512 ** Each time a blob is read from the %_data table, it is padded with this
194539 ** One object per %_data table.
194542 Fts5Config *pConfig; /* Virtual table configuration */
194543 char *zDataTbl; /* Name of %_data table */
194550 Fts5Hash *pHash; /* Hash table for in-memory data */
194559 sqlite3_blob *pReader; /* RO incr-blob open on %_data table */
194635 /* Values to insert into the %_idx table */
194636 Fts5Buffer btterm; /* Next term to insert into %_idx table */
194891 ** Retrieve a record from the %_data table.
194928 ** table, missing row, non-blob/text in block column - indicate
195002 ** INSERT OR REPLACE a record into the %_data table.
196695 ** in-memory hash table. If there is no such term in the hash-table, the
197501 ** * the table contains 100 or fewer columns.
197665 /* Add a segment iterator for the current contents of the hash table. */
198554 /* Remove the redundant segments from the %_data table */
198717 ** Flush the contents of in-memory hash table iHash to a new level-0
198753 /* Begin scanning through hash table entries. This loop runs once for each
198754 ** term/doclist currently stored within the hash table. */
198876 /* Unless it is empty, flush the hash table to disk */
199382 /* Allocate the hash table if it has not already been allocated */
199387 /* Flush the hash table to disk if required */
199413 ** table may have changed on disk. So any in-memory caches of %_data
199425 ** The %_data table is completely empty when this function is called. This
199440 ** and initialize the underlying %_data table.
199735 ** the number of user defined columns in the FTS table.
199769 ** table since it was created.
199957 ** This check may only be performed if the hash table is empty. This
199958 ** is because the hash table only supports a single scan query at
200303 ** Decode a segment-data rowid from the %_data table. This function is
200307 i64 iRowid, /* Rowid from %_data table */
200799 ** SQLite invokes the following virtual table methods as transactions are
200875 ** Virtual-table object.
200879 Fts5Config *pConfig; /* Virtual table configuration */
200913 ** Virtual-table cursor object.
201068 ** Return true if pTab is a contentless table.
201075 ** Delete a virtual table handle allocated by fts5InitVtab().
201087 ** The xDisconnect() virtual table method.
201095 ** The xDestroy() virtual table method.
201108 ** methods of the FTS3 virtual table.
201114 ** argv[2] -> table name
201120 void *pAux, /* Hash table containing tokenizers */
201130 Fts5Table *pTab = 0; /* New virtual table object */
201180 ** The xConnect() and xCreate() methods for the virtual table. All the
201185 void *pAux, /* Pointer to tokenizer hash table */
201195 void *pAux, /* Pointer to tokenizer hash table */
201471 ** on the xClose method of the virtual table interface.
201530 ** open on table pTab.
201580 ** Advance the cursor to the next row in the table that matches the
201678 ** is not possible as SQLite reference counts the virtual table objects.
201680 ** table, saving it creates a circular reference.
201756 ** Search for an auxiliary function named zName that can be used with table
201871 ** This is the xFilter interface for the virtual table. See
201872 ** the virtual table xFilter method documentation for additional
201879 ** 3. A full-table scan.
201993 "%s: table does not support scanning", pConfig->zName
201997 /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup
202019 ** This is the xEof method of the virtual table. SQLite calls this
202045 ** exposes %_content.rowid as the rowid for the virtual table. The
202135 Fts5Table *pTab, /* Fts5 table object */
202136 const char *zCmd, /* Text inserted into table-name column */
202147 "contentless or external content fts5 table"
202156 "'rebuild' may not be used with a contentless fts5 table"
202233 sqlite3_vtab *pVtab, /* Virtual table handle */
202295 "cannot %s contentless fts5 table: %s",
202375 ** the pending-terms hash-table have already been flushed into the database
202386 ** hash-table. Any changes made to the database are reverted by SQLite.
203096 ** as the table. Return the cursor integer id number. This value is only
203125 ** virtual table.
203128 sqlite3_vtab *pVtab, /* Virtual table handle */
203150 ** Implementation of FTS5 xRename method. Rename an fts5 table.
203153 sqlite3_vtab *pVtab, /* Virtual table handle */
203154 const char *zName /* New name of table */
203163 ** Flush the contents of the pending-terms table to disk.
203189 ** Discard the contents of the pending terms table.
203531 i64 nTotalRow; /* Total number of rows in FTS table */
203570 /* If there is no %_docsize table, there should be no requests for
203692 "DROP TABLE IF EXISTS %Q.'%q_data';"
203693 "DROP TABLE IF EXISTS %Q.'%q_idx';"
203694 "DROP TABLE IF EXISTS %Q.'%q_config';",
203701 "DROP TABLE IF EXISTS %Q.'%q_docsize';",
203707 "DROP TABLE IF EXISTS %Q.'%q_content';",
203717 const char *zTail, /* Tail of table name e.g. "data", "config" */
203718 const char *zName /* New name of FTS5 table */
203722 "ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';",
203745 ** Create the shadow table named zPost, with definition zDefn. Return
203750 const char *zPost, /* Shadow table to create (e.g. "content") */
203751 const char *zDefn, /* Columns etc. for shadow table */
203758 rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
203767 "fts5: error creating shadow table %q_%s: %s",
203893 ** If a row with rowid iDel is present in the %_content table, add the
203948 ** Insert a record into the %_docsize table. Specifically, do:
203952 ** If there is no %_docsize table (as happens if the columnsize=0 option
203953 ** is specified when the FTS5 table is created), this function is a no-op.
204020 ** Remove a row from the FTS table.
204081 /* Reinitialize the %_data table. This call creates the initial structure
204159 ** by inserting a dummy row into the %_docsize table. The dummy will be
204162 ** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In
204184 ** Insert a new row into the FTS content table.
204194 /* Insert the new row into the %_content table. */
204202 sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */
204219 ** Insert new entries into the FTS index and %_docsize table.
204371 ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return
204391 ** %_content table. This block stores the checksum in ctx.cksum. */
204474 ** %_content table.
204532 ** each table column. This function reads the %_docsize record for the
204539 int nCol = p->pConfig->nCol; /* Number of user columns in table */
206602 ** This is an SQLite virtual table module implementing direct access to an
206607 ** CREATE TABLE vocab(term, col, doc, cnt, PRIMARY KEY(term, col));
206612 ** instances of term $term in column $col (in any row of the fts5 table).
206615 ** CREATE TABLE vocab(term, doc, cnt, PRIMARY KEY(term));
206623 ** CREATE TABLE vocab(term, doc, col, offset, PRIMARY KEY(<all-fields>));
206637 char *zFts5Tbl; /* Name of fts5 table */
206638 char *zFts5Db; /* Db containing fts5 table */
206656 Fts5Config *pConfig; /* Fts5 table configuration */
206662 i64 rowid; /* This table's current rowid value */
206687 ** Translate a string containing an fts5vocab table type to an
206708 *pzErr = sqlite3_mprintf("fts5vocab: unknown table type: %Q", zCopy);
206719 ** The xDisconnect() virtual table method.
206728 ** The xDestroy() virtual table method.
206738 ** methods of the FTS3 virtual table.
206744 ** argv[2] -> table name
206748 ** argv[3] -> name of fts5 table
206749 ** argv[4] -> type of fts5vocab table
206754 ** argv[4] -> name of fts5 table
206755 ** argv[5] -> type of fts5vocab table
206766 "CREATE TABlE vocab(" FTS5_VOCAB_COL_SCHEMA ")",
206767 "CREATE TABlE vocab(" FTS5_VOCAB_ROW_SCHEMA ")",
206768 "CREATE TABlE vocab(" FTS5_VOCAB_INST_SCHEMA ")"
206816 ** The xConnect() and xCreate() methods for the virtual table. All the
206821 void *pAux, /* Pointer to tokenizer hash table */
206831 void *pAux, /* Pointer to tokenizer hash table */
206895 /* This virtual table always delivers results in ascending order of
206947 "no such fts5 table
206983 ** on the xClose method of the virtual table interface.
207044 ** Advance the cursor to the next row in the table.
207165 ** This is the xFilter implementation for the virtual table.
207233 ** This is the xEof method of the virtual table. SQLite calls this
207373 ** This file demonstrates an eponymous virtual table that returns information
207394 ** serve as the underlying representation of a stmt virtual table
207416 ** stmt_vtab that describes the stmt virtual table.
207452 "CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
207588 ** that uses the stmt virtual table. This routine needs to create
207603 ** stmt virtual table.