Home | History | Annotate | Download | only in orig

Lines Matching refs:Table

100 ** limits the size of a row in a table or index.
112 ** * Columns in a table
122 ** not have more than a dozen or so columns in any table. And if
184 ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
938 #define SQLITE_LOCKED 6 /* A table in the database is locked */
2200 ** ^Each entry in an SQLite table has a unique 64-bit signed
2204 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
2214 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
2216 ** row as long as the trigger or virtual table method is running.
2217 ** But once the trigger or virtual table method ends, the value returned
2219 ** table method began.)^
2259 ** are not counted. Only real table changes are counted.
2261 ** ^(A "row change" is a change to a single row of a single table
2264 ** rollback, ABORT processing, [DROP TABLE], or by any other
2309 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
2405 ** an attempt is made to open a database table that another thread
2471 ** for a specified amount of time when a table is locked. ^The handler
2493 ** Definition: A <b>result table</b> is memory data structure created by the
2494 ** [sqlite3_get_table()] interface. A result table records the
2497 ** The table conceptually has a number of rows and columns. But
2498 ** these numbers are not part of the result table itself. These
2502 ** A result table is an array of pointers to zero-terminated UTF-8 strings.
2509 ** A result table might consist of one or more memory allocations.
2510 ** It is not safe to pass a result table directly to [sqlite3_free()].
2511 ** A result table should be deallocated using [sqlite3_free_table()].
2513 ** ^(As an example of the result table format, suppose a query result
2525 ** result table has 8 entries. Suppose the result table is stored
2541 ** string of its 2nd parameter and returns a result table to the
2545 ** it must pass the result table pointer to sqlite3_free_table() in order to
2623 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
2651 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
2772 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2823 ** a NULL value in place of the table column that would have
2826 ** columns of a table.
2909 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
2910 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
2911 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
2912 #define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
2913 #define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
2915 #define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
2917 #define SQLITE_DELETE 9 /* Table Name NULL */
2918 #define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
2919 #define SQLITE_DROP_TABLE 11 /* Table Name NULL */
2920 #define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
2921 #define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
2922 #define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
2924 #define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
2926 #define SQLITE_INSERT 18 /* Table Name NULL */
2928 #define SQLITE_READ 20 /* Table Name Column Name */
2931 #define SQLITE_UPDATE 23 /* Table Name Column Name */
2934 #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
2936 #define SQLITE_ANALYZE 28 /* Table Name NULL */
2937 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
2938 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
3157 ** <table border="1" align=center cellpadding=5>
3181 ** </table>
3373 ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
3379 ** <dd>The maximum number of columns in a table definition or in the
3600 ** that can be stored in a database table. SQLite uses dynamic typing
3862 ** ^These routines provide a means to determine the database, table, and
3863 ** table column that is the origin of a particular result column in
3865 ** ^The name of the database or table or column can be returned as
3867 ** the database name, the _table_ routines return the table name, and
3876 ** database, table, and column.
3886 ** occurs. ^Otherwise, they return the name of the attached database, table,
3916 ** returned result set of that [SELECT] is a table column (not an
3917 ** expression or subquery) then the declared type of the table
3924 ** CREATE TABLE t1(c1 VARIANT);
4150 ** conversion automatically. ^(The following table details the conversions
4154 ** <table border="1">
4173 ** </table>
4176 ** The table above makes reference to standard C library functions atoi()
4179 ** used in the table for brevity and because they are familiar to most
5142 ** database and table name containing the affected row.
5300 ** CAPI3REF: Extract Metadata About A Column Of A Table
5303 ** database table accessible using the [database connection] handle
5309 ** table or NULL. ^If it is NULL, then all attached databases are searched
5310 ** for the table using the same algorithm used by the database engine to
5311 ** resolve unqualified table references.
5313 ** ^The third and fourth parameters to this function are the table and column
5322 ** <table border="1">
5330 ** </table>
5337 ** ^If the specified table is actually a view, an [error code] is returned.
5354 ** error occurs during this process, or if the requested table or column
5364 const char *zTableName, /* Table name */
5466 ** The interface to the virtual-table mechanism is currently considered
5470 ** When the virtual-table mechanism stabilizes, we will declare the
5475 ** Structures used by the virtual table interface
5483 ** CAPI3REF: Virtual Table Object
5484 ** KEYWORDS: sqlite3_module {virtual table module}
5486 ** This structure, sometimes called a "virtual table module",
5490 ** ^A virtual table module is created by filling in a persistent
5534 ** CAPI3REF: Virtual Table Indexing Information
5538 ** of the [virtual table] interface to
5540 ** method of a [virtual table module]. The fields under **Inputs** are the
5560 ** relevant to the particular virtual table being queried.
5570 ** virtual table and is not checked again by SQLite.)^
5582 ** particular lookup. A full scan of a table
5583 ** a cost of N. A binary search of a table of N entries should have a
5594 } *aConstraint; /* Table of WHERE clause constraints */
5613 ** CAPI3REF: Virtual Table Constraint Operator Codes
5618 ** a query that uses a [virtual table].
5628 ** CAPI3REF: Register A Virtual Table Implementation
5630 ** ^These routines are used to register a new [virtual table module] name.
5632 ** creating a new [virtual table] using the module and before using a
5633 ** preexisting [virtual table] for the module.
5638 ** the implementation of the [virtual table module]. ^The fourth
5640 ** into the [xCreate] and [xConnect] methods of the virtual table module
5641 ** when a new virtual table is be being created or reinitialized.
5667 ** CAPI3REF: Virtual Table Instance Object
5670 ** Every [virtual table module] implementation uses a subclass
5672 ** of the [virtual table]. Each subclass will
5685 const sqlite3_module *pModule; /* The module for this virtual table */
5688 /* Virtual table implementations will typically add additional fields */
5692 ** CAPI3REF: Virtual Table Cursor Object
5693 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
5695 ** Every [virtual table module] implementation uses a subclass of the
5697 ** [virtual table] and are used
5698 ** to loop through the virtual table. Cursors are created using the
5709 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
5710 /* Virtual table implementations will typically add additional fields */
5714 ** CAPI3REF: Declare The Schema Of A Virtual Table
5717 ** [virtual table module] call this interface
5724 ** CAPI3REF: Overload A Function For A Virtual Table
5727 ** using the [xFindFunction] method of the [virtual table module].
5737 ** by a [virtual table].
5742 ** The interface to the virtual-table mechanism defined above (back up
5747 ** When the virtual-table mechanism stabilizes, we will declare the
5769 ** in row iRow, column zColumn, table zTable in database zDb;
5835 ** to a different row of the same database table. ^The new row is identified
5837 ** changed. ^The database, table and column on which the blob handle is open
5843 ** the nominated column.)^ ^If the new row is not present in the table, or if
6580 ** statements. For example, if the number of table steps greatly exceeds
6581 ** the number of table searches or result rows, that would tend to indicate
6582 ** that the prepared statement is using a full table scan rather than
6609 ** a table as part of a full table scan. Large numbers for this counter
6764 ** <table border=1 width=85% align=center>
6771 ** </table>
7097 ** shared-cache table, and more than one other connection currently holds
7098 ** a read-lock on the same table, then SQLite arbitrarily selects one of
7158 ** <b>The "DROP TABLE" Exception</b>
7162 ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement,
7167 ** invoked immediately. If the application then re-attempts the "DROP TABLE"
7173 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7394 ** CAPI3REF: Virtual Table Interface Configuration
7397 ** of a [virtual table] implementation to configure
7398 ** various facets of the virtual table interface.
7401 ** xCreate virtual table method then the behavior is undefined.
7410 ** CAPI3REF: Virtual Table Configuration Options
7413 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
7420 ** where X is an integer. If X is zero, then the [virtual table] whose
7428 ** If X is non-zero, then the virtual table implementation guarantees
7438 ** Virtual table implementations that are required to handle OR REPLACE
7441 ** CONFLICT policy is REPLACE, the virtual table implementation should
7451 ** CAPI3REF: Determine The Virtual Table Conflict Policy
7454 ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The
7458 ** [virtual table].
7466 ** inform a [virtual table] implementation what the [ON CONFLICT] mode
7566 ** This is the header file for the generic hash-table implemenation
7576 /* A complete hash table is an instance of the following structure.
7584 ** All elements of the hash table are on a single doubly-linked list.
7593 ** Hash.ht table is never allocated because if there are few elements
7594 ** in the table, it is faster to do a linear search than to manage
7595 ** the hash table.
7598 unsigned int htsize; /* Number of buckets in the hash table */
7599 unsigned int count; /* Number of entries in this table */
7601 struct _ht { /* the hash table */
7607 /* Each element in the hash table is an instance of the following
7614 HashElem *next, *prev; /* Next and previous elements in the table */
7628 ** Macros for looping over all elements of a hash table. The idiom is
7646 ** Number of entries in a hash table
7961 ** table or index. This is an unsigned integer type. For 99.9% of
8043 ** Name of the master database table. The master database table
8044 ** is a special table that holds the names and attributes of all
8051 ** The root-page of the master database table.
8056 ** The name of the schema table.
8154 typedef struct Table Table;
8274 ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.
8275 ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data
8281 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
8282 #define BTREE_BLOBKEY 2 /* Table has keys only - no data */
8313 Btree*, /* BTree containing table to open */
9628 Hash fkeyHash; /* All foreign keys by referenced table name */
9629 Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
9701 ** A hash table for function definitions.
9707 FuncDef *a[23]; /* Hash table for functions */
9739 int newTnum; /* Rootpage of table being initialized */
9791 FuncDefHash aFunc; /* Hash table of connection functions */
9830 #define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */
9865 #define SQLITE_IndexCover 0x10 /* Disable index covering table */
9886 ** hash table. When multiple functions have the same name, the hash table
9992 ** Each SQLite module (virtual table definition) is defined by an
9994 ** hash table.
10004 ** information about each column of an SQL table is held in an instance
10093 ** An object of this type is created for each virtual table present in
10099 ** instance of the sqlite3_vtab* handle used to access the virtual table
10105 ** then be used by the virtual table implementation to access real tables
10108 ** connection as that used to execute SQL operations on the virtual table.
10110 ** All VTable objects that correspond to a single table in a shared
10112 ** the Table.pVTable member variable of the corresponding Table object.
10114 ** table, it searches the list for the VTable that corresponds to the
10118 ** When an in-memory Table object is deleted (for example when the
10121 ** immediately. Instead, they are moved from the Table.pVTable list to
10135 sqlite3 *db; /* Database connection associated with this table */
10145 ** Each SQL table is represented in memory by an instance of the
10148 ** Table.zName is the name of the table. The case of the original
10149 ** CREATE TABLE statement is stored, but case is not significant for
10152 ** Table.nCol is the number of columns in this table. Table.aCol is a
10155 ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
10156 ** the column that is that key. Otherwise Table.iPKey is negative. Note
10159 ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid
10160 ** is generated for each row of the table. TF_HasPrimaryKey is set if
10161 ** the table has any PRIMARY KEY, INTEGER or otherwise.
10163 ** Table.tnum is the page number for the root BTree page of the table in the
10164 ** database file. If Table.iDb is the index of the database table backend
10167 ** then the table is stored in a file that is automatically deleted
10168 ** when the VDBE cursor to the table is closed. In this case Table.tnum
10169 ** refers VDBE cursor number that holds the table open, not to the root
10171 ** sub-query that appears instead of a real table name in the FROM clause
10174 struct Table {
10175 char *zName; /* Name of the table or view */
10177 int nCol; /* Number of columns in this table */
10179 Index *pIndex; /* List of SQL indexes on this table. */
10180 int tnum; /* Root BTree node for this table (see note above) */
10181 tRowcnt nRowEst; /* Estimated rows in table - from sqlite_stat1 table */
10183 u16 nRef; /* Number of pointers to this Table */
10186 FKey *pFKey; /* Linked list of all foreign keys in this table */
10192 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
10200 Schema *pSchema; /* Schema that contains this table */
10201 Table *pNextZombie; /* Next on the Parse.pZombieTab list */
10207 #define TF_Readonly 0x01 /* Read-only system table */
10208 #define TF_Ephemeral 0x02 /* An ephemeral table */
10209 #define TF_HasPrimaryKey 0x04 /* Table has a primary key */
10211 #define TF_Virtual 0x10 /* Is a virtual table */
10215 ** Test to see whether or not a table is a virtual table. This is
10217 ** table support is omitted from the build.
10230 ** A foreign key is associated with two tables. The "from" table is
10231 ** the table that contains the REFERENCES clause that creates the foreign
10232 ** key. The "to" table is the table that is named in the REFERENCES clause.
10235 ** CREATE TABLE ex1(
10240 ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2".
10243 ** which is attached to the from-table. The to-table need not exist when
10244 ** the from-table is created. The existence of the to-table is not checked.
10247 Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */
10249 char *zTo; /* Name of table that the key points to (aka: Parent) */
10250 FKey *pNextTo; /* Next foreign key on table named zTo */
10251 FKey *pPrevTo; /* Previous foreign key on table named zTo */
10282 ** referenced table row is propagated into the row that holds the
10322 ** Records are used to store the content of a table row and to store
10349 ** The columns of the table that are to be indexed are described
10351 ** we have the following table and index:
10353 ** CREATE TABLE Ex1(c1 int, c2 int, c3 text);
10356 ** In the Table structure describing Ex1, nCol==3 because there are
10357 ** three columns in the table. In the Index structure describing
10375 Table *pTable; /* The SQL table being indexed */
10377 Index *pNext; /* The next index associated with the same table */
10381 int nColumn; /* Number of columns in the table used by this index */
10394 ** Each sample stored in the sqlite_stat3 table is represented in memory
10441 ** than the source table */
10443 int sortingIdxPTab; /* Cursor number of pseudo-table */
10447 Table *pTab; /* Source table */
10448 int iTable; /* Cursor number of the source table */
10449 int iColumn; /* Column number within the source table */
10462 int iDistinct; /* Ephemeral table used to enforce DISTINCT */
10509 ** An expression of the form ID or ID.ID refers to a column in a table.
10511 ** the integer cursor number of a VDBE cursor pointing to that table and
10527 ** If the Expr is of type OP_Column, and the table it is selecting from
10528 ** is a disk table or the "old.*" pseudo-table, then pTab points to the
10529 ** corresponding table definition.
10573 int iTable; /* TK_COLUMN: cursor number of table holding column
10579 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
10583 Table *pTab; /* Table for TK_COLUMN expressions. */
10693 ** column names after a table name in an INSERT statement. In the statement
10697 ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
10702 int idx; /* Index in some Table.aCol[] of a column named zName */
10723 ** Each table or subquery in the FROM clause is a separate element of
10727 ** can also be used to describe a particular table such as the table that
10729 ** such a table must be a simple name: ID. But in SQLite, the table can
10730 ** now be identified by a database name, a dot, then the table name: ID.ID.
10732 ** The jointype starts out showing the join type between the current table
10733 ** and the next table on the list. The parser builds the list this way.
10735 ** jointype expresses the join between the table and the previous table.
10737 ** In the colUsed field, the high-order bit (bit 63) is set if the table
10744 char *zDatabase; /* Name of database holding this table */
10745 char *zName; /* Name of the table */
10747 Table *pTab; /* An SQL table corresponding to zName */
10748 Select *pSelect; /* A SELECT statement used in place of a table name */
10757 int iCursor; /* The VDBE cursor number used to access this table */
10799 sqlite3_index_info *pVtabIdx; /* Virtual table index to use */
10810 ** virtual table. The pIdxInfo pointer contains indexing
10811 ** information for the i-th table in the FROM clause before reordering.
10813 ** All other information in the i-th WhereLevel object for the i-th table
10819 int iTabCur; /* The VDBE cursor used to access the table */
10839 ** we need a place to cache virtual table index information for each
10840 ** virtual table in the FROM clause and the WhereLevel structure is
10844 sqlite3_index_info *pIdxInfo; /* Index info for n-th source table */
10856 #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
10858 #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
10889 ** A NameContext defines a context in which to resolve table and column
10893 ** to the table being operated on by INSERT, UPDATE, or DELETE. The
10972 #define SF_HasTypeInfo 0x20 /* FROM subqueries have Table metadata */
11011 ** tables, the following information is attached to the Table.u.autoInc.p
11012 ** pointer of each autoincrement table to record some side information that
11013 ** the code generator needs. We have to keep per-table autoincrement
11020 Table *pTab; /* Table this info block refers to */
11079 ** used to store the set of table-locks required by the statement being
11109 int iTable; /* Table cursor number */
11110 int iColumn; /* Table column number */
11120 int regRowid; /* Register holding rowid of CREATE TABLE entry */
11125 TableLock *aTableLock; /* Required table locks for shared-cache mode */
11131 Table *pTriggerTab; /* Table triggers are being coded for */
11159 Table *pNewTable; /* A table being constructed by CREATE TABLE */
11166 Table **apVtabLock; /* Pointer to virtual tables needing locking */
11168 Table *pZombieTab; /* List of Table objects to delete after code gen */
11198 #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
11205 * 1. In the "trigHash" hash table (part of the sqlite3* that represents the
11207 * 2. All triggers associated with a single table form a linked list, using the
11210 * struct Table.
11217 char *table; /* The table or view to which the trigger applies */
11224 Schema *pTabSchema; /* Schema containing the table */
11226 Trigger *pNext; /* Next trigger associated with the table */
11256 * target -> A token holding the quoted name of the table to insert into.
11264 * target -> A token holding the quoted name of the table to delete from.
11269 * target -> A token holding the quoted name of the table to update rows of.
11282 Token target; /* Target table for DELETE, UPDATE, INSERT */
11603 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
11636 SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse*,Table*);
11642 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);
11643 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);
11672 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
11673 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
11674 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
11682 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
11683 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
11700 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
11701 SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
11732 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
11733 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
11735 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
11737 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
11738 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
11758 SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, int);
11767 SQLITE_PRIVATE Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
11768 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *, Table *);
11769 SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
11771 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
11772 void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
11781 SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
11862 SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *, Table *);
11927 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
12004 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table*);
12012 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
12015 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
12021 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
12044 SQLITE_PRIVATE void sqlite3FkCheck(Parse*, Table*, int, int);
12045 SQLITE_PRIVATE void sqlite3FkDropTable(Parse*, SrcList *, Table*);
12046 SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int);
12047 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
12048 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
12049 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
12058 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
12249 ** The following 256 byte lookup table is used to support SQLites built-in
12363 ** Hash table for global functions - functions common to all
12364 ** database connections. After initialization, this table is
12878 Btree *pBt; /* Separate file holding temporary table */
12889 Bool isTable; /* True if a table requiring integer keys */
12891 Bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */
12893 sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */
13111 ** any virtual table method invocations made by the vdbe program. It is
13114 ** "DROP TABLE" statements and to prevent some nasty side effects of
13115 ** malloc failure when SQLite is invoked recursively by a virtual table
13475 sqlite3DeleteTable(db, (Table *)sqliteHashData(p));
15048 ** fatal. For example, if a malloc fails while resizing a hash table, this
15050 ** hash table will continue to function normally. So a malloc failure
15051 ** during a hash table resize is a benign fault.
16186 ** small chunk list, or into the large chunk hash table.
16357 ** chunk table or in the large chunk hash table. This is
19435 ** The following table is searched linearly, so it is good to put the
20532 ** This lookup table is used to help decode the first byte of
22250 /* Turn bulk memory into a hash table object by initializing the
22253 ** "pNew" is a pointer to the hash table that is to be initialized.
22263 /* Remove all entries from a hash table. Reclaim all memory.
22264 ** Call this routine to delete a hash table or to reset a hash table
22268 HashElem *elem; /* For looping over all elements of the table */
22298 /* Link pNew element into the hash table pH. If pEntry!=0 then also
22302 Hash *pH, /* The complete hash table */
22329 /* Resize the hash table so that it cantains "new_size" buckets.
22331 ** The hash table might fail to resize if sqlite3_malloc() fails or
22336 struct _ht *new_ht; /* The new hash table */
22346 /* The inability to allocates space for a larger hash table is
22368 ** hash table that matches the given key. The hash for this key has
22397 /* Remove a single entry from the hash table given a pointer to that
22431 /* Attempt to locate an element of the hash table pH with a key
22451 /* Insert an element into the hash table pH. The key is pKey,nKey
22460 ** the new data is returned and the hash table is unchanged.
22463 ** element corresponding to "key" is removed from the hash table.
22466 unsigned int h; /* the hash of the key modulo hash table size */
35832 ** But sometimes (for example when during a DROP of a large table) most
35870 /* Number of u32 values in hash table. */
35872 /* Maximum number of entries in hash table before
35895 ** a hash table that will hold up to BITVEC_MXHASH distinct values.
35916 u32 aHash[BITVEC_NINT]; /* Hash table representation */
36046 ** that BitvecClear can use to rebuilt its hash table.
36924 /* Hash table of all pages. The following variables may only be accessed
36930 PgHdr1 **apHash; /* Hash table for fast lookup by key */
36942 PgHdr1 *pNext; /* Next in hash table chain */
37219 ** This function is used to resize the hash table used by the cache passed
37299 ** Remove the page supplied as an argument from the hash table
37570 /* Step 1: Search the hash table for an existing entry. */
40073 ** Find a page in the hash table given its page number. Return
41013 ** in this case. But for things like temporary table (which will be
45496 ** database page number associated with each wal frame, and a hash-table
45511 ** Even without using the hash table, the last frame for page P
45518 ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
45520 ** hash table for each page number in the mapping section, so the hash
45521 ** table is never more than half full. The expected number of collisions
45522 ** prior to finding a match is 1. Each entry of the hash table is an
45527 ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table
45530 ** To look for page P in the hash table, first compute a hash iKey on
45535 ** Then start scanning entries of the hash table, starting with iKey
45536 ** (wrapping around to the beginning when the end of the hash table is
45539 ** wrap-around.) Because the hash table is never more than half full,
45563 ** Both readers can use the same hash table and mapping section to get
45564 ** the correct result. There may be entries in the hash table with
45566 ** slots in the hash table and so the first reader will get an answer as
45567 ** if no values greater than K0 had ever been inserted into the hash table
45572 ** When a rollback occurs, the value of K is decreased. Hash table entries
45574 ** from the hash table at this point.
45785 ** Each page of the wal-index mapping contains a hash-table made up of
45819 ** is a hash-table following every HASHTABLE_NPAGE page numbers in the
45830 ** The block of page numbers associated with the first hash-table in a
45832 ** hash-table on each aligned 32KB page of the wal-index.
46156 ** Return pointers to the hash table and page number array stored on
46160 ** Set output variable *paHash to point to the start of the hash table
46162 ** number of the first frame indexed by this hash table. If a
46163 ** slot in the hash table is set to N, it refers to frame number
46167 ** first frame indexed by the hash table, frame (*piZero+1).
46171 int iHash, /* Find the iHash'th table */
46202 ** Return the number of the wal-index page that contains the hash-table
46230 ** Remove entries from the hash table that point to WAL slots greater
46236 ** At most only the hash table containing pWal->hdr.mxFrame needs to be
46242 volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
46243 volatile u32 *aPgno = 0; /* Page number array for hash table */
46256 /* Obtain pointers to the hash-table and page-number array containing
46258 ** that the page said hash-table and array reside on is already mapped.
46264 /* Zero all hash-table entries that correspond to frame numbers greater
46283 ** via the hash table even after the cleanup.
46307 volatile ht_slot *aHash = 0; /* Hash table */
46312 ** page number array and hash table entry.
46315 int iKey; /* Hash table key */
46316 int idx; /* Value to write to hash-table slot */
46322 /* If this is the first entry to be added to this hash-table, zero the
46323 ** entire hash table and aPgno[] array before proceding.
46334 ** the hash-table before writing any new entries.
46341 /* Write the aPgno[] array entry and the hash-table slot. */
46350 /* Verify that the number of entries in the hash table exactly equals
46355 int nEntry = 0; /* Number of entries in the hash table */
46361 ** via the hash table. This turns out to be a really, really expensive
47653 /* Search the hash table or tables for an entry matching page number
47655 ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
47659 ** table). This means the value just read from the hash
47669 ** if we had exclusive access to the hash-table:
47672 ** This condition filters out normal hash-table collisions.
47676 ** table after the current read-transaction had started.
47679 volatile ht_slot *aHash; /* Pointer to hash table */
48745 ** is opened on the table with root page BtShared.iTable. Locks are removed
48751 Pgno iTable; /* Root page of table */
48827 ** table (because there exists one or more read-locks on the table),
48857 u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */
48858 u16 minLeaf; /* Minimum local payload in a LEAFDATA table */
48963 ** because the table is empty or because BtreeCursorFirst() has not been
48967 ** The table that this cursor was opened on still exists, but has been
49010 ** The pointer map is a lookup table that identifies the parent page for
49251 ** a statement since we will be comparing table and column names
49447 ** shared-cache table level locks. If the library is compiled with the
49467 ** table with root page iRoot. Return 1 if it does and 0 if not.
49469 ** For example, when writing to a table with root-page iRoot via
49476 ** the corresponding table. This makes things a bit more complicated,
49477 ** as this module treats each table as a separate structure. To determine
49478 ** the table corresponding to the index being written, this
49481 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
49482 ** hold a write-lock on the schema table (root page 1). This is also
49514 /* Figure out the root-page that the lock should be held on. For table
49517 ** table. */
49531 ** write-lock on the schema table, or (if the client is reading) a
49552 ** table or index rooted at iRoot because other shared connections are
49553 ** simultaneously reading that same table or index.
49557 ** the iRoot table. Except, if the other Btree object has the
49561 ** For example, before writing to any part of the table or index
49582 ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return
49622 ** may hold a WRITE_LOCK on any table in this file (since there can
49642 ** Add a lock on the table with root-page iTable to the shared-btree used
49670 ** table, and that lock is obtained in BtreeBeginTrans(). */
49678 /* First search the list for an existing lock on this table. */
49687 ** with table iTable, allocate one and link it into the list.
49715 ** Release all the table locks (locks obtained via calls to
49818 ** This function is called before modifying the contents of a table
49823 ** table is about to be deleted. In this case invalidate all incrblob
49824 ** cursors open on any row within the table with root-page pgnoRoot.
49940 /* If this is an intKey table, then the above call to BtreeKeySize()
49943 ** table, then malloc space for and store the pCur->nKey bytes of key
49977 ** the table with root-page iRoot. Usually, this is called just before cursor
49978 ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()).
51405 ** The call to sqlite3BtreeRollback() drops any table-locks held by
52806 ** cursors open with wrFlag==0 on the same table. Otherwise
52823 int iTable, /* Root page of table to open */
52834 ** b-tree database, the connection is holding the required table locks,
52872 int iTable, /* Root page of table to open */
53020 ** that is currently pointing to a row in a (non-empty) table.
53033 ** For a table with the INTKEY flag set, this routine returns the key
53200 ** invalidated if some other cursor writes to the same table, or if
53206 ** * Creating a table (may require moving an overflow page).
53380 ** in the table.
53606 ** If the table has a virtual root page, then the cursor is moved to point
53607 ** to the virtual root page instead of the actual root page. A table has a
53609 ** single child page. This can only happen with the table rooted at page 1.
53620 ** indicating a table b-tree, or if the caller did specify a KeyInfo
53661 ** NULL, the caller expects a table b-tree. If this is not the case,
53748 /* Move the cursor to the first entry in the table. Return SQLITE_OK
53750 ** or set *pRes to 1 if the table is empty.
53771 /* Move the cursor to the last entry in the table. Return SQLITE_OK
53773 ** or set *pRes to 1 if the table is empty.
53829 ** is smaller than intKey/pIdxKey or if the table is empty
53842 i64 intKey, /* The table key */
53891 ** be the right kind (index or table) of b-tree page. Otherwise
54021 ** Return TRUE if the cursor is not pointing at an entry of the table.
54024 ** past the last entry in the table or sqlite3BtreePrev() moves past
54025 ** the first entry. TRUE is also returned if the table is empty.
54028 /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
54189 ** is only used by auto-vacuum databases when allocating a new table.
55646 ** of the table is a linear scan through the file. That
56102 ** define what table the record should be inserted into. The cursor
56105 ** For an INTKEY table, only the nKey value of the key is used. pKey is
56106 ** ignored. For a ZERODATA table, the pData and nData are both ignored.
56122 BtCursor *pCur, /* Insert data into the table of this cursor */
56152 ** intkey table, the caller should be inserting integer keys with a
56156 /* If this is an insert into a table b-tree, invalidate any incrblob
56163 /* Save the positions of any other cursors open on this table.
56166 ** example, when inserting data into a table with auto-generated integer
56186 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
56238 ** entry in the table, and the next row inserted has an integer key
56286 /* If this is a delete operation to remove a row from a table b-tree,
56310 /* Save the positions of any other cursors open on this table before
56377 ** Create a new BTree table. Write into *piTable the page
56378 ** number for the root page of the new table.
56392 int ptfFlags; /* Page-type flage for the root page of new table */
56408 /* Creating a new table may probably require moving an existing database
56416 ** root page of the new table should go. meta[3] is the largest root-page
56442 ** the new table (assuming an error did not occur). But we were
56535 BtShared *pBt, /* The BTree that contains the table */
56580 ** Delete all information from a single table in the database. iTable is
56581 ** the page number of the root of the table. After this routine returns,
56585 ** read cursors on the table. Open write cursors are moved to the
56586 ** root of the table.
56588 ** If pnChange is not NULL, then table iTable must be an intkey table. The
56590 ** entries in the table.
56598 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56599 ** is the root of a table b-tree - if it is not, the following call is
56612 ** Erase all information in a table and add the root of the table to
56613 ** the freelist. Except, the root of the principle table (the one on
56617 ** cursors on the table.
56639 /* It is illegal to drop a table if any cursors are open on the
56672 /* If the table being dropped is the table with the largest root-page
56681 /* The table being dropped does not have the largest root-page
57276 ** a table. nRoot is the number of entries in aRoot.
57498 ** sqlite_master table. Otherwise SQLITE_OK.
57513 ** Obtain a lock on the table whose root page is iTab. The
57539 ** INTKEY table currently pointing at a valid table entry.
57565 ** (c) the connection holds a write-lock on the table (if required),
57567 ** (e) the cursor points at a valid row of an intKey table.
60596 ** to 6.6 percent. The test case is inserting 1000 rows into a table
62053 ** the blob of data that it corresponds to. In a table record, all serial
62058 ** The following table describes the various storage classes for data:
62435 ** This function compares the two table rows or index records
63592 ** 3 The name of the table that the column derives from
63593 ** 4 The name of the table column that the result column derives from
63687 ** Return the name of the table from which a result column derives.
63703 ** Return the name of the table column from which a result column derives.
64526 int nField, /* Number of fields in the table or index */
64528 int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */
65207 VdbeCursor *pC; /* Cursor of table to get the new rowid */
65217 VdbeCursor *pC; /* Cursor to table into which insert is written */
65221 const char *zTbl; /* Table name - used by the opdate hook */
66326 ** with a CREATE TABLE statement.)
66997 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
66999 ** The first OP_Column against a pseudo-table after the value of the content
67108 /* Read and parse the table header. Store the results of the parse
67165 ** in the table, and in that case, 5*u.an.nField+3 might be smaller than u.an.offset.
67220 ** table. Set the u.an.offset for any extra columns not present in
67327 ** use as a data record in a database table or as a key
67460 ** Store the number of entries (an integer value) in the table or index
67915 ** are queried from within xNext() and other v-table methods using
67918 ** v-table would have to be ready for the sqlite3_vtab structure itself
67920 ** a v-table method.
67934 ** Open a read-only cursor for the database table whose root page is
67958 ** value, it is set to the number of columns in the table.
67964 ** Open a read/write cursor named P1 on the table or index whose root
67972 ** value, it is set to the number of columns in the table, or to the
67973 ** largest index of any column of the table that is actually used.
67976 ** in read/write mode. For a given table, there can be one or more read-only
68064 ** Open a new cursor P1 to a transient table.
68067 ** table is deleted automatically when the cursor is closed.
68069 ** P2 is the number of columns in the ephemeral table.
68070 ** The cursor points to a BTree table if P4==0 and to a BTree index
68075 ** confusion because the term "temp table", might refer either
68076 ** to a TEMP table at the SQL level, or to a table opened by
68078 ** that created confusion with the whole virtual-table idea.
68116 ** opening it. If a transient table is required, just use the
68117 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
68167 ** Open a new cursor that points to a fake table that contains a single
68172 ** A pseudo-table created by this opcode is used to hold a single
68175 ** is the only cursor opcode that works with a pseudo-table.
68178 ** the pseudo-table.
68209 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68222 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68235 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68248 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68393 /* u.bb.res might be negative because the table is empty. Check to
68404 /* This happens when attempting to open the sqlite3_master table
68406 ** take the jump (since there are no records in the table).
68415 ** P1 is an open table cursor and P2 is a rowid integer. Arrange
68621 ** with that key does not exist in table of P1, then jump to P2.
68626 ** operation assumes the key is an integer and that P1 is a table whereas
68664 ** sqlite_master table returns SQLITE_EMPTY.
68690 ** Get a new integer record number (a.k.a "rowid") used as the key to a table.
68692 ** table that cursor P1 points to. The new record number is written
68705 VdbeCursor *pC; /* Cursor of table to get the new rowid */
68729 ** it already exists in the table. If it does not exist, we have
68805 ** an AUTOINCREMENT table. */
68841 ** Write an entry into the table of cursor P1. A new entry is
68865 ** Parameter P4 may point to a string containing the table-name, or
68889 VdbeCursor *pC; /* Cursor to table into which insert is written */
68893 const char *zTbl; /* Table name - used by the opdate hook */
68958 ** record in the table. If it is left pointing at the next record, then
68965 ** P1 must not be pseudo-table. It has to be a real table with
68968 ** If P4 is not NULL, then it is the name of the table that P1 is
68995 ** OP_Column on the same table without any intervening operations that
69083 ** of a real table, not a pseudo-table.
69093 ** of a real table, not a pseudo-table.
69162 ** Store in register P2 an integer which is the key of the table entry that
69165 ** P1 can be either an ordinary table or a virtual table. There used to
69167 ** one opcode now works for both table types.
69235 ** will refer to the last entry in the database table or index.
69236 ** If the table or index is empty and P2>0, then jump immediately to P2.
69237 ** If P2 is 0 or if the table or index is not empty, fall through
69293 ** will refer to the first entry in the database table or index.
69294 ** If the table or index is empty and P2>0, then jump immediately to P2.
69295 ** If P2 is 0 or if the table or index is not empty, fall through
69332 ** table or index. If there are no more key/value pairs then fall through
69336 ** The P1 cursor must be for a real table, not a pseudo-table.
69349 ** table or index. If there is no previous key/value pairs then fall through
69353 ** The P1 cursor must be for a real table, not a pseudo-table.
69497 ** the rowid of the table entry to which this index entry points.
69599 ** Delete an entire database table or index whose root page in the database
69602 ** The table being destroyed is in the main database file if P3==0. If
69603 ** P3==1 then the table to be clear is in the auxiliary database file
69604 ** that is used to store tables create using CREATE TEMPORARY TABLE.
69611 ** movement was required (because the table being dropped was already
69659 ** Delete all contents of the database table or index whose root page
69661 ** remove the table or index from the database file.
69663 ** The table being clear is in the main database file if P2==0. If
69664 ** P2==1 then the table to be clear is in the auxiliary database file
69665 ** that is used to store tables create using CREATE TEMPORARY TABLE.
69667 ** If the P3 value is non-zero, then the table referred to must be an
69668 ** intkey table (an SQL table, not an index). In this case the row change
69669 ** count is incremented by the number of rows in the table being cleared.
69671 ** also incremented by the number of rows in the table being cleared.
69698 ** Allocate a new table in the main database file if P1==0 or in the
69700 ** P1>1. Write the root page number of the new table into
69703 ** The difference between a table and an index is this: A table must
69713 ** P1>1. Write the root page number of the new table into
69744 ** Read and parse all entries from the SQLITE_MASTER table of database P1
69802 ** Read the sqlite_stat1 table for database P1 and load the content
69803 ** of that table into the internal index hash table. This will cause
69816 ** the table named P4 in database P1. This is called after a table
70583 ** Obtain a lock on a particular table. This instruction is only used when
70590 ** P2 contains the root-page of the table to lock.
70592 ** P4 contains a pointer to the name of the table being locked. This is only
70605 sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z);
70616 ** xBegin method for that table.
70619 ** within a callback to a virtual table xSync() method. If it is, the error
70636 ** P4 is the name of a virtual table in database P1. Call the xCreate method
70637 ** for that table.
70648 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
70649 ** of that table.
70662 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70664 ** table and stores that cursor in P1.
70709 ** This opcode invokes the xFilter method on the virtual table specified
70779 ** the row of the virtual-table that the
70837 ** Advance virtual table P1 to the next row in its result set and
70838 ** jump to instruction P2. Or, if the virtual table has reached
70863 ** some other method is next invoked on the save virtual table cursor.
70884 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70916 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70926 ** row. This can be NULL to have the virtual table select the new
71202 int iCol; /* Table column this handle is open on */
71284 const char *zTable, /* The table containing the blob */
71294 ** db/table/row entry. The reason for using a vdbe program instead
71328 Table *pTab;
71352 sqlite3ErrorMsg(pParse, "cannot open virtual table: %s", zTable);
71444 /* Make sure a mutex is held on the table to be accessed */
71464 ** think that the table has one more column than it really
71604 ** database table.
72697 ** Table of methods for JournalFile sqlite3_file object.
72981 ** Table of methods for MemJournal sqlite3_file object.
73182 ** table and column.
73293 ** pExpr->iTable Set to the cursor number for the table obtained
73295 ** pExpr->pTab Points to the Table structure of X.Y (even if
73297 ** pExpr->iColumn Set to the column number within the table.
73304 ** can be used. The zTable variable is the name of the table (the "Y"). This
73306 ** means that the form of the name is Z and that columns from any table
73314 const char *zDb, /* Name of the database containing table, or NULL */
73315 const char *zTab, /* Name of table containing column, or NULL */
73322 int cntTab = 0; /* Number of matching table names */
73346 Table *pTab;
73377 ** is for the right-hand table of a NATURAL JOIN or is in a
73403 Table *pTab = 0;
73464 ** SELECT a+b AS x FROM table WHERE x<10;
73535 /* If a column from a table in pSrcList is referenced, then record
73657 /* A table name and column name: ID.ID
73658 ** Or a database, table and column: ID.ID.ID
74279 ** table columns and result-set columns. At the same time, do error
74283 ** To resolve table columns references we look for nodes (or subtrees) of the
74289 ** Y: The name of a table in a FROM clause. Or in a trigger
74292 ** Z: The name of a column in table Y.
74297 ** Expr.pTab Points to the Table object for X.Y
74306 ** Table-name and function resolution occurs on the substituted expression
74419 ** CREATE TABLE t1(a);
75291 Table *pTab;
75744 Table *pTab;
75763 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
75786 ** The index of the cursor opened on the b-tree (database table, database index
75787 ** or ephermal table) is stored in pX->iTable before this function returns.
75790 ** IN_INDEX_ROWID - The cursor was opened on a database table.
75793 ** populated epheremal table.
75798 ** SELECT <column> FROM <table>
75802 ** epheremal table must be used unless the selected <column> is guaranteed
75807 ** for fast set membership tests. In this case an epheremal table must
75837 int eType = 0; /* Type of RHS table. IN_INDEX_* */
75838 int iTab = pParse->nTab++; /* Cursor of the RHS table */
75844 /* Check to see if an existing table or index can be used to
75846 ** ephemeral table.
75851 Table *pTab; /* Table <table>. */
75864 /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
75887 ** be used in place of a temp-table, it must be ordered according
75925 /* Could not found an existing table or index to use as the RHS b-tree.
75926 ** We will have to generate an ephemeral table to do the job.
75964 ** to some integer key column of a table B-Tree. In this case, use an
76023 KeyInfo keyInfo; /* Keyinfo for the generated table */
76034 ** expression it is handled the same way. An ephemeral table is
76056 ** table allocated and opened above.
76078 ** store it in the temporary table
76110 /* Evaluate the expression and insert it into the temp table */
76215 /* Compute the RHS. After this step, the table with cursor
76250 /* In this case, the RHS is the ROWID of table b-tree
76402 ** particular table is stored in a particular register.
76535 ** Generate code to extract the value of the iCol-th column of a table.
76539 Table *pTab, /* The table containing the value */
76540 int iTabCur, /* The cursor for this table */
76557 ** table pTab and store the column value in a register. An effort
76566 Table *pTab, /* Description of the table
76567 int iColumn, /* Index of the table column */
76568 int iTable, /* The cursor pointing to the table */
76997 ** a virtual table column.
77001 ** see if it is a column in a virtual table. This is done because
77100 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
77101 ** is set to the column of the pseudo-table to read, or to -1 to
77106 ** to reference another column of the old.* pseudo-table, where
77108 ** set to (n+1), where n is the number of columns in each pseudo-table.
77109 ** For a reference to any other column in the new.* pseudo-table, p1
77111 ** example, if the table on which triggers are being fired is
77114 ** CREATE TABLE t1(a, b);
77122 Table *pTab = pExpr->pTab;
77533 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
77534 ** is set to the column of the pseudo-table to read, or to -1 to
78218 /* If we reach this point, it means that pExpr refers to a table
78445 ** that implements the ALTER TABLE command.
78450 ** ALTER TABLE logic from the build.
78457 ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
78458 ** CREATE INDEX command. The second is a table name. The table name in
78459 ** the CREATE TABLE or CREATE INDEX statement is replaced with the third
78462 ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
78463 ** -> 'CREATE TABLE def(a, b, c)'
78486 /* The principle used to locate the table name in the CREATE TABLE
78487 ** statement is that the table name is the first non-space token that
78519 ** generated by the ALTER TABLE ... RENAME command to modify the definition
78520 ** of any foreign key constraints that use the table being renamed as the
78521 ** parent table. It is passed three arguments:
78523 ** 1) The complete text of the CREATE TABLE statement being modified,
78524 ** 2) The old name of the table being renamed, and
78525 ** 3) The new name of the table being renamed.
78527 ** It returns the new CREATE TABLE statement. For example:
78529 ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
78530 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
78582 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
78583 ** statement. The second is a table name. The table name in the CREATE
78586 ** TRIGGER, not CREATE INDEX and CREATE TABLE.
78606 /* The principle used to locate the table name in the CREATE TRIGGER
78607 ** statement is that the table name is the first token that is immediatedly
78615 /* Ran out of input before finding the table name. Return NULL. */
78637 ** Note that ON cannot be a database, table or column name, so
78647 /* Variable tname now contains the token that is the old table-name
78658 ** Register built-in functions used to help implement ALTER TABLE
78709 ** tables that have foreign key constraints that refer to table pTab (i.e.
78710 ** constraints for which pTab is the parent table) from the sqlite_master
78711 ** table.
78713 static char *whereForeignKeys(Parse *pParse, Table *pTab){
78725 ** temporary triggers on table pTab from the sqlite_temp_master table. If
78726 ** table pTab has no temporary triggers, or is itself stored in the
78729 static char *whereTempTriggers(Parse *pParse, Table *pTab){
78734 /* If the table is not located in the temp-db (in which case NULL is
78756 ** Generate code to drop and reload the internal representation of table
78758 ** Argument zName is the name of the table in the database schema at
78761 ** "ALTER TABLE RENAME TO" statement.
78763 static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
78778 /* Drop any table triggers from the internal schema. */
78786 /* Drop the table and index from the internal schema. */
78789 /* Reload the table, index and permanent trigger schemas. */
78795 /* Now, if the table is not stored in the temp database, reload any temp
78805 ** Parameter zName is the name of a table that is about to be altered
78806 ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
78807 ** If the table is a system table, this function leaves an error message
78810 ** Or, if zName is not a system table, zero is returned.
78814 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
78821 ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
78826 SrcList *pSrc, /* The table to rename. */
78827 Token *pName /* The new table name. */
78829 int iDb; /* Database that contains the table */
78831 Table *pTab; /* Table being renamed */
78835 const char *zTabName; /* Original name of the table */
78854 /* Get a NULL terminated version of the new table name. */
78858 /* Check that a table or index named 'zName' does not already exist
78863 "there is already another table or index with this name: %s", zName);
78867 /* Make sure it is not a system table being altered, or a reserved name
78868 ** that the table is being renamed to.
78904 ** Then modify the schema cookie (since the ALTER TABLE modifies the
78905 ** schema). Open a statement transaction if the table is a virtual
78906 ** table.
78915 /* If this is a virtual table, invoke the xRename() function if
78917 ** of any resources used by the v-table implementation (including other
78918 ** SQLite tables) that are identified by the name of the virtual table.
78935 /* If foreign-key support is enabled, rewrite the CREATE TABLE
78937 ** for which the renamed table is the parent table. */
78948 /* Modify the sqlite_master table to use the new table name. */
78960 "WHEN type='table' THEN %Q "
78965 "(type='table' OR type='index' OR type='trigger');",
78974 /* If the sqlite_sequence table exists in this database, then update
78975 ** it with the new table name.
78985 table, modify the sqlite_temp_master
78986 ** table. Don't do this if the table being ALTERed is itself located in
79003 Table *pFrom = p->pFrom;
79011 /* Drop and reload the internal table schema. */
79047 ** This function is called after an "ALTER TABLE ... ADD" statement
79051 ** The Table structure pParse->pNewTable was extended to include
79055 Table *pNew; /* Copy of pParse->pNewTable */
79056 Table *pTab; /* Table being altered */
79059 const char *zTab; /* Table name */
79133 /* Modify the CREATE TABLE statement. */
79145 "WHERE type = 'table' AND name = %Q",
79159 /* Reload the schema of the modified table. */
79164 ** This function is called by the parser after the table-name in
79165 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
79166 ** pSrc is the full-name of the table being altered.
79168 ** This routine makes a (partial) copy of the Table structure
79169 ** for the table being altered and sets Parse.pNewTable to point
79172 ** the copy. The copy of the Table structure is deleted by tokenize.c
79176 ** coding the "ALTER TABLE ... ADD" statement.
79179 Table *pNew;
79180 Table *pTab;
79187 /* Look up the table being altered. */
79213 /* Put a copy of the Table struct in Parse.pNewTable for the
79217 ** table because user table are not allowed to have the "sqlite_"
79220 pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
79280 ** CREATE TABLE sqlite_stat1(tbl, idx, stat);
79281 ** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);
79282 ** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);
79285 ** The sqlite_stat2 table is not created or used unless the SQLite version
79287 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
79288 ** The sqlite_stat2 table is superceded by sqlite_stat3, which is only
79296 ** name in the idx column. The tbl column is the name of the table to
79299 ** list is the number of rows in the index and in the table. The second
79316 ** rows in the table identified by sqlite_stat1.tbl.
79322 ** 3.6.18 and 3.7.8. The "stat2" table contains additional information
79324 ** the "idx" column and the "tbl" column is the name of the table to which
79326 ** table for each index.
79341 ** writes the sqlite_stat2 table. This version of SQLite only supports
79349 ** The format of the sqlite_stat3 table is similar to the format of
79350 ** the sqlite_stat2 table. There are multiple entries for each index.
79351 ** The idx column names the index and the tbl column is the table of the
79379 ** This routine generates code that opens the sqlite_stat1 table for
79381 ** SQLITE_ENABLE_STAT3 macro defined, then the sqlite_stat3 table is
79385 ** Similarly, if the sqlite_stat3 table does not exist and the library
79388 ** Argument zWhere may be a pointer to a buffer containing a table name,
79391 ** with the named table are deleted. If zWhere==0, then code is generated
79392 ** to delete all stat table entries.
79397 int iStatCur, /* Open the sqlite_stat1 table on this cursor */
79398 const char *zWhere, /* Delete entries for this table or index */
79428 Table *pStat;
79430 /* The sqlite_stat[12] table does not exist. Create it. Note that a
79431 ** side-effect of the CREATE TABLE statement is to leave the rootpage
79432 ** of the new table in register pParse->regRoot. This is important
79435 "CREATE TABLE %Q.%s(%s)", pDb->zName, zTab, aTable[i].zCols
79440 /* The table already exists. If zWhere is not NULL, delete all entries
79441 ** associated with the table zWhere. If zWhere is NULL, delete the
79442 ** entire contents of the table. */
79450 /* The sqlite_stat[12] table already exists. Delete all rows. */
79478 tRowcnt nRow; /* Number of rows in the entire table */
79485 i64 iRowid; /* Rowid in main table of the key */
79497 ** are the number of rows in the table or index (C) and the number of samples
79550 ** table.
79686 ** a single table.
79690 Table *pTab, /* Table whose indices are to be analyzed */
79692 int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */
79704 int regTabname = iMem++; /* Register containing table name */
79715 int regCount = iMem++; /* Number of rows in the table or index */
79720 int iTabCur = pParse->nTab++; /* Table cursor */
79722 int regCol = iMem++; /* Content of a column in analyzed table */
79751 /* Establish a read-lock on the table at the shared-cache level. */
79800 ** The total number of rows in the table.
79905 ** The result is a single row of the sqlite_stat1 table. The first
79906 ** two columns are the names of the table and index. The third column
79910 ** column of the table. This additional integer is a guess of how many
79911 ** rows of the table the index will select. If D is the count of distinct
79917 ** If K==0 then no entry is made into the sqlite_stat1 table.
79940 /* If the table has no indices, create a single sqlite_stat1 entry
79991 Table *pTab = (Table*)sqliteHashData(k);
79998 ** Generate code that will do an analysis of a single table in
80002 static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){
80031 ** Form 3 analyzes all indices associated with the named table.
80038 Table *pTab;
80057 /* Form 2: Analyze the database or table named */
80073 /* Form 3: Analyze the fully qualified table name */
80102 ** sqlite_stat1 table.
80104 ** argv[0] = name of the table
80109 ** the table.
80114 Table *pTable;
80182 ** Load content from the sqlite_stat3 table into the Index.aSample[]
80315 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
80317 ** during compilation and the sqlite_stat3 table is present, no data is
80321 ** sqlite_stat3 table is not present in the database, SQLITE_ERROR is
80323 ** table (if it is present) before returning.
80349 /* Check to make sure the sqlite_stat1 table exists */
80356 /* Load new statistics out of the sqlite_stat1 table */
80367 /* Load the statistics from the sqlite_stat3 table. */
80830 ** a specific database to all table references where the database name
81004 ** the table and the column that are being accessed. The auth function
81039 ** table zTab in database zDb. This function assumes that an authorization
81048 const char *zTab, /* Table name */
81071 ** The pExpr should be a TK_COLUMN expression. The table referred to
81072 ** is in pTabList or else it is the NEW or OLD table of a trigger.
81083 SrcList *pTabList /* All table that pExpr might refer to */
81086 Table *pTab = 0; /* The table being read */
81087 const char *zCol; /* Name of the column of the table */
81088 int iSrc; /* Index in pTabList->a[] of table being read */
81090 int iCol; /* Index of column in table */
81096 ** temporary table. */
81213 ** CREATE TABLE
81214 ** DROP TABLE
81238 int iDb; /* The database containing the table to be locked */
81239 int iTab; /* The root page of the table to be locked */
81241 const char *zName; /* Name of the table */
81245 ** Record the fact that we want to lock a table at run-time.
81247 ** The table to be locked has root page iTab and is found in database iDb.
81256 int iDb, /* Index of the database containing the table to lock */
81257 int iTab, /* Root page number of the table to be locked */
81259 const char *zName /* Name of the table to be locked */
81291 ** Code an OP_TableLock instruction for each table locked by the
81373 ** obtain the required table-locks. This is a no-op unless the
81453 ** table given the name of that table and (optionally) the name of the
81454 ** database containing the table. Return NULL if not found.
81456 ** If zDatabase is 0, all databases are searched for the table and the
81457 ** first matching table is returned. (No checking for duplicate table
81463 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
81464 Table *p = 0;
81483 ** table given the name of that table and (optionally) the name of the
81484 ** database containing the table. Return NULL if not found. Also leave an
81491 SQLITE_PRIVATE Table *sqlite3LocateTable(
81493 int isView, /* True if looking for a VIEW rather than a TABLE */
81494 const char *zName, /* Name of the table we are looking for */
81497 Table *p;
81507 const char *zMsg = isView ? "no such view" : "no such table";
81525 ** table and the first matching index is returned. (No checking
81561 ** unlike that index from its Table then remove the index from
81562 ** the index hash table and free all memory structures associated
81674 ** Delete memory allocated for the column names of a table or view (the
81675 ** Table.aCol[] array).
81677 static void sqliteDeleteColumnNames(sqlite3 *db, Table *pTable){
81695 ** Table. No changes are made to disk by this routine.
81698 ** the table data structure from the hash table. But it does destroy
81700 ** the table.
81702 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
81707 /* Do not delete the table until the reference count reaches zero. */
81711 /* Delete all indices associated with this table. */
81726 /* Delete any foreign keys attached to this table. */
81729 /* Delete the Table structure itself.
81745 ** Unlink the given table from the hash tables and the delete the
81746 ** table structure with all its indices and foreign keys.
81749 Table *p;
81756 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
81789 ** Open the sqlite_master table stored in database number iDb for
81790 ** writing. The table is opened using cursor 0.
81796 sqlite3VdbeChangeP4(v, -1, (char *)5, P4_INT32); /* 5 column table */
81838 /* The table or view or trigger name is passed to this routine via tokens
81839 ** pName1 and pName2. If the table name was fully qualified, for example:
81841 ** CREATE TABLE xxx.yyy (...);
81844 ** the table name is not fully qualified, i.e.:
81846 ** CREATE TABLE yyy(...);
81851 ** pName2) that stores the unqualified table name. The index of the
81886 ** unqualified name for a new schema object (table, index, view or
81902 ** Begin constructing a new table representation in memory. This is
81904 ** to a CREATE TABLE statement. In particular, this routine is called
81905 ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp
81906 ** flag is true if the table should be stored in the auxiliary database
81909 ** CREATE and TABLE.
81911 ** The new table record is initialized and put in pParse->pNewTable.
81912 ** As more of the CREATE TABLE statement is parsed, additional action
81914 ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine
81915 ** is called to complete the construction of the new table record.
81919 Token *pName1, /* First part of the name of the table or view */
81920 Token *pName2, /* Second part of the name of the table or view */
81921 int isTemp, /* True if this is a TEMP table
81923 int isVirtual, /* True if this is a VIRTUAL table */
81924 int noErr /* Do nothing if table already exists */
81926 Table *pTable;
81927 char *zName = 0; /* The name of the new table */
81930 int iDb; /* Database number to create the table in */
81931 Token *pName; /* Unqualified name of the table to create */
81933 /* The table or view name to create is passed to this routine via tokens
81934 ** pName1 and pName2. If the table name was fully qualified, for example:
81936 ** CREATE TABLE xxx.yyy (...);
81939 ** the table name is not fully qualified, i.e.:
81941 ** CREATE TABLE yyy(...);
81946 ** pName2) that stores the unqualified table name. The variable iDb is
81947 ** set to the index of the database that the table or view is to be
81953 /* If creating a temp table, the name may not be qualified. Unless
81955 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
81994 /* Make sure the new table name does not collide with an existing
81995 ** index or table name in the same database. Issue an error message if
82009 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
82022 pTable = sqlite3DbMallocZero(db, sizeof(Table));
82037 /* If this is the magic sqlite_sequence table used by autoincrement,
82038 ** then record a pointer to this table in the main database structure
82039 ** so that INSERT can find the table easily.
82048 /* Begin generating the code that will insert the table record into
82049 ** the SQLITE_MASTER table. Note in particular that we must go ahead
82050 ** and allocate the record number for the table entry now. Before any
82052 ** indices to be created and the table record must come before the
82053 ** indices. Hence, the record number for the table must be allocated
82085 /* This just creates a place-holder record in the sqlite_master table.
82090 ** The root page number of the new table is left in reg pParse->regRoot.
82133 ** Add a new column to the table currently being constructed.
82136 ** in a CREATE TABLE statement. sqlite3StartTable() gets called
82141 Table *p;
82185 ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
82190 Table *p;
82201 ** substrings in the following table. If one of the substrings is
82204 ** the table take priority. For example, if zType is 'BLOBINT',
82218 ** If none of the substrings in the above table are found,
82259 ** parsing a CREATE TABLE statement. The pFirst token is the first
82267 Table *p;
82280 ** of the table currently under construction.
82286 ** parsing a CREATE TABLE statement.
82289 Table *p;
82314 ** Designate the PRIMARY KEY for the table. pList is a list of names
82316 ** most recently added column of the table is the primary key.
82318 ** A table can have at most one primary key. If the table already has
82323 ** then we will try to use that column as the rowid. Set the Table.iPKey
82324 ** field of the table under construction to be the index of the
82325 ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is
82338 Table *pTab = pParse->pNewTable;
82344 "table \"%s\" has more than one primary key", pTab->zName);
82393 ** Add a new CHECK constraint to the table currently under construction.
82401 Table *pTab = pParse->pNewTable;
82412 ** Set the collation function of the most recently parsed table column
82416 Table *p;
82563 ** Generate a CREATE TABLE statement appropriate for the given
82564 ** table. Memory to hold the text of the statement is obtained
82567 static char *createTableStmt(sqlite3 *db, Table *p){
82592 sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
82633 ** a CREATE TABLE statement.
82635 ** The table structure that other action routines have been building
82639 ** An entry for the table is made in the master table on disk, unless
82640 ** this is a temporary table or db->init.busy==1. When db->init.busy==1
82641 ** it means we are reading the sqlite_master table because we just
82642 ** connected to the database or because the sqlite_master table has
82643 ** recently changed, so the entry for this table already exists in
82644 ** the sqlite_master table. We do not want to create it again.
82647 ** was called to create a table generated from a
82648 ** "CREATE TABLE ... AS SELECT ..." statement. The column names of
82649 ** the new table will match the result set of the SELECT.
82654 Token *pEnd, /* The final ')' token in the CREATE TABLE */
82657 Table *p;
82694 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
82696 ** for the table from the db->init.newTnum field. (The page number
82703 /* If not initializing, then create a record for the new table
82704 ** in the SQLITE_MASTER table of the database.
82706 ** If this is a TEMPORARY table, write the entry into the auxiliary
82712 char *zType; /* "view" or "table" */
82713 char *zType2; /* "VIEW" or "TABLE" */
82714 char *zStmt; /* Text of the CREATE TABLE or CREATE VIEW statement */
82722 ** Initialize zType for the new view or table.
82725 /* A regular table */
82726 zType = "table";
82727 zType2 = "TABLE";
82736 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
82737 ** statement to populate the new table. The root-page number for the
82738 ** new table is in register pParse->regRoot.
82742 ** by the new table.
82744 ** A shared-cache write-lock is not required to write to the new table,
82751 Table *pSelTab;
82783 ** SQLITE_MASTER table. We just need to update that slot with all
82802 /* Check to see if we need to create an sqlite_sequence table for
82810 "CREATE TABLE %Q.sqlite_sequence(name,seq)",
82823 /* Add the table to the in-memory representation of the database.
82826 Table *pOld;
82867 Table *p;
82924 /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */
82932 ** The Table
82936 SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
82937 Table *pSelTab; /* A fake table from which we get the result set */
82970 ** CREATE TABLE main.ex1(a);
82980 /* If we get this far, it means we need to compute the table names.
83036 Table *pTab = sqliteHashData(i);
83051 ** used by SQLite when the btree layer moves a table root page. The
83052 ** root-page of a table or index in database iDb has changed from iFrom
83055 ** Ticket #1728: The symbol table might still contain information
83058 ** have the same rootpage number as the real table or index that is
83061 ** or tables and not the table/index that is actually being moved.
83076 Table *pTab = sqliteHashData(pElem);
83092 ** Write code to erase the table with root-page iTable from database iDb.
83093 ** Also write code to modify the sqlite_master table and internal schema
83094 ** if a root-page of another table is moved by the btree-layer whilst
83104 ** is non-zero, then it is the root page number of a table moved to
83105 ** location iTable. The following code modifies the sqlite_master table to
83120 ** Write VDBE code to erase table pTab and all associated indices on disk.
83122 ** in case a root-page belonging to another table is moved by the btree layer
83125 static void destroyTable(Parse *pParse, Table *pTab){
83136 ** table and index root-pages in order, starting with the numerically
83180 ** after a DROP INDEX or DROP TABLE command.
83186 const char *zName /* Name of index or table */
83203 ** Generate code to drop a table.
83205 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
83221 /* Drop all triggers associated with the table being dropped. Code
83234 /* Remove any entries of the sqlite_sequence table associated with
83235 ** the table being dropped. This is done before the table is dropped
83236 ** at the btree level, in case the sqlite_sequence table needs to
83247 /* Drop all SQLITE_MASTER table and index entries that refer to the
83248 ** table. The program name loops through the master table and deletes
83249 ** every row that refers to a table of the same name as the one being
83251 ** created in the temp database that refers to a table in another
83261 /* Remove the table entry from SQLite's internal schema and modify
83273 ** This routine is called to do the work of a DROP TABLE statement.
83274 ** pName is the name of the table to be dropped.
83277 Table *pTab;
83299 /* If pTab is a virtual table, call ViewGetColumnNames() to ensure
83342 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
83347 /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used
83348 ** on a table.
83351 sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);
83360 /* Generate code to remove the table from the master table
83376 ** This routine is called to create a new foreign key on the table
83378 ** in the current table point to the foreign key. If pFromCol==0 then
83380 ** the table referred to. pToCol is a list of tables in the other
83381 ** pTo table that the foreign key points to. flags contains all
83385 ** An FKey structure is created and added to the table currently
83393 ExprList *pFromCol, /* Columns in this table that point to other table */
83394 Token *pTo, /* Name of the other table */
83395 ExprList *pToCol, /* Columns in the other table */
83402 Table *p = pParse->pNewTable;
83415 " should reference only one column of table %T",
83423 "columns in the referenced table");
83493 /* Link the foreign key to the table as the last step.
83514 Table *pTab;
83534 Table *pTab = pIndex->pTable; /* The table that is indexed */
83557 /* Require a write-lock on the table to perform this operation */
83583 /* Open the table. Loop through all rows of the table, inserting index
83643 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
83644 ** and pTblList is the name of the table that is to be indexed. Both will
83647 ** as the table to be indexed. pParse->pNewTable is a table that is
83648 ** currently being constructed by a CREATE TABLE statement.
83652 ** to the table currently under construction.
83662 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
83671 Table *pTab = 0; /* Table to be indexed */
83680 Db *pDb; /* The specific table containing the indexed database */
83698 ** Find the table that is to be indexed. Return early if not found.
83703 ** to search for the table. 'Fix' the table name to this db
83704 ** before looking up the table.
83712 /* If the index name was unqualified, check if the the table
83713 ** is a temp table. If so, set the database to 1. Do not do this
83748 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
83766 ** index or table with the same name.
83769 ** sqlite_master table (because some other process changed the schema) and
83770 ** one of the index names collides with the name of a temporary table or
83786 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
83826 ** key out of the last column added to the table under construction.
83896 /* Scan the names of the columns of the table to be indexed and
83916 sqlite3ErrorMsg(pParse, "table %s has no column named %s",
83957 ** CREATE TABLE t(x PRIMARY KEY, y);
83958 ** CREATE TABLE t(x, y, UNIQUE(x, y));
83960 ** Either way, check to see if the table already has such an index. If
83992 ** constraint specified somewhere in the CREATE TABLE statement.
84011 /* Link the new Index structure to its table and to the other
84032 ** involves writing the index into the master table and filling in the
84033 ** index with the current table contents.
84037 ** CREATE INDEX statements are read out of the master table. In
84042 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
84100 /* When adding an index to the list of indices for a table, make
84141 ** number of rows in the table that match any particular value of the
84207 Table *pTab = pIndex->pTable;
84220 /* Generate code to remove the index and from the master table */
84399 ** Append a new table name to the given SrcList. Create a new SrcList if
84407 ** If pDatabase is not null, it means that the table has an optional
84408 ** database name prefix. Like this: "database.table". The pDatabase
84409 ** points to the table name and the pTable points to the database name.
84410 ** The SrcList.a[].zName field is filled with the table name which might
84419 ** Then B is a table name and the database name is unspecified. If called
84424 ** Then C is the table name and B is the database name. If C is defined
84435 Token *pTable, /* Table to append */
84436 Token *pDatabase /* Database of the table */
84507 ** are the name of the table and database named in the FROM clause term.
84521 Token *pTable, /* Name of the table to add to the FROM clause */
84524 Select *pSubquery, /* A subquery used in place of a table name */
84803 ** inserting multiple rows in a table, or inserting a row and index entries.)
84870 static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
84894 Table *pTab; /* A table in the database */
84900 pTab = (Table*)sqliteHashData(k);
84918 ** indices associated with the named table.
84923 char *z; /* Name of a table or index */
84925 Table *pTab; /* A table in the database */
84929 Token *pObjName; /* Name of the table or index to be reindexed */
85149 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
85153 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
85186 ** to the hash table).
85278 FuncDefHash *pHash, /* Hash table to search */
85293 ** Insert a new FuncDef into a FuncDefHash hash table.
85296 FuncDefHash *pHash, /* The hash table into which to insert */
85394 ** new entry to the hash table and return it.
85436 Table *pTab = sqliteHashData(pElem);
85491 ** the name of a single table, as one might find in an INSERT, DELETE,
85492 ** or UPDATE statement. Look up that table in the symbol table and
85493 ** return a pointer. Set an error message and return NULL if the table
85498 ** pSrc->a[0].pTab Pointer to the Table object
85502 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
85504 Table *pTab;
85519 ** Check to make sure the given table is writable. If it is not
85523 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
85524 /* A table is not writable under the following circumstances:
85526 ** 1) It is a virtual table and no implementation of the xUpdate method
85528 ** 2) It is a system table (i.e. sqlite_master), this call is not
85540 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
85556 ** Evaluate a view and store its result in an ephemeral table. The
85558 ** set of rows in the view that are to be added to the ephemeral table.
85562 Table *pView, /* View definition */
85564 int iCur /* Cursor number for ephemerial table */
85695 SrcList *pTabList, /* The table from which we should delete things */
85699 Table *pTab; /* The table from which records will be deleted */
85704 Index *pIdx; /* For looping over indices of the table */
85715 Trigger *pTrigger; /* List of table triggers, if required */
85725 /* Locate the table which we want to delete. This table has to be
85728 ** an SrcList* parameter instead of just a Table* parameter.
85733 /* Figure out if we have any triggers and if the table being
85767 /* Assign cursor number to the table and all its indices.
85791 ** a ephemeral table.
85818 table. Prior to version 3.6.5,
85834 ** the table and pick which records to delete.
85860 /* Unless this is a view, open cursors for the table we are
85889 /* Close the cursors open on the table and its indexes. */
85898 /* Update the sqlite_sequence table by storing the content of the
85934 ** single table to be deleted.
85939 ** 1. A read/write cursor pointing to pTab, the table containing the row
85948 ** This routine generates code to remove both the table record and all
85953 Table *pTab, /* Table containing the row to be deleted */
85954 int iCur, /* Cursor number for the table */
85988 /* Populate the OLD.* pseudo-table register array. These values will be
86009 ** refer to this table (i.e. constraints attached to other tables)
86014 /* Delete the index and table entries. Skip this step if pTab is really
86043 ** index entries associated with a single row of a single table.
86048 ** 1. A read/write cursor pointing to pTab, the table containing the row
86059 Table *pTab, /* Table containing the row to be deleted */
86060 int iCur, /* Cursor number for the table */
86077 ** iCur is the index of a cursor open on the pTab table and pointing to
86088 int iCur, /* Cursor number for the pIdx->pTable table */
86094 Table *pTab = pIdx->pTable;
87641 ** to the global function hash table. This occurs at start-time (as
87792 ** I.1) For each FK for which the table is the child table, search
87793 ** the parent table for a match. If none is found increment the
87796 ** I.2) For each FK for which the table is the parent table,
87797 ** search the child table for rows that correspond to the new
87798 ** row in the parent table. Decrement the counter for each row
87803 ** D.1) For each FK for which the table is the child table,
87804 ** search the parent table for a row that corresponds to the
87805 ** deleted row in the child table. If such a row is not found,
87808 ** D.2) For each FK for which the table is the parent table, search
87809 ** the child table for rows that correspond to the deleted row
87810 ** in the parent table. For each found increment the counter.
87837 ** TODO: How should dropping a table be handled? How should renaming a
87838 ** table be handled?
87873 ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);
87884 ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
87885 ** Given that pParent is the parent table for foreign key constraint pFKey,
87896 ** array is the index of the child table column that is mapped by the FK
87897 ** constraint to the parent table column stored in the left-most column
87899 ** child table column that corresponds to the second left-most column of
87910 ** foreign key definition, and the parent table does not have a
87914 ** foreign key definition, and the PRIMARY KEY of the parent table
87916 ** the child table.
87924 Table *pParent, /* Parent table of FK constraint pFKey */
87926 Index **ppIdx, /* OUT: Unique index on parent table */
87940 ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
87951 ** mapped to the primary key of table pParent, or
87974 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
87985 ** map to an explicit list of columns in table pParent. Check if this
88031 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
88032 ** on the child table of pFKey, this function is invoked twice for each row
88037 ** row in the parent table that corresponds to the row being inserted into
88038 ** or deleted from the child table. If the parent row can be found, no
88040 ** found in the parent table:
88058 Table *pTab, /* Parent table of FK pFKey */
88061 int *aiCol, /* Map from parent key columns to child table columns */
88062 int regData, /* Address of array containing child table row */
88075 ** Check if any of the key columns in the child table row are NULL. If
88077 ** search for a matching row in the parent table. */
88089 ** column of the parent table (table pTab). */
88101 /* If the parent table is the same as the child table, and we are about
88127 /* If the parent table is the same as the child table, and we are about
88164 ** one row into the table, raise a constraint immediately instead of
88184 ** from the parent table of foreign key constraint pFKey and, if pFKey is
88185 ** deferred, when a row is inserted into the same table. When generating
88190 ** table that correspond to the parent table row being deleted or inserted.
88212 SrcList *pSrc, /* SrcList containing the table to scan */
88213 Table *pTab,
88216 int *aiCol, /* Map from pIdx cols to child table cols */
88217 int regData, /* Referenced table data starts here */
88243 Expr *pLeft; /* Value from parent table row */
88244 Expr *pRight; /* Column ref to child table */
88246 int iCol; /* Index of column in child table */
88247 const char *zCol; /* Name of column in child table */
88274 /* If the child table is the same as the parent table, and this scan
88280 Expr *pLeft; /* Value from parent table row */
88281 Expr *pRight; /* Column ref to child table */
88322 ** constraints for which table pTab is the parent table. For example,
88325 ** CREATE TABLE t1(a PRIMARY KEY);
88326 ** CREATE TABLE t2(b REFERENCES t1(a);
88328 ** Calling this function with table "t1" as an argument returns a pointer
88329 ** to the FKey structure representing the foreign key constraint on table
88332 ** table).
88334 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){
88359 ** This function is called to generate code that runs when table pTab is
88362 ** table pTab.
88366 ** (a) The table is the parent table of a FK constraint, or
88367 ** (b) The table is the child table of a deferred FK constraint and it is
88372 ** the table from the database. Triggers are disabled while running this
88375 SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
88383 /* Search for a deferred foreign key constraint for which this table
88384 ** is the child table. If one cannot be found, return without
88418 ** table pTab to generate VDBE code to perform foreign key constraint
88432 ** the original record is deleted from the table using the calling convention
88438 Table *pTab, /* Row is being deleted from this table */
88458 ** child table (the table that the foreign key definition is part of). */
88460 Table *pTo; /* Parent table of foreign key pFKey */
88468 /* Find the parent table of this foreign key. Also find a unique index
88469 ** on the parent key columns in the parent table. If either of these
88481 /* If isIgnoreErrors is true, then a table is being dropped. In this
88482 ** case SQLite runs a "DELETE FROM xxx" on the table being dropped
88484 ** If the parent table of an FK constraint on the current table is
88486 ** FK counter for each row of the current table with non-NULL keys.
88513 ** values read from the parent table are NULL. */
88523 /* Take a shared-cache advisory read-lock on the parent table. Allocate
88525 ** in the parent table. */
88530 /* A row is being removed from the child table. Search for the parent.
88536 /* A row is being added to the child table. If a parent row cannot
88544 /* Loop through all the foreign key constraints that refer to this table */
88552 /* Inserting a single row into a parent table cannot cause an immediate
88563 /* Create a SrcList structure containing a single table (the table
88564 ** the foreign key that refers to this table is attached to). This
88579 ** on the parent table of this FK, then throw an exception
88597 ** row contained in table pTab.
88601 Table *pTab /* Table being modified */
88623 ** row contained in table pTab. If the operation is a DELETE, then
88625 ** to an array of size N, where N is the number of columns in table pTab.
88629 ** UPDATE statement modifies the rowid fields of the table.
88637 Table *pTab, /* Table being modified */
88644 ** table in question is either the child or parent table for any
88683 ** compiled on table pTab, which is the parent table of foreign-key pFKey.
88694 ** For example, if pFKey is the foreign key and pTab is table "p" in
88697 ** CREATE TABLE p(pk PRIMARY KEY);
88698 ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);
88712 Table *pTab, /* Table being updated or deleted from */
88726 char const *zFrom; /* Name of child table */
88729 int *aiCol = 0; /* child table cols -> parent key cols */
88743 Token tFromCol; /* Name of column in child table */
88744 Token tToCol; /* Name of column in parent table */
88745 int iFromCol; /* Idx of column in child table */
88759 ** parent table are used for the comparison. */
88898 Table *pTab, /* Table being updated or deleted from */
88903 ** refer to table pTab. If there is an action associated with the FK
88921 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
88922 ** hash table.
88924 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
88931 /* Remove the FK from the fkeyHash hash table. */
88980 ** Generate code that will open a table for reading.
88984 int iCur, /* The cursor number of the table */
88986 Table *pTab, /* The table to be opened */
89002 ** the table, according to the affinity of the column:
89030 Table *pTab = pIdx->pTable;
89049 ** string for table pTab. A column affinity string has one character
89061 SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){
89062 /* The first time a column affinity string for a particular table
89064 ** stored as a member of the Table structure for subsequent use.
89067 ** sqlite3DeleteTable() when the Table structure itself is cleaned up.
89092 ** Return non-zero if the table pTab in database iDb or any of its indices
89096 ** run without using temporary table for the results of the SELECT.
89098 static int readsTable(Parse *p, int iStartAddr, int iDb, Table *pTab){
89134 ** Locate or create an AutoincInfo structure associated with table pTab
89138 ** There is at most one AutoincInfo structure per table even if the
89139 ** same table is autoincremented multiple times due to inserts within
89141 ** first use of table pTab. On 2nd and subsequent uses, the original
89146 ** (1) Register to hold the name of the pTab table.
89156 Table *pTab /* The table we are writing to */
89172 pToplevel->nMem++; /* Register to hold name of table */
89188 Db *pDb; /* Database only autoinc table */
89238 ** table (either directly or through triggers) needs to call this
89288 Table *pDest, /* The table we are inserting into */
89297 ** insert into TABLE (IDLIST) values(EXPRLIST)
89298 ** insert into TABLE (IDLIST) select
89300 ** The IDLIST following the table name is always optional. If omitted,
89301 ** then a list of all columns for the table is substituted. The IDLIST
89314 ** open write cursor to <table> and its indices
89316 ** write the resulting record into <table>
89321 ** INSERT INTO <table> SELECT ...
89324 ** in other words if the SELECT pulls all columns from a single table
89332 ** open a write cursor to <table>
89334 ** transfer all records in <table2> over to <table>
89336 ** foreach index on <table>
89337 ** open a write cursor on the <table> index
89344 ** and the SELECT clause does not read from <table> at any time.
89359 ** B: open write cursor to <table> and its indices
89362 ** insert the select result into <table> from R..R+n
89367 ** values from a SELECT but the data is being inserted into a table
89369 ** we have to use a intermediate table to store the results of
89384 ** B: open temp table
89387 ** insert row from R..R+n into temp table
89389 ** M: open write cursor to <table> and its indices
89390 ** rewind temp table
89391 ** C: loop over rows of intermediate table
89392 ** transfer values form intermediate table into <table>
89398 SrcList *pTabList, /* Name of table into which we are inserting */
89405 Table *pTab; /* The table to insert into. aka TABLE */
89406 char *zTab; /* Name of the table into which we are inserting */
89407 const char *zDb; /* Name of the database holding this table */
89410 Index *pIdx; /* For looping over indices of the table */
89412 int nHidden = 0; /* Number of hidden columns if TABLE is virtual */
89416 int useTempTable = 0; /* Store SELECT results in intermediate table */
89422 int iDb; /* Index of database holding TABLE */
89423 Db *pDb; /* The database containing table being inserted into */
89448 /* Locate the table into which we will be inserting new information.
89465 /* Figure out if we have any triggers and if the table being
89484 ** module table).
89491 * (a) the table is not read-only,
89522 /* If this is an AUTOINCREMENT table, look up the sequence number in the
89523 ** sqlite_sequence table and store it in memory cell regAutoinc.
89584 ** should be written into a temporary table (template 4). Set to
89586 ** the destination table (template 3).
89588 ** A temp table must be used if the table being updated is also one
89590 ** temp table in the case of row triggers.
89598 ** and add it to a transient table srcTab. The code generated
89601 ** B: open temp table
89604 ** insert row from R..R+n into temp table
89609 int regTempRowid; /* Register to hold temp table ROWID */
89645 ** of columns to be inserted into the table.
89654 "table %S has %d columns but %d values were supplied",
89664 ** all elements of the IDLIST really are columns of the table and
89667 ** If the table has an INTEGER PRIMARY KEY column and that column
89671 ** is appears in the original table. (The index of the primary
89672 ** key in the original table is pTab->iPKey.)
89692 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
89701 /* If there is no IDLIST term but the table has an integer primary
89703 ** in the original table definition.
89716 /* If this is not a view, open the table and and all indices */
89736 ** rewind temp table
89737 ** C: loop over rows of intermediate table
89738 ** transfer values form intermediate table into <table>
89750 ** insert the select result into <table> from R..R+n
89797 /* Cannot have triggers on a virtual table. If it were possible,
89824 ** If this is a real table, attempt conversions as required by the
89825 ** table column affinities.
89841 ** except when the table has an INTEGER PRIMARY KEY column, in which
89985 /* Update the sqlite_sequence table by storing the content of the
90054 ** attached to the table.
90103 Table *pTab, /* the table into which we are inserting */
90120 int iCur; /* Table cursor number */
90127 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90223 /* If there are DELETE triggers on this table and the
90225 ** remove the conflicting row from the the table. This will fire
90226 ** the triggers and remove both the table and index b-tree entries.
90229 ** flag is not set, but the table has one or more indexes, call
90231 ** only. The table b-tree entry will be replaced by the new entry
90243 ** table.
90389 Table *pTab, /* the table into which we are inserting */
90407 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90441 ** Generate code that will open cursors for a table and for all
90442 ** indices of that table. The "baseCur" parameter is the cursor number used
90443 ** for the table. Indices are opened on subsequent cursors.
90445 ** Return the number of indices on the table.
90449 Table *pTab, /* Table to be opened */
90450 int baseCur, /* Cursor number assigned to the table */
90553 ** Sometimes the xfer optimization will only work if the destination table
90556 ** does a test to see if the destination table is empty and jumps over the
90566 Table *pDest, /* The table we are inserting into */
90572 Table *pSrc; /* The table in the FROM clause of SELECT */
90595 return 0; /* tab1 must not be a virtual table */
90647 return 0; /* FROM clause does not contain a real table */
90650 return 0; /* tab1 and tab2 may not be the same table */
90654 return 0; /* tab2 must not be a virtual table */
90694 /* Disallow the transfer optimization if the destination table constains
90711 ** table (tab1) is initially empty.
90728 ** only if the destination table is initially empty. This code makes
92953 ** PRAGMA table_info(<table>)
92955 ** Return a single row for each column of the named table. The columns of
92965 Table *pTab;
93004 Table *pTab;
93028 Table *pTab;
93091 Table *pTab;
93103 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC);
93219 Table *pTab = sqliteHashData(x);
93249 Table *pTab = sqliteHashData(x);
93411 ** creating or dropping a table or index). The schema version is used by
93685 ** argv[1] = root page number for table or index. 0 for trigger or view.
93708 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
93711 ** structures that describe the table, index, or view.
93743 ** constraint for a CREATE TABLE. The index should have already
93744 ** been created when we processed the CREATE TABLE. All we have
93750 /* This can occur if there exists an index on a TEMP table which
93752 ** the permanent table is hidden by the TEMP table, we can also
93753 ** safely ignore the index on the permanent table.
93775 Table *pTab;
93785 ** The master database table has a structure like this
93788 "CREATE TABLE sqlite_master(\n"
93798 "CREATE TEMP TABLE sqlite_temp_master(\n"
93817 ** initialised. zMasterName is the name of the master table.
93930 ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN
93990 ** purpose of this is to allow access to the sqlite_master table
94138 ** expr.c is trying to resolve a reference to a transient table (i.e. one
94354 ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error
94687 ** Return the index of a column in a table. Return -1 if the column
94688 ** is not contained in the table.
94690 static int columnIndex(Table *pTab, const char *zCol){
94700 ** table that has a column named zCol.
94702 ** When found, set *piTab and *piCol to the table index and column index
94738 ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the
94745 int iLeft, /* Index of first table to join in pSrc */
94746 int iColLeft, /* Index of column in first table */
94747 int iRight, /* Index of second table in pSrc */
94748 int iColRight, /* Index of column in second table */
94788 ** expression depends on table iRightJoinTable even if that table is not
94818 ** The left most table is the first entry in Select.pSrc. The right-most
94819 ** table is the last entry. The join operator is held in the entry to
94829 struct SrcList_item *pLeft; /* Left table being joined */
94830 struct SrcList_item *pRight; /* Right table being joined */
94836 Table *pLeftTab = pLeft->pTab;
94837 Table *pRightTab = pRight->pTab;
94853 char *zName; /* Name of column in the right table */
94854 int iLeft; /* Matching left table */
94855 int iLeftCol; /* Matching column in the left table */
94893 int iLeft; /* Table on the left with matching column name */
95008 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
95042 int srcTab, /* Pull data from this table */
95043 int nColumn, /* Number of columns in the source table */
95109 ** table iParm.
95123 ** the temporary table iParm.
95155 ** item into the set table with bogus data.
95356 int bUseTmp /* True if a temp table was used */
95490 ** original CREATE TABLE statement if the expression is a column. The
95520 /* The expression is a column. Locate the table the column is being
95521 ** extracted from in NameContext.pSrcList. This table may be real
95522 ** database table or a subquery.
95524 Table *pTab = 0; /* Table structure column is extracted from */
95547 ** CREATE TABLE t1(col INTEGER);
95563 /* The "table" is actually a sub-select or a view in the FROM clause
95580 /* A real table */
95701 Table *pTab;
95737 ** column names for a table that would hold the expression list.
95776 Table *pTab; /* Table associated with this expression */
95875 ** Given a SELECT statement, generate a Table structure that describes
95878 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
95879 Table *pTab;
95890 pTab = sqlite3DbMallocZero(db, sizeof(Table) );
96102 /* Create the destination temporary table if necessary
96174 int unionTab; /* Cursor number of the temporary table holding result */
96185 /* We can reuse a temporary table generated by a SELECT to our
96194 /* We will need to create our own temporary table to hold the
96246 /* Convert the data in the temporary table into whatever form
96294 /* Code the SELECTs to our left into temporary table "tab1".
96303 /* Code the current SELECT into temporary table "tab2"
96491 ** item into the set table with bogus data.
97014 ** a column in table number iTable with a copy of the iColumn-th
97022 ** changes to pExpr so that it refers directly to the source table
97028 int iTable, /* Table to be substituted */
97060 int iTable, /* Table to be substituted */
97072 int iTable, /* Table to be replaced */
97106 ** subquery first and store the results in a temporary table, then
97107 ** run the outer query on that temporary table. This requires two
97108 ** passes over the data. Furthermore, because the temporary table
97119 ** exist on the table t1, a complete scan of the data might be
97142 ** table sqlite_once that consists of a single row containing a
97225 int iParent; /* VDBE cursor number of the pSub result set temp table */
97413 /* Delete the transient table structure associated with the
97424 /* Defer deleting the Table object associated with the
97432 Table *pTabToDel = pSubitem->pTab;
97623 ** where table is a database table, not a sub-select or view. If the query
97624 ** does match this pattern, then a pointer to the Table object representing
97627 static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
97628 Table *pTab;
97659 Table *pTab = pFrom->pTab;
97695 ** for instances of the "*" operator or the TABLE.* operator.
97696 ** If found, expand each "*" to be every column in every table
97697 ** and TABLE.* to be every column in TABLE.
97723 table named in the FROM clause of the select. If
97724 ** an entry of the FROM clause is a subquery instead of a table or view,
97725 ** then create a transient table structure to describe the subquery.
97728 Table *pTab;
97742 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
97753 /* An ordinary table or view name in the FROM clause */
97761 /* We reach here if the named table is a really a view */
97783 ** all columns in all tables. And for every TABLE.* insert the names
97784 ** of all columns in TABLE. The parser inserted a special expression
97826 /* This expression is a "*" or a "TABLE.*" and needs to be
97828 int tableSeen = 0; /* Set to 1 when TABLE matches */
97829 char *zTName; /* text of name of TABLE */
97838 Table *pTab = pFrom->pTab;
97869 ** table to the right of the join */
97874 ** using clause from the table on the right. */
97901 sqlite3ErrorMsg(pParse, "no such table: %s", zTName);
97961 ** information to the Table structure that represents the result set
97964 ** The Table structure that represents the result set was constructed
97981 Table *pTab = pFrom->pTab;
97998 ** the Table structures of all FROM-clause subqueries in a
98019 ** * Ephemeral Table objects are created for all FROM-clause subqueries.
98021 ** * Wildcards "*" and "TABLE.*" in result sets are expanded.
98182 Table *pTab, /* Table being queried */
98186 char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s %s%s(~%d rows)",
98219 ** row of result as the key in table pDest->iParm.
98223 ** SRT_Union Store results as a key in a temporary table pDest->iParm.
98225 ** SRT_Except Remove results from the temporary table pDest->iParm.
98227 ** SRT_Table Store results in temporary table pDest->iParm.
98228 ** This is like SRT_EphemTab except that the table
98231 ** SRT_EphemTab Create an temporary table pDest->iParm and store
98235 ** the table first.
98271 int distinct; /* Table to use for the distinct set */
98357 /* Generate a subroutine that will fill an ephemeral table with
98449 ** The second form is preferred as a single index (or temp-table) may be
98451 ** written the query must use a temp-table for at least one of the ORDER
98452 ** BY and DISTINCT, and an index or separate temp-table for the other.
98482 /* If the output is destined for a temporary table, open that table.
98691 ** we do not have to sort. The OP_OpenEphemeral table will be
98855 Table *pTab;
98857 /* If isSimpleCount() returns a pointer to a Table structure, then
98862 ** where the Table structure returned represents table <tbl>.
98865 ** OP_Count instruction is executed either on the intkey table that
98866 ** contains the data for table <tbl> or on one of its indexes. It
98881 ** there is such an index, and it has less columns than the table
99116 /************** Begin file table.c *******************************************/
99155 ** This routine is called once for each row in the result table. Its job
99230 ** Instead, the entire table should be passed to sqlite3_free_table() when
99236 char ***pazResult, /* Write the result table here */
99314 /************** End of table.c ***********************************************/
99348 ** Given table pTab, return a list of all the triggers attached to
99349 ** the table. The list is connected by Trigger.pNext pointers.
99361 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
99375 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
99401 SrcList *pTableName,/* The name of the table/view the trigger applies to */
99407 Table *pTab; /* Table that the trigger fires off of */
99451 /* If the trigger name was unqualified, and the table is a temp table,
99453 ** If sqlite3SrcListLookup() returns 0, indicating the table does not
99462 /* Ensure the table name matches database name and that the table exists */
99471 /* The table does not exist. */
99474 ** Normally, whenever a table is dropped, all associated triggers are
99475 ** dropped too. But if a TEMP trigger is created on a non-TEMP table
99476 ** and the table is dropped by a different database connection, the
99479 ** "orphaned trigger" - a trigger whose associated table is missing.
99508 /* Do not create a trigger on a system table */
99510 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
99525 " trigger on table: %S", pTableName, 0);
99559 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
99620 /* Make an entry in the sqlite_master table */
99628 pTrig->table, z);
99643 Table *pTab;
99644 int n = sqlite3Strlen30(pLink->table);
99645 pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table, n);
99710 Token *pTableName, /* Name of the table into which we insert */
99743 Token *pTableName, /* Name of the table to be updated */
99768 Token *pTableName, /* The table from which rows are deleted */
99789 sqlite3DbFree(db, pTrigger->table);
99844 ** Return a pointer to the Table structure for the table that a trigger
99847 static Table *tableOfTrigger(Trigger *pTrigger){
99848 int n = sqlite3Strlen30(pTrigger->table);
99849 return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n);
99857 Table *pTable;
99923 Table *pTab = tableOfTrigger(pTrigger);
99952 ** Return a list of all triggers on table pTab if there exists at least
99954 ** performed on the table, and, if that operation is an UPDATE, if at
99959 Table *pTab, /* The table the contains the triggers */
100131 Table *pTab, /* The table pTrigger is attached to */
100244 Table *pTab, /* The table trigger pTrigger is attached to */
100271 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
100278 Table *pTab, /* The table to code triggers from */
100309 ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
100319 ** in the trigger program. If N is the number of columns in table pTab
100349 Trigger *pTrigger, /* List of triggers on table pTab */
100353 Table *pTab, /* The table to code triggers from */
100366 /* Sanity checking: The schema for the trigger and for the table are
100367 ** always defined. The trigger must be in the same schema as the table
100385 ** Triggers may access values stored in the old.* or new.* pseudo-table.
100392 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
100394 ** are more than 32 columns in the table, and at least one of the columns
100401 ** applies to the old.* table. If 1, the new.* table.
100411 Trigger *pTrigger, /* List of triggers on table pTab */
100415 Table *pTab, /* The table to code triggers from */
100461 SrcList *pSrc, /* The virtual table to be modified */
100462 Table *pTab, /* The virtual table */
100473 ** i-th column of table pTab. This routine sets the P4 parameter of the
100477 ** column definition. This was either supplied by the user when the table
100478 ** was created, or added later to the table definition by an ALTER TABLE
100479 ** command. If the latter, then the row-records in the table btree on disk
100485 ** Column definitions created by an ALTER TABLE command may only have
100488 ** when the ALTER TABLE is executed and one of the literal values written
100489 ** into the sqlite_master table.)
100501 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
100531 SrcList *pTabList, /* The table in which we should change things */
100537 Table *pTab; /* The table to be updated */
100547 ** an expression for the i-th column of the table.
100554 int iDb; /* Database containing the table being updated */
100569 int regNew; /* Content of the NEW.* table in triggers */
100570 int regOld = 0; /* Content of OLD.* table in triggers */
100580 /* Locate the table which we want to update.
100586 /* Figure out if we have any triggers and if the table being
100613 /* Allocate a cursors for the main database table and for all indices.
100676 ** array for each index associated with table being updated. Fill in
100737 ** a ephemeral table.
100833 /* If there are triggers on this table, populate an array of registers
100854 ** table and index records, and as the values for any new.* references
100981 /* Update the sqlite_sequence table by storing the content of the
101021 ** Generate code for an UPDATE of a virtual table.
101023 ** The strategy is that we create an ephemerial table that contains
101030 ** Then we loop over this ephemeral table and for each row in
101031 ** the ephermeral table call VUpdate.
101033 ** When finished, drop the ephemeral table.
101037 ** it out of the ephemeral table before calling VUpdate.
101041 SrcList *pSrc, /* The virtual table to be modified */
101042 Table *pTab, /* The virtual table */
101053 int ephemTab; /* Table holding the result of the SELECT */
101080 /* Create the ephemeral table into which the update results will
101088 /* fill the ephemeral table
101093 /* Generate code to scan the ephemeral table and call VUpdate. */
101328 "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) "
101329 " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'"
101350 "WHERE type = 'table' AND name!='sqlite_sequence' "
101355 /* Copy over the sequence table
101373 ** from the SQLITE_MASTER table.
101380 " OR (type='table' AND rootpage=0)"
101481 ** Before a virtual table xCreate() or xConnect() method is invoked, the
101488 Table *pTab;
101537 ** External API function used to create a new virtual-table module.
101549 ** External API function used to create a new virtual-table module.
101562 ** Lock the virtual table so that it cannot be disconnected.
101566 ** If a disconnect is attempted while a virtual table is locked,
101575 ** pTab is a pointer to a Table structure representing a virtual-table.
101577 ** this virtual-table, if one has been created, or NULL otherwise.
101579 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
101587 ** Decrement the ref-count on a virtual table object. When the ref-count
101608 ** Table p is a virtual table. This function moves all elements in the
101614 static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
101620 ** that contains table p is held by the caller. See header comments
101648 ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
101660 ** associated with the database the virtual table is stored in is held
101661 ** or, if the virtual table is stored in a non-sharable database, then
101685 ** Clear any and all virtual-table information from the Table record.
101686 ** This routine is called, for example, just before deleting the Table
101689 ** Since it is a virtual-table, the Table structure contains a pointer
101698 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
101712 ** string will be freed automatically when the table is
101715 static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
101736 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
101742 Token *pName1, /* Name of new table, or database name */
101743 Token *pName2, /* Name of new table or NULL */
101744 Token *pModuleName, /* Name of the module for the virtual table */
101745 int ifNotExists /* No error if the table already exists */
101747 int iDb; /* The database the table is being created in */
101748 Table *pTable; /* The new virtual table */
101768 /* Creating a virtual table invokes the authorization callback twice.
101770 ** sqlite_master table, has already been made by sqlite3StartTable().
101771 ** The second call, to obtain permission to create the table, is made now.
101783 ** virtual table currently under construction in pParse->pTable.
101795 ** The parser calls this routine after the CREATE VIRTUAL TABLE statement
101799 Table *pTab = pParse->pNewTable; /* The table being constructed */
101807 /* If the CREATE VIRTUAL TABLE statement is being entered for the
101808 ** first time (in other words if the virtual table is actually being
101811 ** in the sqlite_master table.
101819 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
101823 zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
101826 ** SQLITE_MASTER table. We just need to update that slot with all
101830 ** entry in the sqlite_master table tht was created for this vtab
101836 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
101849 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
101855 /* If we are rereading the sqlite_master table create the in-memory
101856 ** record of the table. The xConnect() method is not called until
101857 ** the first time the virtual table is used in an SQL statement. This
101859 ** the required virtual table implementations are registered. */
101861 Table *pOld;
101878 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
101888 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
101902 ** Invoke a virtual table constructor (either xCreate or xConnect). The
101908 Table *pTab,
101933 /* Invoke the virtual table constructor */
101965 ** columns of the table to see if any of them contain the token "hidden".
102009 ** of the virtual table pTab. If an error occurs, an error code is returned
102012 ** This call is a no-op if table pTab is not a virtual table.
102014 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
102025 /* Locate the required virtual table module */
102046 ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.
102067 ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should
102078 ** of the virtual table named zTab in database iDb.
102086 Table *pTab;
102093 /* Locate the required virtual table module */
102121 ** This function is used to set the schema of a virtual table. It is only
102123 ** virtual table module.
102129 Table *pTab;
102183 ** of the virtual table named zTab in database iDb. This occurs
102184 ** when a DROP TABLE is mentioned.
102186 ** This call is a no-op if zTab is not a virtual table.
102190 Table *pTab;
102286 ** If the virtual table pVtab supports the transaction interface
102336 ** as the second argument to the virtual table method invoked.
102340 ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
102343 ** If any virtual table method returns an error code other than SQLITE_OK,
102345 ** function immediately. If all calls to virtual table methods are successful,
102384 ** If pExpr is a column in a virtual table, then let the virtual
102385 ** table implementation have an opportunity to overload the function.
102387 ** This routine is used to allow virtual table implementations to
102400 Table *pTab;
102411 /* Check to see the left operand is a column in a virtual table */
102423 /* Call the xFindFunction method on the virtual table implementation
102455 ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
102460 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
102463 Table **apVtabLock;
102481 ** table update operation currently in progress.
102499 ** of the virtual table being implemented.
102547 ** generating the code that loops through a table looking for applicable
102673 WhereMaskSet *pMaskSet; /* Mapping of table cursor numbers to bitmasks */
102674 Bitmask vmask; /* Bitmask identifying virtual table cursors */
102773 ** But if the table is the right table of a left join, WhereLevel.wsFlags
102776 ** ISNULL constraints will then not be used on the right table of a left
102786 #define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */
102791 #define WHERE_IDX_ONLY 0x00800000 /* Use index only - omit table */
102795 #define WHERE_VIRTUALTABLE 0x08000000 /* Use virtual-table processing */
102806 WhereMaskSet *pMaskSet, /* Mapping from table cursor numbers to bitmasks */
102960 ** There is one cursor per table in the FROM clause. The number of
102980 ** the VDBE cursor number of the table. This routine just has to
103116 ** where X is a reference to the iColumn of table iCur and <op> is one of
103350 ** a single table T (as shown in example B above) then create a new virtual
103362 ** If all subterms are indexable by a single table T, then set
103365 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
103368 ** "T.C <op> <expr>" where C is any column of table T and
103408 WhereMaskSet *pMaskSet = pWC->pMaskSet; /* Table use masks */
103503 ** something other than == on a column in the single table. The 1-bit
103505 ** "table.column=expr" for some single table. The one bit that is set
103506 ** will correspond to the common table. We still need to check to make
103513 ** Note that terms of the form "table.column1=table.column2" (the
103514 ** same table on both sizes of the ==) cannot be optimized.
103519 int iCursor = -1; /* Table cursor common to all terms */
103522 /* Search for a table and column that appears on one side or the
103523 ** other of the == operator in every subterm. That table and column
103525 ** such table and column. Set okToChngToIN if an appropriate table
103554 /* No candidate table+column was found. This can only occur
103563 /* We have found a candidate table and column. Check to see if that
103564 ** table and column is common to every term in the OR clause */
103658 WhereMaskSet *pMaskSet; /* Set of table index masks */
103695 ** on left table of a LEFT JOIN. Ticket #3015 */
103940 ** a reference to any table other than the iBase table.
103946 int iBase /* Ignore references to this table */
103961 ** Argument iBase is the cursor number used for the table that pIdx refers
103970 int iBase, /* Cursor for table associated with pIdx */
104009 int base, /* Cursor number for the table pIdx is on */
104023 ** same table as index pIdx, return early. Finally, if there is no
104024 ** matching "col=X" expression and the column is on the same table as pIdx,
104064 Table *pTab;
104069 /* If there is more than one table or sub-select in the FROM clause of
104076 /* If any of the expressions is an IPK column on table iBase, then return
104085 /* Loop through all indices on the table, checking each to see if it makes
104120 ** left-most table in the FROM clause of that same SELECT statement and
104121 ** the table has a cursor number of "base". pIdx is an index on pTab.
104135 WhereMaskSet *pMaskSet, /* Mapping from table cursor numbers to bitmaps */
104137 int base, /* Cursor number for the table to be sorted */
104158 ** represent the rowid index that is part of every table. */
104180 ** left-most table of the FROM clause */
104334 ** The table associated with FROM clause term pSrc may be either a
104335 ** regular B-Tree table or a virtual table.
104347 const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */
104434 struct SrcList_item *pSrc, /* Table we are trying to access */
104449 ** If the query plan for pSrc specified in pCost is a full table scan
104452 ** than a full table scan even when the cost of constructing the index
104463 double nTableRow; /* Rows in the input table */
104468 Table *pTable; /* Table tht might be indexed */
104497 /* The cost of creating the transient table would be greater than
104498 ** doing the full table scan */
104541 Table *pTable; /* The table being indexed */
104582 ** original table never needs to be accessed. Automatic indices must
104584 ** original table changes and the index and table cannot both be used
104696 ** to this virtual table */
104708 ** virtual table then allocate space for the aOrderBy part of
104780 ** The table object reference passed as the second argument to this function
104781 ** must represent a virtual table. This function invokes the xBestIndex()
104782 ** method of the virtual table with the sqlite3_index_info pointer passed
104793 static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
104818 "table %s: xBestIndex returned an invalid plan", pTab->zName);
104827 ** Compute the best index for a virtual table.
104830 ** table module. This routine is really just a wrapper that sets up
104835 ** same virtual table. The sqlite3_index_info structure is created
104838 ** code is generated to access the virtual table. The whereInfoDelete()
104852 Table *pTab = pSrc->pTab;
104898 ** table. In other words, if the constraint is of the form:
104904 ** of the table containing column.
104907 ** on the current table. That way we only have to compute it once
104946 /* If there is an ORDER BY clause, and the selected virtual table index
105378 ** Find the best query plan for accessing a particular table. Write the
105392 ** index and in the main table.
105394 ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in
105400 ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table
105415 int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */
105429 /* If the pSrc table is the right table of a LEFT JOIN then we may not
105430 ** use an index to satisfy IS NULL constraints on that table. This is
105431 ** because columns might end up being NULL if the table does not match -
105450 Index *pFirst; /* First of real indices on the table */
105461 /* The real indices of the table are only considered if the
105532 ** Boolean. True if a table lookup is required for each index entry
105534 ** This is always false for the rowid primary key index of a table.
105535 ** For other indexes, it is true unless all the columns of the table
105539 ** two queries requires table b-tree lookups in order to find the value
105647 ** using the main table (i.e. if the index is a covering
105668 ** constraint, do not let the estimate exceed half the rows in the table.
105703 ** to do a binary search to locate a row in a table or index is roughly
105705 ** a table or index. The actual times can vary, with the size of
105711 ** not give us data on the relative sizes of table and index records.
105712 ** So this computation assumes table records are about twice as big
105716 /* The cost of a full table scan is a number of move operations equal
105717 ** to the number of rows in the table.
105719 ** We add an additional 4x penalty to full table scans. This causes
105731 /* For an index lookup followed by a table lookup:
105734 ** + nRow table searches to lookup the table entry using the rowid
105746 ** nInMult table searches to find the initial entry for each range
105747 ** + nRow steps through the table
105768 /* If there are additional constraints on this table that cannot
105777 ** mask will only have one bit set - the bit for the current table.
105885 ** Find the query plan for accessing table pSrc->pTab. Write the
105888 ** both real and virtual table scans.
106064 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
106090 ** CREATE TABLE t1(a TEXT PRIMARY KEY, b);
106110 int iCur = pLevel->iTabCur; /* The cursor of the table */
106194 ** Argument pLevel describes a strategy for scanning table pTab. This
106196 ** of the subset of table rows scanned by the strategy in the form of an
106212 static char *explainIndexRange(sqlite3 *db, WhereLevel *pLevel, Table *pTab){
106247 ** record is added to the output to describe the table scan strategy in
106252 SrcList *pTabList, /* Table list this loop refers to */
106278 zMsg = sqlite3MAppendf(db, zMsg, "%s TABLE %s", zMsg, pItem->zName);
106310 zMsg = sqlite3MAppendf(db, zMsg, "%s VIRTUAL TABLE INDEX %d:%s", zMsg,
106340 int iCur; /* The VDBE cursor for the table */
106378 /* If this is the right table of a LEFT OUTER JOIN, allocate and
106379 ** initialize a memory cell that records if this table matches any
106380 ** row of the left table of the join.
106390 /* Case 0: The table is a virtual-table. Use the VFilter and VNext
106736 ** of the table column that the inequality contrains is not NULL.
106748 /* Seek the table cursor, if required */
106777 ** CREATE TABLE t1(a,b,c,d);
106813 SrcList *pOrTab; /* Shortened table list or OR-clause generation */
106832 /* Set up a new SrcList ni pOrTab containing the table being scanned
106906 /* Loop through table entries that match term pOrTerm. */
106925 ** contained one or more AND term from a notReady table. The
106926 ** terms from the notReady table could not be tested and will
106931 /* Finish the loop through table entries that match term pOrTerm. */
106951 ** scan of the entire table.
106992 ** at least one row of the right table has matched the left table.
107068 ** The basic idea is to do a nested loop, one loop for each table in
107070 ** same as a SELECT with only a single table in the FROM clause.) For
107091 ** There are Btree cursors associated with each table. t1 uses cursor
107104 ** refer to those indices, a complete table scan can be avoided and the
107138 ** If an index can be used so that the natural output order of the table
107180 ** only generate code for the first table in pTabList and assume that
107239 ** its Expr.iRightJoinTable value to find the bitmask of the right table
107240 ** of the join. Subtracting one from the right table bitmask gives a
107245 ** to virtual table cursors are set. This is used to selectively disable
107293 /* Chose the best index to use for each table in the FROM clause.
107301 ** pWInfo->a[].iTabCur The VDBE cursor for the database table
107313 Index *pIdx; /* Index for FROM table at pTabItem */
107334 ** were used as the innermost nested loop. In other words, a table
107335 ** is chosen such that the cost of running that table cannot be reduced
107343 ** not be as small as it would be if the table really were the innermost
107346 ** table really is the innermost join.
107357 ** CREATE TABLE t1(a, b);
107358 ** CREATE TABLE t2(c, d);
107361 ** The best strategy is to iterate through table t1 first. However it
107363 ** Since the cost of a linear scan through table t2 is the same
107364 ** as the cost of a linear scan through table t1, a simple greedy
107373 int doNotReorder; /* True if this table should not be reordered */
107390 WHERETRACE(("=== trying table %d with isOptimal=%d ===\n",
107416 /* Conditions under which this table becomes the best so far:
107418 ** (1) The table must not depend on other tables that have not
107421 ** (2) A full-table-scan plan cannot supercede indexed plan unless
107422 ** the full-table-scan is an "optimal" plan as defined above.
107424 ** (3) All tables have an INDEXED BY clause or this table lacks an
107425 ** INDEXED BY clause or this table uses the specific
107431 ** An indexable full-table-scan from reaching rule (3).
107446 WHERETRACE(("=== table %d is best so far"
107457 WHERETRACE(("*** Optimizer selects table %d for loop %d"
107483 /* Check that if the table scanned by this loop iteration had an
107531 Table *pTab; /* Table to open */
107532 int iDb; /* Index of database containing table/index */
107600 /* Record in the query plan information about the current table
107601 ** and the index used to access it (if any). If the table itself
107726 Table *pTab = pTabItem->pTab;
107742 ** from the index in preference to the table. Sometimes, this means
107743 ** the table need never be read from. This is a performance boost,
107744 ** as the vdbe level waits until the table is read before actually
107745 ** seeking the table cursor to the record corresponding to the current
107749 ** sqlite3WhereEnd will have created code that references the table
107751 ** that reference the table and converts them into opcodes that
107955 ** table.
108052 ** slots in the yy_action[] table.
108054 ** The action table is constructed as a single large table named yy_action[].
108061 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
108072 ** yy_action[] A single table containing all actions.
108073 ** yy_lookahead[] A table containing the lookahead for each entry in
108553 /* The next table maps tokens into fallback tokens. If a construct
108581 0, /* TABLE => nothing */
108708 ** are required. The following table supplies these names */
108714 "TABLE", "CREATE", "IF", "NOT",
108806 /* 26 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
108887 /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
109089 /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109090 /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109096 /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109492 /* The following table contains information about every rule that
109927 case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
110145 case 107: /* cmd ::= DROP TABLE ifexists fullname */
110844 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
110930 case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
110935 case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
110952 case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
111336 ** might be implemented more directly using a hand-written hash table.
111487 testcase( i==19 ); /* TABLE */
112036 /* If the pParse->declareVtab flag is set, do not delete any table
112038 ** will take responsibility for freeing the Table structure.
112053 Table *p = pParse->pZombieTab;
113163 HashElem *i; /* Hash table iterator */
113181 ** SQL statements below, as the v-table implementation may be storing
113337 /* SQLITE_LOCKED */ "database table is locked",
113347 /* SQLITE_EMPTY */ "table contains no data",
113384 int count /* Number of times table has been busy */
113542 ** to the hash table.
113682 ** Declare that a function has been overloaded by a virtual table.
113979 ** following table describes the relationship between these two values
115000 ** Return meta information about a specific column of a database table.
115007 const char *zTableName, /* Table name */
115017 Table *pTab = 0;
115035 /* Locate the table in question */
115068 ** 2. The table is not a view and the column name identified an
115100 zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName,
115966 ** the %_segments table in sorted order. This means that when the end
116030 ** The segment directory in table %_segdir stores meta-information for
116070 ** leaf nodes are written in to the %_segments table in order, this
116189 ** When an fts3 table is created, it passes any arguments passed to
116190 ** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the
116194 ** be used for the fts3 table (customized by the tokenizer clause arguments).
116216 ** TABLE statement that created the fts3 table. For example, if
116332 ** This is the header file for the generic hash-table implemenation
116334 ** hash table implementation for the full-text indexing module.
116344 /* A complete hash table is an instance of the following structure.
116355 int count; /* Number of entries in this table */
116357 int htsize; /* Number of buckets in the hash table */
116358 struct _fts3ht { /* the hash table */
116364 /* Each element in the hash table is an instance of the following
116371 Fts3HashElem *next, *prev; /* Next and previous elements in the table */
116377 ** There are 2 different modes of operation for a hash table:
116410 ** Macros for looping over all elements of a hash table. The idiom is
116428 ** Number of entries in a hash table
116446 ** Fts3Table.pendingTerms hash table. Normally, the hash table is
116450 ** segment is created and the hash table cleared immediately.
116585 const char *zName; /* virtual table name */
116586 int nColumn; /* number of named columns in virtual table */
116593 ** statements is run and reset within a single virtual table API call.
116601 u8 bHasStat; /* True if %_stat table exists */
116602 u8 bHasDocsize; /* True if %_docsize table exists */
116605 char *zSegmentsTbl; /* Name of %_segments table */
116606 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116612 ** size of the pending data, including hash table overhead, not including
116617 ** A single FTS4 table may have multiple full-text indexes. For each index
116625 Fts3Hash hPending; /* Pending terms table for this index */
116634 ** methods of the virtual table are called at appropriate times. These
116644 ** When the core wants to read from the virtual table, it creates a
116645 ** virtual table cursor (an instance of the following structure) using
116665 sqlite3_int64 nDoc; /* Documents in table */
116683 ** CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);
116692 #define FTS3_FULLSCAN_SEARCH 0 /* Linear scan of %_content table */
116693 #define FTS3_DOCID_SEARCH 1 /* Lookup by rowid on %_content table */
116752 ** where nCol is the number of columns in the queried FTS table. The array
117086 ** The xDisconnect() virtual table method.
117140 ** The xDestroy() virtual table method.
117150 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
117152 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
117153 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
117154 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
117155 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
117166 ** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
117185 /* Create a list of user columns for the virtual table */
117191 /* Create the whole "CREATE TABLE" statement to pass to SQLite */
117193 "CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)",
117210 ** required by the FTS3 table passed as the only argument. This is done
117214 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
117224 char *zContentCols; /* Columns of %_content table */
117226 /* Create a list of user columns for the content table */
117237 /* Create the content table */
117239 "CREATE TABLE %Q.'%q_content'(%s)",
117247 "CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);",
117251 "CREATE TABLE %Q.'%q_segdir'("
117264 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117270 "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);",
117405 ** table has the three user-defined columns "a", "b", and "c", the following
117457 ** of columns in the %_content table (one for the docid plus one for each
117462 ** bracket. For example, if zFunc is "zip" and the FTS3 table has three
117525 ** representing the indexes maintained by the current FTS table. FTS tables
117528 ** (if any) specified as part of the CREATE VIRTUAL TABLE statement.
117543 struct Fts3Index **apIndex /* OUT: Array of indexes for this table */
117579 ** This function is called when initializing an FTS4 table that uses the
117581 ** of the new FTS4 table.
117585 ** a table of that name. If found, the output variables are populated
117588 ** *pnCol: Set to the number of columns table xxx has,
117594 ** the name of the corresponding column in table xxx. The array
117599 ** If the table cannot be found, an error code is returned and the output
117606 const char *zTbl, /* Name of content table */
117626 int nCol; /* Number of table columns */
117665 ** methods of the FTS3 virtual table.
117671 ** argv[2] -> table name
117677 void *pAux, /* Hash table containing tokenizers */
117690 int nCol = 0; /* Number of columns in the FTS table */
117693 int nName; /* Bytes required to hold table name */
117696 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
117699 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
117702 int bNoDocsize = 0; /* True to omit %_docsize table */
117726 ** + Figures out the number of columns the FTSX table will have, and
117843 ** TABLE statement, use all columns from the content table.
117971 /* Declare the table schema to SQLite. */
117996 ** The xConnect() and xCreate() methods for the virtual table. All the
118001 void *pAux, /* Pointer to tokenizer hash table */
118011 void *pAux, /* Pointer to tokenizer hash table */
118026 ** 3. Linear scan of %_content table.
118034 /* By default use a full table scan. This is an expensive option,
118128 ** on the xClose method of the virtual table interface.
118149 ** (or the equivalent for a content=xxx table) and set pCsr->pStmt to
118170 ** of the %_content table that contains the last match. Return
118188 ** table is missing a row that is present in the full-text index.
118244 ** table, then there are always 20 bytes of zeroed padding following the
118340 Fts3Table *p, /* Virtual table handle */
118358 char *zBlob = 0; /* Blob read from %_segments table */
119151 Fts3Table *p, /* FTS table handle */
119234 Fts3Table *p, /* FTS3 table handle */
119250 ** made by an fts4aux module, not an FTS table. In this case calling
119308 Fts3Table *p, /* FTS3 table handle */
119345 Fts3Table *p, /* FTS virtual table handle */
119370 Fts3Cursor *pCsr, /* Virtual table cursor handle */
119436 Fts3Table *p, /* Virtual table handle */
119508 ** Advance the cursor to the next row in the %_content table that
119510 ** the next row that matches. For a full-table scan, this will be
119511 ** simply the next row in the %_content table. For a docid lookup,
119537 ** This is the xFilter interface for the virtual table. See
119538 ** the virtual table xFilter method documentation for additional
119541 ** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against
119542 ** the %_content table.
119545 ** in the %_content table.
119618 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
119619 ** statement loops through all rows of the %_content table. For a
119646 ** This is the xEof method of the virtual table. SQLite calls this
119656 ** exposes %_content.docid as the rowid for the virtual table. The
119672 ** (iCol == p->nColumn) -> Magic column with the same name as the table.
119694 /* The extra column whose name is the same as the table.
119727 sqlite3_vtab *pVtab, /* Virtual table handle */
119737 ** hash-table to the database.
119761 ** the pending-terms hash-table have already been flushed into the database
119777 ** hash-table. Any changes made to the database are reverted by SQLite.
119905 ** where 't' is the name of an FTS3 table.
119913 Fts3Table *p; /* Virtual table handle */
119959 ** virtual table.
119962 sqlite3_vtab *pVtab, /* Virtual table handle */
119995 ** Implementation of FTS3 xRename method. Rename an fts3 table.
119998 sqlite3_vtab *pVtab, /* Virtual table handle */
119999 const char *zName /* New name of table */
120005 /* As it happens, the pending terms table is always empty here. This is
120006 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
120008 ** flushes the pending terms table. But leave the (no-op) call to
120016 "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';",
120023 "ALTER TABLE %Q.'%q_docsize' RENAME TO '%q_docsize';",
120029 "ALTER TABLE %Q.'%q_stat' RENAME TO '%q_stat';",
120034 "ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';",
120038 "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';",
120047 ** Flush the contents of the pending-terms table to disk.
120075 ** Discard the contents of the pending terms table.
120116 ** allocated for the tokenizer hash table.
120168 /* Allocate and initialise the hash-table used to store tokenizers. */
120176 /* Load the built-in tokenizers into the hash table */
120194 /* Create the virtual table wrapper around the hash-table and overload
120217 /* An error has occurred. Delete the hash table and return the error code. */
120282 Fts3Table *pTab, /* FTS Table pointer */
120765 ** of data that will fit on a single leaf page of an intkey table in
120773 ** data from the %_stat table to calculate it.
120775 ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3
120776 ** varints, where nCol is the number of columns in the FTS3 table.
120778 ** the table. The following nCol varints contain the total amount of
120779 ** data stored in all rows of each column of the table, from left
120848 ** table actually contains the same data as the index. To prevent this from
121421 ** 2. After scanning the current FTS table row for the deferred tokens,
121656 ** the FTS table (considering all rows), and
121658 ** 2. For each column, the number of rows in the table for which the
121670 ** values are set to the number of documents in the table. In other
121672 ** column of each row of the table.
121796 ** Initialize API pointer table, if required.
121856 ** Schema of the terms table.
121858 #define FTS3_TERMS_SCHEMA "CREATE TABLE x(term, col, documents, occurrences)"
121874 char const *zFts3; /* Name of fts3 table */
121879 Fts3auxTable *p; /* Virtual table object to return */
121883 /* The user should specify a single argument - the name of an fts3 table. */
122382 const char **azCol; /* Array of column names for fts3 table */
123049 ** of each column in the target fts3 table, in order from left to right.
123052 ** The iDefaultCol parameter should be passed the index of the table column
123056 ** match any table column.
123061 char **azCol, /* Array of column names for fts3 table */
123122 ** Function to query the hash-table of tokenizers (see README.tokenizers).
123208 ** of a column of the fts3 table that the query expression may refer to.
123315 ** We've modified it slightly to serve as a standalone hash table
123349 /* Turn bulk memory into a hash table object by initializing the
123352 ** "pNew" is a pointer to the hash table that is to be initialized.
123355 ** determines what kind of key the hash table will use. "copyKey" is
123356 ** true if the hash table should make its own private copy of keys and
123370 /* Remove all entries from a hash table. Reclaim all memory.
123371 ** Call this routine to delete a hash table or to reset a hash table
123375 Fts3HashElem *elem; /* For looping over all elements of the table */
123464 /* Link an element into the hash table
123467 Fts3Hash *pH, /* The complete hash table */
123490 /* Resize the hash table so that it cantains "new_size" buckets.
123491 ** "new_size" must be a power of 2. The hash table might fail
123497 struct _fts3ht *new_ht; /* The new hash table */
123517 ** hash table that matches the given key. The hash for this key has
123545 /* Remove a single entry from the hash table given a pointer to that
123599 ** Attempt to locate an element of the hash table pH with a key
123610 /* Insert an element into the hash table pH. The key is pKey,nKey
123620 ** the new data is returned and the hash table is unchanged.
123623 ** element corresponding to "key" is removed from the hash table.
123626 Fts3Hash *pH, /* The hash table to insert into */
123632 int h; /* the hash of the key modulo hash table size */
124366 ** hash table. This function may be called as follows:
124377 ** the string <key-name> must already exist in the has table. Otherwise,
124382 ** to string <key-name> (after the hash-table is updated, if applicable).
124479 Fts3Hash *pHash, /* Tokenizer hash table */
124759 ** the hash table pointed to by argument pHash. The hash table must
124767 ** defined at compilation time, a temporary virtual table (see header
124772 ** of both the scalar and, if created, the virtual table.
124893 ** else we need to reindex. One solution would be a meta-table to
125099 ** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()
125239 ** or the pending-terms table being flushed), leaves are written into the
125306 Fts3Table *p, /* Virtual table handle */
125387 Fts3Table *pTab, /* FTS3 table handle */
125417 Fts3Table *pTab, /* Fts3 table handle */
125424 Fts3Table *pTab, /* Fts3 table handle */
125441 Fts3Table *p, /* The FTS3 table */
125459 ** table-lock on the %_content table. This is required before reading
125460 ** data from the fts3 table. If this lock is not acquired first, then
125462 ** tables, but no read-lock on the %_content table. If this happens
125463 ** a second connection will be able to write to the fts3 table, but
125474 ** This reasoning does not apply to a content=xxx table.
125503 ** in the %_segdir table on disk. This function is used to convert three
125505 ** can be used to query the %_segdir table.
125535 ** all rows in the %_segdir table, from oldest to newest. If successful,
125540 ** each FTS3 table.
125542 ** The statement returns the following columns from the %_segdir table:
125551 Fts3Table *p, /* FTS3 table */
125707 Fts3Hash *pHash, /* Pending terms hash table to add entry to */
125736 ** pending-terms hash-table. The docid used is that currently stored in
125742 Fts3Table *p, /* Table into which text will be inserted */
125766 ** zText==0. In this case, add zero token entries to the hash table and
125820 Fts3Table *p, /* Full-text table handle */
125864 ** pendingTerms hash table.
125897 ** apVal[p->nColumn+2] Hidden column with same name as table
125902 Fts3Table *p, /* Full-text table */
125922 ** table. The SQL for this statement is:
125927 ** defined columns in the FTS3 table, plus one for the docid field.
125972 ** Remove all data from the FTS3 table. Clear the hash table containing
125978 /* Discard the contents of the pending-terms hash table. */
126012 Fts3Table *p, /* The FTS table to delete from */
126051 ** This function allocates a new level iLevel index in the segdir table.
126109 ** The %_segments table is declared as follows:
126111 ** CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)
126113 ** This function reads data from a single row of the %_segments table. The
126117 ** identified table row is. Whether or not paBlob is NULL, *pnBlob is set
126120 ** If an error occurs, or the table does not contain the specified row,
126131 ** on the database file for longer than necessary). Thus, any virtual table
126136 Fts3Table *p, /* FTS3 table handle */
126400 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
126572 ** the contents of the pending-terms hash table to the database.
126593 ** through each term in the pending-terms table. Or, if isPrefixIter is
126595 ** the pending terms hash table contains the terms "sqlite", "mysql" and
126608 Fts3Table *p, /* Virtual table handle */
126825 ** Insert a record into the %_segments table.
126828 Fts3Table *p, /* Virtual table handle */
126845 ** Insert a record into the %_segdir table.
126848 Fts3Table *p, /* Virtual table handle */
126897 Fts3Table *p, /* Virtual table handle */
127034 Fts3Table *p, /* Virtual table handle */
127103 Fts3Table *p, /* Virtual table handle */
127132 /* Find the next free blockid in the %_segments table */
127241 Fts3Table *p, /* Virtual table handle */
127264 /* The entire tree fits on the root node. Write it to the segdir table. */
127288 ** pRowid would mean the FTS3 table were empty.
127290 ** If successful, *pisEmpty is set to true if the table is empty except for
127298 /* If using the content=xxx option, assume the table is never empty */
127317 ** Segment levels are stored in the 'level' column of the %_segdir table.
127364 Fts3Table *p, /* Virtual table handle */
127483 Fts3Table *p, /* Virtual table handle */
127551 Fts3Table *p, /* Virtual table handle */
127583 Fts3Table *p, /* Virtual table handle */
127592 Fts3Table *p, /* Virtual table handle */
127667 Fts3Table *p, /* Virtual table handle */
128009 Fts3Table *p, /* Table into which to insert */
128037 ** Record 0 of the %_stat table contains a blob consisting of N varints,
128038 ** where N is the number of user defined columns in the fts3 table plus
128042 ** Varint 0: Total number of rows in the table.
128045 ** the column for all rows of the table.
128048 ** columns of all rows of the table.
128053 Fts3Table *p, /* Table being updated */
128154 ** The entire FTS index is discarded and rebuilt. If the table is one
128156 ** the current contents of the xxx table. Otherwise, it is rebuilt based
128157 ** on the contents of the %_content table.
128170 /* Compose and prepare an SQL statement to loop through the content table */
128297 ** table, not for all rows.
128302 int i; /* Used to iterate through table columns */
128381 Fts3Cursor *pCsr, /* Fts3 table cursor */
128404 ** present in the FTS3 table. If it is, delete it and adjust the contents
128417 /* Deleting this row means the whole table is empty. In this case
128419 ** data in the pendingTerms hash table. */
128441 ** tables. The schema of the virtual table being:
128443 ** CREATE TABLE <table name>(
128445 ** <table name> HIDDEN,
128525 ** the %_content table. If we hit the duplicate rowid constraint (or any
128587 ** Flush any data in the pending-terms hash table to disk. If successful,
128698 int nCol; /* Number of columns in table */
129144 Fts3Table *pTab, /* FTS3 table snippet comes from */
129353 ** rows of the table. Y is the number of rows for which column iCol contains
129647 sqlite3_int64 nDoc; /* Number of rows in table */
129836 /* Loop through all columns of the table being considered for snippets.
129838 ** columns of the FTS3 table. Otherwise, only column iCol is considered.
129896 int iCol; /* Column of table to populate aTerm for */
129968 /* Loop through the table columns, appending offset information to
130073 Fts3Cursor *pCsr, /* FTS3 table cursor */
130128 ** algorithms packaged as an SQLite virtual table module.
130135 ** The data structure for a single virtual r-tree table is stored in three
130137 ** in the table name is replaced with the user-supplied name of the r-tree
130138 ** table.
130140 ** CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
130141 ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
130142 ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
130145 ** table. For each node that is not the root node of the r-tree, there is
130146 ** an entry in the %_parent table associating the node with its parent.
130147 ** And for each row of data in the table, there is an entry in the %_rowid
130148 ** table that maps from the entries rowid to the id of the node that it
130151 ** The root node of an r-tree always exists, even if the r-tree table is
130153 ** table must be the same size as the root node. The content of each node
130247 /* Size of hash table Rtree.aHash. This hash table is not expected to
130254 ** An rtree virtual-table object.
130259 int iNodeSize; /* Size in bytes of each node in the node table */
130263 char *zDb; /* Name of database containing r-tree table */
130264 char *zName; /* Name of r-tree table */
130265 RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */
130510 ** in the Rtree.aHash table.
130520 ** Search the node hash table for node iNode. If found, return a pointer
130530 ** Add node pNode to the node hash table.
130541 ** Remove node pNode from the node hash table.
130587 /* Check if the requested node is already in the hash table. If so,
130818 ** the virtual table module xCreate() and xConnect() methods.
130825 ** Rtree virtual table module xCreate method.
130838 ** Rtree virtual table module xConnect method.
130878 ** Rtree virtual table module xDisconnect method.
130886 ** Rtree virtual table module xDestroy method.
130892 "DROP TABLE '%q'.'%q_node';"
130893 "DROP TABLE '%q'.'%q_rowid';"
130894 "DROP TABLE '%q'.'%q_parent';",
130913 ** Rtree virtual table module xOpen method.
130950 ** Rtree virtual table module xClose method.
130963 ** Rtree virtual table module xEof method.
131195 ** Rtree virtual table module xNext method.
131240 ** Rtree virtual table module xRowid method.
131253 ** Rtree virtual table module xColumn method.
131279 ** return SQLITE_OK. If there is no such record in the table, set
131344 ** Rtree virtual table module xFilter method.
131435 ** Rtree virtual table module xBestIndex method. There are three
131436 ** table scan strategies to choose from (in order from most to
131442 ** 2 See below R-tree query or full-table scan.
131670 Rtree *pRtree, /* Rtree table */
131767 Rtree *pRtree, /* Rtree table */
131793 ** Write mapping (iRowid->iNode) to the <rtree>_rowid table.
131803 ** Write mapping (iNode->iPar) to the <rtree>_parent table.
132495 /* Remove the node from the in-memory hash table and link it into
132779 /* Delete the corresponding entry in the <rtree>_rowid table. */
132847 /* Constraint handling. A write operation on an r-tree table may return
132884 ** the table. If so, the constraint has failed. */
132908 ** record to delete from the r-tree table. The following block does
132955 "ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";"
132956 "ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";"
132957 "ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";"
132971 rtreeCreate, /* xCreate - create a table */
132972 rtreeConnect, /* xConnect - connect to an existing table */
132974 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
132975 rtreeDestroy, /* xDestroy - Drop a table */
132989 rtreeRename, /* xRename - rename the table */
133006 /* Read and write the xxx_node table */
133011 /* Read and write the xxx_rowid table */
133016 /* Read and write the xxx_parent table */
133028 "CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);"
133029 "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);"
133030 "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY, parentnode INTEGER);"
133091 ** determine the node-size used by the rtree table being created or connected
133096 ** table already exists. In this case the node-size is determined by inspecting
133135 ** methods of the r-tree virtual table.
133139 ** argv[2] -> table name
133145 int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */
133146 sqlite3_vtab **ppVtab, /* OUT: New virtual table */
133158 "Wrong number of columns for an rtree table", /* 1 */
133159 "Too few columns for an rtree table", /* 2 */
133160 "Too many columns for an rtree table" /* 3 */
133194 ** the r-tree table schema.
133200 char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
133300 ** virtual table module "rtree" and the debugging/analysis scalar
133339 ** table MATCH operators.