Lines Matching defs:table
761 #define SQLITE_LOCKED 6 /* A table in the database is locked */
2320 ** the use of covering indices for full table scans in the query optimizer.
2324 ** The ability to disable the use of covering indices for full table scans
2414 ** of a table column that its values are likely to be very large - larger
2660 ** <li> Writes to the [sqlite_dbpage] virtual table.
2741 ** process a table with generated columns and a descending index. This is
2789 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
2793 ** the most recent successful [INSERT] into a rowid table or [virtual table]
2803 ** Some virtual table implementations may INSERT rows into rowid tables as
2807 ** unintuitive results. Virtual table implementations that do write to rowid
3036 ** an attempt is made to access a database table associated with
3038 ** or process has the table locked.
3095 ** for a specified amount of time when a table is locked. ^The handler
3120 ** Definition: A <b>result table</b> is memory data structure created by the
3121 ** [sqlite3_get_table()] interface. A result table records the
3124 ** The table conceptually has a number of rows and columns. But
3125 ** these numbers are not part of the result table itself. These
3129 ** A result table is an array of pointers to zero-terminated UTF-8 strings.
3136 ** A result table might consist of one or more memory allocations.
3137 ** It is not safe to pass a result table directly to [sqlite3_free()].
3138 ** A result table should be deallocated using [sqlite3_free_table()].
3140 ** ^(As an example of the result table format, suppose a query result
3152 ** result table has 8 entries. Suppose the result table is stored
3168 ** string of its 2nd parameter and returns a result table to the
3172 ** it must pass the result table pointer to sqlite3_free_table() in order to
3353 ** select random [ROWID | ROWIDs] when inserting new records into a table that
3412 ** a NULL value in place of the table column that would have
3415 ** columns of a table.
3416 ** ^When a table is referenced by a [SELECT] but no column values are
3417 ** extracted from that table (for example in a query like
3419 ** is invoked once for that table with a column name that is an empty string.
3925 ** <table border="1" align=center cellpadding=5>
3951 ** </table>
4310 ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
4316 ** <dd>The maximum number of columns in a table definition or in the
4639 ** read-only no-op if the table already exists, but
4686 ** that can be stored in a database table. SQLite uses dynamic typing
4982 ** WHERE clause constraints and the table content, it might return no rows.
5022 ** ^These routines provide a means to determine the database, table, and
5023 ** table column that is the origin of a particular result column in
5025 ** ^The name of the database or table or column can be returned as
5027 ** the database name, the _table_ routines return the table name, and
5036 ** database, table, and column.
5046 ** occurs. ^Otherwise, they return the name of the attached database, table,
5073 ** returned result set of that [SELECT] is a table column (not an
5074 ** expression or subquery) then the declared type of the table
5246 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5263 ** </table></blockquote>
5359 ** conversion automatically. ^(The following table details the conversions
5363 ** <table border="1">
5382 ** </table>
5794 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5817 ** against a virtual table.
5820 ** </table></blockquote>
5878 ** ^Within the [xUpdate] method of a [virtual table], the
5893 ** interfaces. ^If X comes from an SQL literal value, or a table column,
6940 ** a [rowid table].
6945 ** row is updated, inserted or deleted in a rowid table.
6952 ** database and table name containing the affected row.
7148 ** information about column C of table T in database D
7156 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
7157 ** does not. If the table name parameter T in a call to
7164 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
7165 ** for the table using the same algorithm used by the database engine to
7166 ** resolve unqualified table references.
7168 ** ^The third and fourth parameters to this function are the table and column
7176 ** <table border="1">
7184 ** </table>
7191 ** ^If the specified table is actually a view, an [error code] is returned.
7193 ** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
7194 ** is not a [WITHOUT ROWID] table and an
7361 ** The interface to the virtual-table mechanism is currently considered
7365 ** When the virtual-table mechanism stabilizes, we will declare the
7370 ** Structures used by the virtual table interface
7379 ** KEYWORDS: sqlite3_module {virtual table module}
7381 ** This structure, sometimes called a "virtual table module",
7382 ** defines the implementation of a [virtual table].
7385 ** ^A virtual table module is created by filling in a persistent
7436 ** of the [virtual table] interface to
7438 ** method of a [virtual table module]. The fields under **Inputs** are the
7458 ** relevant to the particular virtual table being queried.
7463 ** The colUsed field indicates which columns of the virtual table may be
7464 ** required by the current scan. Virtual table columns are numbered from
7468 ** required by SQLite. If the table has at least 64 columns and any column
7479 ** virtual table and might not be checked again by the byte code.)^ ^(The
7498 ** to a linear scan of an SQLite table with N rows. A cost of log(N)
7500 ** binary search on a unique indexed field of an SQLite table with N rows.
7512 ** part of the same statement to delete or update a virtual table row and the
7522 ** If a virtual table extension is
7568 ** Virtual table implementations are allowed to set the
7580 ** a query that uses a [virtual table].
7592 ** by the [xFindFunction|xFindFunction method] of the virtual table
7634 ** ^These routines are used to register a new [virtual table module] name.
7636 ** creating a new [virtual table] using the module and before using a
7637 ** preexisting [virtual table] for the module.
7642 ** the implementation of the [virtual table module]. ^The fourth
7644 ** into the [xCreate] and [xConnect] methods of the virtual table module
7645 ** when a new virtual table is be being created or reinitialized.
7681 ** table modules from database connection D except those named on list L.
7684 ** ^If the L parameter is NULL, then all virtual table modules are removed.
7697 ** Every [virtual table module] implementation uses a subclass
7699 ** of the [virtual table]. Each subclass will
7712 const sqlite3_module *pModule; /* The module for this virtual table */
7715 /* Virtual table implementations will typically add additional fields */
7720 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
7722 ** Every [virtual table module] implementation uses a subclass of the
7724 ** [virtual table] and are used
7725 ** to loop through the virtual table. Cursors are created using the
7736 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
7737 /* Virtual table implementations will typically add additional fields */
7744 ** [virtual table module] call this interface
7755 ** using the [xFindFunction] method of the [virtual table module].
7765 ** by a [virtual table].
7770 ** The interface to the virtual-table mechanism defined above (back up
7775 ** When the virtual-table mechanism stabilizes, we will declare the
7799 ** in row iRow, column zColumn, table zTable in database zDb;
7826 ** <li> ^(Table zTable is a WITHOUT ROWID table)^,
7828 ** <li> ^(Row iRow is not present in the table)^,
7845 ** different row of the same table using the [sqlite3_blob_reopen()]
7846 ** interface. However, the column, table, or database of a [BLOB handle]
7891 ** to a different row of the same database table. ^The new row is identified
7893 ** changed. ^The database, table and column on which the blob handle is open
7899 ** the nominated column.)^ ^If the new row is not present in the table, or if
8463 ** creates a new table named "BEGIN" with three columns named
8892 ** statements. For example, if the number of table steps greatly exceeds
8893 ** the number of table searches or result rows, that would tend to indicate
8894 ** that the prepared statement is using a full table scan rather than
8921 ** a table as part of a full table scan. Large numbers for this counter
9119 ** <table border=1 width=85% align=center>
9126 ** </table>
9457 ** shared-cache table, and more than one other connection currently holds
9458 ** a read-lock on the same table, then SQLite arbitrarily selects one of
9829 ** of a [virtual table] implementation to configure
9830 ** various facets of the virtual table interface.
9833 ** xCreate virtual table method then the behavior is undefined.
9836 ** [database connection] in which the virtual table is being created and
9839 ** of the [virtual table configuration options]. The presence and meaning
9840 ** of parameters after C depend on which [virtual table configuration option]
9847 ** KEYWORDS: {virtual table configuration options}
9848 ** KEYWORDS: {virtual table configuration option}
9851 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
9859 ** where X is an integer. If X is zero, then the [virtual table] whose
9867 ** If X is non-zero, then the virtual table implementation guarantees
9877 ** Virtual table implementations that are required to handle OR REPLACE
9880 ** CONFLICT policy is REPLACE, the virtual table implementation should
9890 ** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9891 ** prohibits that virtual table from being used from within triggers and
9898 ** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9899 ** identify that virtual table as being safe to use from within triggers
9901 ** virtual table can do no serious harm even if it is controlled by a
9915 ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The
9919 ** [virtual table].
9948 ** method of a [virtual table], then it might return true if the
9950 ** column value will not change. The virtual table implementation can use
9962 ** The sqlite3_vtab_nochange() routine is an optimization. Virtual table
9975 ** method of a [virtual table]. This function returns a pointer to a string
10006 ** CAPI3REF: Determine if a virtual table query is DISTINCT
10010 ** of a [virtual table] implementation. The result of calling this
10015 ** gives the virtual table additional information about how the query
10016 ** planner wants the output to be ordered. As long as the virtual table
10022 ** that the query planner needs the virtual table to return all rows in the
10025 ** virtual table outputs all rows in sorted order, then it is always safe for
10042 ** are adjacent. ^The virtual table may, if it chooses, omit extra rows
10049 ** rows to be sorted.)^ ^The virtual table implementation is free to omit
10055 ** ^For the purposes of comparing virtual table output values to see if the
10060 ** If a virtual table implementation is unable to meet the requirements
10064 ** ^A virtual table implementation is always free to return rows in any order
10071 ** flag might help queries against a virtual table to run faster. Being
10082 ** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
10086 ** ^(A constraint on a virtual table of the form
10094 ** on the right-hand side of the IN operator.)^ Thus the virtual table
10099 ** table to see all values on the right-hand of the IN operator all at
10108 ** by which the virtual table can ask SQLite if all-at-once processing
10113 ** to SQLite that the virtual table does or does not want to process
10116 ** which the virtual table tells SQLite how it wants to process the
10134 ** integer. This is how the virtual table tells SQLite that it wants to
10155 ** [xFilter|xFilter() method] of a [virtual table] implementation.
10193 ** method from which these routines were called. If the virtual table
10205 ** of a [virtual table] implementation. The result of calling this interface
10209 ** the [xBestIndex] method of a [virtual table] implementation, with P being
10247 ** inform a [virtual table] implementation what the [ON CONFLICT] mode
10291 ** to a zero-terminated UTF-8 string containing the name of the index or table
10405 ** on a database table.
10429 ** table that is being modified.
10431 ** For an UPDATE or DELETE operation on a [rowid table], the sixth
10433 ** row being modified or deleted. For an INSERT operation on a rowid table,
10434 ** or any operation on a WITHOUT ROWID table, the value of the sixth
10435 ** parameter is undefined. For an INSERT or UPDATE on a rowid table the
10455 ** the table row before it is updated. The N parameter must be between 0
10464 ** the table row after it is updated. The N parameter must be between 0
11076 ** the first table has been attached to the session object.
11138 ** If argument zTab is not NULL, then it is the name of a table to attach
11140 ** made to the table while the session object is enabled will be recorded. See
11153 ** It is not an error if the named table does not exist in the database. Nor
11154 ** is it an error if the named table does not have a PRIMARY KEY. However,
11165 ** As of SQLite version 3.22.0, the "sqlite_stat1" table is an exception to
11181 ** table. However, if the application calls sqlite3changeset_new(),
11188 ** changes made to the sqlite_stat1 table. Legacy versions of the
11190 ** sqlite_stat1 table that are part of a changeset or patchset.
11198 ** CAPI3REF: Set a table filter on a Session Object.
11203 ** to determine whether changes to the table's rows should be tracked or not.
11204 ** If xFilter returns 0, changes are not tracked. Note that once a table is
11228 ** each representing a change to a single row of an attached table. An INSERT
11253 ** single table are grouped together. In other words, when iterating through
11255 ** to a single table are processed before moving on to the next table. Tables
11258 ** a single table are stored is undefined.
11266 ** Once a table has been attached to a session object, the session object
11267 ** records the primary key values of all new rows inserted into the table.
11280 ** original values of other table columns (created when the users deletes
11297 ** the changeset. Or, if no such row is found in the table, a DELETE
11348 ** argument, this function attaches table zTbl in the same manner as the
11355 ** a table compatible with the table attached to the session by this function.
11356 ** A table is considered compatible if it:
11370 ** used to update the table in database zFrom (call this the "from-table")
11371 ** so that its content is the same as the table attached to the session
11372 ** object (call this the "to-table"). Specifically:
11375 ** <li> For each row (primary key) that exists in the to-table but not in
11376 ** the from-table, an INSERT record is added to the session object.
11378 ** <li> For each row (primary key) that exists in the to-table but not in
11379 ** the from-table, a DELETE record is added to the session object.
11392 ** required compatible table.
11434 ** a single table are grouped together, tables appear in the order in which
11453 ** an attached table is modified and then later on the original values
11495 ** that apply to a single table are grouped together. This means that when
11497 ** this function, all changes that relate to a single table are visited
11499 ** the applies to table X, then one for table Y, and then later on visit
11500 ** another change for table X.
11576 ** *pnCol is set to the number of columns in the table affected by the change; and
11579 ** the name of the table affected by the current change. The buffer remains
11594 const char **pzTab, /* OUT: Pointer to table name */
11595 int *pnCol, /* OUT: Number of columns in table */
11604 ** For each modified table, a changeset includes the following:
11607 ** <li> The number of columns in the table, and
11612 ** the table modified by the change that iterator pIter currently points to.
11614 ** nCol is the number of columns in the table. Elements of *pabPK are set to
11619 ** in the table.
11645 ** of columns in the table affected by the current change. Otherwise,
11676 ** of columns in the table affected by the current change. Otherwise,
11708 ** of columns in the table affected by the current change. Otherwise,
11912 ** <table border=1 style="margin-left:8ex;margin-right:8ex">
11952 ** </table>
11954 ** If the new changeset contains changes to a table that is already present
11956 ** primary key columns for the table must be consistent. If this is not the
11978 ** table are grouped together in the output of this function. Tables appear
12012 ** callback". If it is not NULL, then for each table affected by at least one
12014 ** the table name as the second argument, and a copy of the context pointer
12016 ** returns zero, then no attempt is made to apply any changes to the table.
12018 ** is NULL, all changes related to the table are attempted.
12020 ** For each table that is not excluded by the filter callback, this function
12021 ** tests that the target database contains a compatible table. A table is
12025 ** <li> The table has the same name as the name recorded in the
12027 ** <li> The table has at least as many columns as recorded in the
12029 ** <li> The table has primary key columns in the same position as
12033 ** If there is no compatible table, it is not an error, but none of the
12034 ** changes associated with the table are applied. A warning message is issued
12036 ** one such warning is issued for each table in the changeset.
12038 ** For each change for which there is a compatible table, an attempt is made
12039 ** to modify the table contents according to the UPDATE, INSERT or DELETE
12073 ** database table has more columns than are recorded in the changeset,
12075 ** the current database contents - any trailing database table columns
12092 ** database table, the trailing fields are populated with their default
12135 ** table that the callback related to, from within the xConflict callback.
12476 ** <table border=1 style="margin-left:8ex;margin-right:8ex">
12485 ** </table>
12725 ** Virtual table implementations may overload SQL functions by implementing
12755 ** to the total number of tokens in the FTS5 table. Or, if iCol is
12756 ** non-negative but less than the number of columns in the table, return
12758 ** the FTS5 table.
12761 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
12766 ** Return the number of columns in the table.
12771 ** non-negative but less than the number of columns in the table, set
12775 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
12779 ** This function may be quite inefficient if used with an FTS5 table
12802 ** This API can be quite slow if used with an FTS5 table created with the
12803 ** "detail=none" or "detail=column" option. If the FTS5 table is created
12805 ** (i.e. if it is a contentless table), then this API always returns 0.
12818 ** This API can be quite slow if used with an FTS5 table created with the
12825 ** Tokenize text using the tokenizer belonging to the FTS5 table.
12828 ** This API function is used to query the FTS table for phrase iPhrase
12890 ** This function is used to retrieve the total number of rows in the table.
12917 ** This API can be quite slow if used with an FTS5 table created with the
12918 ** "detail=none" or "detail=column" option. If the FTS5 table is created
12920 ** (i.e. if it is a contentless table), then this API always iterates
12942 ** This API can be quite slow if used with an FTS5 table created with the
12943 ** "detail=none" option. If the FTS5 table is created with either
12944 ** "detail=none" "content=" option (i.e. if it is a contentless table),
13018 ** to create the FTS5 table.
13042 ** or removed from the FTS table. The tokenizer is being invoked to
13307 ** limits the size of a row in a table or index.
13319 ** * Columns in a table
13329 ** not have more than a dozen or so columns in any table. And if
13387 ** the main database table and for temporary tables.
13899 ** This is the header file for the generic hash-table implementation
13909 /* A complete hash table is an instance of the following structure.
13917 ** All elements of the hash table are on a single doubly-linked list.
13926 ** Hash.ht table is never allocated because if there are few elements
13927 ** in the table, it is faster to do a linear search than to manage
13928 ** the hash table.
13931 unsigned int htsize; /* Number of buckets in the hash table */
13932 unsigned int count; /* Number of entries in this table */
13934 struct _ht { /* the hash table */
13940 /* Each element in the hash table is an instance of the following
13947 HashElem *next, *prev; /* Next and previous elements in the table */
13961 ** Macros for looping over all elements of a hash table. The idiom is
13979 ** Number of entries in a hash table
14397 ** table or index. This is an unsigned integer type. For 99.9% of
14646 ** Name of table that holds the database schema.
14655 ** The LEGACY names are stored in the internal symbol hash table
14669 ** The root-page of the schema table.
14674 ** The name of the schema table. The name is different for TEMP.
15537 ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.
15538 ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data
15647 ** the main table row automatically deletes corresponding index rows,
15657 Btree*, /* BTree containing table to open */
15694 ** entry in either an index or table btree.
15706 ** The aMem,nMem fields are uninitialized for table btrees.
16819 Hash fkeyHash; /* All foreign keys by referenced table name */
16820 Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
16936 ** A hash table for built-in function definitions. (Application-defined
16937 ** functions use a regular table table from hash.h.)
16945 FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */
17048 Pgno newTnum; /* Rootpage of table being initialized */
17052 unsigned imposterTable : 1; /* Building an imposter table */
17118 Hash aFunc; /* Hash table of connection functions */
17154 sqlite3_xDropTableHandle xDropTableHandle; /* User drop table callback */
17231 #define DBFLAG_SchemaChange 0x0001 /* Uncommitted Hash table changes */
17302 ** structure is held in the db->aHash hash table.
17536 ** Each SQLite module (virtual table definition) is defined by an
17538 ** hash table.
17546 Table *pEpoTab; /* Eponymous table for this module */
17550 ** Information about each column of an SQL table is held in an instance
17555 ** "table column index" This is the index of the column in the
17562 ** or equal to the table column index. It is
17609 #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
17689 ** An object of this type is created for each virtual table present in
17695 ** instance of the sqlite3_vtab* handle used to access the virtual table
17701 ** then be used by the virtual table implementation to access real tables
17704 ** connection as that used to execute SQL operations on the virtual table.
17706 ** All VTable objects that correspond to a single table in a shared
17710 ** table, it searches the list for the VTable that corresponds to the
17731 sqlite3 *db; /* Database connection associated with this table */
17748 ** The schema for each SQL table, virtual table, and view is represented
17752 char *zName; /* Name of the table or view */
17754 Index *pIndex; /* List of SQL indexes on this table. */
17758 Pgno tnum; /* Root BTree page for this table */
17762 i16 nCol; /* Number of columns in this table */
17764 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
17765 LogEst szTabRow; /* Estimated size of each table row in bytes */
17767 LogEst costMult; /* Cost multiplier for using this table */
17774 FKey *pFKey; /* Linked list of all foreign keys in this table */
17788 Schema *pSchema; /* Schema that contains this table */
17806 #define TF_Readonly 0x00000001 /* Read-only system table */
17820 #define TF_Shadow 0x00001000 /* True for a shadow table */
17821 #define TF_HasStat4 0x00002000 /* STAT4 info available for this table */
17822 #define TF_Ephemeral 0x00004000 /* An ephemeral table */
17823 #define TF_Eponymous 0x00008000 /* An eponymous virtual table */
17829 #define TABTYP_NORM 0 /* Ordinary table */
17830 #define TABTYP_VTAB 1 /* Virtual table */
17837 ** Test to see whether or not a table is a virtual table. This is
17839 ** table support is omitted from the build.
17868 /* Does the table have a rowid */
17875 ** A foreign key is associated with two tables. The "from" table is
17876 ** the table that contains the REFERENCES clause that creates the foreign
17877 ** key. The "to" table is the table that is named in the REFERENCES clause.
17885 ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2".
17888 ** from-table == child-table
17889 ** to-table == parent-table
17892 ** which is attached to the from-table. The to-table need not exist when
17893 ** the from-table is created. The existence of the to-table is not checked.
17897 ** A list of all children for a table named Z (which might not even exist)
17903 char *zTo; /* Name of table that the key points to (aka: Parent) */
17939 ** referenced table row is propagated into the row that holds the
17992 ** Records are used to store the content of a table row and to store
18043 ** The columns of the table that are to be indexed are described
18045 ** we have the following table and index:
18051 ** three columns in the table. In the Index structure describing
18067 ** colNotIdxed has a 1 bit for every column of the original table that
18072 ** table is used, the "colUsed & colNotIdxed" test will always be non-zero
18079 ** table as part of parsing an existing database schema), transient instances
18089 Table *pTable; /* The SQL table being indexed */
18091 Index *pNext; /* The next index associated with the same table */
18130 #define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
18146 ** Each sample stored in the sqlite_stat4 table is represented in memory
18196 ** than the source table */
18198 int sortingIdxPTab; /* Cursor number of pseudo-table */
18203 Table *pTab; /* Source table */
18205 int iTable; /* Cursor number of the source table */
18207 i16 iColumn; /* Column number within the source table */
18218 int iDistinct; /* Ephemeral table used to enforce DISTINCT */
18267 ** An expression of the form ID or ID.ID refers to a column in a table.
18269 ** the integer cursor number of a VDBE cursor pointing to that table and
18285 ** If the Expr is of type OP_Column, and the table it is selecting from
18286 ** is a disk table or the "old.*" pseudo-table, then pTab points to the
18287 ** corresponding table definition.
18340 int iTable; /* TK_COLUMN: cursor number of table holding column
18344 ** TK_IN: ephemerial table holding RHS
18352 int iJoin; /* If EP_OuterON or EP_InnerON, the right table */
18545 ** column names after a table name in an INSERT statement. In the statement
18549 ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
18575 ** The jointype starts out showing the join type between the current table
18576 ** and the next table on the list. The parser builds the list this way.
18578 ** jointype expresses the join between the table and the previous table.
18580 ** In the colUsed field, the high-order bit (bit 63) is set if the table
18592 char *zDatabase; /* Name of database holding this table */
18593 char *zName; /* Name of the table */
18595 Table *pTab; /* An SQL table corresponding to zName */
18596 Select *pSelect; /* A SELECT statement used in place of a table name */
18601 u8 jointype; /* Type of join between this table and the previous */
18604 unsigned isTabFunc :1; /* True if table-valued-function syntax */
18617 int iCursor; /* The VDBE cursor number used to access this table */
18625 ExprList *pFuncArg; /* Arguments to table-valued-function */
18702 ** A NameContext defines a context in which to resolve table and column
18706 ** to the table being operated on by INSERT, UPDATE, or DELETE. The
18914 ** row of result as the key in table pDest->iSDParm.
18918 ** SRT_EphemTab Create an temporary table pDest->iSDParm and store
18922 ** the table first.
18930 ** SRT_Table Store results in temporary table pDest->iSDParm.
18931 ** SRT_Fifo This is like SRT_EphemTab except that the table
18936 ** SRT_DistFifo Store results in a temporary table pDest->iSDParm.
18937 ** But also use temporary table pDest->iSDParm+1 as
18949 ** SRT_Upfrom Store results in the temporary table already opened by
18951 ** table is an intkey table - in this case the first
18953 ** key. If (pDest->iSDParm>0), then the table is an index
18954 ** table. (pDest->iSDParm) is the number of key columns in
18999 ** pointer of each autoincrement table to record some side information that
19000 ** the code generator needs. We have to keep per-table autoincrement
19102 ** used to store the set of table-locks required by the statement being
19147 TableLock *aTableLock; /* Required table locks for shared-cache mode */
19199 Table *pNewTable; /* A table being constructed by CREATE TABLE */
19299 ** 1. In the "trigHash" hash table (part of the sqlite3* that represents the
19301 ** 2. All triggers associated with a single table form a linked list, using the
19311 char *table; /* The table or view to which the trigger applies */
19319 Schema *pTabSchema; /* Schema containing the table */
19321 Trigger *pNext; /* Next trigger associated with the table */
19351 ** zTarget -> Dequoted name of the table to insert into.
19358 ** zTarget -> Dequoted name of the table to delete from.
19363 ** zTarget -> Dequoted name of the table to update.
19383 char *zTarget; /* Target table for DELETE, UPDATE, INSERT */
19402 int iRetCur; /* Transient table holding RETURNING results */
19632 ** A single common table expression
19652 ** one or more CTEs (common table expressions).
19676 int iCur; /* Ephemeral table holding the materialization */
19677 LogEst nRowEst; /* Estimated number of rows in the table */
19739 int nBufferCol; /* Number of columns in buffer table */
19812 ** FTS3 and FTS4 both require virtual table support
20849 #define IN_INDEX_ROWID 1 /* Search the rowid of the table */
20853 #define IN_INDEX_NOOP 5 /* No table available. Use comparisons */
22076 ** The following 256 byte lookup table is used to support SQLites built-in
22291 ** Hash table for global functions - functions common to all
22292 ** database connections. After initialization, this table is
22478 ** - On either an index or a table
22480 ** * A virtual table
22494 Bool isEphemeral:1; /* True for an ephemeral table */
22496 Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
22500 Btree *pBtx; /* Separate file holding temporary table */
22501 u32 *aAltMap; /* Mapping from table to index column numbers */
22652 ** * MEM_Null|MEM_Zero An SQL NULL with the virtual table
22806 char *zName; /* Name of table or index */
22938 ** OP_VFilter, the xFilter method of a virtual table. The vector is the
22950 BtCursor *pCsr; /* An ephemeral table holding all values */
24120 ** The following table defines various date transformations of the form
25334 ** fatal. For example, if a malloc fails while resizing a hash table, this
25336 ** hash table will continue to function normally. So a malloc failure
25337 ** during a hash table resize is a benign fault.
26489 ** small chunk list, or into the large chunk hash table.
26660 ** chunk table or in the large chunk hash table. This is
30006 ** The following table is searched linearly, so it is good to put the
31982 ** emulate collation associated with a table column. These show
32103 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
32104 ** is set to the column of the pseudo-table to read, or to -1 to
32168 sqlite3TreeViewLine(pView, "First FROM table rowid");
32170 sqlite3TreeViewLine(pView, "First FROM table column %d",
33110 ** This lookup table is used to help decode the first byte of
35335 /* Turn bulk memory into a hash table object by initializing the
35338 ** "pNew" is a pointer to the hash table that is to be initialized.
35348 /* Remove all entries from a hash table. Reclaim all memory.
35349 ** Call this routine to delete a hash table or to reset a hash table
35353 HashElem *elem; /* For looping over all elements of the table */
35386 /* Link pNew element into the hash table pH. If pEntry!=0 then also
35390 Hash *pH, /* The complete hash table */
35417 /* Resize the hash table so that it cantains "new_size" buckets.
35419 ** The hash table might fail to resize if sqlite3_malloc() fails or
35424 struct _ht *new_ht; /* The new hash table */
35434 /* The inability to allocates space for a larger hash table is
35439 ** use the actual amount of space allocated for the hash table (which
35460 ** hash table that matches the given key. If no element is found,
35496 /* Remove a single entry from the hash table given a pointer to that
35530 /* Attempt to locate an element of the hash table pH with a key
35540 /* Insert an element into the hash table pH. The key is pKey
35549 ** the new data is returned and the hash table is unchanged.
35552 ** element corresponding to "key" is removed from the hash table.
35555 unsigned int h; /* the hash of the key modulo hash table size */
52214 ** But sometimes (for example when during a DROP of a large table) most
52254 /* Number of u32 values in hash table. */
52256 /* Maximum number of entries in hash table before
52279 ** a hash table that will hold up to BITVEC_MXHASH distinct values.
52300 u32 aHash[BITVEC_NINT]; /* Hash table representation */
52433 ** that BitvecClear can use to rebuilt its hash table.
53656 PgHdr1 *pNext; /* Next in hash table chain */
53728 /* Hash table of all pages. The following variables may only be accessed
53734 PgHdr1 **apHash; /* Hash table for fast lookup by key */
54066 ** This function is used to resize the hash table used by the cache passed
54131 ** Remove the page supplied as an argument from the hash table
54191 ** cache, then there is no point in scanning the entire hash table.
54199 ** It is necessary to scan the entire hash table */
54544 /* Step 1: Search the hash table for an existing entry. */
54548 /* Step 2: If the page was found in the hash table, then return it.
54549 ** If the page was not in the hash table and createFlag is 0, abort.
58290 ** in this case. But for things like temporary table (which will be
63531 ** database page number associated with each wal frame, and a hash-table
63546 ** Even without using the hash table, the last frame for page P
63553 ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
63555 ** hash table for each page number in the mapping section, so the hash
63556 ** table is never more than half full. The expected number of collisions
63557 ** prior to finding a match is 1. Each entry of the hash table is an
63562 ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table
63565 ** To look for page P in the hash table, first compute a hash iKey on
63570 ** Then start scanning entries of the hash table, starting with iKey
63571 ** (wrapping around to the beginning when the end of the hash table is
63574 ** wrap-around.) Because the hash table is never more than half full,
63598 ** Both readers can use the same hash table and mapping section to get
63599 ** the correct result. There may be entries in the hash table with
63601 ** slots in the hash table and so the first reader will get an answer as
63602 ** if no values greater than K0 had ever been inserted into the hash table
63607 ** When a rollback occurs, the value of K is decreased. Hash table entries
63609 ** from the hash table at this point.
63918 ** Each page of the wal-index mapping contains a hash-table made up of
63952 ** is a hash-table following every HASHTABLE_NPAGE page numbers in the
63963 ** The block of page numbers associated with the first hash-table in a
63965 ** hash-table on each aligned 32KB page of the wal-index.
64343 ** of a page hash table in the wal-index. This becomes the return value
64348 volatile ht_slot *aHash; /* Start of the wal-index hash table */
64354 ** Return pointers to the hash table and page number array stored on
64358 ** Set output variable pLoc->aHash to point to the start of the hash table
64360 ** number of the first frame indexed by this hash table. If a
64361 ** slot in the hash table is set to N, it refers to frame number
64365 ** first frame indexed by the hash table, frame (pLoc->iZero).
64369 int iHash, /* Find the iHash'th table */
64370 WalHashLoc *pLoc /* OUT: Hash table location */
64392 ** Return the number of the wal-index page that contains the hash-table
64421 ** Remove entries from the hash table that point to WAL slots greater
64427 ** At most only the hash table containing pWal->hdr.mxFrame needs to be
64433 WalHashLoc sLoc; /* Hash table location */
64445 /* Obtain pointers to the hash-table and page-number array containing
64447 ** that the page said hash-table and array reside on is already mapped.(1)
64454 /* Zero all hash-table entries that correspond to frame numbers greater
64474 ** via the hash table even after the cleanup.
64496 WalHashLoc sLoc; /* Wal-index hash table location */
64501 ** page number array and hash table entry.
64504 int iKey; /* Hash table key */
64505 int idx; /* Value to write to hash-table slot */
64511 /* If this is the first entry to be added to this hash-table, zero the
64512 ** entire hash table and aPgno[] array before proceeding.
64524 ** the hash-table before writing any new entries.
64531 /* Write the aPgno[] array entry and the hash-table slot. */
64540 /* Verify that the number of entries in the hash table exactly equals
64545 int nEntry = 0; /* Number of entries in the hash table */
64551 ** via the hash table. This turns out to be a really, really expensive
64855 ** This table also serves as a helpful cross-reference when trying to
66328 WalHashLoc sLoc; /* Hash table location */
66528 /* Search the hash table or tables for an entry matching page number
66530 ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
66534 ** table). This means the value just read from the hash
66544 ** if we had exclusive access to the hash-table:
66547 ** This condition filters out normal hash-table collisions.
66551 ** table after the current read-transaction had started.
66555 WalHashLoc sLoc; /* Hash table location */
67841 u8 intKey; /* True if table b-trees. False for index b-trees */
67842 u8 intKeyLeaf; /* True if the leaf of an intKey table */
67875 ** is opened on the table with root page BtShared.iTable. Locks are removed
67881 Pgno iTable; /* Root page of table */
67976 ** table (because there exists one or more read-locks on the table),
68008 u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */
68009 u16 minLeaf; /* Minimum local payload in a LEAFDATA table */
68135 ** because the table is empty or because BtreeCursorFirst() has not been
68147 ** The table that this cursor was opened on still exists, but has been
68191 ** The pointer map is a lookup table that identifies the parent page for
68457 ** a statement since we will be comparing table and column names
68696 ** shared-cache table level locks. If the library is compiled with the
68779 ** table with root page iRoot. Return 1 if it does and 0 if not.
68781 ** For example, when writing to a table with root-page iRoot via
68788 ** the corresponding table. This makes things a bit more complicated,
68789 ** as this module treats each table as a separate structure. To determine
68790 ** the table corresponding to the index being written, this
68793 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
68794 ** hold a write-lock on the schema table (root page 1). This is also
68826 /* Figure out the root-page that the lock should be held on. For table
68829 ** table. */
68851 ** write-lock on the schema table, or (if the client is reading) a
68872 ** table or index rooted at iRoot because other shared connections are
68873 ** simultaneously reading that same table or index.
68877 ** the iRoot table. Except, if the other Btree object has the
68881 ** For example, before writing to any part of the table or index
68902 ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return
68942 ** may hold a WRITE_LOCK on any table in this file (since there can
68962 ** Add a lock on the table with root-page iTable to the shared-btree used
68990 ** table, and that lock is obtained in BtreeBeginTrans(). */
68998 /* First search the list for an existing lock on this table. */
69007 ** with table iTable, allocate one and link it into the list.
69035 ** Release all the table locks (locks obtained via calls to
69149 ** This function is called before modifying the contents of a table
69154 ** table is about to be deleted. In this case invalidate all incrblob
69155 ** cursors open on any row within the table with root-page pgnoRoot.
69163 Pgno pgnoRoot, /* The table that might be changing */
69278 ** If the cursor is open on an intkey table, then the integer key
69280 ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
69291 /* Only the rowid is required for a table btree */
69357 ** the table with root-page iRoot. "Saving the cursor position" means that
69361 ** table, for example in BtreeDelete() or BtreeInsert().
69786 ** btreeParseCellPtr() => table btree leaf nodes
69787 ** btreeParseCellNoPayload() => table btree internal nodes
69947 ** cellSizePtrNoPayload() => table internal nodes
69948 ** cellSizePtrTableLeaf() => table leaf nodes
69949 ** cellSizePtr() => all index nodes & table leaf nodes
70537 ** interior table b-tree page. */
70540 ** leaf table b-tree page. */
70760 ** possible for a root page of a table that contains no rows) then the
71476 ** The call to sqlite3BtreeRollback() drops any table-locks held by
73136 ** cursors open with wrFlag==0 on the same table. Otherwise
73149 ** in which index entries are automatically deleted when corresponding table
73163 Pgno iTable, /* Root page of table to open */
73178 ** b-tree database, the connection is holding the required table locks,
73230 Pgno iTable, /* Root page of table to open */
73243 Pgno iTable, /* Root page of table to open */
73356 ** that is currently pointing to a row in a (non-empty) table.
73369 ** Return the value of the integer key or "rowid" for a table btree.
73371 ** ordinary table btree. If the cursor points to an index btree or
73410 ** currently pointing to. For table btrees, this will be the amount
73425 ** Return an upper bound on the size of any record for the table
73572 ** invalidated if some other cursor writes to the same table, or if
73578 ** * Creating a table (may require moving an overflow page).
73772 ** pCur can be pointing to either a table or an index b-tree.
73773 ** If pointing to a table btree, then the content section is read. If
73777 ** to a valid row in the table. For sqlite3BtreePayloadChecked(), the
73825 ** table btrees (pPage->intKey==1). The number of bytes of available
73964 ** If the table has a virtual root page, then the cursor is moved to point
73965 ** to the virtual root page instead of the actual root page. A table has a
73967 ** single child page. This can only happen with the table rooted at page 1.
73978 ** indicating a table b-tree, or if the caller did specify a KeyInfo
74028 ** NULL, the caller expects a table b-tree. If this is not the case,
74034 ** in such a way that page pRoot is linked into a second b-tree table
74112 /* Move the cursor to the first entry in the table. Return SQLITE_OK
74114 ** or set *pRes to 1 if the table is empty.
74134 /* Move the cursor to the last entry in the table. Return SQLITE_OK
74136 ** or set *pRes to 1 if the table is empty.
74180 /* Move the cursor so that it points to an entry in a table (a.k.a INTKEY)
74181 ** table near the key intKey. Return a success code.
74194 ** is smaller than intKey or if the table is empty
74205 i64 intKey, /* The table key */
74278 ** be the right kind (index or table) of b-tree page. Otherwise
74396 ** page of a table.
74408 /* Move the cursor so that it points to an entry in an index table
74422 ** is smaller than pIdxKey or if the table is empty
74432 ** exists an entry in the table that exactly matches pIdxKey.
74462 ** in the table and the pIdxKey search key is greater than or
74465 ** (2) If the cursor is on the last page of the table and the first
74522 ** be the right kind (index or table) of b-tree page. Otherwise
74640 ** Return TRUE if the cursor is not pointing at an entry of the table.
74643 ** past the last entry in the table or sqlite3BtreePrev() moves past
74644 ** the first entry. TRUE is also returned if the table is empty.
74647 /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
74655 ** Return an estimate for the number of rows in the table that pCur is
74777 ** SQLITE_DONE the cursor is already on the first element of the table
75836 ** For a table-btree (with rowids) the items 2 and 4 are empty because
75850 ** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
76689 /* Verify that all sibling pages are of the same "type" (table-leaf,
76690 ** table-interior, index-leaf, or index-interior).
76951 ** of the table is closer to a linear scan through the file. That in turn
77343 ** pointing to the same b-tree. If an insert occurs on one SQL table
77345 ** table linked to the same b-tree. If the secondary insert causes a
77347 ** first SQL table, violating invariants on the first insert.
77601 ** define what table the record should be inserted into, and is left
77604 ** For a table btree (used for rowid tables), only the pX.nKey value of
77629 BtCursor *pCur, /* Insert data into the table of this cursor */
77647 /* Save the positions of any other cursors open on this table.
77650 ** example, when inserting data into a table with auto-generated integer
77663 ** than one table or index with the same root page as used by the cursor.
77690 ** intkey table, the caller should be inserting integer keys with a
77696 /* If this is an insert into a table b-tree, invalidate any incrblob
77738 /* This is an index or a WITHOUT ROWID table */
77797 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
77890 ** entry in the table, and the next row inserted has an integer key
78049 ** associated with a single table entry and its indexes. Only one of those
78141 /* Save the positions of any other cursors open on this table before
78148 /* If this is a delete operation to remove a row from a table b-tree,
78256 ** Create a new BTree table. Write into *piTable the page
78257 ** number for the root page of the new table.
78271 int ptfFlags; /* Page-type flage for the root page of new table */
78287 /* Creating a new table may probably require moving an existing database
78295 ** root page of the new table should go. meta[3] is the largest root-page
78324 ** the new table (assuming an error did not occur). But we were
78424 BtShared *pBt, /* The BTree that contains the table */
78479 ** Delete all information from a single table in the database. iTable is
78480 ** the page number of the root of the table. After this routine returns,
78484 ** read cursors on the table. Open write cursors are moved to the
78485 ** root of the table.
78488 ** is incremented by the number of entries in the table.
78499 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
78500 ** is the root of a table b-tree - if it is not, the following call is
78512 ** Delete all information from the single table that pCur is open on.
78514 ** This routine only work for pCur on an ephemeral table.
78521 ** Erase all information in a table and add the root of the table to
78522 ** the freelist. Except, the root of the principle table (the one on
78526 ** cursors on the table.
78571 /* If the table being dropped is the table with the largest root-page
78580 /* The table being dropped does not have the largest root-page
79287 ** a table. nRoot is the number of entries in aRoot.
79299 ** happens when performing an integrity check on a single table. The
79556 ** sqlite_schema table. Otherwise SQLITE_OK.
79571 ** Obtain a lock on the table whose root page is iTab. The
79597 ** INTKEY table currently pointing at a valid table entry.
79620 /* Save the positions of all other cursors open on this table. This is
79624 ** Note that pCsr must be open on a INTKEY table and saveCursorPosition()
79625 ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence
79634 ** (c) the connection holds a write-lock on the table (if required),
79636 ** (e) the cursor points at a valid row of an intKey table.
80687 ** If a table contains a numeric value and an index is based on the
80690 ** that the index and table are consistent. See ticket
82122 ** on a table column definition, and hence only when pCtx==0. This
82330 ** in the sqlite_stat4 table.
83649 const char *zName /* Name of table or index being scanned */
84568 ** to 6.6 percent. The test case is inserting 1000 rows into a table
86229 ** the blob of data that it corresponds to. In a table record, all serial
86234 ** The following table describes the various storage classes for data:
86476 case 10: { /* Internal use only: NULL with virtual table
86641 ** This function compares two index or table record keys in the same way
87043 ** This function compares the two table rows or index records
87802 Table *pTab, /* Modified table */
88765 ** table, then it returns true if and only if the the call is during an
88770 ** xColumn method of a virtual table, then the return value is meaningless
88773 ** Virtual table implements might use this routine to optimize their
89191 ** 3 The name of the table that the column derives from
89192 ** 4 The name of the table column that the result column derives from
89295 ** Return the name of the table from which a result column derives.
89309 ** Return the name of the table column from which a result column derives.
90513 int nField, /* Number of fields in the table or index */
93478 ** table of P4.
93479 ** <li> Table P4 should be a STRICT table.
93613 ** use as a data record in a database table or as a key
93629 ** of the right-most table that can be null-trimmed.
93746 ** table methods that never invoke sqlite3_result_xxxxx() while
93947 ** Store the number of entries (an integer value) in the table or index
93951 ** every btree page of the table. But if P3 is non-zero, an estimate
94338 ** are queried from within xNext() and other v-table methods using
94341 ** v-table would have to be ready for the sqlite3_vtab structure itself
94343 ** a v-table method.
94441 ** Open a read-only cursor for the database table whose root page is
94458 ** object, then table being opened must be an [index b-tree] where the
94461 ** value, then the table being opened must be a [table b-tree] with a
94491 ** Open a read/write cursor named P1 on the table or index whose root
94497 ** object, then table being opened must be an [index b-tree] where the
94500 ** value, then the table being opened must be a [table b-tree] with a
94631 ** Open a new cursor P1 that points to the same ephemeral table as
94669 ** Open a new cursor P1 to a transient table.
94672 ** table is deleted automatically when the cursor is closed.
94674 ** If the cursor P1 is already opened on an ephemeral table, the table
94677 ** P2 is the number of columns in the ephemeral table.
94678 ** The cursor points to a BTree table if P4==0 and to a BTree index
94723 /* If the ephermeral table is already open and has no duplicates from
94724 ** OP_OpenDup, then erase all existing content so that the table is
94725 ** empty again, rather than creating a new table. */
94742 ** opening it. If a transient table is required, just use the
94743 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
94821 ** Open a new cursor that points to a fake table that contains a single
94826 ** A pseudo-table created by this opcode is used to hold a single
94829 ** is the only cursor opcode that works with a pseudo-table.
94832 ** the pseudo-table.
94870 ** table or index for cursor P1 are used. P4 is a 64-bit integer
94872 ** first 63 columns of the table or index that are actually used
94888 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
94915 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
94933 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
94951 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
95157 /* res might be negative because the table is empty. Check to
95600 ** P1 is the index of a cursor open on an SQL table btree (with integer
95624 ** P1 is the index of a cursor open on an SQL table btree (with integer
95726 ** Get a new integer record number (a.k.a "rowid") used as the key to a table.
95728 ** table that cursor P1 points to. The new record number is written
95740 VdbeCursor *pC; /* Cursor of table to get the new rowid */
95767 ** it already exists in the table. If it does not exist, we have
95837 ** an AUTOINCREMENT table. */
95863 ** Write an entry into the table of cursor P1. A new entry is
95900 VdbeCursor *pC; /* Cursor to table into which insert is written */
95983 ** of table - intkey or index. This opcode is used as part of copying
96013 ** record in the table. If it is left pointing at the next record, then
96020 ** delete one of several associated with deleting a table row and all its
96028 ** P1 must not be pseudo-table. It has to be a real table with
96195 ** a register that is the source for a pseudo-table cursor created using
96196 ** OpenPseudo. That pseudo-table cursor is the one that is identified by
96224 ** If cursor P2 is a table, then the content extracted is the data.
96227 ** of a real table, not a pseudo-table.
96233 ** position in order that they can write to the same table. If P3==0
96240 ** by any use of another cursor pointing to the same table.
96285 ** Store in register P2 an integer which is the key of the table entry that
96288 ** P1 can be either an ordinary table or a virtual table. There used to
96290 ** one opcode now works for both table types.
96382 ** will refer to the last entry in the database table or index.
96383 ** If the table or index is empty and P2>0, then jump immediately to P2.
96384 ** If P2 is 0 or if the table or index is not empty, fall through
96428 ** Estimate the number of rows in the table P1. Jump to P2 if that
96488 ** will refer to the first entry in the database table or index.
96489 ** If the table or index is empty, jump immediately to P2.
96490 ** If the table or index is not empty, fall through to the following
96532 ** table or index. If there are no more key/value pairs then fall through
96540 ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have
96556 ** table or index. If there is no previous key/value pairs then fall through
96565 ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is
96774 ** table. This opcode does a deferred seek of the P3 table cursor
96782 ** one entry for each column in the P3 table. If array entry a(i)
96794 ** the rowid of the table entry to which this index entry points.
96801 VdbeCursor *pTabCur; /* The P2 table cursor (OP_DeferredSeek only) */
96993 ** Delete an entire database table or index whose root page in the database
96996 ** The table being destroyed is in the main database file if P3==0. If
96997 ** P3==1 then the table to be clear is in the auxiliary database file
97005 ** table being dropped was already the last one in the database) then a
97053 ** Delete all contents of the database table or index whose root page
97055 ** remove the table or index from the database file.
97057 ** The table being clear is in the main database file if P2==0. If
97058 ** P2==1 then the table to be clear is in the auxiliary database file
97062 ** by the number of rows in the table being cleared. If P3 is greater
97064 ** by the number of rows in the table being cleared.
97090 ** Delete all contents from the ephemeral table or sorter
97118 ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table
97119 ** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table.
97156 ** Read and parse all entries from the schema table of database P1
97217 ** the sqlite_schema table is corrupt. */
97237 ** Read the sqlite_stat1 table for database P1 and load the content
97238 ** of that table into the internal index hash table. This will cause
97252 ** the table named P4 in database P1. This is called after a table
98249 ** Obtain a lock on a particular table. This instruction is only used when
98256 ** P2 contains the root-page of the table to lock.
98258 ** P4 contains a pointer to the name of the table being locked. This is only
98272 sqlite3VdbeError(p, "database table is locked: %s", z);
98285 ** xBegin method for that table.
98288 ** within a callback to a virtual table xSync() method. If it is, the error
98304 ** P2 is a register that holds the name of a virtual table in database
98305 ** P1. Call the xCreate method for that table.
98309 const char *zTab; /* Name of the virtual table */
98333 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
98334 ** of that table.
98349 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
98351 ** table and stores that cursor in P1.
98428 ** This opcode invokes the xFilter method on the virtual table specified
98487 ** the current row of the virtual-table of cursor P1.
98493 ** table implementation. The P5 column might also contain other
98545 ** Advance virtual table P1 to the next row in its result set and
98546 ** jump to instruction P2. Or, if the virtual table has reached
98569 ** some other method is next invoked on the save virtual table cursor.
98587 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
98623 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
98633 ** row. This can be NULL to have the virtual table select the new
99382 const char *zTable, /* The table containing the blob */
99422 sqlite3ErrorMsg(&sParse, "cannot open virtual table: %s", zTable);
99426 sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable);
99508 ** db/table/row entry. The reason for using a vdbe program instead
99543 /* Make sure a mutex is held on the table to be accessed */
99567 ** think that the table has one more column than it really
99734 ** database table.
102565 /* An instance of the bytecode() table-valued function.
102580 int iRowid; /* The rowid of the output table */
102593 ** Create a new bytecode() table-valued function.
102762 pCur->zType = "table";
102929 ** virtual table.
103563 ** symbols (e.g. a table that does not exist) in a window definition. */
103690 ** table and column.
103695 ** Magic table number to mean the EXCLUDED table in an UPSERT statement.
103782 ** Subqueries stores the original database, table and column names for their
103866 SrcItem *pMatch, /* Source table containing the column */
103888 ** pExpr->iTable Set to the cursor number for the table obtained
103892 ** pExpr->iColumn Set to the column number within the table.
103899 ** can be used. The zTable variable is the name of the table (the "Y"). This
103901 ** means that the form of the name is Z and that columns from any table
103909 const char *zDb, /* Name of the database containing table, or NULL */
103910 const char *zTab, /* Name of table containing column, or NULL */
103917 int cntTab = 0; /* Number of matching table names */
104008 /* An INNER or LEFT JOIN. Use the left-most table */
104012 /* A RIGHT JOIN. Use the right-most table */
104064 /* An INNER or LEFT JOIN. Use the left-most table */
104068 /* A RIGHT JOIN. Use the right-most table */
104107 ** a reference in the RETURNING clause to a table being modified.
104229 ** SELECT a+b AS x FROM table WHERE x<10;
104391 /* If a column from a table in pSrcList is referenced, then record
104399 ** avoid setting bits beyond the maximum column number of the table.
104403 ** of the table.
104614 ** Or table name and column name: ID.ID
104615 ** Or a database, table and column: ID.ID.ID
105498 /* Resolve names in table-valued-function arguments */
105602 ** table columns and result-set columns. At the same time, do error
105606 ** To resolve table columns references we look for nodes (or subtrees) of the
105612 ** Y: The name of a table in a FROM clause. Or in a trigger
105615 ** Z: The name of a column in table Y.
105760 ** Resolve names in expressions that can only reference a single table
105779 Table *pTab, /* The table being referenced, or NULL */
105835 ** Return the affinity character for a single column of a table.
106266 ** not be ready for evaluation because the table cursor has not yet
107984 ** when parsing an existing schema out of the sqlite_schema table and 4
108049 ** of the sqlite_schema table */
108108 ** for any single row of the table with cursor iCur. In other words, the
108110 ** table other than iCur.
108124 ** (1) pExpr cannot refer to any table other than pSrc->iCursor.
108389 ** that can be simplified to a direct table access, then return
108392 ** table, then return NULL.
108420 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
108435 ** Generate code that checks the left-most column of index table iCur to see if
108483 ** IN_INDEX_ROWID - The cursor was opened on a database table.
108487 ** populated epheremal table.
108494 ** SELECT <column1>, <column2>... FROM <table>
108497 ** an ephemeral table might need to be generated from the RHS and then
108498 ** pX->iTable made to point to the ephemeral table instead of an
108499 ** existing table. In this case, the creation and initialization of the
108500 ** ephmeral table might be put inside of a subroutine, the EP_Subrtn flag
108506 ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast
108512 ** An epheremal table will be created unless the selected columns are guaranteed
108517 ** for fast set membership tests) then an epheremal table must
108562 int eType = 0; /* Type of RHS table. IN_INDEX_* */
108563 int iTab; /* Cursor of the RHS table */
108587 /* Check to see if an existing table or index can be used to
108589 ** ephemeral table. */
108592 Table *pTab; /* Table <table>. */
108602 /* Code an OP_Transaction and OP_TableLock for <table>. */
108610 /* The "x IN (SELECT rowid FROM table)" case */
108625 ** comparison is the same as the affinity of each column in table
108627 ** use any index of the RHS table. */
108631 char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */
108727 ** then it is not worth creating an ephemeral table to evaluate
108741 /* Could not find an existing table or index to use as the RHS b-tree.
108742 ** We will have to generate an ephemeral table to do the job.
108843 ** Generate code that will construct an ephemeral table containing all terms
108851 ** constructed ephermeral table is returned. The first time the ephemeral
108852 ** table is computed, the cursor number is also stored in pExpr->iTable,
108924 /* Construct the ephemeral table that will contain the content of
108942 ** table allocated and opened above.
108985 ** store it in the temporary table. If <expr> is a column, then use
109023 /* Evaluate the expression and insert it into the temp table */
109264 ** IN_INDEX_NOOP is returned, the table opened with cursor iTab
109393 /* In this case, the RHS is the ROWID of table b-tree and so we also
109545 int iTabCur, /* Cursor pointing to a table row */
109591 ** Generate code to extract the value of the iCol-th column of a table.
109595 Table *pTab, /* The table containing the value */
109596 int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */
109644 ** table pTab and store the column value in register iReg.
109651 Table *pTab, /* Description of the table we are reading from */
109652 int iColumn, /* Index of the table column */
109653 int iTable, /* The cursor pointing to the table */
109971 ** datatype by applying the Affinity of the table column to the
110035 ** in the index refer to the table to which the index belongs */
110351 ** a virtual table column.
110355 ** see if it is a column in a virtual table. This is done because
110472 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
110473 ** is set to the column of the pseudo-table to read, or to -1 to
110478 ** to reference another column of the old.* pseudo-table, where
110480 ** set to (n+1), where n is the number of columns in each pseudo-table.
110481 ** For a reference to any other column in the new.* pseudo-table, p1
110483 ** example, if the table on which triggers are being fired is
110534 ** that derive from the right-hand table of a LEFT JOIN. The
110535 ** Expr.iTable value is the table number for the right-hand table.
110536 ** The expression is only evaluated if that table is not currently
111619 ** Expr.iTable<0 then assume a table number given by iTab.
111655 ** If the expression node requires that the table at pWalker->iCur
111714 ** is the column of a virtual table */
111751 ** one column of table iTab is non-null. In other words, return true
111767 ** clause requires that some column of the right table of the LEFT JOIN
111796 ** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
111797 ** is the cursor for the table.
111801 int iCur; /* Cursor number for the table corresponding to the index */
111805 ** Check to see if there are references to columns in table
111821 ** Determine if an index pIdx on table with cursor iCur contains will
111823 ** expression and false if the pExpr expression references table columns
111828 ** corresponding table entry.
111832 int iCur, /* The cursor number for the corresponding table */
111900 ** table is in neither RefSrcList.pRef nor RefSrcList.aiExclude.
111928 ** 1 pExpr does references a table in pSrcList.
111930 ** 0 pExpr references some table that is not defined in either
112086 /* If we reach this point, it means that pExpr refers to a table
112350 ** Parameter zName is the name of a table that is about to be altered
112352 ** If the table is a system table, this function leaves an error message
112355 ** Or, if zName is not a system table, zero is returned.
112366 sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
112411 ** identifiers) within the "sql" column of the sqlite_schema table in
112413 ** not true, similarly update all SQL statements in the sqlite_schema table
112452 SrcList *pSrc, /* The table to rename. */
112453 Token *pName /* The new table name. */
112455 int iDb; /* Database that contains the table */
112461 const char *zTabName; /* Original name of the table */
112474 /* Get a NULL terminated version of the new table name. */
112478 /* Check that a table or index named 'zName' does not already exist
112486 "there is already another table or index with this name: %s", zName);
112490 /* Make sure it is not a system table being altered, or a reserved name
112491 ** that the table is being renamed to.
112496 if( SQLITE_OK!=sqlite3CheckObjectName(pParse,zName,"table",zName) ){
112541 ** the schema to use the new table name. */
112550 /* Update the tbl_name and name columns of the sqlite_schema table
112556 "WHEN type='table' THEN %Q "
112562 "(type='table' OR type='index' OR type='trigger');",
112569 /* If the sqlite_sequence table exists in this database, then update
112570 ** it with the new table name.
112579 /* If the table being renamed is not itself part of the temp database,
112594 /* If this is a virtual table, invoke the xRename() function if
112596 ** of any resources used by the v-table implementation (including other
112597 ** SQLite tables) that are identified by the name of the virtual table.
112616 ** Write code that will raise an error if the table described by
112621 const char *zDb, /* Schema holding the table */
112747 "WHERE type = 'table' AND name = %Q",
112769 /* Reload the table definition */
112790 ** This function is called by the parser after the table-name in
112791 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
112792 ** pSrc is the full-name of the table being altered.
112795 ** for the table being altered and sets Parse.pNewTable to point
112812 /* Look up the table being altered. */
112844 ** table because user table are not allowed to have the "sqlite_"
112880 ** command. This function checks if the table is a view or virtual
112881 ** table (columns of views or virtual tables may not be renamed). If so,
112884 ** Or, if pTab is not a view or virtual table, zero is returned.
112896 zType = "virtual table";
112928 const char *zDb; /* Name of schema containing the table */
112932 /* Locate the table to be altered */
112936 /* Cannot alter a system table */
112940 /* Which schema holds the table to be altered */
112952 /* Make sure the old name really is a column name in the table to be
112970 ** CREATE statement text for the sqlite_schema table.
113011 ** * The name of a table column in Column.zName
113623 pParse->pTriggerTab = sqlite3FindTable(db, pNew->table,
113627 /* ALWAYS() because if the table of the trigger does not exist, the
113769 ** 1. type: Type of object ("table", "view" etc.)
113779 ** The iCol-th column (left-most is 0) of table zTable is renamed from zCol
113853 /* A regular table */
113996 ** of any foreign key constraints that use the table being renamed as the
113997 ** parent table. It is passed three arguments:
113999 ** 0: The database containing the table being renamed.
114000 ** 1. type: Type of object ("table", "view" etc.)
114003 ** 4: The old name of the table being renamed, and
114004 ** 5: The new name of the table being renamed.
114071 /* Modify any FK definitions to point to the new table. */
114086 /* If this is the table being altered, fix any table refs in CHECK
114110 if( 0==sqlite3_stricmp(sParse.pNewTrigger->table, zOld)
114113 renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);
114297 ** 2: Object type ("view", "table", "trigger" or "index").
114307 ** B. Else if a trigger is created and the the table that the trigger is
114379 ** argv[0]: An integer - the index of the schema containing the table
114413 /* This can happen if the sqlite_schema table is corrupt */
114449 ** table being edited, and token pName the name of the column to drop.
114459 /* Look up the table being altered. */
114466 /* Make sure this is not an attempt to ALTER a view, virtual table or
114467 ** system table. */
114499 /* Edit the sqlite_schema table */
114514 "WHERE (type=='table' AND tbl_name=%Q COLLATE nocase)"
114522 /* Edit rows of table on disk */
114632 ** The sqlite_stat2 table is not created or used unless the SQLite version
114634 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
114635 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
114650 ** name in the idx column. The tbl column is the name of the table to
114654 ** number of rows in the table, except for partial indices.) The second
114671 ** rows in the table identified by sqlite_stat1.tbl.
114677 ** 3.6.18 and 3.7.8. The "stat2" table contains additional information
114679 ** the "idx" column and the "tbl" column is the name of the table to which
114681 ** table for each index.
114696 ** writes the sqlite_stat2 table. This version of SQLite only supports
114707 ** As with sqlite_stat2, the sqlite_stat4 table contains histogram data
114712 ** The sqlite_stat4 table contains multiple entries for each index.
114713 ** The idx column names the index and the tbl column is the table of the
114740 ** The sqlite_stat3 table is like sqlite_stat4 except that it only
114761 ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now
114767 ** Argument zWhere may be a pointer to a buffer containing a table name,
114769 ** the sqlite_statN tables associated with the named table are deleted.
114770 ** If zWhere==0, then code is generated to delete all stat table entries.
114775 int iStatCur, /* Open the sqlite_stat1 table on this cursor */
114776 const char *zWhere, /* Delete entries for this table or index */
114817 /* The sqlite_statN table does not exist. Create it. Note that a
114819 ** of the new table in register pParse->regRoot. This is important
114828 /* The table already exists. If zWhere is not NULL, delete all entries
114829 ** associated with the table zWhere. If zWhere is NULL, delete the
114830 ** entire contents of the table. */
114843 /* The sqlite_stat[134] table already exists. Delete all rows. */
114878 i64 iRowid; /* Rowid in main table of the key */
114993 ** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the
114994 ** total number of columns in the table.
114998 ** PRIMARY KEY of the table. The covering index that implements the
114999 ** original WITHOUT ROWID table as N==K as a special case.
115181 ** iCol occurs many times in the table. However, if we have already
115394 #define STAT_GET_STAT1 0 /* "stat" column of stat1 table */
115417 ** stat1 table entry information.
115440 ** table for this index.
115556 int i; /* Index of column in the table */
115574 ** a single table.
115580 int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */
115592 u8 needTableCnt = 1; /* True to count the table */
115599 int regTabname = iMem++; /* Register containing table name */
115643 /* Establish a read-lock on the table at the shared-cache level.
115644 ** Open a read-only cursor on the table. Also allocate a cursor number
115712 ** the sqlite_stat4 table. */
115724 ** (or for a WITHOUT ROWID table, the number of PK columns),
115861 /* Add the entry to the stat1 table. */
115872 /* Add the entries to the stat4 table. */
115971 ** Generate code that will do an analysis of a single table in
116004 ** Form 3 analyzes all indices associated with the named table.
116034 /* Form 3: Analyze the table or index named as an argument */
116133 ** sqlite_stat1 table.
116135 ** argv[0] = name of the table
116140 ** the table.
116264 ** occur in the stat4 table for this index. Set sumEq to the sum of
116286 ** Look up an index by name. Or, if the name of a WITHOUT ROWID table
116287 ** is supplied instead, find the PRIMARY KEY index for that table.
116398 ** the sqlite_stat4 table. */
116432 ** Load content from the sqlite_stat4 table into
116459 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
116461 ** during compilation and the sqlite_stat4 table is present, no data is
116465 ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is
116467 ** table (if it is present) before returning.
116499 /* Load new statistics out of the sqlite_stat1 table */
116515 /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
116522 /* Load the statistics from the sqlite_stat4 table. */
117111 ** a specific database to all table references where the database name
117245 ** the table and the column that are being accessed. The auth function
117283 ** table zTab in database zDb. This function assumes that an authorization
117318 ** The pExpr should be a TK_COLUMN expression. The table referred to
117319 ** is in pTabList or else it is the NEW or OLD table of a trigger.
117330 SrcList *pTabList /* All table that pExpr might refer to */
117332 Table *pTab = 0; /* The table being read */
117333 const char *zCol; /* Name of the column of the table */
117334 int iSrc; /* Index in pTabList->a[] of table being read */
117336 int iCol; /* Index of column in table */
117344 ** temporary table. */
117490 int iDb; /* The database containing the table to be locked */
117491 Pgno iTab; /* The root page of the table to be locked */
117493 const char *zLockName; /* Name of the table */
117497 ** Record the fact that we want to lock a table at run-time.
117499 ** The table to be locked has root page iTab and is found in database iDb.
117508 int iDb, /* Index of the database containing the table to lock */
117509 Pgno iTab, /* Root page number of the table to be locked */
117511 const char *zName /* Name of the table to be locked */
117544 int iDb, /* Index of the database containing the table to lock */
117545 Pgno iTab, /* Root page number of the table to be locked */
117547 const char *zName /* Name of the table to be locked */
117555 ** Code an OP_TableLock instruction for each table locked by the
117695 ** obtain the required table-locks. This is a no-op unless the
117792 ** Return TRUE if zTable is the name of the system table that stores the
117802 ** table given the name of that table and (optionally) the name of the
117803 ** database containing the table. Return NULL if not found.
117805 ** If zDatabase is 0, all databases are searched for the table and the
117806 ** first matching table is returned. (No checking for duplicate table
117819 /* Only the admin user is allowed to know that the sqlite_user table
117882 ** table given the name of that table and (optionally) the name of the
117883 ** database containing the table. Return NULL if not found. Also leave an
117893 const char *zName, /* Name of the table we are looking for */
117910 /* If zName is the not the name of a table in the schema created using
117911 ** CREATE, then check to see if it is the name of an virtual table that
117912 ** can be an eponymous virtual table. */
117931 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
117945 ** Locate the table identified by *p.
117970 ** Return the preferred table name for system tables. Translate legacy
117992 ** table and the first matching index is returned. (No checking
118034 ** the index hash table and free all memory structures associated
118156 Table *pTab, /* The table containing the column */
118228 ** Delete memory allocated for the column names of a table or view (the
118260 ** the table data structure from the hash table. But it does destroy
118262 ** the table.
118288 /* Delete all indices associated with this table. */
118329 /* Do not delete the table until the reference count reaches zero. */
118338 ** Unlink the given table from the hash tables and the delete the
118339 ** table structure with all its indices and foreign keys.
118349 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
118397 ** Open the sqlite_schema table stored in database number iDb for
118398 ** writing. The table is opened using cursor 0.
118444 /* The table or view or trigger name is passed to this routine via tokens
118445 ** pName1 and pName2. If the table name was fully qualified, for example:
118450 ** the table name is not fully qualified, i.e.:
118457 ** pName2) that stores the unqualified table name. The index of the
118506 ** unqualified name for a new schema object (table, index, view or
118511 ** When parsing the sqlite_schema table, this routine also checks to
118519 const char *zTblName /* Parent table name for triggers and indexes */
118551 ** Return the PRIMARY KEY index of a table
118560 ** Convert an table column number into a index column number. That is,
118561 ** for the column iCol in the table (as defined by the CREATE TABLE statement)
118574 /* Convert a storage column number into a table column number.
118580 ** The storage column number is less than the table column number if
118597 /* Convert a table column number into a storage column number.
118602 ** the number of non-virtual columns in the table plus N.
118612 ** input column is a VIRTUAL table, put it after all the other columns.
118654 ** is used by CREATE TABLE IF NOT EXISTS and similar if the table already
118669 ** Begin constructing a new table representation in memory. This is
118672 ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp
118673 ** flag is true if the table should be stored in the auxiliary database
118678 ** The new table record is initialized and put in pParse->pNewTable.
118682 ** is called to complete the construction of the new table record.
118686 Token *pName1, /* First part of the name of the table or view */
118687 Token *pName2, /* Second part of the name of the table or view */
118688 int isTemp, /* True if this is a TEMP table */
118690 int isVirtual, /* True if this is a VIRTUAL table */
118691 int noErr /* Do nothing if table already exists */
118694 char *zName = 0; /* The name of the new table */
118697 int iDb; /* Database number to create the table in */
118698 Token *pName; /* Unqualified name of the table to create */
118710 /* If creating a temp table, the name may not be qualified. Unless
118712 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
118723 if( sqlite3CheckObjectName(pParse, zName, isView?"view":"table", zName) ){
118748 /* Make sure the new table name does not collide with an existing
118749 ** index or table name in the same database. Issue an error message if
118764 (IsView(pTable)? "view" : "table"), pName);
118797 /* Begin generating the code that will insert the table record into
118798 ** the schema table. Note in particular that we must go ahead
118799 ** and allocate the record number for the table entry now. Before any
118801 ** indices to be created and the table record must come before the
118802 ** indices. Hence, the record number for the table must be allocated
118834 /* This just creates a place-holder record in the sqlite_schema table.
118839 ** The root page number of the new table is left in reg pParse->regRoot.
118871 /* Set properties of a table column based on the (magical)
118960 ** Add a new column to the table currently being constructed.
119107 ** substrings in the following table. If one of the substrings is
119110 ** the table take priority. For example, if zType is 'BLOBINT',
119124 ** If none of the substrings in the above table are found,
119196 ** of the table currently under construction.
119287 ** Designate the PRIMARY KEY for the table. pList is a list of names
119289 ** most recently added column of the table is the primary key.
119291 ** A table can have at most one primary key. If the table already has
119297 ** field of the table under construction to be the index of the
119318 "table \"%s\" has more than one primary key", pTab->zName);
119379 ** Add a new CHECK constraint to the table currently under construction.
119412 ** Set the collation function of the most recently parsed table column
119578 ** table. Memory to hold the text of the statement is obtained
119674 ** Estimate the total row width for a table.
119718 ** PRIMARY KEY index. pIdx is an index on the same table. pIdx may
119752 ** columns that are within the first 63 columns of the table and a 1 for
119755 ** of the table have a 1.
119760 ** able to find all instances of a reference to the indexed table column
119762 ** the actual table at hand in order to recompute the virtual column, if
119788 ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
119794 ** (3) Bypass the creation of the sqlite_schema table entry
119796 ** identified by the sqlite_schema table entry of the table itself.
119798 ** schema to the rootpage from the main table.
119799 ** (5) Add all table columns to the PRIMARY KEY Index object
119839 /* Locate the PRIMARY KEY index. Or, if this table was originally
119840 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
119894 ** table entry. This is only required if currently generating VDBE
119902 /* The root page of the PRIMARY KEY is the table root page */
119939 /* Add all table columns to the PRIMARY KEY index
119965 ** Return true if pTab is a virtual table and zName is a shadow table name
119966 ** for that virtual table.
119970 Module *pMod; /* Module for the virtual table */
119986 ** Table pTab is a virtual table. If it the virtual table implementation
119993 Module *pMod; /* Module for the virtual table */
119994 HashElem *k; /* For looping through the symbol table */
120021 ** Return true if zName is a shadow table name in the current database
120045 ** they should not be changed. Expressions attached to a table or
120072 ** The table structure that other action routines have been building
120076 ** An entry for the table is made in the schema table on disk, unless
120077 ** this is a temporary table or db->init.busy==1. When db->init.busy==1
120078 ** it means we are reading the sqlite_schema table because we just
120079 ** connected to the database or because the sqlite_schema table has
120080 ** recently changed, so the entry for this table already exists in
120081 ** the sqlite_schema table. We do not want to create it again.
120084 ** was called to create a table generated from a
120086 ** the new table will match the result set of the SELECT.
120092 u32 tabOpts, /* Extra table options. Usually 0. */
120095 Table *p; /* The new table */
120097 int iDb; /* Database in which the table lives */
120098 Index *pIdx; /* An implied index of the table */
120111 ** "sqlite_schema" or "sqlite_temp_schema" table on the disk.
120113 ** for the table from the db->init.newTnum field. (The page number
120117 ** table itself. So mark it read-only.
120179 sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
120234 /* Estimate the average row size for the table and for all implied indices */
120240 /* If not initializing, then create a record for the new table
120241 ** in the schema table of the database.
120243 ** If this is a TEMPORARY table, write the entry into the auxiliary
120249 char *zType; /* "view" or "table" */
120259 ** Initialize zType for the new view or table.
120262 /* A regular table */
120263 zType = "table";
120274 ** statement to populate the new table. The root-page number for the
120275 ** new table is in register pParse->regRoot.
120279 ** by the new table.
120281 ** A shared-cache write-lock is not required to write to the new table,
120290 int regRec; /* A record to be insert into the new table */
120293 Table *pSelTab; /* A table that describes the SELECT results */
120348 ** schema table. We just need to update that slot with all
120367 /* Check to see if we need to create an sqlite_sequence table for
120387 /* Add the table to the in-memory representation of the database.
120403 /* If this is the magic sqlite_sequence table used by autoincrement,
120404 ** then record a pointer to this table in the main database structure
120405 ** so that INSERT can find the table easily. */
120503 /* Use sqlite3EndTable() to add the view to the schema table */
120523 Table *pSelTab; /* A fake table from which we get the result set */
120548 ** table is virtual or nCol is zero.
120573 /* If we get this far, it means we need to compute the table names.
120605 ** The names of the columns in the table are taken from
120607 ** normally holds CHECK constraints on an ordinary table, but for
120675 ** used by SQLite when the btree layer moves a table root page. The
120676 ** root-page of a table or index in database iDb has changed from iFrom
120679 ** Ticket #1728: The symbol table might still contain information
120682 ** have the same rootpage number as the real table or index that is
120685 ** or tables and not the table/index that is actually being moved.
120716 ** Write code to erase the table with root-page iTable from database iDb.
120717 ** Also write code to modify the sqlite_schema table and internal schema
120718 ** if a root-page of another table is moved by the btree-layer whilst
120729 ** is non-zero, then it is the root page number of a table moved to
120730 ** location iTable. The following code modifies the sqlite_schema table to
120746 ** Write VDBE code to erase table pTab and all associated indices on disk.
120748 ** in case a root-page belonging to another table is moved by the btree layer
120754 ** table and index root-pages in order, starting with the numerically
120804 const char *zName /* Name of index or table */
120821 ** Generate code to drop a table.
120839 /* Drop all triggers associated with the table being dropped. Code
120852 /* Remove any entries of the sqlite_sequence table associated with
120853 ** the table being dropped. This is done before the table is dropped
120854 ** at the btree level, in case the sqlite_sequence table needs to
120865 /* Drop all entries in the schema table that refer to the
120866 ** table. The program name loops through the schema table and deletes
120867 ** every row that refers to a table of the same name as the one being
120869 ** created in the temp database that refers to a table in another
120880 /* Remove the table entry from SQLite's internal schema and modify
120910 ** Return true if it is not allowed to drop the given table
120929 ** pName is the name of the table to be dropped.
120958 /* If pTab is a virtual table, call ViewGetColumnNames() to ensure
121000 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
121006 ** on a table.
121009 sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);
121018 /* Generate code to remove the table from the schema table
121036 ** This routine is called to create a new foreign key on the table
121038 ** in the current table point to the foreign key. If pFromCol==0 then
121040 ** the table referred to (a.k.a the "parent" table). pToCol is a list
121041 ** of tables in the parent pTo table. flags contains all
121045 ** An FKey structure is created and added to the table currently
121053 ExprList *pFromCol, /* Columns in this table that point to other table */
121054 Token *pTo, /* Name of the other table */
121055 ExprList *pToCol, /* Columns in the other table */
121075 " should reference only one column of table %T",
121083 "columns in the referenced table");
121163 /* Link the foreign key to the table as the last step.
121207 Table *pTab = pIndex->pTable; /* The table that is indexed */
121228 /* Require a write-lock on the table to perform this operation */
121246 /* Open the table. Loop through all rows of the table, inserting index
121289 ** a different order from the main table.
121362 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
121363 ** and pTblList is the name of the table that is to be indexed. Both will
121366 ** as the table to be indexed. pParse->pNewTable is a table that is
121371 ** to the table currently under construction.
121394 Db *pDb; /* The specific table containing the indexed database */
121419 ** Find the table that is to be indexed. Return early if not found.
121424 ** to search for the table. 'Fix' the table name to this db
121425 ** before looking up the table.
121433 /* If the index name was unqualified, check if the table
121434 ** is a temp table. If so, set the database to 1. Do not do this
121456 "cannot create a TEMP index on non-TEMP table \"%s\"",
121478 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
121496 ** index or table with the same name.
121499 ** sqlite_schema table (because some other process changed the schema) and
121500 ** one of the index names collides with the name of a temporary table or
121517 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
121566 ** key out of the last column added to the table under construction.
121635 ** a table column, store that column in aiColumn[]. For general expressions,
121639 ** TODO: Issue a warning if the table primary key is used as part of the
121709 /* Append the table key to the end of the index. For WITHOUT ROWID
121735 /* If this index contains every column of its table, then mark
121759 ** Either way, check to see if the table already has such an index. If
121819 /* Link the new Index structure to its table and to the other
121848 ** the index in the sqlite_schema table and populate the index with
121850 ** table to parse the schema, or if this index is the PRIMARY KEY index
121851 ** of a WITHOUT ROWID table.
121854 ** or UNIQUE index in a CREATE TABLE statement. Since the table
121871 ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
121974 ** number of rows in the table that match any particular value of the
121998 ** number of rows in the table, or half the number of rows in the table
122002 ** table but other parts we are having to guess at, then do not let the
122003 ** estimated number of rows in the table be less than 1000 (LogEst 99).
122077 /* Generate code to remove the index and from the schema table */
122280 ** Append a new table name to the given SrcList. Create a new SrcList if
122289 ** If pDatabase is not null, it means that the table has an optional
122290 ** database name prefix. Like this: "database.table". The pDatabase
122291 ** points to the table name and the pTable points to the database name.
122292 ** The SrcList.a[].zName field is filled with the table name which might
122301 ** Then B is a table name and the database name is unspecified. If called
122306 ** Then C is the table name and B is the database name. If C is defined
122318 Token *pDatabase /* Database of the table */
122404 ** are the name of the table and database named in the FROM clause term.
122418 Token *pTable, /* Name of the table to add to the FROM clause */
122421 Select *pSubquery, /* A subquery used in place of a table name */
122521 ** table-valued-function.
122555 ** code generator can easily tell that the table is part of
122752 ** inserting multiple rows in a table, or inserting a row and index entries.)
122848 Table *pTab /* The table with the non-unique rowid */
122914 Table *pTab; /* A table in the database */
122938 ** indices associated with the named table.
122943 char *z; /* Name of a table or index */
122945 Table *pTab; /* A table in the database */
122949 Token *pObjName; /* Name of the table or index to be reindexed */
123047 Token *pName, /* Name of the common-table */
123048 ExprList *pArglist, /* Optional column name list for the table */
123049 Select *pQuery, /* Query used to initialize the table */
123116 sqlite3ErrorMsg(pParse, "duplicate WITH table name: %s", zName);
123250 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
123254 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
123286 ** to the hash table).
123504 ** Insert a new FuncDef into a FuncDefHash hash table.
123608 ** new entry to the hash table and return it.
123717 ** the name of a single table, as one might find in an INSERT, DELETE,
123718 ** or UPDATE statement. Look up that table in the symbol table and
123719 ** return a pointer. Set an error message and return NULL if the table
123754 /* Return true if table pTab is read-only.
123756 ** A table is read-only if any of the following are true:
123758 ** 1) It is a virtual table and no implementation of the xUpdate method
123761 ** 2) A trigger is currently being coded and the table is a virtual table
123763 ** the table is not SQLITE_VTAB_INNOCUOUS.
123765 ** 3) It is a system table (i.e. sqlite_schema), this call is not
123769 ** 4) The table is a shadow table, the database connection is in
123788 sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"",
123808 ** Check to make sure the given table is writable.
123816 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
123831 ** Evaluate a view and store its result in an ephemeral table. The
123833 ** set of rows in the view that are to be added to the ephemeral table.
123841 int iCur /* Cursor number for ephemeral table */
123976 SrcList *pTabList, /* The table from which we should delete things */
123982 Table *pTab; /* The table from which records will be deleted */
123985 Index *pIdx; /* For looping over indices of the table */
123986 int iTabCur; /* Cursor number for the table */
123999 Index *pPk; /* The PRIMARY KEY index on the table */
124004 int iEphCur = 0; /* Ephemeral table holding all primary key values */
124008 int addrEphOpen = 0; /* Instruction to open the Ephemeral table */
124014 Trigger *pTrigger; /* List of table triggers, if required */
124026 /* Locate the table which we want to delete. This table has to be
124034 /* Figure out if we have any triggers and if the table being
124087 /* Assign cursor numbers to the table and all its indices.
124111 ** an ephemeral table.
124147 ** It is easier just to erase the whole table. Prior to version 3.6.5,
124186 /* For a rowid table, initialize the RowSet to an empty set */
124192 /* For a WITHOUT ROWID table, create an ephemeral table used to
124258 /* Add the PK key for this row to the temporary table */
124272 /* Unless this is a view, open cursors for the table we are
124352 /* Update the sqlite_sequence table by storing the content of the
124391 ** single table to be deleted. Both the original table entry and
124397 ** store for the table. (This will be either the table itself,
124398 ** in the case of a rowid table, or the PRIMARY KEY index in the case
124399 ** of a WITHOUT ROWID table.)
124480 /* Populate the OLD.* pseudo-table register array. These values will be
124515 ** refer to this table (i.e. constraints attached to other tables)
124520 /* Delete the index and table entries. Skip this step if pTab is really
124526 ** be invoked unless table pTab is a system table. The difference is that
124566 ** index entries associated with a single row of a single table, pTab
124571 ** btree for the table pTab. (This will be either the table itself
124585 int iDataCur, /* Cursor of table holding data. */
124619 ** iCur is the index of a cursor open on the pTab table and pointing to
124620 ** the entry that needs indexing. If pTab is a WITHOUT ROWID table, then
124644 ** on a table with multiple indices, and especially with the ROWID or
124689 ** might be stored in the table as an integer (using a compact
125227 ** routines in the function table. The noopFunc macro provides this.
126939 ** to the global function hash table. This occurs at start-time (as
127176 ** I.1) For each FK for which the table is the child table, search
127177 ** the parent table for a match. If none is found increment the
127180 ** I.2) For each FK for which the table is the parent table,
127181 ** search the child table for rows that correspond to the new
127182 ** row in the parent table. Decrement the counter for each row
127187 ** D.1) For each FK for which the table is the child table,
127188 ** search the parent table for a row that corresponds to the
127189 ** deleted row in the child table. If such a row is not found,
127192 ** D.2) For each FK for which the table is the parent table, search
127193 ** the child table for rows that correspond to the deleted row
127194 ** in the parent table. For each found increment the counter.
127222 ** TODO: How should dropping a table be handled? How should renaming a
127223 ** table be handled?
127269 ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
127270 ** Given that pParent is the parent table for foreign key constraint pFKey,
127281 ** array is the index of the child table column that is mapped by the FK
127282 ** constraint to the parent table column stored in the left-most column
127284 ** child table column that corresponds to the second left-most column of
127295 ** foreign key definition, and the parent table does not have a
127299 ** foreign key definition, and the PRIMARY KEY of the parent table
127301 ** the child table.
127309 Table *pParent, /* Parent table of FK constraint pFKey */
127311 Index **ppIdx, /* OUT: Unique index on parent table */
127325 ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
127336 ** mapped to the primary key of table pParent, or
127361 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
127372 ** map to an explicit list of columns in table pParent. Check if this
127420 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
127421 ** on the child table of pFKey, this function is invoked twice for each row
127426 ** row in the parent table that corresponds to the row being inserted into
127427 ** or deleted from the child table. If the parent row can be found, no
127429 ** found in the parent table:
127447 Table *pTab, /* Parent table of FK pFKey */
127450 int *aiCol, /* Map from parent key columns to child table columns */
127451 int regData, /* Address of array containing child table row */
127470 ** Check if any of the key columns in the child table row are NULL. If
127472 ** search for a matching row in the parent table. */
127485 ** column of the parent table (table pTab). */
127499 /* If the parent table is the same as the child table, and we are about
127526 /* If the parent table is the same as the child table, and we are about
127569 ** one row into the table, raise a constraint immediately instead of
127589 ** to column iCol of table pTab.
127597 Table *pTab, /* The table whose content is at r[regBase]... */
127598 int regBase, /* Contents of table pTab */
127624 ** Return an Expr object that refers to column iCol of table pTab which
127629 Table *pTab, /* The table whose column is desired */
127630 int iCursor, /* The open cursor on the table */
127645 ** from the parent table of foreign key constraint pFKey and, if pFKey is
127646 ** deferred, when a row is inserted into the same table. When generating
127655 ** table that correspond to the parent table row being deleted or inserted.
127673 SrcList *pSrc, /* The child table to be scanned */
127674 Table *pTab, /* The parent table */
127677 int *aiCol, /* Map from pIdx cols to child table cols */
127708 Expr *pLeft; /* Value from parent table row */
127709 Expr *pRight; /* Column ref to child table */
127711 i16 iCol; /* Index of column in child table */
127712 const char *zCol; /* Name of column in child table */
127724 /* If the child table is the same as the parent table, then add terms
127740 Expr *pLeft; /* Value from parent table row */
127741 Expr *pRight; /* Column ref to child table */
127788 ** FKey.pNextTo) holding all children of table pTab. For example,
127794 ** Calling this function with table "t1" as an argument returns a pointer
127795 ** to the FKey structure representing the foreign key constraint on table
127798 ** table).
127843 ** This function is called to generate code that runs when table pTab is
127846 ** table pTab.
127850 ** (a) The table is the parent table of a FK constraint, or
127851 ** (b) The table is the child table of a deferred FK constraint and it is
127856 ** the table from the database. Triggers are disabled while running this
127868 /* Search for a deferred foreign key constraint for which this table
127869 ** is the child table. If one cannot be found, return without
127912 ** for which pTab is the child table. An UPDATE statement against pTab
127913 ** is currently being processed. For each column of the table that is
127939 ** for which pTab is the parent table. An UPDATE statement against pTab
127940 ** is currently being processed. For each column of the table that is
127993 ** table pTab to generate VDBE code to perform foreign key constraint
128007 ** the original record is deleted from the table using the calling convention
128013 Table *pTab, /* Row is being deleted from this table */
128036 ** child table (the table that the foreign key definition is part of). */
128038 Table *pTo; /* Parent table of foreign key pFKey */
128053 /* Find the parent table of this foreign key. Also find a unique index
128054 ** on the parent key columns in the parent table. If either of these
128066 /* If isIgnoreErrors is true, then a table is being dropped. In this
128067 ** case SQLite runs a "DELETE FROM xxx" on the table being dropped
128069 ** If the parent table of an FK constraint on the current table is
128071 ** FK counter for each row of the current table with non-NULL keys.
128101 ** values read from the parent table are NULL. */
128111 /* Take a shared-cache advisory read-lock on the parent table. Allocate
128113 ** in the parent table. */
128118 /* A row is being removed from the child table. Search for the parent.
128124 /* A row is being added to the child table. If a parent row cannot
128138 /* Loop through all the foreign key constraints that refer to this table.
128153 /* Inserting a single row into a parent table cannot cause (or fix)
128164 /* Create a SrcList structure containing the child table. We need the
128165 ** child table as a SrcList for sqlite3WhereBegin() */
128194 ** child table to fire. In these cases the fk constraint counters
128212 ** row contained in table pTab.
128242 ** row contained in table pTab. If the operation is a DELETE, then
128244 ** to an array of size N, where N is the number of columns in table pTab.
128248 ** UPDATE statement modifies the rowid fields of the table.
128256 ** * There are any FKs for which pTab is the child and the parent table
128275 ** table in question is either the child or parent table for any
128305 ** compiled on table pTab, which is the parent table of foreign-key pFKey.
128316 ** For example, if pFKey is the foreign key and pTab is table "p" in
128350 char const *zFrom; /* Name of child table */
128353 int *aiCol = 0; /* child table cols -> parent key cols */
128367 Token tFromCol; /* Name of column in child table */
128368 Token tToCol; /* Name of column in parent table */
128369 int iFromCol; /* Idx of column in child table */
128383 ** parent table are used for the comparison. */
128538 ** refer to table pTab. If there is an action associated with the FK
128558 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
128559 ** hash table.
128570 /* Remove the FK from the fkeyHash hash table. */
128622 ** (1) acquire a lock for table pTab then
128625 ** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index
128626 ** for that table that is actually opened.
128630 int iCur, /* The cursor number of the table */
128632 Table *pTab, /* The table to be opened */
128658 ** the table, according to the affinity of the column:
128716 ** Compute an affinity string for a table. Space is obtained
128739 ** of values that are about to be gathered into a row for table pTab.
128744 ** Compute the affinity string for table pTab, if it has not already been
128822 ** Return non-zero if the table pTab in database iDb or any of its indices
128825 ** run without using a temporary table for the results of the SELECT.
128874 ** All regular columns for table pTab have been puts into registers
128883 Table *pTab /* The table */
128919 /* If an OP_TypeCheck was generated because the table is STRICT,
128982 ** Locate or create an AutoincInfo structure associated with table pTab
128985 ** table. (Also return zero when doing a VACUUM since we do not want to
128988 ** There is at most one AutoincInfo structure per table even if the
128989 ** same table is autoincremented multiple times due to inserts within
128991 ** first use of table pTab. On 2nd and subsequent uses, the original
128996 ** (1) The name of the pTab table.
129007 Table *pTab /* The table we are writing to */
129018 /* Verify that the sqlite_sequence table exists and is an ordinary
129019 ** rowid table with exactly two columns.
129042 pToplevel->nMem++; /* Register to hold name of table */
129058 Db *pDb; /* Database only autoinc table */
129126 ** table (either directly or through triggers) needs to call this
129182 Table *pDest, /* The table we are inserting into */
129195 ** The IDLIST following the table name is always optional. If omitted,
129196 ** then a list of all (non-hidden) columns for the table is substituted.
129211 ** open write cursor to <table> and its indices
129213 ** write the resulting record into <table>
129218 ** INSERT INTO <table> SELECT ...
129221 ** in other words if the SELECT pulls all columns from a single table
129229 ** open a write cursor to <table>
129231 ** transfer all records in <table2> over to <table>
129233 ** foreach index on <table>
129234 ** open a write cursor on the <table> index
129241 ** and the SELECT clause does not read from <table> at any time.
129253 ** B: open write cursor to <table> and its indices
129255 ** insert the select result into <table> from R..R+n
129260 ** values from a SELECT but the data is being inserted into a table
129262 ** we have to use an intermediate table to store the results of
129274 ** B: open temp table
129276 ** insert row from R..R+n into temp table
129278 ** M: open write cursor to <table> and its indices
129279 ** rewind temp table
129280 ** C: loop over rows of intermediate table
129281 ** transfer values form intermediate table into <table>
129287 SrcList *pTabList, /* Name of table into which we are inserting */
129294 Table *pTab; /* The table to insert into. aka TABLE */
129297 Index *pIdx; /* For looping over indices of the table */
129309 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
129311 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
129312 u8 bIdListInOrder; /* True if IDLIST is in table order */
129350 /* Locate the table into which we will be inserting new information.
129365 /* Figure out if we have any triggers and if the table being
129397 /* Cannot insert into a read-only table.
129431 /* If this is an AUTOINCREMENT table, look up the sequence number in the
129432 ** sqlite_sequence table and store it in memory cell regAutoinc.
129448 ** all elements of the IDLIST really are columns of the table and
129451 ** If the table has an INTEGER PRIMARY KEY column and that column
129455 ** is appears in the original table. (The index of the INTEGER
129456 ** PRIMARY KEY in the original table is pTab->iPKey.) After this
129458 ** is unspecified, and hence the table is either WITHOUT ROWID or
129497 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
129535 ** should be written into a temporary table (template 4). Set to
129537 ** the destination table (template 3).
129539 ** A temp table must be used if the table being updated is also one
129541 ** temp table in the case of row triggers.
129549 ** and add it to a transient table srcTab. The code generated
129552 ** B: open temp table
129554 ** insert row from R..R+n into temp table
129559 int regTempRowid; /* Register to hold temp table ROWID */
129594 /* If there is no IDLIST term but the table has an integer primary
129596 ** column index in the original table definition.
129615 ** of columns to be inserted into the table.
129627 "table %S has %d columns but %d values were supplied",
129648 /* If this is not a view, open the table and and all indices */
129662 aRegIdx[i] = ++pParse->nMem; /* Register to store the table record */
129668 sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
129702 ** rewind temp table, if empty goto D
129703 ** C: loop over rows of intermediate table
129704 ** transfer values form intermediate table into <table>
129715 ** insert the select result into <table> from R..R+n
129863 ** If this is a real table, attempt conversions as required by the
129864 ** table column affinities.
129953 ** constraints or (b) there are no triggers and this table is not a
129954 ** parent table in a foreign key constraint. It is safe to set the
130011 /* Update the sqlite_sequence table by storing the content of the
130115 ** the indexes of a table in the order provided in the Table->pIndex list.
130121 ** of a table in either Index.pNext order, or in some other order established
130179 ** on table pTab.
130185 ** case of a WITHOUT ROWID table. The second register in the range will
130186 ** contain the content of the first table column. The third register will
130187 ** contain the content of the second table column. And so forth.
130195 ** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)
130197 ** the iDataCur content table is guaranteed to be unchanged by the UPDATE.
130202 ** that the table is a WITHOUT ROWID table and has no rowid. On an INSERT,
130213 ** main table, if pTab is a rowid table, and stores that record in the
130221 ** table and all applicable indices (that is to say, all indices for which
130222 ** aRegIdx[] is not zero). iDataCur is the cursor for the main table when
130223 ** inserting or updating a rowid table, or the cursor for the PRIMARY KEY
130224 ** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor
130270 Table *pTab, /* The table being inserted or updated */
130272 int iDataCur, /* Canonical data cursor (main table or PK index) */
130305 Trigger *pTrigger; /* List of DELETE triggers on the table pTab */
130313 assert( !IsView(pTab) ); /* This table is not a VIEW */
130318 ** pPk index or 1 for a rowid table. In other words, nPkField is the
130319 ** number of fields in the true primary key of the table. */
130503 ** list of indexes attached to a table puts all OE_Replace indexes last
130611 ** exist in the table.
130665 /* Check to see if the new rowid already exists in the table. Skip
130687 /* If there are DELETE triggers on this table and the
130689 ** remove the conflicting row from the table. This will fire
130690 ** the triggers and remove both the table and index b-tree entries.
130693 ** flag is not set, but the table has one or more indexes, call
130695 ** only. The table b-tree entry will be replaced by the new entry
130707 ** table.
130759 ** WITHOUT ROWID table.
130829 ** of a WITHOUT ROWID table and there has been no change the
130860 ** (2) The table is a WITHOUT ROWID table
130861 ** (3) There are no secondary indexes on the table
130916 ** table, only conflict if the new PRIMARY KEY values are actually
131083 /* Generate the table record */
131100 ** to be the number of columns in table pTab that must not be NULL-trimmed.
131120 ** Table pTab is a WITHOUT ROWID table that is being written to. The cursor
131129 int iCur, /* Cursor number for table */
131156 Table *pTab, /* the table into which we are inserting */
131177 assert( !IsView(pTab) ); /* This table is not a VIEW */
131222 ** Allocate cursors for the pTab table and all its indices and generate
131226 ** the table itself, but the PRIMARY KEY index in the case of a WITHOUT
131227 ** ROWID table) is returned in *piDataCur. The first index cursor is
131234 ** For a rowid table, *piDataCur will be exactly one less than *piIdxCur.
131235 ** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range
131239 ** If pTab is a virtual table, then this routine is a no-op and the
131247 int iBase, /* Use this for the table cursor, if there is one */
131248 u8 *aToOpen, /* If not NULL: boolean for each table and index */
131371 ** Sometimes the xfer optimization will only work if the destination table
131374 ** does a test to see if the destination table is empty and jumps over the
131384 Table *pDest, /* The table we are inserting into */
131391 Table *pSrc; /* The table in the FROM clause of SELECT */
131408 ** attached to it. Proceeding may generate a false "no such table: xxx"
131414 return 0; /* tab1 must not be a virtual table */
131465 return 0; /* FROM clause does not contain a real table */
131469 return 0; /* tab1 and tab2 may not be the same table */
131475 return 0; /* tab2 may not be a view or virtual table */
131484 return 0; /* Cannot feed from a non-strict into a strict table */
131493 return 0; /* Neither table may have __hidden__ columns */
131581 /* Disallow the transfer optimization if the destination table constains
131599 ** table (tab1) is initially empty.
131621 ** only if the destination table is initially empty. Unless the
131624 ** table is always empty.
131706 ** that the destination table is empty. If all indexed columns use
132289 /* handle after drop table done */
132617 /* handle after drop table done */
133558 ** object. This ensures that the aPragmaName[] table is arranged in
133638 /* 2 */ "table",
133680 /* 43 */ "table", /* Used by: foreign_key_check */
134722 /* Locate the pragma in the lookup table */
135407 ** PRAGMA table_info(<table>)
135409 ** Return a single row for each column of the named table. The columns of
135473 ** Return a single row for each table, virtual table, or view in the
135476 ** schema: Name of attached database hold this table
135477 ** name: Name of the table itself
135478 ** type: "table", "view", "virtual", "shadow"
135480 ** wr: True for a WITHOUT ROWID table
135481 ** strict: True for a STRICT table
135495 ** for a table, that can potentially disrupt the hash table, so restart
135534 zType = "table";
135582 ** WITHOUT ROWID table named zRight, and if there is, show the
135583 ** structure of the PRIMARY KEY index for that table. */
135750 Table *pTab; /* Child table contain "REFERENCES" keyword */
135751 Table *pParent; /* Parent table that child points to */
135752 Index *pIdx; /* Index in the parent table */
135755 HashElem *k; /* Loop counter: Next table in schema */
135893 ** Or, the parameter N can be the name of a table. In that case, only
135894 ** the one table named is verified. The freelist is only verified if
135895 ** the named table is "sqlite_schema" (or one of its aliases).
135904 Table *pObjTab = 0; /* Check only this one table, if not NULL */
135944 int mxIdx = 0; /* Maximum number of indexes for any table */
135959 Table *pTab = sqliteHashData(x); /* Current table */
136008 int bStrict; /* True for a STRICT table */
136024 /* reg[7] counts the number of entries in the table.
136036 /* Fetch the right-most column from the table. This will cause
136221 /* Verify that an index entry exists for the current table row */
136397 ** creating or dropping a table or index). The schema version is used by
136564 ** In the current implementation, a table is analyzed if only if all of
136570 ** more indexes of the table at some point during the lifetime of
136573 ** (3) One or more indexes of the table are currently unanalyzed OR
136574 ** the number of rows in the table has increased by 25 times or more
136582 int iTabCur; /* Cursor for a table whose size needs checking */
136585 Table *pTab; /* A table in the schema */
136586 Index *pIdx; /* An index of the table */
136605 /* If table pTab has not been used in a way that would benefit from
136610 /* Reanalyze if the table is 25 times larger than the last analysis */
136831 ** Implementation of an eponymous virtual table that runs a pragma.
136851 ** Pragma virtual table module xConnect method.
136913 ** Pragma virtual table module xDisconnect method.
136921 /* Figure out the best index to use to search a pragma virtual table.
136964 /* Create a new cursor for the pragma virtual table */
136975 /* Clear all content from pragma virtual table cursor. */
136986 /* Close a pragma virtual table cursor */
136994 /* Advance the pragma virtual table cursor to the next row */
137011 ** Pragma virtual table module xFilter method.
137061 ** Pragma virtual table module xEof method.
137087 ** Pragma virtual table module xRowid method.
137095 /* The pragma virtual table object */
137098 0, /* xCreate - create a table */
137099 pragmaVtabConnect, /* xConnect - connect to an existing table */
137101 pragmaVtabDisconnect, /* xDisconnect - Disconnect from a table */
137102 0, /* xDestroy - Drop a table */
137116 0, /* xRename - rename the table */
137125 ** then register an eponymous virtual table for that pragma and return
137126 ** a pointer to the Module object for the new virtual table.
137200 ** Check to see if any sibling index (another index on the same table)
137231 ** argv[0] = type of object: "table", "index", "trigger", or "view".
137233 ** argv[2] = associated table if an index or trigger
137234 ** argv[3] = root page number for table or index. 0 for trigger or view.
137263 ** structures that describe the table, index, or view.
137365 ** table name will be inserted automatically by the parser so we can just
137367 ** the schema table as read-only. */
137368 azArg[0] = "table";
137544 ** table even when its contents have been corrupted.
137688 ** expr.c is trying to resolve a reference to a transient table (i.e. one
138009 ** locked the sqlite3_schema table, return SQLITE_LOCKED. If any other error
138236 int tabTnct; /* Ephemeral table used for DISTINCT processing */
138251 ** retrieve the associated "bigblob" values directly from table t1 as the
138255 ** aDefer[] array for each database table that may be read as values are
138273 int iCsr; /* Cursor number for table */
138274 int nKey; /* Number of PK columns for table pTab (>=1) */
138520 ** Return the index of a column in a table. Return -1 if the column
138521 ** is not contained in the table.
138551 ** table that has a column named zCol. The search is left-to-right.
138554 ** When found, set *piTab and *piCol to the table index and column index
138604 ** expression depends on table w.iJoin even if that table is not
138648 ** if the table that p references is on the left side of a RIGHT JOIN.
138688 ** The left most table is the first entry in Select.pSrc. The right-most
138689 ** table is the last entry. The join operator is held in the entry to
138699 SrcItem *pLeft; /* Left table being joined */
138700 SrcItem *pRight; /* Right table being joined */
138723 char *zName; /* Name of column in the right table */
138778 ** JOINs. If only a single table on the left side of this join
138958 KeyInfo *pKI; /* Original KeyInfo on the sorter table */
139058 ** Build an ephemeral table that contains all entries seen before and
139061 ** Parameter iTab is the cursor number of an ephemeral table that must
139063 ** The ephemeral cursor table is queried for a record identical to the
139072 ** table is not required. Instead, the current set of values
139168 ** The ephemeral table is not needed. So change the
139173 ** The ephemeral table is not needed. But we do need register
139216 ** the row from table t1 is stored instead. Then, as records are extracted from
139218 ** retrieved directly from table t1. If the values are very large, this
139302 int srcTab, /* Pull data from this table if non-negative */
139368 ** there are columns in the table on the left. The error will be caught
139494 ** table iParm.
139508 ** the temporary table iParm.
139537 ** output table as well. */
139569 ** aggregates do. Don't record that empty row in the output table. */
139586 ** item into the set table with bogus data.
140126 /* The expression is a column. Locate the table the column is being
140127 ** extracted from in NameContext.pSrcList. This table may be real
140128 ** database table or a subquery.
140167 /* The "table" is actually a sub-select or a view in the FROM clause
140190 /* A real table or a CTE table */
140313 ** refers directly to a table column, then the
140314 ** result column name is just the table column
140317 ** full=ON, short=ANY: If the result refers directly to a table column,
140318 ** then the result column name with the table name
140331 int fullName; /* TABLE.COLUMN if no AS clause and is a direct table ref */
140395 ** column names for a table that would hold the expression list.
140427 Hash ht; /* Hash table of column names */
140532 Table *pTab, /* Add column type information to this table */
140771 ** <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)
140776 ** There is exactly one reference to the recursive-table in the FROM clause
140780 ** into a Queue table. Rows are extracted from the Queue table one by
140782 ** extracted row (now in the iCurrent table) becomes the content of the
140783 ** recursive-table for a recursive-query run. The output of the recursive-query
140784 ** is added back into the Queue table. Then another row is extracted from Queue
140785 ** and the iteration continues until the Queue table is empty.
140788 ** inserted into the Queue table. The iDistinct table keeps a copy of all rows
140792 ** If the query has an ORDER BY, then entries in the Queue table are kept in
140794 ** an ORDER BY, the Queue table is just a FIFO.
140809 int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
140815 int iCurrent = 0; /* The Current table */
140816 int regCurrent; /* Register holding Current table */
140817 int iQueue; /* The Queue table */
140820 SelectDest destQueue; /* SelectDest targetting the Queue table */
140848 /* Locate the cursor number of the Current table */
140857 ** the Distinct table must be exactly one greater than Queue in order
140879 VdbeComment((v, "Queue table"));
140892 ** iDistinct table. pFirstRec is left pointing to the left-most
140936 ** the value for the recursive-table. Store the results in the Queue.
141079 /* Create the destination temporary table if necessary
141167 int unionTab; /* Cursor number of the temp table holding result */
141178 /* We can reuse a temporary table generated by a SELECT to our
141184 /* We will need to create our own temporary table to hold the
141236 /* Convert the data in the temporary table into whatever form
141279 /* Code the SELECTs to our left into temporary table "tab1".
141288 /* Code the current SELECT into temporary table "tab2"
141969 ** All references to columns in table iTable are to be replaced by corresponding
141980 ** Suppose the original expression is an integer constant. Even though the table
141983 ** that checks to see if the nullRow flag is set on the table. If the nullRow
142002 int iTable; /* Replace references to this table */
142003 int iNewTable; /* New table number */
142015 ** a column in table number iTable with a copy of the iColumn-th
142023 ** changes to pExpr so that it refers directly to the source table
142314 ** subquery first and store the results in a temporary table, then
142315 ** run the outer query on that temporary table. This requires two
142316 ** passes over the data. Furthermore, because the temporary table
142327 ** exist on the table t1, a complete scan of the data might be
142346 ** table and
142363 ** table sqlite_once that consists of a single row containing a
142488 int iParent; /* VDBE cursor number of the pSub result set temp table */
142489 int iNewParent = -1;/* Replacement table for iParent */
143241 ** (2) The inner query is the recursive part of a common table expression.
143251 ** of a LEFT JOIN where iCursor is not the right-hand table of that
143449 ** where table is a database table, not a sub-select or view. If the query
143455 ** this routine returns NULL when it could have returned a table pointer.
143601 ** Check to see if the FROM clause term pFrom has table-valued function
143603 ** non-zero, since pFrom is not allowed to be a table-valued function.
143616 ** WITH contexts, from inner to outermost. If the table identified by
143617 ** FROM clause element pItem is really a common-table-expression (CTE)
143618 ** then return a pointer to the CTE definition for that table. Otherwise
143735 int iRecTab = -1; /* Cursor for recursive table */
143801 "multiple references to recursive table: %s", pCte->zName
143843 sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
143875 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
143969 ** If found, expand each "*" to be every column in every table
144014 /* Look up every table named in the FROM clause of the select. If
144015 ** an entry of the FROM clause is a subquery instead of a table or view,
144016 ** then create a transient table structure to describe the subquery.
144039 /* An ordinary table or view name in the FROM clause */
144074 sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"",
144241 ** using clause from the table on the right. */
144301 sqlite3ErrorMsg(pParse, "no such table: %s", zTName);
144805 if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */
144976 ** as part of populating the temp table for an UPDATE...FROM statement.
145033 ** to a real table */
145036 /* Convert LEFT JOIN into JOIN if there are terms of the right table
145117 ** are output, rather than every row of the table.
145215 ** The fake column name is an empty string. It is possible for a table to
145217 ** distinguish between an unreferenced table and an actual reference to the
145305 ** the make the pItem->iCursor be a copy of the ephemerial table that
145393 ** The second form is preferred as a single index (or temp-table) may be
145395 ** written the query must use a temp-table for at least one of the ORDER
145396 ** BY and DISTINCT, and an index or separate temp-table for the other.
145443 /* If the output is destined for a temporary table, open that table.
145784 ** we do not have to sort. The OP_OpenEphemeral table will be
145840 /* If the index or temporary table used by the GROUP BY sort
145842 ** clause, cancel the ephemeral table open coded earlier.
145969 ** where the Table structure returned represents table <tbl>.
145972 ** OP_Count instruction is executed either on the intkey table that
145973 ** contains the data for table <tbl> or on one of its indexes. It
146161 /************** Begin file table.c *******************************************/
146199 ** This routine is called once for each row in the result table. Its job
146274 ** Instead, the entire table should be passed to sqlite3_free_table() when
146280 char ***pazResult, /* Write the result table here */
146361 /************** End of table.c ***********************************************/
146399 ** Given table pTab, return a list of all the triggers attached to
146400 ** the table. The list is connected by Trigger.pNext pointers.
146413 Schema *pTmpSchema; /* Schema of the pTab table */
146424 && pTrig->table
146425 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
146436 pTrig->table = pTab->zName;
146472 SrcList *pTableName,/* The name of the table/view the trigger applies to */
146514 ** name on pTableName if we are reparsing out of the schema table
146521 /* If the trigger name was unqualified, and the table is a temp table,
146523 ** If sqlite3SrcListLookup() returns 0, indicating the table does not
146532 /* Ensure the table name matches database name and that the table exists */
146541 /* The table does not exist. */
146572 /* Do not create a trigger on a system table */
146574 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
146588 " trigger on table: %S", pTableName->a);
146622 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
146628 sqlite3RenameTokenRemap(pParse, pTrigger->table, pTableName->a[0].zName);
146654 ** Normally, whenever a table is dropped, all associated triggers are
146655 ** dropped too. But if a TEMP trigger is created on a non-TEMP table
146656 ** and the table is dropped by a different database connection, the
146659 ** "orphaned trigger" - a trigger whose associated table is missing.
146717 ** are read-only, and the trigger makes a change to a shadow table,
146726 "trigger \"%s\" may not write to shadow table \"%s\"",
146733 /* Make an entry in the sqlite_schema table */
146743 pTrig->table, z);
146760 pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);
146850 Token *pTableName, /* Name of the table into which we insert */
146895 Token *pTableName, /* Name of the table to be updated */
146935 Token *pTableName, /* The table from which rows are deleted */
146964 sqlite3DbFree(db, pTrigger->table);
147017 ** Return a pointer to the Table structure for the table that a trigger
147021 return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table);
147119 ** Return a list of all triggers on table pTab if there exists at least
147121 ** performed on the table, and, if that operation is an UPDATE, if at
147126 Table *pTab, /* The table the contains the triggers */
147189 Table *pTab, /* The table the contains the triggers */
147251 ** form "table.*".
147268 ** clause. The table that we are returning from is pTab.
147276 Table *pTab /* The table being updated */
147319 Table *pTab, /* The table to code triggers from */
147515 Table *pTab, /* The table pTrigger is attached to */
147629 Table *pTab, /* The table trigger pTrigger is attached to */
147657 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
147664 Table *pTab, /* The table to code triggers from */
147695 ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
147705 ** in the trigger program. If N is the number of columns in table pTab
147735 Trigger *pTrigger, /* List of triggers on table pTab */
147739 Table *pTab, /* The table to code triggers from */
147752 /* Sanity checking: The schema for the trigger and for the table are
147753 ** always defined. The trigger must be in the same schema as the table
147779 ** Triggers may access values stored in the old.* or new.* pseudo-table.
147786 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
147788 ** are more than 32 columns in the table, and at least one of the columns
147795 ** applies to the old.* table. If 1, the new.* table.
147805 Trigger *pTrigger, /* List of triggers on table pTab */
147809 Table *pTab, /* The table to code triggers from */
147861 SrcList *pSrc, /* The virtual table to be modified */
147862 Table *pTab, /* The virtual table */
147873 ** i-th column of table pTab. This routine sets the P4 parameter of the
147877 ** column definition. This was either supplied by the user when the table
147878 ** was created, or added later to the table definition by an ALTER TABLE
147879 ** command. If the latter, then the row-records in the table btree on disk
147889 ** into the sqlite_schema table.)
147896 ** If column as REAL affinity and the table is an ordinary b-tree table
147897 ** (not a virtual table) then the value might have been stored as an
147933 ** aXRef[j] will be non-negative if column j of the original table is
147934 ** being updated. chngRowid will be true if the rowid of the table is
147963 ** aXRef[j] will be non-negative if column j of the original table is
147964 ** being updated. chngRowid will be true if the rowid of the table is
147981 ** table in the source-list (pSrc->a[0]).
147995 ** and write the results to the ephemeral table already opened as cursor
148008 ** Exactly how results are written to table iEph, and exactly what
148010 ** of table pTabList->a[0].pTab.
148012 ** If the table is a WITHOUT ROWID table, then argument pPk must be its
148014 ** of the table, in order. The results of the query are written to ephemeral
148015 ** table iEph as index keys, using OP_IdxInsert.
148017 ** If the table is actually a view, then <other-columns> are all columns of
148018 ** the view. The results are written to the ephemeral table iEph as records
148021 ** If the table is a virtual or ordinary intkey table, then <other-columns>
148022 ** is its rowid. For a virtual table, the results are written to iEph as
148025 ** remaining fields make up the table record.
148029 int iEph, /* Cursor for open eph. table */
148030 Index *pPk, /* PK if table 0 is WITHOUT ROWID */
148126 SrcList *pTabList, /* The table in which we should change things */
148135 Table *pTab; /* The table to be updated */
148147 int *aRegIdx = 0; /* Registers for to each index and the main table */
148149 ** an expression for the i-th column of the table.
148152 u8 chngPk; /* PRIMARY KEY changed in a WITHOUT ROWID table */
148153 u8 chngRowid; /* Rowid changed in a normal table */
148159 int iDb; /* Database containing the table being updated */
148172 int iEph = 0; /* Ephemeral table holding all primary key values */
148186 int regNew = 0; /* Content of the NEW.* table in triggers */
148187 int regOld = 0; /* Content of OLD.* table in triggers */
148199 /* Locate the table which we want to update.
148205 /* Figure out if we have any triggers and if the table being
148254 /* Allocate a cursors for the main database table and for all indices.
148399 ** So reset the colUsed mask. Unless this is a virtual table. In that
148401 ** table implementation makes all columns available).
148407 /* There is one entry in the aRegIdx[] array for each index on the table
148435 aRegIdx[nAllIdx] = ++pParse->nMem; /* Register storing the table record */
148450 ** table record is written. regRowSet holds the RowSet for the
148472 ** an ephemeral table.
148571 ** things might disturb a cursor being used to scan through the table
148618 ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change
148619 ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table
148757 ** table and index records, and as the values for any new.* references
148964 /* Update the sqlite_sequence table by storing the content of the
149004 ** Generate code for an UPDATE of a virtual table.
149007 ** "onepass" strategy. Onepass is only used if the virtual table
149010 ** The default strategy is to create an ephemeral table that contains
149017 ** Then loop through the contents of this ephemeral table executing a
149018 ** VUpdate for each row. When finished, drop the ephemeral table.
149020 ** The "onepass" strategy does not use an ephemeral table. Instead, it
149026 SrcList *pSrc, /* The virtual table to be modified */
149027 Table *pTab, /* The virtual table */
149043 int regRowid; /* Register for ephem table rowid */
149044 int iCsr = pSrc->a[0].iCursor; /* Cursor used for virtual table scan */
149050 ** create and open the ephemeral table in which the records created from
149098 /* Start scanning the virtual table */
149144 ** the ephemeral table. */
149159 /* End the virtual table scan */
149164 /* Begin scannning through the ephemeral table. */
149167 /* Extract arguments from the current row of the ephemeral table and
149178 /* End of the ephemeral table scan. Or, if using the onepass strategy,
149286 Table *pTab; /* That table into which we are inserting */
149324 /* The conflict-target is the rowid of the primary table */
149440 ** In this case parameter iCur is a cursor open on the table b-tree that
149441 ** currently points to the conflicting table row. Otherwise, if pIdx
149448 Table *pTab, /* The table being updated */
149804 " WHERE type='table'AND name<>'sqlite_sequence'"
149825 "WHERE type='table'AND coalesce(rootpage,1)>0",
149835 ** from the schema table.
149841 " OR(type='table'AND rootpage=0)",
149954 ** Before a virtual table xCreate() or xConnect() method is invoked, the
149961 VTable *pVTable; /* The virtual table being constructed */
149962 Table *pTab; /* The Table object to which the virtual table belongs */
149968 ** Construct and install a Module object for a virtual table. When this
150042 ** External API function used to create a new virtual-table module.
150057 ** External API function used to create a new virtual-table module.
150073 ** External API to drop all virtual-table modules, except those named
150111 ** Lock the virtual table so that it cannot be disconnected.
150115 ** If a disconnect is attempted while a virtual table is locked,
150124 ** pTab is a pointer to a Table structure representing a virtual-table.
150126 ** this virtual-table, if one has been created, or NULL otherwise.
150136 ** Decrement the ref-count on a virtual table object. When the ref-count
150159 ** Table p is a virtual table. This function moves all elements in the
150174 ** that contains table p is held by the caller. See header comments
150201 ** Table *p is a virtual table. This function removes the VTable object
150202 ** for table *p associated with database connection db from the linked
150227 ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
150239 ** associated with the database the virtual table is stored in is held
150240 ** or, if the virtual table is stored in a non-sharable database, then
150264 ** Clear any and all virtual-table information from the Table record.
150268 ** Since it is a virtual-table, the Table structure contains a pointer
150293 ** string will be freed automatically when the table is
150324 Token *pName1, /* Name of new table, or database name */
150325 Token *pName2, /* Name of new table or NULL */
150326 Token *pModuleName, /* Name of the module for the virtual table */
150327 int ifNotExists /* No error if the table already exists */
150329 Table *pTable; /* The new virtual table */
150352 /* Creating a virtual table invokes the authorization callback twice.
150354 ** sqlite_schema table, has already been made by sqlite3StartTable().
150355 ** The second call, to obtain permission to create the table, is made now.
150359 assert( iDb>=0 ); /* The database the table is being created in */
150369 ** virtual table currently under construction in pParse->pTable.
150385 Table *pTab = pParse->pNewTable; /* The table being constructed */
150395 ** first time (in other words if the virtual table is actually being
150398 ** in the sqlite_schema table.
150416 ** schema table. We just need to update that slot with all
150420 ** entry in the sqlite_schema table tht was created for this vtab
150426 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
150446 /* If we are rereading the sqlite_schema table create the in-memory
150447 ** record of the table. */
150489 ** Invoke a virtual table constructor (either xCreate or xConnect). The
150513 /* Check that the virtual-table is not already being initialized */
150541 /* Invoke the virtual table constructor */
150579 ** columns of the table to see if any of them contain the token "hidden".
150624 ** of the virtual table pTab. If an error occurs, an error code is returned
150627 ** This call is a no-op if table pTab is not a virtual table.
150641 /* Locate the required virtual table module */
150663 ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.
150685 ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should
150696 ** of the virtual table named zTab in database iDb.
150711 /* Locate the required virtual table module */
150739 ** This function is used to set the schema of a virtual table. It is only
150741 ** virtual table module.
150832 ** of the virtual table named zTab in database iDb. This occurs
150835 ** This call is a no-op if zTab is not a virtual table.
150946 ** If the virtual table pVtab supports the transaction interface
151001 ** as the second argument to the virtual table method invoked.
151005 ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
151008 ** If any virtual table method returns an error code other than SQLITE_OK,
151010 ** function immediately. If all calls to virtual table methods are successful,
151051 ** If pExpr is a column in a virtual table, then let the virtual
151052 ** table implementation have an opportunity to overload the function.
151054 ** This routine is used to allow virtual table implementations to
151075 /* Check to see the left operand is a column in a virtual table */
151088 /* Call the xFindFunction method on the virtual table implementation
151126 ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
151151 ** Check to see if virtual table module pMod can be have an eponymous
151152 ** virtual table instance. If it can, create one if one does not already
151153 ** exist. Return non-zero if either the eponymous virtual table instance
151157 ** An eponymous virtual table instance is one that is named after its
151159 ** statement in order to come into existance. Eponymous virtual table
151162 ** Any virtual table module for which xConnect and xCreate are the same
151163 ** method can have an eponymous virtual table instance.
151200 ** Erase the eponymous virtual table instance associated with
151201 ** virtual table module pMod, if it exists.
151206 /* Mark the table as Ephemeral prior to deleting it, so that the
151217 ** table update operation currently in progress.
151238 ** of the virtual table being implemented.
151381 int iTabCur; /* The VDBE cursor used to access the table */
151436 Bitmask maskSelf; /* Bitmask identifying table iTab */
151440 u8 iTab; /* Position in FROM clause of table for this loop */
151456 u32 bOmitOffset : 1; /* True to let virtual table handle offset */
151747 ** clause is processed, so that every table in a join is guaranteed to be
151924 #define WHERE_IDX_ONLY 0x00000040 /* Use index only - omit table */
152000 ** Argument pLevel describes a strategy for scanning table pTab. This
152001 ** function appends text to pStr that describes the subset of table
152042 ** is added to the output to describe the table scan strategy in pLevel.
152647 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
152841 int iTabCur; /* Cursor for the main table */
152843 Index *pIdx; /* The index used to access the table */
152849 ** the table CCurHint.iTabCur, verify that the same column can be
152866 ** should be included in the cursor-hint for a table that is on the rhs
152900 ** that accesses any table other than the one identified by
152909 ** Also, if the node is a TK_COLUMN that does access the table idenified
152912 ** an access of the index rather than the original table.
152978 ** JOIN for which the current table is not the rhs are omitted
152981 ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
153049 ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
153066 ** in the table. For each table column, if the column is the i'th
153072 ** the table cursor.
153251 int iCur; /* The VDBE cursor for the table */
153304 /* If this is the right table of a LEFT OUTER JOIN, allocate and
153305 ** initialize a memory cell that records if this table matches any
153306 ** row of the left table of the join.
153317 /* Compute a safe address to jump to if we discover that the table for
153337 /* Case 1: The table is a virtual-table. Use the VFilter and VNext
153954 /* Seek the table cursor, if required */
153958 /* pIdx is a covering index. No need to access the main table. */
153986 ** The OR-optimization doesn't work for the right hand table of
154049 ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then
154055 SrcList *pOrTab; /* Shortened table list or OR-clause generation */
154077 /* Set up a new SrcList in pOrTab containing the table being scanned
154146 ** The subquery might get coded as a subroutine. Any table-references
154203 /* Loop through table entries that match term pOrTerm. */
154241 /* Check if the temp table already contains this key. If so,
154244 ** insert the key into the temp table and proceed with processing
154249 ** the temp table. And if iSet is -1, assume that there is no
154250 ** need to insert the key into the temp table, as it will never
154276 ** contained one or more AND term from a notReady table. The
154277 ** terms from the notReady table could not be tested and will
154309 /* Finish the loop through table entries that match term pOrTerm. */
154345 ** scan of the entire table.
154515 /* pTab is the right-hand table of the RIGHT JOIN. Generate code that
154516 ** will record that the current row of that table has been matched at
154547 ** at least one row of the right table has matched the left table.
155038 ** In every case, "column" must be a column of a virtual table. If there
155042 ** appropriate virtual table operator. The return value is 1 or 2 if there
155044 ** of virtual table in forms (5) or (7) then return 2.
155076 ** virtual table on their second argument, which is the same as
155277 ** a single table T (as shown in example B above) then create a new virtual
155299 ** If all subterms are indexable by a single table T, then set
155302 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
155305 ** "T.C <op> <expr>" where C is any column of table T and
155461 ** something other than == on a column in the single table. The 1-bit
155463 ** "table.column=expr" for some single table. The one bit that is set
155464 ** will correspond to the common table. We still need to check to make
155471 ** Note that terms of the form "table.column1=table.column2" (the
155472 ** same table on both sizes of the ==) cannot be optimized.
155480 /* Search for a table and column that appears on one side or the
155481 ** other of the == operator in every subterm. That table and column
155483 ** such table and column. Set okToChngToIN if an appropriate table
155516 /* No candidate table+column was found. This can only occur
155525 /* We have found a candidate table and column. Check to see if that
155526 ** table and column is common to every term in the OR clause */
155664 ** number of the table that is indexed and aiCurCol[1] to the column number
155675 int *aiCurCol, /* Write the referenced table cursor and column here */
155700 int *aiCurCol, /* Write the referenced table cursor & column here */
155721 if( mPrereq==0 ) return 0; /* No table references */
155722 if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
155752 WhereMaskSet *pMaskSet; /* Set of table index masks */
155813 ** on left table of a LEFT JOIN. Ticket #3015 */
155819 /* The ON clause of an INNER JOIN references a table to its right.
156291 ** that object is a virtual table, and
156293 ** to the virtual table xBestIndex method.
156299 ** single virtual table in the FROM clause of the SELECT.
156499 ** For table-valued-functions, transform the function arguments into
156503 ** a HIDDEN column in the table.
156564 ** generating the code that loops through a table looking for applicable
156711 ** table and iaCur[1] gets the cursor used by an auxiliary index.
156833 ** There is one cursor per table in the FROM clause. The number of
156972 ** for terms of the form "X <op> <expr>" where X is column iColumn of table
156974 ** must be one of the indexes of table iCur.
157027 ** where X is a reference to the iColumn of table iCur or of index pIdx
157031 ** If pIdx!=0 then it must be one of the indexes of table iCur.
157033 ** rather than the iColumn-th column of table iCur.
157046 ** the form "X <op> Y" where Y is a column in another table if no terms of
157087 int iBase, /* Cursor for table associated with pIdx */
157148 /* If there is more than one table or sub-select in the FROM clause of
157155 /* If any of the expressions is an IPK column on table iBase, then return
157166 /* Loop through all indices on the table, checking each to see if it makes
157209 ** opcodes into OP_Copy when the table is being accessed via co-routine
157210 ** instead of via table lookup.
157220 int iTabCur, /* OP_Column/OP_Rowid references to this table */
157306 ** the right table of a RIGHT JOIN because the constraint implies a
157307 ** not-NULL condition on the left table of the RIGHT JOIN.
157383 Table *pTable; /* The table being indexed */
157418 ** rows of the target table (pSrc) that can be used. */
157456 ** original table never needs to be accessed. Automatic indices must
157458 ** original table changes and the index and table cannot both be used
157618 int iCur; /* Cursor for table getting the filter */
157636 ** estimated size of the table is larger. We could actually
157637 ** measure the size of the table at run-time using OP_Count with
157640 ** sqlite_stat1 table, testing is much easier.
157744 /* Find all WHERE clause constraints referring to this virtual table.
157773 ** virtual table then allocate space for the aOrderBy part of
157929 ** The table object reference passed as the second argument to this function
157930 ** must represent a virtual table. This function invokes the xBestIndex()
157931 ** method of the virtual table with the sqlite3_index_info object that
159156 ** table statistics.
159165 ** of rows in the table. In other words, assume that x==EXPR will filter
159174 LogEst nRow /* Number of rows in the entire table */
159196 ** that depend only on the table being scanned, and that will tend to
159197 ** cause many rows to be omitted, then mark that table as
159289 ** the right column of the right source table. And that the sort
159356 LogEst rSize; /* Number of rows in the table */
159357 LogEst rLogSize; /* Logarithm of table size */
159463 ** N = the total number of rows in the table
159465 ** M = the number of rows in the table that match terms to the
159603 ** to be true for half or more of the rows in the table.
159643 ** visiting the rows in the main table. */
159770 int iTab, /* The table for which we want an index */
159805 int iTabCur; /* Cursor number for the corresponding table */
159811 ** If the Expr node references the table with cursor pCk->iTabCur, then
159858 int iTabCur /* Cursor for the table being indexed */
159889 ** Add all WhereLoop objects for a single table of the join where the table
159890 ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be
159891 ** a b-tree table, not a virtual table.
159896 ** For a full scan, assuming the table (or index) contains nRow rows:
159898 ** cost = nRow * 3.0 // full-table scan
159903 ** estimated average size of the index and table records.
159922 ** of a full table scan.
159926 Bitmask mPrereq /* Extra prerequesites for using this table */
159939 LogEst rSize; /* number of rows in the table */
159962 Index *pFirst; /* First of real indices on the table */
159976 /* The real indices of the table are only considered if the
159991 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
159993 && !pSrc->fg.isRecursive /* Not a recursive common table expression. */
159997 LogEst rLogSize; /* Logarithm of the number of rows in the table */
160011 ** the table being indexed and where X is 7 (LogEst=28) for normal
160025 /* TUNING: Each index lookup yields 20 rows in the table. This
160071 /* Full table scan */
160073 /* TUNING: Cost of full table scan is 3.0*N. The 3.0 factor is an
160074 ** extra cost designed to discourage the use of full table scans,
160077 ** (to 2.75) if we have valid STAT4 information for the table.
160078 ** At 2.75, a full table scan is preferred over using an index on
160128 ** index and table rows. */
160132 ** doing table lookups. The cost will be 3x the number of
160135 ** table lookup. */
160146 ** the expected number of table lookups accordingly */
160193 ** Return true if pTerm is a virtual table LIMIT or OFFSET term.
160203 ** be used by the virtual table identified by pBuilder->pNew->iTab. This
160215 ** virtual table in question. These are added to the plans prerequisites
160273 /* Invoke the virtual table xBestIndex() method */
160279 ** Make no entries in the loop table.
160331 /* A virtual table that is constrained by an IN clause may not
160502 ** This is used by the (built-in) sqlite_dbpage virtual table.
160521 ** Add all WhereLoop objects for a table of the join identified by
160522 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
160526 ** entries that occur before the virtual table in the FROM clause and are
160529 ** virtual table and are separated from it by at least one LEFT or
160539 ** table. So any terms for which all prerequisites are satisfied by
160542 ** virtual table, so any terms for which the prerequisites overlap with
160621 ** in the set of terms that apply to the current virtual table. */
160789 ** the planner may elect to "OR" together a full-table scan and an
160926 int iColumn; /* A column number within table iCur */
160955 ** The rowid for a table is always UNIQUE and NOT NULL so whenever the
160994 /* Mark off any ORDER BY term X that is a column in the table of
161101 /* Get the column number in the table (iColumn) and sort order
161718 ** Most queries use only a single table (they are not joins) and have
161869 ** For a table to not affect the result, the following must be true:
161872 ** 2) The table must be the RHS of a LEFT JOIN.
161874 ** must contain a constraint that limits the scan of the table to
161876 ** 4) The table must not be referenced by any part of the query apart
161885 ** then table t2 can be omitted from the following:
161963 ** of rows in the table that is being considered for the Bloom
161969 ** (4) The size of the table being searched is known by ANALYZE.
162030 ** table.
162041 SrcItem *pTabItem /* The FROM clause entry for the table */
162092 ** The basic idea is to do a nested loop, one loop for each table in
162094 ** same as a SELECT with only a single table in the FROM clause.) For
162115 ** There are Btree cursors associated with each table. t1 uses cursor
162128 ** refer to those indices, a complete table scan can be avoided and the
162224 ** only generate code for the first table in pTabList and assume that
162297 ** a table T, then X-1 is the bitmask for all other tables to the left of T.
162506 ** * the table is not a virtual table, and
162541 int iDb; /* Index of database containing table/index */
162612 ** WITHOUT ROWID table. No need for a separate index */
162763 ** index rather than the main table. In SQLITE_DEBUG mode, we want
162824 ** the RIGHT JOIN table */
162991 /* For a co-routine, change all OP_Column references to the table of
163003 ** from the index instead of from the table where possible. In some cases
163004 ** this optimization prevents the table from ever being read, which can
163008 ** sqlite3WhereEnd will have created code that references the table
163010 ** that reference the table and converts them into opcodes that
163079 /* Unable to translate the table reference into an index
163081 ** table being referenced really is open.
163220 ** temp table Window.iEphCsr.
163224 ** in a temp table before returning any rows. In other cases it does not.
163979 ** with a TK_COLUMN that reads the (N-1)th element of table
164141 /* Assign a cursor number for the ephemeral table used to buffer rows.
164143 ** many columns the table will have. */
164233 /* Defer deleting the temporary table pTab because if an error occurred,
164234 ** there could still be references to that table embedded in the
164551 ** table and 3 registers. The registers are used as follows:
164680 ** that it processes in a temporary table. If it is not zero, this
164681 ** variable indicates when rows may be removed from the temp table (in
164702 ** table, sorted by "a, b" (it actually populates the cache lazily, and
164704 ** a mere detail). It keeps three cursors open on the temp table. One
165145 ** Return true if the current frame should be cached in the ephemeral table,
165409 ** temporary table. It otherwise might, if (a>b). Also ensure that,
165587 ** Insert new row into eph table.
165590 ** // Rewind three cursors, all open on the eph table.
165598 ** // First time this branch is taken, the eph table contains two
165639 ** csrCurrent and csrEnd) iterate through the ephemeral table. Cases that
165649 ** Insert new row into eph table.
165677 ** Insert new row into eph table.
165721 ** Insert new row into eph table.
165755 ** Insert new row into eph table.
165762 ** delete eph table contents
165774 ** added to the ephemeral table is the start of a new group. In
165781 ** Insert new row into eph table.
165806 ** Insert new row into eph table.
165842 ** Insert new row into eph table.
165872 ** Insert new row into eph table.
165913 int csrWrite; /* Cursor used to write to eph. table */
165956 /* Figure out when rows may be deleted from the ephemeral table. There
165990 ** into the ephemeral table. */
166049 /* Insert the new row into the ephemeral table */
166792 ** slots in the yy_action[] table.
166797 ** The action table is constructed as a single large table named yy_action[].
166813 ** yy_action[] A single table containing all actions.
166814 ** yy_lookahead[] A table containing the lookahead for each entry in
167438 /* The next table maps tokens (terminal symbols) into fallback tokens.
167725 ** are required. The following table supplies these names */
169908 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
169918 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
170967 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
171343 /* There are no SHIFTREDUCE actions on nonterminals because the table
171702 ** using a lookup table, whereas a switch() directly on c uses a binary search.
171703 ** The lookup table is much faster. To maximize speed, and to ensure that
171704 ** a lookup table is used, all of the classes need to be small integers and
171836 ** might be implemented more directly using a hand-written hash table.
171988 /* Hash table decoded:
172869 /* If the pParse->declareVtab flag is set, do not delete any table
174057 ** full table scans in the query optimizer. */
174653 ** SQL statements below, as the v-table implementation may be storing
174734 HashElem *i; /* Hash table iterator */
174854 ** but are "saved" in case the table pages are moved around.
175025 /* SQLITE_LOCKED */ "database table is locked",
175089 int count /* Number of times table has been busy */
175289 ** to the hash table.
175523 ** Declare that a function has been overloaded by a virtual table.
175972 ** following table describes the relationship between these two values
177241 ** Return meta information about a specific column of a database table.
177281 /* Locate the table in question */
177290 /* Query for existance of table only */
177316 ** 2. The table is not a view and the column name identified an
177348 zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName,
177740 ** and tbl_name fields of the sqlite_schema table. This is normally
177802 ** table should connect.
177805 ** run a single CREATE TABLE statement to construct the imposter table in
178843 ** the %_segments table in sorted order. This means that when the end
178907 ** The segment directory in table %_segdir stores meta-information for
178947 ** leaf nodes are written in to the %_segments table in order, this
179075 ** When an fts3 table is created, it passes any arguments passed to
179080 ** be used for the fts3 table (customized by the tokenizer clause arguments).
179102 ** TABLE statement that created the fts3 table. For example, if
179218 ** This is the header file for the generic hash-table implementation
179220 ** hash table implementation for the full-text indexing module.
179230 /* A complete hash table is an instance of the following structure.
179241 int count; /* Number of entries in this table */
179243 int htsize; /* Number of buckets in the hash table */
179244 struct _fts3ht { /* the hash table */
179250 /* Each element in the hash table is an instance of the following
179257 Fts3HashElem *next, *prev; /* Next and previous elements in the table */
179263 ** There are 2 different modes of operation for a hash table:
179296 ** Macros for looping over all elements of a hash table. The idiom is
179314 ** Number of entries in a hash table
179344 ** Fts3Table.pendingTerms hash table. Normally, the hash table is
179348 ** segment is created and the hash table cleared immediately.
179514 const char *zName; /* virtual table name */
179515 int nColumn; /* number of named columns in virtual table */
179526 ** statements is run and reset within a single virtual table API call.
179536 u8 bHasStat; /* True if %_stat table exists (2==unknown) */
179537 u8 bHasDocsize; /* True if %_docsize table exists */
179541 char *zSegmentsTbl; /* Name of %_segments table */
179542 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
179550 ** A single FTS4 table may have multiple full-text indexes. For each index
179556 ** pending data structures, including hash table overhead, but not including
179564 Fts3Hash hPending; /* Pending terms table for this index */
179574 ** methods of the virtual table are called at appropriate times. These
179600 ** When the core wants to read from the virtual table, it creates a
179601 ** virtual table cursor (an instance of the following structure) using
179622 sqlite3_int64 nDoc; /* Documents in table */
179648 #define FTS3_FULLSCAN_SEARCH 0 /* Linear scan of %_content table */
179649 #define FTS3_DOCID_SEARCH 1 /* Lookup by rowid on %_content table */
179722 ** where nCol is the number of columns in the queried FTS table. The array
179954 Fts3Hash hash; /* Hash table */
180169 ** The xDisconnect() virtual table method.
180235 ** The xDestroy() virtual table method.
180266 ** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
180285 /* Create a list of user columns for the virtual table */
180309 ** Create the %_stat table if it does not already exist.
180322 ** required by the FTS3 table passed as the only argument. This is done
180326 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
180336 char *zContentCols; /* Columns of %_content table */
180338 /* Create a list of user columns for the content table */
180349 /* Create the content table */
180515 ** table has the three user-defined columns "a", "b", and "c", the following
180567 ** of columns in the %_content table (one for the docid plus one for each
180572 ** bracket. For example, if zFunc is "zip" and the FTS3 table has three
180654 ** representing the indexes maintained by the current FTS table. FTS tables
180672 struct Fts3Index **apIndex /* OUT: Array of indexes for this table */
180714 ** This function is called when initializing an FTS4 table that uses the
180716 ** of the new FTS4 table.
180720 ** a table of that name. If found, the output variables are populated
180723 ** *pnCol: Set to the number of columns table xxx has,
180729 ** the name of the corresponding column in table xxx. The array
180734 ** If the table cannot be found, an error code is returned and the output
180741 const char *zTbl, /* Name of content table */
180765 int nCol; /* Number of table columns */
180804 ** methods of the FTS3 virtual table.
180810 ** argv[2] -> table name
180816 void *pAux, /* Hash table containing tokenizers */
180829 int nCol = 0; /* Number of columns in the FTS table */
180832 int nName; /* Bytes required to hold table name */
180835 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
180838 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
180841 int bNoDocsize = 0; /* True to omit %_docsize table */
180877 ** + Figures out the number of columns the FTSX table will have, and
181001 ** TABLE statement, use all columns from the content table.
181151 /* Check to see if a legacy fts3 table has been "upgraded" by the
181152 ** addition of a %_stat table so that it can use incremental merge.
181167 /* Declare the table schema to SQLite. */
181194 ** The xConnect() and xCreate() methods for the virtual table. All the
181199 void *pAux, /* Pointer to tokenizer hash table */
181209 void *pAux, /* Pointer to tokenizer hash table */
181250 ** 3. Linear scan of %_content table.
181266 /* By default use a full table scan. This is an expensive option,
181433 ** on the xClose method of the virtual table interface.
181450 ** (or the equivalent for a content=xxx table) and set pCsr->pStmt to
181478 ** of the %_content table that contains the last match. Return
181498 ** table is missing a row that is present in the full-text index.
181555 ** table, then there are always 20 bytes of zeroed padding following the
181655 Fts3Table *p, /* Virtual table handle */
181673 char *zBlob = 0; /* Blob read from %_segments table */
182510 Fts3Table *p, /* FTS table handle */
182608 Fts3Table *p, /* FTS3 table handle */
182624 ** made by an fts4aux module, not an FTS table. In this case calling
182682 Fts3Table *p, /* FTS3 table handle */
182714 Fts3Table *p, /* FTS virtual table handle */
182739 Fts3Cursor *pCsr, /* Virtual table cursor handle */
182805 Fts3Table *p, /* Virtual table handle */
182877 ** Advance the cursor to the next row in the %_content table that
182879 ** the next row that matches. For a full-table scan, this will be
182880 ** simply the next row in the %_content table. For a docid lookup,
182924 ** This is the xFilter interface for the virtual table. See
182925 ** the virtual table xFilter method documentation for additional
182928 ** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against
182929 ** the %_content table.
182932 ** in the %_content table.
183018 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
183019 ** statement loops through all rows of the %_content table. For a
183057 ** This is the xEof method of the virtual table. SQLite calls this
183072 ** exposes %_content.docid as the rowid for the virtual table. The
183088 ** (iCol == p->nColumn) -> Magic column with the same name as the table.
183106 /* The special 'table-name' column */
183128 /* A user column. Or, if this is a full-table scan, possibly the
183147 sqlite3_vtab *pVtab, /* Virtual table handle */
183157 ** hash-table to the database.
183176 ** of blocks from the segments table. But this is not considered overhead
183206 ** If it is currently unknown whether or not the FTS table has an %_stat
183207 ** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat
183249 ** the pending-terms hash-table have already been flushed into the database
183265 ** hash-table. Any changes made to the database are reverted by SQLite.
183418 ** where 't' is the name of an FTS3 table.
183426 Fts3Table *p; /* Virtual table handle */
183472 ** virtual table.
183475 sqlite3_vtab *pVtab, /* Virtual table handle */
183508 ** Implementation of FTS3 xRename method. Rename an fts3 table.
183511 sqlite3_vtab *pVtab, /* Virtual table handle */
183512 const char *zName /* New name of table */
183518 /* At this point it must be known if the %_stat table exists or not.
183522 /* As it happens, the pending terms table is always empty here. This is
183525 ** flushes the pending terms table. But leave the (no-op) call to
183566 ** Flush the contents of the pending-terms table to disk.
183598 ** Discard the contents of the pending terms table.
183654 ** allocated for the tokenizer hash table.
183719 /* Allocate and initialize the hash-table used to store tokenizers. */
183728 /* Load the built-in tokenizers into the hash table */
183750 /* Create the virtual table wrapper around the hash-table and overload
183780 /* An error has occurred. Delete the hash table and return the error code. */
184278 Fts3Table *pTab, /* Virtual table handle */
184572 ** of data that will fit on a single leaf page of an intkey table in
184581 ** data from the %_stat table to calculate it.
184583 ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3
184584 ** varints, where nCol is the number of columns in the FTS3 table.
184586 ** the table. The following nCol varints contain the total amount of
184587 ** data stored in all rows of each column of the table, from left
184655 ** table actually contains the same data as the index. To prevent this from
185258 ** 2. After scanning the current FTS table row for the deferred tokens,
185507 ** the FTS table (considering all rows), and
185509 ** 2. For each column, the number of rows in the table for which the
185521 ** values are set to the number of documents in the table. In other
185523 ** column of each row of the table.
185742 ** Initialize API pointer table, if required.
185807 ** Schema of the terms table.
185826 char const *zFts3; /* Name of fts3 table */
185831 Fts3auxTable *p; /* Virtual table object to return */
185837 ** CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);
185838 ** CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);
186415 const char **azCol; /* Array of column names for fts3 table */
187283 char **azCol, /* Array of column names for fts3 table */
187334 ** of each column in the target fts3 table, in order from left to right.
187337 ** The iDefaultCol parameter should be passed the index of the table column
187341 ** match any table column.
187346 char **azCol, /* Array of column names for fts3 table */
187493 ** of a column of the fts3 table that the query expression may refer to.
187628 ** We've modified it slightly to serve as a standalone hash table
187664 /* Turn bulk memory into a hash table object by initializing the
187667 ** "pNew" is a pointer to the hash table that is to be initialized.
187670 ** determines what kind of key the hash table will use. "copyKey" is
187671 ** true if the hash table should make its own private copy of keys and
187685 /* Remove all entries from a hash table. Reclaim all memory.
187686 ** Call this routine to delete a hash table or to reset a hash table
187690 Fts3HashElem *elem; /* For looping over all elements of the table */
187779 /* Link an element into the hash table
187782 Fts3Hash *pH, /* The complete hash table */
187805 /* Resize the hash table so that it cantains "new_size" buckets.
187806 ** "new_size" must be a power of 2. The hash table might fail
187812 struct _fts3ht *new_ht; /* The new hash table */
187832 ** hash table that matches the given key. The hash for this key has
187860 /* Remove a single entry from the hash table given a pointer to that
187914 ** Attempt to locate an element of the hash table pH with a key
187925 /* Insert an element into the hash table pH. The key is pKey,nKey
187935 ** the new data is returned and the hash table is unchanged.
187938 ** element corresponding to "key" is removed from the hash table.
187941 Fts3Hash *pH, /* The hash table to insert into */
187947 int h; /* the hash of the key modulo hash table size */
188712 ** hash table. This function may be called as follows:
188723 ** the string <key-name> must already exist in the has table. Otherwise,
188728 ** to string <key-name> (after the hash-table is updated, if applicable).
188832 Fts3Hash *pHash, /* Tokenizer hash table */
189128 ** the hash table pointed to by argument pHash. The hash table must
189136 ** defined at compilation time, a temporary virtual table (see header
189141 ** of both the scalar and, if created, the virtual table.
189261 ** else we need to reindex. One solution would be a meta-table to
189439 ** This file contains code for the "fts3tokenize" virtual table module.
189440 ** An fts3tokenize virtual table is created as follows:
189446 ** The table created has the following schema:
189454 ** The virtual table module tokenizes this <string>, using the FTS3
189477 ** Virtual table structure.
189486 ** Virtual table cursor structure.
189570 ** Schema of the tokenizer table.
189581 ** argv[2]: table name
189586 void *pHash, /* Hash table of tokenizers */
189932 ** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()
190097 ** or the pending-terms table being flushed), leaves are written into the
190175 Fts3Table *p, /* Virtual table handle */
190245 ** Read a single entry from the %_segdir table. The entry from absolute
190320 Fts3Table *pTab, /* FTS3 table handle */
190345 Fts3Table *pTab, /* Fts3 table handle */
190366 Fts3Table *pTab, /* Fts3 table handle */
190383 Fts3Table *p, /* The FTS3 table */
190401 ** shared-cache table-lock on the %_segdir table. This is required before
190402 ** writing data to the fts3 table. If this lock is not acquired first, then
190438 ** in the %_segdir table on disk. This function is used to convert three
190440 ** can be used to query the %_segdir table.
190453 Fts3Table *p, /* FTS3 table handle */
190469 ** all rows in the %_segdir table, from oldest to newest. If successful,
190474 ** each FTS3 table.
190476 ** The statement returns the following columns from the %_segdir table:
190485 Fts3Table *p, /* FTS3 table */
190641 Fts3Hash *pHash, /* Pending terms hash table to add entry to */
190670 ** pending-terms hash-table. The docid used is that currently stored in
190700 ** zText==0. In this case, add zero token entries to the hash table and
190754 Fts3Table *p, /* Full-text table handle */
190802 ** pendingTerms hash table.
190838 ** apVal[p->nColumn+2] Hidden column with same name as table
190843 Fts3Table *p, /* Full-text table */
190863 ** table. The SQL for this statement is:
190868 ** defined columns in the FTS3 table, plus one for the docid field.
190913 ** Remove all data from the FTS3 table. Clear the hash table containing
190919 /* Discard the contents of the pending-terms hash table. */
190953 Fts3Table *p, /* The FTS table to delete from */
190999 ** This function allocates a new level iLevel index in the segdir table.
191058 ** The %_segments table is declared as follows:
191062 ** This function reads data from a single row of the %_segments table. The
191066 ** identified table row is. Whether or not paBlob is NULL, *pnBlob is set
191069 ** If an error occurs, or the table does not contain the specified row,
191080 ** on the database file for longer than necessary). Thus, any virtual table
191085 Fts3Table *p, /* FTS3 table handle */
191373 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
191552 ** the contents of the pending-terms hash table to the database.
191576 ** through each term in the pending-terms table. Or, if isPrefixIter is
191578 ** the pending terms hash table contains the terms "sqlite", "mysql" and
191591 Fts3Table *p, /* Virtual table handle */
191809 ** Insert a record into the %_segments table.
191812 Fts3Table *p, /* Virtual table handle */
191830 ** Find the largest relative level number in the table. If successful, set
191851 ** Insert a record into the %_segdir table.
191854 Fts3Table *p, /* Virtual table handle */
191911 Fts3Table *p, /* Virtual table handle */
192053 Fts3Table *p, /* Virtual table handle */
192122 Fts3Table *p, /* Virtual table handle */
192151 /* Find the next free blockid in the %_segments table */
192273 Fts3Table *p, /* Virtual table handle */
192296 /* The entire tree fits on the root node. Write it to the segdir table. */
192321 ** pRowid would mean the FTS3 table were empty.
192323 ** If successful, *pisEmpty is set to true if the table is empty except for
192331 /* If using the content=xxx option, assume the table is never empty */
192350 ** Segment levels are stored in the 'level' column of the %_segdir table.
192414 ** Delete all entries in the %_segments table associated with the segment
192416 ** of the %_segdir table.
192419 Fts3Table *p, /* FTS table handle */
192451 Fts3Table *p, /* Virtual table handle */
192571 Fts3Table *p, /* Virtual table handle */
192639 Fts3Table *p, /* Virtual table handle */
192671 Fts3Table *p, /* Virtual table handle */
192680 Fts3Table *p, /* Virtual table handle */
192768 Fts3Table *p, /* Virtual table handle */
193005 Fts3Table *p, /* FTS table handle */
193019 /* Loop through all entries in the %_segdir table corresponding to
193310 ** Record 0 of the %_stat table contains a blob consisting of N varints,
193311 ** where N is the number of user defined columns in the fts3 table plus
193315 ** Varint 0: Total number of rows in the table.
193318 ** the column for all rows of the table.
193321 ** columns of all rows of the table.
193438 ** The entire FTS index is discarded and rebuilt. If the table is one
193440 ** the current contents of the xxx table. Otherwise, it is rebuilt based
193441 ** on the contents of the %_content table.
193454 /* Compose and prepare an SQL statement to loop through the content table */
193524 Fts3Table *p, /* FTS3 table handle */
193743 Fts3Table *p, /* Fts3 table handle */
193898 Fts3Table *p, /* Fts3 table handle */
193984 Fts3Table *p, /* FTS3 table handle */
194011 ** table. However, this is not permitted in this case. The problem is that
194012 ** space has already been reserved in the %_segments table, and so the
194013 ** start_block and end_block fields of the %_segdir table must be populated.
194022 ** table until we are sure it is needed.
194092 ** Query to see if the entry in the %_segments table with blockid iEnd is
194100 ** is, then a NULL entry has been inserted into the %_segments table
194135 Fts3Table *p, /* Fts3 table handle */
194176 /* Check for the zero-length marker in the %_segments table */
194308 ** In the %_segdir table, a segment is defined by the values in three
194331 Fts3Table *p, /* Fts3 table handle */
194367 /* Insert the marker in the %_segments table to make sure nobody tries
194385 ** Remove an entry from the %_segdir table. This involves running the
194396 Fts3Table *p, /* FTS3 table handle */
194420 Fts3Table *p, /* FTS3 table handle */
194546 ** table, and modifying existing entries in both the %_segments and %_segdir
194553 Fts3Table *p, /* FTS3 table handle */
194639 Fts3Table *p, /* FTS table handle */
194707 ** exists, is stored in the rowid==1 row of the %_stat table.
194710 ** table and return SQLITE_OK. Otherwise, if an error occurs, return an
194808 Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
194825 /* Search the %_segdir table for the absolute level with the smallest
194842 /* If the hint read from the %_stat table is not empty, check if the
194872 ** nMin segments and no hint in the %_stat table. No work to do.
194958 /* Write the hint values into the %_stat table for the next incr-merger */
194987 ** INSERT INTO table(table) VALUES('merge=A,B');
194994 Fts3Table *p, /* FTS3 table handle */
195031 ** INSERT INTO table(table) VALUES('automerge=X');
195037 Fts3Table *p, /* FTS3 table handle */
195095 Fts3Table *p, /* FTS3 table handle */
195165 ** content table. If no error occurs and the contents do match, set *pbOk
195195 /* This block calculates the checksum according to the %_content table */
195280 ** 2. By scanning and tokenizing the content table.
195286 Fts3Table *p /* FTS3 table handle */
195378 ** table, not for all rows.
195383 int i; /* Used to iterate through table columns */
195464 Fts3Cursor *pCsr, /* Fts3 table cursor */
195488 ** present in the FTS3 table. If it is, delete it and adjust the contents
195498 int bFound = 0; /* True if *pRowid really is in the table */
195502 int isEmpty = 0; /* Deleting *pRowid leaves the table empty */
195506 /* Deleting this row means the whole table is empty. In this case
195508 ** data in the pendingTerms hash table. */
195529 ** tables. The schema of the virtual table being:
195531 ** CREATE TABLE <table name>(
195533 ** <table name> HIDDEN,
195553 /* At this point it must be known if the %_stat table exists or not.
195619 ** the %_content table. If we hit the duplicate rowid constraint (or any
195680 ** Flush any data in the pending-terms hash table to disk. If successful,
195798 int nCol; /* Number of columns in table */
196358 Fts3Table *pTab, /* FTS3 table snippet comes from */
196641 ** rows of the table. Y is the number of rows for which column iCol contains
196966 sqlite3_int64 nDoc; /* Number of rows in table */
197195 /* Loop through all columns of the table being considered for snippets.
197197 ** columns of the FTS3 table. Otherwise, only column iCol is considered.
197255 int iCol; /* Column of table to populate aTerm for */
197326 /* Loop through the table columns, appending offset information to
197433 Fts3Cursor *pCsr, /* FTS3 table cursor */
197573 ** statement has specified that the tokenizer for this table shall consider
200364 ** The json_each virtual table
200380 /* Constructor for the json_each virtual table */
200401 ** the last two columns in the table. Should this ever changes, be
200422 /* destructor for json_each virtual table */
200685 ** column. Without such a constraint, the table cannot operate. idxNum is
200700 ** columns in the table */
200828 /* The methods of the json_each virtual table */
200856 /* The methods of the json_tree virtual table. */
200926 ** Register the JSON table-valued functions
200959 ** algorithms packaged as an SQLite virtual table module.
200966 ** The data structure for a single virtual r-tree table is stored in three
200968 ** in the table name is replaced with the user-supplied name of the r-tree
200969 ** table.
200976 ** table. For each node that is not the root node of the r-tree, there is
200977 ** an entry in the %_parent table associating the node with its parent.
200978 ** And for each row of data in the table, there is an entry in the %_rowid
200979 ** table that maps from the entries rowid to the id of the node that it
200981 ** on the end of the %_rowid table.
200983 ** The root node of an r-tree always exists, even if the r-tree table is
200985 ** table must be the same size as the root node. The content of each node
201072 /* Size of hash table Rtree.aHash. This hash table is not expected to
201078 /* The xBestIndex method of this virtual table requires an estimate of
201079 ** the number of rows in the virtual table to calculate the costs of
201081 ** sqlite_stat1 table (with RTREE_MIN_ROWEST as a hard-coded minimum).
201089 ** An rtree virtual-table object.
201094 int iNodeSize; /* Size in bytes of each node in the node table */
201105 u8 bCorrupt; /* Shadow table corruption detected */
201108 char *zDb; /* Name of database containing r-tree table */
201109 char *zName; /* Name of r-tree table */
201111 i64 nRowEst; /* Estimated number of rows in this table */
201144 RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */
201152 ** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will
201567 ** in the Rtree.aHash table.
201574 ** Search the node hash table for node iNode. If found, return a pointer
201584 ** Add node pNode to the node hash table.
201595 ** Remove node pNode from the node hash table.
201651 /* Check if the requested node is already in the hash table. If so,
201915 ** the virtual table module xCreate() and xConnect() methods.
201922 ** Rtree virtual table module xCreate method.
201935 ** Rtree virtual table module xConnect method.
201980 ** Rtree virtual table module xDisconnect method.
201988 ** Rtree virtual table module xDestroy method.
202016 ** Rtree virtual table module xOpen method.
202065 ** Rtree virtual table module xClose method.
202080 ** Rtree virtual table module xEof method.
202634 ** Rtree virtual table module xNext method.
202652 ** Rtree virtual table module xRowid method.
202666 ** Rtree virtual table module xColumn method.
202718 ** return SQLITE_OK. If there is no such record in the table, set
202776 ** Rtree virtual table module xFilter method.
202898 ** Rtree virtual table module xBestIndex method. There are three
202899 ** table scan strategies to choose from (in order from most to
202905 ** 2 See below R-tree query or full-table scan.
203144 Rtree *pRtree, /* Rtree table */
203204 Rtree *pRtree, /* Rtree table */
203239 ** Write mapping (iRowid->iNode) to the <rtree>_rowid table.
203249 ** Write mapping (iNode->iPar) to the <rtree>_parent table.
203746 /* Remove the node from the in-memory hash table and link it into
204032 /* Delete the corresponding entry in the <rtree>_rowid table. */
204114 ** A constraint has failed while inserting a row into an rtree table.
204186 /* Constraint handling. A write operation on an r-tree table may return
204205 ** with "column" that are interpreted as table constraints.
204235 ** the table. If so, the constraint has failed. */
204259 ** record to delete from the r-tree table. The following block does
204378 ** of the number of rows in the virtual table. If possible, this is based
204428 rtreeCreate, /* xCreate - create a table */
204429 rtreeConnect, /* xConnect - connect to an existing table */
204431 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
204432 rtreeDestroy, /* xDestroy - Drop a table */
204446 rtreeRename, /* xRename - rename the table */
204464 /* Write the xxx_node table */
204468 /* Read and write the xxx_rowid table */
204473 /* Read and write the xxx_parent table */
204603 ** determine the node-size used by the rtree table being created or connected
204608 ** table already exists. In this case the node-size is determined by inspecting
204666 ** methods of the r-tree virtual table.
204670 ** argv[2] -> table name
204677 sqlite3_vtab **ppVtab, /* OUT: New virtual table */
204693 "Wrong number of columns for an rtree table", /* 1 */
204694 "Too few columns for an rtree table", /* 2 */
204695 "Too many columns for an rtree table", /* 3 */
204726 ** the r-tree table schema.
204886 const char *zDb; /* Database containing rtree table */
204887 const char *zTab; /* Name of rtree table */
204888 int bInt; /* True for rtree_i32 table */
204892 int nLeaf; /* Number of leaf cells in table */
204893 int nNonLeaf; /* Number of non-leaf cells in table */
204972 ** Otherwise, the contents of rtree table node iNode are loaded from
205015 ** (if bLeaf==1) table contains a specified entry. The schemas of the
205050 rtreeCheckAppendMsg(pCheck, "Mapping (%lld -> %lld) missing from %s table",
205057 "Found (%lld -> %lld) in %s table, expected (%lld -> %lld)",
205182 ** %_rowid or %_parent table is exactly nExpect. If not, it adds
205196 rtreeCheckAppendMsg(pCheck, "Wrong number of entries in %%%s table"
205213 const char *zTab, /* Name of rtree table to check */
205217 sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */
205247 /* Find number of dimensions in the rtree table. */
205287 ** rtreecheck(<rtree-table>);
205288 ** rtreecheck(<database>, <rtree-table>);
205291 ** table. The integrity-check verifies the following:
205293 ** 1. For each cell in the r-tree structure (%_node table), that:
205301 ** table corresponding to the cell's rowid value that
205305 ** %_parent table mapping from the cell's child node to the
205308 ** 2. That there are the same number of entries in the %_rowid table
205310 ** is a leaf cell that corresponds to each entry in the %_rowid table.
205312 ** 3. That there are the same number of entries in the %_parent table
205315 ** %_parent table.
205363 ** This file implements an alternative R-Tree virtual table that
206564 ** methods of the geopoly virtual table.
206568 ** argv[2] -> table name
206575 sqlite3_vtab **ppVtab, /* OUT: New virtual table */
206610 ** the r-tree table schema.
206653 ** GEOPOLY virtual table module xCreate method.
206666 ** GEOPOLY virtual table module xConnect method.
206680 ** GEOPOLY virtual table module xFilter method.
206689 ** 4 full table scan
206811 ** Rtree virtual table module xBestIndex method. There are three
206812 ** table scan strategies to choose from (in order from most to
206820 ** 4 "fullscan" full-table scan.
206873 ** GEOPOLY virtual table module xColumn method.
206977 ** the table. If so, the constraint has failed. */
206994 ** record to delete from the r-tree table. The following block does
207090 geopolyCreate, /* xCreate - create a table */
207091 geopolyConnect, /* xConnect - connect to an existing table */
207093 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
207094 rtreeDestroy, /* xDestroy - Drop a table */
207108 rtreeRename, /* xRename - rename the table */
207172 ** virtual table module "rtree" and the debugging/analysis scalar
207435 ** This lookup table is used to help decode the first byte of
208190 ** sqlite3rbu.h. Essentially, for each table xyz in the target database
208191 ** that the user wishes to write to, a corresponding data_xyz table is
208193 ** update, insert or delete from the target table.
208248 ** collected in the rbu_xyz table. And for both UPDATEs and DELETEs all
208329 ** KEY fields may not be updated or deleted. If the table being written
208346 ** containing an RBU update is an "RBU database". For each table in the
208347 ** target database to be updated, the RBU database should contain a table
208349 ** target table, and one more - "rbu_control". The data_% table should
208361 ** The order of the columns in the data_% table does not matter.
208363 ** Instead of a regular table, the RBU database may also contain virtual
208375 ** If the target database table is a virtual table or a table that has no
208376 ** PRIMARY KEY declaration, the data_% table must also contain a column
208390 ** target table must be present in the input table. For virtual tables,
208392 ** the input table, or not otherwise. For example, to write to an fts4
208393 ** table with a hidden languageid column such as:
208397 ** Either of the following input table schemas may be used:
208403 ** update, the corresponding data_% table should contain a single record
208408 ** If the target database table has an INTEGER PRIMARY KEY, it is not
208413 ** update, the corresponding data_% table should contain a single record
208416 ** corresponding columns of the data_% table. The values stored in the
208420 ** update, the corresponding data_% table should contain a single record
208423 ** stored in the corresponding columns of the data_% table row, as should
208426 ** there are columns in the target database table, and must consist entirely
208441 ** target table with the value stored in the corresponding data_% column, the
208443 ** the target table column. rbu_delta() is invoked with two arguments - the
208444 ** original value currently stored in the target table column and the
208445 ** value specified in the data_xxx table.
208456 ** ota_control string, the contents of the data_xxx table column is assumed
208459 ** the existing value within the target database table must be of type BLOB.
208463 ** If the target database table is a virtual table or a table with no PRIMARY
208476 ** table in "rowid" order is roughly the same as reading them sorted by
208477 ** the PRIMARY KEY of the corresponding target database table. In other
208478 ** words, rows should be sorted using the destination table PRIMARY KEY
208489 ** 2) Registers any required virtual table modules with the database
208657 ** register the required virtual table implementations.
208661 ** the rbu update db handle to any required virtual table
208753 ** database contains an "rbu_count" table. The rbu_count table, if it
208758 ** There must be one row in the table for each source (data_xxx) table within
208760 ** table. The 'cnt' column should contain the number of rows within the
208761 ** source table.
208763 ** If the rbu_count table is present and populated correctly and this
208765 ** permyriadage progress of the same stage. If the rbu_count table does
208767 ** table exists but is not correctly populated, the value of the *pnOne
208930 ** The rbu_state table is used to save the state of a partially applied
208931 ** update so that it can be resumed later. The table consists of integer
208943 ** Only valid if STAGE==1. The target database name of the table
208948 ** currently being written, or NULL if the main table is currently being
208953 ** table/index.
208974 ** Only valid if STAGE==1. The RBU database name of the table
209025 ** A structure to store values read from the rbu_state table in memory.
209053 ** the target database that require updating. For each such table, the
209056 ** * the table itself,
209057 ** * each index of the table (zero or more points to visit), and
209058 ** * a special "cleanup table" state.
209061 ** If the table has no indexes on it, abIndexed is set to NULL. Otherwise,
209066 ** If there are one or more partial indexes on the table, all fields of
209078 int *aiSrcOrder; /* src table col -> target table col */
209086 const char *zTbl; /* Name of target db table */
209087 const char *zDataTbl; /* Name of rbu db table (or null) */
209092 int nIndex; /* Number of aux. indexes on table zTbl */
209116 ** 5: Table is a virtual table.
209130 #define RBU_INSERT 1 /* Insert on a main table b-tree */
209131 #define RBU_DELETE 2 /* Delete a row from a main table b-tree */
209136 #define RBU_UPDATE 6 /* Update a row in a main table b-tree */
209151 ** If the RBU database contains an rbu_count table, this value is set to
209164 ** of rows in the source table and nIndex the number of indexes on the
209165 ** corresponding target database table.
209171 ** for an UPDATE operation does not exist in the target table, then
209184 ** first pass of each source table. The updated nPhaseOneStep value is
209185 ** stored in the rbu_state table if the RBU update is suspended.
209623 ** the current object (table/index pair).
209734 ** accepts one or two arguments. The first argument is the name of a table -
209735 ** the name of a table in the RBU database. The second, if it is present, is 1
209736 ** for a view or 0 for a table.
209738 ** For a non-vacuum RBU handle, if the table name matches the pattern:
209797 "WHERE type IN ('table', 'view') AND target IS NOT NULL "
209955 /* Determine the type of a table.
209959 ** on the type of the table specified by parameters dbName and zTbl.
209961 ** RBU_PK_NOTABLE: No such table.
209966 ** RBU_PK_VTAB: Table is a virtual table.
209969 ** parameter. Unless the table has an external primary key index
209971 ** if the table does have an external primary key index, then *piPk
209981 ** }else if( "PRAGMA index_list()" for the table contains a "pk" index ){
210022 /* Either an error, or no such table. */
210026 *peType = RBU_PK_VTAB; /* virtual table */
210128 ** the table (not index) that the iterator currently points to.
210139 int bRbuRowid = 0; /* If input table has column "rbu_rowid" */
210143 /* Figure out the type of table this step will deal with. */
210148 p->zErrmsg = sqlite3_mprintf("no such table: %s", pIter->zTbl);
210159 ** of the input table. Ignore any input table columns that begin with
210188 "table %q %s rbu_rowid column", pIter->zDataTbl,
210193 /* Check that all non-HIDDEN columns in the destination table are also
210194 ** present in the input table. Populate the abTblPk[], azTblType[] and
210261 ** in order, for the current table. Before each column name, add the text
210294 ** updating a table (not an index). The table may be a rowid table or
210295 ** a WITHOUT ROWID table. It queries the target database to find the
210296 ** largest key that has already been written to the target table and
210298 ** rows from the source table. For a rowid table, the WHERE clause
210313 int bRowid, /* True for a rowid table */
210314 const char *zWrite /* Target table name prefix */
210360 ** clause to select the remaining required rows from the source table.
210375 ** rows from the sourct table, just as it does for an RBU update operation.
210471 ** used to read from an data_xxx or rbu_tmp_xxx table while updating the
210480 ** and "t1" is a table with an explicit INTEGER PRIMARY KEY column
210495 char **pzImposterCols, /* OUT: Columns for imposter table */
210533 /* An integer primary key. If the table has an explicit IPK, use
210594 ** Assuming the current table columns are "a", "b" and "c", and the zObj
210627 /* For a table with implicit rowids, append "old._rowid_" to the list. */
210637 ** primary key of the current table. For example, if the table is:
210695 ** an UPDATE statement used to update the table object that the iterator
210697 ** column of the data_xxx table entry is set to zMask.
210779 ** The iterator currently points to a table (not index) of type
210781 ** declaration for the corresponding imposter table. For example,
210782 ** if the iterator points to a table created as:
210831 ** This function creates the second imposter table used when writing to
210832 ** a table b-tree where the table has an external primary key. If the
210834 ** a table (not index) with an external primary key, this function is a
210837 ** Assuming the iterator does point to a table with an external PK, this
210838 ** function creates a WITHOUT ROWID imposter table named "rbu_imposter2"
210839 ** used to access that PK index. For example, if the target table is
210844 ** then the imposter table schema is:
210856 char *zCols = 0; /* Used to build up list of table cols */
210857 char *zPk = 0; /* Used to build up table PK declaration */
210859 /* Figure out the name of the primary key index for the current table.
210911 ** a table (not an index) when this function is called. This function
210912 ** attempts to create any imposter table required to write to the main
210913 ** table b-tree of the table before returning. Non-zero is returned if
210914 ** an imposter table are created, or zero otherwise.
210916 ** An imposter table is required in all cases except RBU_PK_VTAB. Only
210917 ** virtual tables are written to directly. The imposter table has the
210918 ** same schema as the actual target table (less any UNIQUE constraints).
210941 /* If the target table column is an "INTEGER PRIMARY KEY", add
210942 ** "PRIMARY KEY" to the imposter table column declaration. */
210969 ** Prepare a statement used to insert rows into the "rbu_tmp_xxx" table.
210975 ** the target table, plus one (for the rbu_control column), plus one more
210976 ** (for the rbu_rowid column) if the target table is an implicit IPK or
210977 ** virtual table.
211147 char *zImposterCols = 0; /* Columns for imposter table */
211161 /* Create the imposter table used to write to this index. */
211248 const char *zWrite; /* Imposter table name */
211258 /* Create the imposter table or tables (if required). */
211290 /* Create the rbu_tmp_xxx table and the triggers to populate it. */
211387 ** be used to update the imposter table for the main table b-tree of the
211388 ** table object that pIter currently points to, assuming that the
211389 ** rbu_control column of the data_xyz table contains zMask.
211494 ** table into it. Return a pointer to the new object. It is the
211614 /* If it has not already been created, create the rbu_state table */
212176 /* If this is an INSERT into a table b-tree and the table has an
212201 /* For a virtual table, or a table with no primary key, the
212324 ** Update the contents of the rbu_state table within the rbu database. The
212467 /* If this is an RBU vacuum operation and the state table was empty
212478 /* Clean up the rbu_tmp_xxx table for the previous table. It
212599 ** the rbu_state table was empty) it is a no-op. Otherwise, it arranges
212684 ** name of a table expected to appear in the target database. It returns
212685 ** the number of auxilliary indexes on the table.
212723 ** If the RBU database contains the rbu_count table, use it to initialize
212724 ** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table
212729 ** There should be one row in the table for each data_xxx table in the
212730 ** database. The 'tbl' column should contain the name of a data_xxx table,
212734 ** for all rows in the rbu_count table, where nIndex is the number of
212735 ** indexes on the corresponding target database table.
212748 /* Check for the rbu_count table. If it does not exist, or if an error
213044 ** state table. This causes the next call to sqlite3rbu_vacuum()
214197 ** This file contains an implementation of the "dbstat" virtual table.
214199 ** The dbstat virtual table is used to extract low-level storage
214254 " name TEXT," /* 0 Name of table or index */
214265 " aggregate BOOLEAN HIDDEN" /* 11 aggregate info for each table */
214301 /* The cursor for scanning the dbstat virtual table */
214306 u8 isAgg; /* Aggregate results for each table */
214326 /* An instance of the DBSTAT virtual table */
214338 ** Connect to or create a new DBSTAT virtual table.
214381 ** Disconnect from or destroy the DBSTAT virtual table.
214412 /* Force DBSTAT table should always be the right-most table in a join */
214637 /* A table interior node. nPayload==0. */
214872 case 0x05: /* table internal */
214876 case 0x0D: /* table leaf */
214927 const char *zName = 0; /* Only provide analysis of this table */
214957 "SELECT 'sqlite_schema' AS name,1 AS rootpage,'table' AS type"
215051 ** Invoke this routine to register the "dbstat" virtual table module
215100 ** This file contains an implementation of the "sqlite_dbpage" virtual table.
215102 ** The sqlite_dbpage virtual table is used to read or write whole raw
215111 ** This is an eponymous virtual table so it does not need to be created before
215112 ** use. The optional argument to the sqlite_dbpage() table name is the
215116 ** The data field of sqlite_dbpage table can be updated. The new
215151 ** Connect to or create a dbpagevfs virtual table.
215182 ** Disconnect from or destroy a dbpagevfs virtual table.
215192 ** 0 schema=main, full table scan
215194 ** 2 schema=?1, full table scan
215297 ** 0 schema=main, full table scan
215299 ** 2 schema=?1, full table scan
215462 ** written by the sqlite_dbpage virtual table, start a write transaction
215479 ** Invoke this routine to register the "dbpage" virtual table module
215614 char *zTab; /* Current table */
215624 ** for each table the session object is monitoring. The structures are
215627 ** The keys of the SessionTable.aChange[] hash table are all rows that have
215629 ** table.
215631 ** The data associated with each hash-table entry is a structure containing
215637 char *zName; /* Local name of table */
215638 int nCol; /* Number of columns in table zName */
215642 int nEntry; /* Total number of entries in hash table */
215644 SessionChange **apChange; /* Hash table buckets */
215691 ** one or more tables. Operations on a single table are grouped together,
215695 ** Each group of changes begins with a table header:
215698 ** Varint: Number of columns in the table.
215700 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
215702 ** Followed by one or more changes to the table.
215711 ** columns in the table. The i'th field of each record is associated with
215712 ** the i'th column of the table, counting from left to right in the order
215723 ** associated with table columns that are not PRIMARY KEY columns and are
215727 ** with table columns modified by the UPDATE change contain the new
215728 ** values. Fields associated with table columns that are not modified
215737 ** Each group of changes begins with a table header:
215740 ** Varint: Number of columns in the table.
215742 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
215744 ** Followed by one or more changes to the table.
215753 ** table column, counting from left to right within the CREATE TABLE
215762 ** PRIMARY KEY fields contain the values identifying the table row to update,
215778 ** changesets. All entries related to a single table are grouped together.
215780 ** Each group of entries begins with a table header in changeset format:
215783 ** Varint: Number of columns in the table.
215785 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
215787 ** Followed by one or more entries associated with the table.
215808 ** this structure stored in a SessionTable.aChange[] hash table.
215816 SessionChange *pNext; /* For hash-table collisions */
216032 SessionTable *pTab, /* Session table handle */
216106 ** hash key. Assume the has table has nBucket buckets. The hash keys
216117 int nBucket /* Assume this many buckets in hash table */
216157 ** Arguments aLeft and aRight are pointers to change records for table pTab.
216171 int iCol; /* Used to iterate through table columns */
216431 ** If required, grow the hash table used to store changes on table pTab
216437 ** that case the hash-table does not grow, but SQLITE_OK is returned anyway.
216438 ** Growing the hash table in this case is a performance optimization only,
216483 ** This function queries the database for the names of the columns of table
216487 ** of columns in the database table and variable *pzTab is set to point to a
216488 ** nul-terminated copy of the table name. *pazCol (if not NULL) is set to
216493 ** For example, if the table is declared as:
216514 const char ***pazCol, /* OUT: Array of column names for table */
216630 ** write to table pTab, part of session pSession. If this is the first
216631 ** write to this table, initalize the SessionTable.nCol, azCol[] and
216635 ** non-zero returned. Or, if no error occurs but the table has no primary
216637 ** indicate that updates on this table should be ignored. SessionTable.abPK
216671 ** sqlite_stat1 table. The purpose of this is to substitute a zero-length
216673 ** sqlite_stat1 table.
216809 ** change on table pTab (attached to session pSession). The type of change
216813 ** to the changed-rows hash table associated with table pTab.
216827 /* Load table details if required */
216831 ** number of columns in the table. */
216837 /* Grow the hash table if required */
216869 /* Search the hash table for an existing record for this row. */
216928 /* Add the change to the hash-table */
216973 /* Search for an existing table */
216979 /* If there is a table-filter configured, invoke it. If it returns 0,
216980 ** do not automatically add the new table. */
217272 /* Locate and if necessary initialize the target table object */
217280 /* Check the table schemas match */
217303 *pzErrMsg = sqlite3_mprintf("table schemas do not match");
217382 ** Free the list of table objects passed as the first argument. The contents
217428 /* Delete all attached table objects. And the contents of their
217439 ** Set a table filter on a Session Object.
217452 ** Attach a table to a session. All subsequent changes made to the table
217469 SessionTable *pTab; /* New table object (if required) */
217853 int nCol, /* Number of columns in table */
217899 ** Formulate and prepare a SELECT statement to retrieve a row from table
217908 int nCol, /* Number of columns in table */
217909 const char **azCol, /* Names of table columns */
217963 int nCol, /* Number of columns in table */
218028 ** is called. Otherwise, append a serialized table header (part of the binary
218038 /* Write a table header */
218089 int nCol = 0; /* Number of columns in table */
218093 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
218097 /* Check the table schema is still Ok. */
218103 /* Write a table header */
218589 ** The input pointer currently points to the second byte of a table-header.
218592 ** + number of columns in table (varint)
218594 ** + table name (nul terminated).
218610 ** database table is, according to sqliteLimit.h, 32676. So
218611 ** consider any table-header that purports to have more than 65536
218672 ** The input pointer currently points to the second byte of a table-header.
218675 ** + number of columns in table (varint)
218677 ** + table name (nul terminated).
218679 ** This function decodes the table-header and populates the p->nCol,
218682 ** input pointer is left pointing to the byte following the table header.
218741 int *pbNew, /* If non-NULL, true if new table */
218788 /* The first record in the changeset is not a table header. Must be a
218890 int *pbNew /* If non-NULL, true if new table */
218920 const char **pzTab, /* OUT: Pointer to table name */
218921 int *pnCol, /* OUT: Number of columns in table */
218934 ** the database table affected by the change that pIter currently points
219088 int nCol = 0; /* Number of cols in current table */
219089 u8 *abPK = 0; /* PK array for current table */
219091 SessionBuffer sPK = {0, 0, 0}; /* PK array for current table */
219112 /* A 'table' record consists of:
219115 ** * Number of columns in said table (a varint),
219117 ** * A nul-terminated table name.
219295 int bStat1; /* True if table is sqlite_stat1 */
219300 u8 bRebaseStarted; /* If table header is already in rebase */
219466 ** Formulate a statement to DELETE a row from database db. Assuming a table
219535 ** Formulate and prepare an SQL statement to query table zTab by primary
219536 ** key. Assuming the following table structure:
219557 ** Formulate and prepare an INSERT statement to add a record to table zTab.
219600 ** Prepare statements for applying changes to the sqlite_stat1 table.
219650 ** pStmt. The table being inserted into has nCol columns.
219696 ** iterator pIter points to to the SELECT and attempts to seek to the table
219717 int nCol; /* Number of columns in table */
219755 /* Append a table-header to the rebase buffer */
219946 ** * all columns of the table are PK columns (in this case there is
219994 /* A NOTFOUND or DATA error. Search the table to see if it contains
220181 const char *zTab = 0; /* Name of current table */
220232 ** xFilter callback returns zero, skip this table. If it returns
220259 "sqlite3changeset_apply(): no such table: %s", zTab
220265 "sqlite3changeset_apply(): table %s has %d columns, "
220273 "primary key mismatch for table %s", zTab
220297 /* If there is a schema mismatch on the current table, proceed to the
220482 int bRebase, /* True for a rebase hash-table */
220665 int bRebase /* True if hash table is for rebasing */
220691 /* Search the list for a matching table */
220734 /* Search for existing entry. If found, remove it from the hash table.
220979 sqlite3_changegroup grp; /* Hash table */
221106 sqlite3_rebaser *p, /* Rebaser hash table */
221136 /* Append a table header to the output for this new table */
221386 ** Virtual table implementations may overload SQL functions by implementing
221416 ** to the total number of tokens in the FTS5 table. Or, if iCol is
221417 ** non-negative but less than the number of columns in the table, return
221419 ** the FTS5 table.
221422 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
221427 ** Return the number of columns in the table.
221432 ** non-negative but less than the number of columns in the table, set
221436 ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
221440 ** This function may be quite inefficient if used with an FTS5 table
221463 ** This API can be quite slow if used with an FTS5 table created with the
221464 ** "detail=none" or "detail=column" option. If the FTS5 table is created
221466 ** (i.e. if it is a contentless table), then this API always returns 0.
221479 ** This API can be quite slow if used with an FTS5 table created with the
221486 ** Tokenize text using the tokenizer belonging to the FTS5 table.
221489 ** This API function is used to query the FTS table for phrase iPhrase
221551 ** This function is used to retrieve the total number of rows in the table.
221578 ** This API can be quite slow if used with an FTS5 table created with the
221579 ** "detail=none" or "detail=column" option. If the FTS5 table is created
221581 ** (i.e. if it is a contentless table), then this API always iterates
221603 ** This API can be quite slow if used with an FTS5 table created with the
221604 ** "detail=none" option. If the FTS5 table is created with either
221605 ** "detail=none" "content=" option (i.e. if it is a contentless table),
221679 ** to create the FTS5 table.
221703 ** or removed from the FTS table. The tokenizer is being invoked to
221999 ** Maximum number of prefix indexes on single FTS5 table. This must be
222079 ** And all information loaded from the %_config table.
222101 ** True if the %_docsize table is created.
222120 char *zContent; /* content table */
222127 int bLock; /* True when table is preparing statement */
222130 /* Values loaded from the %_config table */
222148 /* Current expected value of %_config table 'version' field */
222180 /* Load the contents of the %_config table */
222287 ** to access the data stored in the %_data table.
222420 ** table may have changed on disk. So any in-memory caches of %_data
222445 ** Return the total number of entries read from the %_data table by
222491 ** Virtual-table object.
222496 Fts5Config *pConfig; /* Virtual table configuration */
222522 ** Create a hash table, free a hash table.
222537 ** Empty (but do not delete) a hash table.
222542 Fts5Hash*, /* Hash table to query */
222550 Fts5Hash*, /* Hash table to query */
223008 ** slots in the fts5yy_action[] table.
223013 ** The action table is constructed as a single large table named fts5yy_action[].
223029 ** fts5yy_action[] A single table containing all actions.
223030 ** fts5yy_lookahead[] A table containing the lookahead for each entry in
223092 /* The next table maps tokens (terminal symbols) into fallback tokens.
223194 ** are required. The following table supplies these names */
223951 /* There are no SHIFTREDUCE actions on nonterminals because the table
224825 ** table matched by each individual phrase within the query.
224854 sqlite3_int64 nRow = 0; /* Number of rows in table */
224855 sqlite3_int64 nToken = 0; /* Number of tokens in table */
224872 /* Calculate the average document length for this FTS5 table */
225359 ** designed to produce hash table collisions really do work. */
225915 ** or xConnect method of the virtual table. This function attempts to
225955 *pzErr = sqlite3_mprintf("reserved fts5 table name: %s", pRet->zName);
226319 ** Load the contents of the %_config table into memory.
229466 ** This file contains the implementation of an in-memory hash table used
229482 ** Each entry in the hash table is represented by an object of the
229527 ** Allocate a new hash table.
229557 ** Free a hash table object.
229568 ** Empty (but do not delete) a hash table.
229604 ** Resize the hash table by doubling the number of slots.
229678 ** Add an entry to the in-memory hash table. The key is the concatenation
229727 /* Allocate new Fts5HashEntry and add it to the hash table. */
229879 ** Extract all tokens from hash table iHash and link them into a list
229880 ** in sorted order. The hash table is cleared before returning. It is
229929 ** Query the hash table for a doclist associated with term pTerm/nTerm.
229932 Fts5Hash *pHash, /* Hash table to query */
229970 Fts5Hash *p, /* Hash table to query */
230020 ** %_data table. Other parts of the system access this functionality via
230030 ** The %_data table contains all the FTS indexes for an FTS5 virtual table.
230065 ** The %_data table managed by this module,
230076 ** recorded in a single record within the %_data table. The record consists
230078 ** SQLite varints. If the FTS table features more than one index (because
230100 ** A single record within the %_data table. The data is a list of varints.
230103 ** rows of the table.
230216 ** Rowids for the averages and structure records in the %_data table.
230223 ** and nodes. All nodes and leaves are stored in the %_data table with large
230253 ** Each time a blob is read from the %_data table, it is padded with this
230280 ** One object per %_data table.
230283 Fts5Config *pConfig; /* Virtual table configuration */
230284 char *zDataTbl; /* Name of %_data table */
230291 Fts5Hash *pHash; /* Hash table for in-memory data */
230300 sqlite3_blob *pReader; /* RO incr-blob open on %_data table */
230376 /* Values to insert into the %_idx table */
230377 Fts5Buffer btterm; /* Next term to insert into %_idx table */
230634 ** Retrieve a record from the %_data table.
230671 ** table, missing row, non-blob/text in block column - indicate
230749 ** INSERT OR REPLACE a record into the %_data table.
232509 ** in-memory hash table. If there is no such term in the hash-table, the
233337 ** * the table contains 100 or fewer columns.
233496 /* Add a segment iterator for the current contents of the hash table. */
234409 /* Remove the redundant segments from the %_data table */
234572 ** Flush the contents of in-memory hash table iHash to a new level-0
234608 /* Begin scanning through hash table entries. This loop runs once for each
234609 ** term/doclist currently stored within the hash table. */
234733 /* Unless it is empty, flush the hash table to disk */
235345 /* Allocate the hash table if it has not already been allocated */
235350 /* Flush the hash table to disk if required */
235376 ** table may have changed on disk. So any in-memory caches of %_data
235388 ** The %_data table is completely empty when this function is called. This
235404 ** and initialize the underlying %_data table.
235713 ** the number of user defined columns in the FTS table.
235747 ** table since it was created.
235966 ** This check may only be performed if the hash table is empty. This
235967 ** is because the hash table only supports a single scan query at
236324 ** Decode a segment-data rowid from the %_data table. This function is
236328 i64 iRowid, /* Rowid from %_data table */
236868 ** SQLite invokes the following virtual table methods as transactions are
236977 ** Virtual-table cursor object.
237135 ** Return true if pTab is a contentless table.
237142 ** Delete a virtual table handle allocated by fts5InitVtab().
237154 ** The xDisconnect() virtual table method.
237162 ** The xDestroy() virtual table method.
237175 ** methods of the FTS3 virtual table.
237181 ** argv[2] -> table name
237187 void *pAux, /* Hash table containing tokenizers */
237197 Fts5FullTable *pTab = 0; /* New virtual table object */
237247 ** The xConnect() and xCreate() methods for the virtual table. All the
237252 void *pAux, /* Pointer to tokenizer hash table */
237262 void *pAux, /* Pointer to tokenizer hash table */
237318 ** 1. A MATCH constraint against the table column.
237341 ** Match against table column: "m"
237401 "recursively defined fts5 content table"
237610 ** on the xClose method of the virtual table interface.
237669 ** open on table pTab.
237719 ** Advance the cursor to the next row in the table that matches the
237830 ** is not possible as SQLite reference counts the virtual table objects.
237832 ** table, saving it creates a circular reference.
237908 ** Search for an auxiliary function named zName that can be used with table
238023 ** This is the xFilter interface for the virtual table. See
238024 ** the virtual table xFilter method documentation for additional
238031 ** 3. A full-table scan.
238058 "recursively defined fts5 content table"
238194 "%s: table does not support scanning", pConfig->zName
238198 /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup
238223 ** This is the xEof method of the virtual table. SQLite calls this
238249 ** exposes %_content.rowid as the rowid for the virtual table. The
238346 Fts5FullTable *pTab, /* Fts5 table object */
238347 const char *zCmd, /* Text inserted into table-name column */
238358 "contentless or external content fts5 table"
238367 "'rebuild' may not be used with a contentless fts5 table"
238445 sqlite3_vtab *pVtab, /* Virtual table handle */
238506 "cannot %s contentless fts5 table: %s",
238592 ** the pending-terms hash-table have already been flushed into the database
238603 ** hash-table. Any changes made to the database are reverted by SQLite.
239319 ** as the table. Return the cursor integer id number. This value is only
239350 ** virtual table.
239353 sqlite3_vtab *pVtab, /* Virtual table handle */
239375 ** Implementation of FTS5 xRename method. Rename an fts5 table.
239378 sqlite3_vtab *pVtab, /* Virtual table handle */
239379 const char *zName /* New name of table */
239393 ** Flush the contents of the pending-terms table to disk.
239415 ** Discard the contents of the pending terms table.
239778 i64 nTotalRow; /* Total number of rows in FTS table */
239817 /* If there is no %_docsize table, there should be no requests for
239967 const char *zTail, /* Tail of table name e.g. "data", "config" */
239968 const char *zName /* New name of FTS5 table */
239995 ** Create the shadow table named zPost, with definition zDefn. Return
240000 const char *zPost, /* Shadow table to create (e.g. "content") */
240001 const char *zDefn, /* Columns etc. for shadow table */
240017 "fts5: error creating shadow table %q_%s: %s",
240143 ** If a row with rowid iDel is present in the %_content table, add the
240209 ** Insert a record into the %_docsize table. Specifically, do:
240213 ** If there is no %_docsize table (as happens if the columnsize=0 option
240214 ** is specified when the FTS5 table is created), this function is a no-op.
240282 ** Remove a row from the FTS table.
240345 /* Reinitialize the %_data table. This call creates the initial structure
240426 ** by inserting a dummy row into the %_docsize table. The dummy will be
240429 ** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In
240451 ** Insert a new row into the FTS content table.
240461 /* Insert the new row into the %_content table. */
240469 sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */
240486 ** Insert new entries into the FTS index and %_docsize table.
240639 ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return
240664 ** %_content table. This block stores the checksum in ctx.cksum. */
240749 ** %_content table.
240807 ** each table column. This function reads the %_docsize record for the
240814 int nCol = p->pConfig->nCol; /* Number of user columns in table */
240864 ** database - it might be that the FTS5 table really does contain zero
240866 ** and there is no way for that API to be invoked if the table contains
243477 ** This is an SQLite virtual table module implementing direct access to an
243487 ** instances of term $term in column $col (in any row of the fts5 table).
243512 char *zFts5Tbl; /* Name of fts5 table */
243513 char *zFts5Db; /* Db containing fts5 table */
243523 Fts5Table *pFts5; /* Associated FTS5 table */
243538 i64 rowid; /* This table's current rowid value */
243563 ** Translate a string containing an fts5vocab table type to an
243584 *pzErr = sqlite3_mprintf("fts5vocab: unknown table type: %Q", zCopy);
243595 ** The xDisconnect() virtual table method.
243604 ** The xDestroy() virtual table method.
243614 ** methods of the FTS3 virtual table.
243620 ** argv[2] -> table name
243624 ** argv[3] -> name of fts5 table
243625 ** argv[4] -> type of fts5vocab table
243630 ** argv[4] -> name of fts5 table
243631 ** argv[5] -> type of fts5vocab table
243692 ** The xConnect() and xCreate() methods for the virtual table. All the
243697 void *pAux, /* Pointer to tokenizer hash table */
243707 void *pAux, /* Pointer to tokenizer hash table */
243771 /* This virtual table always delivers results in ascending order of
243831 "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
243872 ** on the xClose method of the virtual table interface.
243935 ** Advance the cursor to the next row in the table.
244063 ** This is the xFilter implementation for the virtual table.
244136 ** This is the xEof method of the virtual table. SQLite calls this
244275 ** This file demonstrates an eponymous virtual table that returns information
244306 ** serve as the underlying representation of a stmt virtual table
244327 ** stmt_vtab that describes the stmt virtual table.
244528 ** that uses the stmt virtual table. This routine needs to create
244543 ** stmt virtual table.
246132 sql = sqlite3_mprintf("SELECT 'CREATE TABLE %s.' || substr(sql,14) FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence' AND rootpage>0;", dbName);
246162 sql = sqlite3_mprintf("SELECT 'INSERT INTO %s.' || quote(name) || ' SELECT * FROM main.' || quote(name) || ';' FROM main.sqlite_master WHERE type = 'table' AND name!='sqlite_sequence' AND rootpage>0;", dbName);
246192 sql = sqlite3_mprintf("INSERT INTO %s.sqlite_master SELECT type, name, tbl_name, rootpage, sql FROM main.sqlite_master WHERE type='view' OR type='trigger' OR (type='table' AND rootpage=0);", dbName, dbName);