Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove the OP_CreateTable and OP_CreateIndex opcodes, which are not required with the key/value backend. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
31b1faa9954a449ce6774256e0eddd55 |
User & Date: | drh 2012-02-22 00:11:19.695 |
Context
2012-02-22
| ||
02:44 | Remove the OP_Destroy opcode. Add an implementation for OP_Clear. check-in: 15cf832dfc user: drh tags: trunk | |
00:11 | Remove the OP_CreateTable and OP_CreateIndex opcodes, which are not required with the key/value backend. check-in: 31b1faa995 user: drh tags: trunk | |
2012-02-21
| ||
20:03 | Only the bare basics work. But we might as well go ahead and call this the trunk since we are unlikely to ever need to bisect back into this massive rewrite effort. check-in: a101b3e1c4 user: drh tags: trunk | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
207 208 209 210 211 212 213 214 215 216 217 218 219 220 | pParse->nTab = 0; pParse->nMem = 0; pParse->nSet = 0; pParse->nVar = 0; pParse->cookieMask = 0; pParse->cookieGoto = 0; } /* ** Run the parser and code generator recursively in order to generate ** code for the SQL statement given onto the end of the pParse context ** currently under construction. When the parser is run recursively ** this way, the final OP_Halt is not appended and other initialization ** and finalization steps are omitted because those are handling by the | > > > > > > > > > > > > > > > > > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | pParse->nTab = 0; pParse->nMem = 0; pParse->nSet = 0; pParse->nVar = 0; pParse->cookieMask = 0; pParse->cookieGoto = 0; } /* ** Find an available table number for database iDb */ static int firstAvailableTableNumber(sqlite4 *db, int iDb){ HashElem *i; int maxTab = 1; for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash); i;i=sqliteHashNext(i)){ Table *pTab = (Table*)sqliteHashData(i); if( pTab->tnum > maxTab ) maxTab = pTab->tnum; } for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash); i;i=sqliteHashNext(i)){ Index *pIdx = (Index*)sqliteHashData(i); if( pIdx->tnum > maxTab ) maxTab = pIdx->tnum; } return maxTab+1; } /* ** Run the parser and code generator recursively in order to generate ** code for the SQL statement given onto the end of the pParse context ** currently under construction. When the parser is run recursively ** this way, the final OP_Halt is not appended and other initialization ** and finalization steps are omitted because those are handling by the |
︙ | ︙ | |||
850 851 852 853 854 855 856 | #ifndef SQLITE_OMIT_VIRTUALTABLE if( isVirtual ){ sqlite4VdbeAddOp0(v, OP_VBegin); } #endif | < > | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | #ifndef SQLITE_OMIT_VIRTUALTABLE if( isVirtual ){ sqlite4VdbeAddOp0(v, OP_VBegin); } #endif /* This just creates a place-holder record in the sqlite_master table. ** The record created does not contain anything yet. It will be replaced ** by the real entry in code generated at sqlite4EndTable(). ** ** The rowid for the new entry is left in register pParse->regRowid. ** The root page number of the new table is left in reg pParse->regRoot. ** The rowid and root page number values are needed by the code that ** sqlite4EndTable will generate. */ reg1 = pParse->regRowid = ++pParse->nMem; reg2 = pParse->regRoot = ++pParse->nMem; reg3 = ++pParse->nMem; #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) if( isView || isVirtual ){ sqlite4VdbeAddOp2(v, OP_Integer, 0, reg2); }else #endif { int tnum = firstAvailableTableNumber(db, iDb); sqlite4VdbeAddOp2(v, OP_Integer, tnum, reg2); } sqlite4OpenMasterTable(pParse, iDb); sqlite4VdbeAddOp2(v, OP_NewRowid, 0, reg1); sqlite4VdbeAddOp2(v, OP_Null, 0, reg3); sqlite4VdbeAddOp3(v, OP_Insert, 0, reg3, reg1); sqlite4VdbeChangeP5(v, OPFLAG_APPEND); sqlite4VdbeAddOp0(v, OP_Close); |
︙ | ︙ | |||
2191 2192 2193 2194 2195 2196 2197 | #endif } /* ** Generate code that will erase and refill index *pIdx. This is ** used to initialize a newly created index or to recompute the ** content of an index in response to a REINDEX command. | < < < < < < | | 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 | #endif } /* ** Generate code that will erase and refill index *pIdx. This is ** used to initialize a newly created index or to recompute the ** content of an index in response to a REINDEX command. */ static void sqlite4RefillIndex(Parse *pParse, Index *pIndex){ Table *pTab = pIndex->pTable; /* The table that is indexed */ int iTab = pParse->nTab++; /* Cursor used for pTab */ int iIdx = pParse->nTab++; /* Cursor used for pIndex */ int iSorter; /* Cursor opened by OpenSorter (if in use) */ int addr1; /* Address of top of loop */ int addr2; /* Address to jump to for next iteration */ int tnum; /* Root page of index */ |
︙ | ︙ | |||
2227 2228 2229 2230 2231 2232 2233 | #endif /* Require a write-lock on the table to perform this operation */ sqlite4TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName); v = sqlite4GetVdbe(pParse); if( v==0 ) return; | < < < | | < < < < | 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 | #endif /* Require a write-lock on the table to perform this operation */ sqlite4TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName); v = sqlite4GetVdbe(pParse); if( v==0 ) return; tnum = pIndex->tnum; sqlite4VdbeAddOp2(v, OP_Clear, tnum, iDb); pKey = sqlite4IndexKeyinfo(pParse, pIndex); sqlite4VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, (char *)pKey, P4_KEYINFO_HANDOFF); #ifndef SQLITE_OMIT_MERGE_SORT /* Open the sorter cursor if we are to use one. */ iSorter = pParse->nTab++; sqlite4VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO); #else iSorter = iTab; |
︙ | ︙ | |||
2712 2713 2714 2715 2716 2717 2718 | ** or UNIQUE constraint of a CREATE TABLE statement. Since the table ** has just been created, it contains no data and the index initialization ** step can be skipped. */ else{ /* if( db->init.busy==0 ) */ Vdbe *v; char *zStmt; | < | | | | | 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 | ** or UNIQUE constraint of a CREATE TABLE statement. Since the table ** has just been created, it contains no data and the index initialization ** step can be skipped. */ else{ /* if( db->init.busy==0 ) */ Vdbe *v; char *zStmt; v = sqlite4GetVdbe(pParse); if( v==0 ) goto exit_create_index; /* Create the rootpage for the index */ sqlite4BeginWriteOperation(pParse, 1, iDb); pIndex->tnum = firstAvailableTableNumber(db, iDb); /* Gather the complete text of the CREATE INDEX statement into ** the zStmt variable */ if( pStart ){ assert( pEnd!=0 ); /* A named index with an explicit CREATE INDEX statement */ zStmt = sqlite4MPrintf(db, "CREATE%s INDEX %.*s", onError==OE_None ? "" : " UNIQUE", (int)(pEnd->z - pName->z) + 1, pName->z); }else{ /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ /* zStmt = sqlite4MPrintf(""); */ zStmt = 0; } /* Add an entry in sqlite_master for this index */ sqlite4NestedParse(pParse, "INSERT INTO %Q.%s VALUES('index',%Q,%Q,%d,%Q);", db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pIndex->zName, pTab->zName, pIndex->tnum, zStmt ); sqlite4DbFree(db, zStmt); /* Fill the index with data and reparse the schema. Code an OP_Expire ** to invalidate all pre-compiled statements. */ if( pTblName ){ sqlite4RefillIndex(pParse, pIndex); sqlite4ChangeCookie(pParse, iDb); sqlite4VdbeAddParseSchemaOp(v, iDb, sqlite4MPrintf(db, "name='%q' AND type='index'", pIndex->zName)); sqlite4VdbeAddOp1(v, OP_Expire, 0); } } |
︙ | ︙ | |||
3542 3543 3544 3545 3546 3547 3548 | static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){ Index *pIndex; /* An index associated with pTab */ for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){ if( zColl==0 || collationMatch(zColl, pIndex) ){ int iDb = sqlite4SchemaToIndex(pParse->db, pTab->pSchema); sqlite4BeginWriteOperation(pParse, 0, iDb); | | | 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 | static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){ Index *pIndex; /* An index associated with pTab */ for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){ if( zColl==0 || collationMatch(zColl, pIndex) ){ int iDb = sqlite4SchemaToIndex(pParse->db, pTab->pSchema); sqlite4BeginWriteOperation(pParse, 0, iDb); sqlite4RefillIndex(pParse, pIndex); } } } #endif /* ** Recompute all indices of all tables in all databases where the |
︙ | ︙ | |||
3632 3633 3634 3635 3636 3637 3638 | sqlite4DbFree(db, z); return; } pIndex = sqlite4FindIndex(db, z, zDb); sqlite4DbFree(db, z); if( pIndex ){ sqlite4BeginWriteOperation(pParse, 0, iDb); | | | 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 | sqlite4DbFree(db, z); return; } pIndex = sqlite4FindIndex(db, z, zDb); sqlite4DbFree(db, z); if( pIndex ){ sqlite4BeginWriteOperation(pParse, 0, iDb); sqlite4RefillIndex(pParse, pIndex); return; } sqlite4ErrorMsg(pParse, "unable to identify the object to be reindexed"); } #endif /* |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
3713 3714 3715 3716 3717 3718 3719 | ** See also: Destroy */ case OP_Clear: { assert( 0 ); break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 | ** See also: Destroy */ case OP_Clear: { assert( 0 ); break; } /* Opcode: ParseSchema P1 * * P4 * ** ** Read and parse all entries from the SQLITE_MASTER table of database P1 ** that match the WHERE clause P4. ** ** This opcode invokes the parser to create a new virtual machine, |
︙ | ︙ |