aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c4
-rw-r--r--src/build.c44
-rw-r--r--src/delete.c34
-rw-r--r--src/insert.c82
-rw-r--r--src/main.c25
-rw-r--r--src/md5.c322
-rw-r--r--src/printf.c32
-rw-r--r--src/trigger.c241
-rw-r--r--src/update.c34
-rw-r--r--src/vdbe.c4
-rw-r--r--src/where.c26
11 files changed, 423 insertions, 425 deletions
diff --git a/src/btree.c b/src/btree.c
index 7a3908994..f096e5f62 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -9,7 +9,7 @@
** 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
@@ -2564,7 +2564,7 @@ int sqliteBtreeUpdateMeta(Btree *pBt, int *aMeta){
}
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;
}
diff --git a/src/build.c b/src/build.c
index aff5d51bf..c41b1cf03 100644
--- a/src/build.c
+++ b/src/build.c
@@ -25,7 +25,7 @@
** 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>
@@ -324,26 +324,26 @@ void sqliteRollbackInternalChanges(sqlite *db){
/* 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);
}
@@ -355,7 +355,7 @@ void sqliteRollbackInternalChanges(sqlite *db){
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;
@@ -2116,8 +2116,8 @@ void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
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
diff --git a/src/delete.c b/src/delete.c
index 2d04100eb..829be31ad 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -12,7 +12,7 @@
** 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"
@@ -103,17 +103,17 @@ void sqliteDeleteFrom(
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;
}
}
}
@@ -223,10 +223,10 @@ void sqliteDeleteFrom(
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);
@@ -234,7 +234,7 @@ void sqliteDeleteFrom(
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;
@@ -251,11 +251,11 @@ void sqliteDeleteFrom(
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);
@@ -264,7 +264,7 @@ void sqliteDeleteFrom(
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;
diff --git a/src/insert.c b/src/insert.c
index 017407130..50b22d99f 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -12,7 +12,7 @@
** 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"
@@ -76,7 +76,7 @@ void sqliteInsert(
*/
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,
@@ -243,19 +243,19 @@ void sqliteInsert(
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);
@@ -265,7 +265,7 @@ void sqliteInsert(
/* 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 */
@@ -275,8 +275,8 @@ void sqliteInsert(
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;
}
@@ -290,18 +290,18 @@ void sqliteInsert(
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{
@@ -313,27 +313,27 @@ void sqliteInsert(
*/
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);
}
}
@@ -356,14 +356,14 @@ void sqliteInsert(
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;
}
diff --git a/src/main.c b/src/main.c
index 1a85ae3c5..3d277e829 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
** 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"
@@ -399,7 +399,7 @@ static void clearHashTable(sqlite *db, int preserveTemps){
assert(pTab);
if (pTab->isTemp) {
sqliteHashInsert(&db->trigHash, pTrigger->name, strlen(pTrigger->name),
- pTrigger);
+ pTrigger);
} else {
sqliteDeleteTrigger(pTrigger);
}
@@ -521,18 +521,19 @@ int sqlite_complete(const char *zSql){
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;
}
diff --git a/src/md5.c b/src/md5.c
index 9e791f2fa..1fd70167b 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -55,13 +55,13 @@ typedef char MD5Context[88];
* 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 */
@@ -73,7 +73,7 @@ static void byteReverse (unsigned char *buf, unsigned longs){
/* 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
@@ -81,85 +81,85 @@ static void byteReverse (unsigned char *buf, unsigned longs){
* 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;
}
/*
@@ -168,12 +168,12 @@ static void MD5Transform(uint32 buf[4], const uint32 in[16]){
*/
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;
}
/*
@@ -183,47 +183,47 @@ static void MD5Init(MD5Context *pCtx){
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);
}
/*
@@ -232,43 +232,43 @@ void MD5Update(MD5Context *pCtx, const unsigned char *buf, unsigned int 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 */
}
/*
diff --git a/src/printf.c b/src/printf.c
index 3a765600e..8cc511a07 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -336,7 +336,7 @@ static int vxprintf(
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. */
@@ -356,7 +356,7 @@ static int vxprintf(
}else prefix = 0;
if( flag_zeropad && precision<width-(prefix!=0) ){
precision = width-(prefix!=0);
- }
+ }
bufpt = &buf[etBUFSIZE];
if( xtype==etORDINAL ){
long a,b;
@@ -386,18 +386,18 @@ static int vxprintf(
*(--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;
@@ -411,11 +411,11 @@ static int vxprintf(
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
@@ -439,7 +439,7 @@ static int vxprintf(
length = 3;
break;
}
- }
+ }
bufpt = buf;
/*
** If the field type is etGENERIC, then convert to either etEXP
@@ -458,9 +458,9 @@ static int vxprintf(
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[].
@@ -482,7 +482,7 @@ static int vxprintf(
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 */
@@ -501,11 +501,11 @@ static int vxprintf(
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. */
@@ -541,9 +541,9 @@ static int vxprintf(
if( precision>=0 ){
for(idx=1; idx<precision; idx++) buf[idx] = c;
length = precision;
- }else{
+ }else{
length =1;
- }
+ }
bufpt = buf;
break;
case etSTRING:
@@ -599,7 +599,7 @@ static int vxprintf(
nspace = nspace/2;
width -= nspace;
flag_leftjustify = 1;
- }
+ }
count += nspace;
while( nspace>=etSPACESIZE ){
(*func)(arg,spaces,etSPACESIZE);
diff --git a/src/trigger.c b/src/trigger.c
index 8ad7027a1..044ef254d 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -1,39 +1,38 @@
/*
- * 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;
@@ -41,20 +40,19 @@ sqliteCreateTrigger(
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;
@@ -81,8 +79,9 @@ sqliteCreateTrigger(
}
/* 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);
@@ -247,7 +246,7 @@ void sqliteDropTrigger(Parse *pParse, Token * trigname, int nested)
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;
}
@@ -266,20 +265,20 @@ void sqliteDropTrigger(Parse *pParse, Token * trigname, int nested)
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
@@ -305,7 +304,7 @@ void sqliteDropTrigger(Parse *pParse, Token * trigname, int nested)
sqliteBeginWriteOperation(pParse);
base = sqliteVdbeAddOpList(pParse->pVdbe,
- ArraySize(dropTrigger), dropTrigger);
+ ArraySize(dropTrigger), dropTrigger);
sqliteVdbeChangeP3(pParse->pVdbe, base+2, tmp_name, 0);
if (!nested)
@@ -329,7 +328,7 @@ static int checkColumnOverLap(IdList * ii, ExprList * ee)
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;
}
@@ -364,7 +363,7 @@ int sqliteTriggersExist(
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;
@@ -377,70 +376,70 @@ int sqliteTriggersExist(
}
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;
@@ -457,16 +456,16 @@ int sqliteCodeRowTrigger(
/* 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) {
@@ -490,10 +489,10 @@ int sqliteCodeRowTrigger(
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);
@@ -582,23 +581,23 @@ void sqliteViewTriggers(Parse *pParse, Table *pTab,
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;
}
}
@@ -606,23 +605,23 @@ void sqliteViewTriggers(Parse *pParse, Table *pTab,
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);
@@ -639,5 +638,3 @@ trigger_cleanup:
sqliteExprDelete(theSelect.pWhere);
return;
}
-
-
diff --git a/src/update.c b/src/update.c
index f729f950f..a7dda4d47 100644
--- a/src/update.c
+++ b/src/update.c
@@ -12,7 +12,7 @@
** 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"
@@ -64,17 +64,17 @@ void sqliteUpdate(
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;
}
}
}
@@ -213,10 +213,10 @@ void sqliteUpdate(
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);
@@ -240,7 +240,7 @@ void sqliteUpdate(
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
@@ -340,13 +340,13 @@ void sqliteUpdate(
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
@@ -360,7 +360,7 @@ void sqliteUpdate(
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);
diff --git a/src/vdbe.c b/src/vdbe.c
index a7a12af12..3fc328ec6 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -30,7 +30,7 @@
** 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>
@@ -4560,7 +4560,7 @@ case OP_PushList: {
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;
diff --git a/src/where.c b/src/where.c
index 1bf6f25ee..9f95e2819 100644
--- a/src/where.c
+++ b/src/where.c
@@ -13,7 +13,7 @@
** 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"
@@ -217,20 +217,20 @@ WhereInfo *sqliteWhereBegin(
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);
}
}