Home | History | Annotate | Download | only in dist

Lines Matching defs: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 */
35860 ** But sometimes (for example when during a DROP of a large table) most
35898 /* Number of u32 values in hash table. */
35900 /* Maximum number of entries in hash table before
35923 ** a hash table that will hold up to BITVEC_MXHASH distinct values.
35944 u32 aHash[BITVEC_NINT]; /* Hash table representation */
36074 ** that BitvecClear can use to rebuilt its hash table.
36952 /* Hash table of all pages. The following variables may only be accessed
36958 PgHdr1 **apHash; /* Hash table for fast lookup by key */
36970 PgHdr1 *pNext; /* Next in hash table chain */
37247 ** This function is used to resize the hash table used by the cache passed
37327 ** Remove the page supplied as an argument from the hash table
37598 /* Step 1: Search the hash table for an existing entry. */
40101 ** Find a page in the hash table given its page number. Return
41041 ** in this case. But for things like temporary table (which will be
45524 ** database page number associated with each wal frame, and a hash-table
45539 ** Even without using the hash table, the last frame for page P
45546 ** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
45548 ** hash table for each page number in the mapping section, so the hash
45549 ** table is never more than half full. The expected number of collisions
45550 ** prior to finding a match is 1. Each entry of the hash table is an
45555 ** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table
45558 ** To look for page P in the hash table, first compute a hash iKey on
45563 ** Then start scanning entries of the hash table, starting with iKey
45564 ** (wrapping around to the beginning when the end of the hash table is
45567 ** wrap-around.) Because the hash table is never more than half full,
45591 ** Both readers can use the same hash table and mapping section to get
45592 ** the correct result. There may be entries in the hash table with
45594 ** slots in the hash table and so the first reader will get an answer as
45595 ** if no values greater than K0 had ever been inserted into the hash table
45600 ** When a rollback occurs, the value of K is decreased. Hash table entries
45602 ** from the hash table at this point.
45813 ** Each page of the wal-index mapping contains a hash-table made up of
45847 ** is a hash-table following every HASHTABLE_NPAGE page numbers in the
45858 ** The block of page numbers associated with the first hash-table in a
45860 ** hash-table on each aligned 32KB page of the wal-index.
46184 ** Return pointers to the hash table and page number array stored on
46188 ** Set output variable *paHash to point to the start of the hash table
46190 ** number of the first frame indexed by this hash table. If a
46191 ** slot in the hash table is set to N, it refers to frame number
46195 ** first frame indexed by the hash table, frame (*piZero+1).
46199 table */
46230 ** Return the number of the wal-index page that contains the hash-table
46258 ** Remove entries from the hash table that point to WAL slots greater
46264 ** At most only the hash table containing pWal->hdr.mxFrame needs to be
46270 volatile ht_slot *aHash = 0; /* Pointer to hash table to clear */
46271 volatile u32 *aPgno = 0; /* Page number array for hash table */
46284 /* Obtain pointers to the hash-table and page-number array containing
46286 ** that the page said hash-table and array reside on is already mapped.
46292 /* Zero all hash-table entries that correspond to frame numbers greater
46311 ** via the hash table even after the cleanup.
46335 volatile ht_slot *aHash = 0; /* Hash table */
46340 ** page number array and hash table entry.
46343 int iKey; /* Hash table key */
46344 int idx; /* Value to write to hash-table slot */
46350 /* If this is the first entry to be added to this hash-table, zero the
46351 ** entire hash table and aPgno[] array before proceding.
46362 ** the hash-table before writing any new entries.
46369 /* Write the aPgno[] array entry and the hash-table slot. */
46378 /* Verify that the number of entries in the hash table exactly equals
46383 int nEntry = 0; /* Number of entries in the hash table */
46389 ** via the hash table. This turns out to be a really, really expensive
47681 /* Search the hash table or tables for an entry matching page number
47683 ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
47687 ** table). This means the value just read from the hash
47697 ** if we had exclusive access to the hash-table:
47700 ** This condition filters out normal hash-table collisions.
47704 ** table after the current read-transaction had started.
47707 volatile ht_slot *aHash; /* Pointer to hash table */
48773 ** is opened on the table with root page BtShared.iTable. Locks are removed
48779 Pgno iTable; /* Root page of table */
48855 ** table (because there exists one or more read-locks on the table),
48885 u16 maxLeaf; /* Maximum local payload in a LEAFDATA table */
48886 u16 minLeaf; /* Minimum local payload in a LEAFDATA table */
48991 ** because the table is empty or because BtreeCursorFirst() has not been
48995 ** The table that this cursor was opened on still exists, but has been
49038 ** The pointer map is a lookup table that identifies the parent page for
49279 ** a statement since we will be comparing table and column names
49475 ** shared-cache table level locks. If the library is compiled with the
49495 ** table with root page iRoot. Return 1 if it does and 0 if not.
49497 ** For example, when writing to a table with root-page iRoot via
49504 ** the corresponding table. This makes things a bit more complicated,
49505 ** as this module treats each table as a separate structure. To determine
49506 ** the table corresponding to the index being written, this
49509 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
49510 ** hold a write-lock on the schema table (root page 1). This is also
49542 /* Figure out the root-page that the lock should be held on. For table
49545 ** table. */
49559 ** write-lock on the schema table, or (if the client is reading) a
49580 ** table or index rooted at iRoot because other shared connections are
49581 ** simultaneously reading that same table or index.
49585 ** the iRoot table. Except, if the other Btree object has the
49589 ** For example, before writing to any part of the table or index
49610 ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return
49650 ** may hold a WRITE_LOCK on any table in this file (since there can
49670 ** Add a lock on the table with root-page iTable to the shared-btree used
49698 ** table, and that lock is obtained in BtreeBeginTrans(). */
49706 /* First search the list for an existing lock on this table. */
49715 ** with table iTable, allocate one and link it into the list.
49743 ** Release all the table locks (locks obtained via calls to
49846 ** This function is called before modifying the contents of a table
49851 ** table is about to be deleted. In this case invalidate all incrblob
49852 ** cursors open on any row within the table with root-page pgnoRoot.
49968 /* If this is an intKey table, then the above call to BtreeKeySize()
49971 ** table, then malloc space for and store the pCur->nKey bytes of key
50005 ** the table with root-page iRoot. Usually, this is called just before cursor
50006 ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()).
51433 ** The call to sqlite3BtreeRollback() drops any table-locks held by
52834 ** cursors open with wrFlag==0 on the same table. Otherwise
52851 int iTable, /* Root page of table to open */
52862 ** b-tree database, the connection is holding the required table locks,
52900 int iTable, /* Root page of table to open */
53048 ** that is currently pointing to a row in a (non-empty) table.
53061 ** For a table with the INTKEY flag set, this routine returns the key
53228 ** invalidated if some other cursor writes to the same table, or if
53234 ** * Creating a table (may require moving an overflow page).
53408 ** in the table.
53634 ** If the table has a virtual root page, then the cursor is moved to point
53635 ** to the virtual root page instead of the actual root page. A table has a
53637 ** single child page. This can only happen with the table rooted at page 1.
53648 ** indicating a table b-tree, or if the caller did specify a KeyInfo
53689 ** NULL, the caller expects a table b-tree. If this is not the case,
53776 /* Move the cursor to the first entry in the table. Return SQLITE_OK
53778 ** or set *pRes to 1 if the table is empty.
53799 /* Move the cursor to the last entry in the table. Return SQLITE_OK
53801 ** or set *pRes to 1 if the table is empty.
53857 ** is smaller than intKey/pIdxKey or if the table is empty
53870 i64 intKey, /* The table key */
53919 ** be the right kind (index or table) of b-tree page. Otherwise
54049 ** Return TRUE if the cursor is not pointing at an entry of the table.
54052 ** past the last entry in the table or sqlite3BtreePrev() moves past
54053 ** the first entry. TRUE is also returned if the table is empty.
54056 /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
54217 ** is only used by auto-vacuum databases when allocating a new table.
55674 ** of the table is a linear scan through the file. That
56130 ** define what table the record should be inserted into. The cursor
56133 ** For an INTKEY table, only the nKey value of the key is used. pKey is
56134 ** ignored. For a ZERODATA table, the pData and nData are both ignored.
56150 BtCursor *pCur, /* Insert data into the table of this cursor */
56180 ** intkey table, the caller should be inserting integer keys with a
56184 /* If this is an insert into a table b-tree, invalidate any incrblob
56191 /* Save the positions of any other cursors open on this table.
56194 ** example, when inserting data into a table with auto-generated integer
56214 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
56266 ** entry in the table, and the next row inserted has an integer key
56314 /* If this is a delete operation to remove a row from a table b-tree,
56338 /* Save the positions of any other cursors open on this table before
56405 ** Create a new BTree table. Write into *piTable the page
56406 ** number for the root page of the new table.
56420 int ptfFlags; /* Page-type flage for the root page of new table */
56436 /* Creating a new table may probably require moving an existing database
56444 ** root page of the new table should go. meta[3] is the largest root-page
56470 ** the new table (assuming an error did not occur). But we were
56563 BtShared *pBt, /* The BTree that contains the table */
56608 ** Delete all information from a single table in the database. iTable is
56609 ** the page number of the root of the table. After this routine returns,
56613 ** read cursors on the table. Open write cursors are moved to the
56614 ** root of the table.
56616 ** If pnChange is not NULL, then table iTable must be an intkey table. The
56618 ** entries in the table.
56626 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56627 ** is the root of a table b-tree - if it is not, the following call is
56640 ** Erase all information in a table and add the root of the table to
56641 ** the freelist. Except, the root of the principle table (the one on
56645 ** cursors on the table.
56667 /* It is illegal to drop a table if any cursors are open on the
56700 /* If the table being dropped is the table with the largest root-page
56709 /* The table being dropped does not have the largest root-page
57304 ** a table. nRoot is the number of entries in aRoot.
57526 ** sqlite_master table. Otherwise SQLITE_OK.
57541 ** Obtain a lock on the table whose root page is iTab. The
57567 ** INTKEY table currently pointing at a valid table entry.
57593 ** (c) the connection holds a write-lock on the table (if required),
57595 ** (e) the cursor points at a valid row of an intKey table.
60624 ** to 6.6 percent. The test case is inserting 1000 rows into a table
62081 ** the blob of data that it corresponds to. In a table record, all serial
62086 ** The following table describes the various storage classes for data:
62463 ** This function compares the two table rows or index records
63620 ** 3 The name of the table that the column derives from
63621 ** 4 The name of the table column that the result column derives from
63715 ** Return the name of the table from which a result column derives.
63731 ** Return the name of the table column from which a result column derives.
64554 int nField, /* Number of fields in the table or index */
64556 int isBtreeCursor /* True for B-Tree. False for pseudo-table or vtab */
65235 VdbeCursor *pC; /* Cursor of table to get the new rowid */
65245 VdbeCursor *pC; /* Cursor to table into which insert is written */
65249 const char *zTbl; /* Table name - used by the opdate hook */
66354 ** with a CREATE TABLE statement.)
67025 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
67027 ** The first OP_Column against a pseudo-table after the value of the content
67136 /* Read and parse the table header. Store the results of the parse
67193 ** in the table, and in that case, 5*u.an.nField+3 might be smaller than u.an.offset.
67248 ** table. Set the u.an.offset for any extra columns not present in
67355 ** use as a data record in a database table or as a key
67488 ** Store the number of entries (an integer value) in the table or index
67943 ** are queried from within xNext() and other v-table methods using
67946 ** v-table would have to be ready for the sqlite3_vtab structure itself
67948 ** a v-table method.
67962 ** Open a read-only cursor for the database table whose root page is
67986 ** value, it is set to the number of columns in the table.
67992 ** Open a read/write cursor named P1 on the table or index whose root
68000 ** value, it is set to the number of columns in the table, or to the
68001 ** largest index of any column of the table that is actually used.
68004 ** in read/write mode. For a given table, there can be one or more read-only
68092 ** Open a new cursor P1 to a transient table.
68095 ** table is deleted automatically when the cursor is closed.
68097 ** P2 is the number of columns in the ephemeral table.
68098 ** The cursor points to a BTree table if P4==0 and to a BTree index
68103 ** confusion because the term "temp table", might refer either
68104 ** to a TEMP table at the SQL level, or to a table opened by
68106 ** that created confusion with the whole virtual-table idea.
68144 ** opening it. If a transient table is required, just use the
68145 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
68195 ** Open a new cursor that points to a fake table that contains a single
68200 ** A pseudo-table created by this opcode is used to hold a single
68203 ** is the only cursor opcode that works with a pseudo-table.
68206 ** the pseudo-table.
68237 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68250 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68263 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68276 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68421 /* u.bb.res might be negative because the table is empty. Check to
68432 /* This happens when attempting to open the sqlite3_master table
68434 ** take the jump (since there are no records in the table).
68443 ** P1 is an open table cursor and P2 is a rowid integer. Arrange
68649 ** with that key does not exist in table of P1, then jump to P2.
68654 ** operation assumes the key is an integer and that P1 is a table whereas
68692 ** sqlite_master table returns SQLITE_EMPTY.
68718 ** Get a new integer record number (a.k.a "rowid") used as the key to a table.
68720 ** table that cursor P1 points to. The new record number is written
68733 VdbeCursor *pC; /* Cursor of table to get the new rowid */
68757 ** it already exists in the table. If it does not exist, we have
68833 ** an AUTOINCREMENT table. */
68869 ** Write an entry into the table of cursor P1. A new entry is
68893 ** Parameter P4 may point to a string containing the table-name, or
68917 VdbeCursor *pC; /* Cursor to table into which insert is written */
68921 const char *zTbl; /* Table name - used by the opdate hook */
68986 ** record in the table. If it is left pointing at the next record, then
68993 ** P1 must not be pseudo-table. It has to be a real table with
68996 ** If P4 is not NULL, then it is the name of the table that P1 is
69023 ** OP_Column on the same table without any intervening operations that
69111 ** of a real table, not a pseudo-table.
69121 ** of a real table, not a pseudo-table.
69190 ** Store in register P2 an integer which is the key of the table entry that
69193 ** P1 can be either an ordinary table or a virtual table. There used to
69195 ** one opcode now works for both table types.
69263 ** will refer to the last entry in the database table or index.
69264 ** If the table or index is empty and P2>0, then jump immediately to P2.
69265 ** If P2 is 0 or if the table or index is not empty, fall through
69321 ** will refer to the first entry in the database table or index.
69322 ** If the table or index is empty and P2>0, then jump immediately to P2.
69323 ** If P2 is 0 or if the table or index is not empty, fall through
69360 ** table or index. If there are no more key/value pairs then fall through
69364 ** The P1 cursor must be for a real table, not a pseudo-table.
69377 ** table or index. If there is no previous key/value pairs then fall through
69381 ** The P1 cursor must be for a real table, not a pseudo-table.
69525 ** the rowid of the table entry to which this index entry points.
69627 ** Delete an entire database table or index whose root page in the database
69630 ** The table being destroyed is in the main database file if P3==0. If
69631 ** P3==1 then the table to be clear is in the auxiliary database file
69632 ** that is used to store tables create using CREATE TEMPORARY TABLE.
69639 ** movement was required (because the table being dropped was already
69687 ** Delete all contents of the database table or index whose root page
69689 ** remove the table or index from the database file.
69691 ** The table being clear is in the main database file if P2==0. If
69692 ** P2==1 then the table to be clear is in the auxiliary database file
69693 ** that is used to store tables create using CREATE TEMPORARY TABLE.
69695 ** If the P3 value is non-zero, then the table referred to must be an
69696 ** intkey table (an SQL table, not an index). In this case the row change
69697 ** count is incremented by the number of rows in the table being cleared.
69699 ** also incremented by the number of rows in the table being cleared.
69726 ** Allocate a new table in the main database file if P1==0 or in the
69728 ** P1>1. Write the root page number of the new table into
69731 ** The difference between a table and an index is this: A table must
69741 ** P1>1. Write the root page number of the new table into
69772 ** Read and parse all entries from the SQLITE_MASTER table of database P1
69830 ** Read the sqlite_stat1 table for database P1 and load the content
69831 ** of that table into the internal index hash table. This will cause
69844 ** the table named P4 in database P1. This is called after a table
70611 ** Obtain a lock on a particular table. This instruction is only used when
70618 ** P2 contains the root-page of the table to lock.
70620 ** P4 contains a pointer to the name of the table being locked. This is only
70633 sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z);
70644 ** xBegin method for that table.
70647 ** within a callback to a virtual table xSync() method. If it is, the error
70664 ** P4 is the name of a virtual table in database P1. Call the xCreate method
70665 ** for that table.
70676 ** P4 is the name of a virtual table in database P1. Call the xDestroy method
70677 ** of that table.
70690 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70692 ** table and stores that cursor in P1.
70737 ** This opcode invokes the xFilter method on the virtual table specified
70807 ** the row of the virtual-table that the
70865 ** Advance virtual table P1 to the next row in its result set and
70866 ** jump to instruction P2. Or, if the virtual table has reached
70891 ** some other method is next invoked on the save virtual table cursor.
70912 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70944 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70954 ** row. This can be NULL to have the virtual table select the new
71230 int iCol; /* Table column this handle is open on */
71312 const char *zTable, /* The table containing the blob */
71322 ** db/table/row entry. The reason for using a vdbe program instead
71356 Table *pTab;
71380 sqlite3ErrorMsg(pParse, "cannot open virtual table: %s", zTable);
71472 /* Make sure a mutex is held on the table to be accessed */
71492 ** think that the table has one more column than it really
71632 ** database table.
72733 ** Table of methods for JournalFile sqlite3_file object.
73017 ** Table of methods for MemJournal sqlite3_file object.
73218 ** table and column.
73329 ** pExpr->iTable Set to the cursor number for the table obtained
73331 ** pExpr->pTab Points to the Table structure of X.Y (even if
73333 ** pExpr->iColumn Set to the column number within the table.
73340 ** can be used. The zTable variable is the name of the table (the "Y"). This
73342 ** means that the form of the name is Z and that columns from any table
73350 const char *zDb, /* Name of the database containing table, or NULL */
73351 const char *zTab, /* Name of table containing column, or NULL */
73358 int cntTab = 0; /* Number of matching table names */
73382 Table *pTab;
73413 ** is for the right-hand table of a NATURAL JOIN or is in a
73439 Table *pTab = 0;
73500 ** SELECT a+b AS x FROM table WHERE x<10;
73571 /* If a column from a table in pSrcList is referenced, then record
73693 /* A table name and column name: ID.ID
73694 ** Or a database, table and column: ID.ID.ID
74315 ** table columns and result-set columns. At the same time, do error
74319 ** To resolve table columns references we look for nodes (or subtrees) of the
74325 ** Y: The name of a table in a FROM clause. Or in a trigger
74328 ** Z: The name of a column in table Y.
74333 ** Expr.pTab Points to the Table object for X.Y
74342 ** Table-name and function resolution occurs on the substituted expression
74455 ** CREATE TABLE t1(a);
75327 Table *pTab;
75780 Table *pTab;
75799 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
75822 ** The index of the cursor opened on the b-tree (database table, database index
75823 ** or ephermal table) is stored in pX->iTable before this function returns.
75826 ** IN_INDEX_ROWID - The cursor was opened on a database table.
75829 ** populated epheremal table.
75834 ** SELECT <column> FROM <table>
75838 ** epheremal table must be used unless the selected <column> is guaranteed
75843 ** for fast set membership tests. In this case an epheremal table must
75873 int eType = 0; /* Type of RHS table. IN_INDEX_* */
75874 int iTab = pParse->nTab++; /* Cursor of the RHS table */
75880 /* Check to see if an existing table or index can be used to
75882 ** ephemeral table.
75887 Table *pTab; /* Table <table>. */
75900 /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
75923 ** be used in place of a temp-table, it must be ordered according
75961 /* Could not found an existing table or index to use as the RHS b-tree.
75962 ** We will have to generate an ephemeral table to do the job.
76000 ** to some integer key column of a table B-Tree. In this case, use an
76059 KeyInfo keyInfo; /* Keyinfo for the generated table */
76070 ** expression it is handled the same way. An ephemeral table is
76092 ** table allocated and opened above.
76114 ** store it in the temporary table. If <expr> is a column, then use
76146 /* Evaluate the expression and insert it into the temp table */
76251 /* Compute the RHS. After this step, the table with cursor
76286 /* In this case, the RHS is the ROWID of table b-tree
76438 ** particular table is stored in a particular register.
76571 ** Generate code to extract the value of the iCol-th column of a table.
76575 Table *pTab, /* The table containing the value */
76576 int iTabCur, /* The cursor for this table */
76593 ** table pTab and store the column value in a register. An effort
76602 Table *pTab, /* Description of the table we are reading from */
76603 int iColumn, /* Index of the table column */
76604 int iTable, /* The cursor pointing to the table */
77033 ** a virtual table column.
77037 ** see if it is a column in a virtual table. This is done because
77136 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
77137 ** is set to the column of the pseudo-table to read, or to -1 to
77142 ** to reference another column of the old.* pseudo-table, where
77144 ** set to (n+1), where n is the number of columns in each pseudo-table.
77145 ** For a reference to any other column in the new.* pseudo-table, p1
77147 ** example, if the table on which triggers are being fired is
77150 ** CREATE TABLE t1(a, b);
77158 Table *pTab = pExpr->pTab;
77569 ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
77570 ** is set to the column of the pseudo-table to read, or to -1 to
78254 /* If we reach this point, it means that pExpr refers to a table
78481 ** that implements the ALTER TABLE command.
78486 ** ALTER TABLE logic from the build.
78493 ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
78494 ** CREATE INDEX command. The second is a table name. The table name in
78495 ** the CREATE TABLE or CREATE INDEX statement is replaced with the third
78498 ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
78499 ** -> 'CREATE TABLE
78522 /* The principle used to locate the table name in the CREATE TABLE
78523 ** statement is that the table name is the first non-space token that
78555 ** generated by the ALTER TABLE ... RENAME command to modify the definition
78556 ** of any foreign key constraints that use the table being renamed as the
78557 ** parent table. It is passed three arguments:
78559 ** 1) The complete text of the CREATE TABLE statement being modified,
78560 ** 2) The old name of the table being renamed, and
78561 ** 3) The new name of the table being renamed.
78563 ** It returns the new CREATE TABLE statement. For example:
78565 ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
78566 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
78618 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
78619 ** statement. The second is a table name. The table name in the CREATE
78622 ** TRIGGER, not CREATE INDEX and CREATE TABLE.
78642 /* The principle used to locate the table name in the CREATE TRIGGER
78643 ** statement is that the table name is the first token that is immediatedly
78651 /* Ran out of input before finding the table name. Return NULL. */
78673 ** Note that ON cannot be a database, table or column name, so
78683 /* Variable tname now contains the token that is the old table-name
78694 ** Register built-in functions used to help implement ALTER TABLE
78745 ** tables that have foreign key constraints that refer to table pTab (i.e.
78746 ** constraints for which pTab is the parent table) from the sqlite_master
78747 ** table.
78749 static char *whereForeignKeys(Parse *pParse, Table *pTab){
78761 ** temporary triggers on table pTab from the sqlite_temp_master table. If
78762 ** table pTab has no temporary triggers, or is itself stored in the
78765 static char *whereTempTriggers(Parse *pParse, Table *pTab){
78770 /* If the table is not located in the temp-db (in which case NULL is
78792 ** Generate code to drop and reload the internal representation of table
78794 ** Argument zName is the name of the table in the database schema at
78797 ** "ALTER TABLE RENAME TO" statement.
78799 static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
78814 /* Drop any table triggers from the internal schema. */
78822 /* Drop the table and index from the internal schema. */
78825 /* Reload the table, index and permanent trigger schemas. */
78831 /* Now, if the table is not stored in the temp database, reload any temp
78841 ** Parameter zName is the name of a table that is about to be altered
78842 ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
78843 ** If the table is a system table, this function leaves an error message
78846 ** Or, if zName is not a system table, zero is returned.
78850 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
78857 ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
78862 SrcList *pSrc, /* The table to rename. */
78863 Token *pName /* The new table name. */
78865 int iDb; /* Database that contains the table */
78867 Table *pTab; /* Table being renamed */
78871 const char *zTabName; /* Original name of the table */
78890 /* Get a NULL terminated version of the new table name. */
78894 /* Check that a table or index named 'zName' does not already exist
78899 "there is already another table or index with this name: %s", zName);
78903 /* Make sure it is not a system table being altered, or a reserved name
78904 ** that the table is being renamed to.
78940 ** Then modify the schema cookie (since the ALTER TABLE modifies the
78941 ** schema). Open a statement transaction if the table is a virtual
78942 ** table.
78951 /* If this is a virtual table, invoke the xRename() function if
78953 ** of any resources used by the v-table implementation (including other
78954 ** SQLite tables) that are identified by the name of the virtual table.
78971 /* If foreign-key support is enabled, rewrite the CREATE TABLE
78973 ** for which the renamed table is the parent table. */
78984 table to use the new table name. */
78996 "WHEN type='table' THEN %Q "
79001 "(type='table' OR type='index' OR type='trigger');",
79010 /* If the sqlite_sequence table exists in this database, then update
79011 ** it with the new table name.
79021 /* If there are TEMP triggers on this table, modify the sqlite_temp_master
79022 ** table. Don't do this if the table being ALTERed is itself located in
79039 Table *pFrom = p->pFrom;
79047 /* Drop and reload the internal table schema. */
79083 ** This function is called after an "ALTER TABLE ... ADD" statement
79087 ** The Table structure pParse->pNewTable was extended to include
79091 Table *pNew; /* Copy of pParse->pNewTable */
79092 Table *pTab; /* Table being altered */
79095 const char *zTab; /* Table name */
79169 /* Modify the CREATE TABLE statement. */
79181 "WHERE type = 'table' AND name = %Q",
79195 /* Reload the schema of the modified table. */
79200 ** This function is called by the parser after the table-name in
79201 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
79202 ** pSrc is the full-name of the table being altered.
79204 ** This routine makes a (partial) copy of the Table structure
79205 ** for the table being altered and sets Parse.pNewTable to point
79208 ** the copy. The copy of the Table structure is deleted by tokenize.c
79212 ** coding the "ALTER TABLE ... ADD" statement.
79215 Table *pNew;
79216 Table *pTab;
79223 /* Look up the table being altered. */
79249 /* Put a copy of the Table struct in Parse.pNewTable for the
79253 ** table because user table are not allowed to have the "sqlite_"
79256 pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
79316 ** CREATE TABLE sqlite_stat1(tbl, idx, stat);
79317 ** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);
79318 ** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);
79321 ** The sqlite_stat2 table is not created or used unless the SQLite version
79323 ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated.
79324 ** The sqlite_stat2 table is superceded by sqlite_stat3, which is only
79332 ** name in the idx column. The tbl column is the name of the table to
79335 ** list is the number of rows in the index and in the table. The second
79352 ** rows in the table identified by sqlite_stat1.tbl.
79358 ** 3.6.18 and 3.7.8. The "stat2" table contains additional information
79360 ** the "idx" column and the "tbl" column is the name of the table to which
79362 ** table for each index.
79377 ** writes the sqlite_stat2 table. This version of SQLite only supports
79385 ** The format of the sqlite_stat3 table is similar to the format of
79386 ** the sqlite_stat2 table. There are multiple entries for each index.
79387 ** The idx column names the index and the tbl column is the table of the
79415 ** This routine generates code that opens the sqlite_stat1 table for
79417 ** SQLITE_ENABLE_STAT3 macro defined, then the sqlite_stat3 table is
79421 ** Similarly, if the sqlite_stat3 table does not exist and the library
79424 ** Argument zWhere may be a pointer to a buffer containing a table name,
79427 ** with the named table are deleted. If zWhere==0, then code is generated
79428 ** to delete all stat table entries.
79433 int iStatCur, /* Open the sqlite_stat1 table on this cursor */
79434 const char *zWhere, /* Delete entries for this table or index */
79464 Table *pStat;
79466 /* The sqlite_stat[12] table does not exist. Create it. Note that a
79467 ** side-effect of the CREATE TABLE statement is to leave the rootpage
79468 ** of the new table in register pParse->regRoot. This is important
79471 "CREATE TABLE %Q.%s(%s)", pDb->zName, zTab, aTable[i].zCols
79476 /* The table already exists. If zWhere is not NULL, delete all entries
79477 ** associated with the table zWhere. If zWhere is NULL, delete the
79478 ** entire contents of the table. */
79486 /* The sqlite_stat[12] table already exists. Delete all rows. */
79514 tRowcnt nRow; /* Number of rows in the entire table */
79521 i64 iRowid; /* Rowid in main table of the key */
79533 ** are the number of rows in the table or index (C) and the number of samples
79586 ** table.
79722 ** a single table.
79726 Table *pTab, /* Table whose indices are to be analyzed */
79728 int iStatCur, /* Index of VdbeCursor that writes the sqlite_stat1 table */
79740 int regTabname = iMem++; /* Register containing table name */
79751 int regCount = iMem++; /* Number of rows in the table or index */
79756 int iTabCur = pParse->nTab++; /* Table cursor */
79758 int regCol = iMem++; /* Content of a column in analyzed table */
79787 /* Establish a read-lock on the table at the shared-cache level. */
79836 ** The total number of rows in the table.
79941 ** The result is a single row of the sqlite_stat1 table. The first
79942 ** two columns are the names of the table and index. The third column
79946 ** column of the table. This additional integer is a guess of how many
79947 ** rows of the table the index will select. If D is the count of distinct
79953 ** If K==0 then no entry is made into the sqlite_stat1 table.
79976 /* If the table has no indices, create a single sqlite_stat1 entry
80027 Table *pTab = (Table*)sqliteHashData(k);
80034 ** Generate code that will do an analysis of a single table in
80038 static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){
80067 ** Form 3 analyzes all indices associated with the named table.
80074 Table *pTab;
80093 /* Form 2: Analyze the database or table named */
80109 /* Form 3: Analyze the fully qualified table name */
80138 ** sqlite_stat1 table.
80140 ** argv[0] = name of the table
80145 ** the table.
80150 Table *pTable;
80218 ** Load content from the sqlite_stat3 table into the Index.aSample[]
80351 ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
80353 ** during compilation and the sqlite_stat3 table is present, no data is
80357 ** sqlite_stat3 table is not present in the database, SQLITE_ERROR is
80359 ** table (if it is present) before returning.
80385 /* Check to make sure the sqlite_stat1 table exists */
80392 /* Load new statistics out of the sqlite_stat1 table */
80403 /* Load the statistics from the sqlite_stat3 table. */
80866 ** a specific database to all table references where the database name
81040 ** the table and the column that are being accessed. The auth function
81075 ** table zTab in database zDb. This function assumes that an authorization
81084 const char *zTab, /* Table name */
81107 ** The pExpr should be a TK_COLUMN expression. The table referred to
81108 ** is in pTabList or else it is the NEW or OLD table of a trigger.
81119 SrcList *pTabList /* All table that pExpr might refer to */
81122 Table *pTab = 0; /* The table being read */
81123 const char *zCol; /* Name of the column of the table */
81124 int iSrc; /* Index in pTabList->a[] of table being read */
81126 int iCol; /* Index of column in table */
81132 ** temporary table. */
81249 ** CREATE TABLE
81250 ** DROP TABLE
81274 int iDb; /* The database containing the table to be locked */
81275 int iTab; /* The root page of the table to be locked */
81277 const char *zName; /* Name of the table */
81281 ** Record the fact that we want to lock a table at run-time.
81283 ** The table to be locked has root page iTab and is found in database iDb.
81292 int iDb, /* Index of the database containing the table to lock */
81293 int iTab, /* Root page number of the table to be locked */
81295 const char *zName /* Name of the table to be locked */
81327 ** Code an OP_TableLock instruction for each table locked by the
81409 ** obtain the required table-locks. This is a no-op unless the
81489 ** table given the name of that table and (optionally) the name of the
81490 ** database containing the table. Return NULL if not found.
81492 ** If zDatabase is 0, all databases are searched for the table and the
81493 ** first matching table is returned. (No checking for duplicate table
81499 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
81500 Table *p = 0;
81519 ** table given the name of that table and (optionally) the name of the
81520 ** database containing the table. Return NULL if not found. Also leave an
81527 SQLITE_PRIVATE Table *sqlite3LocateTable(
81529 int isView, /* True if looking for a VIEW rather than a TABLE */
81530 const char *zName, /* Name of the table we are looking for */
81533 Table *p;
81543 const char *zMsg = isView ? "no such view" : "no such table";
81561 ** table and the first matching index is returned. (No checking
81597 ** unlike that index from its Table then remove the index from
81598 ** the index hash table and free all memory structures associated
81710 ** Delete memory allocated for the column names of a table or view (the
81711 ** Table.aCol[] array).
81713 static void sqliteDeleteColumnNames(sqlite3 *db, Table *pTable){
81731 ** Table. No changes are made to disk by this routine.
81734 ** the table data structure from the hash table. But it does destroy
81736 ** the table.
81738 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
81743 /* Do not delete the table until the reference count reaches zero. */
81747 /* Delete all indices associated with this table. */
81762 /* Delete any foreign keys attached to this table. */
81765 /* Delete the Table structure itself.
81781 ** Unlink the given table from the hash tables and the delete the
81782 ** table structure with all its indices and foreign keys.
81785 Table *p;
81792 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
81825 ** Open the sqlite_master table stored in database number iDb for
81826 ** writing. The table is opened using cursor 0.
81832 sqlite3VdbeChangeP4(v, -1, (char *)5, P4_INT32); /* 5 column table */
81874 /* The table or view or trigger name is passed to this routine via tokens
81875 ** pName1 and pName2. If the table name was fully qualified, for example:
81877 ** CREATE TABLE xxx.yyy (...);
81880 ** the table name is not fully qualified, i.e.:
81882 ** CREATE TABLE yyy(...);
81887 ** pName2) that stores the unqualified table name. The index of the
81922 ** unqualified name for a new schema object (table, index, view or
81938 ** Begin constructing a new table representation in memory. This is
81940 ** to a CREATE TABLE statement. In particular, this routine is called
81941 ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp
81942 ** flag is true if the table should be stored in the auxiliary database
81945 ** CREATE and TABLE.
81947 ** The new table record is initialized and put in pParse->pNewTable.
81948 ** As more of the CREATE TABLE statement is parsed, additional action
81950 ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine
81951 ** is called to complete the construction of the new table record.
81955 Token *pName1, /* First part of the name of the table or view */
81956 Token *pName2, /* Second part of the name of the table or view */
81957 int isTemp, /* True if this is a TEMP table */
81959 int isVirtual, /* True if this is a VIRTUAL table */
81960 int noErr /* Do nothing if table already exists */
81962 Table *pTable;
81963 char *zName = 0; /* The name of the new table */
81966 int iDb; /* Database number to create the table in */
81967 Token *pName; /* Unqualified name of the table to create */
81969 /* The table or view name to create is passed to this routine via tokens
81970 ** pName1 and pName2. If the table name was fully qualified, for example:
81972 ** CREATE TABLE xxx.yyy (...);
81975 ** the table name is not fully qualified, i.e.:
81977 ** CREATE TABLE yyy(...);
81982 ** pName2) that stores the unqualified table name. The variable iDb is
81983 ** set to the index of the database that the table or view is to be
81989 /* If creating a temp table, the name may not be qualified. Unless
81991 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
82030 /* Make sure the new table name does not collide with an existing
82031 ** index or table name in the same database. Issue an error message if
82045 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
82058 pTable = sqlite3DbMallocZero(db, sizeof(Table));
82073 /* If this is the magic sqlite_sequence table used by autoincrement,
82074 ** then record a pointer to this table in the main database structure
82075 ** so that INSERT can find the table easily.
82084 /* Begin generating the code that will insert the table record into
82085 ** the SQLITE_MASTER table. Note in particular that we must go ahead
82086 ** and allocate the record number for the table entry now. Before any
82088 ** indices to be created and the table record must come before the
82089 ** indices. Hence, the record number for the table must be allocated
82121 /* This just creates a place-holder record in the sqlite_master table.
82126 ** The root page number of the new table is left in reg pParse->regRoot.
82169 ** Add a new column to the table currently being constructed.
82172 ** in a CREATE TABLE statement. sqlite3StartTable() gets called
82177 Table *p;
82221 ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
82226 Table *p;
82237 ** substrings in the following table. If one of the substrings is
82240 ** the table take priority. For example, if zType is 'BLOBINT',
82254 ** If none of the substrings in the above table are found,
82295 ** parsing a CREATE TABLE statement. The pFirst token is the first
82303 Table *p;
82316 ** of the table currently under construction.
82322 ** parsing a CREATE TABLE statement.
82325 Table *p;
82350 ** Designate the PRIMARY KEY for the table. pList is a list of names
82352 ** most recently added column of the table is the primary key.
82354 ** A table can have at most one primary key. If the table already has
82359 ** then we will try to use that column as the rowid. Set the Table.iPKey
82360 ** field of the table under construction to be the index of the
82361 ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is
82374 Table *pTab = pParse->pNewTable;
82380 "table \"%s\" has more than one primary key", pTab->zName);
82429 ** Add a new CHECK constraint to the table currently under construction.
82437 Table *pTab = pParse->pNewTable;
82448 ** Set the collation function of the most recently parsed table column
82452 Table *p;
82599 ** Generate a CREATE TABLE statement appropriate for the given
82600 ** table. Memory to hold the text of the statement is obtained
82603 static char *createTableStmt(sqlite3 *db, Table *p){
82628 sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
82669 ** a CREATE TABLE statement.
82671 ** The table structure that other action routines have been building
82675 ** An entry for the table is made in the master table on disk, unless
82676 ** this is a temporary table or db->init.busy==1. When db->init.busy==1
82677 ** it means we are reading the sqlite_master table because we just
82678 ** connected to the database or because the sqlite_master table has
82679 ** recently changed, so the entry for this table already exists in
82680 ** the sqlite_master table. We do not want to create it again.
82683 ** was called to create a table generated from a
82684 ** "CREATE TABLE ... AS SELECT ..." statement. The column names of
82685 ** the new table will match the result set of the SELECT.
82690 Token *pEnd, /* The final ')' token in the CREATE TABLE */
82693 Table *p;
82730 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
82732 ** for the table from the db->init.newTnum field. (The page number
82739 /* If not initializing, then create a record for the new table
82740 ** in the SQLITE_MASTER table of the database.
82742 ** If this is a TEMPORARY table, write the entry into the auxiliary
82748 char *zType; /* "view" or "table" */
82749 char *zType2; /* "VIEW" or "TABLE" */
82750 char *zStmt; /* Text of the CREATE TABLE or CREATE VIEW statement */
82758 ** Initialize zType for the new view or table.
82761 /* A regular table */
82762 zType = "table";
82763 zType2 = "TABLE";
82772 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
82773 ** statement to populate the new table. The root-page number for the
82774 ** new table is in register pParse->regRoot.
82778 ** by the new table.
82780 ** A shared-cache write-lock is not required to write to the new table,
82787 Table *pSelTab;
82819 ** SQLITE_MASTER table. We just need to update that slot with all
82838 /* Check to see if we need to create an sqlite_sequence table for
82846 "CREATE TABLE %Q.sqlite_sequence(name,seq)",
82859 /* Add the table to the in-memory representation of the database.
82862 Table *pOld;
82903 Table *p;
82960 /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */
82968 ** The Table structure pTable is really a VIEW. Fill in the names of
82972 SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
82973 Table *pSelTab; /* A fake table from which we get the result set */
83006 ** CREATE TABLE main.ex1(a);
83016 /* If we get this far, it means we need to compute the table names.
83072 Table *pTab = sqliteHashData(i);
83087 ** used by SQLite when the btree layer moves a table root page. The
83088 ** root-page of a table or index in database iDb has changed from iFrom
83091 ** Ticket #1728: The symbol table might still contain information
83094 ** have the same rootpage number as the real table or index that is
83097 ** or tables and not the table/index that is actually being moved.
83112 Table *pTab = sqliteHashData(pElem);
83128 ** Write code to erase the table with root-page iTable from database iDb.
83129 ** Also write code to modify the sqlite_master table and internal schema
83130 ** if a root-page of another table is moved by the btree-layer whilst
83140 ** is non-zero, then it is the root page number of a table moved to
83141 ** location iTable. The following code modifies the sqlite_master table to
83156 ** Write VDBE code to erase table pTab and all associated indices on disk.
83158 ** in case a root-page belonging to another table is moved by the btree layer
83161 static void destroyTable(Parse *pParse, Table *pTab){
83172 ** table and index root-pages in order, starting with the numerically
83216 ** after a DROP INDEX or DROP TABLE command.
83222 const char *zName /* Name of index or table */
83239 ** Generate code to drop a table.
83241 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
83257 /* Drop all triggers associated with the table being dropped. Code
83270 /* Remove any entries of the sqlite_sequence table associated with
83271 ** the table being dropped. This is done before the table is dropped
83272 ** at the btree level, in case the sqlite_sequence table needs to
83283 /* Drop all SQLITE_MASTER table and index entries that refer to the
83284 ** table. The program name loops through the master table and deletes
83285 ** every row that refers to a table of the same name as the one being
83287 ** created in the temp database that refers to a table in another
83297 /* Remove the table entry from SQLite's internal schema and modify
83309 ** This routine is called to do the work of a DROP TABLE statement.
83310 ** pName is the name of the table to be dropped.
83313 Table *pTab;
83335 /* If pTab is a virtual table, call ViewGetColumnNames() to ensure
83378 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
83383 /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used
83384 ** on a table.
83387 sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);
83396 /* Generate code to remove the table from the master table
83412 ** This routine is called to create a new foreign key on the table
83414 ** in the current table point to the foreign key. If pFromCol==0 then
83416 ** the table referred to. pToCol is a list of tables in the other
83417 ** pTo table that the foreign key points to. flags contains all
83421 ** An FKey structure is created and added to the table currently
83429 ExprList *pFromCol, /* Columns in this table that point to other table */
83430 Token *pTo, /* Name of the other table */
83431 ExprList *pToCol, /* Columns in the other table */
83438 Table *p = pParse->pNewTable;
83451 " should reference only one column of table %T",
83459 "columns in the referenced table");
83529 /* Link the foreign key to the table as the last step.
83550 Table *pTab;
83570 Table *pTab = pIndex->pTable; /* The table that is indexed */
83593 /* Require a write-lock on the table to perform this operation */
83619 /* Open the table. Loop through all rows of the table, inserting index
83679 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
83680 ** and pTblList is the name of the table that is to be indexed. Both will
83683 ** as the table to be indexed. pParse->pNewTable is a table that is
83684 ** currently being constructed by a CREATE TABLE statement.
83688 ** to the table currently under construction.
83698 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
83707 Table *pTab = 0; /* Table to be indexed */
83716 Db *pDb; /* The specific table containing the indexed database */
83734 ** Find the table that is to be indexed. Return early if not found.
83739 ** to search for the table. 'Fix' the table name to this db
83740 ** before looking up the table.
83748 /* If the index name was unqualified, check if the the table
83749 ** is a temp table. If so, set the database to 1. Do not do this
83784 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
83802 ** index or table with the same name.
83805 ** sqlite_master table (because some other process changed the schema) and
83806 ** one of the index names collides with the name of a temporary table or
83822 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
83862 ** key out of the last column added to the table under construction.
83932 /* Scan the names of the columns of the table to be indexed and
83952 sqlite3ErrorMsg(pParse, "table %s has no column named %s",
83993 ** CREATE TABLE t(x PRIMARY KEY, y);
83994 ** CREATE TABLE t(x, y, UNIQUE(x, y));
83996 ** Either way, check to see if the table already has such an index. If
84028 ** constraint specified somewhere in the CREATE TABLE statement.
84047 /* Link the new Index structure to its table and to the other
84068 ** involves writing the index into the master table and filling in the
84069 ** index with the current table contents.
84073 ** CREATE INDEX statements are read out of the master table. In
84078 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
84136 /* When adding an index to the list of indices for a table, make
84177 ** number of rows in the table that match any particular value of the
84243 Table *pTab = pIndex->pTable;
84256 /* Generate code to remove the index and from the master table */
84435 ** Append a new table name to the given SrcList. Create a new SrcList if
84443 ** If pDatabase is not null, it means that the table has an optional
84444 ** database name prefix. Like this: "database.table". The pDatabase
84445 ** points to the table name and the pTable points to the database name.
84446 ** The SrcList.a[].zName field is filled with the table name which might
84455 ** Then B is a table name and the database name is unspecified. If called
84460 ** Then C is the table name and B is the database name. If C is defined
84471 Token *pTable, /* Table to append */
84472 Token *pDatabase /* Database of the table */
84543 ** are the name of the table and database named in the FROM clause term.
84557 Token *pTable, /* Name of the table to add to the FROM clause */
84560 Select *pSubquery, /* A subquery used in place of a table name */
84839 ** inserting multiple rows in a table, or inserting a row and index entries.)
84906 static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
84930 Table *pTab; /* A table in the database */
84936 pTab = (Table*)sqliteHashData(k);
84954 ** indices associated with the named table.
84959 char *z; /* Name of a table or index */
84961 Table *pTab; /* A table in the database */
84965 Token *pObjName; /* Name of the table or index to be reindexed */
85185 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
85189 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
85222 ** to the hash table).
85314 FuncDefHash *pHash, /* Hash table to search */
85329 ** Insert a new FuncDef into a FuncDefHash hash table.
85332 FuncDefHash *pHash, /* The hash table into which to insert */
85430 ** new entry to the hash table and return it.
85472 Table *pTab = sqliteHashData(pElem);
85527 ** the name of a single table, as one might find in an INSERT, DELETE,
85528 ** or UPDATE statement. Look up that table in the symbol table and
85529 ** return a pointer. Set an error message and return NULL if the table
85534 ** pSrc->a[0].pTab Pointer to the Table object
85538 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
85540 Table *pTab;
85555 ** Check to make sure the given table is writable. If it is not
85559 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
85560 /* A table is not writable under the following circumstances:
85562 ** 1) It is a virtual table and no implementation of the xUpdate method
85564 ** 2) It is a system table (i.e. sqlite_master), this call is not
85576 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
85592 ** Evaluate a view and store its result in an ephemeral table. The
85594 ** set of rows in the view that are to be added to the ephemeral table.
85598 Table *pView, /* View definition */
85600 int iCur /* Cursor number for ephemerial table */
85731 SrcList *pTabList, /* The table from which we should delete things */
85735 Table *pTab; /* The table from which records will be deleted */
85740 Index *pIdx; /* For looping over indices of the table */
85751 Trigger *pTrigger; /* List of table triggers, if required */
85761 /* Locate the table which we want to delete. This table has to be
85764 ** an SrcList* parameter instead of just a Table* parameter.
85769 /* Figure out if we have any triggers and if the table being
85803 /* Assign cursor number to the table
85827 ** a ephemeral table.
85854 ** It is easier just to erase the whole table. Prior to version 3.6.5,
85870 ** the table and pick which records to delete.
85896 /* Unless this is a view, open cursors for the table we are
85925 /* Close the cursors open on the table and its indexes. */
85934 /* Update the sqlite_sequence table by storing the content of the
85970 ** single table to be deleted.
85975 ** 1. A read/write cursor pointing to pTab, the table containing the row
85984 ** This routine generates code to remove both the table record and all
85989 Table *pTab, /* Table containing the row to be deleted */
85990 int iCur, /* Cursor number for the table */
86024 /* Populate the OLD.* pseudo-table register array. These values will be
86045 ** refer to this table (i.e. constraints attached to other tables)
86050 /* Delete the index and table entries. Skip this step if pTab is really
86079 ** index entries associated with a single row of a single table.
86084 ** 1. A read/write cursor pointing to pTab, the table containing the row
86095 Table *pTab, /* Table containing the row to be deleted */
86096 int iCur, /* Cursor number for the table */
86113 ** iCur is the index of a cursor open on the pTab table and pointing to
86124 int iCur, /* Cursor number for the pIdx->pTable table */
86130 Table *pTab = pIdx->pTable;
87677 ** to the global function hash table. This occurs at start-time (as
87828 ** I.1) For each FK for which the table is the child table, search
87829 ** the parent table for a match. If none is found increment the
87832 ** I.2) For each FK for which the table is the parent table,
87833 ** search the child table for rows that correspond to the new
87834 ** row in the parent table. Decrement the counter for each row
87839 table is the child table,
87840 ** search the parent table for a row that corresponds to the
87841 ** deleted row in the child table. If such a row is not found,
87844 ** D.2) For each FK for which the table is the parent table, search
87845 ** the child table for rows that correspond to the deleted row
87846 ** in the parent table. For each found increment the counter.
87873 ** TODO: How should dropping a table be handled? How should renaming a
87874 ** table be handled?
87909 ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);
87920 ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
87921 ** Given that pParent is the parent table for foreign key constraint pFKey,
87932 ** array is the index of the child table column that is mapped by the FK
87933 ** constraint to the parent table column stored in the left-most column
87935 ** child table column that corresponds to the second left-most column of
87946 ** foreign key definition, and the parent table does not have a
87950 ** foreign key definition, and the PRIMARY KEY of the parent table
87952 ** the child table.
87960 Table *pParent, /* Parent table of FK constraint pFKey */
87962 Index **ppIdx, /* OUT: Unique index on parent table */
87976 ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
87987 ** mapped to the primary key of table pParent, or
88010 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
88021 ** map to an explicit list of columns in table pParent. Check if this
88067 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
88068 ** on the child table of pFKey, this function is invoked twice for each row
88073 ** row in the parent table that corresponds to the row being inserted into
88074 ** or deleted from the child table. If the parent row can be found, no
88076 ** found in the parent table:
88094 Table *pTab, /* Parent table of FK pFKey */
88097 int *aiCol, /* Map from parent key columns to child table columns */
88098 int regData, /* Address of array containing child table row */
88111 ** Check if any of the key columns in the child table row are NULL. If
88113 ** search for a matching row in the parent table. */
88125 ** column of the parent table (table pTab). */
88137 /* If the parent table is the same as the child table, and we are about
88163 /* If the parent table is the same as the child table, and we are about
88200 ** one row into the table, raise a constraint immediately instead of
88220 ** from the parent table of foreign key constraint pFKey and, if pFKey is
88221 ** deferred, when a row is inserted into the same table. When generating
88226 ** table that correspond to the parent table row being deleted or inserted.
88248 SrcList *pSrc, /* SrcList containing the table to scan */
88249 Table *pTab,
88252 int *aiCol, /* Map from pIdx cols to child table cols */
88253 int regData, /* Referenced table data starts here */
88279 Expr *pLeft; /* Value from parent table row */
88280 Expr *pRight; /* Column ref to child table */
88282 int iCol; /* Index of column in child table */
88283 const char *zCol; /* Name of column in child table */
88310 /* If the child table is the same as the parent table, and this scan
88316 Expr *pLeft; /* Value from parent table row */
88317 Expr *pRight; /* Column ref to child table */
88358 ** constraints for which table pTab is the parent table. For example,
88361 ** CREATE TABLE t1(a PRIMARY KEY);
88362 ** CREATE TABLE t2(b REFERENCES t1(a);
88364 ** Calling this function with table "t1" as an argument returns a pointer
88365 ** to the FKey structure representing the foreign key constraint on table
88368 ** table).
88370 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){
88395 ** This function is called to generate code that runs when table pTab is
88398 ** table pTab.
88402 ** (a) The table is the parent table of a FK constraint, or
88403 ** (b) The table is the child table of a deferred FK constraint and it is
88408 ** the table from the database. Triggers are disabled while running this
88411 SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
88419 /* Search for a deferred foreign key constraint for which this table
88420 ** is the child table. If one cannot be found, return without
88454 ** table pTab to generate VDBE code to perform foreign key constraint
88468 ** the original record is deleted from the table using the calling convention
88474 Table *pTab, /* Row is being deleted from this table */
88494 ** child table (the table that the foreign key definition is part of). */
88496 Table *pTo; /* Parent table of foreign key pFKey */
88504 /* Find the parent table of this foreign key. Also find a unique index
88505 ** on the parent key columns in the parent table. If either of these
88517 /* If isIgnoreErrors is true, then a table is being dropped. In this
88518 ** case SQLite runs a "DELETE FROM xxx" on the table being dropped
88520 ** If the parent table of an FK constraint on the current table is
88522 ** FK counter for each row of the current table with non-NULL keys.
88549 ** values read from the parent table are NULL. */
88559 /* Take a shared-cache advisory read-lock on the parent table. Allocate
88561 ** in the parent table. */
88566 /* A row is being removed from the child table. Search for the parent.
88572 /* A row is being added to the child table. If a parent row cannot
88580 /* Loop through all the foreign key constraints that refer to this table */
88588 /* Inserting a single row into a parent table cannot cause an immediate
88599 /* Create a SrcList structure containing a single table (the table
88600 ** the foreign key that refers to this table is attached to). This
88615 ** on the parent table of this FK, then throw an exception
88633 ** row contained in table pTab.
88637 Table *pTab /* Table being modified */
88659 ** row contained in table pTab. If the operation is a DELETE, then
88661 ** to an array of size N, where N is the number of columns in table pTab.
88665 ** UPDATE statement modifies the rowid fields of the table.
88673 Table *pTab, /* Table being modified */
88680 ** table in question is either the child or parent table for any
88719 ** compiled on table pTab, which is the parent table of foreign-key pFKey.
88730 ** For example, if pFKey is the foreign key and pTab is table "p" in
88733 ** CREATE TABLE p(pk PRIMARY KEY);
88734 ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);
88748 Table *pTab, /* Table being updated or deleted from */
88762 char const *zFrom; /* Name of child table */
88765 int *aiCol = 0; /* child table cols -> parent key cols */
88779 Token tFromCol; /* Name of column in child table */
88780 Token tToCol; /* Name of column in parent table */
88781 int iFromCol; /* Idx of column in child table */
88795 ** parent table are used for the comparison. */
88934 Table *pTab, /* Table being updated or deleted from */
88939 ** refer to table pTab. If there is an action associated with the FK
88957 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
88958 ** hash table.
88960 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
88967 /* Remove the FK from the fkeyHash hash table. */
89016 ** Generate code that will open a table for reading.
89020 int iCur, /* The cursor number of the table */
89022 Table *pTab, /* The table to be opened */
89038 ** the table, according to the affinity of the column:
89066 Table *pTab = pIdx->pTable;
89085 ** string for table pTab. A column affinity string has one character
89097 SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){
89098 /* The first time a column affinity string for a particular table
89100 ** stored as a member of the Table structure for subsequent use.
89103 ** sqlite3DeleteTable() when the Table structure itself is cleaned up.
89128 ** Return non-zero if the table pTab in database iDb or any of its indices
89132 ** run without using temporary table for the results of the SELECT.
89134 static int readsTable(Parse *p, int iStartAddr, int iDb, Table *pTab){
89170 ** Locate or create an AutoincInfo structure associated with table pTab
89174 ** There is at most one AutoincInfo structure per table even if the
89175 ** same table is autoincremented multiple times due to inserts within
89177 ** first use of table pTab. On 2nd and subsequent uses, the original
89182 ** (1) Register to hold the name of the pTab table.
89192 Table *pTab /* The table we are writing to */
89208 pToplevel->nMem++; /* Register to hold name of table */
89224 Db *pDb; /* Database only autoinc table */
89274 ** table (either directly or through triggers) needs to call this
89324 Table *pDest, /* The table we are inserting into */
89333 ** insert into TABLE (IDLIST) values(EXPRLIST)
89334 ** insert into TABLE (IDLIST) select
89336 ** The IDLIST following the table name is always optional. If omitted,
89337 ** then a list of all columns for the table is substituted. The IDLIST
89350 ** open write cursor to <table> and its indices
89352 ** write the resulting record into <table>
89357 ** INSERT INTO <table> SELECT ...
89360 ** in other words if the SELECT pulls all columns from a single table
89368 ** open a write cursor to <table>
89370 ** transfer all records in <table2> over to <table>
89372 ** foreach index on <table>
89373 ** open a write cursor on the <table> index
89380 ** and the SELECT clause does not read from <table> at any time.
89395 ** B: open write cursor to <table> and its indices
89398 ** insert the select result into <table> from R..R+n
89403 ** values from a SELECT but the data is being inserted into a table
89405 ** we have to use a intermediate table to store the results of
89420 ** B: open temp table
89423 ** insert row from R..R+n into temp table
89425 ** M: open write cursor to <table> and its indices
89426 ** rewind temp table
89427 ** C: loop over rows of intermediate table
89428 ** transfer values form intermediate table into <table>
89434 SrcList *pTabList, /* Name of table into which we are inserting */
89441 Table *pTab; /* The table to insert into. aka TABLE */
89442 char *zTab; /* Name of the table into which we are inserting */
89443 const char *zDb; /* Name of the database holding this table */
89446 Index *pIdx; /* For looping over indices of the table */
89448 int nHidden = 0; /* Number of hidden columns if TABLE is virtual */
89452 int useTempTable = 0; /* Store SELECT results in intermediate table */
89458 int iDb; /* Index of database holding TABLE */
89459 Db *pDb; /* The database containing table being inserted into */
89484 /* Locate the table into which we will be inserting new information.
89501 /* Figure out if we have any triggers and if the table being
89520 ** module table).
89527 * (a) the table is not read-only,
89558 /* If this is an AUTOINCREMENT table, look up the sequence number in the
89559 ** sqlite_sequence table and store it in memory cell regAutoinc.
89620 ** should be written into a temporary table (template 4). Set to
89622 ** the destination table (template 3).
89624 ** A temp table must be used if the table being updated is also one
89626 ** temp table in the case of row triggers.
89634 ** and add it to a transient table srcTab. The code generated
89637 ** B: open temp table
89640 ** insert row from R..R+n into temp table
89645 int regTempRowid; /* Register to hold temp table ROWID */
89681 ** of columns to be inserted into the table.
89690 "table %S has %d columns but %d values were supplied",
89700 ** all elements of the IDLIST really are columns of the table and
89703 ** If the table has an INTEGER PRIMARY KEY column and that column
89707 ** is appears in the original table. (The index of the primary
89708 ** key in the original table is pTab->iPKey.)
89728 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
89737 /* If there is no IDLIST term but the table has an integer primary
89739 ** in the original table definition.
89752 /* If this is not a view, open the table and and all indices */
89772 ** rewind temp table
89773 ** C: loop over rows of intermediate table
89774 ** transfer values form intermediate table into <table>
89786 ** insert the select result into <table> from R..R+n
89833 /* Cannot have triggers on a virtual table. If it were possible,
89860 ** If this is a real table, attempt conversions as required by the
89861 ** table column affinities.
89877 ** except when the table has an INTEGER PRIMARY KEY column, in which
90021 /* Update the sqlite_sequence table by storing the content of the
90090 ** attached to the table.
90139 Table *pTab, /* the table into which we are inserting */
90156 int iCur; /* Table cursor number */
90163 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90259 /* If there are DELETE triggers on this table and the
90261 ** remove the conflicting row from the the table. This will fire
90262 ** the triggers and remove both the table and index b-tree entries.
90265 ** flag is not set, but the table has one or more indexes, call
90267 ** only. The table b-tree entry will be replaced by the new entry
90279 ** table.
90425 Table *pTab, /* the table into which we are inserting */
90443 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90477 ** Generate code that will open cursors for a table and for all
90478 ** indices of that table. The "baseCur" parameter is the cursor number used
90479 ** for the table. Indices are opened on subsequent cursors.
90481 ** Return the number of indices on the table.
90485 Table *pTab, /* Table to be opened */
90486 int baseCur, /* Cursor number assigned to the table */
90589 ** Sometimes the xfer optimization will only work if the destination table
90592 ** does a test to see if the destination table is empty and jumps over the
90602 Table *pDest, /* The table we are inserting into */
90608 Table *pSrc; /* The table in the FROM clause of SELECT */
90631 return 0; /* tab1 must not be a virtual table */
90683 return 0; /* FROM clause does not contain a real table */
90686 return 0; /* tab1 and tab2 may not be the same table */
90690 return 0; /* tab2 must not be a virtual table */
90730 /* Disallow the transfer optimization if the destination table constains
90747 ** table (tab1) is initially empty.
90764 ** only if the destination table is initially empty. This code makes
92989 ** PRAGMA table_info(<table>)
92991 ** Return a single row for each column of the named table. The columns of
93001 Table *pTab;
93040 Table *pTab;
93064 Table *pTab;
93127 Table *pTab;
93139 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC);
93255 Table *pTab = sqliteHashData(x);
93285 Table *pTab = sqliteHashData(x);
93447 ** creating or dropping a table or index). The schema version is used by
93721 ** argv[1] = root page number for table or index. 0 for trigger or view.
93744 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
93747 ** structures that describe the table, index, or view.
93779 ** constraint for a CREATE TABLE. The index should have already
93780 ** been created when we processed the CREATE TABLE. All we have
93786 /* This can occur if there exists an index on a TEMP table which
93788 ** the permanent table is hidden by the TEMP table, we can also
93789 ** safely ignore the index on the permanent table.
93811 Table *pTab;
93821 ** The master database table has a structure like this
93824 "CREATE TABLE sqlite_master(\n"
93834 "CREATE TEMP TABLE sqlite_temp_master(\n"
93853 ** initialised. zMasterName is the name of the master table.
93966 ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN
94026 ** purpose of this is to allow access to the sqlite_master table
94174 ** expr.c is trying to resolve a reference to a transient table (i.e. one
94390 ** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error
94723 ** Return the index of a column in a table. Return -1 if the column
94724 ** is not contained in the table.
94726 static int columnIndex(Table *pTab, const char *zCol){
94736 ** table that has a column named zCol.
94738 ** When found, set *piTab and *piCol to the table index and column index
94774 ** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the
94781 int iLeft, /* Index of first table to join in pSrc */
94782 int iColLeft, /* Index of column in first table */
94783 int iRight, /* Index of second table in pSrc */
94784 int iColRight, /* Index of column in second table */
94824 ** expression depends on table iRightJoinTable even if that table is not
94854 ** The left most table is the first entry in Select.pSrc. The right-most
94855 ** table is the last entry. The join operator is held in the entry to
94865 struct SrcList_item *pLeft; /* Left table being joined */
94866 struct SrcList_item *pRight; /* Right table being joined */
94872 Table *pLeftTab = pLeft->pTab;
94873 Table *pRightTab = pRight->pTab;
94889 char *zName; /* Name of column in the right table */
94890 int iLeft; /* Matching left table */
94891 int iLeftCol; /* Matching column in the left table */
94929 int iLeft; /* Table on the left with matching column name */
95044 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
95078 int srcTab, /* Pull data from this table */
95079 int nColumn, /* Number of columns in the source table */
95145 ** table iParm.
95159 ** the temporary table iParm.
95191 ** item into the set table with bogus data.
95392 int bUseTmp /* True if a temp table was used */
95526 ** original CREATE TABLE statement if the expression is a column. The
95556 /* The expression is a column. Locate the table the column is being
95557 ** extracted from in NameContext.pSrcList. This table may be real
95558 ** database table or a subquery.
95560 Table *pTab = 0; /* Table structure column is extracted from */
95583 ** CREATE TABLE t1(col INTEGER);
95599 /* The "table" is actually a sub-select or a view in the FROM clause
95616 /* A real table */
95737 Table *pTab;
95773 ** column names for a table that would hold the expression list.
95812 Table *pTab; /* Table associated with this expression */
95911 ** Given a SELECT statement, generate a Table structure that describes
95914 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
95915 Table *pTab;
95926 pTab = sqlite3DbMallocZero(db, sizeof(Table) );
96138 /* Create the destination temporary table if necessary
96210 int unionTab; /* Cursor number of the temporary table holding result */
96221 /* We can reuse a temporary table generated by a SELECT to our
96230 /* We will need to create our own temporary table to hold the
96282 /* Convert the data in the temporary table into whatever form
96330 /* Code the SELECTs to our left into temporary table "tab1".
96339 /* Code the current SELECT into temporary table "tab2"
96527 ** item into the set table with bogus data.
97050 ** a column in table number iTable with a copy of the iColumn-th
97058 ** changes to pExpr so that it refers directly to the source table
97064 int iTable, /* Table to be substituted */
97096 int iTable, /* Table to be substituted */
97108 int iTable, /* Table to be replaced */
97142 ** subquery first and store the results in a temporary table, then
97143 ** run the outer query on that temporary table. This requires two
97144 ** passes over the data. Furthermore, because the temporary table
97155 ** exist on the table t1, a complete scan of the data might be
97178 ** table sqlite_once that consists of a single row containing a
97261 int iParent; /* VDBE cursor number of the pSub result set temp table */
97449 /* Delete the transient table structure associated with the
97460 /* Defer deleting the Table object associated with the
97468 Table *pTabToDel = pSubitem->pTab;
97659 ** where table is a database table, not a sub-select or view. If the query
97660 ** does match this pattern, then a pointer to the Table object representing
97663 static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
97664 Table *pTab;
97695 Table *pTab = pFrom->pTab;
97731 ** for instances of the "*" operator or the TABLE.* operator.
97732 ** If found, expand each "*" to be every column in every table
97733 ** and TABLE.* to be every column in TABLE.
97759 /* Look up every table named in the FROM clause of the select. If
97760 ** an entry of the FROM clause is a subquery instead of a table or view,
97761 ** then create a transient table structure to describe the subquery.
97764 Table *pTab;
97778 pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
97789 /* An ordinary table or view name in the FROM clause */
97797 /* We reach here if the named table is a really a view */
97819 ** all columns in all tables. And for every TABLE.* insert the names
97820 ** of all columns in TABLE. The parser inserted a special expression
97862 /* This expression is a "*" or a "TABLE.*" and needs to be
97864 int tableSeen = 0; /* Set to 1 when TABLE matches */
97865 char *zTName; /* text of name of TABLE */
97874 Table *pTab = pFrom->pTab;
97905 ** table to the right of the join */
97910 ** using clause from the table on the right. */
97937 sqlite3ErrorMsg(pParse, "no such table: %s", zTName);
97997 ** information to the Table structure that represents the result set
98000 ** The Table structure that represents the result set was constructed
98017 Table *pTab = pFrom->pTab;
98034 ** the Table structures of all FROM-clause subqueries in a
98055 ** * Ephemeral Table objects are created for all FROM-clause subqueries.
98057 ** * Wildcards "*" and "TABLE.*" in result sets are expanded.
98218 Table *pTab, /* Table being queried */
98222 char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s %s%s(~%d rows)",
98255 ** row of result as the key in table pDest->iParm.
98259 ** SRT_Union Store results as a key in a temporary table pDest->iParm.
98261 ** SRT_Except Remove results from the temporary table pDest->iParm.
98263 ** SRT_Table Store results in temporary table pDest->iParm.
98264 ** This is like SRT_EphemTab except that the table
98267 ** SRT_EphemTab Create an temporary table pDest->iParm and store
98271 ** the table first.
98307 int distinct; /* Table to use for the distinct set */
98393 /* Generate a subroutine that will fill an ephemeral table with
98485 ** The second form is preferred as a single index (or temp-table) may be
98487 ** written the query must use a temp-table for at least one of the ORDER
98488 ** BY and DISTINCT, and an index or separate temp-table for the other.
98518 /* If the output is destined for a temporary table, open that table.
98727 ** we do not have to sort. The OP_OpenEphemeral table will be
98891 Table *pTab;
98893 /* If isSimpleCount() returns a pointer to a Table structure, then
98898 ** where the Table structure returned represents table <tbl>.
98901 ** OP_Count instruction is executed either on the intkey table that
98902 ** contains the data for table <tbl> or on one of its indexes. It
98917 ** there is such an index, and it has less columns than the table
99152 /************** Begin file table.c *******************************************/
99191 ** This routine is called once for each row in the result table. Its job
99266 ** Instead, the entire table should be passed to sqlite3_free_table() when
99272 char ***pazResult, /* Write the result table here */
99350 /************** End of table.c ***********************************************/
99384 ** Given table pTab, return a list of all the triggers attached to
99385 ** the table. The list is connected by Trigger.pNext pointers.
99397 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
99411 && 0==sqlite3StrICmp(pTrig->table, pTab->zName)
99437 SrcList *pTableName,/* The name of the table/view the trigger applies to */
99443 Table *pTab; /* Table that the trigger fires off of */
99487 /* If the trigger name was unqualified, and the table is a temp table,
99489 ** If sqlite3SrcListLookup() returns 0, indicating the table does not
99498 /* Ensure the table name matches database name and that the table exists */
99507 /* The table does not exist. */
99510 ** Normally, whenever a table is dropped, all associated triggers are
99511 ** dropped too. But if a TEMP trigger is created on a non-TEMP table
99512 ** and the table is dropped by a different database connection, the
99515 ** "orphaned trigger" - a trigger whose associated table is missing.
99544 /* Do not create a trigger on a system table */
99546 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
99561 " trigger on table: %S", pTableName, 0);
99595 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
99656 /* Make an entry in the sqlite_master table */
99664 pTrig->table, z);
99679 Table *pTab;
99680 int n = sqlite3Strlen30(pLink->table);
99681 pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table, n);
99746 Token *pTableName, /* Name of the table into which we insert */
99779 Token *pTableName, /* Name of the table to be updated */
99804 Token *pTableName, /* The table from which rows are deleted */
99825 sqlite3DbFree(db, pTrigger->table);
99880 ** Return a pointer to the Table structure for the table that a trigger
99883 static Table *tableOfTrigger(Trigger *pTrigger){
99884 int n = sqlite3Strlen30(pTrigger->table);
99885 return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n);
99893 Table *pTable;
99959 Table *pTab = tableOfTrigger(pTrigger);
99988 ** Return a list of all triggers on table pTab if there exists at least
99990 ** performed on the table, and, if that operation is an UPDATE, if at
99995 Table *pTab, /* The table the contains the triggers */
100167 Table *pTab, /* The table pTrigger is attached to */
100280 Table *pTab, /* The table trigger pTrigger is attached to */
100307 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
100314 Table *pTab, /* The table to code triggers from */
100345 ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
100355 ** in the trigger program. If N is the number of columns in table pTab
100385 Trigger *pTrigger, /* List of triggers on table pTab */
100389 Table *pTab, /* The table to code triggers from */
100402 /* Sanity checking: The schema for the trigger and for the table are
100403 ** always defined. The trigger must be in the same schema as the table
100421 ** Triggers may access values stored in the old.* or new.* pseudo-table.
100428 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
100430 ** are more than 32 columns in the table, and at least one of the columns
100437 ** applies to the old.* table. If 1, the new.* table.
100447 Trigger *pTrigger, /* List of triggers on table pTab */
100451 Table *pTab, /* The table to code triggers from */
100497 SrcList *pSrc, /* The virtual table to be modified */
100498 Table *pTab, /* The virtual table */
100509 ** i-th column of table pTab. This routine sets the P4 parameter of the
100513 ** column definition. This was either supplied by the user when the table
100514 ** was created, or added later to the table definition by an ALTER TABLE
100515 ** command. If the latter, then the row-records in the table btree on disk
100521 ** Column definitions created by an ALTER TABLE command may only have
100524 ** when the ALTER TABLE is executed and one of the literal values written
100525 ** into the sqlite_master table.)
100537 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
100567 SrcList *pTabList, /* The table in which we should change things */
100573 Table *pTab; /* The table to be updated */
100583 ** an expression for the i-th column of the table.
100590 int iDb; /* Database containing the table being updated */
100605 int regNew; /* Content of the NEW.* table in triggers */
100606 int regOld = 0; /* Content of OLD.* table in triggers */
100616 /* Locate the table which we want to update.
100622 /* Figure out if we have any triggers and if the table being
100649 /* Allocate a cursors for the main database table and for all indices.
100712 ** array for each index associated with table being updated. Fill in
100773 ** a ephemeral table.
100869 /* If there are triggers on this table, populate an array of registers
100890 ** table and index records, and as the values for any new.* references
101017 /* Update the sqlite_sequence table by storing the content of the
101057 ** Generate code for an UPDATE of a virtual table.
101059 ** The strategy is that we create an ephemerial table that contains
101066 ** Then we loop over this ephemeral table and for each row in
101067 ** the ephermeral table call VUpdate.
101069 ** When finished, drop the ephemeral table.
101073 ** it out of the ephemeral table before calling VUpdate.
101077 SrcList *pSrc, /* The virtual table to be modified */
101078 Table *pTab, /* The virtual table */
101089 int ephemTab; /* Table holding the result of the SELECT */
101116 /* Create the ephemeral table into which the update results will
101124 /* fill the ephemeral table
101129 /* Generate code to scan the ephemeral table and call VUpdate. */
101364 "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) "
101365 " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'"
101386 "WHERE type = 'table' AND name!='sqlite_sequence' "
101391 /* Copy over the sequence table
101409 ** from the SQLITE_MASTER table.
101416 " OR (type='table' AND rootpage=0)"
101517 ** Before a virtual table xCreate() or xConnect() method is invoked, the
101524 Table *pTab;
101573 ** External API function used to create a new virtual-table module.
101585 ** External API function used to create a new virtual-table module.
101598 ** Lock the virtual table so that it cannot be disconnected.
101602 ** If a disconnect is attempted while a virtual table is locked,
101611 ** pTab is a pointer to a Table structure representing a virtual-table.
101613 ** this virtual-table, if one has been created, or NULL otherwise.
101615 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
101623 ** Decrement the ref-count on a virtual table object. When the ref-count
101644 ** Table p is a virtual table. This function moves all elements in the
101650 static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
101656 ** that contains table p is held by the caller. See header comments
101684 ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
101696 ** associated with the database the virtual table is stored in is held
101697 ** or, if the virtual table is stored in a non-sharable database, then
101721 ** Clear any and all virtual-table information from the Table record.
101722 ** This routine is called, for example, just before deleting the Table
101725 ** Since it is a virtual-table, the Table structure contains a pointer
101734 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
101748 ** string will be freed automatically when the table is
101751 static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
101772 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
101778 Token *pName1, /* Name of new table, or database name */
101779 Token *pName2, /* Name of new table or NULL */
101780 Token *pModuleName, /* Name of the module for the virtual table */
101781 int ifNotExists /* No error if the table already exists */
101783 table is being created in */
101784 Table *pTable; /* The new virtual table */
101804 /* Creating a virtual table invokes the authorization callback twice.
101806 ** sqlite_master table, has already been made by sqlite3StartTable().
101807 ** The second call, to obtain permission to create the table, is made now.
101819 ** virtual table currently under construction in pParse->pTable.
101831 ** The parser calls this routine after the CREATE VIRTUAL TABLE statement
101835 Table *pTab = pParse->pNewTable; /* The table being constructed */
101843 /* If the CREATE VIRTUAL TABLE statement is being entered for the
101844 ** first time (in other words if the virtual table is actually being
101847 ** in the sqlite_master table.
101855 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
101859 zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
101862 ** SQLITE_MASTER table. We just need to update that slot with all
101866 ** entry in the sqlite_master table tht was created for this vtab
101872 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
101885 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
101891 /* If we are rereading the sqlite_master table create the in-memory
101892 ** record of the table. The xConnect() method is not called until
101893 ** the first time the virtual table is used in an SQL statement. This
101895 ** the required virtual table implementations are registered. */
101897 Table *pOld;
101914 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
101924 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
101938 ** Invoke a virtual table constructor (either xCreate or xConnect). The
101944 Table *pTab,
101969 /* Invoke the virtual table constructor */
102001 ** columns of the table to see if any of them contain the token "hidden".
102045 ** of the virtual table pTab. If an error occurs, an error code is returned
102048 ** This call is a no-op if table pTab is not a virtual table.
102050 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
102061 /* Locate the required virtual table module */
102082 ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.
102103 ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should
102114 ** of the virtual table named zTab in database iDb.
102122 Table *pTab;
102129 /* Locate the required virtual table module */
102157 ** This function is used to set the schema of a virtual table. It is only
102159 ** virtual table module.
102165 Table *pTab;
102219 ** of the virtual table named zTab in database iDb. This occurs
102220 ** when a DROP TABLE is mentioned.
102222 ** This call is a no-op if zTab is not a virtual table.
102226 Table *pTab;
102322 ** If the virtual table pVtab supports the transaction interface
102372 ** as the second argument to the virtual table method invoked.
102376 ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
102379 ** If any virtual table method returns an error code other than SQLITE_OK,
102381 ** function immediately. If all calls to virtual table methods are successful,
102420 ** If pExpr is a column in a virtual table, then let the virtual
102421 ** table implementation have an opportunity to overload the function.
102423 ** This routine is used to allow virtual table implementations to
102436 Table *pTab;
102447 /* Check to see the left operand is a column in a virtual table */
102459 /* Call the xFindFunction method on the virtual table implementation
102491 ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
102496 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
102499 Table **apVtabLock;
102517 ** table update operation currently in progress.
102535 ** of the virtual table being implemented.
102583 ** generating the code that loops through a table looking for applicable
102709 WhereMaskSet *pMaskSet; /* Mapping of table cursor numbers to bitmasks */
102710 Bitmask vmask; /* Bitmask identifying virtual table cursors */
102809 ** But if the table is the right table of a left join, WhereLevel.wsFlags
102812 ** ISNULL constraints will then not be used on the right table of a left
102822 #define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */
102827 #define WHERE_IDX_ONLY 0x00800000 /* Use index only - omit table */
102831 #define WHERE_VIRTUALTABLE 0x08000000 /* Use virtual-table processing */
102842 WhereMaskSet *pMaskSet, /* Mapping from table cursor numbers to bitmasks */
102996 ** There is one cursor per table in the FROM clause. The number of
103016 ** the VDBE cursor number of the table. This routine just has to
103152 ** where X is a reference to the iColumn of table iCur and <op> is one of
103386 ** a single table T (as shown in example B above) then create a new virtual
103398 ** If all subterms are indexable by a single table T, then set
103401 ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T
103404 ** "T.C <op> <expr>" where C is any column of table T and
103444 WhereMaskSet *pMaskSet = pWC->pMaskSet; /* Table use masks */
103539 ** something other than == on a column in the single table. The 1-bit
103541 ** "table.column=expr" for some single table. The one bit that is set
103542 ** will correspond to the common table. We still need to check to make
103549 ** Note that terms of the form "table.column1=table.column2" (the
103550 ** same table on both sizes of the ==) cannot be optimized.
103555 int iCursor = -1; /* Table cursor common to all terms */
103558 /* Search for a table and column that appears on one side or the
103559 ** other of the == operator in every subterm. That table and column
103561 ** such table and column. Set okToChngToIN if an appropriate table
103590 /* No candidate table+column was found. This can only occur
103599 /* We have found a candidate table and column. Check to see if that
103600 ** table and column is common to every term in the OR clause */
103694 WhereMaskSet *pMaskSet; /* Set of table index masks */
103731 ** on left table of a LEFT JOIN. Ticket #3015 */
103976 ** a reference to any table other than the iBase table.
103982 int iBase /* Ignore references to this table */
103997 ** Argument iBase is the cursor number used for the table that pIdx refers
104006 int iBase, /* Cursor for table associated with pIdx */
104045 int base, /* Cursor number for the table pIdx is on */
104059 ** same table as index pIdx, return early. Finally, if there is no
104060 ** matching "col=X" expression and the column is on the same table as pIdx,
104100 Table *pTab;
104105 /* If there is more than one table or sub-select in the FROM clause of
104112 /* If any of the expressions is an IPK column on table iBase, then return
104121 /* Loop through all indices on the table, checking each to see if it makes
104156 ** left-most table in the FROM clause of that same SELECT statement and
104157 ** the table has a cursor number of "base". pIdx is an index on pTab.
104171 WhereMaskSet *pMaskSet, /* Mapping from table cursor numbers to bitmaps */
104173 int base, /* Cursor number for the table to be sorted */
104194 ** represent the rowid index that is part of every table. */
104216 ** left-most table of the FROM clause */
104370 ** The table associated with FROM clause term pSrc may be either a
104371 ** regular B-Tree table or a virtual table.
104383 const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */
104470 struct SrcList_item *pSrc, /* Table we are trying to access */
104485 ** If the query plan for pSrc specified in pCost is a full table scan
104488 ** than a full table scan even when the cost of constructing the index
104499 double nTableRow; /* Rows in the input table */
104504 Table *pTable; /* Table tht might be indexed */
104533 /* The cost of creating the transient table would be greater than
104534 ** doing the full table scan */
104577 Table *pTable; /* The table being indexed */
104618 ** original table never needs to be accessed. Automatic indices must
104620 ** original table changes and the index and table cannot both be used
104732 ** to this virtual table */
104744 ** virtual table then allocate space for the aOrderBy part of
104816 ** The table object reference passed as the second argument to this function
104817 ** must represent a virtual table. This function invokes the xBestIndex()
104818 ** method of the virtual table with the sqlite3_index_info pointer passed
104829 static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
104854 "table %s: xBestIndex returned an invalid plan", pTab->zName);
104863 ** Compute the best index for a virtual table.
104866 ** table module. This routine is really just a wrapper that sets up
104871 ** same virtual table. The sqlite3_index_info structure is created
104874 ** code is generated to access the virtual table. The whereInfoDelete()
104888 Table *pTab = pSrc->pTab;
104934 ** table. In other words, if the constraint is of the form:
104940 ** of the table containing column.
104943 ** on the current table. That way we only have to compute it once
104982 /* If there is an ORDER BY clause, and the selected virtual table index
105414 ** Find the best query plan for accessing a particular table. Write the
105428 ** index and in the main table.
105430 ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in
105436 ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table
105451 table to be accessed */
105465 /* If the pSrc table is the right table of a LEFT JOIN then we may not
105466 ** use an index to satisfy IS NULL constraints on that table. This is
105467 ** because columns might end up being NULL if the table does not match -
105486 Index *pFirst; /* First of real indices on the table */
105497 /* The real indices of the table are only considered if the
105568 ** Boolean. True if a table lookup is required for each index entry
105570 ** This is always false for the rowid primary key index of a table.
105571 ** For other indexes, it is true unless all the columns of the table
105575 ** two queries requires table b-tree lookups in order to find the value
105683 ** using the main table (i.e. if the index is a covering
105704 ** constraint, do not let the estimate exceed half the rows in the table.
105739 ** to do a binary search to locate a row in a table or index is roughly
105741 ** a table or index. The actual times can vary, with the size of
105747 ** not give us data on the relative sizes of table and index records.
105748 ** So this computation assumes table records are about twice as big
105752 /* The cost of a full table scan is a number of move operations equal
105753 ** to the number of rows in the table.
105755 ** We add an additional 4x penalty to full table scans. This causes
105767 /* For an index lookup followed by a table lookup:
105770 ** + nRow table searches to lookup the table entry using the rowid
105782 ** nInMult table searches to find the initial entry for each range
105783 ** + nRow steps through the table
105804 /* If there are additional constraints on this table that cannot
105813 ** mask will only have one bit set - the bit for the current table.
105921 ** Find the query plan for accessing table pSrc->pTab. Write the
105924 ** both real and virtual table scans.
106100 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
106126 ** CREATE TABLE t1(a TEXT PRIMARY KEY, b);
106146 int iCur = pLevel->iTabCur; /* The cursor of the table */
106230 ** Argument pLevel describes a strategy for scanning table pTab. This
106232 ** of the subset of table rows scanned by the strategy in the form of an
106248 static char *explainIndexRange(sqlite3 *db, WhereLevel *pLevel, Table *pTab){
106283 ** record is added to the output to describe the table scan strategy in
106288 SrcList *pTabList, /* Table list this loop refers to */
106314 zMsg = sqlite3MAppendf(db, zMsg, "%s TABLE %s", zMsg, pItem->zName);
106346 zMsg = sqlite3MAppendf(db, zMsg, "%s VIRTUAL TABLE INDEX %d:%s", zMsg,
106376 int iCur; /* The VDBE cursor for the table */
106414 /* If this is the right table of a LEFT OUTER JOIN, allocate and
106415 ** initialize a memory cell that records if this table matches any
106416 ** row of the left table of the join.
106426 /* Case 0: The table is a virtual-table. Use the VFilter and VNext
106772 ** of the table column that the inequality contrains is not NULL.
106784 /* Seek the table cursor, if required */
106813 ** CREATE TABLE t1(a,b,c,d);
106849 SrcList *pOrTab; /* Shortened table list or OR-clause generation */
106868 /* Set up a new SrcList ni pOrTab containing the table being scanned
106942 /* Loop through table entries that match term pOrTerm. */
106961 ** contained one or more AND term from a notReady table. The
106962 ** terms from the notReady table could not be tested and will
106967 /* Finish the loop through table entries that match term pOrTerm. */
106987 ** scan of the entire table.
107028 ** at least one row of the right table has matched the left table.
107104 ** The basic idea is to do a nested loop, one loop for each table in
107106 ** same as a SELECT with only a single table in the FROM clause.) For
107127 ** There are Btree cursors associated with each table. t1 uses cursor
107140 ** refer to those indices, a complete table scan can be avoided and the
107174 ** If an index can be used so that the natural output order of the table
107216 ** only generate code for the first table in pTabList and assume that
107275 ** its Expr.iRightJoinTable value to find the bitmask of the right table
107276 ** of the join. Subtracting one from the right table bitmask gives a
107281 ** to virtual table cursors are set. This is used to selectively disable
107329 /* Chose the best index to use for each table in the FROM clause.
107337 ** pWInfo->a[].iTabCur The VDBE cursor for the database table
107349 Index *pIdx; /* Index for FROM table at pTabItem */
107370 ** were used as the innermost nested loop. In other words, a table
107371 ** is chosen such that the cost of running that table cannot be reduced
107379 ** not be as small as it would be if the table really were the innermost
107382 ** table really is the innermost join.
107393 ** CREATE TABLE t1(a, b);
107394 ** CREATE TABLE t2(c, d);
107397 ** The best strategy is to iterate through table t1 first. However it
107399 ** Since the cost of a linear scan through table t2 is the same
107400 ** as the cost of a linear scan through table t1, a simple greedy
107409 int doNotReorder; /* True if this table should not be reordered */
107426 WHERETRACE(("=== trying table %d with isOptimal=%d ===\n",
107452 /* Conditions under which this table becomes the best so far:
107454 ** (1) The table must not depend on other tables that have not
107457 ** (2) A full-table-scan plan cannot supercede indexed plan unless
107458 ** the full-table-scan is an "optimal" plan as defined above.
107460 ** (3) All tables have an INDEXED BY clause or this table lacks an
107461 ** INDEXED BY clause or this table uses the specific
107467 ** An indexable full-table-scan from reaching rule (3).
107482 WHERETRACE(("=== table %d is best so far"
107493 WHERETRACE(("*** Optimizer selects table %d for loop %d"
107519 /* Check that if the table scanned by this loop iteration had an
107567 Table *pTab; /* Table to open */
107568 int iDb; /* Index of database containing table/index */
107636 /* Record in the query plan information about the current table
107637 ** and the index used to access it (if any). If the table itself
107762 Table *pTab = pTabItem->pTab;
107778 ** from the index in preference to the table. Sometimes, this means
107779 ** the table need never be read from. This is a performance boost,
107780 ** as the vdbe level waits until the table is read before actually
107781 ** seeking the table cursor to the record corresponding to the current
107785 ** sqlite3WhereEnd will have created code that references the table
107787 ** that reference the table and converts them into opcodes that
107991 ** table.
108088 ** slots in the yy_action[] table.
108090 ** The action table is constructed as a single large table named yy_action[].
108097 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
108108 ** yy_action[] A single table containing all actions.
108109 ** yy_lookahead[] A table containing the lookahead for each entry in
108589 /* The next table maps tokens into fallback tokens. If a construct
108617 0, /* TABLE => nothing */
108744 ** are required. The following table supplies these names */
108750 "TABLE", "CREATE", "IF", "NOT",
108842 /* 26 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
108923 /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
109125 /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109126 /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109132 /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109528 /* The following table contains information about every rule that
109963 case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
110181 case 107: /* cmd ::= DROP TABLE ifexists fullname */
110880 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
110966 case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
110971 case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
110988 case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
111372 ** might be implemented more directly using a hand-written hash table.
111523 testcase( i==19 ); /* TABLE */
112072 /* If the pParse->declareVtab flag is set, do not delete any table
112074 ** will take responsibility for freeing the Table structure.
112089 Table *p = pParse->pZombieTab;
113199 HashElem *i; /* Hash table iterator */
113217 ** SQL statements below, as the v-table implementation may be storing
113373 /* SQLITE_LOCKED */ "database table is locked",
113383 /* SQLITE_EMPTY */ "table contains no data",
113420 int count /* Number of times table has been busy */
113578 ** to the hash table.
113718 ** Declare that a function has been overloaded by a virtual table.
114015 ** following table describes the relationship between these two values
115036 ** Return meta information about a specific column of a database table.
115043 const char *zTableName, /* Table name */
115053 Table *pTab = 0;
115071 /* Locate the table in question */
115104 ** 2. The table is not a view and the column name identified an
115136 zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName,
116002 ** the %_segments table in sorted order. This means that when the end
116066 ** The segment directory in table %_segdir stores meta-information for
116106 ** leaf nodes are written in to the %_segments table in order, this
116225 ** When an fts3 table is created, it passes any arguments passed to
116226 ** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the
116230 ** be used for the fts3 table (customized by the tokenizer clause arguments).
116252 ** TABLE statement that created the fts3 table. For example, if
116368 ** This is the header file for the generic hash-table implemenation
116370 ** hash table implementation for the full-text indexing module.
116380 /* A complete hash table is an instance of the following structure.
116391 int count; /* Number of entries in this table */
116393 int htsize; /* Number of buckets in the hash table */
116394 struct _fts3ht { /* the hash table */
116400 /* Each element in the hash table is an instance of the following
116407 Fts3HashElem *next, *prev; /* Next and previous elements in the table */
116413 ** There are 2 different modes of operation for a hash table:
116446 ** Macros for looping over all elements of a hash table. The idiom is
116464 ** Number of entries in a hash table
116482 ** Fts3Table.pendingTerms hash table. Normally, the hash table is
116486 ** segment is created and the hash table cleared immediately.
116621 const char *zName; /* virtual table name */
116622 int nColumn; /* number of named columns in virtual table */
116629 ** statements is run and reset within a single virtual table API call.
116637 u8 bHasStat; /* True if %_stat table exists */
116638 u8 bHasDocsize; /* True if %_docsize table exists */
116641 char *zSegmentsTbl; /* Name of %_segments table */
116642 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116648 ** size of the pending data, including hash table overhead, not including
116653 ** A single FTS4 table may have multiple full-text indexes. For each index
116661 Fts3Hash hPending; /* Pending terms table for this index */
116670 ** methods of the virtual table are called at appropriate times. These
116680 ** When the core wants to read from the virtual table, it creates a
116681 ** virtual table cursor (an instance of the following structure) using
116701 sqlite3_int64 nDoc; /* Documents in table */
116719 ** CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);
116728 #define FTS3_FULLSCAN_SEARCH 0 /* Linear scan of %_content table */
116729 #define FTS3_DOCID_SEARCH 1 /* Lookup by rowid on %_content table */
116788 ** where nCol is the number of columns in the queried FTS table. The array
117122 ** The xDisconnect() virtual table method.
117176 ** The xDestroy() virtual table method.
117186 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
117188 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
117189 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
117190 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
117191 fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
117202 ** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table
117221 /* Create a list of user columns for the virtual table */
117227 /* Create the whole "CREATE TABLE" statement to pass to SQLite */
117229 "CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)",
117246 ** required by the FTS3 table passed as the only argument. This is done
117250 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
117260 char *zContentCols; /* Columns of %_content table */
117262 /* Create a list of user columns for the content table */
117273 /* Create the content table */
117275 "CREATE TABLE %Q.'%q_content'(%s)",
117283 "CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);",
117287 "CREATE TABLE %Q.'%q_segdir'("
117300 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117306 "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);",
117441 ** table has the three user-defined columns "a", "b", and "c", the following
117493 ** of columns in the %_content table (one for the docid plus one for each
117498 ** bracket. For example, if zFunc is "zip" and the FTS3 table has three
117561 ** representing the indexes maintained by the current FTS table. FTS tables
117564 ** (if any) specified as part of the CREATE VIRTUAL TABLE statement.
117579 struct Fts3Index **apIndex /* OUT: Array of indexes for this table */
117615 ** This function is called when initializing an FTS4 table that uses the
117617 ** of the new FTS4 table.
117621 ** a table of that name. If found, the output variables are populated
117624 ** *pnCol: Set to the number of columns table xxx has,
117630 ** the name of the corresponding column in table xxx. The array
117635 ** If the table cannot be found, an error code is returned and the output
117642 const char *zTbl, /* Name of content table */
117662 int nCol; /* Number of table columns */
117701 ** methods of the FTS3 virtual table.
117707 ** argv[2] -> table name
117713 void *pAux, /* Hash table containing tokenizers */
117726 int nCol = 0; /* Number of columns in the FTS table */
117729 int nName; /* Bytes required to hold table name */
117732 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
117735 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
117738 int bNoDocsize = 0; /* True to omit %_docsize table */
117762 ** + Figures out the number of columns the FTSX table will have, and
117879 ** TABLE statement, use all columns from the content table.
118007 /* Declare the table schema to SQLite. */
118032 ** The xConnect() and xCreate() methods for the virtual table. All the
118037 void *pAux, /* Pointer to tokenizer hash table */
118047 void *pAux, /* Pointer to tokenizer hash table */
118062 ** 3. Linear scan of %_content table.
118070 /* By default use a full table scan. This is an expensive option,
118164 ** on the xClose method of the virtual table interface.
118185 ** (or the equivalent for a content=xxx table) and set pCsr->pStmt to
118206 ** of the %_content table that contains the last match. Return
118224 ** table is missing a row that is present in the full-text index.
118280 ** table, then there are always 20 bytes of zeroed padding following the
118376 Fts3Table *p, /* Virtual table handle */
118394 char *zBlob = 0; /* Blob read from %_segments table */
119187 Fts3Table *p, /* FTS table handle */
119270 Fts3Table *p, /* FTS3 table handle */
119286 ** made by an fts4aux module, not an FTS table. In this case calling
119344 Fts3Table *p, /* FTS3 table handle */
119381 Fts3Table *p, /* FTS virtual table handle */
119406 Fts3Cursor *pCsr, /* Virtual table cursor handle */
119472 Fts3Table *p, /* Virtual table handle */
119544 ** Advance the cursor to the next row in the %_content table that
119546 ** the next row that matches. For a full-table scan, this will be
119547 ** simply the next row in the %_content table. For a docid lookup,
119573 ** This is the xFilter interface for the virtual table. See
119574 ** the virtual table xFilter method documentation for additional
119577 ** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against
119578 ** the %_content table.
119581 ** in the %_content table.
119654 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
119655 ** statement loops through all rows of the %_content table. For a
119682 ** This is the xEof method of the virtual table. SQLite calls this
119692 ** exposes %_content.docid as the rowid for the virtual table. The
119708 ** (iCol == p->nColumn) -> Magic column with the same name as the table.
119730 /* The extra column whose name is the same as the table.
119763 sqlite3_vtab *pVtab, /* Virtual table handle */
119773 ** hash-table to the database.
119797 ** the pending-terms hash-table have already been flushed into the database
119813 ** hash-table. Any changes made to the database are reverted by SQLite.
119941 ** where 't' is the name of an FTS3 table.
119949 Fts3Table *p; /* Virtual table handle */
119995 ** virtual table.
119998 sqlite3_vtab *pVtab, /* Virtual table handle */
120031 ** Implementation of FTS3 xRename method. Rename an fts3 table.
120034 sqlite3_vtab *pVtab, /* Virtual table handle */
120035 const char *zName /* New name of table */
120041 /* As it happens, the pending terms table is always empty here. This is
120042 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
120044 ** flushes the pending terms table. But leave the (no-op) call to
120052 "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';",
120059 "ALTER TABLE %Q.'%q_docsize' RENAME TO '%q_docsize';",
120065 "ALTER TABLE %Q.'%q_stat' RENAME TO '%q_stat';",
120070 "ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';",
120074 "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';",
120083 ** Flush the contents of the pending-terms table to disk.
120111 ** Discard the contents of the pending terms table.
120152 ** allocated for the tokenizer hash table.
120204 /* Allocate and initialise the hash-table used to store tokenizers. */
120212 /* Load the built-in tokenizers into the hash table */
120230 /* Create the virtual table wrapper around the hash-table and overload
120263 /* An error has occurred. Delete the hash table and return the error code. */
120328 Fts3Table *pTab, /* FTS Table pointer */
120811 ** of data that will fit on a single leaf page of an intkey table in
120819 ** data from the %_stat table to calculate it.
120821 ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3
120822 ** varints, where nCol is the number of columns in the FTS3 table.
120824 ** the table. The following nCol varints contain the total amount of
120825 ** data stored in all rows of each column of the table, from left
120894 ** table actually contains the same data as the index. To prevent this from
121467 ** 2. After scanning the current FTS table row for the deferred tokens,
121702 ** the FTS table (considering all rows), and
121704 ** 2. For each column, the number of rows in the table for which the
121716 ** values are set to the number of documents in the table. In other
121718 ** column of each row of the table.
121842 ** Initialize API pointer table, if required.
121902 ** Schema of the terms table.
121904 #define FTS3_TERMS_SCHEMA "CREATE TABLE x(term, col, documents, occurrences)"
121920 char const *zFts3; /* Name of fts3 table */
121925 Fts3auxTable *p; /* Virtual table object to return */
121929 /* The user should specify a single argument - the name of an fts3 table. */
122428 const char **azCol; /* Array of column names for fts3 table */
123095 ** of each column in the target fts3 table, in order from left to right.
123098 ** The iDefaultCol parameter should be passed the index of the table column
123102 ** match any table column.
123107 char **azCol, /* Array of column names for fts3 table */
123168 ** Function to query the hash-table of tokenizers (see README.tokenizers).
123254 ** of a column of the fts3 table that the query expression may refer to.
123361 ** We've modified it slightly to serve as a standalone hash table
123395 /* Turn bulk memory into a hash table object by initializing the
123398 ** "pNew" is a pointer to the hash table that is to be initialized.
123401 ** determines what kind of key the hash table will use. "copyKey" is
123402 ** true if the hash table should make its own private copy of keys and
123416 /* Remove all entries from a hash table. Reclaim all memory.
123417 ** Call this routine to delete a hash table or to reset a hash table
123421 Fts3HashElem *elem; /* For looping over all elements of the table */
123510 /* Link an element into the hash table
123513 Fts3Hash *pH, /* The complete hash table */
123536 /* Resize the hash table so that it cantains "new_size" buckets.
123537 ** "new_size" must be a power of 2. The hash table might fail
123543 struct _fts3ht *new_ht; /* The new hash table */
123563 ** hash table that matches the given key. The hash for this key has
123591 /* Remove a single entry from the hash table given a pointer to that
123645 ** Attempt to locate an element of the hash table pH with a key
123656 /* Insert an element into the hash table pH. The key is pKey,nKey
123666 ** the new data is returned and the hash table is unchanged.
123669 ** element corresponding to "key" is removed from the hash table.
123672 Fts3Hash *pH, /* The hash table to insert into */
123678 int h; /* the hash of the key modulo hash table size */
124412 ** hash table. This function may be called as follows:
124423 ** the string <key-name> must already exist in the has table. Otherwise,
124428 ** to string <key-name> (after the hash-table is updated, if applicable).
124525 Fts3Hash *pHash, /* Tokenizer hash table */
124805 ** the hash table pointed to by argument pHash. The hash table must
124813 ** defined at compilation time, a temporary virtual table (see header
124818 ** of both the scalar and, if created, the virtual table.
124939 ** else we need to reindex. One solution would be a meta-table to
125145 ** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()
125285 ** or the pending-terms table being flushed), leaves are written into the
125352 Fts3Table *p, /* Virtual table handle */
125433 Fts3Table *pTab, /* FTS3 table handle */
125463 Fts3Table *pTab, /* Fts3 table handle */
125470 Fts3Table *pTab, /* Fts3 table handle */
125487 Fts3Table *p, /* The FTS3 table */
125505 ** table-lock on the %_content table. This is required before reading
125506 ** data from the fts3 table. If this lock is not acquired first, then
125508 ** tables, but no read-lock on the %_content table. If this happens
125509 ** a second connection will be able to write to the fts3 table, but
125520 ** This reasoning does not apply to a content=xxx table.
125549 ** in the %_segdir table on disk. This function is used to convert three
125551 ** can be used to query the %_segdir table.
125581 ** all rows in the %_segdir table, from oldest to newest. If successful,
125586 ** each FTS3 table.
125588 ** The statement returns the following columns from the %_segdir table:
125597 Fts3Table *p, /* FTS3 table */
125753 Fts3Hash *pHash, /* Pending terms hash table to add entry to */
125782 ** pending-terms hash-table. The docid used is that currently stored in
125788 Fts3Table *p, /* Table into which text will be inserted */
125812 ** zText==0. In this case, add zero token entries to the hash table and
125866 Fts3Table *p, /* Full-text table handle */
125910 ** pendingTerms hash table.
125943 ** apVal[p->nColumn+2] Hidden column with same name as table
125948 Fts3Table *p, /* Full-text table */
125968 ** table. The SQL for this statement is:
125973 ** defined columns in the FTS3 table, plus one for the docid field.
126018 ** Remove all data from the FTS3 table. Clear the hash table containing
126024 /* Discard the contents of the pending-terms hash table. */
126058 Fts3Table *p, /* The FTS table to delete from */
126097 ** This function allocates a new level iLevel index in the segdir table.
126155 ** The %_segments table is declared as follows:
126157 ** CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)
126159 ** This function reads data from a single row of the %_segments table. The
126163 ** identified table row is. Whether or not paBlob is NULL, *pnBlob is set
126166 ** If an error occurs, or the table does not contain the specified row,
126177 ** on the database file for longer than necessary). Thus, any virtual table
126182 Fts3Table *p, /* FTS3 table handle */
126446 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
126618 ** the contents of the pending-terms hash table to the database.
126639 ** through each term in the pending-terms table. Or, if isPrefixIter is
126641 ** the pending terms hash table contains the terms "sqlite", "mysql" and
126654 Fts3Table *p, /* Virtual table handle */
126871 ** Insert a record into the %_segments table.
126874 Fts3Table *p, /* Virtual table handle */
126891 ** Insert a record into the %_segdir table.
126894 Fts3Table *p, /* Virtual table handle */
126943 Fts3Table *p, /* Virtual table handle */
127080 Fts3Table *p, /* Virtual table handle */
127149 Fts3Table *p, /* Virtual table handle */
127178 /* Find the next free blockid in the %_segments table */
127287 Fts3Table *p, /* Virtual table handle */
127310 /* The entire tree fits on the root node. Write it to the segdir table. */
127334 ** pRowid would mean the FTS3 table were empty.
127336 ** If successful, *pisEmpty is set to true if the table is empty except for
127344 /* If using the content=xxx option, assume the table is never empty */
127363 ** Segment levels are stored in the 'level' column of the %_segdir table.
127410 Fts3Table *p, /* Virtual table handle */
127529 Fts3Table *p, /* Virtual table handle */
127597 Fts3Table *p, /* Virtual table handle */
127629 Fts3Table *p, /* Virtual table handle */
127638 Fts3Table *p, /* Virtual table handle */
127713 Fts3Table *p, /* Virtual table handle */
128055 Fts3Table *p, /* Table into which to insert */
128083 ** Record 0 of the %_stat table contains a blob consisting of N varints,
128084 ** where N is the number of user defined columns in the fts3 table plus
128088 ** Varint 0: Total number of rows in the table.
128091 ** the column for all rows of the table.
128094 ** columns of all rows of the table.
128099 Fts3Table *p, /* Table being updated */
128200 ** The entire FTS index is discarded and rebuilt. If the table is one
128202 ** the current contents of the xxx table. Otherwise, it is rebuilt based
128203 ** on the contents of the %_content table.
128216 /* Compose and prepare an SQL statement to loop through the content table */
128343 ** table, not for all rows.
128348 int i; /* Used to iterate through table columns */
128427 Fts3Cursor *pCsr, /* Fts3 table cursor */
128450 ** present in the FTS3 table. If it is, delete it and adjust the contents
128463 /* Deleting this row means the whole table is empty. In this case
128465 ** data in the pendingTerms hash table. */
128487 ** tables. The schema of the virtual table being:
128489 ** CREATE TABLE <table name>(
128491 ** <table name> HIDDEN,
128571 ** the %_content table. If we hit the duplicate rowid constraint (or any
128633 ** Flush any data in the pending-terms hash table to disk. If successful,
128744 int nCol; /* Number of columns in table */
129190 Fts3Table *pTab, /* FTS3 table snippet comes from */
129399 ** rows of the table. Y is the number of rows for which column iCol contains
129693 sqlite3_int64 nDoc; /* Number of rows in table */
129882 /* Loop through all columns of the table being considered for snippets.
129884 ** columns of the FTS3 table. Otherwise, only column iCol is considered.
129942 int iCol; /* Column of table to populate aTerm for */
130014 /* Loop through the table columns, appending offset information to
130119 Fts3Cursor *pCsr, /* FTS3 table cursor */
130174 ** algorithms packaged as an SQLite virtual table module.
130181 ** The data structure for a single virtual r-tree table is stored in three
130183 ** in the table name is replaced with the user-supplied name of the r-tree
130184 ** table.
130186 ** CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
130187 ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
130188 ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
130191 ** table. For each node that is not the root node of the r-tree, there is
130192 ** an entry in the %_parent table associating the node with its parent.
130193 ** And for each row of data in the table, there is an entry in the %_rowid
130194 ** table that maps from the entries rowid to the id of the node that it
130197 ** The root node of an r-tree always exists, even if the r-tree table is
130199 ** table must be the same size as the root node. The content of each node
130293 /* Size of hash table Rtree.aHash. This hash table is not expected to
130300 ** An rtree virtual-table object.
130305 int iNodeSize; /* Size in bytes of each node in the node table */
130309 char *zDb; /* Name of database containing r-tree table */
130310 char *zName; /* Name of r-tree table */
130311 RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */
130556 ** in the Rtree.aHash table.
130566 ** Search the node hash table for node iNode. If found, return a pointer
130576 ** Add node pNode to the node hash table.
130587 ** Remove node pNode from the node hash table.
130633 /* Check if the requested node is already in the hash table. If so,
130864 ** the virtual table module xCreate() and xConnect() methods.
130871 ** Rtree virtual table module xCreate method.
130884 ** Rtree virtual table module xConnect method.
130924 ** Rtree virtual table module xDisconnect method.
130932 ** Rtree virtual table module xDestroy method.
130938 "DROP TABLE '%q'.'%q_node';"
130939 "DROP TABLE '%q'.'%q_rowid';"
130940 "DROP TABLE '%q'.'%q_parent';",
130959 ** Rtree virtual table module xOpen method.
130996 ** Rtree virtual table module xClose method.
131009 ** Rtree virtual table module xEof method.
131241 ** Rtree virtual table module xNext method.
131286 ** Rtree virtual table module xRowid method.
131299 ** Rtree virtual table module xColumn method.
131325 ** return SQLITE_OK. If there is no such record in the table, set
131390 ** Rtree virtual table module xFilter method.
131481 ** Rtree virtual table module xBestIndex method. There are three
131482 ** table scan strategies to choose from (in order from most to
131488 ** 2 See below R-tree query or full-table scan.
131716 Rtree *pRtree, /* Rtree table */
131813 Rtree *pRtree, /* Rtree table */
131839 ** Write mapping (iRowid->iNode) to the <rtree>_rowid table.
131849 ** Write mapping (iNode->iPar) to the <rtree>_parent table.
132541 /* Remove the node from the in-memory hash table and link it into
132825 /* Delete the corresponding entry in the <rtree>_rowid table. */
132893 /* Constraint handling. A write operation on an r-tree table may return
132930 ** the table. If so, the constraint has failed. */
132954 ** record to delete from the r-tree table. The following block does
133001 "ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";"
133002 "ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";"
133003 "ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";"
133017 rtreeCreate, /* xCreate - create a table */
133018 rtreeConnect, /* xConnect - connect to an existing table */
133020 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
133021 rtreeDestroy, /* xDestroy - Drop a table */
133035 rtreeRename, /* xRename - rename the table */
133052 /* Read and write the xxx_node table */
133057 /* Read and write the xxx_rowid table */
133062 /* Read and write the xxx_parent table */
133074 "CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);"
133075 "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);"
133076 "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY, parentnode INTEGER);"
133137 ** determine the node-size used by the rtree table being created or connected
133142 ** table already exists. In this case the node-size is determined by inspecting
133181 ** methods of the r-tree virtual table.
133185 ** argv[2] -> table name
133191 int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */
133192 sqlite3_vtab **ppVtab, /* OUT: New virtual table */
133204 "Wrong number of columns for an rtree table", /* 1 */
133205 "Too few columns for an rtree table", /* 2 */
133206 "Too many columns for an rtree table" /* 3 */
133240 ** the r-tree table schema.
133246 char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
133346 ** virtual table module "rtree" and the debugging/analysis scalar
133385 ** table MATCH operators.