Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Record the database name in addition to the table name for DELETE, INSERT, and UPDATE statements. (CVS 879) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a5d8fc95ee58dc3205a0bbbcadaa3b9c |
User & Date: | drh 2003-03-20 01:16:58.000 |
Context
2003-03-24
| ||
09:39 | Added pkg-config support. (CVS 880) (check-in: ec1c5a6113 user: a.rottmann tags: trunk) | |
2003-03-20
| ||
01:16 | Record the database name in addition to the table name for DELETE, INSERT, and UPDATE statements. (CVS 879) (check-in: a5d8fc95ee user: drh tags: trunk) | |
2003-03-19
| ||
03:14 | Modifications to the VDBE to support more than one database file. (CVS 878) (check-in: 875da9eed9 user: drh tags: trunk) | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
21 22 23 24 25 26 27 | ** COPY ** VACUUM ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ** COPY ** VACUUM ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** ** $Id: build.c,v 1.133 2003/03/20 01:16:58 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Check to see if the schema for the database needs |
︙ | ︙ | |||
1801 1802 1803 1804 1805 1806 1807 1808 | } /* ** Append a new table name to the given SrcList. Create a new SrcList if ** need be. A new entry is created in the SrcList even if pToken is NULL. ** ** A new SrcList is returned, or NULL if malloc() fails. */ | > > > > > > > > > > > > > > > > > > > | | | | > | | | > > > > > > > > | | > > > > > > > > > > | 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 | } /* ** Append a new table name to the given SrcList. Create a new SrcList if ** need be. A new entry is created in the SrcList even if pToken is NULL. ** ** A new SrcList is returned, or NULL if malloc() fails. ** ** If pDatabase is not null, it means that the table has an optional ** database name prefix. Like this: "database.table". The pDatabase ** points to the table name and the pTable points to the database name. ** The SrcList.a[].zName field is filled with the table name which might ** come from pTable (if pDatabase is NULL) or from pDatabase. ** SrcList.a[].zDatabase is filled with the database name from pTable, ** or with NULL if no database is specified. ** ** In other words, if call like this: ** ** sqliteSrcListAppend(A,B,0); ** ** Then B is a table name and the database name is unspecified. If called ** like this: ** ** sqliteSrcListAppend(A,B,C); ** ** Then C is the table name and B is the database name. */ SrcList *sqliteSrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){ if( pList==0 ){ pList = sqliteMalloc( sizeof(SrcList) ); if( pList==0 ) return 0; } if( (pList->nSrc & 7)==1 ){ SrcList *pNew; pNew = sqliteRealloc(pList, sizeof(*pList) + (pList->nSrc+8)*sizeof(pList->a[0]) ); if( pNew==0 ){ sqliteSrcListDelete(pList); return 0; } pList = pNew; } memset(&pList->a[pList->nSrc], 0, sizeof(pList->a[0])); if( pDatabase && pDatabase->z==0 ){ pDatabase = 0; } if( pDatabase && pTable ){ Token *pTemp = pDatabase; pDatabase = pTable; pTable = pTemp; } if( pTable ){ char **pz = &pList->a[pList->nSrc].zName; sqliteSetNString(pz, pTable->z, pTable->n, 0); if( *pz==0 ){ sqliteSrcListDelete(pList); return 0; }else{ sqliteDequote(*pz); } } if( pDatabase ){ char **pz = &pList->a[pList->nSrc].zDatabase; sqliteSetNString(pz, pDatabase->z, pDatabase->n, 0); if( *pz==0 ){ sqliteSrcListDelete(pList); return 0; }else{ sqliteDequote(*pz); } } |
︙ | ︙ | |||
1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 | /* ** Delete an entire SrcList including all its substructure. */ void sqliteSrcListDelete(SrcList *pList){ int i; if( pList==0 ) return; for(i=0; i<pList->nSrc; i++){ sqliteFree(pList->a[i].zName); sqliteFree(pList->a[i].zAlias); if( pList->a[i].pTab && pList->a[i].pTab->isTransient ){ sqliteDeleteTable(0, pList->a[i].pTab); } sqliteSelectDelete(pList->a[i].pSelect); sqliteExprDelete(pList->a[i].pOn); sqliteIdListDelete(pList->a[i].pUsing); } | > < | 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 | /* ** Delete an entire SrcList including all its substructure. */ void sqliteSrcListDelete(SrcList *pList){ int i; if( pList==0 ) return; for(i=0; i<pList->nSrc; i++){ sqliteFree(pList->a[i].zDatabase); sqliteFree(pList->a[i].zName); sqliteFree(pList->a[i].zAlias); if( pList->a[i].pTab && pList->a[i].pTab->isTransient ){ sqliteDeleteTable(0, pList->a[i].pTab); } sqliteSelectDelete(pList->a[i].pSelect); sqliteExprDelete(pList->a[i].pOn); sqliteIdListDelete(pList->a[i].pUsing); } sqliteFree(pList); } /* ** The COPY command is for compatibility with PostgreSQL and specificially ** for the ability to read the output of pg_dump. The format is as ** follows: |
︙ | ︙ | |||
2075 2076 2077 2078 2079 2080 2081 | ** named database files. */ void sqliteCodeVerifySchema(Parse *pParse){ int i; sqlite *db = pParse->db; Vdbe *v = sqliteGetVdbe(pParse); for(i=0; i<db->nDb; i++){ | | | 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 | ** named database files. */ void sqliteCodeVerifySchema(Parse *pParse){ int i; sqlite *db = pParse->db; Vdbe *v = sqliteGetVdbe(pParse); for(i=0; i<db->nDb; i++){ if( i==1 || db->aDb[i].pBt==0 ) continue; sqliteVdbeAddOp(v, OP_VerifyCookie, 0, db->aDb[i].schema_cookie); } pParse->schemaVerified = 1; } /* ** Generate VDBE code that prepares for doing an operation that |
︙ | ︙ |
Changes to src/delete.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle DELETE FROM statements. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle DELETE FROM statements. ** ** $Id: delete.c,v 1.47 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" /* ** Given a table name, find the corresponding table and make sure the ** table is writeable. Generate an error and return NULL if not. If |
︙ | ︙ | |||
37 38 39 40 41 42 43 | " may not be modified", 0); pParse->nErr++; return 0; } return pTab; } | < < < < < < < < < < < < < < < < < < < < < < < < | < > | < > | > | < < > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | " may not be modified", 0); pParse->nErr++; return 0; } return pTab; } /* ** Process a DELETE FROM statement. */ void sqliteDeleteFrom( Parse *pParse, /* The parser context */ SrcList *pTabList, /* The table from which we should delete things */ Expr *pWhere /* The WHERE clause. May be null */ ){ Vdbe *v; /* The virtual database engine */ Table *pTab; /* The table from which records will be deleted */ char *zTab; /* Name of the table from which we are deleting */ int end, addr; /* A couple addresses of generated code */ int i; /* Loop counter */ WhereInfo *pWInfo; /* Information about the WHERE clause */ Index *pIdx; /* For looping over indices of the table */ int base; /* Index of the first available table cursor */ sqlite *db; /* Main database structure */ int row_triggers_exist = 0; int oldIdx = -1; if( pParse->nErr || sqlite_malloc_failed ){ pTabList = 0; goto delete_from_cleanup; } db = pParse->db; assert( pTabList->nSrc==1 ); /* Check for the special case of a VIEW with one or more ON DELETE triggers ** defined */ zTab = pTabList->a[0].zName; if( zTab != 0 ){ pTab = sqliteFindTable(pParse->db, zTab); if( pTab ){ row_triggers_exist = sqliteTriggersExist(pParse, pTab->pTrigger, TK_DELETE, TK_BEFORE, TK_ROW, 0) || sqliteTriggersExist(pParse, pTab->pTrigger, TK_DELETE, TK_AFTER, TK_ROW, 0); } if( row_triggers_exist && pTab->pSelect ){ /* Just fire VIEW triggers */ sqliteSrcListDelete(pTabList); sqliteViewTriggers(pParse, pTab, pWhere, OE_Replace, 0); return; } } /* Locate the table which we want to delete. This table has to be ** put in an SrcList structure because some of the subroutines we ** will be calling are designed to work with multiple tables and expect ** an SrcList* parameter instead of just a Table* parameter. */ pTab = pTabList->a[0].pTab = sqliteTableNameToTable(pParse, zTab); if( pTab==0 ){ goto delete_from_cleanup; } assert( pTab->pSelect==0 ); /* This table is not a view */ if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0) ){ goto delete_from_cleanup; } /* Allocate a cursor used to store the old.* data for a trigger. */ |
︙ | ︙ |
Changes to src/expr.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: expr.c,v 1.89 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Construct a new expression node and return a pointer to it. Memory ** for this node is obtained from sqliteMalloc(). The calling function |
︙ | ︙ | |||
180 181 182 183 184 185 186 187 | pNew->a[i].done = 0; } return pNew; } SrcList *sqliteSrcListDup(SrcList *p){ SrcList *pNew; int i; if( p==0 ) return 0; | > > | < < | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | pNew->a[i].done = 0; } return pNew; } SrcList *sqliteSrcListDup(SrcList *p){ SrcList *pNew; int i; int nByte; if( p==0 ) return 0; nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0); pNew = sqliteMalloc( nByte ); if( pNew==0 ) return 0; pNew->nSrc = p->nSrc; for(i=0; i<p->nSrc; i++){ pNew->a[i].zName = sqliteStrDup(p->a[i].zName); pNew->a[i].zAlias = sqliteStrDup(p->a[i].zAlias); pNew->a[i].jointype = p->a[i].jointype; pNew->a[i].pTab = 0; pNew->a[i].pSelect = sqliteSelectDup(p->a[i].pSelect); pNew->a[i].pOn = sqliteExprDup(p->a[i].pOn); |
︙ | ︙ |
Changes to src/insert.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** ** $Id: insert.c,v 1.74 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" /* ** This routine is call to handle SQL of the following forms: ** ** insert into TABLE (IDLIST) values(EXPRLIST) |
︙ | ︙ | |||
81 82 83 84 85 86 87 | ** loop over the intermediate table ** transfer values form intermediate table into <table> ** end the loop ** cleanup */ void sqliteInsert( Parse *pParse, /* Parser context */ | | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | ** loop over the intermediate table ** transfer values form intermediate table into <table> ** end the loop ** cleanup */ void sqliteInsert( Parse *pParse, /* Parser context */ SrcList *pTabList, /* Name of table into which we are inserting */ ExprList *pList, /* List of values to be inserted */ Select *pSelect, /* A SELECT statement to use as the data source */ IdList *pColumn, /* Column names corresponding to IDLIST. */ int onError /* How to handle constraint errors */ ){ Table *pTab; /* The table to insert into */ char *zTab; /* Name of the table into which we are inserting */ int i, j, idx; /* Loop counters */ Vdbe *v; /* Generate code into this virtual machine */ Index *pIdx; /* For looping over indices of the table */ int nColumn; /* Number of columns in the data */ int base; /* First available cursor */ int iCont, iBreak; /* Beginning and end of the loop over srcTab */ sqlite *db; /* The main database structure */ |
︙ | ︙ | |||
113 114 115 116 117 118 119 | int newIdx = -1; if( pParse->nErr || sqlite_malloc_failed ) goto insert_cleanup; db = pParse->db; /* Locate the table into which we will be inserting new information. */ | > | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | int newIdx = -1; if( pParse->nErr || sqlite_malloc_failed ) goto insert_cleanup; db = pParse->db; /* Locate the table into which we will be inserting new information. */ assert( pTabList->nSrc==1 ); zTab = pTabList->a[0].zName; if( zTab==0 ) goto insert_cleanup; pTab = sqliteFindTable(pParse->db, zTab); if( pTab==0 ){ sqliteSetString(&pParse->zErrMsg, "no such table: ", zTab, 0); pParse->nErr++; goto insert_cleanup; } |
︙ | ︙ | |||
141 142 143 144 145 146 147 | sqliteSetString(&pParse->zErrMsg, pTab->pSelect ? "view " : "table ", zTab, " may not be modified", 0); pParse->nErr++; goto insert_cleanup; } | < < | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | sqliteSetString(&pParse->zErrMsg, pTab->pSelect ? "view " : "table ", zTab, " may not be modified", 0); pParse->nErr++; goto insert_cleanup; } if( pTab==0 ) goto insert_cleanup; /* If pTab is really a view, make sure it has been initialized. */ if( pTab->pSelect ){ if( sqliteViewGetColumnNames(pParse, pTab) ){ |
︙ | ︙ | |||
517 518 519 520 521 522 523 524 525 | sqliteVdbeAddOp(v, OP_ColumnName, 0, 0); sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC); sqliteVdbeAddOp(v, OP_MemLoad, iCntMem, 0); sqliteVdbeAddOp(v, OP_Callback, 1, 0); } insert_cleanup: if( pList ) sqliteExprListDelete(pList); if( pSelect ) sqliteSelectDelete(pSelect); | > < | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | sqliteVdbeAddOp(v, OP_ColumnName, 0, 0); sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC); sqliteVdbeAddOp(v, OP_MemLoad, iCntMem, 0); sqliteVdbeAddOp(v, OP_Callback, 1, 0); } insert_cleanup: sqliteSrcListDelete(pTabList); if( pList ) sqliteExprListDelete(pList); if( pSelect ) sqliteSelectDelete(pSelect); sqliteIdListDelete(pColumn); } /* ** Generate code to do a constraint check prior to an INSERT or an UPDATE. ** ** When this routine is called, the stack contains (from bottom to top) |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.116 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** A pointer to this structure is used to communicate information |
︙ | ︙ | |||
373 374 375 376 377 378 379 380 381 382 383 384 385 386 | } } sqliteFree(db); sqliteStrRealloc(pzErrMsg); return 0; } db->aDb[0].zName = "main"; /* Attempt to read the schema */ sqliteRegisterBuiltinFunctions(db); rc = sqliteInit(db, pzErrMsg); db->magic = SQLITE_MAGIC_OPEN; if( sqlite_malloc_failed ){ sqlite_close(db); | > | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | } } sqliteFree(db); sqliteStrRealloc(pzErrMsg); return 0; } db->aDb[0].zName = "main"; db->aDb[1].zName = "temp"; /* Attempt to read the schema */ sqliteRegisterBuiltinFunctions(db); rc = sqliteInit(db, pzErrMsg); db->magic = SQLITE_MAGIC_OPEN; if( sqlite_malloc_failed ){ sqlite_close(db); |
︙ | ︙ | |||
465 466 467 468 469 470 471 472 473 474 475 476 477 478 | return; } db->magic = SQLITE_MAGIC_CLOSED; for(j=0; j<db->nDb; j++){ if( db->aDb[j].pBt ){ sqliteBtreeClose(db->aDb[j].pBt); } } if( db->aDb!=db->aDbStatic ){ sqliteFree(db->aDb); } sqliteResetInternalSchema(db); for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){ FuncDef *pFunc, *pNext; | > > > | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | return; } db->magic = SQLITE_MAGIC_CLOSED; for(j=0; j<db->nDb; j++){ if( db->aDb[j].pBt ){ sqliteBtreeClose(db->aDb[j].pBt); } if( j>=2 ){ sqliteFree(db->aDb[j].zName); } } if( db->aDb!=db->aDbStatic ){ sqliteFree(db->aDb); } sqliteResetInternalSchema(db); for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){ FuncDef *pFunc, *pNext; |
︙ | ︙ |
Changes to src/parse.y.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** ** @(#) $Id: parse.y,v 1.92 2003/03/20 01:16:59 drh Exp $ */ %token_prefix TK_ %token_type {Token} %default_type {Token} %extra_argument {Parse *pParse} %syntax_error { if( pParse->zErrMsg==0 ){ |
︙ | ︙ | |||
122 123 124 125 126 127 128 | id(A) ::= ID(X). {A = X;} // The following directive causes tokens ABORT, AFTER, ASC, etc. to // fallback to ID if they will not parse as their original value. // This obviates the need for the "id" nonterminal. // %fallback ID | | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | id(A) ::= ID(X). {A = X;} // The following directive causes tokens ABORT, AFTER, ASC, etc. to // fallback to ID if they will not parse as their original value. // This obviates the need for the "id" nonterminal. // %fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR IGNORE IMMEDIATE INITIALLY INSTEAD MATCH KEY OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT TEMP TRIGGER VACUUM VIEW. // And "ids" is an identifer-or-string. // %type ids {Token} |
︙ | ︙ | |||
349 350 351 352 353 354 355 | // in a SELECT statement. "stl_prefix" is a prefix of this list. // stl_prefix(A) ::= seltablist(X) joinop(Y). { A = X; if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y; } stl_prefix(A) ::= . {A = 0;} | | | | > > > > | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | // in a SELECT statement. "stl_prefix" is a prefix of this list. // stl_prefix(A) ::= seltablist(X) joinop(Y). { A = X; if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y; } stl_prefix(A) ::= . {A = 0;} seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) on_opt(N) using_opt(U). { A = sqliteSrcListAppend(X,&Y,&D); if( Z.n ) sqliteSrcListAddAlias(A,&Z); if( N ){ if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; } else { sqliteExprDelete(N); } } if( U ){ if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; } else { sqliteIdListDelete(U); } } } seltablist(A) ::= stl_prefix(X) LP select(S) RP as(Z) on_opt(N) using_opt(U). { A = sqliteSrcListAppend(X,0,0); A->a[A->nSrc-1].pSelect = S; if( Z.n ) sqliteSrcListAddAlias(A,&Z); if( N ){ if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; } else { sqliteExprDelete(N); } } if( U ){ if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; } else { sqliteIdListDelete(U); } } } %type dbnm {Token} dbnm(A) ::= . {A.z=0; A.n=0;} dbnm(A) ::= DOT nm(X). {A = X;} %type joinop {int} %type joinop2 {int} joinop(X) ::= COMMA. { X = JT_INNER; } joinop(X) ::= JOIN. { X = JT_INNER; } joinop(X) ::= JOIN_KW(A) JOIN. { X = sqliteJoinType(pParse,&A,0,0); } joinop(X) ::= JOIN_KW(A) nm(B) JOIN. { X = sqliteJoinType(pParse,&A,&B,0); } joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN. |
︙ | ︙ | |||
443 444 445 446 447 448 449 | limit_opt(A) ::= LIMIT INTEGER(X) OFFSET INTEGER(Y). {A.limit = atoi(X.z); A.offset = atoi(Y.z);} limit_opt(A) ::= LIMIT INTEGER(X) COMMA INTEGER(Y). {A.limit = atoi(Y.z); A.offset = atoi(X.z);} /////////////////////////// The DELETE statement ///////////////////////////// // | | | > | | | > | | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | limit_opt(A) ::= LIMIT INTEGER(X) OFFSET INTEGER(Y). {A.limit = atoi(X.z); A.offset = atoi(Y.z);} limit_opt(A) ::= LIMIT INTEGER(X) COMMA INTEGER(Y). {A.limit = atoi(Y.z); A.offset = atoi(X.z);} /////////////////////////// The DELETE statement ///////////////////////////// // cmd ::= DELETE FROM nm(X) dbnm(D) where_opt(Y). { sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&X,&D), Y); } %type where_opt {Expr*} %destructor where_opt {sqliteExprDelete($$);} where_opt(A) ::= . {A = 0;} where_opt(A) ::= WHERE expr(X). {A = X;} %type setlist {ExprList*} %destructor setlist {sqliteExprListDelete($$);} ////////////////////////// The UPDATE command //////////////////////////////// // cmd ::= UPDATE orconf(R) nm(X) dbnm(D) SET setlist(Y) where_opt(Z). {sqliteUpdate(pParse,sqliteSrcListAppend(0,&X,&D),Y,Z,R);} setlist(A) ::= setlist(Z) COMMA nm(X) EQ expr(Y). {A = sqliteExprListAppend(Z,Y,&X);} setlist(A) ::= nm(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);} ////////////////////////// The INSERT command ///////////////////////////////// // cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) VALUES LP itemlist(Y) RP. {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), Y, 0, F, R);} cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) select(S). {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), 0, S, F, R);} %type insert_cmd {int} insert_cmd(A) ::= INSERT orconf(R). {A = R;} insert_cmd(A) ::= REPLACE. {A = OE_Replace;} %type itemlist {ExprList*} |
︙ | ︙ | |||
821 822 823 824 825 826 827 | sqliteExprSpan(A, &X, &Y); } //////////////////////// DROP TRIGGER statement ////////////////////////////// cmd ::= DROP TRIGGER nm(X). { sqliteDropTrigger(pParse,&X,0); } | > > > > > > > > > | 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | sqliteExprSpan(A, &X, &Y); } //////////////////////// DROP TRIGGER statement ////////////////////////////// cmd ::= DROP TRIGGER nm(X). { sqliteDropTrigger(pParse,&X,0); } //////////////////////// ATTACH DATABASE file AS name ///////////////////////// cmd ::= ATTACH database_kw_opt ids AS nm. database_kw_opt ::= DATABASE. database_kw_opt ::= . //////////////////////// DETACH DATABASE name ///////////////////////////////// cmd ::= DETACH database_kw_opt nm. |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.164 2003/03/20 01:16:59 drh Exp $ */ #include "config.h" #include "sqlite.h" #include "hash.h" #include "vdbe.h" #include "parse.h" #include "btree.h" |
︙ | ︙ | |||
604 605 606 607 608 609 610 611 612 613 614 615 616 617 | ** The following structure describes the FROM clause of a SELECT statement. ** Each table or subquery in the FROM clause is a separate element of ** the SrcList.a[] array. */ struct SrcList { int nSrc; /* Number of tables or subqueries in the FROM clause */ struct SrcList_item { char *zName; /* Name of the table */ char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ Table *pTab; /* An SQL table corresponding to zName */ Select *pSelect; /* A SELECT statement used in place of a table name */ int jointype; /* Type of join between this table and the next */ Expr *pOn; /* The ON clause of a join */ IdList *pUsing; /* The USING clause of a join */ | > | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | ** The following structure describes the FROM clause of a SELECT statement. ** Each table or subquery in the FROM clause is a separate element of ** the SrcList.a[] array. */ struct SrcList { int nSrc; /* Number of tables or subqueries in the FROM clause */ struct SrcList_item { char *zDatabase; /* Name of database holding this table */ char *zName; /* Name of the table */ char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ Table *pTab; /* An SQL table corresponding to zName */ Select *pSelect; /* A SELECT statement used in place of a table name */ int jointype; /* Type of join between this table and the next */ Expr *pOn; /* The ON clause of a join */ IdList *pUsing; /* The USING clause of a join */ } a[1]; /* One entry for each identifier on the list */ }; /* ** Permitted values of the SrcList.a.jointype field */ #define JT_INNER 0x0001 /* Any kind of inner or cross join */ #define JT_NATURAL 0x0002 /* True for a "natural" join */ |
︙ | ︙ | |||
971 972 973 974 975 976 977 | void sqliteAddCollateType(Parse*, int); void sqliteEndTable(Parse*,Token*,Select*); void sqliteCreateView(Parse*,Token*,Token*,Select*,int); int sqliteViewGetColumnNames(Parse*,Table*); void sqliteViewResetAll(sqlite*); void sqliteDropTable(Parse*, Token*, int); void sqliteDeleteTable(sqlite*, Table*); | | | < | | | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | void sqliteAddCollateType(Parse*, int); void sqliteEndTable(Parse*,Token*,Select*); void sqliteCreateView(Parse*,Token*,Token*,Select*,int); int sqliteViewGetColumnNames(Parse*,Table*); void sqliteViewResetAll(sqlite*); void sqliteDropTable(Parse*, Token*, int); void sqliteDeleteTable(sqlite*, Table*); void sqliteInsert(Parse*, SrcList*, ExprList*, Select*, IdList*, int); IdList *sqliteIdListAppend(IdList*, Token*); int sqliteIdListIndex(IdList*,const char*); SrcList *sqliteSrcListAppend(SrcList*, Token*, Token*); void sqliteSrcListAddAlias(SrcList*, Token*); void sqliteIdListDelete(IdList*); void sqliteSrcListDelete(SrcList*); void sqliteCreateIndex(Parse*, Token*, Token*, IdList*, int, Token*, Token*); void sqliteDropIndex(Parse*, Token*); void sqliteAddKeyType(Vdbe*, ExprList*); void sqliteAddIdxKeyType(Vdbe*, Index*); int sqliteSelect(Parse*, Select*, int, int, Select*, int, int*); Select *sqliteSelectNew(ExprList*,SrcList*,Expr*,ExprList*,Expr*,ExprList*, int,int,int); void sqliteSelectDelete(Select*); void sqliteSelectUnbind(Select*); Table *sqliteTableNameToTable(Parse*, const char*); void sqliteDeleteFrom(Parse*, SrcList*, Expr*); void sqliteUpdate(Parse*, SrcList*, ExprList*, Expr*, int); WhereInfo *sqliteWhereBegin(Parse*, int, SrcList*, Expr*, int, ExprList**); void sqliteWhereEnd(WhereInfo*); void sqliteExprCode(Parse*, Expr*); void sqliteExprIfTrue(Parse*, Expr*, int, int); void sqliteExprIfFalse(Parse*, Expr*, int, int); Table *sqliteFindTable(sqlite*,const char*); Index *sqliteFindIndex(sqlite*,const char*); |
︙ | ︙ |
Changes to src/tokenize.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** ** $Id: tokenize.c,v 1.56 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include <stdlib.h> /* |
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | static Keyword aKeywordTable[] = { { "ABORT", 0, TK_ABORT, 0 }, { "AFTER", 0, TK_AFTER, 0 }, { "ALL", 0, TK_ALL, 0 }, { "AND", 0, TK_AND, 0 }, { "AS", 0, TK_AS, 0 }, { "ASC", 0, TK_ASC, 0 }, { "BEFORE", 0, TK_BEFORE, 0 }, { "BEGIN", 0, TK_BEGIN, 0 }, { "BETWEEN", 0, TK_BETWEEN, 0 }, { "BY", 0, TK_BY, 0 }, { "CASCADE", 0, TK_CASCADE, 0 }, { "CASE", 0, TK_CASE, 0 }, { "CHECK", 0, TK_CHECK, 0 }, { "CLUSTER", 0, TK_CLUSTER, 0 }, { "COLLATE", 0, TK_COLLATE, 0 }, { "COMMIT", 0, TK_COMMIT, 0 }, { "CONFLICT", 0, TK_CONFLICT, 0 }, { "CONSTRAINT", 0, TK_CONSTRAINT, 0 }, { "COPY", 0, TK_COPY, 0 }, { "CREATE", 0, TK_CREATE, 0 }, { "CROSS", 0, TK_JOIN_KW, 0 }, { "DEFAULT", 0, TK_DEFAULT, 0 }, { "DEFERRED", 0, TK_DEFERRED, 0 }, { "DEFERRABLE", 0, TK_DEFERRABLE, 0 }, { "DELETE", 0, TK_DELETE, 0 }, { "DELIMITERS", 0, TK_DELIMITERS, 0 }, { "DESC", 0, TK_DESC, 0 }, { "DISTINCT", 0, TK_DISTINCT, 0 }, { "DROP", 0, TK_DROP, 0 }, { "END", 0, TK_END, 0 }, { "EACH", 0, TK_EACH, 0 }, { "ELSE", 0, TK_ELSE, 0 }, { "EXCEPT", 0, TK_EXCEPT, 0 }, { "EXPLAIN", 0, TK_EXPLAIN, 0 }, | > > > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | static Keyword aKeywordTable[] = { { "ABORT", 0, TK_ABORT, 0 }, { "AFTER", 0, TK_AFTER, 0 }, { "ALL", 0, TK_ALL, 0 }, { "AND", 0, TK_AND, 0 }, { "AS", 0, TK_AS, 0 }, { "ASC", 0, TK_ASC, 0 }, { "ATTACH", 0, TK_ATTACH, 0 }, { "BEFORE", 0, TK_BEFORE, 0 }, { "BEGIN", 0, TK_BEGIN, 0 }, { "BETWEEN", 0, TK_BETWEEN, 0 }, { "BY", 0, TK_BY, 0 }, { "CASCADE", 0, TK_CASCADE, 0 }, { "CASE", 0, TK_CASE, 0 }, { "CHECK", 0, TK_CHECK, 0 }, { "CLUSTER", 0, TK_CLUSTER, 0 }, { "COLLATE", 0, TK_COLLATE, 0 }, { "COMMIT", 0, TK_COMMIT, 0 }, { "CONFLICT", 0, TK_CONFLICT, 0 }, { "CONSTRAINT", 0, TK_CONSTRAINT, 0 }, { "COPY", 0, TK_COPY, 0 }, { "CREATE", 0, TK_CREATE, 0 }, { "CROSS", 0, TK_JOIN_KW, 0 }, { "DATABASE", 0, TK_DATABASE, 0 }, { "DEFAULT", 0, TK_DEFAULT, 0 }, { "DEFERRED", 0, TK_DEFERRED, 0 }, { "DEFERRABLE", 0, TK_DEFERRABLE, 0 }, { "DELETE", 0, TK_DELETE, 0 }, { "DELIMITERS", 0, TK_DELIMITERS, 0 }, { "DESC", 0, TK_DESC, 0 }, { "DETACH", 0, TK_DETACH, 0 }, { "DISTINCT", 0, TK_DISTINCT, 0 }, { "DROP", 0, TK_DROP, 0 }, { "END", 0, TK_END, 0 }, { "EACH", 0, TK_EACH, 0 }, { "ELSE", 0, TK_ELSE, 0 }, { "EXCEPT", 0, TK_EXCEPT, 0 }, { "EXPLAIN", 0, TK_EXPLAIN, 0 }, |
︙ | ︙ |
Changes to src/trigger.c.
︙ | ︙ | |||
510 511 512 513 514 515 516 517 | assert(ss); assert(ss->pSrc); sqliteSelect(pParse, ss, SRT_Discard, 0, 0, 0, 0); sqliteSelectDelete(ss); break; } case TK_UPDATE: { sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0); | > > | > > | | | | > | | | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | assert(ss); assert(ss->pSrc); sqliteSelect(pParse, ss, SRT_Discard, 0, 0, 0, 0); sqliteSelectDelete(ss); break; } case TK_UPDATE: { SrcList *pSrc; pSrc = sqliteSrcListAppend(0, &pTriggerStep->target, 0); sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0); sqliteUpdate(pParse, pSrc, sqliteExprListDup(pTriggerStep->pExprList), sqliteExprDup(pTriggerStep->pWhere), orconf); sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0); break; } case TK_INSERT: { SrcList *pSrc; pSrc = sqliteSrcListAppend(0, &pTriggerStep->target, 0); sqliteInsert(pParse, pSrc, sqliteExprListDup(pTriggerStep->pExprList), sqliteSelectDup(pTriggerStep->pSelect), sqliteIdListDup(pTriggerStep->pIdList), orconf); break; } case TK_DELETE: { SrcList *pSrc; sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0); pSrc = sqliteSrcListAppend(0, &pTriggerStep->target, 0); sqliteDeleteFrom(pParse, pSrc, sqliteExprDup(pTriggerStep->pWhere)); sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0); break; } default: assert(0); } pParse->nTab = saveNTab; |
︙ | ︙ | |||
607 608 609 610 611 612 613 | if( fire_this && (pTriggerStack = sqliteMalloc(sizeof(TriggerStack)))!=0 ){ int endTrigger; SrcList dummyTablist; Expr * whenExpr; dummyTablist.nSrc = 0; | < | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | if( fire_this && (pTriggerStack = sqliteMalloc(sizeof(TriggerStack)))!=0 ){ int endTrigger; SrcList dummyTablist; Expr * whenExpr; dummyTablist.nSrc = 0; /* Push an entry on to the trigger stack */ pTriggerStack->pTrigger = pTrigger; pTriggerStack->newIdx = newIdx; pTriggerStack->oldIdx = oldIdx; pTriggerStack->pTab = pTab; pTriggerStack->pNext = pParse->trigStack; |
︙ | ︙ | |||
678 679 680 681 682 683 684 | assert(pTab->pSelect); tblNameToken.z = pTab->zName; tblNameToken.n = strlen(pTab->zName); theSelect.isDistinct = 0; theSelect.pEList = sqliteExprListAppend(0, sqliteExpr(TK_ALL, 0, 0, 0), 0); | | | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | assert(pTab->pSelect); tblNameToken.z = pTab->zName; tblNameToken.n = strlen(pTab->zName); theSelect.isDistinct = 0; theSelect.pEList = sqliteExprListAppend(0, sqliteExpr(TK_ALL, 0, 0, 0), 0); theSelect.pSrc = sqliteSrcListAppend(0, &tblNameToken, 0); theSelect.pWhere = pWhere; pWhere = 0; theSelect.pGroupBy = 0; theSelect.pHaving = 0; theSelect.pOrderBy = 0; theSelect.op = TK_SELECT; /* ?? */ theSelect.pPrior = 0; theSelect.nLimit = -1; |
︙ | ︙ |
Changes to src/update.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** | | | > < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** ** $Id: update.c,v 1.55 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" /* ** Process an UPDATE statement. */ void sqliteUpdate( Parse *pParse, /* The parser context */ SrcList *pTabList, /* The table in which we should change things */ ExprList *pChanges, /* Things to be changed */ Expr *pWhere, /* The WHERE clause. May be null */ int onError /* How to handle constraint errors */ ){ int i, j; /* Loop counters */ char *zTab; /* Name of the table to be updated */ Table *pTab; /* The table to be updated */ int addr; /* VDBE instruction address of the start of the loop */ WhereInfo *pWInfo; /* Information about the WHERE clause */ Vdbe *v; /* The virtual database engine */ Index *pIdx; /* For looping over indices */ int nIdx; /* Number of indices that need updating */ int nIdxTotal; /* Total number of indices */ int base; /* Index of first available table cursor */ |
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 | int row_triggers_exist = 0; int newIdx = -1; /* index of trigger "new" temp table */ int oldIdx = -1; /* index of trigger "old" temp table */ if( pParse->nErr || sqlite_malloc_failed ) goto update_cleanup; db = pParse->db; /* Check for the special case of a VIEW with one or more ON UPDATE triggers * defined */ | > < < | | | | | | | | | | | | | > | | < | | < | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | int row_triggers_exist = 0; int newIdx = -1; /* index of trigger "new" temp table */ int oldIdx = -1; /* index of trigger "old" temp table */ if( pParse->nErr || sqlite_malloc_failed ) goto update_cleanup; db = pParse->db; assert( pTabList->nSrc==1 ); /* Check for the special case of a VIEW with one or more ON UPDATE triggers * defined */ zTab = pTabList->a[0].zName; if( zTab != 0 ){ pTab = sqliteFindTable(pParse->db, zTab); if( pTab ){ row_triggers_exist = sqliteTriggersExist(pParse, pTab->pTrigger, TK_UPDATE, TK_BEFORE, TK_ROW, pChanges) || sqliteTriggersExist(pParse, pTab->pTrigger, TK_UPDATE, TK_AFTER, TK_ROW, pChanges); } if( row_triggers_exist && pTab->pSelect ){ /* Just fire VIEW triggers */ sqliteSrcListDelete(pTabList); sqliteViewTriggers(pParse, pTab, pWhere, onError, pChanges); return; } } /* Locate the table which we want to update. This table has to be ** put in an SrcList structure because some of the subroutines we ** will be calling are designed to work with multiple tables and expect ** an SrcList* parameter instead of just a Table* parameter. */ pTab = pTabList->a[0].pTab = sqliteTableNameToTable(pParse, zTab); if( pTab==0 ) goto update_cleanup; assert( pTab->pSelect==0 ); /* This table is not a VIEW */ aXRef = sqliteMalloc( sizeof(int) * pTab->nCol ); if( aXRef==0 ) goto update_cleanup; for(i=0; i<pTab->nCol; i++) aXRef[i] = -1; /* If there are FOR EACH ROW triggers, allocate temp tables */ if( row_triggers_exist ){ |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
32 33 34 35 36 37 38 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.209 2003/03/20 01:16:59 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The makefile scans this source file and creates the following ** array of string constants which are the names of all VDBE opcodes. |
︙ | ︙ | |||
1206 1207 1208 1209 1210 1211 1212 | } /* ** Delete an entire VDBE. */ void sqliteVdbeDelete(Vdbe *p){ int i; | < | 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 | } /* ** Delete an entire VDBE. */ void sqliteVdbeDelete(Vdbe *p){ int i; if( p==0 ) return; Cleanup(p); if( p->pPrev ){ p->pPrev->pNext = p->pNext; }else{ assert( p->db->pVdbe==p ); p->db->pVdbe = p->pNext; |
︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 | p->nOp = 0; } for(i=0; i<p->nOp; i++){ if( p->aOp[i].p3type==P3_DYNAMIC ){ sqliteFree(p->aOp[i].p3); } } | < < < < < < < | 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | p->nOp = 0; } for(i=0; i<p->nOp; i++){ if( p->aOp[i].p3type==P3_DYNAMIC ){ sqliteFree(p->aOp[i].p3); } } sqliteFree(p->aOp); sqliteFree(p->aLabel); sqliteFree(p->aStack); sqliteFree(p); } /* |
︙ | ︙ | |||
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 | void sqliteVdbeMakeReady( Vdbe *p, /* The VDBE */ sqlite_callback xCallback, /* Result callback */ void *pCallbackArg, /* 1st argument to xCallback() */ int isExplain /* True if the EXPLAIN keywords is present */ ){ int n; assert( p!=0 ); assert( p->aStack==0 ); assert( p->magic==VDBE_MAGIC_INIT ); /* Add a HALT instruction to the very end of the program. */ | > > > | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 | void sqliteVdbeMakeReady( Vdbe *p, /* The VDBE */ sqlite_callback xCallback, /* Result callback */ void *pCallbackArg, /* 1st argument to xCallback() */ int isExplain /* True if the EXPLAIN keywords is present */ ){ int n; #ifdef MEMORY_DEBUG extern int access(const char*,int); #endif assert( p!=0 ); assert( p->aStack==0 ); assert( p->magic==VDBE_MAGIC_INIT ); /* Add a HALT instruction to the very end of the program. */ |
︙ | ︙ | |||
3341 3342 3343 3344 3345 3346 3347 | ** Either a transaction needs to have been started or an OP_Open needs ** to be executed (to establish a read lock) before this opcode is ** invoked. */ case OP_VerifyCookie: { int aMeta[SQLITE_N_BTREE_META]; assert( pOp->p1>=0 && pOp->p1<db->nDb ); | < | 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 | ** Either a transaction needs to have been started or an OP_Open needs ** to be executed (to establish a read lock) before this opcode is ** invoked. */ case OP_VerifyCookie: { int aMeta[SQLITE_N_BTREE_META]; assert( pOp->p1>=0 && pOp->p1<db->nDb ); rc = sqliteBtreeGetMeta(db->aDb[pOp->p1].pBt, aMeta); if( rc==SQLITE_OK && aMeta[1]!=pOp->p2 ){ sqliteSetString(&p->zErrMsg, "database schema has changed", 0); rc = SQLITE_SCHEMA; } break; } |
︙ | ︙ |