-C In\sthe\s"lang.html"\sdocumentation\sfile,\sput\sthe\sCREATE\sTRIGGER\sand\sDROP\sTRIGGER\nsections\sin\salphabetical\sorder.\s(CVS\s564)
-D 2002-05-15T11:43:16
+C Remove\sall\stabs\sfrom\sthe\sbeginning\sof\ssource\scode\slines.\s\sReplace\stabs\swith\nthe\sappropriate\snumber\sof\sspaces.\s(CVS\s565)
+D 2002-05-15T11:44:14
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
-F src/btree.c 7dd7ddc66459982dd0cb9800958c1f8d65a32d9f
+F src/btree.c c01b404b9373ae1c0daf7d1f9211c72ead67638e
F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
-F src/build.c cbf1b552d381c3f94baad9be2defbc60a158ac64
-F src/delete.c 392159781f9dff5f07ce2cb7d3a3a184eb38c0ab
+F src/build.c 74f19f9001ee3708b451faf8fc8a6b36024a9be7
+F src/delete.c 48e4c533b39d6edfcfca23fb500129b80b7cad30
F src/encode.c 346b12b46148506c32038524b95c4631ab46d760
F src/expr.c 6888e37e4eecdc20567aedd442328df752465723
F src/func.c a31dcba85bc2ecb9b752980289cf7e6cd0cafbce
F src/hash.c cc259475e358baaf299b00a2c7370f2b03dda892
F src/hash.h dca065dda89d4575f3176e75e9a3dc0f4b4fb8b9
-F src/insert.c 9f89b395e25f2a9eaea841fa736a4036d33d2b24
-F src/main.c 6bc0b3dd014f6af13007472581593e87b2797139
-F src/md5.c b2b1a34fce66ceca97f4e0dabc20be8be7933c92
+F src/insert.c 26ca700fb4055c34970ebac1d9a9a067bebef3b0
+F src/main.c 9e9ba7d8491928c46c6a70d9b7c30bbf7e60d499
+F src/md5.c 0ae1f3e2cac92d06fc6246d1b4b8f61a2fe66d3b
F src/os.c 5ab8b6b4590d0c1ab8e96c67996c170e4462e0fc
F src/os.h 4a361fccfbc4e7609b3e1557f604f94c1e96ad10
F src/pager.c ba5740104cc27b342cd43eebfdc44d60f64a3ded
F src/pager.h 6fddfddd3b73aa8abc081b973886320e3c614f0e
F src/parse.y 164789531d0c6a2c28fb4baded14afc1be4bd4aa
-F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d
+F src/printf.c d8032ee18b860c812eeff596c9bebfdacb7930fd
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c 1b623a7d826ec7c245bc542b665d61724da2a62d
F src/shell.c 5acbe59e137d60d8efd975c683dbea74ab626530
F src/test3.c 4e52fff8b01f08bd202f7633feda5639b7ba2b5e
F src/threadtest.c 81f0598e0f031c1bd506af337fdc1b7e8dff263f
F src/tokenize.c f12f78c58b2a79ea4eee880efad63a328e103c62
-F src/trigger.c b8df3e8f0952979bbbcbd0cb05b7d564924a3282
-F src/update.c 2e8becd1cd3a597f74f8879e2c246cca5d20a119
+F src/trigger.c 768b895cf09382db4e2d1ce5aace7e6a4cbf7e4d
+F src/update.c f9b53d46cc651b9630fc53342b9e792031f6fc5c
F src/util.c 707c30f8c13cddace7c08556ac450c0b786660b3
-F src/vdbe.c 428d7dba1fb84a3da6170c3cb387d177c315a72a
+F src/vdbe.c 42281b4e0e0c4a089018a14d6840ada5a1896e51
F src/vdbe.h 126a651ba26f05de075dcc6da5466244a31af6b8
-F src/where.c 3138c1b44193ab5f432919ab25e49f3d97bd6108
+F src/where.c d1c05aca90d2a9d7000c40db5a4b1ac9d6d1169d
F test/all.test e4d3821eeba751829b419cd47814bd20af4286d1
F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
F test/btree.test bf326f546a666617367a7033fa2c07451bd4f8e1
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 29b8330ca6bfe32c499a045189683100f2b15246
-R a27803f7b286e7959f11eb8469f192e0
+P d1d8642b57bd0765ade730248012d58b0859c12c
+R 7c8b29631adcec690efa7e7338377d43
U drh
-Z a84814eb63e1343d44fc3775f1b09115
+Z 13f7f043962d157cad884aca33ba63e6
-d1d8642b57bd0765ade730248012d58b0859c12c
\ No newline at end of file
+690f9a163173c4c7af7e8e92e942cee4184c7974
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.60 2002/03/06 22:01:35 drh Exp $
+** $Id: btree.c,v 1.61 2002/05/15 11:44:14 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
}
pP1 = pBt->page1;
rc = sqlitepager_write(pP1);
- if( rc ) return rc;
+ if( rc ) return rc;
memcpy(pP1->aMeta, &aMeta[1], sizeof(pP1->aMeta));
return SQLITE_OK;
}
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.88 2002/05/15 08:30:13 danielk1977 Exp $
+** $Id: build.c,v 1.89 2002/05/15 11:44:14 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
/* Remove any triggers that haven't been commited yet */
for(pElem = sqliteHashFirst(&db->trigHash); pElem;
pElem = (pElem?sqliteHashNext(pElem):0)) {
- Trigger * pTrigger = sqliteHashData(pElem);
- if (!pTrigger->isCommit) {
- Table * tbl = sqliteFindTable(db, pTrigger->table);
- if (tbl) {
- if (tbl->pTrigger == pTrigger)
- tbl->pTrigger = pTrigger->pNext;
- else {
- Trigger * cc = tbl->pTrigger;
- while (cc) {
- if (cc->pNext == pTrigger) {
- cc->pNext = cc->pNext->pNext;
- break;
- }
- cc = cc->pNext;
- }
- assert(cc);
- }
+ Trigger *pTrigger = sqliteHashData(pElem);
+ if( !pTrigger->isCommit ){
+ Table *pTbl = sqliteFindTable(db, pTrigger->table);
+ if( pTbl ){
+ if( pTbl->pTrigger == pTrigger ){
+ pTbl->pTrigger = pTrigger->pNext;
+ }else{
+ Trigger *cc = pTbl->pTrigger;
+ while( cc ){
+ if (cc->pNext == pTrigger) {
+ cc->pNext = cc->pNext->pNext;
+ break;
+ }
+ cc = cc->pNext;
+ }
+ assert(cc);
+ }
}
sqliteHashInsert(&db->trigHash, pTrigger->name,
- 1 + strlen(pTrigger->name), 0);
+ 1 + strlen(pTrigger->name), 0);
sqliteDeleteTrigger(pTrigger);
pElem = sqliteHashFirst(&db->trigHash);
}
Trigger * pTrigger = sqliteHashData(pElem);
Table * tab = sqliteFindTable(db, pTrigger->table);
sqliteHashInsert(&db->trigHash, pTrigger->name,
- strlen(pTrigger->name) + 1, pTrigger);
+ strlen(pTrigger->name) + 1, pTrigger);
pTrigger->pNext = tab->pTrigger;
tab->pTrigger = pTrigger;
sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC);
sqliteVdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0);
sqliteVdbeAddOp(v, OP_Callback, 3, 0);
- ++i;
- pIdx = pIdx->pNext;
+ ++i;
+ pIdx = pIdx->pNext;
}
}
}else
** This file contains C code routines that are called by the parser
** to handle DELETE FROM statements.
**
-** $Id: delete.c,v 1.31 2002/05/15 08:30:13 danielk1977 Exp $
+** $Id: delete.c,v 1.32 2002/05/15 11:44:14 drh Exp $
*/
#include "sqliteInt.h"
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);
+ 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);
}
sqliteFree(zTab);
if (row_triggers_exist && pTab->pSelect ) {
- /* Just fire VIEW triggers */
- sqliteViewTriggers(pParse, pTab, pWhere, OE_Replace, 0);
- return;
+ /* Just fire VIEW triggers */
+ sqliteViewTriggers(pParse, pTab, pWhere, OE_Replace, 0);
+ return;
}
}
}
sqliteVdbeAddOp(v, OP_Integer, 13, 0);
for (ii = 0; ii < pTab->nCol; ii++) {
- if (ii == pTab->iPKey)
- sqliteVdbeAddOp(v, OP_Recno, base, 0);
- else
- sqliteVdbeAddOp(v, OP_Column, base, ii);
+ if (ii == pTab->iPKey)
+ sqliteVdbeAddOp(v, OP_Recno, base, 0);
+ else
+ sqliteVdbeAddOp(v, OP_Column, base, ii);
}
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
sqliteVdbeAddOp(v, OP_Rewind, oldIdx, 0);
sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1,
- oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default);
+ oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default);
}
pParse->nTab = base + 1;
if (row_triggers_exist) {
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
- sqliteVdbeAddOp(v, OP_Close, base + i, pIdx->tnum);
+ sqliteVdbeAddOp(v, OP_Close, base + i, pIdx->tnum);
}
sqliteVdbeAddOp(v, OP_Close, base, 0);
sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1,
- oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default);
+ oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default);
}
sqliteVdbeAddOp(v, OP_Goto, 0, addr);
if (!row_triggers_exist) {
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
- sqliteVdbeAddOp(v, OP_Close, base + i, pIdx->tnum);
+ sqliteVdbeAddOp(v, OP_Close, base + i, pIdx->tnum);
}
sqliteVdbeAddOp(v, OP_Close, base, 0);
pParse->nTab = base;
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.53 2002/05/15 08:30:13 danielk1977 Exp $
+** $Id: insert.c,v 1.54 2002/05/15 11:44:14 drh Exp $
*/
#include "sqliteInt.h"
*/
row_triggers_exist =
sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT,
- TK_BEFORE, TK_ROW, 0) ||
+ TK_BEFORE, TK_ROW, 0) ||
sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT, TK_AFTER, TK_ROW, 0);
if( pTab->readOnly || (pTab->pSelect && !row_triggers_exist) ){
sqliteSetString(&pParse->zErrMsg,
sqliteVdbeAddOp(v, OP_Integer, 13, 0);
for(i=0; i<pTab->nCol; i++){
if( pColumn==0 ){
- j = i;
+ j = i;
}else{
- for(j=0; j<pColumn->nId; j++){
- if( pColumn->a[j].idx==i ) break;
- }
+ for(j=0; j<pColumn->nId; j++){
+ if( pColumn->a[j].idx==i ) break;
+ }
}
if( pColumn && j>=pColumn->nId ){
- sqliteVdbeAddOp(v, OP_String, 0, 0);
- sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC);
+ sqliteVdbeAddOp(v, OP_String, 0, 0);
+ sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC);
}else if( srcTab>=0 ){
- sqliteVdbeAddOp(v, OP_Column, srcTab, j);
+ sqliteVdbeAddOp(v, OP_Column, srcTab, j);
}else{
- sqliteExprCode(pParse, pList->a[j].pExpr);
+ sqliteExprCode(pParse, pList->a[j].pExpr);
}
}
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
/* Fire BEFORE triggers */
if (
sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_BEFORE, pTab, newIdx, -1,
- onError)
+ onError)
) goto insert_cleanup;
/* Open the tables and indices for the INSERT */
sqliteVdbeAddOp(v, openOp, base, pTab->tnum);
sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC);
for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){
- sqliteVdbeAddOp(v, openOp, idx+base, pIdx->tnum);
- sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC);
+ sqliteVdbeAddOp(v, openOp, idx+base, pIdx->tnum);
+ sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC);
}
pParse->nTab += idx;
}
if (!pTab->pSelect) {
if( keyColumn>=0 ){
if( srcTab>=0 ){
- sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn);
+ sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn);
}else{
- int addr;
- sqliteExprCode(pParse, pList->a[keyColumn].pExpr);
-
- /* If the PRIMARY KEY expression is NULL, then use OP_NewRecno
- ** to generate a unique primary key value.
- */
- addr = sqliteVdbeAddOp(v, OP_Dup, 0, 1);
- sqliteVdbeAddOp(v, OP_NotNull, 0, addr+4);
- sqliteVdbeAddOp(v, OP_Pop, 1, 0);
- sqliteVdbeAddOp(v, OP_NewRecno, base, 0);
+ int addr;
+ sqliteExprCode(pParse, pList->a[keyColumn].pExpr);
+
+ /* If the PRIMARY KEY expression is NULL, then use OP_NewRecno
+ ** to generate a unique primary key value.
+ */
+ addr = sqliteVdbeAddOp(v, OP_Dup, 0, 1);
+ sqliteVdbeAddOp(v, OP_NotNull, 0, addr+4);
+ sqliteVdbeAddOp(v, OP_Pop, 1, 0);
+ sqliteVdbeAddOp(v, OP_NewRecno, base, 0);
}
sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
}else{
*/
for(i=0; i<pTab->nCol; i++){
if( i==pTab->iPKey ){
- /* The value of the INTEGER PRIMARY KEY column is always a NULL.
- ** Whenever this column is read, the record number will be substituted
- ** in its place. So will fill this column with a NULL to avoid
- ** taking up data space with information that will never be used. */
- sqliteVdbeAddOp(v, OP_String, 0, 0);
- continue;
+ /* The value of the INTEGER PRIMARY KEY column is always a NULL.
+ ** Whenever this column is read, the record number will be substituted
+ ** in its place. So will fill this column with a NULL to avoid
+ ** taking up data space with information that will never be used. */
+ sqliteVdbeAddOp(v, OP_String, 0, 0);
+ continue;
}
if( pColumn==0 ){
- j = i;
+ j = i;
}else{
- for(j=0; j<pColumn->nId; j++){
- if( pColumn->a[j].idx==i ) break;
- }
+ for(j=0; j<pColumn->nId; j++){
+ if( pColumn->a[j].idx==i ) break;
+ }
}
if( pColumn && j>=pColumn->nId ){
- sqliteVdbeAddOp(v, OP_String, 0, 0);
- sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC);
+ sqliteVdbeAddOp(v, OP_String, 0, 0);
+ sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC);
}else if( srcTab>=0 ){
- sqliteVdbeAddOp(v, OP_Column, srcTab, j);
+ sqliteVdbeAddOp(v, OP_Column, srcTab, j);
}else{
- sqliteExprCode(pParse, pList->a[j].pExpr);
+ sqliteExprCode(pParse, pList->a[j].pExpr);
}
}
if (!pTab->pSelect) {
sqliteVdbeAddOp(v, OP_Close, base, 0);
for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){
- sqliteVdbeAddOp(v, OP_Close, idx+base, 0);
+ sqliteVdbeAddOp(v, OP_Close, idx+base, 0);
}
}
/* Code AFTER triggers */
if (
- sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_AFTER, pTab, newIdx, -1,
- onError)
+ sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_AFTER, pTab, newIdx, -1,
+ onError)
) goto insert_cleanup;
}
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.72 2002/05/15 08:30:13 danielk1977 Exp $
+** $Id: main.c,v 1.73 2002/05/15 11:44:14 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
assert(pTab);
if (pTab->isTemp) {
sqliteHashInsert(&db->trigHash, pTrigger->name, strlen(pTrigger->name),
- pTrigger);
+ pTrigger);
} else {
sqliteDeleteTrigger(pTrigger);
}
while( *zSql && *zSql!='\n' ){ zSql++; }
if( *zSql==0 ) return isComplete;
break;
- }
+ }
default: {
- if (seenCreate && !sqliteStrNICmp(zSql, "trigger", 7))
- while (sqliteStrNICmp(zSql, "end", 3))
- if (!*++zSql) return 0;
-
+ if (seenCreate && !sqliteStrNICmp(zSql, "trigger", 7)){
+ while (sqliteStrNICmp(zSql, "end", 3)){
+ if (!*++zSql) return 0;
+ }
+ }
if (!sqliteStrNICmp(zSql, "create", 6)) {
- zSql = zSql + 5;
- seenCreate = 1;
- } else
- seenCreate = 0;
-
+ zSql = zSql + 5;
+ seenCreate = 1;
+ }else{
+ seenCreate = 0;
+ }
isComplete = 0;
break;
}
* Note: this code is harmless on little-endian machines.
*/
static void byteReverse (unsigned char *buf, unsigned longs){
- uint32 t;
- do {
- t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
- ((unsigned)buf[1]<<8 | buf[0]);
- *(uint32 *)buf = t;
- buf += 4;
- } while (--longs);
+ uint32 t;
+ do {
+ t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
+ ((unsigned)buf[1]<<8 | buf[0]);
+ *(uint32 *)buf = t;
+ buf += 4;
+ } while (--longs);
}
/* The four core functions - F1 is optimized somewhat */
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* the data and converts bytes into longwords for this routine.
*/
static void MD5Transform(uint32 buf[4], const uint32 in[16]){
- register uint32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+ register uint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
/*
*/
static void MD5Init(MD5Context *pCtx){
struct Context *ctx = (struct Context *)pCtx;
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
}
/*
static
void MD5Update(MD5Context *pCtx, const unsigned char *buf, unsigned int len){
struct Context *ctx = (struct Context *)pCtx;
- uint32 t;
+ uint32 t;
- /* Update bitcount */
+ /* Update bitcount */
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
- /* Handle any leading odd-sized chunks */
+ /* Handle any leading odd-sized chunks */
- if ( t ) {
- unsigned char *p = (unsigned char *)ctx->in + t;
+ if ( t ) {
+ unsigned char *p = (unsigned char *)ctx->in + t;
- t = 64-t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
- }
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
- buf += t;
- len -= t;
- }
+ t = 64-t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+ buf += t;
+ len -= t;
+ }
- /* Process data in 64-byte chunks */
+ /* Process data in 64-byte chunks */
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
- buf += 64;
- len -= 64;
- }
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+ buf += 64;
+ len -= 64;
+ }
- /* Handle any remaining bytes of data. */
+ /* Handle any remaining bytes of data. */
- memcpy(ctx->in, buf, len);
+ memcpy(ctx->in, buf, len);
}
/*
*/
static void MD5Final(unsigned char digest[16], MD5Context *pCtx){
struct Context *ctx = (struct Context *)pCtx;
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count-8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0];
- ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32 *)ctx->in);
- byteReverse((unsigned char *)ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count-8);
+ }
+ byteReverse(ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0];
+ ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32 *)ctx->in);
+ byteReverse((unsigned char *)ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
/*
case etORDINAL:
case etRADIX:
if( flag_long ) longvalue = va_arg(ap,long);
- else longvalue = va_arg(ap,int);
+ else longvalue = va_arg(ap,int);
#ifdef etCOMPATIBILITY
/* For the format %#x, the value zero is printed "0" not "0x0".
** I think this is stupid. */
}else prefix = 0;
if( flag_zeropad && precision<width-(prefix!=0) ){
precision = width-(prefix!=0);
- }
+ }
bufpt = &buf[etBUFSIZE];
if( xtype==etORDINAL ){
long a,b;
*(--bufpt) = cset[longvalue%base];
longvalue = longvalue/base;
}while( longvalue>0 );
- }
+ }
length = (long)&buf[etBUFSIZE]-(long)bufpt;
for(idx=precision-length; idx>0; idx--){
*(--bufpt) = '0'; /* Zero pad */
- }
+ }
if( prefix ) *(--bufpt) = prefix; /* Add sign */
if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
char *pre, x;
pre = infop->prefix;
if( *bufpt!=pre[0] ){
for(pre=infop->prefix; (x=(*pre))!=0; pre++) *(--bufpt) = x;
- }
+ }
}
length = (long)&buf[etBUFSIZE]-(long)bufpt;
break;
if( realvalue<0.0 ){
realvalue = -realvalue;
prefix = '-';
- }else{
+ }else{
if( flag_plussign ) prefix = '+';
else if( flag_blanksign ) prefix = ' ';
else prefix = 0;
- }
+ }
if( infop->type==etGENERIC && precision>0 ) precision--;
rounder = 0.0;
#ifdef COMPATIBILITY
length = 3;
break;
}
- }
+ }
bufpt = buf;
/*
** If the field type is etGENERIC, then convert to either etEXP
precision = precision - exp;
xtype = etFLOAT;
}
- }else{
+ }else{
flag_rtz = 0;
- }
+ }
/*
** The "exp+precision" test causes output to be of type etEXP if
** the precision is too large to fit in buf[].
if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0;
}
bufpt++; /* point to next free slot */
- }else{ /* etEXP or etGENERIC */
+ }else{ /* etEXP or etGENERIC */
flag_dp = (precision>0 || flag_alternateform);
if( prefix ) *(bufpt++) = prefix; /* Sign */
*(bufpt++) = et_getdigit(&realvalue,&nsd); /* First digit */
if( exp>=100 ){
*(bufpt++) = (exp/100)+'0'; /* 100's digit */
exp %= 100;
- }
+ }
*(bufpt++) = exp/10+'0'; /* 10's digit */
*(bufpt++) = exp%10+'0'; /* 1's digit */
}
- }
+ }
/* The converted number is in buf[] and zero terminated. Output it.
** Note that the number is in the usual order, not reversed as with
** integer conversions. */
if( precision>=0 ){
for(idx=1; idx<precision; idx++) buf[idx] = c;
length = precision;
- }else{
+ }else{
length =1;
- }
+ }
bufpt = buf;
break;
case etSTRING:
nspace = nspace/2;
width -= nspace;
flag_leftjustify = 1;
- }
+ }
count += nspace;
while( nspace>=etSPACESIZE ){
(*func)(arg,spaces,etSPACESIZE);
/*
- * All copyright on this work is disclaimed by the author.
- *
- */
-
+** All copyright on this work is disclaimed by the author.
+*/
#include "sqliteInt.h"
+
/*
- * This is called by the parser when it sees a CREATE TRIGGER statement
- */
-void
-sqliteCreateTrigger(
- Parse * pParse, /* The parse context of the CREATE TRIGGER statement */
- Token * nm, /* The name of the trigger */
- int tr_tm, /* One of TK_BEFORE, TK_AFTER */
- int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
- IdList * cols, /* column list if this is an UPDATE OF trigger */
- Token * tbl, /* The name of the table/view the trigger applies to */
- int foreach, /* One of TK_ROW or TK_STATEMENT */
- Expr * pWhen, /* WHEN clause */
- TriggerStep * steps, /* The triggered program */
- char const * cc, int len) /* The string data to make persistent */
-{
- Trigger * nt;
- Table * tab;
+** This is called by the parser when it sees a CREATE TRIGGER statement
+*/
+void sqliteCreateTrigger(
+ Parse *pParse, /* The parse context of the CREATE TRIGGER statement */
+ Token *nm, /* The name of the trigger */
+ int tr_tm, /* One of TK_BEFORE, TK_AFTER */
+ int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
+ IdList *cols, /* column list if this is an UPDATE OF trigger */
+ Token *tbl, /* The name of the table/view the trigger applies to */
+ int foreach, /* One of TK_ROW or TK_STATEMENT */
+ Expr *pWhen, /* WHEN clause */
+ TriggerStep *steps, /* The triggered program */
+ char const *cc, /* The string data to make persistent */
+ int len
+){
+ Trigger *nt;
+ Table *tab;
int offset;
- TriggerStep * ss;
+ TriggerStep *ss;
/* Check that:
- 1. the trigger name does not already exist.
- 2. the table (or view) does exist.
- */
+ ** 1. the trigger name does not already exist.
+ ** 2. the table (or view) does exist.
+ */
{
- char * tmp_str = sqliteStrNDup(nm->z, nm->n);
- if (sqliteHashFind(&(pParse->db->trigHash), tmp_str, nm->n + 1)) {
+ char *tmp_str = sqliteStrNDup(nm->z, nm->n);
+ if( sqliteHashFind(&(pParse->db->trigHash), tmp_str, nm->n + 1) ){
sqliteSetNString(&pParse->zErrMsg, "trigger ", -1,
- nm->z, nm->n, " already exists", -1, 0);
+ nm->z, nm->n, " already exists", -1, 0);
sqliteFree(tmp_str);
pParse->nErr++;
goto trigger_cleanup;
sqliteFree(tmp_str);
}
{
- char * tmp_str = sqliteStrNDup(tbl->z, tbl->n);
+ char *tmp_str = sqliteStrNDup(tbl->z, tbl->n);
tab = sqliteFindTable(pParse->db, tmp_str);
sqliteFree(tmp_str);
- if (!tab) {
+ if( !tab ){
sqliteSetNString(&pParse->zErrMsg, "no such table: ", -1,
- tbl->z, tbl->n, 0);
+ tbl->z, tbl->n, 0);
pParse->nErr++;
goto trigger_cleanup;
}
}
/* Build the Trigger object */
- nt = (Trigger *)sqliteMalloc(sizeof(Trigger));
-
+ nt = (Trigger*)sqliteMalloc(sizeof(Trigger));
nt->name = sqliteStrNDup(nm->z, nm->n);
nt->table = sqliteStrNDup(tbl->z, tbl->n);
nt->op = op;
}
/* if we are not initializing, and this trigger is not on a TEMP table,
- build the sqlite_master entry */
- if (!pParse->initFlag && !tab->isTemp) {
+ ** build the sqlite_master entry
+ */
+ if( !pParse->initFlag && !tab->isTemp ){
/* Make an entry in the sqlite_master table */
sqliteBeginWriteOperation(pParse);
trig = sqliteHashFind(&(pParse->db->trigHash), tmp_name, trigname->n + 1);
if (!trig) {
sqliteSetNString(&pParse->zErrMsg, "no such trigger: ", -1,
- tmp_name, -1, 0);
+ tmp_name, -1, 0);
sqliteFree(tmp_name);
return;
}
else {
Trigger * cc = tbl->pTrigger;
while (cc) {
- if (cc->pNext == trig) {
- cc->pNext = cc->pNext->pNext;
- break;
- }
- cc = cc->pNext;
+ if (cc->pNext == trig) {
+ cc->pNext = cc->pNext->pNext;
+ break;
+ }
+ cc = cc->pNext;
}
assert(cc);
}
/* 2 */
sqliteHashInsert(&(pParse->db->trigHash), tmp_name,
- trigname->n + 1, NULL);
+ trigname->n + 1, NULL);
sqliteHashInsert(&(pParse->db->trigDrop), trig->name,
- trigname->n + 1, trig);
+ trigname->n + 1, trig);
}
/* Unless this is a trigger on a TEMP TABLE, generate code to destroy the
sqliteBeginWriteOperation(pParse);
base = sqliteVdbeAddOpList(pParse->pVdbe,
- ArraySize(dropTrigger), dropTrigger);
+ ArraySize(dropTrigger), dropTrigger);
sqliteVdbeChangeP3(pParse->pVdbe, base+2, tmp_name, 0);
if (!nested)
for (i = 0; i < ii->nId; i++)
for (e = 0; e < ee->nExpr; e++)
if (!sqliteStrICmp(ii->a[i].zName, ee->a[e].zName))
- return 1;
+ return 1;
return 0;
}
tt = pTrigger;
while (tt) {
if (tt->op == op && tt->tr_tm == tr_tm && tt->foreach == foreach &&
- checkColumnOverLap(tt->pColumns, pChanges)) {
+ checkColumnOverLap(tt->pColumns, pChanges)) {
TriggerStack * ss;
ss = pParse->trigStack;
while (ss && ss->pTrigger != pTrigger) ss = ss->pNext;
}
static int codeTriggerProgram(
- Parse *pParse,
- TriggerStep * program,
- int onError)
+ Parse *pParse,
+ TriggerStep * program,
+ int onError)
{
TriggerStep * step = program;
int orconf;
while (step) {
- int saveNTab = pParse->nTab;
- orconf = (onError == OE_Default)?step->orconf:onError;
- pParse->trigStack->orconf = orconf;
- switch(step->op) {
- case TK_SELECT: {
+ int saveNTab = pParse->nTab;
+ orconf = (onError == OE_Default)?step->orconf:onError;
+ pParse->trigStack->orconf = orconf;
+ switch(step->op) {
+ case TK_SELECT: {
int tmp_tbl = pParse->nTab++;
- sqliteVdbeAddOp(pParse->pVdbe, OP_OpenTemp, tmp_tbl, 0);
- sqliteVdbeAddOp(pParse->pVdbe, OP_KeyAsData, tmp_tbl, 1);
- sqliteSelect(pParse, step->pSelect,
- SRT_Union, tmp_tbl, 0, 0, 0);
- sqliteVdbeAddOp(pParse->pVdbe, OP_Close, tmp_tbl, 0);
- pParse->nTab--;
- break;
- }
- case TK_UPDATE: {
+ sqliteVdbeAddOp(pParse->pVdbe, OP_OpenTemp, tmp_tbl, 0);
+ sqliteVdbeAddOp(pParse->pVdbe, OP_KeyAsData, tmp_tbl, 1);
+ sqliteSelect(pParse, step->pSelect,
+ SRT_Union, tmp_tbl, 0, 0, 0);
+ sqliteVdbeAddOp(pParse->pVdbe, OP_Close, tmp_tbl, 0);
+ pParse->nTab--;
+ break;
+ }
+ case TK_UPDATE: {
sqliteVdbeAddOp(pParse->pVdbe, OP_PushList, 0, 0);
- sqliteUpdate(pParse, &step->target,
- sqliteExprListDup(step->pExprList),
- sqliteExprDup(step->pWhere), orconf);
+ sqliteUpdate(pParse, &step->target,
+ sqliteExprListDup(step->pExprList),
+ sqliteExprDup(step->pWhere), orconf);
sqliteVdbeAddOp(pParse->pVdbe, OP_PopList, 0, 0);
- break;
- }
- case TK_INSERT: {
+ break;
+ }
+ case TK_INSERT: {
sqliteInsert(pParse, &step->target,
- sqliteExprListDup(step->pExprList),
- sqliteSelectDup(step->pSelect),
- sqliteIdListDup(step->pIdList), orconf);
- break;
- }
- case TK_DELETE: {
- sqliteVdbeAddOp(pParse->pVdbe, OP_PushList, 0, 0);
+ sqliteExprListDup(step->pExprList),
+ sqliteSelectDup(step->pSelect),
+ sqliteIdListDup(step->pIdList), orconf);
+ break;
+ }
+ case TK_DELETE: {
+ sqliteVdbeAddOp(pParse->pVdbe, OP_PushList, 0, 0);
sqliteDeleteFrom(pParse, &step->target,
- sqliteExprDup(step->pWhere)
- );
- sqliteVdbeAddOp(pParse->pVdbe, OP_PopList, 0, 0);
- break;
- }
- default:
- assert(0);
- }
- pParse->nTab = saveNTab;
- step = step->pNext;
+ sqliteExprDup(step->pWhere)
+ );
+ sqliteVdbeAddOp(pParse->pVdbe, OP_PopList, 0, 0);
+ break;
+ }
+ default:
+ assert(0);
+ }
+ pParse->nTab = saveNTab;
+ step = step->pNext;
}
return 0;
}
int sqliteCodeRowTrigger(
- Parse * pParse, /* Parse context */
- int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
- ExprList * changes, /* Changes list for any UPDATE OF triggers */
- int tr_tm, /* One of TK_BEFORE, TK_AFTER */
- Table * tbl, /* The table to code triggers from */
- int newTable, /* The indice of the "new" row to access */
- int oldTable, /* The indice of the "old" row to access */
- int onError) /* ON CONFLICT policy */
+ Parse * pParse, /* Parse context */
+ int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
+ ExprList * changes, /* Changes list for any UPDATE OF triggers */
+ int tr_tm, /* One of TK_BEFORE, TK_AFTER */
+ Table * tbl, /* The table to code triggers from */
+ int newTable, /* The indice of the "new" row to access */
+ int oldTable, /* The indice of the "old" row to access */
+ int onError) /* ON CONFLICT policy */
{
Trigger * pTrigger;
TriggerStack * pTriggerStack;
/* determine whether we should code this trigger */
if (pTrigger->op == op && pTrigger->tr_tm == tr_tm &&
- pTrigger->foreach == TK_ROW) {
+ pTrigger->foreach == TK_ROW) {
fire_this = 1;
pTriggerStack = pParse->trigStack;
while (pTriggerStack) {
- if (pTriggerStack->pTrigger == pTrigger) fire_this = 0;
- pTriggerStack = pTriggerStack->pNext;
+ if (pTriggerStack->pTrigger == pTrigger) fire_this = 0;
+ pTriggerStack = pTriggerStack->pNext;
}
if (op == TK_UPDATE && pTrigger->pColumns &&
- !checkColumnOverLap(pTrigger->pColumns, changes))
- fire_this = 0;
+ !checkColumnOverLap(pTrigger->pColumns, changes))
+ fire_this = 0;
}
if (fire_this) {
endTrigger = sqliteVdbeMakeLabel(pParse->pVdbe);
whenExpr = sqliteExprDup(pTrigger->pWhen);
if (sqliteExprResolveIds(pParse, 0, &dummyTablist, 0, whenExpr)) {
- pParse->trigStack = pParse->trigStack->pNext;
- sqliteFree(pTriggerStack);
- sqliteExprDelete(whenExpr);
- return 1;
+ pParse->trigStack = pParse->trigStack->pNext;
+ sqliteFree(pTriggerStack);
+ sqliteExprDelete(whenExpr);
+ return 1;
}
sqliteExprIfFalse(pParse, whenExpr, endTrigger);
sqliteExprDelete(whenExpr);
for(ii=0; ii<pChanges->nExpr; ii++){
int jj;
if( sqliteExprResolveIds(pParse, oldIdx, theSelect.pSrc , 0,
- pChanges->a[ii].pExpr) )
- goto trigger_cleanup;
+ pChanges->a[ii].pExpr) )
+ goto trigger_cleanup;
if( sqliteExprCheck(pParse, pChanges->a[ii].pExpr, 0, 0) )
- goto trigger_cleanup;
+ goto trigger_cleanup;
for(jj=0; jj<pTab->nCol; jj++){
- if( sqliteStrICmp(pTab->aCol[jj].zName, pChanges->a[ii].zName)==0 ){
- aXRef[jj] = ii;
- break;
- }
+ if( sqliteStrICmp(pTab->aCol[jj].zName, pChanges->a[ii].zName)==0 ){
+ aXRef[jj] = ii;
+ break;
+ }
}
if( jj>=pTab->nCol ){
- sqliteSetString(&pParse->zErrMsg, "no such column: ",
- pChanges->a[ii].zName, 0);
- pParse->nErr++;
- goto trigger_cleanup;
+ sqliteSetString(&pParse->zErrMsg, "no such column: ",
+ pChanges->a[ii].zName, 0);
+ pParse->nErr++;
+ goto trigger_cleanup;
}
}
for (ii = 0; ii < pTab->nCol; ii++)
if( aXRef[ii] < 0 )
- sqliteVdbeAddOp(v, OP_Column, oldIdx, ii);
+ sqliteVdbeAddOp(v, OP_Column, oldIdx, ii);
else
- sqliteExprCode(pParse, pChanges->a[aXRef[ii]].pExpr);
+ sqliteExprCode(pParse, pChanges->a[aXRef[ii]].pExpr);
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0);
sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0);
sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE,
- pTab, newIdx, oldIdx, onError);
+ pTab, newIdx, oldIdx, onError);
sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER,
- pTab, newIdx, oldIdx, onError);
+ pTab, newIdx, oldIdx, onError);
} else {
sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, oldIdx,
- onError);
+ onError);
sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, oldIdx,
- onError);
+ onError);
}
sqliteVdbeAddOp(v, OP_Next, oldIdx, startOfLoop);
sqliteExprDelete(theSelect.pWhere);
return;
}
-
-
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
-** $Id: update.c,v 1.37 2002/05/15 08:30:14 danielk1977 Exp $
+** $Id: update.c,v 1.38 2002/05/15 11:44:15 drh Exp $
*/
#include "sqliteInt.h"
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);
+ 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);
}
sqliteFree(zTab);
if (row_triggers_exist && pTab->pSelect ) {
- /* Just fire VIEW triggers */
- sqliteViewTriggers(pParse, pTab, pWhere, onError, pChanges);
- return;
+ /* Just fire VIEW triggers */
+ sqliteViewTriggers(pParse, pTab, pWhere, onError, pChanges);
+ return;
}
}
}
sqliteVdbeAddOp(v, OP_Integer, 13, 0);
for (ii = 0; ii < pTab->nCol; ii++) {
- if (ii == pTab->iPKey)
- sqliteVdbeAddOp(v, OP_Recno, base, 0);
- else
- sqliteVdbeAddOp(v, OP_Column, base, ii);
+ if (ii == pTab->iPKey)
+ sqliteVdbeAddOp(v, OP_Recno, base, 0);
+ else
+ sqliteVdbeAddOp(v, OP_Column, base, ii);
}
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0);
if (sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE, pTab,
- newIdx, oldIdx, onError)) goto update_cleanup;
+ newIdx, oldIdx, onError)) goto update_cleanup;
}
/* Rewind the list of records that need to be updated and
if (row_triggers_exist) {
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
if( openAll || aIdxUsed[i] )
- sqliteVdbeAddOp(v, OP_Close, base+i+1, 0);
+ sqliteVdbeAddOp(v, OP_Close, base+i+1, 0);
}
sqliteVdbeAddOp(v, OP_Close, base, 0);
pParse->nTab = base;
if (sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER, pTab,
- newIdx, oldIdx, onError)) goto update_cleanup;
+ newIdx, oldIdx, onError)) goto update_cleanup;
}
/* Repeat the above with the next record to be updated, until
if (!row_triggers_exist) {
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
if( openAll || aIdxUsed[i] ){
- sqliteVdbeAddOp(v, OP_Close, base+i+1, 0);
+ sqliteVdbeAddOp(v, OP_Close, base+i+1, 0);
}
}
sqliteVdbeAddOp(v, OP_Close, base, 0);
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
-** $Id: vdbe.c,v 1.142 2002/05/15 08:30:14 danielk1977 Exp $
+** $Id: vdbe.c,v 1.143 2002/05/15 11:44:15 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
p->keylistStackDepth++;
assert(p->keylistStackDepth > 0);
p->keylistStack = sqliteRealloc(p->keylistStack,
- sizeof(Keylist *) * p->keylistStackDepth);
+ sizeof(Keylist *) * p->keylistStackDepth);
p->keylistStack[p->keylistStackDepth - 1] = p->pList;
p->pList = 0;
break;
** the WHERE clause of SQL statements. Also found here are subroutines
** to generate VDBE code to evaluate expressions.
**
-** $Id: where.c,v 1.42 2002/05/15 08:30:14 danielk1977 Exp $
+** $Id: where.c,v 1.43 2002/05/15 11:44:15 drh Exp $
*/
#include "sqliteInt.h"
for(i=0; i<nExpr; i++){
exprAnalyze(base, &aExpr[i]);
if (pParse->trigStack && pParse->trigStack->newIdx >= 0) {
- aExpr[i].prereqRight =
- aExpr[i].prereqRight & ~(1 << pParse->trigStack->newIdx - base);
- aExpr[i].prereqLeft =
- aExpr[i].prereqLeft & ~(1 << pParse->trigStack->newIdx - base);
- aExpr[i].prereqAll =
- aExpr[i].prereqAll & ~(1 << pParse->trigStack->newIdx - base);
+ aExpr[i].prereqRight =
+ aExpr[i].prereqRight & ~(1 << pParse->trigStack->newIdx - base);
+ aExpr[i].prereqLeft =
+ aExpr[i].prereqLeft & ~(1 << pParse->trigStack->newIdx - base);
+ aExpr[i].prereqAll =
+ aExpr[i].prereqAll & ~(1 << pParse->trigStack->newIdx - base);
}
if (pParse->trigStack && pParse->trigStack->oldIdx >= 0) {
- aExpr[i].prereqRight =
- aExpr[i].prereqRight & ~(1 << pParse->trigStack->oldIdx - base);
- aExpr[i].prereqLeft =
- aExpr[i].prereqLeft & ~(1 << pParse->trigStack->oldIdx - base);
- aExpr[i].prereqAll =
- aExpr[i].prereqAll & ~(1 << pParse->trigStack->oldIdx - base);
+ aExpr[i].prereqRight =
+ aExpr[i].prereqRight & ~(1 << pParse->trigStack->oldIdx - base);
+ aExpr[i].prereqLeft =
+ aExpr[i].prereqLeft & ~(1 << pParse->trigStack->oldIdx - base);
+ aExpr[i].prereqAll =
+ aExpr[i].prereqAll & ~(1 << pParse->trigStack->oldIdx - base);
}
}