Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | SQLite 3.3.5 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
3c0bd4f9c11c437349608d246cacb99b |
User & Date: | rmsimpson 2006-04-11 18:06:57 |
2006-04-11
| ||
19:44 | 3.3.5 codec changes check-in: c9d926d514 user: rmsimpson tags: sourceforge | |
18:06 | SQLite 3.3.5 check-in: 3c0bd4f9c1 user: rmsimpson tags: sourceforge | |
18:03 | Minor updates check-in: 5f0ab8e135 user: rmsimpson tags: sourceforge | |
Changes to SQLite.Interop/src/alter.c.
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 used to generate VDBE code ** that implements the ALTER TABLE command. ** ** $Id: alter.c,v 1.19 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The code in this file only exists if we are not omitting the ** ALTER TABLE logic from the build. |
| |
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 used to generate VDBE code ** that implements the ALTER TABLE command. ** ** $Id: alter.c,v 1.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The code in this file only exists if we are not omitting the ** ALTER TABLE logic from the build. |
Changes to SQLite.Interop/src/analyze.c.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
** 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. ** ************************************************************************* ** This file contains code associated with the ANALYZE command. ** ** @(#) $Id: analyze.c,v 1.12 2006/02/11 14:43:38 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_ANALYZE #include "sqliteInt.h" /* ** This routine generates code that opens the sqlite_stat1 table on cursor ** iStatCur. |
| |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
** 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. ** ************************************************************************* ** This file contains code associated with the ANALYZE command. ** ** @(#) $Id: analyze.c,v 1.13 2006/04/11 18:06:57 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_ANALYZE #include "sqliteInt.h" /* ** This routine generates code that opens the sqlite_stat1 table on cursor ** iStatCur. |
Changes to SQLite.Interop/src/attach.c.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
** 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. ** ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** ** $Id: attach.c,v 1.18 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Resolve an expression that was part of an ATTACH or DETACH statement. This ** is slightly different from resolving a normal SQL expression, because simple ** identifiers are treated as strings, not possible column names or aliases. ................................................................................ if( db->aDb[iDb].pBt ){ sqlite3BtreeClose(db->aDb[iDb].pBt); db->aDb[iDb].pBt = 0; db->aDb[iDb].pSchema = 0; } sqlite3ResetInternalSchema(db, 0); db->nDb = iDb; sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile); goto attach_error; } return; attach_error: /* Return an error if we get here */ |
|
>
>
>
>
|
>
|
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
** 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. ** ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** ** $Id: attach.c,v 1.19 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Resolve an expression that was part of an ATTACH or DETACH statement. This ** is slightly different from resolving a normal SQL expression, because simple ** identifiers are treated as strings, not possible column names or aliases. ................................................................................ if( db->aDb[iDb].pBt ){ sqlite3BtreeClose(db->aDb[iDb].pBt); db->aDb[iDb].pBt = 0; db->aDb[iDb].pSchema = 0; } sqlite3ResetInternalSchema(db, 0); db->nDb = iDb; if( rc==SQLITE_NOMEM ){ sqlite3MallocFailed(); sqlite3_snprintf(127, zErr, "out of memory"); }else{ sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile); } goto attach_error; } return; attach_error: /* Return an error if we get here */ |
Changes to SQLite.Interop/src/auth.c.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
** ************************************************************************* ** This file contains code used to implement the sqlite3_set_authorizer() ** API. This facility is an optional feature of the library. Embedded ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** ** $Id: auth.c,v 1.18 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** All of the code in this file may be omitted by defining a single ** macro. */ |
| |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
** ************************************************************************* ** This file contains code used to implement the sqlite3_set_authorizer() ** API. This facility is an optional feature of the library. Embedded ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** ** $Id: auth.c,v 1.19 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** All of the code in this file may be omitted by defining a single ** macro. */ |
Changes to SQLite.Interop/src/btree.c.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 ... 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 ... 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 .... 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 .... 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 .... 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 .... 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 .... 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 .... 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 .... 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 .... 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 .... 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 .... 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 .... 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 .... 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 .... 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 .... 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 .... 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 .... 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 .... 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 |
** 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. ** ************************************************************************* ** $Id: btree.c,v 1.21 2006/02/11 14:43:38 rmsimpson Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to ** ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: ** "Sorting And Searching", pages 473-480. Addison-Wesley ** Publishing Company, Reading, Massachusetts. ................................................................................ Pgno pgnoRoot; /* The root page of this tree */ MemPage *pPage; /* Page that contains the entry */ int idx; /* Index of the entry in pPage->aCell[] */ CellInfo info; /* A parse of the cell we are pointing at */ u8 wrFlag; /* True if writable */ u8 eState; /* One of the CURSOR_XXX constants (see below) */ #ifndef SQLITE_OMIT_SHARED_CACHE void *pKey; i64 nKey; int skip; /* (skip<0) -> Prev() is a no-op. (skip>0) -> Next() is */ #endif }; /* ** Potential values for BtCursor.eState. The first two values (VALID and ** INVALID) may occur in any build. The third (REQUIRESEEK) may only occur ................................................................................ /* #define getVarint32 sqlite3GetVarint32 */ #define getVarint32(A,B) ((*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) #define putVarint sqlite3PutVarint /* The database page the PENDING_BYTE occupies. This page is never used. ** TODO: This macro is very similary to PAGER_MJ_PGNO() in pager.c. They ** should possibly be consolidated (presumably in pager.h). */ #define PENDING_BYTE_PAGE(pBt) ((PENDING_BYTE/(pBt)->pageSize)+1) /* ** A linked list of the following structures is stored at BtShared.pLock. ** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor ** is opened on the table with root page BtShared.iTable. Locks are removed ** from this list when a transaction is committed or rolled back, or when ** a btree handle is closed. ................................................................................ iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap); if( rc!=0 ){ return rc; } offset = PTRMAP_PTROFFSET(pBt, key); if( pEType ) *pEType = pPtrmap[offset]; if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]); sqlite3pager_unref(pPtrmap); if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_BKPT; return SQLITE_OK; } ................................................................................ unsigned char *data = pPage->aData; assert( pPage->pBt!=0 ); assert( sqlite3pager_iswriteable(data) ); assert( start>=pPage->hdrOffset+6+(pPage->leaf?0:4) ); assert( (start + size)<=pPage->pBt->usableSize ); if( size<4 ) size = 4; /* Add the space back into the linked list of freeblocks */ hdr = pPage->hdrOffset; addr = hdr + 1; while( (pbegin = get2byte(&data[addr]))<start && pbegin>0 ){ assert( pbegin<=pPage->pBt->usableSize-4 ); assert( pbegin>addr ); ................................................................................ #endif /* ** The following asserts make sure that structures used by the btree are ** the right size. This is to guard against size changes that result ** when compiling on a different architecture. */ assert( sizeof(i64)==8 ); assert( sizeof(u64)==8 ); assert( sizeof(u32)==4 ); assert( sizeof(u16)==2 ); assert( sizeof(Pgno)==4 ); pBt = sqliteMalloc( sizeof(*pBt) ); if( pBt==0 ){ *ppBtree = 0; ................................................................................ pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0); #endif } pBt->usableSize = pBt->pageSize - nReserve; assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */ sqlite3pager_set_pagesize(pBt->pPager, pBt->pageSize); #ifndef SQLITE_OMIT_SHARED_CACHE /* Add the new btree to the linked list starting at ThreadData.pBtree. ** There is no chance that a malloc() may fail inside of the ** sqlite3ThreadData() call, as the ThreadData structure must have already ** been allocated for pTsdro->useSharedData to be non-zero. */ if( pTsdro->useSharedData && zFilename && !isMemdb ){ pBt->pNext = pTsdro->pBtree; ................................................................................ */ pTsd = (ThreadData *)sqlite3ThreadDataReadOnly(); if( pTsd->pBtree==pBt ){ assert( pTsd==sqlite3ThreadData() ); pTsd->pBtree = pBt->pNext; }else{ BtShared *pPrev; for(pPrev=pTsd->pBtree; pPrev && pPrev->pNext!=pBt; pPrev=pPrev->pNext); if( pPrev ){ assert( pTsd==sqlite3ThreadData() ); pPrev->pNext = pBt->pNext; } } #endif ................................................................................ ** truncate the database file to finSize pages and consider the ** free-list empty. */ rc = sqlite3pager_write(pBt->pPage1->aData); if( rc!=SQLITE_OK ) goto autovacuum_out; put4byte(&pBt->pPage1->aData[32], 0); put4byte(&pBt->pPage1->aData[36], 0); if( rc!=SQLITE_OK ) goto autovacuum_out; *nTrunc = finSize; assert( finSize!=PENDING_BYTE_PAGE(pBt) ); autovacuum_out: assert( nRef==*sqlite3pager_stats(pPager) ); if( rc!=SQLITE_OK ){ sqlite3pager_rollback(pPager); ................................................................................ pPage->pParent = 0; /* Increment the free page count on pPage1 */ rc = sqlite3pager_write(pPage1->aData); if( rc ) return rc; n = get4byte(&pPage1->aData[36]); put4byte(&pPage1->aData[36], n+1); #ifndef SQLITE_OMIT_AUTOVACUUM /* If the database supports auto-vacuum, write an entry in the pointer-map ** to indicate that the page is free. */ if( pBt->autoVacuum ){ rc = ptrmapPut(pBt, pPage->pgno, PTRMAP_FREEPAGE, 0); ................................................................................ pPage->pgno, pTrunk->pgno)); }else{ /* Add the newly freed page as a leaf on the current trunk */ rc = sqlite3pager_write(pTrunk->aData); if( rc ) return rc; put4byte(&pTrunk->aData[4], k+1); put4byte(&pTrunk->aData[8+k*4], pPage->pgno); sqlite3pager_dont_write(pBt->pPager, pPage->pgno); TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno)); } releasePage(pTrunk); } return rc; } ................................................................................ put4byte(pPrior, 0); pPayload = &pOvfl->aData[4]; spaceLeft = pBt->usableSize - 4; } n = nPayload; if( n>spaceLeft ) n = spaceLeft; if( n>nSrc ) n = nSrc; memcpy(pPayload, pSrc, n); nPayload -= n; pPayload += n; pSrc += n; nSrc -= n; spaceLeft -= n; if( nSrc==0 ){ ................................................................................ ** given in the second argument so that MemPage.pParent holds the ** pointer in the third argument. */ static int reparentPage(BtShared *pBt, Pgno pgno, MemPage *pNewParent, int idx){ MemPage *pThis; unsigned char *aData; if( pgno==0 ) return SQLITE_OK; assert( pBt->pPager!=0 ); aData = sqlite3pager_lookup(pBt->pPager, pgno); if( aData ){ pThis = (MemPage*)&aData[pBt->pageSize]; assert( pThis->aData==aData ); if( pThis->isInit ){ if( pThis->pParent!=pNewParent ){ if( pThis->pParent ) sqlite3pager_unref(pThis->pParent->aData); pThis->pParent = pNewParent; if( pNewParent ) sqlite3pager_ref(pNewParent->aData); } pThis->idxParent = idx; } sqlite3pager_unref(aData); } #ifndef SQLITE_OMIT_AUTOVACUUM ................................................................................ if( i<nOld ){ pNew = apNew[i] = apOld[i]; pgnoNew[i] = pgnoOld[i]; apOld[i] = 0; rc = sqlite3pager_write(pNew->aData); if( rc ) goto balance_cleanup; }else{ rc = allocatePage(pBt, &pNew, &pgnoNew[i], pgnoNew[i-1], 0); if( rc ) goto balance_cleanup; apNew[i] = pNew; } nNew++; zeroPage(pNew, pageFlags); } ................................................................................ } #endif j++; nxDiv++; } } assert( j==nCell ); if( (pageFlags & PTF_LEAF)==0 ){ memcpy(&apNew[nNew-1]->aData[8], &apCopy[nOld-1]->aData[8], 4); } if( nxDiv==pParent->nCell+pParent->nOverflow ){ /* Right-most sibling is the right-most child of pParent */ put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew[nNew-1]); }else{ ................................................................................ ** 8. Make sure this page is at least 33% full or else it is ** the root of the tree. */ static int checkTreePage( IntegrityCk *pCheck, /* Context for the sanity check */ int iPage, /* Page number of the page to check */ MemPage *pParent, /* Parent page */ char *zParentContext, /* Parent context */ char *zLowerBound, /* All keys should be greater than this, if not NULL */ int nLower, /* Number of characters in zLowerBound */ char *zUpperBound, /* All keys should be less than this, if not NULL */ int nUpper /* Number of characters in zUpperBound */ ){ MemPage *pPage; int i, rc, depth, d2, pgno, cnt; int hdr, cellStart; int nCell; u8 *data; BtShared *pBt; ................................................................................ if( !pPage->leaf ){ pgno = get4byte(pCell); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext); } #endif d2 = checkTreePage(pCheck,pgno,pPage,zContext,0,0,0,0); if( i>0 && d2!=depth ){ checkAppendMsg(pCheck, zContext, "Child page depth differs"); } depth = d2; } } if( !pPage->leaf ){ ................................................................................ pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]); sprintf(zContext, "On page %d at right child: ", iPage); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, 0); } #endif checkTreePage(pCheck, pgno, pPage, zContext,0,0,0,0); } /* Check for complete coverage of the page */ data = pPage->aData; hdr = pPage->hdrOffset; hit = sqliteMalloc( usableSize ); ................................................................................ for(i=0; i<nRoot; i++){ if( aRoot[i]==0 ) continue; #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum && aRoot[i]>1 ){ checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0, 0); } #endif checkTreePage(&sCheck, aRoot[i], 0, "List of tree roots: ", 0,0,0,0); } /* Make sure every page in the file is referenced */ for(i=1; i<=sCheck.nPage; i++){ #ifdef SQLITE_OMIT_AUTOVACUUM if( sCheck.anRef[i]==0 ){ ................................................................................ ** Return true if another user of the same shared btree as the argument ** handle holds an exclusive lock on the sqlite_master table. */ int sqlite3BtreeSchemaLocked(Btree *p){ return (queryTableLock(p, MASTER_ROOT, READ_LOCK)!=SQLITE_OK); } int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_SHARED_CACHE u8 lockType = (isWriteLock?WRITE_LOCK:READ_LOCK); rc = queryTableLock(p, iTab, lockType); if( rc==SQLITE_OK ){ rc = lockTable(p, iTab, lockType); } #endif return rc; } /* ** The following debugging interface has to be in this file (rather ** than in, for example, test1.c) so that it can get access to ** the definition of BtShared. */ #if defined(SQLITE_DEBUG) && defined(TCLSH) ................................................................................ #include <tcl.h> int sqlite3_shared_cache_report( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ const ThreadData *pTd = sqlite3ThreadDataReadOnly(); if( pTd->useSharedData ){ BtShared *pBt; Tcl_Obj *pRet = Tcl_NewObj(); for(pBt=pTd->pBtree; pBt; pBt=pBt->pNext){ const char *zFile = sqlite3pager_filename(pBt->pPager); Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(zFile, -1)); Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(pBt->nRef)); } Tcl_SetObjResult(interp, pRet); } return TCL_OK; } #endif |
| | | > > > > > > | > > | > > > > > > | | | | < > > > > > > > > > > > > > | > > > | < < < < | | | > > > > > > > < < > > > |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 ... 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 ... 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 .... 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 .... 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 .... 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 .... 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 .... 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 .... 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 .... 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 .... 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 .... 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 .... 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 .... 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 .... 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 .... 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 .... 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 .... 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 .... 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 .... 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 |
** 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. ** ************************************************************************* ** $Id: btree.c,v 1.22 2006/04/11 18:06:57 rmsimpson Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to ** ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: ** "Sorting And Searching", pages 473-480. Addison-Wesley ** Publishing Company, Reading, Massachusetts. ................................................................................ Pgno pgnoRoot; /* The root page of this tree */ MemPage *pPage; /* Page that contains the entry */ int idx; /* Index of the entry in pPage->aCell[] */ CellInfo info; /* A parse of the cell we are pointing at */ u8 wrFlag; /* True if writable */ u8 eState; /* One of the CURSOR_XXX constants (see below) */ #ifndef SQLITE_OMIT_SHARED_CACHE void *pKey; /* Saved key that was cursor's last known position */ i64 nKey; /* Size of pKey, or last integer key */ int skip; /* (skip<0) -> Prev() is a no-op. (skip>0) -> Next() is */ #endif }; /* ** Potential values for BtCursor.eState. The first two values (VALID and ** INVALID) may occur in any build. The third (REQUIRESEEK) may only occur ................................................................................ /* #define getVarint32 sqlite3GetVarint32 */ #define getVarint32(A,B) ((*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B)) #define putVarint sqlite3PutVarint /* The database page the PENDING_BYTE occupies. This page is never used. ** TODO: This macro is very similary to PAGER_MJ_PGNO() in pager.c. They ** should possibly be consolidated (presumably in pager.h). ** ** If disk I/O is omitted (meaning that the database is stored purely ** in memory) then there is no pending byte. */ #ifdef SQLITE_OMIT_DISKIO # define PENDING_BYTE_PAGE(pBt) 0x7fffffff #else # define PENDING_BYTE_PAGE(pBt) ((PENDING_BYTE/(pBt)->pageSize)+1) #endif /* ** A linked list of the following structures is stored at BtShared.pLock. ** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor ** is opened on the table with root page BtShared.iTable. Locks are removed ** from this list when a transaction is committed or rolled back, or when ** a btree handle is closed. ................................................................................ iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap); if( rc!=0 ){ return rc; } offset = PTRMAP_PTROFFSET(pBt, key); assert( pEType!=0 ); *pEType = pPtrmap[offset]; if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]); sqlite3pager_unref(pPtrmap); if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_BKPT; return SQLITE_OK; } ................................................................................ unsigned char *data = pPage->aData; assert( pPage->pBt!=0 ); assert( sqlite3pager_iswriteable(data) ); assert( start>=pPage->hdrOffset+6+(pPage->leaf?0:4) ); assert( (start + size)<=pPage->pBt->usableSize ); if( size<4 ) size = 4; #ifdef SQLITE_SECURE_DELETE /* Overwrite deleted information with zeros when the SECURE_DELETE ** option is enabled at compile-time */ memset(&data[start], 0, size); #endif /* Add the space back into the linked list of freeblocks */ hdr = pPage->hdrOffset; addr = hdr + 1; while( (pbegin = get2byte(&data[addr]))<start && pbegin>0 ){ assert( pbegin<=pPage->pBt->usableSize-4 ); assert( pbegin>addr ); ................................................................................ #endif /* ** The following asserts make sure that structures used by the btree are ** the right size. This is to guard against size changes that result ** when compiling on a different architecture. */ assert( sizeof(i64)==8 || sizeof(i64)==4 ); assert( sizeof(u64)==8 || sizeof(u64)==4 ); assert( sizeof(u32)==4 ); assert( sizeof(u16)==2 ); assert( sizeof(Pgno)==4 ); pBt = sqliteMalloc( sizeof(*pBt) ); if( pBt==0 ){ *ppBtree = 0; ................................................................................ pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0); #endif } pBt->usableSize = pBt->pageSize - nReserve; assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */ sqlite3pager_set_pagesize(pBt->pPager, pBt->pageSize); #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO) /* Add the new btree to the linked list starting at ThreadData.pBtree. ** There is no chance that a malloc() may fail inside of the ** sqlite3ThreadData() call, as the ThreadData structure must have already ** been allocated for pTsdro->useSharedData to be non-zero. */ if( pTsdro->useSharedData && zFilename && !isMemdb ){ pBt->pNext = pTsdro->pBtree; ................................................................................ */ pTsd = (ThreadData *)sqlite3ThreadDataReadOnly(); if( pTsd->pBtree==pBt ){ assert( pTsd==sqlite3ThreadData() ); pTsd->pBtree = pBt->pNext; }else{ BtShared *pPrev; for(pPrev=pTsd->pBtree; pPrev && pPrev->pNext!=pBt; pPrev=pPrev->pNext){} if( pPrev ){ assert( pTsd==sqlite3ThreadData() ); pPrev->pNext = pBt->pNext; } } #endif ................................................................................ ** truncate the database file to finSize pages and consider the ** free-list empty. */ rc = sqlite3pager_write(pBt->pPage1->aData); if( rc!=SQLITE_OK ) goto autovacuum_out; put4byte(&pBt->pPage1->aData[32], 0); put4byte(&pBt->pPage1->aData[36], 0); *nTrunc = finSize; assert( finSize!=PENDING_BYTE_PAGE(pBt) ); autovacuum_out: assert( nRef==*sqlite3pager_stats(pPager) ); if( rc!=SQLITE_OK ){ sqlite3pager_rollback(pPager); ................................................................................ pPage->pParent = 0; /* Increment the free page count on pPage1 */ rc = sqlite3pager_write(pPage1->aData); if( rc ) return rc; n = get4byte(&pPage1->aData[36]); put4byte(&pPage1->aData[36], n+1); #ifdef SQLITE_SECURE_DELETE /* If the SQLITE_SECURE_DELETE compile-time option is enabled, then ** always fully overwrite deleted information with zeros. */ rc = sqlite3pager_write(pPage->aData); if( rc ) return rc; memset(pPage->aData, 0, pPage->pBt->pageSize); #endif #ifndef SQLITE_OMIT_AUTOVACUUM /* If the database supports auto-vacuum, write an entry in the pointer-map ** to indicate that the page is free. */ if( pBt->autoVacuum ){ rc = ptrmapPut(pBt, pPage->pgno, PTRMAP_FREEPAGE, 0); ................................................................................ pPage->pgno, pTrunk->pgno)); }else{ /* Add the newly freed page as a leaf on the current trunk */ rc = sqlite3pager_write(pTrunk->aData); if( rc ) return rc; put4byte(&pTrunk->aData[4], k+1); put4byte(&pTrunk->aData[8+k*4], pPage->pgno); #ifndef SQLITE_SECURE_DELETE sqlite3pager_dont_write(pBt->pPager, pPage->pgno); #endif TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno)); } releasePage(pTrunk); } return rc; } ................................................................................ put4byte(pPrior, 0); pPayload = &pOvfl->aData[4]; spaceLeft = pBt->usableSize - 4; } n = nPayload; if( n>spaceLeft ) n = spaceLeft; if( n>nSrc ) n = nSrc; assert( pSrc ); memcpy(pPayload, pSrc, n); nPayload -= n; pPayload += n; pSrc += n; nSrc -= n; spaceLeft -= n; if( nSrc==0 ){ ................................................................................ ** given in the second argument so that MemPage.pParent holds the ** pointer in the third argument. */ static int reparentPage(BtShared *pBt, Pgno pgno, MemPage *pNewParent, int idx){ MemPage *pThis; unsigned char *aData; assert( pNewParent!=0 ); if( pgno==0 ) return SQLITE_OK; assert( pBt->pPager!=0 ); aData = sqlite3pager_lookup(pBt->pPager, pgno); if( aData ){ pThis = (MemPage*)&aData[pBt->pageSize]; assert( pThis->aData==aData ); if( pThis->isInit ){ if( pThis->pParent!=pNewParent ){ if( pThis->pParent ) sqlite3pager_unref(pThis->pParent->aData); pThis->pParent = pNewParent; sqlite3pager_ref(pNewParent->aData); } pThis->idxParent = idx; } sqlite3pager_unref(aData); } #ifndef SQLITE_OMIT_AUTOVACUUM ................................................................................ if( i<nOld ){ pNew = apNew[i] = apOld[i]; pgnoNew[i] = pgnoOld[i]; apOld[i] = 0; rc = sqlite3pager_write(pNew->aData); if( rc ) goto balance_cleanup; }else{ assert( i>0 ); rc = allocatePage(pBt, &pNew, &pgnoNew[i], pgnoNew[i-1], 0); if( rc ) goto balance_cleanup; apNew[i] = pNew; } nNew++; zeroPage(pNew, pageFlags); } ................................................................................ } #endif j++; nxDiv++; } } assert( j==nCell ); assert( nOld>0 ); assert( nNew>0 ); if( (pageFlags & PTF_LEAF)==0 ){ memcpy(&apNew[nNew-1]->aData[8], &apCopy[nOld-1]->aData[8], 4); } if( nxDiv==pParent->nCell+pParent->nOverflow ){ /* Right-most sibling is the right-most child of pParent */ put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew[nNew-1]); }else{ ................................................................................ ** 8. Make sure this page is at least 33% full or else it is ** the root of the tree. */ static int checkTreePage( IntegrityCk *pCheck, /* Context for the sanity check */ int iPage, /* Page number of the page to check */ MemPage *pParent, /* Parent page */ char *zParentContext /* Parent context */ ){ MemPage *pPage; int i, rc, depth, d2, pgno, cnt; int hdr, cellStart; int nCell; u8 *data; BtShared *pBt; ................................................................................ if( !pPage->leaf ){ pgno = get4byte(pCell); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext); } #endif d2 = checkTreePage(pCheck,pgno,pPage,zContext); if( i>0 && d2!=depth ){ checkAppendMsg(pCheck, zContext, "Child page depth differs"); } depth = d2; } } if( !pPage->leaf ){ ................................................................................ pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]); sprintf(zContext, "On page %d at right child: ", iPage); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, 0); } #endif checkTreePage(pCheck, pgno, pPage, zContext); } /* Check for complete coverage of the page */ data = pPage->aData; hdr = pPage->hdrOffset; hit = sqliteMalloc( usableSize ); ................................................................................ for(i=0; i<nRoot; i++){ if( aRoot[i]==0 ) continue; #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum && aRoot[i]>1 ){ checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0, 0); } #endif checkTreePage(&sCheck, aRoot[i], 0, "List of tree roots: "); } /* Make sure every page in the file is referenced */ for(i=1; i<=sCheck.nPage; i++){ #ifdef SQLITE_OMIT_AUTOVACUUM if( sCheck.anRef[i]==0 ){ ................................................................................ ** Return true if another user of the same shared btree as the argument ** handle holds an exclusive lock on the sqlite_master table. */ int sqlite3BtreeSchemaLocked(Btree *p){ return (queryTableLock(p, MASTER_ROOT, READ_LOCK)!=SQLITE_OK); } #ifndef SQLITE_OMIT_SHARED_CACHE /* ** Obtain a lock on the table whose root page is iTab. The ** lock is a write lock if isWritelock is true or a read lock ** if it is false. */ int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){ int rc = SQLITE_OK; u8 lockType = (isWriteLock?WRITE_LOCK:READ_LOCK); rc = queryTableLock(p, iTab, lockType); if( rc==SQLITE_OK ){ rc = lockTable(p, iTab, lockType); } return rc; } #endif /* ** The following debugging interface has to be in this file (rather ** than in, for example, test1.c) so that it can get access to ** the definition of BtShared. */ #if defined(SQLITE_DEBUG) && defined(TCLSH) ................................................................................ #include <tcl.h> int sqlite3_shared_cache_report( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_SHARED_CACHE const ThreadData *pTd = sqlite3ThreadDataReadOnly(); if( pTd->useSharedData ){ BtShared *pBt; Tcl_Obj *pRet = Tcl_NewObj(); for(pBt=pTd->pBtree; pBt; pBt=pBt->pNext){ const char *zFile = sqlite3pager_filename(pBt->pPager); Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(zFile, -1)); Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(pBt->nRef)); } Tcl_SetObjResult(interp, pRet); } #endif return TCL_OK; } #endif |
Changes to SQLite.Interop/src/btree.h.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite B-Tree file ** subsystem. See comments in the source code for a detailed description ** of what each interface routine does. ** ** @(#) $Id: btree.h,v 1.19 2006/02/11 14:43:38 rmsimpson Exp $ */ #ifndef _BTREE_H_ #define _BTREE_H_ /* TODO: This definition is just included so other modules compile. It ** needs to be revisited. */ |
| |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite B-Tree file ** subsystem. See comments in the source code for a detailed description ** of what each interface routine does. ** ** @(#) $Id: btree.h,v 1.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #ifndef _BTREE_H_ #define _BTREE_H_ /* TODO: This definition is just included so other modules compile. It ** needs to be revisited. */ |
Changes to SQLite.Interop/src/build.c.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 .. 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 ... 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 ... 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 ... 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 ... 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 ... 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 .... 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 .... 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 .... 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 .... 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 .... 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 .... 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 |
** CREATE INDEX ** DROP INDEX ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** ** $Id: build.c,v 1.19 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Initialize the pParse structure as needed. ................................................................................ #ifndef SQLITE_OMIT_SHARED_CACHE /* ** The TableLock structure is only used by the sqlite3TableLock() and ** codeTableLocks() functions. */ struct TableLock { int iDb; int iTab; u8 isWriteLock; const char *zName; }; /* ** Have the compiled statement lock the table with rootpage iTab in database ** iDb at the shared-cache level when executed. The isWriteLock argument ** is zero for a read-lock, or non-zero for a write-lock. ** ** The zName parameter should point to the unqualified table name. This is ** used to provide a more informative error message should the lock fail. */ void sqlite3TableLock( Parse *pParse, int iDb, int iTab, u8 isWriteLock, const char *zName ){ int i; int nBytes; TableLock *p; if( 0==sqlite3ThreadDataReadOnly()->useSharedData || iDb<0 ){ return; ................................................................................ Vdbe *v; if( sqlite3MallocFailed() ) return; if( pParse->nested ) return; if( !pParse->pVdbe ){ if( pParse->rc==SQLITE_OK && pParse->nErr ){ pParse->rc = SQLITE_ERROR; } return; } /* Begin by generating some termination code at the end of the ** vdbe program */ db = pParse->db; v = sqlite3GetVdbe(pParse); ................................................................................ sqlite3VdbeOp3(v, OP_Noop, 0, 0, pParse->zSql, pParse->zTail-pParse->zSql); #endif /* SQLITE_OMIT_TRACE */ } /* Get the VDBE program ready for execution */ if( v && pParse->nErr==0 ){ FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0; sqlite3VdbeTrace(v, trace); sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem+3, pParse->nTab+3, pParse->explain); pParse->rc = SQLITE_DONE; pParse->colNamesSet = 0; }else if( pParse->rc==SQLITE_OK ){ ................................................................................ ** Remove the given index from the index hash table, and free ** its memory structures. ** ** The index is removed from the database hash tables but ** it is not unlinked from the Table that it indexes. ** Unlinking from the Table must be done by the calling function. */ static void sqliteDeleteIndex(sqlite3 *db, Index *p){ Index *pOld; const char *zName = p->zName; pOld = sqlite3HashInsert(&p->pSchema->idxHash, zName, strlen( zName)+1, 0); assert( pOld==0 || pOld==p ); freeIndex(p); } ................................................................................ assert( pTable->nRef==0 ); /* Delete all indices associated with this table */ for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema ); sqliteDeleteIndex(db, pIndex); } #ifndef SQLITE_OMIT_FOREIGN_KEY /* Delete all foreign keys associated with this table. The keys ** should have already been unlinked from the db->aFKey hash table */ for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){ ................................................................................ return SQLITE_OK; } /* ** Begin constructing a new table representation in memory. This is ** the first of several action routines that get called in response ** to a CREATE TABLE statement. In particular, this routine is called ** after seeing tokens "CREATE" and "TABLE" and the table name. The ** pStart token is the CREATE and pName is the table name. The isTemp ** flag is true if the table should be stored in the auxiliary database ** file instead of in the main database file. This is normally the case ** when the "TEMP" or "TEMPORARY" keyword occurs in between ** CREATE and TABLE. ** ** The new table record is initialized and put in pParse->pNewTable. ** As more of the CREATE TABLE statement is parsed, additional action ** routines will be called to add more information to this record. ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine ** is called to complete the construction of the new table record. */ void sqlite3StartTable( Parse *pParse, /* Parser context */ Token *pStart, /* The "CREATE" token */ Token *pName1, /* First part of the name of the table or view */ Token *pName2, /* Second part of the name of the table or view */ int isTemp, /* True if this is a TEMP table */ int isView, /* True if this is a VIEW */ int noErr /* Do nothing if table already exists */ ){ Table *pTable; ................................................................................ int iDb; if( pParse->nVar>0 ){ sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); sqlite3SelectDelete(pSelect); return; } sqlite3StartTable(pParse, pBegin, pName1, pName2, isTemp, 1, 0); p = pParse->pNewTable; if( p==0 || pParse->nErr ){ sqlite3SelectDelete(pSelect); return; } sqlite3TwoPartName(pParse, pName1, pName2, &pName); iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema); ................................................................................ #endif /* SQLITE_OMIT_VIEW */ /* ** This function is called by the VDBE to adjust the internal schema ** used by SQLite when the btree layer moves a table root page. The ** root-page of a table or index in database iDb has changed from iFrom ** to iTo. */ #ifndef SQLITE_OMIT_AUTOVACUUM void sqlite3RootPageMoved(Db *pDb, int iFrom, int iTo){ HashElem *pElem; Hash *pHash; pHash = &pDb->pSchema->tblHash; for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); if( pTab->tnum==iFrom ){ pTab->tnum = iTo; return; } } pHash = &pDb->pSchema->idxHash; for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){ Index *pIdx = sqliteHashData(pElem); if( pIdx->tnum==iFrom ){ pIdx->tnum = iTo; return; } } assert(0); } #endif /* ** Write code to erase the table with root-page iTable from database iDb. ** Also write code to modify the sqlite_master table and internal schema ** if a root-page of another table is moved by the btree-layer whilst ................................................................................ ** is generated to remove entries from sqlite_master and/or ** sqlite_temp_master if required. */ pTrigger = pTab->pTrigger; while( pTrigger ){ assert( pTrigger->pSchema==pTab->pSchema || pTrigger->pSchema==db->aDb[1].pSchema ); sqlite3DropTriggerPtr(pParse, pTrigger, 1); pTrigger = pTrigger->pNext; } #ifndef SQLITE_OMIT_AUTOINCREMENT /* Remove any entries of the sqlite_sequence table associated with ** the table being dropped. This is done before the table is dropped ** at the btree level, in case the sqlite_sequence table needs to ................................................................................ } } /* ** Make sure the TEMP database is open and available for use. Return ** the number of errors. Leave any error messages in the pParse structure. */ static int sqlite3OpenTempDatabase(Parse *pParse){ sqlite3 *db = pParse->db; if( db->aDb[1].pBt==0 && !pParse->explain ){ int rc = sqlite3BtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt); if( rc!=SQLITE_OK ){ sqlite3ErrorMsg(pParse, "unable to open a temporary database " "file for storing temporary tables"); pParse->rc = rc; ................................................................................ db = pParse->db; if( pParse->cookieGoto==0 ){ pParse->cookieGoto = sqlite3VdbeAddOp(v, OP_Goto, 0, 0)+1; } if( iDb>=0 ){ assert( iDb<db->nDb ); assert( db->aDb[iDb].pBt!=0 || iDb==1 ); assert( iDb<32 ); mask = 1<<iDb; if( (pParse->cookieMask & mask)==0 ){ pParse->cookieMask |= mask; pParse->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; if( !OMIT_TEMPDB && iDb==1 ){ sqlite3OpenTempDatabase(pParse); } ................................................................................ Db *pDb; /* A single database */ int iDb; /* The database index number */ sqlite3 *db = pParse->db; /* The database connection */ HashElem *k; /* For looping over tables in pDb */ Table *pTab; /* A table in the database */ for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){ if( pDb==0 ) continue; for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){ pTab = (Table*)sqliteHashData(k); reindexTable(pParse, pTab, zColl); } } } #endif |
| | | | | | | | > < | > > | < < > > | | < | > | | | | < < | > > > > > > > > > > > < < < | | | | |
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 .. 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 ... 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 ... 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 ... 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 ... 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 ... 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 .... 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 .... 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 .... 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 .... 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 .... 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 .... 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 |
** CREATE INDEX ** DROP INDEX ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** ** $Id: build.c,v 1.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Initialize the pParse structure as needed. ................................................................................ #ifndef SQLITE_OMIT_SHARED_CACHE /* ** The TableLock structure is only used by the sqlite3TableLock() and ** codeTableLocks() functions. */ struct TableLock { int iDb; /* The database containing the table to be locked */ int iTab; /* The root page of the table to be locked */ u8 isWriteLock; /* True for write lock. False for a read lock */ const char *zName; /* Name of the table */ }; /* ** Record the fact that we want to lock a table at run-time. ** ** The table to be locked has root page iTab and is found in database iDb. ** A read or a write lock can be taken depending on isWritelock. ** ** This routine just records the fact that the lock is desired. The ** code to make the lock occur is generated by a later call to ** codeTableLocks() which occurs during sqlite3FinishCoding(). */ void sqlite3TableLock( Parse *pParse, /* Parsing context */ int iDb, /* Index of the database containing the table to lock */ int iTab, /* Root page number of the table to be locked */ u8 isWriteLock, /* True for a write lock */ const char *zName /* Name of the table to be locked */ ){ int i; int nBytes; TableLock *p; if( 0==sqlite3ThreadDataReadOnly()->useSharedData || iDb<0 ){ return; ................................................................................ Vdbe *v; if( sqlite3MallocFailed() ) return; if( pParse->nested ) return; if( !pParse->pVdbe ){ if( pParse->rc==SQLITE_OK && pParse->nErr ){ pParse->rc = SQLITE_ERROR; return; } } /* Begin by generating some termination code at the end of the ** vdbe program */ db = pParse->db; v = sqlite3GetVdbe(pParse); ................................................................................ sqlite3VdbeOp3(v, OP_Noop, 0, 0, pParse->zSql, pParse->zTail-pParse->zSql); #endif /* SQLITE_OMIT_TRACE */ } /* Get the VDBE program ready for execution */ if( v && pParse->nErr==0 && !sqlite3MallocFailed() ){ FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0; sqlite3VdbeTrace(v, trace); sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem+3, pParse->nTab+3, pParse->explain); pParse->rc = SQLITE_DONE; pParse->colNamesSet = 0; }else if( pParse->rc==SQLITE_OK ){ ................................................................................ ** Remove the given index from the index hash table, and free ** its memory structures. ** ** The index is removed from the database hash tables but ** it is not unlinked from the Table that it indexes. ** Unlinking from the Table must be done by the calling function. */ static void sqliteDeleteIndex(Index *p){ Index *pOld; const char *zName = p->zName; pOld = sqlite3HashInsert(&p->pSchema->idxHash, zName, strlen( zName)+1, 0); assert( pOld==0 || pOld==p ); freeIndex(p); } ................................................................................ assert( pTable->nRef==0 ); /* Delete all indices associated with this table */ for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema ); sqliteDeleteIndex(pIndex); } #ifndef SQLITE_OMIT_FOREIGN_KEY /* Delete all foreign keys associated with this table. The keys ** should have already been unlinked from the db->aFKey hash table */ for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){ ................................................................................ return SQLITE_OK; } /* ** Begin constructing a new table representation in memory. This is ** the first of several action routines that get called in response ** to a CREATE TABLE statement. In particular, this routine is called ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp ** flag is true if the table should be stored in the auxiliary database ** file instead of in the main database file. This is normally the case ** when the "TEMP" or "TEMPORARY" keyword occurs in between ** CREATE and TABLE. ** ** The new table record is initialized and put in pParse->pNewTable. ** As more of the CREATE TABLE statement is parsed, additional action ** routines will be called to add more information to this record. ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine ** is called to complete the construction of the new table record. */ void sqlite3StartTable( Parse *pParse, /* Parser context */ Token *pName1, /* First part of the name of the table or view */ Token *pName2, /* Second part of the name of the table or view */ int isTemp, /* True if this is a TEMP table */ int isView, /* True if this is a VIEW */ int noErr /* Do nothing if table already exists */ ){ Table *pTable; ................................................................................ int iDb; if( pParse->nVar>0 ){ sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); sqlite3SelectDelete(pSelect); return; } sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0); p = pParse->pNewTable; if( p==0 || pParse->nErr ){ sqlite3SelectDelete(pSelect); return; } sqlite3TwoPartName(pParse, pName1, pName2, &pName); iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema); ................................................................................ #endif /* SQLITE_OMIT_VIEW */ /* ** This function is called by the VDBE to adjust the internal schema ** used by SQLite when the btree layer moves a table root page. The ** root-page of a table or index in database iDb has changed from iFrom ** to iTo. ** ** Ticket #1728: The symbol table might still contain information ** on tables and/or indices that are the process of being deleted. ** If you are unlucky, one of those deleted indices or tables might ** have the same rootpage number as the real table or index that is ** being moved. So we cannot stop searching after the first match ** because the first match might be for one of the deleted indices ** or tables and not the table/index that is actually being moved. ** We must continue looping until all tables and indices with ** rootpage==iFrom have been converted to have a rootpage of iTo ** in order to be certain that we got the right one. */ #ifndef SQLITE_OMIT_AUTOVACUUM void sqlite3RootPageMoved(Db *pDb, int iFrom, int iTo){ HashElem *pElem; Hash *pHash; pHash = &pDb->pSchema->tblHash; for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); if( pTab->tnum==iFrom ){ pTab->tnum = iTo; } } pHash = &pDb->pSchema->idxHash; for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){ Index *pIdx = sqliteHashData(pElem); if( pIdx->tnum==iFrom ){ pIdx->tnum = iTo; } } } #endif /* ** Write code to erase the table with root-page iTable from database iDb. ** Also write code to modify the sqlite_master table and internal schema ** if a root-page of another table is moved by the btree-layer whilst ................................................................................ ** is generated to remove entries from sqlite_master and/or ** sqlite_temp_master if required. */ pTrigger = pTab->pTrigger; while( pTrigger ){ assert( pTrigger->pSchema==pTab->pSchema || pTrigger->pSchema==db->aDb[1].pSchema ); sqlite3DropTriggerPtr(pParse, pTrigger); pTrigger = pTrigger->pNext; } #ifndef SQLITE_OMIT_AUTOINCREMENT /* Remove any entries of the sqlite_sequence table associated with ** the table being dropped. This is done before the table is dropped ** at the btree level, in case the sqlite_sequence table needs to ................................................................................ } } /* ** Make sure the TEMP database is open and available for use. Return ** the number of errors. Leave any error messages in the pParse structure. */ int sqlite3OpenTempDatabase(Parse *pParse){ sqlite3 *db = pParse->db; if( db->aDb[1].pBt==0 && !pParse->explain ){ int rc = sqlite3BtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt); if( rc!=SQLITE_OK ){ sqlite3ErrorMsg(pParse, "unable to open a temporary database " "file for storing temporary tables"); pParse->rc = rc; ................................................................................ db = pParse->db; if( pParse->cookieGoto==0 ){ pParse->cookieGoto = sqlite3VdbeAddOp(v, OP_Goto, 0, 0)+1; } if( iDb>=0 ){ assert( iDb<db->nDb ); assert( db->aDb[iDb].pBt!=0 || iDb==1 ); assert( iDb<MAX_ATTACHED+2 ); mask = 1<<iDb; if( (pParse->cookieMask & mask)==0 ){ pParse->cookieMask |= mask; pParse->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; if( !OMIT_TEMPDB && iDb==1 ){ sqlite3OpenTempDatabase(pParse); } ................................................................................ Db *pDb; /* A single database */ int iDb; /* The database index number */ sqlite3 *db = pParse->db; /* The database connection */ HashElem *k; /* For looping over tables in pDb */ Table *pTab; /* A table in the database */ for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){ assert( pDb!=0 ); for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){ pTab = (Table*)sqliteHashData(k); reindexTable(pParse, pTab, zColl); } } } #endif |
Changes to SQLite.Interop/src/callback.c.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 ... 308 309 310 311 312 313 314 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains functions used to access the internal hash tables ** of user defined functions and collation sequences. ** ** $Id: callback.c,v 1.14 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Invoke the 'collation needed' callback to request a collation sequence ** in the database text encoding of name zName, length nName. ................................................................................ pColl[0].zName[nName] = 0; pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl); /* If a malloc() failure occured in sqlite3HashInsert(), it will ** return the pColl pointer to be deleted (because it wasn't added ** to the hash table). */ assert( !pDel || (sqlite3MallocFailed() && pDel==pColl) ); sqliteFree(pDel); } } return pColl; } /* ** Parameter zName points to a UTF-8 encoded string nName bytes long. ................................................................................ } if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){ return pBest; } return 0; } |
| < | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 ... 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains functions used to access the internal hash tables ** of user defined functions and collation sequences. ** ** $Id: callback.c,v 1.15 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Invoke the 'collation needed' callback to request a collation sequence ** in the database text encoding of name zName, length nName. ................................................................................ pColl[0].zName[nName] = 0; pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl); /* If a malloc() failure occured in sqlite3HashInsert(), it will ** return the pColl pointer to be deleted (because it wasn't added ** to the hash table). */ assert( !pDel || (sqlite3MallocFailed() && pDel==pColl) ); if( pDel ){ sqliteFree(pDel); pColl = 0; } } } return pColl; } /* ** Parameter zName points to a UTF-8 encoded string nName bytes long. ................................................................................ } if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){ return pBest; } return 0; } /* ** Free all resources held by the schema structure. The void* argument points ** at a Schema struct. This function does not call sqliteFree() on the ** pointer itself, it just cleans up subsiduary resources (i.e. the contents ** of the schema hash tables). */ void sqlite3SchemaFree(void *p){ Hash temp1; Hash temp2; HashElem *pElem; Schema *pSchema = (Schema *)p; temp1 = pSchema->tblHash; temp2 = pSchema->trigHash; sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0); sqlite3HashClear(&pSchema->aFKey); sqlite3HashClear(&pSchema->idxHash); for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem)); } sqlite3HashClear(&temp2); sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0); for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); sqlite3DeleteTable(0, pTab); } sqlite3HashClear(&temp1); pSchema->pSeqTab = 0; pSchema->flags &= ~DB_SchemaLoaded; } /* ** Find and return the schema associated with a BTree. Create ** a new one if necessary. */ Schema *sqlite3SchemaGet(Btree *pBt){ Schema * p; if( pBt ){ p = (Schema *)sqlite3BtreeSchema(pBt,sizeof(Schema),sqlite3SchemaFree); }else{ p = (Schema *)sqliteMalloc(sizeof(Schema)); } if( p && 0==p->file_format ){ sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0); sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0); sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0); sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1); } return p; } |
Changes to SQLite.Interop/src/complete.c.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
** An tokenizer for SQL ** ** This file contains C code that implements the sqlite3_complete() API. ** This code used to be part of the tokenizer.c source file. But by ** separating it out, the code will be automatically omitted from ** static links that do not use it. ** ** $Id: complete.c,v 1.12 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #ifndef SQLITE_OMIT_COMPLETE /* ** This is defined in tokenize.c. We just have to import the definition. */ |
| |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
** An tokenizer for SQL ** ** This file contains C code that implements the sqlite3_complete() API. ** This code used to be part of the tokenizer.c source file. But by ** separating it out, the code will be automatically omitted from ** static links that do not use it. ** ** $Id: complete.c,v 1.13 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #ifndef SQLITE_OMIT_COMPLETE /* ** This is defined in tokenize.c. We just have to import the definition. */ |
Changes to SQLite.Interop/src/date.c.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: date.c,v 1.20 2006/02/11 14:43:38 rmsimpson Exp $ ** ** NOTES: ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. |
| |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: date.c,v 1.21 2006/04/11 18:06:57 rmsimpson Exp $ ** ** NOTES: ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. |
Changes to SQLite.Interop/src/delete.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 ... 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
** 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 ** in order to generate code for DELETE FROM statements. ** ** $Id: delete.c,v 1.19 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Look up every table that is named in pSrc. If any table is not found, ** add an error message to pParse->zErrMsg and return NULL. If all tables ** are found, return a pointer to the last table. ................................................................................ Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int iCur, /* Cursor number for the table */ int count /* Increment the row change counter */ ){ int addr; addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0); sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, 0); sqlite3VdbeAddOp(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0)); if( count ){ sqlite3VdbeChangeP3(v, -1, pTab->zName, P3_STATIC); } sqlite3VdbeJumpHere(v, addr); } ................................................................................ ** 2. Read/write cursors for all indices of pTab must be open as ** cursor number iCur+i for the i-th index. ** ** 3. The "iCur" cursor must be pointing to the row that is to be ** deleted. */ void sqlite3GenerateRowIndexDelete( sqlite3 *db, /* The database containing the index */ Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int iCur, /* Cursor number for the table */ char *aIdxUsed /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */ ){ int i; Index *pIdx; |
| | < |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 ... 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
** 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 ** in order to generate code for DELETE FROM statements. ** ** $Id: delete.c,v 1.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Look up every table that is named in pSrc. If any table is not found, ** add an error message to pParse->zErrMsg and return NULL. If all tables ** are found, return a pointer to the last table. ................................................................................ Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int iCur, /* Cursor number for the table */ int count /* Increment the row change counter */ ){ int addr; addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0); sqlite3GenerateRowIndexDelete(v, pTab, iCur, 0); sqlite3VdbeAddOp(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0)); if( count ){ sqlite3VdbeChangeP3(v, -1, pTab->zName, P3_STATIC); } sqlite3VdbeJumpHere(v, addr); } ................................................................................ ** 2. Read/write cursors for all indices of pTab must be open as ** cursor number iCur+i for the i-th index. ** ** 3. The "iCur" cursor must be pointing to the row that is to be ** deleted. */ void sqlite3GenerateRowIndexDelete( Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int iCur, /* Cursor number for the table */ char *aIdxUsed /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */ ){ int i; Index *pIdx; |
Changes to SQLite.Interop/src/expr.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 .... 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 .... 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 |
** 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.26 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Return the 'affinity' of the expression pExpr if any. ** ................................................................................ pExpr->iTable = -1; while( pNC && cnt==0 ){ ExprList *pEList; SrcList *pSrcList = pNC->pSrcList; if( pSrcList ){ for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){ Table *pTab = pItem->pTab; int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); Column *pCol; if( pTab==0 ) continue; assert( pTab->nCol>0 ); if( zTab ){ if( pItem->zAlias ){ char *zTabName = pItem->zAlias; if( sqlite3StrICmp(zTabName, zTab)!=0 ) continue; }else{ char *zTabName = pTab->zName; ................................................................................ /* If the expression is not constant then we will need to ** disable the test that was generated above that makes sure ** this code only executes once. Because for a non-constant ** expression we need to rerun this code each time. */ if( testAddr>0 && !sqlite3ExprIsConstant(pE2) ){ VdbeOp *aOp = sqlite3VdbeGetOp(v, testAddr-1); int j; for(j=0; j<3; j++){ aOp[j].opcode = OP_Noop; } testAddr = 0; } /* Evaluate the expression and insert it into the temp table */ sqlite3ExprCode(pParse, pE2); sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &affinity, 1); sqlite3VdbeAddOp(v, OP_IdxInsert, pExpr->iTable, 0); ................................................................................ sqlite3VdbeOp3(v, OP_Function, constMask, nExpr, (char*)pDef, P3_FUNCDEF); stackChng = 1-nExpr; break; } #ifndef SQLITE_OMIT_SUBQUERY case TK_EXISTS: case TK_SELECT: { sqlite3CodeSubselect(pParse, pExpr); sqlite3VdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0); VdbeComment((v, "# load subquery result")); break; } case TK_IN: { int addr; char affinity; |
| | | | > > | < < < < > | > |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 .... 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 .... 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 |
** 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.27 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Return the 'affinity' of the expression pExpr if any. ** ................................................................................ pExpr->iTable = -1; while( pNC && cnt==0 ){ ExprList *pEList; SrcList *pSrcList = pNC->pSrcList; if( pSrcList ){ for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){ Table *pTab; int iDb; Column *pCol; pTab = pItem->pTab; assert( pTab!=0 ); iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( pTab->nCol>0 ); if( zTab ){ if( pItem->zAlias ){ char *zTabName = pItem->zAlias; if( sqlite3StrICmp(zTabName, zTab)!=0 ) continue; }else{ char *zTabName = pTab->zName; ................................................................................ /* If the expression is not constant then we will need to ** disable the test that was generated above that makes sure ** this code only executes once. Because for a non-constant ** expression we need to rerun this code each time. */ if( testAddr>0 && !sqlite3ExprIsConstant(pE2) ){ sqlite3VdbeChangeToNoop(v, testAddr-1, 3); testAddr = 0; } /* Evaluate the expression and insert it into the temp table */ sqlite3ExprCode(pParse, pE2); sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &affinity, 1); sqlite3VdbeAddOp(v, OP_IdxInsert, pExpr->iTable, 0); ................................................................................ sqlite3VdbeOp3(v, OP_Function, constMask, nExpr, (char*)pDef, P3_FUNCDEF); stackChng = 1-nExpr; break; } #ifndef SQLITE_OMIT_SUBQUERY case TK_EXISTS: case TK_SELECT: { if( pExpr->iColumn==0 ){ sqlite3CodeSubselect(pParse, pExpr); } sqlite3VdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0); VdbeComment((v, "# load subquery result")); break; } case TK_IN: { int addr; char affinity; |
Changes to SQLite.Interop/src/func.c.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ... 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 ... 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 ... 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 ... 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 ... 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 .... 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 |
** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: func.c,v 1.21 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* #include <math.h> */ #include <stdlib.h> #include <assert.h> #include "vdbeInt.h" ................................................................................ ** Implementation of the abs() function */ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); if( iVal<0 ) iVal = iVal * -1; sqlite3_result_int64(context, iVal); break; } case SQLITE_NULL: { sqlite3_result_null(context); break; } default: { double rVal = sqlite3_value_double(argv[0]); if( rVal<0 ) rVal = rVal * -1.0; sqlite3_result_double(context, rVal); break; } } } /* ................................................................................ assert( argc==1 || argc==2 ); if( argc==2 ){ if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return; n = sqlite3_value_int(argv[1]); if( n>30 ) n = 30; if( n<0 ) n = 0; } if( SQLITE_NULL==sqlite3_value_type(argv[0]) ) return; r = sqlite3_value_double(argv[0]); sqlite3_snprintf(sizeof(zBuf),zBuf,"%.*f",n,r); sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } /* ** Implementation of the upper() and lower() SQL functions. */ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ unsigned char *z; ................................................................................ ** Implementation of random(). Return a random integer. */ static void randomFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ int r; sqlite3Randomness(sizeof(r), &r); sqlite3_result_int(context, r); } /* ** Implementation of the last_insert_rowid() SQL function. The return ** value is the same as the sqlite3_last_insert_rowid() API function. */ static void last_insert_rowid( ................................................................................ /* ** An instance of the following structure holds the context of a ** sum() or avg() aggregate computation. */ typedef struct SumCtx SumCtx; struct SumCtx { LONGDOUBLE_TYPE sum; /* Sum of terms */ i64 cnt; /* Number of elements summed */ u8 approx; /* True if sum is approximate */ }; /* ** Routines used to compute the sum, average, and total. ** ** The SUM() function follows the (broken) SQL standard which means ** that it returns NULL if it sums over no inputs. TOTAL returns ................................................................................ int type; assert( argc==1 ); p = sqlite3_aggregate_context(context, sizeof(*p)); type = sqlite3_value_numeric_type(argv[0]); if( p && type!=SQLITE_NULL ){ p->cnt++; if( type==SQLITE_INTEGER ){ p->sum += sqlite3_value_int64(argv[0]); if( !p->approx ){ i64 iVal; p->approx = p->sum!=(LONGDOUBLE_TYPE)(iVal = (i64)p->sum); } }else{ p->sum += sqlite3_value_double(argv[0]); p->approx = 1; } } } static void sumFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ if( p->approx ){ sqlite3_result_double(context, p->sum); }else{ sqlite3_result_int64(context, (i64)p->sum); } } } static void avgFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ sqlite3_result_double(context, p->sum/(double)p->cnt); } } static void totalFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); sqlite3_result_double(context, p ? p->sum : 0.0); } /* ** The following structure keeps track of state information for the ** count() aggregate function. */ typedef struct CountCtx CountCtx; ................................................................................ if( pFunc && aAggs[i].needCollSeq ){ pFunc->needCollSeq = 1; } } } sqlite3RegisterDateTimeFunctions(db); #ifdef SQLITE_SSE sqlite3SseFunctions(db); #endif #ifdef SQLITE_CASE_SENSITIVE_LIKE sqlite3RegisterLikeFunctions(db, 1); #else sqlite3RegisterLikeFunctions(db, 0); #endif } |
| | > > > > > > | | | | > > | | > | < > > | | | | > > > > > | > > | | | | | | |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ... 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 ... 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ... 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 ... 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 ... 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 .... 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: func.c,v 1.22 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* #include <math.h> */ #include <stdlib.h> #include <assert.h> #include "vdbeInt.h" ................................................................................ ** Implementation of the abs() function */ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); if( iVal<0 ){ if( (iVal<<1)==0 ){ sqlite3_result_error(context, "integer overflow", -1); return; } iVal = -iVal; } sqlite3_result_int64(context, iVal); break; } case SQLITE_NULL: { sqlite3_result_null(context); break; } default: { double rVal = sqlite3_value_double(argv[0]); if( rVal<0 ) rVal = -rVal; sqlite3_result_double(context, rVal); break; } } } /* ................................................................................ assert( argc==1 || argc==2 ); if( argc==2 ){ if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return; n = sqlite3_value_int(argv[1]); if( n>30 ) n = 30; if( n<0 ) n = 0; } if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; r = sqlite3_value_double(argv[0]); sqlite3_snprintf(sizeof(zBuf),zBuf,"%.*f",n,r); sqlite3_result_double(context, atof(zBuf)); } /* ** Implementation of the upper() and lower() SQL functions. */ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ unsigned char *z; ................................................................................ ** Implementation of random(). Return a random integer. */ static void randomFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite_int64 r; sqlite3Randomness(sizeof(r), &r); if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */ /* can always do abs() of the result */ sqlite3_result_int64(context, r); } /* ** Implementation of the last_insert_rowid() SQL function. The return ** value is the same as the sqlite3_last_insert_rowid() API function. */ static void last_insert_rowid( ................................................................................ /* ** An instance of the following structure holds the context of a ** sum() or avg() aggregate computation. */ typedef struct SumCtx SumCtx; struct SumCtx { double rSum; /* Floating point sum */ i64 iSum; /* Integer sum */ i64 cnt; /* Number of elements summed */ u8 overflow; /* True if integer overflow seen */ u8 approx; /* True if non-integer value was input to the sum */ }; /* ** Routines used to compute the sum, average, and total. ** ** The SUM() function follows the (broken) SQL standard which means ** that it returns NULL if it sums over no inputs. TOTAL returns ................................................................................ int type; assert( argc==1 ); p = sqlite3_aggregate_context(context, sizeof(*p)); type = sqlite3_value_numeric_type(argv[0]); if( p && type!=SQLITE_NULL ){ p->cnt++; if( type==SQLITE_INTEGER ){ i64 v = sqlite3_value_int64(argv[0]); p->rSum += v; if( (p->approx|p->overflow)==0 ){ i64 iNewSum = p->iSum + v; int s1 = p->iSum >> (sizeof(i64)*8-1); int s2 = v >> (sizeof(i64)*8-1); int s3 = iNewSum >> (sizeof(i64)*8-1); p->overflow = (s1&s2&~s3) | (~s1&~s2&s3); p->iSum = iNewSum; } }else{ p->rSum += sqlite3_value_double(argv[0]); p->approx = 1; } } } static void sumFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ if( p->overflow ){ sqlite3_result_error(context,"integer overflow",-1); }else if( p->approx ){ sqlite3_result_double(context, p->rSum); }else{ sqlite3_result_int64(context, p->iSum); } } } static void avgFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ sqlite3_result_double(context, p->rSum/(double)p->cnt); } } static void totalFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); sqlite3_result_double(context, p ? p->rSum : 0.0); } /* ** The following structure keeps track of state information for the ** count() aggregate function. */ typedef struct CountCtx CountCtx; ................................................................................ if( pFunc && aAggs[i].needCollSeq ){ pFunc->needCollSeq = 1; } } } sqlite3RegisterDateTimeFunctions(db); #ifdef SQLITE_SSE (void)sqlite3SseFunctions(db); #endif #ifdef SQLITE_CASE_SENSITIVE_LIKE sqlite3RegisterLikeFunctions(db, 1); #else sqlite3RegisterLikeFunctions(db, 0); #endif } |
Changes to SQLite.Interop/src/hash.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 .. 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 ... 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 ... 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 ... 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 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: hash.c,v 1.18 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** ................................................................................ if( keyClass==SQLITE_HASH_POINTER || keyClass==SQLITE_HASH_INT ) copyKey = 0; #endif pNew->copyKey = copyKey; pNew->first = 0; pNew->count = 0; pNew->htsize = 0; pNew->ht = 0; } /* Remove all entries from a hash table. Reclaim all memory. ** Call this routine to delete a hash table or to reset a hash table ** to the empty state. */ void sqlite3HashClear(Hash *pH){ HashElem *elem; /* For looping over all elements of the table */ assert( pH!=0 ); elem = pH->first; pH->first = 0; if( pH->ht ) sqliteFree(pH->ht); pH->ht = 0; pH->htsize = 0; while( elem ){ HashElem *next_elem = elem->next; if( pH->copyKey && elem->pKey ){ sqliteFree(elem->pKey); } sqliteFree(elem); elem = next_elem; } pH->count = 0; } #if 0 /* NOT USED */ /* ................................................................................ */ static void rehash(Hash *pH, int new_size){ struct _ht *new_ht; /* The new hash table */ HashElem *elem, *next_elem; /* For looping over existing elements */ int (*xHash)(const void*,int); /* The hash function */ assert( (new_size & (new_size-1))==0 ); new_ht = (struct _ht *)sqliteMalloc( new_size*sizeof(struct _ht) ); if( new_ht==0 ) return; if( pH->ht ) sqliteFree(pH->ht); pH->ht = new_ht; pH->htsize = new_size; xHash = hashFunction(pH->keyClass); for(elem=pH->first, pH->first=0; elem; elem = next_elem){ int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1); next_elem = elem->next; insertElement(pH, &new_ht[h], elem); ................................................................................ pEntry->chain = elem->next; } pEntry->count--; if( pEntry->count<=0 ){ pEntry->chain = 0; } if( pH->copyKey && elem->pKey ){ sqliteFree(elem->pKey); } sqliteFree( elem ); pH->count--; if( pH->count<=0 ){ assert( pH->first==0 ); assert( pH->count==0 ); sqlite3HashClear(pH); } } ................................................................................ removeElementGivenHash(pH,elem,h); }else{ elem->data = data; } return old_data; } if( data==0 ) return 0; new_elem = (HashElem*)sqliteMalloc( sizeof(HashElem) ); if( new_elem==0 ) return data; if( pH->copyKey && pKey!=0 ){ new_elem->pKey = sqliteMallocRaw( nKey ); if( new_elem->pKey==0 ){ sqliteFree(new_elem); return data; } memcpy((void*)new_elem->pKey, pKey, nKey); }else{ new_elem->pKey = (void*)pKey; } new_elem->nKey = nKey; pH->count++; if( pH->htsize==0 ){ rehash(pH,8); if( pH->htsize==0 ){ pH->count = 0; sqliteFree(new_elem); return data; } } if( pH->count > pH->htsize ){ rehash(pH,pH->htsize*2); } assert( pH->htsize>0 ); assert( (pH->htsize & (pH->htsize-1))==0 ); h = hraw & (pH->htsize-1); insertElement(pH, &pH->ht[h], new_elem); new_elem->data = data; return 0; } |
| > > | | | | | | | | | | | |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 .. 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 ... 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 ... 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 ... 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 393 394 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: hash.c,v 1.19 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** ................................................................................ if( keyClass==SQLITE_HASH_POINTER || keyClass==SQLITE_HASH_INT ) copyKey = 0; #endif pNew->copyKey = copyKey; pNew->first = 0; pNew->count = 0; pNew->htsize = 0; pNew->ht = 0; pNew->xMalloc = sqlite3MallocX; pNew->xFree = sqlite3FreeX; } /* Remove all entries from a hash table. Reclaim all memory. ** Call this routine to delete a hash table or to reset a hash table ** to the empty state. */ void sqlite3HashClear(Hash *pH){ HashElem *elem; /* For looping over all elements of the table */ assert( pH!=0 ); elem = pH->first; pH->first = 0; if( pH->ht ) pH->xFree(pH->ht); pH->ht = 0; pH->htsize = 0; while( elem ){ HashElem *next_elem = elem->next; if( pH->copyKey && elem->pKey ){ pH->xFree(elem->pKey); } pH->xFree(elem); elem = next_elem; } pH->count = 0; } #if 0 /* NOT USED */ /* ................................................................................ */ static void rehash(Hash *pH, int new_size){ struct _ht *new_ht; /* The new hash table */ HashElem *elem, *next_elem; /* For looping over existing elements */ int (*xHash)(const void*,int); /* The hash function */ assert( (new_size & (new_size-1))==0 ); new_ht = (struct _ht *)pH->xMalloc( new_size*sizeof(struct _ht) ); if( new_ht==0 ) return; if( pH->ht ) pH->xFree(pH->ht); pH->ht = new_ht; pH->htsize = new_size; xHash = hashFunction(pH->keyClass); for(elem=pH->first, pH->first=0; elem; elem = next_elem){ int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1); next_elem = elem->next; insertElement(pH, &new_ht[h], elem); ................................................................................ pEntry->chain = elem->next; } pEntry->count--; if( pEntry->count<=0 ){ pEntry->chain = 0; } if( pH->copyKey && elem->pKey ){ pH->xFree(elem->pKey); } pH->xFree( elem ); pH->count--; if( pH->count<=0 ){ assert( pH->first==0 ); assert( pH->count==0 ); sqlite3HashClear(pH); } } ................................................................................ removeElementGivenHash(pH,elem,h); }else{ elem->data = data; } return old_data; } if( data==0 ) return 0; new_elem = (HashElem*)pH->xMalloc( sizeof(HashElem) ); if( new_elem==0 ) return data; if( pH->copyKey && pKey!=0 ){ new_elem->pKey = pH->xMalloc( nKey ); if( new_elem->pKey==0 ){ pH->xFree(new_elem); return data; } memcpy((void*)new_elem->pKey, pKey, nKey); }else{ new_elem->pKey = (void*)pKey; } new_elem->nKey = nKey; pH->count++; if( pH->htsize==0 ){ rehash(pH,8); if( pH->htsize==0 ){ pH->count = 0; pH->xFree(new_elem); return data; } } if( pH->count > pH->htsize ){ rehash(pH,pH->htsize*2); } assert( pH->htsize>0 ); assert( (pH->htsize & (pH->htsize-1))==0 ); h = hraw & (pH->htsize-1); insertElement(pH, &pH->ht[h], new_elem); new_elem->data = data; return 0; } |
Changes to SQLite.Interop/src/hash.h.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** ** $Id: hash.h,v 1.18 2006/02/11 14:43:38 rmsimpson Exp $ */ #ifndef _SQLITE_HASH_H_ #define _SQLITE_HASH_H_ /* Forward declarations of structures. */ typedef struct Hash Hash; typedef struct HashElem HashElem; ................................................................................ ** this structure opaque. */ struct Hash { char keyClass; /* SQLITE_HASH_INT, _POINTER, _STRING, _BINARY */ char copyKey; /* True if copy of key made on insert */ int count; /* Number of entries in this table */ HashElem *first; /* The first element of the array */ int htsize; /* Number of buckets in the hash table */ struct _ht { /* the hash table */ int count; /* Number of entries with this hash */ HashElem *chain; /* Pointer to first entry with this hash */ } *ht; }; |
|
>
>
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** ** $Id: hash.h,v 1.19 2006/04/11 18:06:57 rmsimpson Exp $ */ #ifndef _SQLITE_HASH_H_ #define _SQLITE_HASH_H_ /* Forward declarations of structures. */ typedef struct Hash Hash; typedef struct HashElem HashElem; ................................................................................ ** this structure opaque. */ struct Hash { char keyClass; /* SQLITE_HASH_INT, _POINTER, _STRING, _BINARY */ char copyKey; /* True if copy of key made on insert */ int count; /* Number of entries in this table */ HashElem *first; /* The first element of the array */ void *(*xMalloc)(int); /* malloc() function to use */ void (*xFree)(void *); /* free() function to use */ int htsize; /* Number of buckets in the hash table */ struct _ht { /* the hash table */ int count; /* Number of entries with this hash */ HashElem *chain; /* Pointer to first entry with this hash */ } *ht; }; |
Changes to SQLite.Interop/src/insert.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 ... 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 ... 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
** 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.19 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Set P3 of the most recently inserted opcode to a column affinity ** string for index pIdx. A column affinity string has one character ** for each column in the table, according to the affinity of the column: ................................................................................ /* Ensure that: * (a) the table is not read-only, * (b) that if it is a view then ON INSERT triggers exist */ if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){ goto insert_cleanup; } if( pTab==0 ) goto insert_cleanup; /* If pTab is really a view, make sure it has been initialized. */ if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){ goto insert_cleanup; } ................................................................................ if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){ int allOk = sqlite3VdbeMakeLabel(v); assert( pParse->ckOffset==0 ); pParse->ckOffset = nCol; sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1); assert( pParse->ckOffset==nCol ); pParse->ckOffset = 0; sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, OE_Abort); sqlite3VdbeResolveLabel(v, allOk); } #endif /* !defined(SQLITE_OMIT_CHECK) */ /* If we have an INTEGER PRIMARY KEY, make sure the primary key ** of the new record does not previously exist. Except, if this ** is an UPDATE and the primary key is not changing, that is OK. ................................................................................ case OE_Abort: case OE_Fail: { sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError, "PRIMARY KEY must be unique", P3_STATIC); break; } case OE_Replace: { sqlite3GenerateRowIndexDelete(pParse->db, v, pTab, base, 0); if( isUpdate ){ sqlite3VdbeAddOp(v, OP_Dup, nCol+hasTwoRowids, 1); sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); } seenReplace = 1; break; } |
| | > > > > > | > | |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 ... 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 ... 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
** 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.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Set P3 of the most recently inserted opcode to a column affinity ** string for index pIdx. A column affinity string has one character ** for each column in the table, according to the affinity of the column: ................................................................................ /* Ensure that: * (a) the table is not read-only, * (b) that if it is a view then ON INSERT triggers exist */ if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){ goto insert_cleanup; } assert( pTab!=0 ); /* If pTab is really a view, make sure it has been initialized. */ if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){ goto insert_cleanup; } ................................................................................ if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){ int allOk = sqlite3VdbeMakeLabel(v); assert( pParse->ckOffset==0 ); pParse->ckOffset = nCol; sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1); assert( pParse->ckOffset==nCol ); pParse->ckOffset = 0; onError = overrideError!=OE_Default ? overrideError : OE_Abort; if( onError==OE_Ignore || onError==OE_Replace ){ sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0); sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest); }else{ sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); } sqlite3VdbeResolveLabel(v, allOk); } #endif /* !defined(SQLITE_OMIT_CHECK) */ /* If we have an INTEGER PRIMARY KEY, make sure the primary key ** of the new record does not previously exist. Except, if this ** is an UPDATE and the primary key is not changing, that is OK. ................................................................................ case OE_Abort: case OE_Fail: { sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError, "PRIMARY KEY must be unique", P3_STATIC); break; } case OE_Replace: { sqlite3GenerateRowIndexDelete(v, pTab, base, 0); if( isUpdate ){ sqlite3VdbeAddOp(v, OP_Dup, nCol+hasTwoRowids, 1); sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); } seenReplace = 1; break; } |
Changes to SQLite.Interop/src/keywordhash.h.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
TK_REPLACE, TK_JOIN_KW, TK_RESTRICT, TK_PRIMARY, TK_QUERY, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_WHEN, TK_UNION, TK_UNIQUE, TK_USING, TK_VACUUM, TK_VALUES, TK_VIEW, TK_WHERE, }; int h, i; if( n<2 ) return TK_ID; h = ((sqlite3UpperToLower[((unsigned char*)z)[0]]*4) ^ (sqlite3UpperToLower[((unsigned char*)z)[n-1]]*3) ^ n) % 127; for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){ if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){ return aCode[i]; } } return TK_ID; } int sqlite3KeywordCode(const unsigned char *z, int n){ return keywordCode((char*)z, n); } |
| | |
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
TK_REPLACE, TK_JOIN_KW, TK_RESTRICT, TK_PRIMARY, TK_QUERY, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_WHEN, TK_UNION, TK_UNIQUE, TK_USING, TK_VACUUM, TK_VALUES, TK_VIEW, TK_WHERE, }; int h, i; if( n<2 ) return TK_ID; h = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127; for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){ if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){ return aCode[i]; } } return TK_ID; } int sqlite3KeywordCode(const unsigned char *z, int n){ return keywordCode((char*)z, n); } |
Changes to SQLite.Interop/src/legacy.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
** ************************************************************************* ** 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: legacy.c,v 1.18 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ................................................................................ if( zSql==0 ) return SQLITE_OK; while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){ int nCol; char **azVals = 0; pStmt = 0; rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover); if( rc!=SQLITE_OK ){ if( pStmt ) sqlite3_finalize(pStmt); continue; } if( !pStmt ){ /* this happens for a comment or white-space */ zSql = zLeftover; continue; } |
|
>
<
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
** ************************************************************************* ** 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: legacy.c,v 1.19 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ................................................................................ if( zSql==0 ) return SQLITE_OK; while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){ int nCol; char **azVals = 0; pStmt = 0; rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover); assert( rc==SQLITE_OK || pStmt==0 ); if( rc!=SQLITE_OK ){ continue; } if( !pStmt ){ /* this happens for a comment or white-space */ zSql = zLeftover; continue; } |
Changes to SQLite.Interop/src/main.c.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 ... 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 ... 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 ... 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 .... 1226 1227 1228 1229 1230 1231 1232 1233 |
** ************************************************************************* ** 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.20 2006/02/11 14:43:38 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The following constant value is used by the SQLITE_BIGENDIAN and ................................................................................ return SQLITE_OK; } if( sqlite3SafetyCheck(db) ){ return SQLITE_MISUSE; } #ifdef SQLITE_SSE sqlite3_finalize(db->pFetch); #endif /* If there are any outstanding VMs, return SQLITE_BUSY. */ if( db->pVdbe ){ sqlite3Error(db, SQLITE_BUSY, "Unable to close due to unfinalised statements"); return SQLITE_BUSY; ................................................................................ ** an integer number of milliseconds passed in as the first ** argument. */ static int sqliteDefaultBusyCallback( void *ptr, /* Database connection */ int count /* Number of times table has been busy */ ){ #if SQLITE_MIN_SLEEP_MS==1 static const u8 delays[] = { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; static const u8 totals[] = { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; # define NDELAY (sizeof(delays)/sizeof(delays[0])) int timeout = ((sqlite3 *)ptr)->busyTimeout; int delay, prior; ................................................................................ sqlite3* db, const char *zName, int enc, void* pCtx, int(*xCompare)(void*,int,const void*,int,const void*) ){ CollSeq *pColl; if( sqlite3SafetyCheck(db) ){ return SQLITE_MISUSE; } /* If SQLITE_UTF16 is specified as the encoding type, transform this ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. */ if( enc==SQLITE_UTF16 ){ enc = SQLITE_UTF16NATIVE; } if( enc!=SQLITE_UTF8 && enc!=SQLITE_UTF16LE && enc!=SQLITE_UTF16BE ){ sqlite3Error(db, SQLITE_ERROR, "Param 3 to sqlite3_create_collation() must be one of " "SQLITE_UTF8, SQLITE_UTF16, SQLITE_UTF16LE or SQLITE_UTF16BE" ); return SQLITE_ERROR; } /* Check if this call is removing or replacing an existing collation ** sequence. If so, and there are active VMs, return busy. If there ** are no active VMs, invalidate any pre-compiled statements. */ pColl = sqlite3FindCollSeq(db, (u8)enc, zName, strlen(zName), 0); if( pColl && pColl->xCmp ){ if( db->activeVdbeCnt ){ sqlite3Error(db, SQLITE_BUSY, "Unable to delete/modify collation sequence due to active statements"); return SQLITE_BUSY; } sqlite3ExpirePreparedStatements(db); } pColl = sqlite3FindCollSeq(db, (u8)enc, zName, strlen(zName), 1); if( pColl ){ pColl->xCmp = xCompare; pColl->pUser = pCtx; pColl->enc = enc; } sqlite3Error(db, SQLITE_OK, 0); return SQLITE_OK; } /* ................................................................................ /* Open the backend database driver */ rc = sqlite3BtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt); if( rc!=SQLITE_OK ){ sqlite3Error(db, rc, 0); db->magic = SQLITE_MAGIC_CLOSED; goto opendb_out; } #ifndef SQLITE_OMIT_PARSER db->aDb[0].pSchema = sqlite3SchemaGet(db->aDb[0].pBt); db->aDb[1].pSchema = sqlite3SchemaGet(0); #endif if( db->aDb[0].pSchema ){ ENC(db) = SQLITE_UTF8; } /* The default safety_level for the main database is 'full'; for the temp ** database it is 'NONE'. This matches the pager layer defaults. */ db->aDb[0].zName = "main"; db->aDb[0].safety_level = 3; #ifndef SQLITE_OMIT_TEMPDB ................................................................................ rc = SQLITE_ERROR; } sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg); sqliteFree(zErrMsg); return sqlite3ApiExit(db, rc); } #endif |
| < > > > > | > > | | < > | < < < | | | < < < > < |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 ... 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 ... 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 ... 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 .... 1226 1227 1228 1229 1230 1231 1232 |
** ************************************************************************* ** 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.21 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The following constant value is used by the SQLITE_BIGENDIAN and ................................................................................ return SQLITE_OK; } if( sqlite3SafetyCheck(db) ){ return SQLITE_MISUSE; } #ifdef SQLITE_SSE { extern void sqlite3SseCleanup(sqlite3*); sqlite3SseCleanup(db); } #endif /* If there are any outstanding VMs, return SQLITE_BUSY. */ if( db->pVdbe ){ sqlite3Error(db, SQLITE_BUSY, "Unable to close due to unfinalised statements"); return SQLITE_BUSY; ................................................................................ ** an integer number of milliseconds passed in as the first ** argument. */ static int sqliteDefaultBusyCallback( void *ptr, /* Database connection */ int count /* Number of times table has been busy */ ){ #if OS_WIN || (defined(HAVE_USLEEP) && HAVE_USLEEP) static const u8 delays[] = { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; static const u8 totals[] = { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; # define NDELAY (sizeof(delays)/sizeof(delays[0])) int timeout = ((sqlite3 *)ptr)->busyTimeout; int delay, prior; ................................................................................ sqlite3* db, const char *zName, int enc, void* pCtx, int(*xCompare)(void*,int,const void*,int,const void*) ){ CollSeq *pColl; int enc2; if( sqlite3SafetyCheck(db) ){ return SQLITE_MISUSE; } /* If SQLITE_UTF16 is specified as the encoding type, transform this ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. */ enc2 = enc & ~SQLITE_UTF16_ALIGNED; if( enc2==SQLITE_UTF16 ){ enc2 = SQLITE_UTF16NATIVE; } if( (enc2&~3)!=0 ){ sqlite3Error(db, SQLITE_ERROR, "unknown encoding"); return SQLITE_ERROR; } /* Check if this call is removing or replacing an existing collation ** sequence. If so, and there are active VMs, return busy. If there ** are no active VMs, invalidate any pre-compiled statements. */ pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 0); if( pColl && pColl->xCmp ){ if( db->activeVdbeCnt ){ sqlite3Error(db, SQLITE_BUSY, "Unable to delete/modify collation sequence due to active statements"); return SQLITE_BUSY; } sqlite3ExpirePreparedStatements(db); } pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 1); if( pColl ){ pColl->xCmp = xCompare; pColl->pUser = pCtx; pColl->enc = enc2 | (enc & SQLITE_UTF16_ALIGNED); } sqlite3Error(db, SQLITE_OK, 0); return SQLITE_OK; } /* ................................................................................ /* Open the backend database driver */ rc = sqlite3BtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt); if( rc!=SQLITE_OK ){ sqlite3Error(db, rc, 0); db->magic = SQLITE_MAGIC_CLOSED; goto opendb_out; } db->aDb[0].pSchema = sqlite3SchemaGet(db->aDb[0].pBt); db->aDb[1].pSchema = sqlite3SchemaGet(0); if( db->aDb[0].pSchema ){ ENC(db) = SQLITE_UTF8; } /* The default safety_level for the main database is 'full'; for the temp ** database it is 'NONE'. This matches the pager layer defaults. */ db->aDb[0].zName = "main"; db->aDb[0].safety_level = 3; #ifndef SQLITE_OMIT_TEMPDB ................................................................................ rc = SQLITE_ERROR; } sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg); sqliteFree(zErrMsg); return sqlite3ApiExit(db, rc); } #endif |
Changes to SQLite.Interop/src/os_unix.c.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 ... 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 ... 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 ... 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 ... 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 ... 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 .... 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 .... 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 .... 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ unsigned char locktype; /* The type of lock held on this fd */ unsigned char isOpen; /* True if needs to be closed */ unsigned char fullSync; /* Use F_FULLSYNC if available */ int dirfd; /* File descriptor for the directory */ #ifdef SQLITE_UNIX_THREADS pthread_t tid; /* The thread that "owns" this OsFile */ #endif }; /* ** Provide the ability to override some OS-layer functions during ................................................................................ }; /* ** These hash tables map inodes and file descriptors (really, lockKey and ** openKey structures) into lockInfo and openCnt structures. Access to ** these hash tables must be protected by a mutex. */ static Hash lockHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; static Hash openHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; #ifdef SQLITE_UNIX_THREADS /* ** This variable records whether or not threads can override each others ** locks. ** ** 0: No. Threads cannot override each others locks. ................................................................................ ** Release a lockInfo structure previously allocated by findLockInfo(). */ static void releaseLockInfo(struct lockInfo *pLock){ assert( sqlite3OsInMutex(1) ); pLock->nRef--; if( pLock->nRef==0 ){ sqlite3HashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0); sqliteFree(pLock); } } /* ** Release a openCnt structure previously allocated by findLockInfo(). */ static void releaseOpenCnt(struct openCnt *pOpen){ assert( sqlite3OsInMutex(1) ); pOpen->nRef--; if( pOpen->nRef==0 ){ sqlite3HashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0); free(pOpen->aPending); sqliteFree(pOpen); } } /* ** Given a file descriptor, locate lockInfo and openCnt structures that ** describes that file descriptor. Create new ones if necessary. The ** return values might be uninitialized if an error occurs. ................................................................................ #endif memset(&key2, 0, sizeof(key2)); key2.dev = statbuf.st_dev; key2.ino = statbuf.st_ino; pLock = (struct lockInfo*)sqlite3HashFind(&lockHash, &key1, sizeof(key1)); if( pLock==0 ){ struct lockInfo *pOld; pLock = sqliteMallocRaw( sizeof(*pLock) ); if( pLock==0 ){ rc = 1; goto exit_findlockinfo; } pLock->key = key1; pLock->nRef = 1; pLock->cnt = 0; pLock->locktype = 0; pOld = sqlite3HashInsert(&lockHash, &pLock->key, sizeof(key1), pLock); if( pOld!=0 ){ assert( pOld==pLock ); sqliteFree(pLock); rc = 1; goto exit_findlockinfo; } }else{ pLock->nRef++; } *ppLock = pLock; if( ppOpen!=0 ){ pOpen = (struct openCnt*)sqlite3HashFind(&openHash, &key2, sizeof(key2)); if( pOpen==0 ){ struct openCnt *pOld; pOpen = sqliteMallocRaw( sizeof(*pOpen) ); if( pOpen==0 ){ releaseLockInfo(pLock); rc = 1; goto exit_findlockinfo; } pOpen->key = key2; pOpen->nRef = 1; pOpen->nLock = 0; pOpen->nPending = 0; pOpen->aPending = 0; pOld = sqlite3HashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen); if( pOld!=0 ){ assert( pOld==pOpen ); sqliteFree(pOpen); releaseLockInfo(pLock); rc = 1; goto exit_findlockinfo; } }else{ pOpen->nRef++; } ................................................................................ if( zBuf[0]==0 ) return 0; if( stat(zBuf, &buf) ) return 0; if( !S_ISDIR(buf.st_mode) ) return 0; if( access(zBuf, 07) ) return 0; #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ return 1; } /* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. */ static int unixRead(OsFile *id, void *pBuf, int amt){ int got; assert( id ); SimulateIOError(SQLITE_IOERR); TIMER_START; got = read(((unixFile*)id)->h, pBuf, amt); TIMER_END; TRACE5("READ %-3d %5d %7d %d\n", ((unixFile*)id)->h, got, last_page, TIMER_ELAPSED); SEEK(0); /* if( got<0 ) got = 0; */ if( got==amt ){ return SQLITE_OK; }else{ return SQLITE_IOERR; } } /* ** Write data from a buffer into a file. Return SQLITE_OK on success ** or some other error code on failure. */ static int unixWrite(OsFile *id, const void *pBuf, int amt){ int wrote = 0; assert( id ); assert( amt>0 ); SimulateIOError(SQLITE_IOERR); SimulateDiskfullError; TIMER_START; while( amt>0 && (wrote = write(((unixFile*)id)->h, pBuf, amt))>0 ){ amt -= wrote; pBuf = &((char*)pBuf)[wrote]; } TIMER_END; TRACE5("WRITE %-3d %5d %7d %d\n", ((unixFile*)id)->h, wrote, last_page, TIMER_ELAPSED); SEEK(0); ................................................................................ */ static int unixSeek(OsFile *id, i64 offset){ assert( id ); SEEK(offset/1024 + 1); #ifdef SQLITE_TEST if( offset ) SimulateDiskfullError #endif lseek(((unixFile*)id)->h, offset, SEEK_SET); return SQLITE_OK; } #ifdef SQLITE_TEST /* ** Count the number of fullsyncs and normal syncs. This is used to test ** that syncs and fullsyncs are occuring at the right times. ................................................................................ releaseLockInfo(id->pLock); releaseOpenCnt(id->pOpen); sqlite3OsLeaveMutex(); id->isOpen = 0; TRACE2("CLOSE %-3d\n", id->h); OpenCounter(-1); sqliteFree(id); *pId = 0; return SQLITE_OK; } /* ** Turn a relative pathname into a full pathname. Return a pointer ** to the full pathname stored in space obtained from sqliteMalloc(). ................................................................................ return 0; } zBuf[0] = 0; sqlite3SetString(&zFull, getcwd(zBuf, 5000), "/", zRelative, (char*)0); sqliteFree(zBuf); } return zFull; } /* ** Change the value of the fullsync flag in the given file descriptor. */ static void unixSetFullSync(OsFile *id, int v){ ................................................................................ ** OsFile. If we run out of memory, close the file and return NULL. */ static int allocateUnixFile(unixFile *pInit, OsFile **pId){ unixFile *pNew; pInit->dirfd = -1; pInit->fullSync = 0; pInit->locktype = 0; SET_THREADID(pInit); pNew = sqliteMalloc( sizeof(unixFile) ); if( pNew==0 ){ close(pInit->h); sqlite3OsEnterMutex(); releaseLockInfo(pInit->pLock); releaseOpenCnt(pInit->pOpen); sqlite3OsLeaveMutex(); *pId = 0; |
> | > | < > | | | | | | > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | |
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ... 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 ... 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 ... 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 ... 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 ... 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 .... 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 .... 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 .... 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 |
struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ unsigned char locktype; /* The type of lock held on this fd */ unsigned char isOpen; /* True if needs to be closed */ unsigned char fullSync; /* Use F_FULLSYNC if available */ int dirfd; /* File descriptor for the directory */ i64 offset; /* Seek offset */ #ifdef SQLITE_UNIX_THREADS pthread_t tid; /* The thread that "owns" this OsFile */ #endif }; /* ** Provide the ability to override some OS-layer functions during ................................................................................ }; /* ** These hash tables map inodes and file descriptors (really, lockKey and ** openKey structures) into lockInfo and openCnt structures. Access to ** these hash tables must be protected by a mutex. */ static Hash lockHash = {SQLITE_HASH_BINARY, 0, 0, 0, sqlite3ThreadSafeMalloc, sqlite3ThreadSafeFree, 0, 0}; static Hash openHash = {SQLITE_HASH_BINARY, 0, 0, 0, sqlite3ThreadSafeMalloc, sqlite3ThreadSafeFree, 0, 0}; #ifdef SQLITE_UNIX_THREADS /* ** This variable records whether or not threads can override each others ** locks. ** ** 0: No. Threads cannot override each others locks. ................................................................................ ** Release a lockInfo structure previously allocated by findLockInfo(). */ static void releaseLockInfo(struct lockInfo *pLock){ assert( sqlite3OsInMutex(1) ); pLock->nRef--; if( pLock->nRef==0 ){ sqlite3HashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0); sqlite3ThreadSafeFree(pLock); } } /* ** Release a openCnt structure previously allocated by findLockInfo(). */ static void releaseOpenCnt(struct openCnt *pOpen){ assert( sqlite3OsInMutex(1) ); pOpen->nRef--; if( pOpen->nRef==0 ){ sqlite3HashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0); free(pOpen->aPending); sqlite3ThreadSafeFree(pOpen); } } /* ** Given a file descriptor, locate lockInfo and openCnt structures that ** describes that file descriptor. Create new ones if necessary. The ** return values might be uninitialized if an error occurs. ................................................................................ #endif memset(&key2, 0, sizeof(key2)); key2.dev = statbuf.st_dev; key2.ino = statbuf.st_ino; pLock = (struct lockInfo*)sqlite3HashFind(&lockHash, &key1, sizeof(key1)); if( pLock==0 ){ struct lockInfo *pOld; pLock = sqlite3ThreadSafeMalloc( sizeof(*pLock) ); if( pLock==0 ){ rc = 1; goto exit_findlockinfo; } pLock->key = key1; pLock->nRef = 1; pLock->cnt = 0; pLock->locktype = 0; pOld = sqlite3HashInsert(&lockHash, &pLock->key, sizeof(key1), pLock); if( pOld!=0 ){ assert( pOld==pLock ); sqlite3ThreadSafeFree(pLock); rc = 1; goto exit_findlockinfo; } }else{ pLock->nRef++; } *ppLock = pLock; if( ppOpen!=0 ){ pOpen = (struct openCnt*)sqlite3HashFind(&openHash, &key2, sizeof(key2)); if( pOpen==0 ){ struct openCnt *pOld; pOpen = sqlite3ThreadSafeMalloc( sizeof(*pOpen) ); if( pOpen==0 ){ releaseLockInfo(pLock); rc = 1; goto exit_findlockinfo; } pOpen->key = key2; pOpen->nRef = 1; pOpen->nLock = 0; pOpen->nPending = 0; pOpen->aPending = 0; pOld = sqlite3HashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen); if( pOld!=0 ){ assert( pOld==pOpen ); sqlite3ThreadSafeFree(pOpen); releaseLockInfo(pLock); rc = 1; goto exit_findlockinfo; } }else{ pOpen->nRef++; } ................................................................................ if( zBuf[0]==0 ) return 0; if( stat(zBuf, &buf) ) return 0; if( !S_ISDIR(buf.st_mode) ) return 0; if( access(zBuf, 07) ) return 0; #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ return 1; } /* ** Seek to the offset in id->offset then read cnt bytes into pBuf. ** Return the number of bytes actually read. Update the offset. */ static int seekAndRead(unixFile *id, void *pBuf, int cnt){ int got; #ifdef USE_PREAD got = pread(id->h, pBuf, cnt, id->offset); #else lseek(id->h, id->offset, SEEK_SET); got = read(id->h, pBuf, cnt); #endif if( got>0 ){ id->offset += got; } return got; } /* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. */ static int unixRead(OsFile *id, void *pBuf, int amt){ int got; assert( id ); SimulateIOError(SQLITE_IOERR); TIMER_START; got = seekAndRead((unixFile*)id, pBuf, amt); TIMER_END; TRACE5("READ %-3d %5d %7d %d\n", ((unixFile*)id)->h, got, last_page, TIMER_ELAPSED); SEEK(0); /* if( got<0 ) got = 0; */ if( got==amt ){ return SQLITE_OK; }else{ return SQLITE_IOERR; } } /* ** Seek to the offset in id->offset then read cnt bytes into pBuf. ** Return the number of bytes actually read. Update the offset. */ static int seekAndWrite(unixFile *id, const void *pBuf, int cnt){ int got; #ifdef USE_PREAD got = pwrite(id->h, pBuf, cnt, id->offset); #else lseek(id->h, id->offset, SEEK_SET); got = write(id->h, pBuf, cnt); #endif if( got>0 ){ id->offset += got; } return got; } /* ** Write data from a buffer into a file. Return SQLITE_OK on success ** or some other error code on failure. */ static int unixWrite(OsFile *id, const void *pBuf, int amt){ int wrote = 0; assert( id ); assert( amt>0 ); SimulateIOError(SQLITE_IOERR); SimulateDiskfullError; TIMER_START; while( amt>0 && (wrote = seekAndWrite((unixFile*)id, pBuf, amt))>0 ){ amt -= wrote; pBuf = &((char*)pBuf)[wrote]; } TIMER_END; TRACE5("WRITE %-3d %5d %7d %d\n", ((unixFile*)id)->h, wrote, last_page, TIMER_ELAPSED); SEEK(0); ................................................................................ */ static int unixSeek(OsFile *id, i64 offset){ assert( id ); SEEK(offset/1024 + 1); #ifdef SQLITE_TEST if( offset ) SimulateDiskfullError #endif ((unixFile*)id)->offset = offset; return SQLITE_OK; } #ifdef SQLITE_TEST /* ** Count the number of fullsyncs and normal syncs. This is used to test ** that syncs and fullsyncs are occuring at the right times. ................................................................................ releaseLockInfo(id->pLock); releaseOpenCnt(id->pOpen); sqlite3OsLeaveMutex(); id->isOpen = 0; TRACE2("CLOSE %-3d\n", id->h); OpenCounter(-1); sqlite3ThreadSafeFree(id); *pId = 0; return SQLITE_OK; } /* ** Turn a relative pathname into a full pathname. Return a pointer ** to the full pathname stored in space obtained from sqliteMalloc(). ................................................................................ return 0; } zBuf[0] = 0; sqlite3SetString(&zFull, getcwd(zBuf, 5000), "/", zRelative, (char*)0); sqliteFree(zBuf); } #if 0 /* ** Remove "/./" path elements and convert "/A/./" path elements ** to just "/". */ if( zFull ){ int i, j; for(i=j=0; zFull[i]; i++){ if( zFull[i]=='/' ){ if( zFull[i+1]=='/' ) continue; if( zFull[i+1]=='.' && zFull[i+2]=='/' ){ i += 1; continue; } if( zFull[i+1]=='.' && zFull[i+2]=='.' && zFull[i+3]=='/' ){ while( j>0 && zFull[j-1]!='/' ){ j--; } i += 3; continue; } } zFull[j++] = zFull[i]; } zFull[j] = 0; } #endif return zFull; } /* ** Change the value of the fullsync flag in the given file descriptor. */ static void unixSetFullSync(OsFile *id, int v){ ................................................................................ ** OsFile. If we run out of memory, close the file and return NULL. */ static int allocateUnixFile(unixFile *pInit, OsFile **pId){ unixFile *pNew; pInit->dirfd = -1; pInit->fullSync = 0; pInit->locktype = 0; pInit->offset = 0; SET_THREADID(pInit); pNew = sqlite3ThreadSafeMalloc( sizeof(unixFile) ); if( pNew==0 ){ close(pInit->h); sqlite3OsEnterMutex(); releaseLockInfo(pInit->pLock); releaseOpenCnt(pInit->pOpen); sqlite3OsLeaveMutex(); *pId = 0; |
Changes to SQLite.Interop/src/os_win.c.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
#endif /* OS_WINCE */ /* ** Convert a UTF-8 string to UTF-32. Space to hold the returned string ** is obtained from sqliteMalloc. */ static WCHAR *utf8ToUnicode(const char *zFilename){ int nByte; WCHAR *zWideFilename; if( !isNT() ){ return 0; } nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0)*sizeof(WCHAR); zWideFilename = sqliteMalloc( nByte*sizeof(zWideFilename[0]) ); if( zWideFilename==0 ){ return 0; } nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nByte); if( nByte==0 ){ sqliteFree(zWideFilename); zWideFilename = 0; } return zWideFilename; } /* |
| | | | | |
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
#endif /* OS_WINCE */ /* ** Convert a UTF-8 string to UTF-32. Space to hold the returned string ** is obtained from sqliteMalloc. */ static WCHAR *utf8ToUnicode(const char *zFilename){ int nChar; WCHAR *zWideFilename; if( !isNT() ){ return 0; } nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) ); if( zWideFilename==0 ){ return 0; } nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); if( nChar==0 ){ sqliteFree(zWideFilename); zWideFilename = 0; } return zWideFilename; } /* |
Changes to SQLite.Interop/src/pager.c.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 .. 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 ... 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 ... 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 ... 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 ... 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 ... 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 .... 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 .... 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 .... 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 .... 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 .... 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 .... 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 .... 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 .... 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 .... 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 .... 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 .... 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 .... 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 .... 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 .... 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 .... 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 .... 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 .... 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 |
** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.20 2006/02/11 14:43:39 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include "os.h" #include "pager.h" #include <assert.h> #include <string.h> ................................................................................ ** The following two macros are used within the TRACEX() macros above ** to print out file-descriptors. ** ** PAGERID() takes a pointer to a Pager struct as it's argument. The ** associated file-descriptor is returned. FILEHANDLEID() takes an OsFile ** struct as it's argument. */ #define PAGERID(p) FILEHANDLEID(&(p)->fd) #define FILEHANDLEID(fd) (sqlite3OsFileHandle(&fd)) /* ** The page cache as a whole is always in one of the following ** states: ** ** PAGER_UNLOCK The page cache is not currently reading or ** writing the database file. There is no ................................................................................ u8 *pStmt; /* Text as it was at the beginning of the current statement */ }; /* ** A macro used for invoking the codec if there is one */ #ifdef SQLITE_HAS_CODEC # define CODEC(P,D,N,X) if( P->xCodec ){ P->xCodec(P->pCodecArg,D,N,X); } #else # define CODEC(P,D,N,X) #endif /* ** Convert a pointer to a PgHdr into a pointer to its data ** and back again. */ #define PGHDR_TO_DATA(P) ((void*)(&(P)[1])) ................................................................................ int sectorSize; /* Assumed sector size during rollback */ #ifdef SQLITE_TEST int nHit, nMiss, nOvfl; /* Cache hits, missing, and LRU overflows */ int nRead,nWrite; /* Database pages read/written */ #endif void (*xDestructor)(void*,int); /* Call this routine when freeing pages */ void (*xReiniter)(void*,int); /* Call this routine when reloading pages */ void (*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ void *pCodecArg; /* First argument to xCodec() */ PgHdr *aHash[N_PG_HASH]; /* Hash table to map page number to PgHdr */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT Pager *pNext; /* Linked list of pagers in this thread */ #endif }; ................................................................................ */ static int write32bits(OsFile *fd, u32 val){ char ac[4]; put32bits(ac, val); return sqlite3OsWrite(fd, ac, 4); } /* ** Write the 32-bit integer 'val' into the page identified by page header ** 'p' at offset 'offset'. */ static void store32bits(u32 val, PgHdr *p, int offset){ char *ac; ac = &((char*)PGHDR_TO_DATA(p))[offset]; put32bits(ac, val); } /* ** Read a 32-bit integer at offset 'offset' from the page identified by ** page header 'p'. */ static u32 retrieve32bits(PgHdr *p, int offset){ unsigned char *ac; ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset]; ................................................................................ ** though fast and simple, catches the mostly likely kind of corruption. ** ** FIX ME: Consider adding every 200th (or so) byte of the data to the ** checksum. That way if a single page spans 3 or more disk sectors and ** only the middle sector is corrupt, we will still have a reasonable ** chance of failing the checksum and thus detecting the problem. */ static u32 pager_cksum(Pager *pPager, Pgno pgno, const u8 *aData){ u32 cksum = pPager->cksumInit; int i = pPager->pageSize-200; while( i>0 ){ cksum += aData[i]; i -= 200; } return cksum; ................................................................................ if( pgno>(unsigned)pPager->dbSize ){ return SQLITE_OK; } if( useCksum ){ rc = read32bits(jfd, &cksum); if( rc ) return rc; pPager->journalOff += 4; if( pager_cksum(pPager, pgno, aData)!=cksum ){ return SQLITE_DONE; } } assert( pPager->state==PAGER_RESERVED || pPager->state>=PAGER_EXCLUSIVE ); /* If the pager is in RESERVED state, then there must be a copy of this ................................................................................ memcpy(pData, aData, pPager->pageSize); if( pPager->xDestructor ){ /*** FIX ME: Should this be xReinit? ***/ pPager->xDestructor(pData, pPager->pageSize); } #ifdef SQLITE_CHECK_PAGES pPg->pageHash = pager_pagehash(pPg); #endif CODEC(pPager, pData, pPg->pgno, 3); } return rc; } /* ** Parameter zMaster is the name of a master journal file. A single journal ** file that referred to the master journal file has just been rolled back. ................................................................................ if( (int)pPg->pgno <= pPager->origDbSize ){ rc = sqlite3OsSeek(pPager->fd, pPager->pageSize*(i64)(pPg->pgno-1)); if( rc==SQLITE_OK ){ rc = sqlite3OsRead(pPager->fd, zBuf, pPager->pageSize); } TRACE3("REFETCH %d page %d\n", PAGERID(pPager), pPg->pgno); if( rc ) break; CODEC(pPager, zBuf, pPg->pgno, 2); }else{ memset(zBuf, 0, pPager->pageSize); } if( pPg->nRef==0 || memcmp(zBuf, PGHDR_TO_DATA(pPg), pPager->pageSize) ){ memcpy(PGHDR_TO_DATA(pPg), zBuf, pPager->pageSize); if( pPager->xReiniter ){ pPager->xReiniter(PGHDR_TO_DATA(pPg), pPager->pageSize); ................................................................................ rc = pager_truncate(pPager, mxPg); if( rc!=SQLITE_OK ){ goto end_playback; } pPager->dbSize = mxPg; } /* rc = sqlite3OsSeek(pPager->jfd, JOURNAL_HDR_SZ(pPager)); */ if( rc!=SQLITE_OK ) goto end_playback; /* Copy original pages out of the journal and back into the database file. */ for(i=0; i<nRec; i++){ rc = pager_playback_one_page(pPager, pPager->jfd, 1); if( rc!=SQLITE_OK ){ if( rc==SQLITE_DONE ){ rc = SQLITE_OK; ................................................................................ break; }else{ goto end_playback; } } } } /* Pages that have been written to the journal but never synced ** where not restored by the loop above. We have to restore those ** pages by reading them back from the original database. */ assert( rc==SQLITE_OK ); pager_reload_cache(pPager); end_playback: if( rc==SQLITE_OK ){ rc = pager_unwritelock(pPager); } if( zMaster ){ /* If there was a master journal and this routine will return true, ................................................................................ return n; } /* ** Forward declaration */ static int syncJournal(Pager*); /* ** Unlink pPg from it's hash chain. Also set the page number to 0 to indicate ** that the page is not part of any hash chain. This is required because the ** sqlite3pager_movepage() routine can leave a page in the ** pNextFree/pPrevFree list that is not a part of any hash-chain. ................................................................................ assert( pPager->aHash[pager_hash(pPg->pgno)]!=pPg ); pPg->pPrevHash->pNextHash = pPg->pNextHash; }else{ int h = pager_hash(pPg->pgno); assert( pPager->aHash[h]==pPg ); pPager->aHash[h] = pPg->pNextHash; } pPg->pgno = 0; pPg->pNextHash = pPg->pPrevHash = 0; } /* ** Unlink a page from the free list (the list of all pages where nRef==0) ** and from its hash collision chain. ................................................................................ /* Remove the pager from the linked list of pagers starting at ** ThreadData.pPager if memory-management is enabled. */ if( pPager==pTsd->pPager ){ pTsd->pPager = pPager->pNext; }else{ Pager *pTmp; for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext); pTmp->pNext = pPager->pNext; } #endif sqliteFree(pPager); return SQLITE_OK; } ................................................................................ if( rc ) return rc; /* If there are dirty pages in the page cache with page numbers greater ** than Pager.dbSize, this means sqlite3pager_truncate() was called to ** make the file smaller (presumably by auto-vacuum code). Do not write ** any such pages to the file. */ if( pList->pgno<=pPager->dbSize ){ CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6); TRACE3("STORE %d page %d\n", PAGERID(pPager), pList->pgno); rc = sqlite3OsWrite(pPager->fd, PGHDR_TO_DATA(pList), pPager->pageSize); CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 0); TEST_INCR(pPager->nWrite); } #ifndef NDEBUG else{ TRACE3("NOSTORE %d page %d\n", PAGERID(pPager), pList->pgno); } #endif ................................................................................ */ PgHdr *pTmp; assert( pPg ); page_remove_from_stmt_list(pPg); if( pPg==p->pAll ){ p->pAll = pPg->pNextAll; }else{ for( pTmp=p->pAll; pTmp->pNextAll!=pPg; pTmp=pTmp->pNextAll ); pTmp->pNextAll = pPg->pNextAll; } nReleased += sqliteAllocSize(pPg); sqliteFree(pPg); } if( rc!=SQLITE_OK ){ ................................................................................ assert( MEMDB==0 ); rc = sqlite3OsSeek(pPager->fd, (pgno-1)*(i64)pPager->pageSize); if( rc==SQLITE_OK ){ rc = sqlite3OsRead(pPager->fd, PGHDR_TO_DATA(pPg), pPager->pageSize); } TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno); CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); if( rc!=SQLITE_OK ){ i64 fileSize; int rc2 = sqlite3OsFileSize(pPager->fd, &fileSize); if( rc2!=SQLITE_OK || fileSize>=pgno*pPager->pageSize ){ /* An IO error occured in one of the the sqlite3OsSeek() or ** sqlite3OsRead() calls above. */ pPg->pgno = 0; ................................................................................ /* The transaction journal now exists and we have a RESERVED or an ** EXCLUSIVE lock on the main database file. Write the current page to ** the transaction journal if it is not there already. */ if( !pPg->inJournal && (pPager->useJournal || MEMDB) ){ if( (int)pPg->pgno <= pPager->origDbSize ){ int szPg; u32 saved; if( MEMDB ){ PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager); TRACE3("JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); assert( pHist->pOrig==0 ); pHist->pOrig = sqliteMallocRaw( pPager->pageSize ); if( pHist->pOrig ){ memcpy(pHist->pOrig, PGHDR_TO_DATA(pPg), pPager->pageSize); } }else{ u32 cksum; /* We should never write to the journal file the page that ** contains the database locks. The following assert verifies ** that we do not. */ assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) ); CODEC(pPager, pData, pPg->pgno, 7); cksum = pager_cksum(pPager, pPg->pgno, pData); saved = *(u32*)PGHDR_TO_EXTRA(pPg, pPager); store32bits(cksum, pPg, pPager->pageSize); szPg = pPager->pageSize+8; store32bits(pPg->pgno, pPg, -4); rc = sqlite3OsWrite(pPager->jfd, &((char*)pData)[-4], szPg); pPager->journalOff += szPg; TRACE4("JOURNAL %d page %d needSync=%d\n", PAGERID(pPager), pPg->pgno, pPg->needSync); CODEC(pPager, pData, pPg->pgno, 0); *(u32*)PGHDR_TO_EXTRA(pPg, pPager) = saved; /* An error has occured writing to the journal file. The ** transaction will be rolled back by the layer above. */ if( rc!=SQLITE_OK ){ return rc; } ................................................................................ assert( pHist->pStmt==0 ); pHist->pStmt = sqliteMallocRaw( pPager->pageSize ); if( pHist->pStmt ){ memcpy(pHist->pStmt, PGHDR_TO_DATA(pPg), pPager->pageSize); } TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); }else{ store32bits(pPg->pgno, pPg, -4); CODEC(pPager, pData, pPg->pgno, 7); rc = sqlite3OsWrite(pPager->stfd,((char*)pData)-4, pPager->pageSize+4); TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); CODEC(pPager, pData, pPg->pgno, 0); if( rc!=SQLITE_OK ){ return rc; } pPager->stmtNRec++; assert( pPager->aInStmt!=0 ); pPager->aInStmt[pPg->pgno/8] |= 1<<(pPg->pgno&7); } ................................................................................ */ void sqlite3pager_dont_write(Pager *pPager, Pgno pgno){ PgHdr *pPg; if( MEMDB ) return; pPg = pager_lookup(pPager, pgno); pPg->alwaysRollback = 1; if( pPg && pPg->dirty && !pPager->stmtInUse ){ if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSize<pPager->dbSize ){ /* If this pages is the last page in the file and the file has grown ** during the current transaction, then do NOT mark the page as clean. ** When the database file grows, we must make sure that the last page ** gets written at least once so that the disk file will be the correct ** size. If you do not write this page and the size of the file ** on the disk ends up being too small, that can lead to database ................................................................................ if( MEMDB ){ pPg = pager_get_all_dirty_pages(pPager); while( pPg ){ clearHistory(PGHDR_TO_HIST(pPg, pPager)); pPg->dirty = 0; pPg->inJournal = 0; pPg->inStmt = 0; pPg->pPrevStmt = pPg->pNextStmt = 0; pPg = pPg->pDirty; } #ifndef NDEBUG for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager); assert( !pPg->alwaysRollback ); ................................................................................ } /* ** Set the codec for this pager */ void sqlite3pager_set_codec( Pager *pPager, void (*xCodec)(void*,void*,Pgno,int), void *pCodecArg ){ pPager->xCodec = xCodec; pPager->pCodecArg = pCodecArg; } /* ................................................................................ /* Read the current value at byte 24. */ pPgHdr = DATA_TO_PGHDR(pPage); change_counter = retrieve32bits(pPgHdr, 24); /* Increment the value just read and write it back to byte 24. */ change_counter++; store32bits(change_counter, pPgHdr, 24); /* Release the page reference. */ sqlite3pager_unref(pPage); return SQLITE_OK; } /* ................................................................................ /* Sync the database file. */ if( !pPager->noSync ){ rc = sqlite3OsSync(pPager->fd, 0); } pPager->state = PAGER_SYNCED; } sync_exit: return rc; } #ifndef SQLITE_OMIT_AUTOVACUUM |
| | | | > | > | < < < < < < < < < < | | | | < < < < < < < < > | < > > > | | | | < < | | < | > | | | | | | | | > | < < | > | < < > | > | | > > |
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 .. 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 ... 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 ... 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 ... 433 434 435 436 437 438 439 440 441 442 443 444 445 446 ... 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 ... 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 .... 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 .... 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 .... 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 .... 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 .... 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 .... 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 .... 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 .... 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 .... 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 .... 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 .... 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 .... 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 .... 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 .... 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 .... 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 .... 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 .... 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 |
** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.21 2006/04/11 18:06:57 rmsimpson Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include "os.h" #include "pager.h" #include <assert.h> #include <string.h> ................................................................................ ** The following two macros are used within the TRACEX() macros above ** to print out file-descriptors. ** ** PAGERID() takes a pointer to a Pager struct as it's argument. The ** associated file-descriptor is returned. FILEHANDLEID() takes an OsFile ** struct as it's argument. */ #define PAGERID(p) ((int)(p->fd)) #define FILEHANDLEID(fd) ((int)fd) /* ** The page cache as a whole is always in one of the following ** states: ** ** PAGER_UNLOCK The page cache is not currently reading or ** writing the database file. There is no ................................................................................ u8 *pStmt; /* Text as it was at the beginning of the current statement */ }; /* ** A macro used for invoking the codec if there is one */ #ifdef SQLITE_HAS_CODEC # define CODEC1(P,D,N,X) if( P->xCodec!=0 ){ P->xCodec(P->pCodecArg,D,N,X); } # define CODEC2(P,D,N,X) ((char*)(P->xCodec!=0?P->xCodec(P->pCodecArg,D,N,X):D)) #else # define CODEC1(P,D,N,X) /* NO-OP */ # define CODEC2(P,D,N,X) ((char*)D) #endif /* ** Convert a pointer to a PgHdr into a pointer to its data ** and back again. */ #define PGHDR_TO_DATA(P) ((void*)(&(P)[1])) ................................................................................ int sectorSize; /* Assumed sector size during rollback */ #ifdef SQLITE_TEST int nHit, nMiss, nOvfl; /* Cache hits, missing, and LRU overflows */ int nRead,nWrite; /* Database pages read/written */ #endif void (*xDestructor)(void*,int); /* Call this routine when freeing pages */ void (*xReiniter)(void*,int); /* Call this routine when reloading pages */ void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ void *pCodecArg; /* First argument to xCodec() */ PgHdr *aHash[N_PG_HASH]; /* Hash table to map page number to PgHdr */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT Pager *pNext; /* Linked list of pagers in this thread */ #endif }; ................................................................................ */ static int write32bits(OsFile *fd, u32 val){ char ac[4]; put32bits(ac, val); return sqlite3OsWrite(fd, ac, 4); } /* ** Read a 32-bit integer at offset 'offset' from the page identified by ** page header 'p'. */ static u32 retrieve32bits(PgHdr *p, int offset){ unsigned char *ac; ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset]; ................................................................................ ** though fast and simple, catches the mostly likely kind of corruption. ** ** FIX ME: Consider adding every 200th (or so) byte of the data to the ** checksum. That way if a single page spans 3 or more disk sectors and ** only the middle sector is corrupt, we will still have a reasonable ** chance of failing the checksum and thus detecting the problem. */ static u32 pager_cksum(Pager *pPager, const u8 *aData){ u32 cksum = pPager->cksumInit; int i = pPager->pageSize-200; while( i>0 ){ cksum += aData[i]; i -= 200; } return cksum; ................................................................................ if( pgno>(unsigned)pPager->dbSize ){ return SQLITE_OK; } if( useCksum ){ rc = read32bits(jfd, &cksum); if( rc ) return rc; pPager->journalOff += 4; if( pager_cksum(pPager, aData)!=cksum ){ return SQLITE_DONE; } } assert( pPager->state==PAGER_RESERVED || pPager->state>=PAGER_EXCLUSIVE ); /* If the pager is in RESERVED state, then there must be a copy of this ................................................................................ memcpy(pData, aData, pPager->pageSize); if( pPager->xDestructor ){ /*** FIX ME: Should this be xReinit? ***/ pPager->xDestructor(pData, pPager->pageSize); } #ifdef SQLITE_CHECK_PAGES pPg->pageHash = pager_pagehash(pPg); #endif CODEC1(pPager, pData, pPg->pgno, 3); } return rc; } /* ** Parameter zMaster is the name of a master journal file. A single journal ** file that referred to the master journal file has just been rolled back. ................................................................................ if( (int)pPg->pgno <= pPager->origDbSize ){ rc = sqlite3OsSeek(pPager->fd, pPager->pageSize*(i64)(pPg->pgno-1)); if( rc==SQLITE_OK ){ rc = sqlite3OsRead(pPager->fd, zBuf, pPager->pageSize); } TRACE3("REFETCH %d page %d\n", PAGERID(pPager), pPg->pgno); if( rc ) break; CODEC1(pPager, zBuf, pPg->pgno, 2); }else{ memset(zBuf, 0, pPager->pageSize); } if( pPg->nRef==0 || memcmp(zBuf, PGHDR_TO_DATA(pPg), pPager->pageSize) ){ memcpy(PGHDR_TO_DATA(pPg), zBuf, pPager->pageSize); if( pPager->xReiniter ){ pPager->xReiniter(PGHDR_TO_DATA(pPg), pPager->pageSize); ................................................................................ rc = pager_truncate(pPager, mxPg); if( rc!=SQLITE_OK ){ goto end_playback; } pPager->dbSize = mxPg; } /* Copy original pages out of the journal and back into the database file. */ for(i=0; i<nRec; i++){ rc = pager_playback_one_page(pPager, pPager->jfd, 1); if( rc!=SQLITE_OK ){ if( rc==SQLITE_DONE ){ rc = SQLITE_OK; ................................................................................ break; }else{ goto end_playback; } } } } /*NOTREACHED*/ assert( 0 ); end_playback: if( rc==SQLITE_OK ){ rc = pager_unwritelock(pPager); } if( zMaster ){ /* If there was a master journal and this routine will return true, ................................................................................ return n; } /* ** Forward declaration */ static int syncJournal(Pager*); static void clearHistory(PgHistory*); /* ** Unlink pPg from it's hash chain. Also set the page number to 0 to indicate ** that the page is not part of any hash chain. This is required because the ** sqlite3pager_movepage() routine can leave a page in the ** pNextFree/pPrevFree list that is not a part of any hash-chain. ................................................................................ assert( pPager->aHash[pager_hash(pPg->pgno)]!=pPg ); pPg->pPrevHash->pNextHash = pPg->pNextHash; }else{ int h = pager_hash(pPg->pgno); assert( pPager->aHash[h]==pPg ); pPager->aHash[h] = pPg->pNextHash; } if( MEMDB ){ clearHistory(PGHDR_TO_HIST(pPg, pPager)); } pPg->pgno = 0; pPg->pNextHash = pPg->pPrevHash = 0; } /* ** Unlink a page from the free list (the list of all pages where nRef==0) ** and from its hash collision chain. ................................................................................ /* Remove the pager from the linked list of pagers starting at ** ThreadData.pPager if memory-management is enabled. */ if( pPager==pTsd->pPager ){ pTsd->pPager = pPager->pNext; }else{ Pager *pTmp; for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext){} pTmp->pNext = pPager->pNext; } #endif sqliteFree(pPager); return SQLITE_OK; } ................................................................................ if( rc ) return rc; /* If there are dirty pages in the page cache with page numbers greater ** than Pager.dbSize, this means sqlite3pager_truncate() was called to ** make the file smaller (presumably by auto-vacuum code). Do not write ** any such pages to the file. */ if( pList->pgno<=pPager->dbSize ){ char *pData = CODEC2(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6); TRACE3("STORE %d page %d\n", PAGERID(pPager), pList->pgno); rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize); TEST_INCR(pPager->nWrite); } #ifndef NDEBUG else{ TRACE3("NOSTORE %d page %d\n", PAGERID(pPager), pList->pgno); } #endif ................................................................................ */ PgHdr *pTmp; assert( pPg ); page_remove_from_stmt_list(pPg); if( pPg==p->pAll ){ p->pAll = pPg->pNextAll; }else{ for( pTmp=p->pAll; pTmp->pNextAll!=pPg; pTmp=pTmp->pNextAll ){} pTmp->pNextAll = pPg->pNextAll; } nReleased += sqliteAllocSize(pPg); sqliteFree(pPg); } if( rc!=SQLITE_OK ){ ................................................................................ assert( MEMDB==0 ); rc = sqlite3OsSeek(pPager->fd, (pgno-1)*(i64)pPager->pageSize); if( rc==SQLITE_OK ){ rc = sqlite3OsRead(pPager->fd, PGHDR_TO_DATA(pPg), pPager->pageSize); } TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno); CODEC1(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); if( rc!=SQLITE_OK ){ i64 fileSize; int rc2 = sqlite3OsFileSize(pPager->fd, &fileSize); if( rc2!=SQLITE_OK || fileSize>=pgno*pPager->pageSize ){ /* An IO error occured in one of the the sqlite3OsSeek() or ** sqlite3OsRead() calls above. */ pPg->pgno = 0; ................................................................................ /* The transaction journal now exists and we have a RESERVED or an ** EXCLUSIVE lock on the main database file. Write the current page to ** the transaction journal if it is not there already. */ if( !pPg->inJournal && (pPager->useJournal || MEMDB) ){ if( (int)pPg->pgno <= pPager->origDbSize ){ int szPg; if( MEMDB ){ PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager); TRACE3("JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); assert( pHist->pOrig==0 ); pHist->pOrig = sqliteMallocRaw( pPager->pageSize ); if( pHist->pOrig ){ memcpy(pHist->pOrig, PGHDR_TO_DATA(pPg), pPager->pageSize); } }else{ u32 cksum, saved; char *pData2, *pEnd; /* We should never write to the journal file the page that ** contains the database locks. The following assert verifies ** that we do not. */ assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) ); pData2 = CODEC2(pPager, pData, pPg->pgno, 7); cksum = pager_cksum(pPager, (u8*)pData2); pEnd = pData2 + pPager->pageSize; pData2 -= 4; saved = *(u32*)pEnd; put32bits(pEnd, cksum); szPg = pPager->pageSize+8; put32bits(pData2, pPg->pgno); rc = sqlite3OsWrite(pPager->jfd, pData2, szPg); pPager->journalOff += szPg; TRACE4("JOURNAL %d page %d needSync=%d\n", PAGERID(pPager), pPg->pgno, pPg->needSync); *(u32*)pEnd = saved; /* An error has occured writing to the journal file. The ** transaction will be rolled back by the layer above. */ if( rc!=SQLITE_OK ){ return rc; } ................................................................................ assert( pHist->pStmt==0 ); pHist->pStmt = sqliteMallocRaw( pPager->pageSize ); if( pHist->pStmt ){ memcpy(pHist->pStmt, PGHDR_TO_DATA(pPg), pPager->pageSize); } TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); }else{ char *pData2 = CODEC2(pPager, pData, pPg->pgno, 7)-4; put32bits(pData2, pPg->pgno); rc = sqlite3OsWrite(pPager->stfd, pData2, pPager->pageSize+4); TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); if( rc!=SQLITE_OK ){ return rc; } pPager->stmtNRec++; assert( pPager->aInStmt!=0 ); pPager->aInStmt[pPg->pgno/8] |= 1<<(pPg->pgno&7); } ................................................................................ */ void sqlite3pager_dont_write(Pager *pPager, Pgno pgno){ PgHdr *pPg; if( MEMDB ) return; pPg = pager_lookup(pPager, pgno); assert( pPg!=0 ); /* We never call _dont_write unless the page is in mem */ pPg->alwaysRollback = 1; if( pPg->dirty && !pPager->stmtInUse ){ if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSize<pPager->dbSize ){ /* If this pages is the last page in the file and the file has grown ** during the current transaction, then do NOT mark the page as clean. ** When the database file grows, we must make sure that the last page ** gets written at least once so that the disk file will be the correct ** size. If you do not write this page and the size of the file ** on the disk ends up being too small, that can lead to database ................................................................................ if( MEMDB ){ pPg = pager_get_all_dirty_pages(pPager); while( pPg ){ clearHistory(PGHDR_TO_HIST(pPg, pPager)); pPg->dirty = 0; pPg->inJournal = 0; pPg->inStmt = 0; pPg->needSync = 0; pPg->pPrevStmt = pPg->pNextStmt = 0; pPg = pPg->pDirty; } #ifndef NDEBUG for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager); assert( !pPg->alwaysRollback ); ................................................................................ } /* ** Set the codec for this pager */ void sqlite3pager_set_codec( Pager *pPager, void *(*xCodec)(void*,void*,Pgno,int), void *pCodecArg ){ pPager->xCodec = xCodec; pPager->pCodecArg = pCodecArg; } /* ................................................................................ /* Read the current value at byte 24. */ pPgHdr = DATA_TO_PGHDR(pPage); change_counter = retrieve32bits(pPgHdr, 24); /* Increment the value just read and write it back to byte 24. */ change_counter++; put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); /* Release the page reference. */ sqlite3pager_unref(pPage); return SQLITE_OK; } /* ................................................................................ /* Sync the database file. */ if( !pPager->noSync ){ rc = sqlite3OsSync(pPager->fd, 0); } pPager->state = PAGER_SYNCED; }else if( MEMDB && nTrunc!=0 ){ rc = sqlite3pager_truncate(pPager, nTrunc); } sync_exit: return rc; } #ifndef SQLITE_OMIT_AUTOVACUUM |
Changes to SQLite.Interop/src/pager.h.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite page cache ** subsystem. The page cache subsystem reads and writes a file a page ** at a time and provides a journal for rollback. ** ** @(#) $Id: pager.h,v 1.19 2006/02/11 14:43:39 rmsimpson Exp $ */ #ifndef _PAGER_H_ #define _PAGER_H_ /* ** The default size of a database page. ................................................................................ int *sqlite3pager_stats(Pager*); void sqlite3pager_set_safety_level(Pager*,int,int); const char *sqlite3pager_filename(Pager*); const char *sqlite3pager_dirname(Pager*); const char *sqlite3pager_journalname(Pager*); int sqlite3pager_nosync(Pager*); int sqlite3pager_rename(Pager*, const char *zNewName); void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*); int sqlite3pager_movepage(Pager*,void*,Pgno); int sqlite3pager_reset(Pager*); int sqlite3pager_release_memory(int); #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) int sqlite3pager_lockstate(Pager*); #endif |
|
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the sqlite page cache ** subsystem. The page cache subsystem reads and writes a file a page ** at a time and provides a journal for rollback. ** ** @(#) $Id: pager.h,v 1.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #ifndef _PAGER_H_ #define _PAGER_H_ /* ** The default size of a database page. ................................................................................ int *sqlite3pager_stats(Pager*); void sqlite3pager_set_safety_level(Pager*,int,int); const char *sqlite3pager_filename(Pager*); const char *sqlite3pager_dirname(Pager*); const char *sqlite3pager_journalname(Pager*); int sqlite3pager_nosync(Pager*); int sqlite3pager_rename(Pager*, const char *zNewName); void sqlite3pager_set_codec(Pager*,void*(*)(void*,void*,Pgno,int),void*); int sqlite3pager_movepage(Pager*,void*,Pgno); int sqlite3pager_reset(Pager*); int sqlite3pager_release_memory(int); #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) int sqlite3pager_lockstate(Pager*); #endif |
Changes to SQLite.Interop/src/parse.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 ... 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 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 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 .... 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 .... 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 .... 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 .... 1794 1795 1796 1797 1798 1799 1800 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 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 .... 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 |
/* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> #line 51 "parse.y" #include "sqliteInt.h" #include "parse.h" /* ** An instance of this structure holds information about the ** LIMIT clause of a SELECT statement. ................................................................................ int yy479; } YYMINORTYPE; #define YYSTACKDEPTH 100 #define sqlite3ParserARG_SDECL Parse *pParse; #define sqlite3ParserARG_PDECL ,Parse *pParse #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse #define sqlite3ParserARG_STORE yypParser->pParse = pParse #define YYNSTATE 560 #define YYNRULE 295 #define YYERRORSYMBOL 137 #define YYERRSYMDT yy479 #define YYFALLBACK 1 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) ................................................................................ ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ static const YYACTIONTYPE yy_action[] = { /* 0 */ 279, 68, 283, 70, 148, 166, 546, 419, 62, 62, /* 10 */ 62, 62, 202, 64, 64, 64, 64, 65, 65, 66, /* 20 */ 66, 66, 67, 67, 548, 549, 432, 69, 64, 64, /* 30 */ 64, 64, 65, 65, 66, 66, 66, 67, 68, 454, /* 40 */ 70, 148, 499, 61, 59, 287, 440, 441, 437, 437, /* 50 */ 63, 63, 62, 62, 62, 62, 501, 64, 64, 64, /* 60 */ 64, 65, 65, 66, 66, 66, 67, 279, 371, 283, /* 70 */ 419, 2, 377, 80, 158, 115, 220, 304, 225, 305, /* 80 */ 170, 245, 856, 119, 559, 504, 204, 2, 246, 389, /* 90 */ 496, 219, 22, 432, 514, 21, 419, 58, 493, 171, /* 100 */ 64, 64, 64, 64, 65, 65, 66, 66, 66, 67, /* 110 */ 61, 59, 287, 440, 441, 437, 437, 63, 63, 62, /* 120 */ 62, 62, 62, 512, 64, 64, 64, 64, 65, 65, /* 130 */ 66, 66, 66, 67, 279, 378, 379, 175, 202, 377, /* 140 */ 330, 333, 334, 220, 304, 225, 305, 170, 245, 203, /* 150 */ 146, 357, 335, 281, 377, 246, 55, 301, 373, 419, /* 160 */ 432, 505, 92, 200, 530, 66, 66, 66, 67, 525, /* 170 */ 192, 65, 65, 66, 66, 66, 67, 61, 59, 287, /* 180 */ 440, 441, 437, 437, 63, 63, 62, 62, 62, 62, /* 190 */ 433, 64, 64, 64, 64, 65, 65, 66, 66, 66, /* 200 */ 67, 279, 378, 379, 411, 431, 110, 226, 427, 205, /* 210 */ 435, 436, 308, 358, 261, 260, 175, 378, 379, 330, /* 220 */ 333, 334, 372, 369, 202, 511, 480, 432, 547, 362, /* 230 */ 466, 335, 510, 500, 410, 41, 276, 414, 434, 429, /* 240 */ 503, 162, 233, 527, 61, 59, 287, 440, 441, 437, /* 250 */ 437, 63, 63, 62, 62, 62, 62, 319, 64, 64, /* 260 */ 64, 64, 65, 65, 66, 66, 66, 67, 279, 472, /* 270 */ 416, 416, 416, 308, 322, 236, 308, 68, 308, 70, /* 280 */ 148, 1, 308, 793, 308, 377, 68, 153, 70, 148, /* 290 */ 149, 377, 325, 282, 432, 410, 35, 551, 410, 35, /* 300 */ 410, 36, 427, 205, 410, 35, 410, 35, 286, 422, /* 310 */ 423, 61, 59, 287, 440, 441, 437, 437, 63, 63, /* 320 */ 62, 62, 62, 62, 411, 64, 64, 64, 64, 65, /* 330 */ 65, 66, 66, 66, 67, 308, 504, 466, 290, 255, /* 340 */ 279, 324, 485, 147, 237, 388, 21, 288, 378, 379, /* 350 */ 451, 419, 232, 451, 378, 379, 308, 410, 28, 451, /* 360 */ 175, 450, 486, 330, 333, 334, 432, 215, 347, 145, /* 370 */ 513, 204, 350, 186, 168, 335, 238, 411, 410, 41, /* 380 */ 256, 462, 76, 61, 59, 287, 440, 441, 437, 437, /* 390 */ 63, 63, 62, 62, 62, 62, 309, 64, 64, 64, /* 400 */ 64, 65, 65, 66, 66, 66, 67, 411, 411, 186, /* 410 */ 396, 308, 279, 291, 419, 338, 476, 308, 390, 234, /* 420 */ 169, 154, 397, 475, 396, 327, 493, 311, 422, 423, /* 430 */ 444, 377, 356, 410, 49, 398, 397, 394, 432, 410, /* 440 */ 49, 502, 171, 411, 429, 312, 162, 395, 351, 398, /* 450 */ 497, 318, 470, 352, 79, 61, 59, 287, 440, 441, /* 460 */ 437, 437, 63, 63, 62, 62, 62, 62, 356, 64, /* 470 */ 64, 64, 64, 65, 65, 66, 66, 66, 67, 279, /* 480 */ 298, 445, 376, 479, 532, 405, 299, 11, 504, 352, /* 490 */ 204, 377, 406, 377, 378, 379, 281, 556, 21, 491, /* 500 */ 491, 246, 560, 372, 369, 432, 392, 393, 314, 123, /* 510 */ 443, 443, 166, 289, 419, 314, 116, 443, 443, 251, /* 520 */ 264, 463, 61, 59, 287, 440, 441, 437, 437, 63, /* 530 */ 63, 62, 62, 62, 62, 292, 64, 64, 64, 64, /* 540 */ 65, 65, 66, 66, 66, 67, 279, 459, 328, 474, /* 550 */ 498, 308, 202, 308, 378, 379, 378, 379, 181, 131, /* 560 */ 179, 265, 308, 5, 308, 363, 314, 355, 443, 443, /* 570 */ 410, 3, 432, 410, 29, 410, 24, 419, 243, 244, /* 580 */ 380, 381, 382, 404, 410, 33, 410, 54, 466, 61, /* 590 */ 59, 287, 440, 441, 437, 437, 63, 63, 62, 62, /* 600 */ 62, 62, 308, 64, 64, 64, 64, 65, 65, 66, /* 610 */ 66, 66, 67, 279, 521, 344, 521, 249, 308, 491, /* 620 */ 308, 470, 308, 470, 410, 25, 308, 240, 308, 314, /* 630 */ 308, 443, 443, 213, 172, 173, 174, 142, 266, 432, /* 640 */ 410, 52, 410, 97, 410, 94, 528, 393, 410, 99, /* 650 */ 410, 100, 410, 111, 212, 255, 61, 59, 287, 440, /* 660 */ 441, 437, 437, 63, 63, 62, 62, 62, 62, 308, /* 670 */ 64, 64, 64, 64, 65, 65, 66, 66, 66, 67, /* 680 */ 279, 308, 345, 188, 297, 91, 308, 491, 308, 415, /* 690 */ 308, 410, 112, 308, 428, 308, 537, 308, 244, 165, /* 700 */ 154, 409, 355, 410, 18, 408, 432, 320, 410, 98, /* 710 */ 410, 34, 410, 95, 313, 410, 53, 410, 113, 410, /* 720 */ 114, 255, 293, 61, 59, 287, 440, 441, 437, 437, /* 730 */ 63, 63, 62, 62, 62, 62, 308, 64, 64, 64, /* 740 */ 64, 65, 65, 66, 66, 66, 67, 279, 308, 491, /* 750 */ 491, 523, 308, 452, 308, 522, 308, 461, 410, 26, /* 760 */ 308, 75, 539, 77, 308, 460, 244, 346, 214, 465, /* 770 */ 410, 37, 469, 432, 410, 38, 410, 27, 410, 39, /* 780 */ 242, 82, 410, 40, 294, 296, 410, 42, 438, 329, /* 790 */ 61, 59, 287, 440, 441, 437, 437, 63, 63, 62, /* 800 */ 62, 62, 62, 308, 64, 64, 64, 64, 65, 65, /* 810 */ 66, 66, 66, 67, 279, 308, 409, 190, 221, 308, /* 820 */ 408, 308, 152, 308, 159, 410, 43, 308, 244, 244, /* 830 */ 222, 20, 308, 139, 425, 425, 481, 410, 44, 482, /* 840 */ 432, 410, 30, 410, 31, 410, 45, 487, 461, 410, /* 850 */ 46, 411, 506, 255, 410, 47, 488, 61, 71, 287, /* 860 */ 440, 441, 437, 437, 63, 63, 62, 62, 62, 62, /* 870 */ 308, 64, 64, 64, 64, 65, 65, 66, 66, 66, /* 880 */ 67, 279, 308, 401, 402, 250, 308, 193, 308, 420, /* 890 */ 308, 23, 410, 48, 540, 449, 255, 14, 468, 477, /* 900 */ 167, 14, 484, 483, 410, 32, 252, 432, 410, 12, /* 910 */ 410, 50, 410, 51, 255, 255, 594, 255, 255, 150, /* 920 */ 489, 411, 123, 253, 279, 59, 287, 440, 441, 437, /* 930 */ 437, 63, 63, 62, 62, 62, 62, 541, 64, 64, /* 940 */ 64, 64, 65, 65, 66, 66, 66, 67, 254, 248, /* 950 */ 432, 123, 337, 411, 123, 267, 269, 196, 361, 366, /* 960 */ 183, 177, 180, 519, 520, 526, 534, 123, 167, 287, /* 970 */ 440, 441, 437, 437, 63, 63, 62, 62, 62, 62, /* 980 */ 342, 64, 64, 64, 64, 65, 65, 66, 66, 66, /* 990 */ 67, 72, 315, 259, 4, 411, 411, 535, 285, 89, /* 1000 */ 544, 349, 89, 353, 354, 19, 310, 72, 315, 368, /* 1010 */ 4, 386, 262, 263, 285, 223, 545, 270, 364, 273, /* 1020 */ 274, 141, 310, 317, 227, 316, 555, 424, 426, 480, /* 1030 */ 455, 458, 490, 431, 332, 492, 533, 157, 543, 317, /* 1040 */ 375, 383, 384, 385, 8, 302, 303, 391, 284, 431, /* 1050 */ 404, 399, 74, 73, 224, 403, 407, 82, 323, 321, /* 1060 */ 72, 306, 307, 400, 231, 414, 81, 206, 74, 73, /* 1070 */ 473, 57, 78, 164, 453, 412, 72, 306, 307, 72, /* 1080 */ 315, 414, 4, 228, 202, 229, 285, 235, 230, 456, /* 1090 */ 457, 413, 207, 120, 310, 83, 326, 102, 416, 416, /* 1100 */ 416, 417, 418, 13, 239, 495, 467, 241, 277, 208, /* 1110 */ 471, 317, 494, 210, 416, 416, 416, 417, 418, 13, /* 1120 */ 211, 431, 156, 278, 339, 507, 508, 216, 217, 218, /* 1130 */ 106, 509, 515, 178, 343, 84, 341, 182, 517, 456, /* 1140 */ 74, 73, 86, 198, 518, 271, 257, 184, 72, 306, /* 1150 */ 307, 348, 272, 414, 118, 529, 187, 127, 536, 359, /* 1160 */ 128, 136, 129, 542, 195, 130, 530, 133, 300, 552, /* 1170 */ 553, 194, 137, 197, 431, 90, 554, 557, 96, 209, /* 1180 */ 101, 374, 387, 117, 201, 56, 416, 416, 416, 417, /* 1190 */ 418, 13, 93, 143, 144, 595, 596, 109, 160, 161, /* 1200 */ 60, 439, 500, 421, 430, 442, 414, 138, 446, 151, /* 1210 */ 6, 447, 155, 448, 163, 360, 268, 260, 15, 7, /* 1220 */ 14, 280, 121, 464, 122, 478, 202, 103, 104, 331, /* 1230 */ 247, 85, 105, 336, 222, 176, 340, 140, 516, 416, /* 1240 */ 416, 416, 124, 295, 125, 167, 524, 258, 107, 185, /* 1250 */ 365, 9, 531, 10, 126, 189, 16, 538, 191, 132, /* 1260 */ 134, 87, 88, 135, 17, 108, 275, 550, 367, 199, /* 1270 */ 370, 536, 558, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 16, 216, 16, 218, 219, 21, 146, 23, 68, 69, /* 10 */ 70, 71, 109, 73, 74, 75, 76, 77, 78, 79, /* 20 */ 80, 81, 82, 82, 164, 165, 42, 72, 73, 74, /* 30 */ 75, 76, 77, 78, 79, 80, 81, 82, 216, 217, /* 40 */ 218, 219, 168, 59, 60, 61, 62, 63, 64, 65, /* 50 */ 66, 67, 68, 69, 70, 71, 168, 73, 74, 75, /* 60 */ 76, 77, 78, 79, 80, 81, 82, 16, 140, 16, /* 70 */ 86, 143, 23, 22, 88, 89, 90, 91, 92, 93, /* 80 */ 94, 95, 138, 139, 140, 146, 226, 143, 102, 166, /* 90 */ 167, 152, 19, 42, 155, 156, 23, 46, 175, 43, /* 100 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, /* 110 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 120 */ 69, 70, 71, 180, 73, 74, 75, 76, 77, 78, /* 130 */ 79, 80, 81, 82, 16, 86, 87, 88, 109, 23, /* 140 */ 91, 92, 93, 90, 91, 92, 93, 94, 95, 191, /* 150 */ 22, 122, 103, 97, 23, 102, 198, 141, 142, 86, /* 160 */ 42, 180, 44, 147, 49, 79, 80, 81, 82, 18, /* 170 */ 154, 77, 78, 79, 80, 81, 82, 59, 60, 61, /* 180 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 190 */ 42, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 200 */ 82, 16, 86, 87, 188, 58, 21, 189, 77, 78, /* 210 */ 62, 63, 146, 98, 99, 100, 88, 86, 87, 91, /* 220 */ 92, 93, 1, 2, 109, 175, 176, 42, 97, 213, /* 230 */ 160, 103, 182, 86, 168, 169, 157, 90, 90, 160, /* 240 */ 161, 162, 146, 92, 59, 60, 61, 62, 63, 64, /* 250 */ 65, 66, 67, 68, 69, 70, 71, 185, 73, 74, /* 260 */ 75, 76, 77, 78, 79, 80, 81, 82, 16, 199, /* 270 */ 123, 124, 125, 146, 208, 209, 146, 216, 146, 218, /* 280 */ 219, 19, 146, 132, 146, 23, 216, 146, 218, 219, /* 290 */ 154, 23, 146, 149, 42, 168, 169, 236, 168, 169, /* 300 */ 168, 169, 77, 78, 168, 169, 168, 169, 163, 164, /* 310 */ 165, 59, 60, 61, 62, 63, 64, 65, 66, 67, /* 320 */ 68, 69, 70, 71, 188, 73, 74, 75, 76, 77, /* 330 */ 78, 79, 80, 81, 82, 146, 146, 160, 211, 146, /* 340 */ 16, 211, 30, 154, 146, 155, 156, 211, 86, 87, /* 350 */ 223, 23, 220, 223, 86, 87, 146, 168, 169, 223, /* 360 */ 88, 223, 50, 91, 92, 93, 42, 144, 224, 179, /* 370 */ 180, 226, 228, 154, 154, 103, 199, 188, 168, 169, /* 380 */ 187, 113, 130, 59, 60, 61, 62, 63, 64, 65, /* 390 */ 66, 67, 68, 69, 70, 71, 146, 73, 74, 75, /* 400 */ 76, 77, 78, 79, 80, 81, 82, 188, 188, 154, /* 410 */ 12, 146, 16, 101, 86, 16, 20, 146, 167, 209, /* 420 */ 200, 201, 24, 20, 12, 205, 175, 163, 164, 165, /* 430 */ 20, 23, 213, 168, 169, 37, 24, 39, 42, 168, /* 440 */ 169, 159, 43, 188, 160, 161, 162, 49, 229, 37, /* 450 */ 168, 39, 146, 234, 130, 59, 60, 61, 62, 63, /* 460 */ 64, 65, 66, 67, 68, 69, 70, 71, 213, 73, /* 470 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 16, /* 480 */ 215, 20, 146, 20, 229, 27, 215, 19, 146, 234, /* 490 */ 226, 23, 34, 23, 86, 87, 97, 155, 156, 146, /* 500 */ 146, 102, 0, 1, 2, 42, 184, 185, 105, 22, /* 510 */ 107, 108, 21, 207, 23, 105, 146, 107, 108, 14, /* 520 */ 14, 113, 59, 60, 61, 62, 63, 64, 65, 66, /* 530 */ 67, 68, 69, 70, 71, 181, 73, 74, 75, 76, /* 540 */ 77, 78, 79, 80, 81, 82, 16, 22, 146, 79, /* 550 */ 20, 146, 109, 146, 86, 87, 86, 87, 53, 53, /* 560 */ 55, 55, 146, 190, 146, 122, 105, 146, 107, 108, /* 570 */ 168, 169, 42, 168, 169, 168, 169, 86, 225, 225, /* 580 */ 7, 8, 9, 96, 168, 169, 168, 169, 160, 59, /* 590 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 600 */ 70, 71, 146, 73, 74, 75, 76, 77, 78, 79, /* 610 */ 80, 81, 82, 16, 98, 99, 100, 20, 146, 146, /* 620 */ 146, 146, 146, 146, 168, 169, 146, 199, 146, 105, /* 630 */ 146, 107, 108, 212, 98, 99, 100, 112, 132, 42, /* 640 */ 168, 169, 168, 169, 168, 169, 184, 185, 168, 169, /* 650 */ 168, 169, 168, 169, 181, 146, 59, 60, 61, 62, /* 660 */ 63, 64, 65, 66, 67, 68, 69, 70, 71, 146, /* 670 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, /* 680 */ 16, 146, 207, 22, 207, 21, 146, 146, 146, 146, /* 690 */ 146, 168, 169, 146, 160, 146, 187, 146, 225, 200, /* 700 */ 201, 106, 146, 168, 169, 110, 42, 146, 168, 169, /* 710 */ 168, 169, 168, 169, 16, 168, 169, 168, 169, 168, /* 720 */ 169, 146, 181, 59, 60, 61, 62, 63, 64, 65, /* 730 */ 66, 67, 68, 69, 70, 71, 146, 73, 74, 75, /* 740 */ 76, 77, 78, 79, 80, 81, 82, 16, 146, 146, /* 750 */ 146, 25, 146, 146, 146, 29, 146, 22, 168, 169, /* 760 */ 146, 129, 187, 131, 146, 202, 225, 41, 212, 146, /* 770 */ 168, 169, 146, 42, 168, 169, 168, 169, 168, 169, /* 780 */ 146, 120, 168, 169, 181, 181, 168, 169, 90, 79, /* 790 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 800 */ 69, 70, 71, 146, 73, 74, 75, 76, 77, 78, /* 810 */ 79, 80, 81, 82, 16, 146, 106, 154, 90, 146, /* 820 */ 110, 146, 87, 146, 19, 168, 169, 146, 225, 225, /* 830 */ 102, 19, 146, 21, 123, 124, 146, 168, 169, 177, /* 840 */ 42, 168, 169, 168, 169, 168, 169, 177, 113, 168, /* 850 */ 169, 188, 146, 146, 168, 169, 177, 59, 60, 61, /* 860 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 870 */ 146, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 880 */ 82, 16, 146, 7, 8, 146, 146, 154, 146, 20, /* 890 */ 146, 22, 168, 169, 187, 20, 146, 22, 20, 20, /* 900 */ 22, 22, 89, 90, 168, 169, 146, 42, 168, 169, /* 910 */ 168, 169, 168, 169, 146, 146, 111, 146, 146, 154, /* 920 */ 20, 188, 22, 146, 16, 60, 61, 62, 63, 64, /* 930 */ 65, 66, 67, 68, 69, 70, 71, 187, 73, 74, /* 940 */ 75, 76, 77, 78, 79, 80, 81, 82, 146, 20, /* 950 */ 42, 22, 20, 188, 22, 187, 187, 19, 187, 187, /* 960 */ 230, 154, 154, 51, 52, 20, 20, 22, 22, 61, /* 970 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 980 */ 231, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 990 */ 82, 16, 17, 146, 19, 188, 188, 20, 23, 22, /* 1000 */ 20, 146, 22, 146, 146, 67, 31, 16, 17, 237, /* 1010 */ 19, 148, 146, 146, 23, 171, 146, 146, 146, 146, /* 1020 */ 146, 190, 31, 48, 192, 222, 146, 227, 227, 176, /* 1030 */ 171, 171, 171, 58, 172, 171, 193, 6, 193, 48, /* 1040 */ 145, 145, 145, 145, 22, 153, 97, 170, 40, 58, /* 1050 */ 96, 170, 77, 78, 170, 172, 170, 120, 117, 115, /* 1060 */ 85, 86, 87, 178, 196, 90, 118, 221, 77, 78, /* 1070 */ 79, 119, 129, 111, 151, 188, 85, 86, 87, 16, /* 1080 */ 17, 90, 19, 193, 109, 194, 23, 95, 195, 23, /* 1090 */ 159, 197, 210, 151, 31, 97, 114, 19, 123, 124, /* 1100 */ 125, 126, 127, 128, 203, 178, 204, 203, 173, 210, /* 1110 */ 204, 48, 159, 210, 123, 124, 125, 126, 127, 128, /* 1120 */ 210, 58, 5, 173, 15, 170, 170, 10, 11, 12, /* 1130 */ 13, 170, 151, 150, 38, 19, 151, 151, 151, 23, /* 1140 */ 77, 78, 129, 26, 233, 28, 232, 150, 85, 86, /* 1150 */ 87, 151, 35, 90, 59, 183, 183, 19, 193, 15, /* 1160 */ 186, 214, 186, 193, 47, 186, 49, 183, 151, 33, /* 1170 */ 151, 54, 214, 56, 58, 235, 151, 136, 158, 174, /* 1180 */ 174, 1, 20, 32, 44, 19, 123, 124, 125, 126, /* 1190 */ 127, 128, 235, 77, 78, 111, 111, 238, 111, 111, /* 1200 */ 19, 90, 86, 20, 20, 106, 90, 19, 11, 19, /* 1210 */ 116, 20, 111, 20, 22, 98, 99, 100, 22, 116, /* 1220 */ 22, 104, 19, 113, 20, 20, 109, 19, 19, 44, /* 1230 */ 20, 19, 19, 44, 102, 94, 16, 21, 17, 123, /* 1240 */ 124, 125, 97, 36, 45, 22, 45, 132, 19, 97, /* 1250 */ 133, 5, 11, 1, 101, 121, 19, 17, 112, 112, /* 1260 */ 101, 67, 67, 121, 19, 14, 135, 20, 57, 134, /* 1270 */ 3, 239, 4, }; #define YY_SHIFT_USE_DFLT (-98) #define YY_SHIFT_MAX 370 static const short yy_shift_ofst[] = { /* 0 */ 221, 975, 1117, -16, 975, 1063, 1063, 1063, 49, 115, /* 10 */ 115, -97, 118, 1063, 1063, 1063, 1063, 1063, -45, 131, /* 20 */ 116, 328, 225, 225, 51, 185, 252, 324, 396, 463, /* 30 */ 530, 597, 664, 731, 798, 731, 731, 731, 731, 731, /* 40 */ 731, 731, 731, 731, 731, 731, 731, 731, 731, 731, /* 50 */ 731, 731, 865, 908, 908, 991, 1063, 1063, 1063, 1063, /* 60 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 70 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 80 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 90 */ 1063, 1063, 1063, 1063, -60, -60, -14, 27, 27, 94, /* 100 */ 86, 399, 116, 116, 116, 116, 151, 116, 116, 116, /* 110 */ 328, -59, -98, -98, -98, 1116, 53, 398, 398, 502, /* 120 */ 491, 116, 491, 116, 116, 116, 116, 116, 116, 116, /* 130 */ 116, 116, 116, 116, 116, 116, 29, 443, -97, -97, /* 140 */ -97, -98, -98, 147, 147, 128, 272, 403, 262, 410, /* 150 */ 461, 412, 268, 408, 468, 470, 573, 116, 116, 710, /* 160 */ 116, 116, 73, 116, 116, 735, 116, 116, 524, 735, /* 170 */ 116, 116, 312, 312, 312, 116, 116, 524, 116, 116, /* 180 */ 524, 116, 726, 516, 116, 116, 524, 116, 116, 116, /* 190 */ 524, 116, 524, 524, 116, 116, 116, 116, 116, 116, /* 200 */ 812, 458, 595, 525, 711, 711, 632, 458, 458, 56, /* 210 */ 458, 458, 487, 661, 661, 1031, 1031, 1031, 1031, 1022, /* 220 */ 949, 949, 1008, 949, 954, 949, -97, 937, 941, 948, /* 230 */ 944, 952, 943, 962, 992, 1066, 992, 962, 998, 982, /* 240 */ 998, 982, 1078, 992, 992, 1066, 1008, 949, 949, 949, /* 250 */ 1078, 1109, 962, 962, 962, 962, 1096, 1013, 1109, 962, /* 260 */ 1095, 1095, 1138, 937, 1144, 1144, 1144, 937, 1095, 1138, /* 270 */ 962, 1136, 1136, 962, 962, 1041, -98, -98, -98, 148, /* 280 */ 506, 536, 505, 728, 876, 805, 869, 698, 875, 878, /* 290 */ 879, 813, 900, 929, 932, 912, 945, 946, 977, 980, /* 300 */ 938, 1180, 1162, 1151, 1140, 1166, 1084, 1085, 1087, 1088, /* 310 */ 1181, 1183, 1184, 1111, 1099, 1188, 1197, 1190, 1191, 1192, /* 320 */ 1193, 1094, 1196, 1103, 1198, 1110, 1203, 1204, 1101, 1205, /* 330 */ 1185, 1208, 1210, 1209, 1212, 1189, 1213, 1141, 1132, 1220, /* 340 */ 1221, 1216, 1145, 1207, 1199, 1223, 1201, 1115, 1152, 1229, /* 350 */ 1246, 1241, 1252, 1153, 1194, 1195, 1134, 1237, 1146, 1240, /* 360 */ 1147, 1159, 1142, 1245, 1247, 1251, 1211, 1135, 1131, 1267, /* 370 */ 1268, }; #define YY_REDUCE_USE_DFLT (-216) #define YY_REDUCE_MAX 278 static const short yy_reduce_ofst[] = { /* 0 */ -56, 136, 16, 70, 189, 127, 66, 130, 190, 219, /* 10 */ 255, 220, 61, 132, 138, 210, 265, 271, -178, -140, /* 20 */ -61, 79, 145, 264, -215, -215, -215, -215, -215, -215, /* 30 */ -215, -215, -215, -215, -215, -215, -215, -215, -215, -215, /* 40 */ -215, -215, -215, -215, -215, -215, -215, -215, -215, -215, /* 50 */ -215, -215, -215, -215, -215, 402, 405, 407, 416, 418, /* 60 */ 456, 472, 474, 476, 480, 482, 484, 523, 535, 540, /* 70 */ 542, 544, 547, 549, 551, 590, 602, 606, 608, 610, /* 80 */ 614, 618, 657, 669, 673, 675, 677, 681, 686, 724, /* 90 */ 736, 740, 742, 744, -215, -215, -77, -215, -215, -215, /* 100 */ -215, 50, 354, 473, 541, 603, 144, 604, 772, 342, /* 110 */ 284, -215, -215, -215, -215, 282, 251, 322, 462, -72, /* 120 */ 177, 306, 428, 353, 193, 475, 421, 477, 509, 575, /* 130 */ 707, 750, 768, 771, 556, 769, 663, 733, 765, 807, /* 140 */ 808, -42, 499, -126, -112, -57, -19, 18, 96, 18, /* 150 */ 18, 72, 141, 146, 198, 250, 223, 336, 370, 373, /* 160 */ 250, 543, 534, 561, 607, 563, 623, 626, 18, 563, /* 170 */ 634, 690, 662, 670, 679, 706, 739, 18, 760, 777, /* 180 */ 18, 802, 730, 749, 847, 855, 18, 857, 858, 866, /* 190 */ 18, 867, 18, 18, 870, 871, 872, 873, 874, 880, /* 200 */ 863, 844, 831, 832, 800, 801, 803, 859, 860, 853, /* 210 */ 861, 864, 862, 843, 845, 895, 896, 897, 898, 892, /* 220 */ 877, 881, 885, 884, 883, 886, 887, 890, 891, 893, /* 230 */ 868, 894, 846, 923, 882, 931, 899, 942, 901, 902, /* 240 */ 904, 906, 935, 903, 910, 953, 927, 955, 956, 961, /* 250 */ 950, 983, 981, 985, 986, 987, 914, 911, 997, 1000, /* 260 */ 972, 973, 947, 965, 974, 976, 979, 970, 984, 958, /* 270 */ 1017, 940, 957, 1019, 1025, 959, 1020, 1005, 1006, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 566, 790, 855, 681, 855, 790, 855, 790, 855, 828, /* 10 */ 828, 685, 841, 786, 790, 855, 855, 855, 761, 812, /* 20 */ 855, 597, 812, 812, 716, 855, 855, 855, 855, 855, /* 30 */ 855, 855, 855, 717, 855, 789, 785, 781, 783, 782, /* 40 */ 718, 705, 714, 721, 697, 826, 723, 724, 729, 730, /* 50 */ 842, 845, 751, 767, 750, 855, 855, 855, 855, 855, /* 60 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 70 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 80 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 90 */ 855, 855, 855, 855, 753, 772, 590, 752, 760, 754, /* 100 */ 755, 650, 855, 855, 855, 855, 585, 855, 855, 855, /* 110 */ 855, 756, 757, 768, 769, 855, 855, 855, 855, 566, /* 120 */ 681, 855, 681, 855, 855, 855, 855, 855, 855, 855, /* 130 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 140 */ 855, 675, 685, 855, 855, 641, 855, 855, 855, 855, /* 150 */ 855, 855, 855, 855, 855, 855, 573, 571, 855, 673, /* 160 */ 855, 855, 599, 855, 855, 683, 855, 855, 688, 689, /* 170 */ 855, 855, 855, 855, 855, 855, 855, 587, 855, 855, /* 180 */ 662, 855, 818, 855, 855, 855, 833, 855, 855, 855, /* 190 */ 831, 855, 664, 726, 800, 855, 855, 846, 848, 855, /* 200 */ 855, 708, 673, 682, 855, 855, 784, 708, 708, 620, /* 210 */ 708, 708, 623, 720, 720, 570, 570, 570, 570, 640, /* 220 */ 652, 652, 637, 652, 623, 652, 855, 720, 711, 713, /* 230 */ 701, 715, 855, 690, 709, 855, 709, 690, 698, 700, /* 240 */ 698, 700, 794, 709, 709, 855, 637, 652, 652, 652, /* 250 */ 794, 582, 690, 690, 690, 690, 822, 825, 582, 690, /* 260 */ 654, 654, 731, 720, 661, 661, 661, 720, 654, 731, /* 270 */ 690, 844, 844, 690, 690, 853, 607, 625, 625, 855, /* 280 */ 855, 855, 855, 855, 855, 738, 855, 855, 855, 855, /* 290 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 300 */ 807, 855, 855, 855, 855, 855, 743, 739, 855, 740, /* 310 */ 855, 855, 855, 855, 667, 855, 855, 855, 855, 855, /* 320 */ 855, 855, 702, 855, 712, 855, 855, 855, 855, 855, /* 330 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 340 */ 855, 855, 855, 855, 820, 821, 855, 855, 855, 855, /* 350 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, /* 360 */ 855, 855, 855, 855, 855, 855, 852, 855, 855, 567, /* 370 */ 855, 561, 564, 563, 565, 569, 572, 594, 595, 596, /* 380 */ 574, 575, 576, 577, 578, 579, 580, 586, 588, 606, /* 390 */ 608, 615, 653, 656, 657, 658, 836, 837, 838, 616, /* 400 */ 635, 638, 639, 617, 624, 706, 707, 618, 671, 672, /* 410 */ 735, 665, 666, 670, 737, 741, 742, 744, 745, 593, /* 420 */ 600, 601, 604, 605, 808, 810, 809, 811, 603, 602, /* 430 */ 746, 749, 758, 759, 765, 771, 774, 763, 764, 766, /* 440 */ 770, 773, 668, 669, 777, 779, 780, 834, 835, 775, /* 450 */ 787, 788, 691, 778, 762, 703, 592, 710, 704, 674, /* 460 */ 684, 693, 694, 695, 696, 679, 680, 686, 699, 733, /* 470 */ 734, 687, 676, 677, 678, 776, 736, 747, 748, 619, /* 480 */ 626, 627, 628, 631, 632, 633, 634, 629, 630, 795, /* 490 */ 796, 798, 797, 621, 622, 636, 609, 610, 611, 612, /* 500 */ 743, 613, 614, 598, 591, 642, 645, 646, 647, 648, /* 510 */ 649, 651, 643, 644, 589, 581, 583, 692, 814, 823, /* 520 */ 824, 819, 815, 816, 817, 584, 791, 792, 655, 727, /* 530 */ 728, 813, 827, 829, 732, 830, 832, 659, 660, 663, /* 540 */ 799, 839, 719, 722, 725, 801, 802, 803, 804, 805, /* 550 */ 806, 840, 843, 847, 849, 850, 851, 854, 568, 562, }; #define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0])) /* The next table maps tokens into fallback tokens. If a construct ** like the following: ** ** %fallback ID X Y Z. ................................................................................ /* 260 */ "trigger_event ::= UPDATE", /* 261 */ "trigger_event ::= UPDATE OF inscollist", /* 262 */ "foreach_clause ::=", /* 263 */ "foreach_clause ::= FOR EACH ROW", /* 264 */ "foreach_clause ::= FOR EACH STATEMENT", /* 265 */ "when_clause ::=", /* 266 */ "when_clause ::= WHEN expr", /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI trigger_cmd_list", /* 268 */ "trigger_cmd_list ::=", /* 269 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt", /* 270 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP", /* 271 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select", /* 272 */ "trigger_cmd ::= DELETE FROM nm where_opt", /* 273 */ "trigger_cmd ::= select", /* 274 */ "expr ::= RAISE LP IGNORE RP", ................................................................................ ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 154: case 188: case 205: #line 368 "parse.y" {sqlite3SelectDelete((yypminor->yy239));} #line 1216 "parse.c" break; case 168: case 169: case 193: case 195: case 203: case 209: case 217: case 220: case 222: case 223: case 233: #line 625 "parse.y" {sqlite3ExprDelete((yypminor->yy178));} #line 1231 "parse.c" break; case 173: case 181: case 191: case 194: case 196: case 198: case 208: case 211: case 212: case 215: case 221: #line 855 "parse.y" {sqlite3ExprListDelete((yypminor->yy462));} #line 1246 "parse.c" break; case 187: case 192: case 200: case 201: #line 496 "parse.y" {sqlite3SrcListDelete((yypminor->yy285));} #line 1254 "parse.c" break; case 197: #line 557 "parse.y" { sqlite3ExprDelete((yypminor->yy270).pLimit); sqlite3ExprDelete((yypminor->yy270).pOffset); } #line 1262 "parse.c" break; case 204: case 207: case 214: #line 513 "parse.y" {sqlite3IdListDelete((yypminor->yy160));} #line 1269 "parse.c" break; case 229: case 234: #line 949 "parse.y" {sqlite3DeleteTriggerStep((yypminor->yy247));} #line 1275 "parse.c" break; case 231: #line 933 "parse.y" {sqlite3IdListDelete((yypminor->yy132).b);} #line 1280 "parse.c" break; case 236: #line 1008 "parse.y" {sqlite3ExprDelete((yypminor->yy292));} #line 1285 "parse.c" break; default: break; /* If no destructor action specified: do nothing */ } } /* ** Pop the parser's stack once. ................................................................................ if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ return; } yytos = &yypParser->yystack[yypParser->yyidx]; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor = *yypMinor; ................................................................................ ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 3: #line 95 "parse.y" { sqlite3FinishCoding(pParse); } #line 1805 "parse.c" break; case 6: #line 98 "parse.y" { sqlite3BeginParse(pParse, 0); } #line 1810 "parse.c" break; case 7: #line 100 "parse.y" { sqlite3BeginParse(pParse, 1); } #line 1815 "parse.c" break; case 8: #line 101 "parse.y" { sqlite3BeginParse(pParse, 2); } #line 1820 "parse.c" break; case 9: #line 107 "parse.y" {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy230);} #line 1825 "parse.c" break; case 13: #line 112 "parse.y" {yygotominor.yy230 = TK_DEFERRED;} #line 1830 "parse.c" break; case 14: case 15: case 16: case 107: case 109: #line 113 "parse.y" {yygotominor.yy230 = yymsp[0].major;} #line 1839 "parse.c" break; case 17: case 18: #line 116 "parse.y" {sqlite3CommitTransaction(pParse);} #line 1845 "parse.c" break; case 19: #line 118 "parse.y" {sqlite3RollbackTransaction(pParse);} #line 1850 "parse.c" break; case 21: #line 123 "parse.y" { sqlite3StartTable(pParse,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,yymsp[-4].minor.yy230,0,yymsp[-2].minor.yy230); } #line 1857 "parse.c" break; case 22: case 25: case 63: case 77: case 79: case 90: case 101: case 112: case 113: case 210: case 213: #line 127 "parse.y" {yygotominor.yy230 = 0;} #line 1872 "parse.c" break; case 23: case 24: case 64: case 78: case 100: case 111: case 211: case 214: #line 128 "parse.y" {yygotominor.yy230 = 1;} #line 1884 "parse.c" break; case 26: #line 134 "parse.y" { sqlite3EndTable(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy0,0); } #line 1891 "parse.c" break; case 27: #line 137 "parse.y" { sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy239); sqlite3SelectDelete(yymsp[0].minor.yy239); } #line 1899 "parse.c" break; case 30: #line 149 "parse.y" { yygotominor.yy384.z = yymsp[-2].minor.yy384.z; yygotominor.yy384.n = (pParse->sLastToken.z-yymsp[-2].minor.yy384.z) + pParse->sLastToken.n; } #line 1907 "parse.c" break; case 31: #line 153 "parse.y" { sqlite3AddColumn(pParse,&yymsp[0].minor.yy384); yygotominor.yy384 = yymsp[0].minor.yy384; } #line 1915 "parse.c" break; case 32: case 33: case 34: case 35: case 36: case 250: #line 163 "parse.y" {yygotominor.yy384 = yymsp[0].minor.yy0;} #line 1925 "parse.c" break; case 38: #line 222 "parse.y" {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy384);} #line 1930 "parse.c" break; case 39: case 42: case 119: case 120: case 131: case 150: case 238: case 248: case 249: #line 223 "parse.y" {yygotominor.yy384 = yymsp[0].minor.yy384;} #line 1943 "parse.c" break; case 40: #line 224 "parse.y" { yygotominor.yy384.z = yymsp[-3].minor.yy384.z; yygotominor.yy384.n = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy384.z; } #line 1951 "parse.c" break; case 41: #line 228 "parse.y" { yygotominor.yy384.z = yymsp[-5].minor.yy384.z; yygotominor.yy384.n = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy384.z; } #line 1959 "parse.c" break; case 43: #line 234 "parse.y" {yygotominor.yy384.z=yymsp[-1].minor.yy384.z; yygotominor.yy384.n=yymsp[0].minor.yy384.n+(yymsp[0].minor.yy384.z-yymsp[-1].minor.yy384.z);} #line 1964 "parse.c" break; case 44: #line 236 "parse.y" { yygotominor.yy230 = atoi((char*)yymsp[0].minor.yy384.z); } #line 1969 "parse.c" break; case 45: #line 237 "parse.y" { yygotominor.yy230 = -atoi((char*)yymsp[0].minor.yy384.z); } #line 1974 "parse.c" break; case 50: case 52: #line 246 "parse.y" {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy178);} #line 1980 "parse.c" break; case 51: #line 247 "parse.y" {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy178);} #line 1985 "parse.c" break; case 53: #line 249 "parse.y" { Expr *p = sqlite3Expr(TK_UMINUS, yymsp[0].minor.yy178, 0, 0); sqlite3AddDefaultValue(pParse,p); } #line 1993 "parse.c" break; case 54: #line 253 "parse.y" { Expr *p = sqlite3Expr(TK_STRING, 0, 0, &yymsp[0].minor.yy384); sqlite3AddDefaultValue(pParse,p); } #line 2001 "parse.c" break; case 56: #line 262 "parse.y" {sqlite3AddNotNull(pParse, yymsp[0].minor.yy230);} #line 2006 "parse.c" break; case 57: #line 264 "parse.y" {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy230,yymsp[0].minor.yy230,yymsp[-2].minor.yy230);} #line 2011 "parse.c" break; case 58: #line 265 "parse.y" {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy230,0,0,0,0);} #line 2016 "parse.c" break; case 59: #line 266 "parse.y" {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy178);} #line 2021 "parse.c" break; case 60: #line 268 "parse.y" {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy384,yymsp[-1].minor.yy462,yymsp[0].minor.yy230);} #line 2026 "parse.c" break; case 61: #line 269 "parse.y" {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy230);} #line 2031 "parse.c" break; case 62: #line 270 "parse.y" {sqlite3AddCollateType(pParse, (char*)yymsp[0].minor.yy384.z, yymsp[0].minor.yy384.n);} #line 2036 "parse.c" break; case 65: #line 283 "parse.y" { yygotominor.yy230 = OE_Restrict * 0x010101; } #line 2041 "parse.c" break; case 66: #line 284 "parse.y" { yygotominor.yy230 = (yymsp[-1].minor.yy230 & yymsp[0].minor.yy13.mask) | yymsp[0].minor.yy13.value; } #line 2046 "parse.c" break; case 67: #line 286 "parse.y" { yygotominor.yy13.value = 0; yygotominor.yy13.mask = 0x000000; } #line 2051 "parse.c" break; case 68: #line 287 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230; yygotominor.yy13.mask = 0x0000ff; } #line 2056 "parse.c" break; case 69: #line 288 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230<<8; yygotominor.yy13.mask = 0x00ff00; } #line 2061 "parse.c" break; case 70: #line 289 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230<<16; yygotominor.yy13.mask = 0xff0000; } #line 2066 "parse.c" break; case 71: #line 291 "parse.y" { yygotominor.yy230 = OE_SetNull; } #line 2071 "parse.c" break; case 72: #line 292 "parse.y" { yygotominor.yy230 = OE_SetDflt; } #line 2076 "parse.c" break; case 73: #line 293 "parse.y" { yygotominor.yy230 = OE_Cascade; } #line 2081 "parse.c" break; case 74: #line 294 "parse.y" { yygotominor.yy230 = OE_Restrict; } #line 2086 "parse.c" break; case 75: case 76: case 91: case 93: case 95: case 96: case 167: #line 296 "parse.y" {yygotominor.yy230 = yymsp[0].minor.yy230;} #line 2097 "parse.c" break; case 80: #line 306 "parse.y" {yygotominor.yy384.n = 0; yygotominor.yy384.z = 0;} #line 2102 "parse.c" break; case 81: #line 307 "parse.y" {yygotominor.yy384 = yymsp[-1].minor.yy0;} #line 2107 "parse.c" break; case 86: #line 313 "parse.y" {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy462,yymsp[0].minor.yy230,yymsp[-2].minor.yy230,0);} #line 2112 "parse.c" break; case 87: #line 315 "parse.y" {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy462,yymsp[0].minor.yy230,0,0,0,0);} #line 2117 "parse.c" break; case 88: #line 316 "parse.y" {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy178);} #line 2122 "parse.c" break; case 89: #line 318 "parse.y" { sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy462, &yymsp[-3].minor.yy384, yymsp[-2].minor.yy462, yymsp[-1].minor.yy230); sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy230); } #line 2130 "parse.c" break; case 92: case 94: #line 332 "parse.y" {yygotominor.yy230 = OE_Default;} #line 2136 "parse.c" break; case 97: #line 337 "parse.y" {yygotominor.yy230 = OE_Ignore;} #line 2141 "parse.c" break; case 98: case 168: #line 338 "parse.y" {yygotominor.yy230 = OE_Replace;} #line 2147 "parse.c" break; case 99: #line 342 "parse.y" { sqlite3DropTable(pParse, yymsp[0].minor.yy285, 0, yymsp[-1].minor.yy230); } #line 2154 "parse.c" break; case 102: #line 352 "parse.y" { sqlite3CreateView(pParse, &yymsp[-6].minor.yy0, &yymsp[-3].minor.yy384, &yymsp[-2].minor.yy384, yymsp[0].minor.yy239, yymsp[-5].minor.yy230); } #line 2161 "parse.c" break; case 103: #line 355 "parse.y" { sqlite3DropTable(pParse, yymsp[0].minor.yy285, 1, yymsp[-1].minor.yy230); } #line 2168 "parse.c" break; case 104: #line 362 "parse.y" { sqlite3Select(pParse, yymsp[0].minor.yy239, SRT_Callback, 0, 0, 0, 0, 0); sqlite3SelectDelete(yymsp[0].minor.yy239); } #line 2176 "parse.c" break; case 105: case 128: #line 372 "parse.y" {yygotominor.yy239 = yymsp[0].minor.yy239;} #line 2182 "parse.c" break; case 106: #line 374 "parse.y" { if( yymsp[0].minor.yy239 ){ yymsp[0].minor.yy239->op = yymsp[-1].minor.yy230; yymsp[0].minor.yy239->pPrior = yymsp[-2].minor.yy239; } yygotominor.yy239 = yymsp[0].minor.yy239; } #line 2193 "parse.c" break; case 108: #line 383 "parse.y" {yygotominor.yy230 = TK_ALL;} #line 2198 "parse.c" break; case 110: #line 387 "parse.y" { yygotominor.yy239 = sqlite3SelectNew(yymsp[-6].minor.yy462,yymsp[-5].minor.yy285,yymsp[-4].minor.yy178,yymsp[-3].minor.yy462,yymsp[-2].minor.yy178,yymsp[-1].minor.yy462,yymsp[-7].minor.yy230,yymsp[0].minor.yy270.pLimit,yymsp[0].minor.yy270.pOffset); } #line 2205 "parse.c" break; case 114: case 235: #line 408 "parse.y" {yygotominor.yy462 = yymsp[-1].minor.yy462;} #line 2211 "parse.c" break; case 115: case 141: case 151: case 234: #line 409 "parse.y" {yygotominor.yy462 = 0;} #line 2219 "parse.c" break; case 116: #line 410 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-2].minor.yy462,yymsp[-1].minor.yy178,yymsp[0].minor.yy384.n?&yymsp[0].minor.yy384:0); } #line 2226 "parse.c" break; case 117: #line 413 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-1].minor.yy462, sqlite3Expr(TK_ALL, 0, 0, 0), 0); } #line 2233 "parse.c" break; case 118: #line 416 "parse.y" { Expr *pRight = sqlite3Expr(TK_ALL, 0, 0, 0); Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-3].minor.yy462, sqlite3Expr(TK_DOT, pLeft, pRight, 0), 0); } #line 2242 "parse.c" break; case 121: #line 428 "parse.y" {yygotominor.yy384.n = 0;} #line 2247 "parse.c" break; case 122: #line 440 "parse.y" {yygotominor.yy285 = sqliteMalloc(sizeof(*yygotominor.yy285));} #line 2252 "parse.c" break; case 123: #line 441 "parse.y" {yygotominor.yy285 = yymsp[0].minor.yy285;} #line 2257 "parse.c" break; case 124: #line 446 "parse.y" { yygotominor.yy285 = yymsp[-1].minor.yy285; if( yygotominor.yy285 && yygotominor.yy285->nSrc>0 ) yygotominor.yy285->a[yygotominor.yy285->nSrc-1].jointype = yymsp[0].minor.yy230; } #line 2265 "parse.c" break; case 125: #line 450 "parse.y" {yygotominor.yy285 = 0;} #line 2270 "parse.c" break; case 126: #line 451 "parse.y" { yygotominor.yy285 = sqlite3SrcListAppend(yymsp[-5].minor.yy285,&yymsp[-4].minor.yy384,&yymsp[-3].minor.yy384); if( yymsp[-2].minor.yy384.n ) sqlite3SrcListAddAlias(yygotominor.yy285,&yymsp[-2].minor.yy384); if( yymsp[-1].minor.yy178 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pOn = yymsp[-1].minor.yy178; } else { sqlite3ExprDelete(yymsp[-1].minor.yy178); } } if( yymsp[0].minor.yy160 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pUsing = yymsp[0].minor.yy160; } else { sqlite3IdListDelete(yymsp[0].minor.yy160); } } } #line 2286 "parse.c" break; case 127: #line 465 "parse.y" { yygotominor.yy285 = sqlite3SrcListAppend(yymsp[-6].minor.yy285,0,0); yygotominor.yy285->a[yygotominor.yy285->nSrc-1].pSelect = yymsp[-4].minor.yy239; if( yymsp[-2].minor.yy384.n ) sqlite3SrcListAddAlias(yygotominor.yy285,&yymsp[-2].minor.yy384); if( yymsp[-1].minor.yy178 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pOn = yymsp[-1].minor.yy178; } else { sqlite3ExprDelete(yymsp[-1].minor.yy178); } } if( yymsp[0].minor.yy160 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pUsing = yymsp[0].minor.yy160; } else { sqlite3IdListDelete(yymsp[0].minor.yy160); } } } #line 2303 "parse.c" break; case 129: #line 486 "parse.y" { yygotominor.yy239 = sqlite3SelectNew(0,yymsp[0].minor.yy285,0,0,0,0,0,0,0); } #line 2310 "parse.c" break; case 130: #line 492 "parse.y" {yygotominor.yy384.z=0; yygotominor.yy384.n=0;} #line 2315 "parse.c" break; case 132: #line 497 "parse.y" {yygotominor.yy285 = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384);} #line 2320 "parse.c" break; case 133: #line 501 "parse.y" { yygotominor.yy230 = JT_INNER; } #line 2325 "parse.c" break; case 134: #line 502 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } #line 2330 "parse.c" break; case 135: #line 503 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy384,0); } #line 2335 "parse.c" break; case 136: #line 505 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy384,&yymsp[-1].minor.yy384); } #line 2340 "parse.c" break; case 137: case 145: case 154: case 161: case 175: case 200: case 223: case 225: case 229: #line 509 "parse.y" {yygotominor.yy178 = yymsp[0].minor.yy178;} #line 2353 "parse.c" break; case 138: case 153: case 160: case 201: case 224: case 226: case 230: #line 510 "parse.y" {yygotominor.yy178 = 0;} #line 2364 "parse.c" break; case 139: case 172: #line 514 "parse.y" {yygotominor.yy160 = yymsp[-1].minor.yy160;} #line 2370 "parse.c" break; case 140: case 171: #line 515 "parse.y" {yygotominor.yy160 = 0;} #line 2376 "parse.c" break; case 142: case 152: #line 526 "parse.y" {yygotominor.yy462 = yymsp[0].minor.yy462;} #line 2382 "parse.c" break; case 143: #line 527 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462,yymsp[-2].minor.yy178,yymsp[-1].minor.yy384.n>0?&yymsp[-1].minor.yy384:0); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } #line 2390 "parse.c" break; case 144: #line 531 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[-2].minor.yy178,yymsp[-1].minor.yy384.n>0?&yymsp[-1].minor.yy384:0); if( yygotominor.yy462 && yygotominor.yy462->a ) yygotominor.yy462->a[0].sortOrder = yymsp[0].minor.yy230; } #line 2398 "parse.c" break; case 146: case 148: #line 540 "parse.y" {yygotominor.yy230 = SQLITE_SO_ASC;} #line 2404 "parse.c" break; case 147: #line 541 "parse.y" {yygotominor.yy230 = SQLITE_SO_DESC;} #line 2409 "parse.c" break; case 149: #line 543 "parse.y" {yygotominor.yy384.z = 0; yygotominor.yy384.n = 0;} #line 2414 "parse.c" break; case 155: #line 561 "parse.y" {yygotominor.yy270.pLimit = 0; yygotominor.yy270.pOffset = 0;} #line 2419 "parse.c" break; case 156: #line 562 "parse.y" {yygotominor.yy270.pLimit = yymsp[0].minor.yy178; yygotominor.yy270.pOffset = 0;} #line 2424 "parse.c" break; case 157: #line 564 "parse.y" {yygotominor.yy270.pLimit = yymsp[-2].minor.yy178; yygotominor.yy270.pOffset = yymsp[0].minor.yy178;} #line 2429 "parse.c" break; case 158: #line 566 "parse.y" {yygotominor.yy270.pOffset = yymsp[-2].minor.yy178; yygotominor.yy270.pLimit = yymsp[0].minor.yy178;} #line 2434 "parse.c" break; case 159: #line 570 "parse.y" {sqlite3DeleteFrom(pParse,yymsp[-1].minor.yy285,yymsp[0].minor.yy178);} #line 2439 "parse.c" break; case 162: #line 581 "parse.y" {sqlite3Update(pParse,yymsp[-3].minor.yy285,yymsp[-1].minor.yy462,yymsp[0].minor.yy178,yymsp[-4].minor.yy230);} #line 2444 "parse.c" break; case 163: #line 587 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462,yymsp[0].minor.yy178,&yymsp[-2].minor.yy384);} #line 2449 "parse.c" break; case 164: #line 588 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[0].minor.yy178,&yymsp[-2].minor.yy384);} #line 2454 "parse.c" break; case 165: #line 594 "parse.y" {sqlite3Insert(pParse, yymsp[-5].minor.yy285, yymsp[-1].minor.yy462, 0, yymsp[-4].minor.yy160, yymsp[-7].minor.yy230);} #line 2459 "parse.c" break; case 166: #line 596 "parse.y" {sqlite3Insert(pParse, yymsp[-2].minor.yy285, 0, yymsp[0].minor.yy239, yymsp[-1].minor.yy160, yymsp[-4].minor.yy230);} #line 2464 "parse.c" break; case 169: case 227: #line 606 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-2].minor.yy462,yymsp[0].minor.yy178,0);} #line 2470 "parse.c" break; case 170: case 228: #line 607 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[0].minor.yy178,0);} #line 2476 "parse.c" break; case 173: #line 616 "parse.y" {yygotominor.yy160 = sqlite3IdListAppend(yymsp[-2].minor.yy160,&yymsp[0].minor.yy384);} #line 2481 "parse.c" break; case 174: #line 617 "parse.y" {yygotominor.yy160 = sqlite3IdListAppend(0,&yymsp[0].minor.yy384);} #line 2486 "parse.c" break; case 176: #line 628 "parse.y" {yygotominor.yy178 = yymsp[-1].minor.yy178; sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } #line 2491 "parse.c" break; case 177: case 182: case 183: #line 629 "parse.y" {yygotominor.yy178 = sqlite3Expr(yymsp[0].major, 0, 0, &yymsp[0].minor.yy0);} #line 2498 "parse.c" break; case 178: case 179: #line 630 "parse.y" {yygotominor.yy178 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} #line 2504 "parse.c" break; case 180: #line 632 "parse.y" { Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy384); yygotominor.yy178 = sqlite3Expr(TK_DOT, temp1, temp2, 0); } #line 2513 "parse.c" break; case 181: #line 637 "parse.y" { Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-4].minor.yy384); Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); Expr *temp3 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy384); Expr *temp4 = sqlite3Expr(TK_DOT, temp2, temp3, 0); yygotominor.yy178 = sqlite3Expr(TK_DOT, temp1, temp4, 0); } #line 2524 "parse.c" break; case 184: #line 646 "parse.y" {yygotominor.yy178 = sqlite3RegisterExpr(pParse, &yymsp[0].minor.yy0);} #line 2529 "parse.c" break; case 185: #line 647 "parse.y" { Token *pToken = &yymsp[0].minor.yy0; Expr *pExpr = yygotominor.yy178 = sqlite3Expr(TK_VARIABLE, 0, 0, pToken); sqlite3ExprAssignVarNumber(pParse, pExpr); } #line 2538 "parse.c" break; case 186: #line 653 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_CAST, yymsp[-3].minor.yy178, 0, &yymsp[-1].minor.yy384); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); } #line 2546 "parse.c" break; case 187: #line 658 "parse.y" { yygotominor.yy178 = sqlite3ExprFunction(yymsp[-1].minor.yy462, &yymsp[-4].minor.yy0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); if( yymsp[-2].minor.yy230 ){ yygotominor.yy178->flags |= EP_Distinct; } } #line 2557 "parse.c" break; case 188: #line 665 "parse.y" { yygotominor.yy178 = sqlite3ExprFunction(0, &yymsp[-3].minor.yy0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); } #line 2565 "parse.c" break; case 189: #line 669 "parse.y" { /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are ** treated as functions that return constants */ yygotominor.yy178 = sqlite3ExprFunction(0,&yymsp[0].minor.yy0); if( yygotominor.yy178 ) yygotominor.yy178->op = TK_CONST_FUNC; } #line 2575 "parse.c" break; case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: #line 675 "parse.y" {yygotominor.yy178 = sqlite3Expr(yymsp[-1].major, yymsp[-2].minor.yy178, yymsp[0].minor.yy178, 0);} #line 2587 "parse.c" break; case 198: #line 685 "parse.y" {yygotominor.yy440.eOperator = yymsp[0].minor.yy0; yygotominor.yy440.not = 0;} #line 2592 "parse.c" break; case 199: #line 686 "parse.y" {yygotominor.yy440.eOperator = yymsp[0].minor.yy0; yygotominor.yy440.not = 1;} #line 2597 "parse.c" break; case 202: #line 691 "parse.y" { ExprList *pList = sqlite3ExprListAppend(0, yymsp[-1].minor.yy178, 0); pList = sqlite3ExprListAppend(pList, yymsp[-3].minor.yy178, 0); if( yymsp[0].minor.yy178 ){ pList = sqlite3ExprListAppend(pList, yymsp[0].minor.yy178, 0); } yygotominor.yy178 = sqlite3ExprFunction(pList, &yymsp[-2].minor.yy440.eOperator); if( yymsp[-2].minor.yy440.not ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy178->span, &yymsp[-1].minor.yy178->span); } #line 2611 "parse.c" break; case 203: #line 702 "parse.y" { yygotominor.yy178 = sqlite3Expr(yymsp[0].major, yymsp[-1].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2619 "parse.c" break; case 204: #line 706 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_ISNULL, yymsp[-2].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2627 "parse.c" break; case 205: #line 710 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_NOTNULL, yymsp[-2].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2635 "parse.c" break; case 206: #line 714 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_NOTNULL, yymsp[-3].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2643 "parse.c" break; case 207: #line 718 "parse.y" { yygotominor.yy178 = sqlite3Expr(yymsp[-1].major, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } #line 2651 "parse.c" break; case 208: #line 722 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_UMINUS, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } #line 2659 "parse.c" break; case 209: #line 726 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_UPLUS, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } #line 2667 "parse.c" break; case 212: #line 733 "parse.y" { ExprList *pList = sqlite3ExprListAppend(0, yymsp[-2].minor.yy178, 0); pList = sqlite3ExprListAppend(pList, yymsp[0].minor.yy178, 0); yygotominor.yy178 = sqlite3Expr(TK_BETWEEN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pList = pList; }else{ sqlite3ExprListDelete(pList); } if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy178->span); } #line 2683 "parse.c" break; case 215: #line 749 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pList = yymsp[-1].minor.yy462; }else{ sqlite3ExprListDelete(yymsp[-1].minor.yy462); } if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2697 "parse.c" break; case 216: #line 759 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_SELECT, 0, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pSelect = yymsp[-1].minor.yy239; }else{ sqlite3SelectDelete(yymsp[-1].minor.yy239); } sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } #line 2710 "parse.c" break; case 217: #line 768 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pSelect = yymsp[-1].minor.yy239; }else{ sqlite3SelectDelete(yymsp[-1].minor.yy239); } if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2724 "parse.c" break; case 218: #line 778 "parse.y" { SrcList *pSrc = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384); yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-3].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,0,0); }else{ sqlite3SrcListDelete(pSrc); } if( yymsp[-2].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy178->span,yymsp[0].minor.yy384.z?&yymsp[0].minor.yy384:&yymsp[-1].minor.yy384); } #line 2739 "parse.c" break; case 219: #line 789 "parse.y" { Expr *p = yygotominor.yy178 = sqlite3Expr(TK_EXISTS, 0, 0, 0); if( p ){ p->pSelect = yymsp[-1].minor.yy239; sqlite3ExprSpan(p,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); }else{ sqlite3SelectDelete(yymsp[-1].minor.yy239); } } #line 2752 "parse.c" break; case 220: #line 801 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_CASE, yymsp[-3].minor.yy178, yymsp[-1].minor.yy178, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pList = yymsp[-2].minor.yy462; }else{ sqlite3ExprListDelete(yymsp[-2].minor.yy462); } sqlite3ExprSpan(yygotominor.yy178, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0); } #line 2765 "parse.c" break; case 221: #line 812 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462, yymsp[-2].minor.yy178, 0); yygotominor.yy462 = sqlite3ExprListAppend(yygotominor.yy462, yymsp[0].minor.yy178, 0); } #line 2773 "parse.c" break; case 222: #line 816 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(0, yymsp[-2].minor.yy178, 0); yygotominor.yy462 = sqlite3ExprListAppend(yygotominor.yy462, yymsp[0].minor.yy178, 0); } #line 2781 "parse.c" break; case 231: #line 843 "parse.y" { sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy384, &yymsp[-5].minor.yy384, sqlite3SrcListAppend(0,&yymsp[-3].minor.yy384,0), yymsp[-1].minor.yy462, yymsp[-9].minor.yy230, &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy230); } #line 2789 "parse.c" break; case 232: case 277: #line 849 "parse.y" {yygotominor.yy230 = OE_Abort;} #line 2795 "parse.c" break; case 233: #line 850 "parse.y" {yygotominor.yy230 = OE_None;} #line 2800 "parse.c" break; case 236: #line 860 "parse.y" { Expr *p = 0; if( yymsp[-1].minor.yy384.n>0 ){ p = sqlite3Expr(TK_COLUMN, 0, 0, 0); if( p ) p->pColl = sqlite3LocateCollSeq(pParse, (char*)yymsp[-1].minor.yy384.z, yymsp[-1].minor.yy384.n); } yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462, p, &yymsp[-2].minor.yy384); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } #line 2813 "parse.c" break; case 237: #line 869 "parse.y" { Expr *p = 0; if( yymsp[-1].minor.yy384.n>0 ){ p = sqlite3Expr(TK_COLUMN, 0, 0, 0); if( p ) p->pColl = sqlite3LocateCollSeq(pParse, (char*)yymsp[-1].minor.yy384.z, yymsp[-1].minor.yy384.n); } yygotominor.yy462 = sqlite3ExprListAppend(0, p, &yymsp[-2].minor.yy384); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } #line 2826 "parse.c" break; case 239: #line 883 "parse.y" {sqlite3DropIndex(pParse, yymsp[0].minor.yy285, yymsp[-1].minor.yy230);} #line 2831 "parse.c" break; case 240: case 241: #line 887 "parse.y" {sqlite3Vacuum(pParse,0);} #line 2837 "parse.c" break; case 242: case 244: #line 893 "parse.y" {sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy384,0);} #line 2843 "parse.c" break; case 243: #line 894 "parse.y" {sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy0,0);} #line 2848 "parse.c" break; case 245: #line 896 "parse.y" { sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy384,1); } #line 2855 "parse.c" break; case 246: #line 899 "parse.y" {sqlite3Pragma(pParse,&yymsp[-4].minor.yy384,&yymsp[-3].minor.yy384,&yymsp[-1].minor.yy384,0);} #line 2860 "parse.c" break; case 247: #line 900 "parse.y" {sqlite3Pragma(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,0,0);} #line 2865 "parse.c" break; case 253: #line 912 "parse.y" { Token all; all.z = yymsp[-3].minor.yy384.z; all.n = (yymsp[0].minor.yy0.z - yymsp[-3].minor.yy384.z) + yymsp[0].minor.yy0.n; sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy247, &all); } #line 2875 "parse.c" break; case 254: #line 921 "parse.y" { sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy384, &yymsp[-6].minor.yy384, yymsp[-5].minor.yy230, yymsp[-4].minor.yy132.a, yymsp[-4].minor.yy132.b, yymsp[-2].minor.yy285, yymsp[-1].minor.yy230, yymsp[0].minor.yy178, yymsp[-9].minor.yy230); yygotominor.yy384 = (yymsp[-6].minor.yy384.n==0?yymsp[-7].minor.yy384:yymsp[-6].minor.yy384); } #line 2883 "parse.c" break; case 255: case 258: #line 927 "parse.y" { yygotominor.yy230 = TK_BEFORE; } #line 2889 "parse.c" break; case 256: #line 928 "parse.y" { yygotominor.yy230 = TK_AFTER; } #line 2894 "parse.c" break; case 257: #line 929 "parse.y" { yygotominor.yy230 = TK_INSTEAD;} #line 2899 "parse.c" break; case 259: case 260: #line 934 "parse.y" {yygotominor.yy132.a = yymsp[0].major; yygotominor.yy132.b = 0;} #line 2905 "parse.c" break; case 261: #line 936 "parse.y" {yygotominor.yy132.a = TK_UPDATE; yygotominor.yy132.b = yymsp[0].minor.yy160;} #line 2910 "parse.c" break; case 262: case 263: #line 939 "parse.y" { yygotominor.yy230 = TK_ROW; } #line 2916 "parse.c" break; case 264: #line 941 "parse.y" { yygotominor.yy230 = TK_STATEMENT; } #line 2921 "parse.c" break; case 265: #line 945 "parse.y" { yygotominor.yy178 = 0; } #line 2926 "parse.c" break; case 266: #line 946 "parse.y" { yygotominor.yy178 = yymsp[0].minor.yy178; } #line 2931 "parse.c" break; case 267: #line 950 "parse.y" { yymsp[-2].minor.yy247->pNext = yymsp[0].minor.yy247; yygotominor.yy247 = yymsp[-2].minor.yy247; } #line 2939 "parse.c" break; case 268: #line 954 "parse.y" { yygotominor.yy247 = 0; } #line 2944 "parse.c" break; case 269: #line 960 "parse.y" { yygotominor.yy247 = sqlite3TriggerUpdateStep(&yymsp[-3].minor.yy384, yymsp[-1].minor.yy462, yymsp[0].minor.yy178, yymsp[-4].minor.yy230); } #line 2949 "parse.c" break; case 270: #line 965 "parse.y" {yygotominor.yy247 = sqlite3TriggerInsertStep(&yymsp[-5].minor.yy384, yymsp[-4].minor.yy160, yymsp[-1].minor.yy462, 0, yymsp[-7].minor.yy230);} #line 2954 "parse.c" break; case 271: #line 968 "parse.y" {yygotominor.yy247 = sqlite3TriggerInsertStep(&yymsp[-2].minor.yy384, yymsp[-1].minor.yy160, 0, yymsp[0].minor.yy239, yymsp[-4].minor.yy230);} #line 2959 "parse.c" break; case 272: #line 972 "parse.y" {yygotominor.yy247 = sqlite3TriggerDeleteStep(&yymsp[-1].minor.yy384, yymsp[0].minor.yy178);} #line 2964 "parse.c" break; case 273: #line 975 "parse.y" {yygotominor.yy247 = sqlite3TriggerSelectStep(yymsp[0].minor.yy239); } #line 2969 "parse.c" break; case 274: #line 978 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_RAISE, 0, 0, 0); yygotominor.yy178->iColumn = OE_Ignore; sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); } #line 2978 "parse.c" break; case 275: #line 983 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy384); yygotominor.yy178->iColumn = yymsp[-3].minor.yy230; sqlite3ExprSpan(yygotominor.yy178, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); } #line 2987 "parse.c" break; case 276: #line 991 "parse.y" {yygotominor.yy230 = OE_Rollback;} #line 2992 "parse.c" break; case 278: #line 993 "parse.y" {yygotominor.yy230 = OE_Fail;} #line 2997 "parse.c" break; case 279: #line 998 "parse.y" { sqlite3DropTrigger(pParse,yymsp[0].minor.yy285); } #line 3004 "parse.c" break; case 280: #line 1004 "parse.y" { sqlite3Attach(pParse, yymsp[-3].minor.yy178, yymsp[-1].minor.yy178, yymsp[0].minor.yy292); } #line 3011 "parse.c" break; case 281: #line 1009 "parse.y" { yygotominor.yy292 = 0; } #line 3016 "parse.c" break; case 282: #line 1010 "parse.y" { yygotominor.yy292 = yymsp[0].minor.yy178; } #line 3021 "parse.c" break; case 285: #line 1016 "parse.y" { sqlite3Detach(pParse, yymsp[0].minor.yy178); } #line 3028 "parse.c" break; case 286: #line 1022 "parse.y" {sqlite3Reindex(pParse, 0, 0);} #line 3033 "parse.c" break; case 287: #line 1023 "parse.y" {sqlite3Reindex(pParse, &yymsp[-1].minor.yy384, &yymsp[0].minor.yy384);} #line 3038 "parse.c" break; case 288: #line 1028 "parse.y" {sqlite3Analyze(pParse, 0, 0);} #line 3043 "parse.c" break; case 289: #line 1029 "parse.y" {sqlite3Analyze(pParse, &yymsp[-1].minor.yy384, &yymsp[0].minor.yy384);} #line 3048 "parse.c" break; case 290: #line 1034 "parse.y" { sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy285,&yymsp[0].minor.yy384); } #line 3055 "parse.c" break; case 291: #line 1037 "parse.y" { sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy384); } #line 3062 "parse.c" break; case 292: #line 1040 "parse.y" { sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy285); } #line 3069 "parse.c" break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); if( yyact < YYNSTATE ){ ................................................................................ if( pParse->zErrMsg==0 ){ if( TOKEN.z[0] ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); }else{ sqlite3ErrorMsg(pParse, "incomplete SQL statement"); } } #line 3136 "parse.c" sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following is executed when the parser accepts */ static void yy_accept( |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | | | | | | | | | | | | | | > | | | > | | > | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 ... 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 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 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 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 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 .... 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 .... 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 .... 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 .... 1797 1798 1799 1800 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 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 .... 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 |
/* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> #line 54 "parse.y" #include "sqliteInt.h" #include "parse.h" /* ** An instance of this structure holds information about the ** LIMIT clause of a SELECT statement. ................................................................................ int yy479; } YYMINORTYPE; #define YYSTACKDEPTH 100 #define sqlite3ParserARG_SDECL Parse *pParse; #define sqlite3ParserARG_PDECL ,Parse *pParse #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse #define sqlite3ParserARG_STORE yypParser->pParse = pParse #define YYNSTATE 559 #define YYNRULE 295 #define YYERRORSYMBOL 137 #define YYERRSYMDT yy479 #define YYFALLBACK 1 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) ................................................................................ ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ static const YYACTIONTYPE yy_action[] = { /* 0 */ 279, 67, 283, 69, 147, 165, 545, 418, 61, 61, /* 10 */ 61, 61, 201, 63, 63, 63, 63, 64, 64, 65, /* 20 */ 65, 65, 66, 66, 547, 548, 431, 68, 63, 63, /* 30 */ 63, 63, 64, 64, 65, 65, 65, 66, 67, 453, /* 40 */ 69, 147, 498, 60, 58, 287, 439, 440, 436, 436, /* 50 */ 62, 62, 61, 61, 61, 61, 500, 63, 63, 63, /* 60 */ 63, 64, 64, 65, 65, 65, 66, 279, 370, 283, /* 70 */ 418, 2, 376, 79, 157, 114, 219, 304, 224, 305, /* 80 */ 169, 244, 855, 118, 558, 503, 203, 2, 245, 388, /* 90 */ 495, 218, 21, 431, 513, 20, 418, 57, 492, 511, /* 100 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, /* 110 */ 60, 58, 287, 439, 440, 436, 436, 62, 62, 61, /* 120 */ 61, 61, 61, 530, 63, 63, 63, 63, 64, 64, /* 130 */ 65, 65, 65, 66, 279, 377, 378, 174, 371, 368, /* 140 */ 330, 333, 334, 219, 304, 224, 305, 169, 244, 510, /* 150 */ 479, 19, 335, 138, 376, 245, 509, 301, 372, 418, /* 160 */ 431, 529, 91, 199, 65, 65, 65, 66, 504, 167, /* 170 */ 191, 64, 64, 65, 65, 65, 66, 60, 58, 287, /* 180 */ 439, 440, 436, 436, 62, 62, 61, 61, 61, 61, /* 190 */ 254, 63, 63, 63, 63, 64, 64, 65, 65, 65, /* 200 */ 66, 279, 250, 410, 410, 430, 109, 395, 426, 204, /* 210 */ 357, 260, 259, 308, 145, 168, 153, 377, 378, 396, /* 220 */ 327, 201, 67, 189, 69, 147, 225, 431, 546, 361, /* 230 */ 465, 365, 397, 499, 318, 409, 40, 413, 428, 312, /* 240 */ 161, 180, 550, 178, 60, 58, 287, 439, 440, 436, /* 250 */ 436, 62, 62, 61, 61, 61, 61, 410, 63, 63, /* 260 */ 63, 63, 64, 64, 65, 65, 65, 66, 279, 471, /* 270 */ 415, 415, 415, 282, 308, 322, 235, 426, 204, 308, /* 280 */ 174, 367, 308, 330, 333, 334, 67, 308, 69, 147, /* 290 */ 148, 559, 371, 368, 431, 335, 409, 34, 165, 465, /* 300 */ 418, 409, 34, 275, 409, 34, 428, 502, 161, 409, /* 310 */ 35, 60, 58, 287, 439, 440, 436, 436, 62, 62, /* 320 */ 61, 61, 61, 61, 410, 63, 63, 63, 63, 64, /* 330 */ 64, 65, 65, 65, 66, 308, 503, 395, 237, 290, /* 340 */ 279, 391, 392, 146, 324, 387, 20, 288, 347, 396, /* 350 */ 174, 450, 350, 330, 333, 334, 450, 409, 27, 450, /* 360 */ 474, 231, 397, 418, 393, 335, 431, 501, 354, 144, /* 370 */ 512, 503, 524, 232, 394, 465, 496, 410, 527, 392, /* 380 */ 555, 20, 75, 60, 58, 287, 439, 440, 436, 436, /* 390 */ 62, 62, 61, 61, 61, 61, 220, 63, 63, 63, /* 400 */ 63, 64, 64, 65, 65, 65, 66, 308, 221, 185, /* 410 */ 338, 254, 279, 308, 239, 443, 475, 308, 319, 308, /* 420 */ 389, 444, 286, 421, 422, 379, 380, 381, 492, 409, /* 430 */ 34, 311, 421, 422, 212, 409, 48, 170, 431, 409, /* 440 */ 40, 409, 48, 410, 122, 314, 526, 442, 442, 1, /* 450 */ 376, 469, 255, 376, 78, 60, 58, 287, 439, 440, /* 460 */ 436, 436, 62, 62, 61, 61, 61, 61, 355, 63, /* 470 */ 63, 63, 63, 64, 64, 65, 65, 65, 66, 279, /* 480 */ 233, 152, 298, 478, 449, 203, 792, 192, 299, 351, /* 490 */ 376, 281, 376, 9, 203, 376, 245, 376, 201, 432, /* 500 */ 314, 376, 442, 442, 490, 431, 314, 325, 442, 442, /* 510 */ 418, 356, 289, 377, 378, 354, 377, 378, 403, 434, /* 520 */ 435, 410, 60, 58, 287, 439, 440, 436, 436, 62, /* 530 */ 62, 61, 61, 61, 61, 263, 63, 63, 63, 63, /* 540 */ 64, 64, 65, 65, 65, 66, 279, 433, 328, 236, /* 550 */ 497, 473, 490, 377, 378, 377, 378, 484, 377, 378, /* 560 */ 377, 378, 308, 522, 377, 378, 314, 521, 442, 442, /* 570 */ 409, 3, 431, 418, 130, 254, 264, 485, 309, 346, /* 580 */ 461, 213, 462, 242, 409, 28, 469, 292, 214, 60, /* 590 */ 58, 287, 439, 440, 436, 436, 62, 62, 61, 61, /* 600 */ 61, 61, 308, 63, 63, 63, 63, 64, 64, 65, /* 610 */ 65, 65, 66, 279, 308, 458, 536, 248, 5, 308, /* 620 */ 201, 308, 469, 308, 409, 23, 308, 202, 291, 308, /* 630 */ 375, 243, 308, 362, 54, 115, 409, 32, 74, 431, /* 640 */ 76, 409, 53, 409, 24, 409, 51, 345, 409, 96, /* 650 */ 149, 409, 93, 265, 409, 98, 60, 58, 287, 439, /* 660 */ 440, 436, 436, 62, 62, 61, 61, 61, 61, 308, /* 670 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, /* 680 */ 279, 308, 404, 297, 410, 90, 308, 176, 308, 405, /* 690 */ 308, 409, 99, 308, 419, 308, 22, 308, 520, 344, /* 700 */ 520, 164, 153, 409, 110, 141, 431, 313, 409, 111, /* 710 */ 409, 16, 409, 97, 254, 409, 33, 409, 94, 409, /* 720 */ 52, 410, 187, 60, 58, 287, 439, 440, 436, 436, /* 730 */ 62, 62, 61, 61, 61, 61, 308, 63, 63, 63, /* 740 */ 63, 64, 64, 65, 65, 65, 66, 279, 308, 490, /* 750 */ 490, 414, 308, 320, 308, 538, 308, 460, 409, 112, /* 760 */ 308, 171, 172, 173, 308, 408, 308, 424, 424, 407, /* 770 */ 409, 113, 427, 431, 409, 25, 409, 36, 409, 37, /* 780 */ 170, 437, 409, 26, 211, 293, 409, 38, 409, 39, /* 790 */ 60, 58, 287, 439, 440, 436, 436, 62, 62, 61, /* 800 */ 61, 61, 61, 308, 63, 63, 63, 63, 64, 64, /* 810 */ 65, 65, 65, 66, 279, 308, 490, 490, 451, 308, /* 820 */ 81, 308, 151, 308, 459, 409, 41, 308, 243, 243, /* 830 */ 400, 401, 308, 448, 281, 12, 464, 409, 42, 468, /* 840 */ 431, 409, 43, 409, 29, 409, 30, 241, 460, 409, /* 850 */ 44, 294, 296, 480, 409, 45, 329, 60, 70, 287, /* 860 */ 439, 440, 436, 436, 62, 62, 61, 61, 61, 61, /* 870 */ 308, 63, 63, 63, 63, 64, 64, 65, 65, 65, /* 880 */ 66, 279, 308, 408, 483, 482, 308, 407, 308, 467, /* 890 */ 308, 166, 409, 46, 308, 243, 243, 476, 488, 12, /* 900 */ 122, 518, 519, 179, 409, 47, 481, 431, 409, 31, /* 910 */ 409, 10, 409, 49, 505, 486, 409, 50, 254, 249, /* 920 */ 254, 254, 254, 158, 279, 58, 287, 439, 440, 436, /* 930 */ 436, 62, 62, 61, 61, 61, 61, 410, 63, 63, /* 940 */ 63, 63, 64, 64, 65, 65, 65, 66, 487, 247, /* 950 */ 431, 122, 254, 337, 525, 122, 122, 251, 533, 539, /* 960 */ 166, 540, 266, 360, 534, 543, 88, 88, 252, 287, /* 970 */ 439, 440, 436, 436, 62, 62, 61, 61, 61, 61, /* 980 */ 195, 63, 63, 63, 63, 64, 64, 65, 65, 65, /* 990 */ 66, 71, 315, 268, 4, 253, 182, 258, 285, 349, /* 1000 */ 342, 352, 353, 261, 262, 544, 310, 71, 315, 269, /* 1010 */ 4, 222, 363, 272, 285, 593, 273, 554, 140, 226, /* 1020 */ 385, 423, 310, 317, 425, 316, 532, 542, 18, 156, /* 1030 */ 479, 454, 457, 430, 332, 489, 374, 382, 383, 317, /* 1040 */ 384, 8, 302, 303, 491, 390, 398, 284, 403, 430, /* 1050 */ 223, 406, 73, 72, 402, 81, 411, 399, 323, 56, /* 1060 */ 71, 306, 307, 205, 321, 413, 80, 227, 73, 72, /* 1070 */ 472, 77, 452, 163, 234, 455, 71, 306, 307, 71, /* 1080 */ 315, 413, 4, 229, 201, 456, 285, 412, 228, 82, /* 1090 */ 119, 326, 230, 206, 310, 207, 101, 276, 415, 415, /* 1100 */ 415, 416, 417, 11, 238, 494, 466, 470, 240, 209, /* 1110 */ 210, 317, 493, 506, 415, 415, 415, 416, 417, 11, /* 1120 */ 507, 430, 155, 339, 508, 514, 177, 215, 216, 217, /* 1130 */ 105, 277, 341, 181, 516, 83, 343, 85, 256, 455, /* 1140 */ 73, 72, 517, 197, 183, 270, 348, 117, 71, 306, /* 1150 */ 307, 528, 271, 413, 186, 126, 535, 358, 127, 128, /* 1160 */ 541, 135, 300, 132, 194, 136, 529, 551, 552, 553, /* 1170 */ 129, 193, 89, 196, 430, 556, 208, 100, 95, 373, /* 1180 */ 386, 116, 200, 55, 17, 594, 415, 415, 415, 416, /* 1190 */ 417, 11, 92, 142, 143, 595, 159, 108, 160, 59, /* 1200 */ 438, 420, 499, 429, 137, 441, 413, 445, 150, 162, /* 1210 */ 446, 447, 6, 7, 13, 359, 267, 259, 463, 12, /* 1220 */ 120, 280, 121, 154, 477, 102, 201, 246, 331, 103, /* 1230 */ 84, 104, 336, 175, 221, 340, 139, 515, 123, 415, /* 1240 */ 415, 415, 184, 124, 295, 166, 257, 106, 523, 278, /* 1250 */ 364, 531, 125, 86, 188, 14, 190, 537, 131, 133, /* 1260 */ 87, 134, 15, 107, 198, 549, 366, 369, 536, 557, /* 1270 */ 274, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 16, 216, 16, 218, 219, 21, 146, 23, 68, 69, /* 10 */ 70, 71, 109, 73, 74, 75, 76, 77, 78, 79, /* 20 */ 80, 81, 82, 82, 164, 165, 42, 72, 73, 74, /* 30 */ 75, 76, 77, 78, 79, 80, 81, 82, 216, 217, /* 40 */ 218, 219, 168, 59, 60, 61, 62, 63, 64, 65, /* 50 */ 66, 67, 68, 69, 70, 71, 168, 73, 74, 75, /* 60 */ 76, 77, 78, 79, 80, 81, 82, 16, 140, 16, /* 70 */ 86, 143, 23, 22, 88, 89, 90, 91, 92, 93, /* 80 */ 94, 95, 138, 139, 140, 146, 226, 143, 102, 166, /* 90 */ 167, 152, 19, 42, 155, 156, 23, 46, 175, 180, /* 100 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, /* 110 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 120 */ 69, 70, 71, 11, 73, 74, 75, 76, 77, 78, /* 130 */ 79, 80, 81, 82, 16, 86, 87, 88, 1, 2, /* 140 */ 91, 92, 93, 90, 91, 92, 93, 94, 95, 175, /* 150 */ 176, 19, 103, 21, 23, 102, 182, 141, 142, 86, /* 160 */ 42, 49, 44, 147, 79, 80, 81, 82, 180, 154, /* 170 */ 154, 77, 78, 79, 80, 81, 82, 59, 60, 61, /* 180 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 190 */ 146, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 200 */ 82, 16, 14, 188, 188, 58, 21, 12, 77, 78, /* 210 */ 98, 99, 100, 146, 22, 200, 201, 86, 87, 24, /* 220 */ 205, 109, 216, 154, 218, 219, 189, 42, 97, 213, /* 230 */ 160, 187, 37, 86, 39, 168, 169, 90, 160, 161, /* 240 */ 162, 53, 236, 55, 59, 60, 61, 62, 63, 64, /* 250 */ 65, 66, 67, 68, 69, 70, 71, 188, 73, 74, /* 260 */ 75, 76, 77, 78, 79, 80, 81, 82, 16, 199, /* 270 */ 123, 124, 125, 149, 146, 208, 209, 77, 78, 146, /* 280 */ 88, 237, 146, 91, 92, 93, 216, 146, 218, 219, /* 290 */ 154, 0, 1, 2, 42, 103, 168, 169, 21, 160, /* 300 */ 23, 168, 169, 157, 168, 169, 160, 161, 162, 168, /* 310 */ 169, 59, 60, 61, 62, 63, 64, 65, 66, 67, /* 320 */ 68, 69, 70, 71, 188, 73, 74, 75, 76, 77, /* 330 */ 78, 79, 80, 81, 82, 146, 146, 12, 199, 211, /* 340 */ 16, 184, 185, 154, 211, 155, 156, 211, 224, 24, /* 350 */ 88, 223, 228, 91, 92, 93, 223, 168, 169, 223, /* 360 */ 20, 220, 37, 86, 39, 103, 42, 159, 146, 179, /* 370 */ 180, 146, 18, 146, 49, 160, 168, 188, 184, 185, /* 380 */ 155, 156, 130, 59, 60, 61, 62, 63, 64, 65, /* 390 */ 66, 67, 68, 69, 70, 71, 90, 73, 74, 75, /* 400 */ 76, 77, 78, 79, 80, 81, 82, 146, 102, 154, /* 410 */ 16, 146, 16, 146, 199, 20, 20, 146, 185, 146, /* 420 */ 167, 20, 163, 164, 165, 7, 8, 9, 175, 168, /* 430 */ 169, 163, 164, 165, 212, 168, 169, 43, 42, 168, /* 440 */ 169, 168, 169, 188, 22, 105, 92, 107, 108, 19, /* 450 */ 23, 146, 187, 23, 130, 59, 60, 61, 62, 63, /* 460 */ 64, 65, 66, 67, 68, 69, 70, 71, 213, 73, /* 470 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 16, /* 480 */ 209, 146, 215, 20, 223, 226, 132, 154, 215, 234, /* 490 */ 23, 97, 23, 19, 226, 23, 102, 23, 109, 42, /* 500 */ 105, 23, 107, 108, 146, 42, 105, 146, 107, 108, /* 510 */ 23, 122, 207, 86, 87, 146, 86, 87, 96, 62, /* 520 */ 63, 188, 59, 60, 61, 62, 63, 64, 65, 66, /* 530 */ 67, 68, 69, 70, 71, 14, 73, 74, 75, 76, /* 540 */ 77, 78, 79, 80, 81, 82, 16, 90, 146, 146, /* 550 */ 20, 79, 146, 86, 87, 86, 87, 30, 86, 87, /* 560 */ 86, 87, 146, 25, 86, 87, 105, 29, 107, 108, /* 570 */ 168, 169, 42, 86, 53, 146, 55, 50, 146, 41, /* 580 */ 113, 212, 113, 225, 168, 169, 146, 181, 144, 59, /* 590 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 600 */ 70, 71, 146, 73, 74, 75, 76, 77, 78, 79, /* 610 */ 80, 81, 82, 16, 146, 22, 187, 20, 190, 146, /* 620 */ 109, 146, 146, 146, 168, 169, 146, 191, 101, 146, /* 630 */ 146, 225, 146, 122, 198, 146, 168, 169, 129, 42, /* 640 */ 131, 168, 169, 168, 169, 168, 169, 207, 168, 169, /* 650 */ 154, 168, 169, 132, 168, 169, 59, 60, 61, 62, /* 660 */ 63, 64, 65, 66, 67, 68, 69, 70, 71, 146, /* 670 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, /* 680 */ 16, 146, 27, 207, 188, 21, 146, 154, 146, 34, /* 690 */ 146, 168, 169, 146, 20, 146, 22, 146, 98, 99, /* 700 */ 100, 200, 201, 168, 169, 112, 42, 16, 168, 169, /* 710 */ 168, 169, 168, 169, 146, 168, 169, 168, 169, 168, /* 720 */ 169, 188, 22, 59, 60, 61, 62, 63, 64, 65, /* 730 */ 66, 67, 68, 69, 70, 71, 146, 73, 74, 75, /* 740 */ 76, 77, 78, 79, 80, 81, 82, 16, 146, 146, /* 750 */ 146, 146, 146, 146, 146, 187, 146, 22, 168, 169, /* 760 */ 146, 98, 99, 100, 146, 106, 146, 123, 124, 110, /* 770 */ 168, 169, 160, 42, 168, 169, 168, 169, 168, 169, /* 780 */ 43, 90, 168, 169, 181, 181, 168, 169, 168, 169, /* 790 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 800 */ 69, 70, 71, 146, 73, 74, 75, 76, 77, 78, /* 810 */ 79, 80, 81, 82, 16, 146, 146, 146, 146, 146, /* 820 */ 120, 146, 87, 146, 202, 168, 169, 146, 225, 225, /* 830 */ 7, 8, 146, 20, 97, 22, 146, 168, 169, 146, /* 840 */ 42, 168, 169, 168, 169, 168, 169, 146, 113, 168, /* 850 */ 169, 181, 181, 146, 168, 169, 79, 59, 60, 61, /* 860 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 870 */ 146, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 880 */ 82, 16, 146, 106, 89, 90, 146, 110, 146, 20, /* 890 */ 146, 22, 168, 169, 146, 225, 225, 20, 20, 22, /* 900 */ 22, 51, 52, 154, 168, 169, 177, 42, 168, 169, /* 910 */ 168, 169, 168, 169, 146, 177, 168, 169, 146, 146, /* 920 */ 146, 146, 146, 19, 16, 60, 61, 62, 63, 64, /* 930 */ 65, 66, 67, 68, 69, 70, 71, 188, 73, 74, /* 940 */ 75, 76, 77, 78, 79, 80, 81, 82, 177, 20, /* 950 */ 42, 22, 146, 20, 20, 22, 22, 146, 20, 187, /* 960 */ 22, 187, 187, 187, 20, 20, 22, 22, 146, 61, /* 970 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 980 */ 19, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 990 */ 82, 16, 17, 187, 19, 146, 230, 146, 23, 146, /* 1000 */ 231, 146, 146, 146, 146, 146, 31, 16, 17, 146, /* 1010 */ 19, 171, 146, 146, 23, 111, 146, 146, 190, 192, /* 1020 */ 148, 227, 31, 48, 227, 222, 193, 193, 67, 6, /* 1030 */ 176, 171, 171, 58, 172, 171, 145, 145, 145, 48, /* 1040 */ 145, 22, 153, 97, 171, 170, 170, 40, 96, 58, /* 1050 */ 170, 170, 77, 78, 172, 120, 188, 178, 117, 119, /* 1060 */ 85, 86, 87, 221, 115, 90, 118, 193, 77, 78, /* 1070 */ 79, 129, 151, 111, 95, 23, 85, 86, 87, 16, /* 1080 */ 17, 90, 19, 195, 109, 159, 23, 197, 194, 97, /* 1090 */ 151, 114, 196, 210, 31, 210, 19, 173, 123, 124, /* 1100 */ 125, 126, 127, 128, 203, 178, 204, 204, 203, 210, /* 1110 */ 210, 48, 159, 170, 123, 124, 125, 126, 127, 128, /* 1120 */ 170, 58, 5, 15, 170, 151, 150, 10, 11, 12, /* 1130 */ 13, 173, 151, 151, 151, 19, 38, 129, 232, 23, /* 1140 */ 77, 78, 233, 26, 150, 28, 151, 59, 85, 86, /* 1150 */ 87, 183, 35, 90, 183, 19, 193, 15, 186, 186, /* 1160 */ 193, 214, 151, 183, 47, 214, 49, 33, 151, 151, /* 1170 */ 186, 54, 235, 56, 58, 136, 174, 174, 158, 1, /* 1180 */ 20, 32, 44, 19, 229, 111, 123, 124, 125, 126, /* 1190 */ 127, 128, 235, 77, 78, 111, 111, 238, 111, 19, /* 1200 */ 90, 20, 86, 20, 19, 106, 90, 11, 19, 22, /* 1210 */ 20, 20, 116, 116, 22, 98, 99, 100, 113, 22, /* 1220 */ 19, 104, 20, 111, 20, 19, 109, 20, 44, 19, /* 1230 */ 19, 19, 44, 94, 102, 16, 21, 17, 97, 123, /* 1240 */ 124, 125, 97, 45, 36, 22, 132, 19, 45, 5, /* 1250 */ 133, 1, 101, 67, 121, 19, 112, 17, 112, 101, /* 1260 */ 67, 121, 19, 14, 134, 20, 57, 3, 239, 4, /* 1270 */ 135, }; #define YY_SHIFT_USE_DFLT (-98) #define YY_SHIFT_MAX 369 static const short yy_shift_ofst[] = { /* 0 */ 137, 975, 1117, -16, 975, 1063, 1063, 1063, 49, -97, /* 10 */ 118, 1063, 1063, 1063, 1063, 1063, -45, 112, 131, 478, /* 20 */ 487, 200, 200, 51, 185, 252, 324, 396, 463, 530, /* 30 */ 597, 664, 731, 798, 731, 731, 731, 731, 731, 731, /* 40 */ 731, 731, 731, 731, 731, 731, 731, 731, 731, 731, /* 50 */ 731, 865, 908, 908, 991, 1063, 1063, 1063, 1063, 1063, /* 60 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 70 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 80 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 90 */ 1063, 1063, 1063, -60, -60, -14, 27, 27, 94, 85, /* 100 */ 394, 478, 478, 478, 478, 354, 478, 478, 478, 487, /* 110 */ -59, -98, -98, -98, 1116, 53, 325, 325, 291, 277, /* 120 */ 478, 277, 478, 478, 478, 478, 478, 478, 478, 478, /* 130 */ 478, 478, 478, 478, 478, 389, 511, -97, -97, -97, /* 140 */ -98, -98, 147, 147, 192, 262, 340, 430, 395, 401, /* 150 */ 195, 467, 469, 474, 472, 418, 427, 427, 777, 427, /* 160 */ 427, 73, 427, 427, 735, 427, 427, 461, 735, 427, /* 170 */ 427, 527, 527, 527, 427, 427, 461, 427, 427, 461, /* 180 */ 427, 538, 600, 427, 427, 461, 427, 427, 427, 461, /* 190 */ 427, 461, 461, 427, 427, 427, 427, 427, 427, 132, /* 200 */ 655, 659, 593, 644, 644, 509, 655, 655, 737, 655, /* 210 */ 655, 422, 700, 700, 1023, 1023, 1023, 1023, 1019, 946, /* 220 */ 946, 1007, 946, 952, 946, -97, 935, 941, 948, 949, /* 230 */ 940, 942, 962, 979, 1052, 979, 962, 992, 977, 992, /* 240 */ 977, 1077, 979, 979, 1052, 1007, 946, 946, 946, 1077, /* 250 */ 1108, 962, 962, 962, 962, 1098, 1008, 1108, 962, 1088, /* 260 */ 1088, 1136, 935, 1142, 1142, 1142, 935, 1088, 1136, 962, /* 270 */ 1134, 1134, 962, 962, 1039, -98, -98, -98, -98, 457, /* 280 */ 521, 663, 188, 306, 823, 904, 674, 691, 813, 869, /* 290 */ 877, 795, 878, 929, 933, 850, 934, 938, 944, 945, /* 300 */ 961, 1178, 1160, 1149, 1138, 1164, 1074, 1084, 1085, 1087, /* 310 */ 1180, 1181, 1183, 1110, 1099, 1185, 1196, 1189, 1190, 1187, /* 320 */ 1191, 1096, 1192, 1097, 1197, 1105, 1201, 1202, 1112, 1204, /* 330 */ 1184, 1206, 1207, 1210, 1211, 1188, 1212, 1139, 1132, 1219, /* 340 */ 1220, 1215, 1141, 1208, 1198, 1223, 1203, 1114, 1145, 1228, /* 350 */ 1244, 1250, 1151, 1186, 1193, 1133, 1236, 1144, 1240, 1146, /* 360 */ 1158, 1140, 1243, 1245, 1249, 1209, 1130, 1135, 1264, 1265, }; #define YY_REDUCE_USE_DFLT (-216) #define YY_REDUCE_MAX 278 static const short yy_reduce_ofst[] = { /* 0 */ -56, 136, 16, 70, 189, 128, 67, 133, 190, 15, /* 10 */ 6, 141, 261, 271, 267, 273, -178, 255, -140, -61, /* 20 */ 146, 259, 268, -215, -215, -215, -215, -215, -215, -215, /* 30 */ -215, -215, -215, -215, -215, -215, -215, -215, -215, -215, /* 40 */ -215, -215, -215, -215, -215, -215, -215, -215, -215, -215, /* 50 */ -215, -215, -215, -215, 402, 416, 456, 468, 473, 475, /* 60 */ 477, 480, 483, 486, 523, 535, 540, 542, 544, 547, /* 70 */ 549, 551, 590, 602, 606, 608, 610, 614, 618, 620, /* 80 */ 657, 669, 673, 675, 677, 681, 686, 724, 736, 740, /* 90 */ 742, 744, 748, -215, -215, -77, -215, -215, -215, -215, /* 100 */ -26, 406, 603, 604, 670, 124, 671, 44, 225, 78, /* 110 */ -215, -215, -215, -215, 208, 253, 157, 194, -72, 139, /* 120 */ 305, 215, 358, 265, 440, 222, 476, 429, 568, 772, /* 130 */ 774, 775, 776, 369, 806, 69, 333, 496, 533, 749, /* 140 */ 436, 501, -126, -112, -81, -12, 37, 227, 37, 37, /* 150 */ 233, 335, 361, 403, 432, 444, 484, 489, 428, 432, /* 160 */ 605, 612, 607, 672, 622, 690, 693, 37, 622, 701, /* 170 */ 707, 729, 738, 771, 768, 773, 37, 811, 822, 37, /* 180 */ 849, 766, 769, 851, 853, 37, 855, 856, 857, 37, /* 190 */ 858, 37, 37, 859, 863, 866, 867, 870, 871, 872, /* 200 */ 840, 828, 827, 794, 797, 803, 860, 861, 854, 864, /* 210 */ 873, 862, 833, 834, 891, 892, 893, 895, 889, 875, /* 220 */ 876, 879, 880, 882, 881, 868, 874, 894, 888, 896, /* 230 */ 890, 842, 921, 883, 926, 885, 939, 901, 902, 905, /* 240 */ 903, 924, 899, 900, 953, 927, 943, 950, 954, 958, /* 250 */ 976, 974, 981, 982, 983, 906, 909, 994, 995, 968, /* 260 */ 971, 947, 963, 972, 973, 984, 967, 980, 951, 1011, /* 270 */ 937, 957, 1017, 1018, 959, 1020, 1002, 1003, 955, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 565, 789, 854, 680, 854, 789, 854, 789, 854, 684, /* 10 */ 840, 785, 789, 854, 854, 854, 760, 854, 811, 854, /* 20 */ 596, 811, 811, 715, 854, 854, 854, 854, 854, 854, /* 30 */ 854, 854, 716, 854, 788, 784, 780, 782, 781, 717, /* 40 */ 704, 713, 720, 696, 825, 722, 723, 728, 729, 841, /* 50 */ 844, 750, 766, 749, 854, 854, 854, 854, 854, 854, /* 60 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 70 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 80 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 90 */ 854, 854, 854, 752, 771, 589, 751, 759, 753, 754, /* 100 */ 649, 854, 854, 854, 854, 584, 854, 854, 854, 854, /* 110 */ 755, 756, 767, 768, 854, 854, 854, 854, 565, 680, /* 120 */ 854, 680, 854, 854, 854, 854, 854, 854, 854, 854, /* 130 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 140 */ 674, 684, 854, 854, 640, 854, 854, 854, 854, 854, /* 150 */ 854, 854, 854, 854, 854, 572, 570, 854, 672, 854, /* 160 */ 854, 598, 854, 854, 682, 854, 854, 687, 688, 854, /* 170 */ 854, 854, 854, 854, 854, 854, 586, 854, 854, 661, /* 180 */ 854, 817, 854, 854, 854, 832, 854, 854, 854, 830, /* 190 */ 854, 663, 725, 799, 854, 854, 845, 847, 854, 854, /* 200 */ 707, 672, 681, 854, 854, 783, 707, 707, 619, 707, /* 210 */ 707, 622, 719, 719, 569, 569, 569, 569, 639, 651, /* 220 */ 651, 636, 651, 622, 651, 854, 719, 710, 712, 700, /* 230 */ 714, 854, 689, 708, 854, 708, 689, 697, 699, 697, /* 240 */ 699, 793, 708, 708, 854, 636, 651, 651, 651, 793, /* 250 */ 581, 689, 689, 689, 689, 821, 824, 581, 689, 653, /* 260 */ 653, 730, 719, 660, 660, 660, 719, 653, 730, 689, /* 270 */ 843, 843, 689, 689, 852, 606, 624, 624, 827, 854, /* 280 */ 854, 854, 854, 854, 854, 737, 854, 854, 854, 854, /* 290 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 300 */ 806, 854, 854, 854, 854, 854, 742, 738, 854, 739, /* 310 */ 854, 854, 854, 854, 666, 854, 854, 854, 854, 854, /* 320 */ 854, 854, 701, 854, 711, 854, 854, 854, 854, 854, /* 330 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 340 */ 854, 854, 854, 854, 819, 820, 854, 854, 854, 854, /* 350 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, /* 360 */ 854, 854, 854, 854, 854, 851, 854, 854, 566, 854, /* 370 */ 560, 563, 562, 564, 568, 571, 593, 594, 595, 573, /* 380 */ 574, 575, 576, 577, 578, 579, 585, 587, 605, 607, /* 390 */ 614, 652, 655, 656, 657, 835, 836, 837, 615, 634, /* 400 */ 637, 638, 616, 623, 705, 706, 617, 670, 671, 734, /* 410 */ 664, 665, 669, 736, 740, 741, 743, 744, 592, 599, /* 420 */ 600, 603, 604, 807, 809, 808, 810, 602, 601, 745, /* 430 */ 748, 757, 758, 764, 770, 773, 762, 763, 765, 769, /* 440 */ 772, 667, 668, 776, 778, 779, 833, 834, 774, 786, /* 450 */ 787, 690, 777, 761, 702, 591, 709, 703, 673, 683, /* 460 */ 692, 693, 694, 695, 678, 679, 685, 698, 732, 733, /* 470 */ 686, 675, 676, 677, 775, 735, 746, 747, 618, 625, /* 480 */ 626, 627, 630, 631, 632, 633, 628, 629, 794, 795, /* 490 */ 797, 796, 620, 621, 635, 608, 609, 610, 611, 742, /* 500 */ 612, 613, 597, 590, 641, 644, 645, 646, 647, 648, /* 510 */ 650, 642, 643, 588, 580, 582, 691, 813, 822, 823, /* 520 */ 818, 814, 815, 816, 583, 790, 791, 654, 726, 727, /* 530 */ 812, 826, 828, 731, 829, 831, 658, 659, 662, 798, /* 540 */ 838, 718, 721, 724, 800, 801, 802, 803, 804, 805, /* 550 */ 839, 842, 846, 848, 849, 850, 853, 567, 561, }; #define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0])) /* The next table maps tokens into fallback tokens. If a construct ** like the following: ** ** %fallback ID X Y Z. ................................................................................ /* 260 */ "trigger_event ::= UPDATE", /* 261 */ "trigger_event ::= UPDATE OF inscollist", /* 262 */ "foreach_clause ::=", /* 263 */ "foreach_clause ::= FOR EACH ROW", /* 264 */ "foreach_clause ::= FOR EACH STATEMENT", /* 265 */ "when_clause ::=", /* 266 */ "when_clause ::= WHEN expr", /* 267 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", /* 268 */ "trigger_cmd_list ::=", /* 269 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt", /* 270 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP", /* 271 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select", /* 272 */ "trigger_cmd ::= DELETE FROM nm where_opt", /* 273 */ "trigger_cmd ::= select", /* 274 */ "expr ::= RAISE LP IGNORE RP", ................................................................................ ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 154: case 188: case 205: #line 371 "parse.y" {sqlite3SelectDelete((yypminor->yy239));} #line 1215 "parse.c" break; case 168: case 169: case 193: case 195: case 203: case 209: case 217: case 220: case 222: case 223: case 233: #line 628 "parse.y" {sqlite3ExprDelete((yypminor->yy178));} #line 1230 "parse.c" break; case 173: case 181: case 191: case 194: case 196: case 198: case 208: case 211: case 212: case 215: case 221: #line 859 "parse.y" {sqlite3ExprListDelete((yypminor->yy462));} #line 1245 "parse.c" break; case 187: case 192: case 200: case 201: #line 499 "parse.y" {sqlite3SrcListDelete((yypminor->yy285));} #line 1253 "parse.c" break; case 197: #line 560 "parse.y" { sqlite3ExprDelete((yypminor->yy270).pLimit); sqlite3ExprDelete((yypminor->yy270).pOffset); } #line 1261 "parse.c" break; case 204: case 207: case 214: #line 516 "parse.y" {sqlite3IdListDelete((yypminor->yy160));} #line 1268 "parse.c" break; case 229: case 234: #line 953 "parse.y" {sqlite3DeleteTriggerStep((yypminor->yy247));} #line 1274 "parse.c" break; case 231: #line 937 "parse.y" {sqlite3IdListDelete((yypminor->yy132).b);} #line 1279 "parse.c" break; case 236: #line 1021 "parse.y" {sqlite3ExprDelete((yypminor->yy292));} #line 1284 "parse.c" break; default: break; /* If no destructor action specified: do nothing */ } } /* ** Pop the parser's stack once. ................................................................................ if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ #line 43 "parse.y" sqlite3ErrorMsg(pParse, "parser stack overflow"); #line 1436 "parse.c" sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ return; } yytos = &yypParser->yystack[yypParser->yyidx]; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor = *yypMinor; ................................................................................ ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 3: #line 98 "parse.y" { sqlite3FinishCoding(pParse); } #line 1809 "parse.c" break; case 6: #line 101 "parse.y" { sqlite3BeginParse(pParse, 0); } #line 1814 "parse.c" break; case 7: #line 103 "parse.y" { sqlite3BeginParse(pParse, 1); } #line 1819 "parse.c" break; case 8: #line 104 "parse.y" { sqlite3BeginParse(pParse, 2); } #line 1824 "parse.c" break; case 9: #line 110 "parse.y" {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy230);} #line 1829 "parse.c" break; case 13: #line 115 "parse.y" {yygotominor.yy230 = TK_DEFERRED;} #line 1834 "parse.c" break; case 14: case 15: case 16: case 107: case 109: #line 116 "parse.y" {yygotominor.yy230 = yymsp[0].major;} #line 1843 "parse.c" break; case 17: case 18: #line 119 "parse.y" {sqlite3CommitTransaction(pParse);} #line 1849 "parse.c" break; case 19: #line 121 "parse.y" {sqlite3RollbackTransaction(pParse);} #line 1854 "parse.c" break; case 21: #line 126 "parse.y" { sqlite3StartTable(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,yymsp[-4].minor.yy230,0,yymsp[-2].minor.yy230); } #line 1861 "parse.c" break; case 22: case 25: case 63: case 77: case 79: case 90: case 101: case 112: case 113: case 210: case 213: #line 130 "parse.y" {yygotominor.yy230 = 0;} #line 1876 "parse.c" break; case 23: case 24: case 64: case 78: case 100: case 111: case 211: case 214: #line 131 "parse.y" {yygotominor.yy230 = 1;} #line 1888 "parse.c" break; case 26: #line 137 "parse.y" { sqlite3EndTable(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy0,0); } #line 1895 "parse.c" break; case 27: #line 140 "parse.y" { sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy239); sqlite3SelectDelete(yymsp[0].minor.yy239); } #line 1903 "parse.c" break; case 30: #line 152 "parse.y" { yygotominor.yy384.z = yymsp[-2].minor.yy384.z; yygotominor.yy384.n = (pParse->sLastToken.z-yymsp[-2].minor.yy384.z) + pParse->sLastToken.n; } #line 1911 "parse.c" break; case 31: #line 156 "parse.y" { sqlite3AddColumn(pParse,&yymsp[0].minor.yy384); yygotominor.yy384 = yymsp[0].minor.yy384; } #line 1919 "parse.c" break; case 32: case 33: case 34: case 35: case 36: case 250: #line 166 "parse.y" {yygotominor.yy384 = yymsp[0].minor.yy0;} #line 1929 "parse.c" break; case 38: #line 225 "parse.y" {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy384);} #line 1934 "parse.c" break; case 39: case 42: case 119: case 120: case 131: case 150: case 238: case 248: case 249: #line 226 "parse.y" {yygotominor.yy384 = yymsp[0].minor.yy384;} #line 1947 "parse.c" break; case 40: #line 227 "parse.y" { yygotominor.yy384.z = yymsp[-3].minor.yy384.z; yygotominor.yy384.n = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy384.z; } #line 1955 "parse.c" break; case 41: #line 231 "parse.y" { yygotominor.yy384.z = yymsp[-5].minor.yy384.z; yygotominor.yy384.n = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy384.z; } #line 1963 "parse.c" break; case 43: #line 237 "parse.y" {yygotominor.yy384.z=yymsp[-1].minor.yy384.z; yygotominor.yy384.n=yymsp[0].minor.yy384.n+(yymsp[0].minor.yy384.z-yymsp[-1].minor.yy384.z);} #line 1968 "parse.c" break; case 44: #line 239 "parse.y" { yygotominor.yy230 = atoi((char*)yymsp[0].minor.yy384.z); } #line 1973 "parse.c" break; case 45: #line 240 "parse.y" { yygotominor.yy230 = -atoi((char*)yymsp[0].minor.yy384.z); } #line 1978 "parse.c" break; case 50: case 52: #line 249 "parse.y" {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy178);} #line 1984 "parse.c" break; case 51: #line 250 "parse.y" {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy178);} #line 1989 "parse.c" break; case 53: #line 252 "parse.y" { Expr *p = sqlite3Expr(TK_UMINUS, yymsp[0].minor.yy178, 0, 0); sqlite3AddDefaultValue(pParse,p); } #line 1997 "parse.c" break; case 54: #line 256 "parse.y" { Expr *p = sqlite3Expr(TK_STRING, 0, 0, &yymsp[0].minor.yy384); sqlite3AddDefaultValue(pParse,p); } #line 2005 "parse.c" break; case 56: #line 265 "parse.y" {sqlite3AddNotNull(pParse, yymsp[0].minor.yy230);} #line 2010 "parse.c" break; case 57: #line 267 "parse.y" {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy230,yymsp[0].minor.yy230,yymsp[-2].minor.yy230);} #line 2015 "parse.c" break; case 58: #line 268 "parse.y" {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy230,0,0,0,0);} #line 2020 "parse.c" break; case 59: #line 269 "parse.y" {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy178);} #line 2025 "parse.c" break; case 60: #line 271 "parse.y" {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy384,yymsp[-1].minor.yy462,yymsp[0].minor.yy230);} #line 2030 "parse.c" break; case 61: #line 272 "parse.y" {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy230);} #line 2035 "parse.c" break; case 62: #line 273 "parse.y" {sqlite3AddCollateType(pParse, (char*)yymsp[0].minor.yy384.z, yymsp[0].minor.yy384.n);} #line 2040 "parse.c" break; case 65: #line 286 "parse.y" { yygotominor.yy230 = OE_Restrict * 0x010101; } #line 2045 "parse.c" break; case 66: #line 287 "parse.y" { yygotominor.yy230 = (yymsp[-1].minor.yy230 & yymsp[0].minor.yy13.mask) | yymsp[0].minor.yy13.value; } #line 2050 "parse.c" break; case 67: #line 289 "parse.y" { yygotominor.yy13.value = 0; yygotominor.yy13.mask = 0x000000; } #line 2055 "parse.c" break; case 68: #line 290 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230; yygotominor.yy13.mask = 0x0000ff; } #line 2060 "parse.c" break; case 69: #line 291 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230<<8; yygotominor.yy13.mask = 0x00ff00; } #line 2065 "parse.c" break; case 70: #line 292 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230<<16; yygotominor.yy13.mask = 0xff0000; } #line 2070 "parse.c" break; case 71: #line 294 "parse.y" { yygotominor.yy230 = OE_SetNull; } #line 2075 "parse.c" break; case 72: #line 295 "parse.y" { yygotominor.yy230 = OE_SetDflt; } #line 2080 "parse.c" break; case 73: #line 296 "parse.y" { yygotominor.yy230 = OE_Cascade; } #line 2085 "parse.c" break; case 74: #line 297 "parse.y" { yygotominor.yy230 = OE_Restrict; } #line 2090 "parse.c" break; case 75: case 76: case 91: case 93: case 95: case 96: case 167: #line 299 "parse.y" {yygotominor.yy230 = yymsp[0].minor.yy230;} #line 2101 "parse.c" break; case 80: #line 309 "parse.y" {yygotominor.yy384.n = 0; yygotominor.yy384.z = 0;} #line 2106 "parse.c" break; case 81: #line 310 "parse.y" {yygotominor.yy384 = yymsp[-1].minor.yy0;} #line 2111 "parse.c" break; case 86: #line 316 "parse.y" {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy462,yymsp[0].minor.yy230,yymsp[-2].minor.yy230,0);} #line 2116 "parse.c" break; case 87: #line 318 "parse.y" {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy462,yymsp[0].minor.yy230,0,0,0,0);} #line 2121 "parse.c" break; case 88: #line 319 "parse.y" {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy178);} #line 2126 "parse.c" break; case 89: #line 321 "parse.y" { sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy462, &yymsp[-3].minor.yy384, yymsp[-2].minor.yy462, yymsp[-1].minor.yy230); sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy230); } #line 2134 "parse.c" break; case 92: case 94: #line 335 "parse.y" {yygotominor.yy230 = OE_Default;} #line 2140 "parse.c" break; case 97: #line 340 "parse.y" {yygotominor.yy230 = OE_Ignore;} #line 2145 "parse.c" break; case 98: case 168: #line 341 "parse.y" {yygotominor.yy230 = OE_Replace;} #line 2151 "parse.c" break; case 99: #line 345 "parse.y" { sqlite3DropTable(pParse, yymsp[0].minor.yy285, 0, yymsp[-1].minor.yy230); } #line 2158 "parse.c" break; case 102: #line 355 "parse.y" { sqlite3CreateView(pParse, &yymsp[-6].minor.yy0, &yymsp[-3].minor.yy384, &yymsp[-2].minor.yy384, yymsp[0].minor.yy239, yymsp[-5].minor.yy230); } #line 2165 "parse.c" break; case 103: #line 358 "parse.y" { sqlite3DropTable(pParse, yymsp[0].minor.yy285, 1, yymsp[-1].minor.yy230); } #line 2172 "parse.c" break; case 104: #line 365 "parse.y" { sqlite3Select(pParse, yymsp[0].minor.yy239, SRT_Callback, 0, 0, 0, 0, 0); sqlite3SelectDelete(yymsp[0].minor.yy239); } #line 2180 "parse.c" break; case 105: case 128: #line 375 "parse.y" {yygotominor.yy239 = yymsp[0].minor.yy239;} #line 2186 "parse.c" break; case 106: #line 377 "parse.y" { if( yymsp[0].minor.yy239 ){ yymsp[0].minor.yy239->op = yymsp[-1].minor.yy230; yymsp[0].minor.yy239->pPrior = yymsp[-2].minor.yy239; } yygotominor.yy239 = yymsp[0].minor.yy239; } #line 2197 "parse.c" break; case 108: #line 386 "parse.y" {yygotominor.yy230 = TK_ALL;} #line 2202 "parse.c" break; case 110: #line 390 "parse.y" { yygotominor.yy239 = sqlite3SelectNew(yymsp[-6].minor.yy462,yymsp[-5].minor.yy285,yymsp[-4].minor.yy178,yymsp[-3].minor.yy462,yymsp[-2].minor.yy178,yymsp[-1].minor.yy462,yymsp[-7].minor.yy230,yymsp[0].minor.yy270.pLimit,yymsp[0].minor.yy270.pOffset); } #line 2209 "parse.c" break; case 114: case 235: #line 411 "parse.y" {yygotominor.yy462 = yymsp[-1].minor.yy462;} #line 2215 "parse.c" break; case 115: case 141: case 151: case 234: #line 412 "parse.y" {yygotominor.yy462 = 0;} #line 2223 "parse.c" break; case 116: #line 413 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-2].minor.yy462,yymsp[-1].minor.yy178,yymsp[0].minor.yy384.n?&yymsp[0].minor.yy384:0); } #line 2230 "parse.c" break; case 117: #line 416 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-1].minor.yy462, sqlite3Expr(TK_ALL, 0, 0, 0), 0); } #line 2237 "parse.c" break; case 118: #line 419 "parse.y" { Expr *pRight = sqlite3Expr(TK_ALL, 0, 0, 0); Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-3].minor.yy462, sqlite3Expr(TK_DOT, pLeft, pRight, 0), 0); } #line 2246 "parse.c" break; case 121: #line 431 "parse.y" {yygotominor.yy384.n = 0;} #line 2251 "parse.c" break; case 122: #line 443 "parse.y" {yygotominor.yy285 = sqliteMalloc(sizeof(*yygotominor.yy285));} #line 2256 "parse.c" break; case 123: #line 444 "parse.y" {yygotominor.yy285 = yymsp[0].minor.yy285;} #line 2261 "parse.c" break; case 124: #line 449 "parse.y" { yygotominor.yy285 = yymsp[-1].minor.yy285; if( yygotominor.yy285 && yygotominor.yy285->nSrc>0 ) yygotominor.yy285->a[yygotominor.yy285->nSrc-1].jointype = yymsp[0].minor.yy230; } #line 2269 "parse.c" break; case 125: #line 453 "parse.y" {yygotominor.yy285 = 0;} #line 2274 "parse.c" break; case 126: #line 454 "parse.y" { yygotominor.yy285 = sqlite3SrcListAppend(yymsp[-5].minor.yy285,&yymsp[-4].minor.yy384,&yymsp[-3].minor.yy384); if( yymsp[-2].minor.yy384.n ) sqlite3SrcListAddAlias(yygotominor.yy285,&yymsp[-2].minor.yy384); if( yymsp[-1].minor.yy178 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pOn = yymsp[-1].minor.yy178; } else { sqlite3ExprDelete(yymsp[-1].minor.yy178); } } if( yymsp[0].minor.yy160 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pUsing = yymsp[0].minor.yy160; } else { sqlite3IdListDelete(yymsp[0].minor.yy160); } } } #line 2290 "parse.c" break; case 127: #line 468 "parse.y" { yygotominor.yy285 = sqlite3SrcListAppend(yymsp[-6].minor.yy285,0,0); yygotominor.yy285->a[yygotominor.yy285->nSrc-1].pSelect = yymsp[-4].minor.yy239; if( yymsp[-2].minor.yy384.n ) sqlite3SrcListAddAlias(yygotominor.yy285,&yymsp[-2].minor.yy384); if( yymsp[-1].minor.yy178 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pOn = yymsp[-1].minor.yy178; } else { sqlite3ExprDelete(yymsp[-1].minor.yy178); } } if( yymsp[0].minor.yy160 ){ if( yygotominor.yy285 && yygotominor.yy285->nSrc>1 ){ yygotominor.yy285->a[yygotominor.yy285->nSrc-2].pUsing = yymsp[0].minor.yy160; } else { sqlite3IdListDelete(yymsp[0].minor.yy160); } } } #line 2307 "parse.c" break; case 129: #line 489 "parse.y" { yygotominor.yy239 = sqlite3SelectNew(0,yymsp[0].minor.yy285,0,0,0,0,0,0,0); } #line 2314 "parse.c" break; case 130: #line 495 "parse.y" {yygotominor.yy384.z=0; yygotominor.yy384.n=0;} #line 2319 "parse.c" break; case 132: #line 500 "parse.y" {yygotominor.yy285 = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384);} #line 2324 "parse.c" break; case 133: #line 504 "parse.y" { yygotominor.yy230 = JT_INNER; } #line 2329 "parse.c" break; case 134: #line 505 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } #line 2334 "parse.c" break; case 135: #line 506 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy384,0); } #line 2339 "parse.c" break; case 136: #line 508 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy384,&yymsp[-1].minor.yy384); } #line 2344 "parse.c" break; case 137: case 145: case 154: case 161: case 175: case 200: case 223: case 225: case 229: #line 512 "parse.y" {yygotominor.yy178 = yymsp[0].minor.yy178;} #line 2357 "parse.c" break; case 138: case 153: case 160: case 201: case 224: case 226: case 230: #line 513 "parse.y" {yygotominor.yy178 = 0;} #line 2368 "parse.c" break; case 139: case 172: #line 517 "parse.y" {yygotominor.yy160 = yymsp[-1].minor.yy160;} #line 2374 "parse.c" break; case 140: case 171: #line 518 "parse.y" {yygotominor.yy160 = 0;} #line 2380 "parse.c" break; case 142: case 152: #line 529 "parse.y" {yygotominor.yy462 = yymsp[0].minor.yy462;} #line 2386 "parse.c" break; case 143: #line 530 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462,yymsp[-2].minor.yy178,yymsp[-1].minor.yy384.n>0?&yymsp[-1].minor.yy384:0); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } #line 2394 "parse.c" break; case 144: #line 534 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[-2].minor.yy178,yymsp[-1].minor.yy384.n>0?&yymsp[-1].minor.yy384:0); if( yygotominor.yy462 && yygotominor.yy462->a ) yygotominor.yy462->a[0].sortOrder = yymsp[0].minor.yy230; } #line 2402 "parse.c" break; case 146: case 148: #line 543 "parse.y" {yygotominor.yy230 = SQLITE_SO_ASC;} #line 2408 "parse.c" break; case 147: #line 544 "parse.y" {yygotominor.yy230 = SQLITE_SO_DESC;} #line 2413 "parse.c" break; case 149: #line 546 "parse.y" {yygotominor.yy384.z = 0; yygotominor.yy384.n = 0;} #line 2418 "parse.c" break; case 155: #line 564 "parse.y" {yygotominor.yy270.pLimit = 0; yygotominor.yy270.pOffset = 0;} #line 2423 "parse.c" break; case 156: #line 565 "parse.y" {yygotominor.yy270.pLimit = yymsp[0].minor.yy178; yygotominor.yy270.pOffset = 0;} #line 2428 "parse.c" break; case 157: #line 567 "parse.y" {yygotominor.yy270.pLimit = yymsp[-2].minor.yy178; yygotominor.yy270.pOffset = yymsp[0].minor.yy178;} #line 2433 "parse.c" break; case 158: #line 569 "parse.y" {yygotominor.yy270.pOffset = yymsp[-2].minor.yy178; yygotominor.yy270.pLimit = yymsp[0].minor.yy178;} #line 2438 "parse.c" break; case 159: #line 573 "parse.y" {sqlite3DeleteFrom(pParse,yymsp[-1].minor.yy285,yymsp[0].minor.yy178);} #line 2443 "parse.c" break; case 162: #line 584 "parse.y" {sqlite3Update(pParse,yymsp[-3].minor.yy285,yymsp[-1].minor.yy462,yymsp[0].minor.yy178,yymsp[-4].minor.yy230);} #line 2448 "parse.c" break; case 163: #line 590 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462,yymsp[0].minor.yy178,&yymsp[-2].minor.yy384);} #line 2453 "parse.c" break; case 164: #line 591 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[0].minor.yy178,&yymsp[-2].minor.yy384);} #line 2458 "parse.c" break; case 165: #line 597 "parse.y" {sqlite3Insert(pParse, yymsp[-5].minor.yy285, yymsp[-1].minor.yy462, 0, yymsp[-4].minor.yy160, yymsp[-7].minor.yy230);} #line 2463 "parse.c" break; case 166: #line 599 "parse.y" {sqlite3Insert(pParse, yymsp[-2].minor.yy285, 0, yymsp[0].minor.yy239, yymsp[-1].minor.yy160, yymsp[-4].minor.yy230);} #line 2468 "parse.c" break; case 169: case 227: #line 609 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-2].minor.yy462,yymsp[0].minor.yy178,0);} #line 2474 "parse.c" break; case 170: case 228: #line 610 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[0].minor.yy178,0);} #line 2480 "parse.c" break; case 173: #line 619 "parse.y" {yygotominor.yy160 = sqlite3IdListAppend(yymsp[-2].minor.yy160,&yymsp[0].minor.yy384);} #line 2485 "parse.c" break; case 174: #line 620 "parse.y" {yygotominor.yy160 = sqlite3IdListAppend(0,&yymsp[0].minor.yy384);} #line 2490 "parse.c" break; case 176: #line 631 "parse.y" {yygotominor.yy178 = yymsp[-1].minor.yy178; sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } #line 2495 "parse.c" break; case 177: case 182: case 183: #line 632 "parse.y" {yygotominor.yy178 = sqlite3Expr(yymsp[0].major, 0, 0, &yymsp[0].minor.yy0);} #line 2502 "parse.c" break; case 178: case 179: #line 633 "parse.y" {yygotominor.yy178 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} #line 2508 "parse.c" break; case 180: #line 635 "parse.y" { Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy384); yygotominor.yy178 = sqlite3Expr(TK_DOT, temp1, temp2, 0); } #line 2517 "parse.c" break; case 181: #line 640 "parse.y" { Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-4].minor.yy384); Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); Expr *temp3 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy384); Expr *temp4 = sqlite3Expr(TK_DOT, temp2, temp3, 0); yygotominor.yy178 = sqlite3Expr(TK_DOT, temp1, temp4, 0); } #line 2528 "parse.c" break; case 184: #line 649 "parse.y" {yygotominor.yy178 = sqlite3RegisterExpr(pParse, &yymsp[0].minor.yy0);} #line 2533 "parse.c" break; case 185: #line 650 "parse.y" { Token *pToken = &yymsp[0].minor.yy0; Expr *pExpr = yygotominor.yy178 = sqlite3Expr(TK_VARIABLE, 0, 0, pToken); sqlite3ExprAssignVarNumber(pParse, pExpr); } #line 2542 "parse.c" break; case 186: #line 656 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_CAST, yymsp[-3].minor.yy178, 0, &yymsp[-1].minor.yy384); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); } #line 2550 "parse.c" break; case 187: #line 661 "parse.y" { yygotominor.yy178 = sqlite3ExprFunction(yymsp[-1].minor.yy462, &yymsp[-4].minor.yy0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); if( yymsp[-2].minor.yy230 && yygotominor.yy178 ){ yygotominor.yy178->flags |= EP_Distinct; } } #line 2561 "parse.c" break; case 188: #line 668 "parse.y" { yygotominor.yy178 = sqlite3ExprFunction(0, &yymsp[-3].minor.yy0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); } #line 2569 "parse.c" break; case 189: #line 672 "parse.y" { /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are ** treated as functions that return constants */ yygotominor.yy178 = sqlite3ExprFunction(0,&yymsp[0].minor.yy0); if( yygotominor.yy178 ) yygotominor.yy178->op = TK_CONST_FUNC; } #line 2579 "parse.c" break; case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: #line 678 "parse.y" {yygotominor.yy178 = sqlite3Expr(yymsp[-1].major, yymsp[-2].minor.yy178, yymsp[0].minor.yy178, 0);} #line 2591 "parse.c" break; case 198: #line 688 "parse.y" {yygotominor.yy440.eOperator = yymsp[0].minor.yy0; yygotominor.yy440.not = 0;} #line 2596 "parse.c" break; case 199: #line 689 "parse.y" {yygotominor.yy440.eOperator = yymsp[0].minor.yy0; yygotominor.yy440.not = 1;} #line 2601 "parse.c" break; case 202: #line 694 "parse.y" { ExprList *pList; pList = sqlite3ExprListAppend(0, yymsp[-1].minor.yy178, 0); pList = sqlite3ExprListAppend(pList, yymsp[-3].minor.yy178, 0); if( yymsp[0].minor.yy178 ){ pList = sqlite3ExprListAppend(pList, yymsp[0].minor.yy178, 0); } yygotominor.yy178 = sqlite3ExprFunction(pList, &yymsp[-2].minor.yy440.eOperator); if( yymsp[-2].minor.yy440.not ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy178->span, &yymsp[-1].minor.yy178->span); } #line 2616 "parse.c" break; case 203: #line 706 "parse.y" { yygotominor.yy178 = sqlite3Expr(yymsp[0].major, yymsp[-1].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2624 "parse.c" break; case 204: #line 710 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_ISNULL, yymsp[-2].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2632 "parse.c" break; case 205: #line 714 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_NOTNULL, yymsp[-2].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2640 "parse.c" break; case 206: #line 718 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_NOTNULL, yymsp[-3].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2648 "parse.c" break; case 207: #line 722 "parse.y" { yygotominor.yy178 = sqlite3Expr(yymsp[-1].major, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } #line 2656 "parse.c" break; case 208: #line 726 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_UMINUS, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } #line 2664 "parse.c" break; case 209: #line 730 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_UPLUS, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } #line 2672 "parse.c" break; case 212: #line 737 "parse.y" { ExprList *pList = sqlite3ExprListAppend(0, yymsp[-2].minor.yy178, 0); pList = sqlite3ExprListAppend(pList, yymsp[0].minor.yy178, 0); yygotominor.yy178 = sqlite3Expr(TK_BETWEEN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pList = pList; }else{ sqlite3ExprListDelete(pList); } if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy178->span); } #line 2688 "parse.c" break; case 215: #line 753 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pList = yymsp[-1].minor.yy462; }else{ sqlite3ExprListDelete(yymsp[-1].minor.yy462); } if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2702 "parse.c" break; case 216: #line 763 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_SELECT, 0, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pSelect = yymsp[-1].minor.yy239; }else{ sqlite3SelectDelete(yymsp[-1].minor.yy239); } sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } #line 2715 "parse.c" break; case 217: #line 772 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pSelect = yymsp[-1].minor.yy239; }else{ sqlite3SelectDelete(yymsp[-1].minor.yy239); } if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy0); } #line 2729 "parse.c" break; case 218: #line 782 "parse.y" { SrcList *pSrc = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384); yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-3].minor.yy178, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,0,0); }else{ sqlite3SrcListDelete(pSrc); } if( yymsp[-2].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy178->span,yymsp[0].minor.yy384.z?&yymsp[0].minor.yy384:&yymsp[-1].minor.yy384); } #line 2744 "parse.c" break; case 219: #line 793 "parse.y" { Expr *p = yygotominor.yy178 = sqlite3Expr(TK_EXISTS, 0, 0, 0); if( p ){ p->pSelect = yymsp[-1].minor.yy239; sqlite3ExprSpan(p,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); }else{ sqlite3SelectDelete(yymsp[-1].minor.yy239); } } #line 2757 "parse.c" break; case 220: #line 805 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_CASE, yymsp[-3].minor.yy178, yymsp[-1].minor.yy178, 0); if( yygotominor.yy178 ){ yygotominor.yy178->pList = yymsp[-2].minor.yy462; }else{ sqlite3ExprListDelete(yymsp[-2].minor.yy462); } sqlite3ExprSpan(yygotominor.yy178, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0); } #line 2770 "parse.c" break; case 221: #line 816 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462, yymsp[-2].minor.yy178, 0); yygotominor.yy462 = sqlite3ExprListAppend(yygotominor.yy462, yymsp[0].minor.yy178, 0); } #line 2778 "parse.c" break; case 222: #line 820 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(0, yymsp[-2].minor.yy178, 0); yygotominor.yy462 = sqlite3ExprListAppend(yygotominor.yy462, yymsp[0].minor.yy178, 0); } #line 2786 "parse.c" break; case 231: #line 847 "parse.y" { sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy384, &yymsp[-5].minor.yy384, sqlite3SrcListAppend(0,&yymsp[-3].minor.yy384,0), yymsp[-1].minor.yy462, yymsp[-9].minor.yy230, &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy230); } #line 2794 "parse.c" break; case 232: case 277: #line 853 "parse.y" {yygotominor.yy230 = OE_Abort;} #line 2800 "parse.c" break; case 233: #line 854 "parse.y" {yygotominor.yy230 = OE_None;} #line 2805 "parse.c" break; case 236: #line 864 "parse.y" { Expr *p = 0; if( yymsp[-1].minor.yy384.n>0 ){ p = sqlite3Expr(TK_COLUMN, 0, 0, 0); if( p ) p->pColl = sqlite3LocateCollSeq(pParse, (char*)yymsp[-1].minor.yy384.z, yymsp[-1].minor.yy384.n); } yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462, p, &yymsp[-2].minor.yy384); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } #line 2818 "parse.c" break; case 237: #line 873 "parse.y" { Expr *p = 0; if( yymsp[-1].minor.yy384.n>0 ){ p = sqlite3Expr(TK_COLUMN, 0, 0, 0); if( p ) p->pColl = sqlite3LocateCollSeq(pParse, (char*)yymsp[-1].minor.yy384.z, yymsp[-1].minor.yy384.n); } yygotominor.yy462 = sqlite3ExprListAppend(0, p, &yymsp[-2].minor.yy384); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } #line 2831 "parse.c" break; case 239: #line 887 "parse.y" {sqlite3DropIndex(pParse, yymsp[0].minor.yy285, yymsp[-1].minor.yy230);} #line 2836 "parse.c" break; case 240: case 241: #line 891 "parse.y" {sqlite3Vacuum(pParse);} #line 2842 "parse.c" break; case 242: case 244: #line 897 "parse.y" {sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy384,0);} #line 2848 "parse.c" break; case 243: #line 898 "parse.y" {sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy0,0);} #line 2853 "parse.c" break; case 245: #line 900 "parse.y" { sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy384,1); } #line 2860 "parse.c" break; case 246: #line 903 "parse.y" {sqlite3Pragma(pParse,&yymsp[-4].minor.yy384,&yymsp[-3].minor.yy384,&yymsp[-1].minor.yy384,0);} #line 2865 "parse.c" break; case 247: #line 904 "parse.y" {sqlite3Pragma(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,0,0);} #line 2870 "parse.c" break; case 253: #line 916 "parse.y" { Token all; all.z = yymsp[-3].minor.yy384.z; all.n = (yymsp[0].minor.yy0.z - yymsp[-3].minor.yy384.z) + yymsp[0].minor.yy0.n; sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy247, &all); } #line 2880 "parse.c" break; case 254: #line 925 "parse.y" { sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy384, &yymsp[-6].minor.yy384, yymsp[-5].minor.yy230, yymsp[-4].minor.yy132.a, yymsp[-4].minor.yy132.b, yymsp[-2].minor.yy285, yymsp[-1].minor.yy230, yymsp[0].minor.yy178, yymsp[-9].minor.yy230); yygotominor.yy384 = (yymsp[-6].minor.yy384.n==0?yymsp[-7].minor.yy384:yymsp[-6].minor.yy384); } #line 2888 "parse.c" break; case 255: case 258: #line 931 "parse.y" { yygotominor.yy230 = TK_BEFORE; } #line 2894 "parse.c" break; case 256: #line 932 "parse.y" { yygotominor.yy230 = TK_AFTER; } #line 2899 "parse.c" break; case 257: #line 933 "parse.y" { yygotominor.yy230 = TK_INSTEAD;} #line 2904 "parse.c" break; case 259: case 260: #line 938 "parse.y" {yygotominor.yy132.a = yymsp[0].major; yygotominor.yy132.b = 0;} #line 2910 "parse.c" break; case 261: #line 940 "parse.y" {yygotominor.yy132.a = TK_UPDATE; yygotominor.yy132.b = yymsp[0].minor.yy160;} #line 2915 "parse.c" break; case 262: case 263: #line 943 "parse.y" { yygotominor.yy230 = TK_ROW; } #line 2921 "parse.c" break; case 264: #line 945 "parse.y" { yygotominor.yy230 = TK_STATEMENT; } #line 2926 "parse.c" break; case 265: #line 949 "parse.y" { yygotominor.yy178 = 0; } #line 2931 "parse.c" break; case 266: #line 950 "parse.y" { yygotominor.yy178 = yymsp[0].minor.yy178; } #line 2936 "parse.c" break; case 267: #line 954 "parse.y" { if( yymsp[-2].minor.yy247 ){ yymsp[-2].minor.yy247->pLast->pNext = yymsp[-1].minor.yy247; }else{ yymsp[-2].minor.yy247 = yymsp[-1].minor.yy247; } yymsp[-2].minor.yy247->pLast = yymsp[-1].minor.yy247; yygotominor.yy247 = yymsp[-2].minor.yy247; } #line 2949 "parse.c" break; case 268: #line 963 "parse.y" { yygotominor.yy247 = 0; } #line 2954 "parse.c" break; case 269: #line 969 "parse.y" { yygotominor.yy247 = sqlite3TriggerUpdateStep(&yymsp[-3].minor.yy384, yymsp[-1].minor.yy462, yymsp[0].minor.yy178, yymsp[-4].minor.yy230); } #line 2959 "parse.c" break; case 270: #line 974 "parse.y" {yygotominor.yy247 = sqlite3TriggerInsertStep(&yymsp[-5].minor.yy384, yymsp[-4].minor.yy160, yymsp[-1].minor.yy462, 0, yymsp[-7].minor.yy230);} #line 2964 "parse.c" break; case 271: #line 977 "parse.y" {yygotominor.yy247 = sqlite3TriggerInsertStep(&yymsp[-2].minor.yy384, yymsp[-1].minor.yy160, 0, yymsp[0].minor.yy239, yymsp[-4].minor.yy230);} #line 2969 "parse.c" break; case 272: #line 981 "parse.y" {yygotominor.yy247 = sqlite3TriggerDeleteStep(&yymsp[-1].minor.yy384, yymsp[0].minor.yy178);} #line 2974 "parse.c" break; case 273: #line 984 "parse.y" {yygotominor.yy247 = sqlite3TriggerSelectStep(yymsp[0].minor.yy239); } #line 2979 "parse.c" break; case 274: #line 987 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_RAISE, 0, 0, 0); if( yygotominor.yy178 ){ yygotominor.yy178->iColumn = OE_Ignore; sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); } } #line 2990 "parse.c" break; case 275: #line 994 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy384); if( yygotominor.yy178 ) { yygotominor.yy178->iColumn = yymsp[-3].minor.yy230; sqlite3ExprSpan(yygotominor.yy178, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); } } #line 3001 "parse.c" break; case 276: #line 1004 "parse.y" {yygotominor.yy230 = OE_Rollback;} #line 3006 "parse.c" break; case 278: #line 1006 "parse.y" {yygotominor.yy230 = OE_Fail;} #line 3011 "parse.c" break; case 279: #line 1011 "parse.y" { sqlite3DropTrigger(pParse,yymsp[0].minor.yy285); } #line 3018 "parse.c" break; case 280: #line 1017 "parse.y" { sqlite3Attach(pParse, yymsp[-3].minor.yy178, yymsp[-1].minor.yy178, yymsp[0].minor.yy292); } #line 3025 "parse.c" break; case 281: #line 1022 "parse.y" { yygotominor.yy292 = 0; } #line 3030 "parse.c" break; case 282: #line 1023 "parse.y" { yygotominor.yy292 = yymsp[0].minor.yy178; } #line 3035 "parse.c" break; case 285: #line 1029 "parse.y" { sqlite3Detach(pParse, yymsp[0].minor.yy178); } #line 3042 "parse.c" break; case 286: #line 1035 "parse.y" {sqlite3Reindex(pParse, 0, 0);} #line 3047 "parse.c" break; case 287: #line 1036 "parse.y" {sqlite3Reindex(pParse, &yymsp[-1].minor.yy384, &yymsp[0].minor.yy384);} #line 3052 "parse.c" break; case 288: #line 1041 "parse.y" {sqlite3Analyze(pParse, 0, 0);} #line 3057 "parse.c" break; case 289: #line 1042 "parse.y" {sqlite3Analyze(pParse, &yymsp[-1].minor.yy384, &yymsp[0].minor.yy384);} #line 3062 "parse.c" break; case 290: #line 1047 "parse.y" { sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy285,&yymsp[0].minor.yy384); } #line 3069 "parse.c" break; case 291: #line 1050 "parse.y" { sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy384); } #line 3076 "parse.c" break; case 292: #line 1053 "parse.y" { sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy285); } #line 3083 "parse.c" break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); if( yyact < YYNSTATE ){ ................................................................................ if( pParse->zErrMsg==0 ){ if( TOKEN.z[0] ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); }else{ sqlite3ErrorMsg(pParse, "incomplete SQL statement"); } } #line 3150 "parse.c" sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following is executed when the parser accepts */ static void yy_accept( |
Changes to SQLite.Interop/src/pragma.c.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 222 223 224 225 226 227 228 229 230 231 232 233 234 235 ... 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 ... 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
** 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. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** ** $Id: pragma.c,v 1.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* Ignore this whole file if pragmas are disabled */ ................................................................................ if( v==0 ) return; /* Interpret the [database.] part of the pragma statement. iDb is the ** index of the database this pragma is being applied to in db.aDb[]. */ iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId); if( iDb<0 ) return; pDb = &db->aDb[iDb]; zLeft = sqlite3NameFromToken(pId); if( !zLeft ) return; if( minusFlag ){ zRight = sqlite3MPrintf("-%T", pValue); }else{ zRight = sqlite3NameFromToken(pValue); ................................................................................ sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", P3_STATIC); sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", P3_STATIC); sqlite3ViewGetColumnNames(pParse, pTab); for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ sqlite3VdbeAddOp(v, OP_Integer, i, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zName, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zType ? pCol->zType : "numeric", 0); sqlite3VdbeAddOp(v, OP_Integer, pCol->notNull, 0); sqlite3ExprCode(pParse, pCol->pDflt); sqlite3VdbeAddOp(v, OP_Integer, pCol->isPrimKey, 0); sqlite3VdbeAddOp(v, OP_Callback, 6, 0); } } }else ................................................................................ */ sqlite3VdbeAddOp(v, OP_Expire, 1, 0); /* ** Reset the safety level, in case the fullfsync flag or synchronous ** setting changed. */ if( db->autoCommit ){ sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, (db->flags&SQLITE_FullFSync)!=0); } } pragma_out: sqliteFree(zLeft); sqliteFree(zRight); } #endif /* SQLITE_OMIT_PRAGMA || SQLITE_OMIT_PARSER */ |
| > > > > > > > | > > |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 ... 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 ... 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
** 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. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** ** $Id: pragma.c,v 1.20 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* Ignore this whole file if pragmas are disabled */ ................................................................................ if( v==0 ) return; /* Interpret the [database.] part of the pragma statement. iDb is the ** index of the database this pragma is being applied to in db.aDb[]. */ iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId); if( iDb<0 ) return; pDb = &db->aDb[iDb]; /* If the temp database has been explicitly named as part of the ** pragma, make sure it is open. */ if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){ return; } zLeft = sqlite3NameFromToken(pId); if( !zLeft ) return; if( minusFlag ){ zRight = sqlite3MPrintf("-%T", pValue); }else{ zRight = sqlite3NameFromToken(pValue); ................................................................................ sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", P3_STATIC); sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", P3_STATIC); sqlite3ViewGetColumnNames(pParse, pTab); for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ sqlite3VdbeAddOp(v, OP_Integer, i, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zName, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zType ? pCol->zType : "", 0); sqlite3VdbeAddOp(v, OP_Integer, pCol->notNull, 0); sqlite3ExprCode(pParse, pCol->pDflt); sqlite3VdbeAddOp(v, OP_Integer, pCol->isPrimKey, 0); sqlite3VdbeAddOp(v, OP_Callback, 6, 0); } } }else ................................................................................ */ sqlite3VdbeAddOp(v, OP_Expire, 1, 0); /* ** Reset the safety level, in case the fullfsync flag or synchronous ** setting changed. */ #ifndef SQLITE_OMIT_PAGER_PRAGMAS if( db->autoCommit ){ sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, (db->flags&SQLITE_FullFSync)!=0); } #endif } pragma_out: sqliteFree(zLeft); sqliteFree(zRight); } #endif /* SQLITE_OMIT_PRAGMA || SQLITE_OMIT_PARSER */ |
Changes to SQLite.Interop/src/prepare.c.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 .. 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ... 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the implementation of the sqlite3_prepare() ** interface, and routines that contribute to loading the database schema ** from disk. ** ** $Id: prepare.c,v 1.15 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** Fill the InitData structure with an error message that indicates ................................................................................ char *zErr; int rc; assert( db->init.busy ); db->init.iDb = iDb; db->init.newTnum = atoi(argv[1]); rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); db->init.iDb = 0; if( SQLITE_OK!=rc ){ if( rc==SQLITE_NOMEM ){ sqlite3FailedMalloc(); }else{ corruptSchema(pData, zErr); } sqlite3_free(zErr); ................................................................................ } sqlite3BtreeCloseCursor(curTemp); } } return allOk; } /* ** Free all resources held by the schema structure. The void* argument points ** at a Schema struct. This function does not call sqliteFree() on the ** pointer itself, it just cleans up subsiduary resources (i.e. the contents ** of the schema hash tables). */ void sqlite3SchemaFree(void *p){ Hash temp1; Hash temp2; HashElem *pElem; Schema *pSchema = (Schema *)p; temp1 = pSchema->tblHash; temp2 = pSchema->trigHash; sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0); sqlite3HashClear(&pSchema->aFKey); sqlite3HashClear(&pSchema->idxHash); for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem)); } sqlite3HashClear(&temp2); sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0); for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); sqlite3DeleteTable(0, pTab); } sqlite3HashClear(&temp1); pSchema->pSeqTab = 0; pSchema->flags &= ~DB_SchemaLoaded; } /* ** Find and return the schema associated with a BTree. Create ** a new one if necessary. */ Schema *sqlite3SchemaGet(Btree *pBt){ Schema * p; if( pBt ){ p = (Schema *)sqlite3BtreeSchema(pBt,sizeof(Schema),sqlite3SchemaFree); }else{ p = (Schema *)sqliteMalloc(sizeof(Schema)); } if( p && 0==p->file_format ){ sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0); sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0); sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0); sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1); } return p; } /* ** Convert a schema pointer into the iDb index that indicates ** which database file in db->aDb[] the schema refers to. ** ** If the same database is attached more than once, the first ** attached database is returned. */ |
| > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 .. 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 ... 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the implementation of the sqlite3_prepare() ** interface, and routines that contribute to loading the database schema ** from disk. ** ** $Id: prepare.c,v 1.16 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** Fill the InitData structure with an error message that indicates ................................................................................ char *zErr; int rc; assert( db->init.busy ); db->init.iDb = iDb; db->init.newTnum = atoi(argv[1]); rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); db->init.iDb = 0; assert( rc!=SQLITE_OK || zErr==0 ); if( SQLITE_OK!=rc ){ if( rc==SQLITE_NOMEM ){ sqlite3FailedMalloc(); }else{ corruptSchema(pData, zErr); } sqlite3_free(zErr); ................................................................................ } sqlite3BtreeCloseCursor(curTemp); } } return allOk; } /* ** Convert a schema pointer into the iDb index that indicates ** which database file in db->aDb[] the schema refers to. ** ** If the same database is attached more than once, the first ** attached database is returned. */ |
Changes to SQLite.Interop/src/printf.c.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ... 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 ... 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 ... 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 ... 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 ... 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
#define etEXP 3 /* Exponentional notation. %e and %E */ #define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ #define etSIZE 5 /* Return number of characters processed so far. %n */ #define etSTRING 6 /* Strings. %s */ #define etDYNSTRING 7 /* Dynamically allocated strings. %z */ #define etPERCENT 8 /* Percent symbol. %% */ #define etCHARX 9 /* Characters. %c */ #define etERROR 10 /* Used to indicate no such conversion type */ /* The rest are extensions, not normally found in printf() */ #define etCHARLIT 11 /* Literal characters. %' */ #define etSQLESCAPE 12 /* Strings with '\'' doubled. %q */ #define etSQLESCAPE2 13 /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ #define etTOKEN 14 /* a pointer to a Token structure */ #define etSRCLIST 15 /* a pointer to a SrcList */ #define etPOINTER 16 /* The %p conversion */ /* ** An "etByte" is an 8-bit unsigned value. */ typedef unsigned char etByte; ................................................................................ etByte flag_blanksign; /* True if " " flag is present */ etByte flag_alternateform; /* True if "#" flag is present */ etByte flag_altform2; /* True if "!" flag is present */ etByte flag_zeropad; /* True if field width constant starts with zero */ etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ UINT64_TYPE longvalue; /* Value for integer types */ LONGDOUBLE_TYPE realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ etByte errorflag = 0; /* True if an error is encountered */ etByte xtype; /* Conversion paradigm */ char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ ................................................................................ flag_longlong = 0; } }else{ flag_long = flag_longlong = 0; } /* Fetch the info entry for the field */ infop = 0; xtype = etERROR; for(idx=0; idx<etNINFO; idx++){ if( c==fmtinfo[idx].fmttype ){ infop = &fmtinfo[idx]; if( useExtended || (infop->flags & FLAG_INTERN)==0 ){ xtype = infop->type; } break; } } zExtra = 0; /* Limit the precision to prevent overflowing buf[] during conversion */ if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){ precision = etBUFSIZE-40; } /* ................................................................................ } if( xtype==etGENERIC && precision>0 ) precision--; #if 0 /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); #else /* It makes more sense to use 0.5 */ for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1); #endif if( xtype==etFLOAT ) realvalue += rounder; /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ exp = 0; if( realvalue>0.0 ){ while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; } while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } ................................................................................ for(i=0; (ch=escarg[i])!=0; i++){ bufpt[j++] = ch; if( ch=='\'' ) bufpt[j++] = ch; } if( needQuote ) bufpt[j++] = '\''; bufpt[j] = 0; length = j; if( precision>=0 && precision<length ) length = precision; break; } case etTOKEN: { Token *pToken = va_arg(ap, Token*); if( pToken && pToken->z ){ (*func)(arg, (char*)pToken->z, pToken->n); } ................................................................................ (*func)(arg, pItem->zDatabase, strlen(pItem->zDatabase)); (*func)(arg, ".", 1); } (*func)(arg, pItem->zName, strlen(pItem->zName)); length = width = 0; break; } case etERROR: buf[0] = '%'; buf[1] = c; errorflag = 0; idx = 1+(c!=0); (*func)(arg,"%",idx); count += idx; if( c==0 ) fmt--; break; }/* End switch over the format type */ /* ** The text of the conversion is pointed to by "bufpt" and is ** "length" characters long. The field width is "width". Do ** the output. */ if( !flag_leftjustify ){ |
< | | | | | | | < > > > > | > | < < < < < < < < < |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 ... 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 ... 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 ... 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 ... 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 ... 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
#define etEXP 3 /* Exponentional notation. %e and %E */ #define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ #define etSIZE 5 /* Return number of characters processed so far. %n */ #define etSTRING 6 /* Strings. %s */ #define etDYNSTRING 7 /* Dynamically allocated strings. %z */ #define etPERCENT 8 /* Percent symbol. %% */ #define etCHARX 9 /* Characters. %c */ /* The rest are extensions, not normally found in printf() */ #define etCHARLIT 10 /* Literal characters. %' */ #define etSQLESCAPE 11 /* Strings with '\'' doubled. %q */ #define etSQLESCAPE2 12 /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ #define etTOKEN 13 /* a pointer to a Token structure */ #define etSRCLIST 14 /* a pointer to a SrcList */ #define etPOINTER 15 /* The %p conversion */ /* ** An "etByte" is an 8-bit unsigned value. */ typedef unsigned char etByte; ................................................................................ etByte flag_blanksign; /* True if " " flag is present */ etByte flag_alternateform; /* True if "#" flag is present */ etByte flag_altform2; /* True if "!" flag is present */ etByte flag_zeropad; /* True if field width constant starts with zero */ etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ sqlite_uint64 longvalue; /* Value for integer types */ LONGDOUBLE_TYPE realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ etByte errorflag = 0; /* True if an error is encountered */ etByte xtype; /* Conversion paradigm */ char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ ................................................................................ flag_longlong = 0; } }else{ flag_long = flag_longlong = 0; } /* Fetch the info entry for the field */ infop = 0; for(idx=0; idx<etNINFO; idx++){ if( c==fmtinfo[idx].fmttype ){ infop = &fmtinfo[idx]; if( useExtended || (infop->flags & FLAG_INTERN)==0 ){ xtype = infop->type; } break; } } zExtra = 0; if( infop==0 ){ return -1; } /* Limit the precision to prevent overflowing buf[] during conversion */ if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){ precision = etBUFSIZE-40; } /* ................................................................................ } if( xtype==etGENERIC && precision>0 ) precision--; #if 0 /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); #else /* It makes more sense to use 0.5 */ for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){} #endif if( xtype==etFLOAT ) realvalue += rounder; /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ exp = 0; if( realvalue>0.0 ){ while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; } while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } ................................................................................ for(i=0; (ch=escarg[i])!=0; i++){ bufpt[j++] = ch; if( ch=='\'' ) bufpt[j++] = ch; } if( needQuote ) bufpt[j++] = '\''; bufpt[j] = 0; length = j; /* The precision is ignored on %q and %Q */ /* if( precision>=0 && precision<length ) length = precision; */ break; } case etTOKEN: { Token *pToken = va_arg(ap, Token*); if( pToken && pToken->z ){ (*func)(arg, (char*)pToken->z, pToken->n); } ................................................................................ (*func)(arg, pItem->zDatabase, strlen(pItem->zDatabase)); (*func)(arg, ".", 1); } (*func)(arg, pItem->zName, strlen(pItem->zName)); length = width = 0; break; } }/* End switch over the format type */ /* ** The text of the conversion is pointed to by "bufpt" and is ** "length" characters long. The field width is "width". Do ** the output. */ if( !flag_leftjustify ){ |
Changes to SQLite.Interop/src/random.c.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
************************************************************************* ** This file contains code to implement a pseudo-random number ** generator (PRNG) for SQLite. ** ** Random numbers are used by some of the database backends in order ** to generate random integer keys for tables or random filenames. ** ** $Id: random.c,v 1.18 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" /* ** Get a single 8-bit random value from the RC4 PRNG. The Mutex |
| |
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
************************************************************************* ** This file contains code to implement a pseudo-random number ** generator (PRNG) for SQLite. ** ** Random numbers are used by some of the database backends in order ** to generate random integer keys for tables or random filenames. ** ** $Id: random.c,v 1.19 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" /* ** Get a single 8-bit random value from the RC4 PRNG. The Mutex |
Changes to SQLite.Interop/src/select.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 ... 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 ... 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 ... 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 ... 752 753 754 755 756 757 758 759 760 761 762 763 764 765 .... 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 .... 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 .... 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 .... 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 .... 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 .... 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 .... 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 .... 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 .... 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 .... 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 |
** 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 SELECT statements in SQLite. ** ** $Id: select.c,v 1.20 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. ................................................................................ /* ** Add code that will check to make sure the top N elements of the ** stack are distinct. iTab is a sorting index that holds previously ** seen combinations of the N values. A new entry is made in iTab ** if the current N values are new. ** ** A jump to addrRepeat is made and the K values are popped from the ** stack if the top N elements are not distinct. */ static void codeDistinct( Vdbe *v, /* Generate code into this VM */ int iTab, /* A sorting index used to test for distinctness */ int addrRepeat, /* Jump to here if not distinct */ int N, /* The top N elements of the stack must be distinct */ int K /* Pop K elements from the stack if indistinct */ ){ #if NULL_ALWAYS_DISTINCT sqlite3VdbeAddOp(v, OP_IsNull, -N, sqlite3VdbeCurrentAddr(v)+6); #endif sqlite3VdbeAddOp(v, OP_MakeRecord, -N, 0); sqlite3VdbeAddOp(v, OP_Distinct, iTab, sqlite3VdbeCurrentAddr(v)+3); sqlite3VdbeAddOp(v, OP_Pop, K, 0); sqlite3VdbeAddOp(v, OP_Goto, 0, addrRepeat); VdbeComment((v, "# skip indistinct records")); sqlite3VdbeAddOp(v, OP_IdxInsert, iTab, 0); } /* ................................................................................ } /* If the DISTINCT keyword was present on the SELECT statement ** and this row has been seen before, then do not make this row ** part of the result. */ if( hasDistinct ){ int n = pEList->nExpr; codeDistinct(v, distinct, iContinue, n, n+1); if( pOrderBy==0 ){ codeOffset(v, p, iContinue, nColumn); } } switch( eDest ){ /* In this mode, write each query result to the key of the temporary ** table iParm. */ #ifndef SQLITE_OMIT_COMPOUND_SELECT case SRT_Union: { sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); if( aff ){ sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); } sqlite3VdbeAddOp(v, OP_IdxInsert, iParm, 0); break; } /* Construct a record from the query result, but instead of ** saving that record, use it as a key to delete elements from ** the temporary table iParm. */ case SRT_Except: { int addr; addr = sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); sqlite3VdbeAddOp(v, OP_NotFound, iParm, addr+3); sqlite3VdbeAddOp(v, OP_Delete, iParm, 0); break; } #endif ................................................................................ /* ** If the inner loop was generated using a non-null pOrderBy argument, ** then the results were placed in a sorter. After the loop is terminated ** we need to run the sorter and output the results. The following ** routine generates the code needed to do that. */ static void generateSortTail( Parse *pParse, /* The parsing context */ Select *p, /* The SELECT statement */ Vdbe *v, /* Generate code into this VDBE */ int nColumn, /* Number of columns of data */ int eDest, /* Write the sorted results here */ int iParm /* Optional parameter associated with eDest */ ){ int brk = sqlite3VdbeMakeLabel(v); int cont = sqlite3VdbeMakeLabel(v); int addr; int iTab; ExprList *pOrderBy = p->pOrderBy; iTab = pOrderBy->iECursor; addr = 1 + sqlite3VdbeAddOp(v, OP_Sort, iTab, brk); codeOffset(v, p, cont, 0); sqlite3VdbeAddOp(v, OP_Column, iTab, pOrderBy->nExpr + 1); switch( eDest ){ case SRT_Table: case SRT_VirtualTab: { sqlite3VdbeAddOp(v, OP_NewRowid, iParm, 0); sqlite3VdbeAddOp(v, OP_Pull, 1, 0); sqlite3VdbeAddOp(v, OP_Insert, iParm, 0); ................................................................................ /* The LIMIT clause will terminate the loop for us */ break; } #endif case SRT_Callback: case SRT_Subroutine: { int i; sqlite3VdbeAddOp(v, OP_Integer, p->pEList->nExpr, 0); sqlite3VdbeAddOp(v, OP_Pull, 1, 0); for(i=0; i<nColumn; i++){ sqlite3VdbeAddOp(v, OP_Column, -1-i, i); } if( eDest==SRT_Callback ){ sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0); }else{ sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm); } sqlite3VdbeAddOp(v, OP_Pop, 2, 0); break; } default: { /* Do nothing */ break; } } ................................................................................ } /* The bottom of the loop */ sqlite3VdbeResolveLabel(v, cont); sqlite3VdbeAddOp(v, OP_Next, iTab, addr); sqlite3VdbeResolveLabel(v, brk); } /* ** Return a pointer to a string containing the 'declaration type' of the ** expression pExpr. The string may be treated as static by the caller. ** ** The declaration type is the exact datatype definition extracted from the ................................................................................ */ Table *sqlite3ResultSetOfSelect(Parse *pParse, char *zTabName, Select *pSelect){ Table *pTab; int i, j; ExprList *pEList; Column *aCol, *pCol; if( prepSelectStmt(pParse, pSelect) ){ return 0; } if( sqlite3SelectResolve(pParse, pSelect, 0) ){ return 0; } pTab = sqliteMalloc( sizeof(Table) ); ................................................................................ addr = sqlite3VdbeAddOp(pParse->pVdbe, OP_OpenVirtual, pOrderBy->iECursor, pOrderBy->nExpr+1); assert( p->addrOpenVirt[2] == -1 ); p->addrOpenVirt[2] = addr; } } /* ** The opcode at addr is an OP_OpenVirtual that created a sorting ** index tha we ended up not needing. This routine changes that ** opcode to OP_Noop. */ static void uncreateSortingIndex(Parse *pParse, int addr){ Vdbe *v = pParse->pVdbe; VdbeOp *pOp = sqlite3VdbeGetOp(v, addr); sqlite3VdbeChangeP3(v, addr, 0, 0); pOp->opcode = OP_Noop; pOp->p1 = 0; pOp->p2 = 0; } #ifndef SQLITE_OMIT_COMPOUND_SELECT /* ** Return the appropriate collating sequence for the iCol-th column of ** the result set for the compound-select statement "p". Return NULL if ** the column has no default collating sequence. ** ** The collating sequence for the compound select is taken from the ................................................................................ /* Convert the data in the temporary table into whatever form ** it is that we currently need. */ if( eDest!=priorOp || unionTab!=iParm ){ int iCont, iBreak, iStart; assert( p->pEList ); if( eDest==SRT_Callback ){ generateColumnNames(pParse, 0, p->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); computeLimitRegisters(pParse, p, iBreak); sqlite3VdbeAddOp(v, OP_Rewind, unionTab, iBreak); iStart = sqlite3VdbeCurrentAddr(v); rc = selectInnerLoop(pParse, p, p->pEList, unionTab, p->pEList->nExpr, ................................................................................ } /* Generate code to take the intersection of the two temporary ** tables. */ assert( p->pEList ); if( eDest==SRT_Callback ){ generateColumnNames(pParse, 0, p->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); computeLimitRegisters(pParse, p, iBreak); sqlite3VdbeAddOp(v, OP_Rewind, tab1, iBreak); iStart = sqlite3VdbeAddOp(v, OP_RowKey, tab1, 0); sqlite3VdbeAddOp(v, OP_NotFound, tab2, iCont); ................................................................................ ** If flattening is not attempted, this routine is a no-op and returns 0. ** If flattening is attempted this routine returns 1. ** ** All of the expression analysis must occur on both the outer query and ** the subquery before this routine runs. */ static int flattenSubquery( Parse *pParse, /* The parsing context */ Select *p, /* The parent or outer SELECT statement */ int iFrom, /* Index in p->pSrc->a[] of the inner subquery */ int isAgg, /* True if outer SELECT uses aggregate functions */ int subqueryIsAgg /* True if the subquery uses aggregate functions */ ){ Select *pSub; /* The inner query or "subquery" */ SrcList *pSrc; /* The FROM clause of the outer query */ ................................................................................ ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; ** \ \_____________ subquery __________/ / ** \_____________________ outer query ______________________________/ ** ** We look at every expression in the outer query and every place we see ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". */ substExprList(p->pEList, iParent, pSub->pEList); pList = p->pEList; for(i=0; i<pList->nExpr; i++){ Expr *pExpr; if( pList->a[i].zName==0 && (pExpr = pList->a[i].pExpr)->span.z!=0 ){ pList->a[i].zName = sqliteStrNDup((char*)pExpr->span.z, pExpr->span.n); } } if( isAgg ){ substExprList(p->pGroupBy, iParent, pSub->pEList); substExpr(p->pHaving, iParent, pSub->pEList); } if( pSub->pOrderBy ){ assert( p->pOrderBy==0 ); p->pOrderBy = pSub->pOrderBy; ................................................................................ sqlite3ExprCodeExprList(pParse, pList); }else{ nArg = 0; } if( pF->iDistinct>=0 ){ addrNext = sqlite3VdbeMakeLabel(v); assert( nArg==1 ); codeDistinct(v, pF->iDistinct, addrNext, 1, 2); } if( pF->pFunc->needCollSeq ){ CollSeq *pColl = 0; struct ExprList_item *pItem; int j; for(j=0, pItem=pList->a; !pColl && j<pList->nExpr; j++, pItem++){ pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); } if( !pColl ){ pColl = pParse->db->pDfltColl; } sqlite3VdbeOp3(v, OP_CollSeq, 0, 0, (char *)pColl, P3_COLLSEQ); } ................................................................................ } /* Check to see if this is a subquery that can be "flattened" into its parent. ** If flattening is a possiblity, do so and return immediately. */ #ifndef SQLITE_OMIT_VIEW if( pParent && pParentAgg && flattenSubquery(pParse, pParent, parentTab, *pParentAgg, isAgg) ){ if( isAgg ) *pParentAgg = 1; goto select_end; } #endif /* If there is an ORDER BY clause, resolve any collation sequences ** names that have been explicitly specified and create a sorting index. ................................................................................ if( pWInfo==0 ) goto select_end; /* If sorting index that was created by a prior OP_OpenVirtual ** instruction ended up not being needed, then change the OP_OpenVirtual ** into an OP_Noop. */ if( addrSortIndex>=0 && pOrderBy==0 ){ uncreateSortingIndex(pParse, addrSortIndex); p->addrOpenVirt[2] = -1; } /* Use the standard inner loop */ if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest, iParm, pWInfo->iContinue, pWInfo->iBreak, aff) ){ ................................................................................ /* End of the loop */ if( groupBySort ){ sqlite3VdbeAddOp(v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop); }else{ sqlite3WhereEnd(pWInfo); uncreateSortingIndex(pParse, addrSortingIdx); } /* Output the final row of result */ sqlite3VdbeAddOp(v, OP_Gosub, 0, addrOutputRow); VdbeComment((v, "# output final row")); |
| | | < < < < | > | | | | | > > > > > > > > > < | | < > > > > > < < < < < < < < < < < < < < > > | > > | < < > | > | | | | |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 ... 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 ... 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 ... 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 ... 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 .... 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 .... 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 .... 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 .... 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 .... 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 .... 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 .... 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 .... 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 .... 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 .... 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 |
** 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 SELECT statements in SQLite. ** ** $Id: select.c,v 1.21 2006/04/11 18:06:57 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. ................................................................................ /* ** Add code that will check to make sure the top N elements of the ** stack are distinct. iTab is a sorting index that holds previously ** seen combinations of the N values. A new entry is made in iTab ** if the current N values are new. ** ** A jump to addrRepeat is made and the N+1 values are popped from the ** stack if the top N elements are not distinct. */ static void codeDistinct( Vdbe *v, /* Generate code into this VM */ int iTab, /* A sorting index used to test for distinctness */ int addrRepeat, /* Jump to here if not distinct */ int N /* The top N elements of the stack must be distinct */ ){ sqlite3VdbeAddOp(v, OP_MakeRecord, -N, 0); sqlite3VdbeAddOp(v, OP_Distinct, iTab, sqlite3VdbeCurrentAddr(v)+3); sqlite3VdbeAddOp(v, OP_Pop, N+1, 0); sqlite3VdbeAddOp(v, OP_Goto, 0, addrRepeat); VdbeComment((v, "# skip indistinct records")); sqlite3VdbeAddOp(v, OP_IdxInsert, iTab, 0); } /* ................................................................................ } /* If the DISTINCT keyword was present on the SELECT statement ** and this row has been seen before, then do not make this row ** part of the result. */ if( hasDistinct ){ assert( pEList!=0 ); assert( pEList->nExpr==nColumn ); codeDistinct(v, distinct, iContinue, nColumn); if( pOrderBy==0 ){ codeOffset(v, p, iContinue, nColumn); } } switch( eDest ){ /* In this mode, write each query result to the key of the temporary ** table iParm. */ #ifndef SQLITE_OMIT_COMPOUND_SELECT case SRT_Union: { sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0); if( aff ){ sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); } sqlite3VdbeAddOp(v, OP_IdxInsert, iParm, 0); break; } /* Construct a record from the query result, but instead of ** saving that record, use it as a key to delete elements from ** the temporary table iParm. */ case SRT_Except: { int addr; addr = sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0); sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); sqlite3VdbeAddOp(v, OP_NotFound, iParm, addr+3); sqlite3VdbeAddOp(v, OP_Delete, iParm, 0); break; } #endif ................................................................................ /* ** If the inner loop was generated using a non-null pOrderBy argument, ** then the results were placed in a sorter. After the loop is terminated ** we need to run the sorter and output the results. The following ** routine generates the code needed to do that. */ static void generateSortTail( Parse *pParse, /* Parsing context */ Select *p, /* The SELECT statement */ Vdbe *v, /* Generate code into this VDBE */ int nColumn, /* Number of columns of data */ int eDest, /* Write the sorted results here */ int iParm /* Optional parameter associated with eDest */ ){ int brk = sqlite3VdbeMakeLabel(v); int cont = sqlite3VdbeMakeLabel(v); int addr; int iTab; int pseudoTab; ExprList *pOrderBy = p->pOrderBy; iTab = pOrderBy->iECursor; if( eDest==SRT_Callback || eDest==SRT_Subroutine ){ pseudoTab = pParse->nTab++; sqlite3VdbeAddOp(v, OP_OpenPseudo, pseudoTab, 0); sqlite3VdbeAddOp(v, OP_SetNumColumns, pseudoTab, nColumn); } addr = 1 + sqlite3VdbeAddOp(v, OP_Sort, iTab, brk); codeOffset(v, p, cont, 0); if( eDest==SRT_Callback || eDest==SRT_Subroutine ){ sqlite3VdbeAddOp(v, OP_Integer, 1, 0); } sqlite3VdbeAddOp(v, OP_Column, iTab, pOrderBy->nExpr + 1); switch( eDest ){ case SRT_Table: case SRT_VirtualTab: { sqlite3VdbeAddOp(v, OP_NewRowid, iParm, 0); sqlite3VdbeAddOp(v, OP_Pull, 1, 0); sqlite3VdbeAddOp(v, OP_Insert, iParm, 0); ................................................................................ /* The LIMIT clause will terminate the loop for us */ break; } #endif case SRT_Callback: case SRT_Subroutine: { int i; sqlite3VdbeAddOp(v, OP_Insert, pseudoTab, 0); for(i=0; i<nColumn; i++){ sqlite3VdbeAddOp(v, OP_Column, pseudoTab, i); } if( eDest==SRT_Callback ){ sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0); }else{ sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm); } break; } default: { /* Do nothing */ break; } } ................................................................................ } /* The bottom of the loop */ sqlite3VdbeResolveLabel(v, cont); sqlite3VdbeAddOp(v, OP_Next, iTab, addr); sqlite3VdbeResolveLabel(v, brk); if( eDest==SRT_Callback || eDest==SRT_Subroutine ){ sqlite3VdbeAddOp(v, OP_Close, pseudoTab, 0); } } /* ** Return a pointer to a string containing the 'declaration type' of the ** expression pExpr. The string may be treated as static by the caller. ** ** The declaration type is the exact datatype definition extracted from the ................................................................................ */ Table *sqlite3ResultSetOfSelect(Parse *pParse, char *zTabName, Select *pSelect){ Table *pTab; int i, j; ExprList *pEList; Column *aCol, *pCol; while( pSelect->pPrior ) pSelect = pSelect->pPrior; if( prepSelectStmt(pParse, pSelect) ){ return 0; } if( sqlite3SelectResolve(pParse, pSelect, 0) ){ return 0; } pTab = sqliteMalloc( sizeof(Table) ); ................................................................................ addr = sqlite3VdbeAddOp(pParse->pVdbe, OP_OpenVirtual, pOrderBy->iECursor, pOrderBy->nExpr+1); assert( p->addrOpenVirt[2] == -1 ); p->addrOpenVirt[2] = addr; } } #ifndef SQLITE_OMIT_COMPOUND_SELECT /* ** Return the appropriate collating sequence for the iCol-th column of ** the result set for the compound-select statement "p". Return NULL if ** the column has no default collating sequence. ** ** The collating sequence for the compound select is taken from the ................................................................................ /* Convert the data in the temporary table into whatever form ** it is that we currently need. */ if( eDest!=priorOp || unionTab!=iParm ){ int iCont, iBreak, iStart; assert( p->pEList ); if( eDest==SRT_Callback ){ Select *pFirst = p; while( pFirst->pPrior ) pFirst = pFirst->pPrior; generateColumnNames(pParse, 0, pFirst->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); computeLimitRegisters(pParse, p, iBreak); sqlite3VdbeAddOp(v, OP_Rewind, unionTab, iBreak); iStart = sqlite3VdbeCurrentAddr(v); rc = selectInnerLoop(pParse, p, p->pEList, unionTab, p->pEList->nExpr, ................................................................................ } /* Generate code to take the intersection of the two temporary ** tables. */ assert( p->pEList ); if( eDest==SRT_Callback ){ Select *pFirst = p; while( pFirst->pPrior ) pFirst = pFirst->pPrior; generateColumnNames(pParse, 0, pFirst->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); computeLimitRegisters(pParse, p, iBreak); sqlite3VdbeAddOp(v, OP_Rewind, tab1, iBreak); iStart = sqlite3VdbeAddOp(v, OP_RowKey, tab1, 0); sqlite3VdbeAddOp(v, OP_NotFound, tab2, iCont); ................................................................................ ** If flattening is not attempted, this routine is a no-op and returns 0. ** If flattening is attempted this routine returns 1. ** ** All of the expression analysis must occur on both the outer query and ** the subquery before this routine runs. */ static int flattenSubquery( Select *p, /* The parent or outer SELECT statement */ int iFrom, /* Index in p->pSrc->a[] of the inner subquery */ int isAgg, /* True if outer SELECT uses aggregate functions */ int subqueryIsAgg /* True if the subquery uses aggregate functions */ ){ Select *pSub; /* The inner query or "subquery" */ SrcList *pSrc; /* The FROM clause of the outer query */ ................................................................................ ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; ** \ \_____________ subquery __________/ / ** \_____________________ outer query ______________________________/ ** ** We look at every expression in the outer query and every place we see ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". */ pList = p->pEList; for(i=0; i<pList->nExpr; i++){ Expr *pExpr; if( pList->a[i].zName==0 && (pExpr = pList->a[i].pExpr)->span.z!=0 ){ pList->a[i].zName = sqliteStrNDup((char*)pExpr->span.z, pExpr->span.n); } } substExprList(p->pEList, iParent, pSub->pEList); if( isAgg ){ substExprList(p->pGroupBy, iParent, pSub->pEList); substExpr(p->pHaving, iParent, pSub->pEList); } if( pSub->pOrderBy ){ assert( p->pOrderBy==0 ); p->pOrderBy = pSub->pOrderBy; ................................................................................ sqlite3ExprCodeExprList(pParse, pList); }else{ nArg = 0; } if( pF->iDistinct>=0 ){ addrNext = sqlite3VdbeMakeLabel(v); assert( nArg==1 ); codeDistinct(v, pF->iDistinct, addrNext, 1); } if( pF->pFunc->needCollSeq ){ CollSeq *pColl = 0; struct ExprList_item *pItem; int j; assert( pList!=0 ); /* pList!=0 if pF->pFunc->needCollSeq is true */ for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); } if( !pColl ){ pColl = pParse->db->pDfltColl; } sqlite3VdbeOp3(v, OP_CollSeq, 0, 0, (char *)pColl, P3_COLLSEQ); } ................................................................................ } /* Check to see if this is a subquery that can be "flattened" into its parent. ** If flattening is a possiblity, do so and return immediately. */ #ifndef SQLITE_OMIT_VIEW if( pParent && pParentAgg && flattenSubquery(pParent, parentTab, *pParentAgg, isAgg) ){ if( isAgg ) *pParentAgg = 1; goto select_end; } #endif /* If there is an ORDER BY clause, resolve any collation sequences ** names that have been explicitly specified and create a sorting index. ................................................................................ if( pWInfo==0 ) goto select_end; /* If sorting index that was created by a prior OP_OpenVirtual ** instruction ended up not being needed, then change the OP_OpenVirtual ** into an OP_Noop. */ if( addrSortIndex>=0 && pOrderBy==0 ){ sqlite3VdbeChangeToNoop(v, addrSortIndex, 1); p->addrOpenVirt[2] = -1; } /* Use the standard inner loop */ if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest, iParm, pWInfo->iContinue, pWInfo->iBreak, aff) ){ ................................................................................ /* End of the loop */ if( groupBySort ){ sqlite3VdbeAddOp(v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop); }else{ sqlite3WhereEnd(pWInfo); sqlite3VdbeChangeToNoop(v, addrSortingIdx, 1); } /* Output the final row of result */ sqlite3VdbeAddOp(v, OP_Gosub, 0, addrOutputRow); VdbeComment((v, "# output final row")); |
Changes to SQLite.Interop/src/shell.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 .. 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 .... 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 .... 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 .... 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 .... 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 .... 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** ** $Id: shell.c,v 1.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include "sqlite3.h" #include <ctype.h> ................................................................................ ** by the SIGINT handler to interrupt database processing. */ static sqlite3 *db = 0; /* ** True if an interrupt (Control-C) has been received. */ static int seenInterrupt = 0; /* ** This is the name of our program. It is set in main(), used ** in a number of other places, mostly for error messages. */ static char *Argv0; ................................................................................ in = fopen(zFile, "rb"); if( in==0 ){ fprintf(stderr, "cannot open file: %s\n", zFile); sqlite3_finalize(pStmt); return 0; } azCol = malloc( sizeof(azCol[0])*(nCol+1) ); if( azCol==0 ) return 0; sqlite3_exec(p->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; while( (zLine = local_getline(0, in))!=0 ){ char *z; i = 0; lineno++; azCol[0] = zLine; ................................................................................ if( c=='t' && n>1 && strncmp(azArg[0], "timeout", n)==0 && nArg>=2 ){ open_db(p); sqlite3_busy_timeout(p->db, atoi(azArg[1])); }else if( c=='w' && strncmp(azArg[0], "width", n)==0 ){ int j; for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){ p->colWidth[j-1] = atoi(azArg[j]); } }else { fprintf(stderr, "unknown command or invalid arguments: " ................................................................................ } free(zLine); if( zSql && _ends_with_semicolon(zSql, nSql) && sqlite3_complete(zSql) ){ p->cnt = 0; open_db(p); rc = sqlite3_exec(p->db, zSql, callback, p, &zErrMsg); if( rc || zErrMsg ){ if( in!=0 && !p->echoOn ) printf("%s\n",zSql); if( zErrMsg!=0 ){ printf("SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); zErrMsg = 0; }else{ printf("SQL error: %s\n", sqlite3_errmsg(p->db)); } ................................................................................ */ static void process_sqliterc( struct callback_data *p, /* Configuration data */ const char *sqliterc_override /* Name of config file. NULL to use default */ ){ char *home_dir = NULL; const char *sqliterc = sqliterc_override; char *zBuf; FILE *in = NULL; if (sqliterc == NULL) { home_dir = find_home_dir(); if( home_dir==0 ){ fprintf(stderr,"%s: cannot locate your home directory!\n", Argv0); return; ................................................................................ if( in ){ if( isatty(fileno(stdout)) ){ printf("Loading resources from %s\n",sqliterc); } process_input(p,in); fclose(in); } return; } /* ** Show available command line options */ static const char zOptions[] = |
| | | > > > > | | > |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 .. 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 .... 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 .... 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 .... 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 .... 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 .... 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** ** $Id: shell.c,v 1.20 2006/04/11 18:06:58 rmsimpson Exp $ */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include "sqlite3.h" #include <ctype.h> ................................................................................ ** by the SIGINT handler to interrupt database processing. */ static sqlite3 *db = 0; /* ** True if an interrupt (Control-C) has been received. */ static volatile int seenInterrupt = 0; /* ** This is the name of our program. It is set in main(), used ** in a number of other places, mostly for error messages. */ static char *Argv0; ................................................................................ in = fopen(zFile, "rb"); if( in==0 ){ fprintf(stderr, "cannot open file: %s\n", zFile); sqlite3_finalize(pStmt); return 0; } azCol = malloc( sizeof(azCol[0])*(nCol+1) ); if( azCol==0 ){ fclose(in); return 0; } sqlite3_exec(p->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; while( (zLine = local_getline(0, in))!=0 ){ char *z; i = 0; lineno++; azCol[0] = zLine; ................................................................................ if( c=='t' && n>1 && strncmp(azArg[0], "timeout", n)==0 && nArg>=2 ){ open_db(p); sqlite3_busy_timeout(p->db, atoi(azArg[1])); }else if( c=='w' && strncmp(azArg[0], "width", n)==0 ){ int j; assert( nArg<=ArraySize(azArg) ); for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){ p->colWidth[j-1] = atoi(azArg[j]); } }else { fprintf(stderr, "unknown command or invalid arguments: " ................................................................................ } free(zLine); if( zSql && _ends_with_semicolon(zSql, nSql) && sqlite3_complete(zSql) ){ p->cnt = 0; open_db(p); rc = sqlite3_exec(p->db, zSql, callback, p, &zErrMsg); if( rc || zErrMsg ){ /* if( in!=0 && !p->echoOn ) printf("%s\n",zSql); */ if( zErrMsg!=0 ){ printf("SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); zErrMsg = 0; }else{ printf("SQL error: %s\n", sqlite3_errmsg(p->db)); } ................................................................................ */ static void process_sqliterc( struct callback_data *p, /* Configuration data */ const char *sqliterc_override /* Name of config file. NULL to use default */ ){ char *home_dir = NULL; const char *sqliterc = sqliterc_override; char *zBuf = 0; FILE *in = NULL; if (sqliterc == NULL) { home_dir = find_home_dir(); if( home_dir==0 ){ fprintf(stderr,"%s: cannot locate your home directory!\n", Argv0); return; ................................................................................ if( in ){ if( isatty(fileno(stdout)) ){ printf("Loading resources from %s\n",sqliterc); } process_input(p,in); fclose(in); } free(zBuf); return; } /* ** Show available command line options */ static const char zOptions[] = |
Changes to SQLite.Interop/src/sqlite3.h.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 .. 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 .. 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 .. 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 .... 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** ** @(#) $Id: sqlite3.h,v 1.20 2006/02/11 14:43:40 rmsimpson Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. ................................................................................ /* ** The version of the SQLite library. */ #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif #define SQLITE_VERSION "3.3.4" /* ** The format of the version string is "X.Y.Z<trailing string>", where ** X is the major version number, Y is the minor version number and Z ** is the release number. The trailing string is often "alpha" or "beta". ** For example "3.1.1beta". ** ................................................................................ ** SQLITE_VERSION_NUMBER is set to 3001001. To detect if they are using ** version 3.1.1 or greater at compile time, programs may use the test ** (SQLITE_VERSION_NUMBER>=3001001). */ #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif #define SQLITE_VERSION_NUMBER 3003004 /* ** The version string is also compiled into the library so that a program ** can check to make sure that the lib*.a file and the *.h file are from ** the same version. The sqlite3_libversion() function returns a pointer ** to the sqlite3_version variable - useful in DLLs which cannot access ** global variables. ................................................................................ /* ** Some compilers do not support the "long long" datatype. So we have ** to do a typedef that for 64-bit integers that depends on what compiler ** is being used. */ #if defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; typedef unsigned __int64 sqlite_uint64; #else typedef long long int sqlite_int64; typedef unsigned long long int sqlite_uint64; #endif ................................................................................ void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_value(sqlite3_context*, sqlite3_value*); /* ** These are the allowed values for the eTextRep argument to ** sqlite3_create_collation and sqlite3_create_function. */ #define SQLITE_UTF8 1 #define SQLITE_UTF16LE 2 #define SQLITE_UTF16BE 3 #define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ /* ** These two functions are used to add new collation sequences to the ** sqlite3 handle specified as the first argument. ** ** The name of the new collation sequence is specified as a UTF-8 string ** for sqlite3_create_collation() and a UTF-16 string for |
| | | > > > | | | | | | > |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 .. 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 .. 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 .. 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 .... 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** ** @(#) $Id: sqlite3.h,v 1.21 2006/04/11 18:06:58 rmsimpson Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. ................................................................................ /* ** The version of the SQLite library. */ #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif #define SQLITE_VERSION "3.3.5" /* ** The format of the version string is "X.Y.Z<trailing string>", where ** X is the major version number, Y is the minor version number and Z ** is the release number. The trailing string is often "alpha" or "beta". ** For example "3.1.1beta". ** ................................................................................ ** SQLITE_VERSION_NUMBER is set to 3001001. To detect if they are using ** version 3.1.1 or greater at compile time, programs may use the test ** (SQLITE_VERSION_NUMBER>=3001001). */ #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif #define SQLITE_VERSION_NUMBER 3003005 /* ** The version string is also compiled into the library so that a program ** can check to make sure that the lib*.a file and the *.h file are from ** the same version. The sqlite3_libversion() function returns a pointer ** to the sqlite3_version variable - useful in DLLs which cannot access ** global variables. ................................................................................ /* ** Some compilers do not support the "long long" datatype. So we have ** to do a typedef that for 64-bit integers that depends on what compiler ** is being used. */ #ifdef SQLITE_INT64_TYPE typedef SQLITE_INT64_TYPE sqlite_int64; typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; typedef unsigned __int64 sqlite_uint64; #else typedef long long int sqlite_int64; typedef unsigned long long int sqlite_uint64; #endif ................................................................................ void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_value(sqlite3_context*, sqlite3_value*); /* ** These are the allowed values for the eTextRep argument to ** sqlite3_create_collation and sqlite3_create_function. */ #define SQLITE_UTF8 1 #define SQLITE_UTF16LE 2 #define SQLITE_UTF16BE 3 #define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ /* ** These two functions are used to add new collation sequences to the ** sqlite3 handle specified as the first argument. ** ** The name of the new collation sequence is specified as a UTF-8 string ** for sqlite3_create_collation() and a UTF-16 string for |
Changes to SQLite.Interop/src/sqliteInt.h.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 ... 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 ... 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 ... 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 ... 512 513 514 515 516 517 518 519 520 521 522 523 524 525 .... 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 .... 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 .... 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 .... 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 .... 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 .... 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 .... 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 .... 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 .... 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 |
** 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.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Extra interface definitions for those who need them */ ................................................................................ */ #ifdef SQLITE_OMIT_TEMPDB #define OMIT_TEMPDB 1 #else #define OMIT_TEMPDB 0 #endif /* ** If the following macro is set to 1, then NULL values are considered ** distinct for the SELECT DISTINCT statement and for UNION or EXCEPT ** compound queries. No other SQL database engine (among those tested) ** works this way except for OCELOT. But the SQL92 spec implies that ** this is how things should work. ** ** If the following macro is set to 0, then NULLs are indistinct for ** SELECT DISTINCT and for UNION. */ #define NULL_ALWAYS_DISTINCT 0 /* ** If the following macro is set to 1, then NULL values are considered ** distinct when determining whether or not two entries are the same ** in a UNIQUE index. This is the way PostgreSQL, Oracle, DB2, MySQL, ** OCELOT, and Firebird all work. The SQL92 spec explicitly says this ** is the way things are suppose to work. ** ................................................................................ ** GCC does not define the offsetof() macro so we'll have to do it ** ourselves. */ #ifndef offsetof #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) #endif /* ** Integers of known sizes. These typedefs might change for architectures ** where the sizes very. Preprocessor macros are available so that the ** types can be conveniently redefined at compile-type. Like this: ** ** cc '-DUINTPTR_TYPE=long long int' ... */ #ifndef UINT64_TYPE # if defined(_MSC_VER) || defined(__BORLANDC__) # define UINT64_TYPE unsigned __int64 # else # define UINT64_TYPE unsigned long long int # endif #endif #ifndef UINT32_TYPE # define UINT32_TYPE unsigned int #endif #ifndef UINT16_TYPE # define UINT16_TYPE unsigned short int #endif #ifndef INT16_TYPE ................................................................................ #ifndef INT8_TYPE # define INT8_TYPE signed char #endif #ifndef LONGDOUBLE_TYPE # define LONGDOUBLE_TYPE long double #endif typedef sqlite_int64 i64; /* 8-byte signed integer */ typedef UINT64_TYPE u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ typedef UINT8_TYPE i8; /* 1-byte signed integer */ /* ................................................................................ ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler typedefs. */ #include "vdbe.h" #include "btree.h" #include "pager.h" /* ** This macro casts a pointer to an integer. Useful for doing ** pointer arithmetic. */ #define Addr(X) ((uptr)X) #ifdef SQLITE_MEMDEBUG /* ** The following global variables are used for testing and debugging ** only. They only work if SQLITE_MEMDEBUG is defined. */ extern int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */ extern int sqlite3_nFree; /* Number of sqliteFree() calls */ extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */ extern int sqlite3_iMallocReset; /* Set iMallocFail to this when it reaches 0 */ extern void *sqlite3_pFirst; /* Pointer to linked list of allocations */ extern int sqlite3_nMaxAlloc; /* High water mark of ThreadData.nAlloc */ extern int sqlite3_mallocDisallowed; /* assert() in sqlite3Malloc() if set */ extern int sqlite3_isFail; /* True if all malloc calls should fail */ extern const char *sqlite3_zFile; /* Filename to associate debug info with */ extern int sqlite3_iLine; /* Line number for debug info */ #define ENTER_MALLOC (sqlite3_zFile = __FILE__, sqlite3_iLine = __LINE__) #define sqliteMalloc(x) (ENTER_MALLOC, sqlite3Malloc(x)) #define sqliteMallocRaw(x) (ENTER_MALLOC, sqlite3MallocRaw(x)) #define sqliteRealloc(x,y) (ENTER_MALLOC, sqlite3Realloc(x,y)) #define sqliteStrDup(x) (ENTER_MALLOC, sqlite3StrDup(x)) #define sqliteStrNDup(x,y) (ENTER_MALLOC, sqlite3StrNDup(x,y)) #define sqliteReallocOrFree(x,y) (ENTER_MALLOC, sqlite3ReallocOrFree(x,y)) #else #define sqliteMalloc(x) sqlite3Malloc(x) #define sqliteMallocRaw(x) sqlite3MallocRaw(x) #define sqliteRealloc(x,y) sqlite3Realloc(x,y) #define sqliteStrDup(x) sqlite3StrDup(x) #define sqliteStrNDup(x,y) sqlite3StrNDup(x,y) #define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y) #endif ................................................................................ int busyTimeout; /* Busy handler timeout, in msec */ Db aDbStatic[2]; /* Static space for the 2 default backends */ #ifdef SQLITE_SSE sqlite3_stmt *pFetch; /* Used by SSE to fetch stored statements */ #endif }; #define ENC(db) ((db)->aDb[0].pSchema->enc) /* ** Possible values for the sqlite.flags and or Db.flags fields. ** ** On sqlite.flags, the SQLITE_InTrans value means that we have ** executed a BEGIN. On Db.flags, SQLITE_InTrans means a statement ................................................................................ Select *pSelect; /* Valid for SELECT and sometimes INSERT steps (when pExprList == 0) */ Token target; /* Valid for DELETE, UPDATE, INSERT steps */ Expr *pWhere; /* Valid for DELETE, UPDATE steps */ ExprList *pExprList; /* Valid for UPDATE statements and sometimes INSERT steps (when pSelect == 0) */ IdList *pIdList; /* Valid for INSERT statements only */ TriggerStep * pNext; /* Next in the link-list */ }; /* * An instance of struct TriggerStack stores information required during code * generation of a single trigger program. While the trigger program is being * coded, its associated TriggerStack instance is pointed to by the * "pTriggerStack" member of the Parse structure. ................................................................................ int sqlite3StrNICmp(const char *, const char *, int); int sqlite3HashNoCase(const char *, int); int sqlite3IsNumber(const char*, int*, u8); int sqlite3Compare(const char *, const char *); int sqlite3SortCompare(const char *, const char *); void sqlite3RealToSortable(double r, char *); void *sqlite3Malloc(int); void *sqlite3MallocRaw(int); void sqlite3Free(void*); void *sqlite3Realloc(void*,int); char *sqlite3StrDup(const char*); char *sqlite3StrNDup(const char*, int); # define sqlite3CheckMemory(a,b) void sqlite3ReallocOrFree(void**,int); void sqlite3FreeX(void*); ................................................................................ void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); void sqlite3ResetInternalSchema(sqlite3*, int); void sqlite3BeginParse(Parse*,int); void sqlite3RollbackInternalChanges(sqlite3*); void sqlite3CommitInternalChanges(sqlite3*); Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*); void sqlite3OpenMasterTable(Parse *, int); void sqlite3StartTable(Parse*,Token*,Token*,Token*,int,int,int); void sqlite3AddColumn(Parse*,Token*); void sqlite3AddNotNull(Parse*, int); void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); void sqlite3AddCheckConstraint(Parse*, Expr*); void sqlite3AddColumnType(Parse*,Token*); void sqlite3AddDefaultValue(Parse*,Expr*); void sqlite3AddCollateType(Parse*, const char*, int); ................................................................................ void sqlite3ExprIfFalse(Parse*, Expr*, int, int); void sqlite3NextedParse(Parse*, const char*, ...); Table *sqlite3FindTable(sqlite3*,const char*, const char*); Table *sqlite3LocateTable(Parse*,const char*, const char*); Index *sqlite3FindIndex(sqlite3*,const char*, const char*); void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); void sqlite3Vacuum(Parse*, Token*); int sqlite3RunVacuum(char**, sqlite3*); char *sqlite3NameFromToken(Token*); int sqlite3ExprCheck(Parse*, Expr*, int, int*); int sqlite3ExprCompare(Expr*, Expr*); int sqliteFuncId(Token*); int sqlite3ExprResolveNames(NameContext *, Expr *); int sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); ................................................................................ void sqlite3CommitTransaction(Parse*); void sqlite3RollbackTransaction(Parse*); int sqlite3ExprIsConstant(Expr*); int sqlite3ExprIsConstantOrFunction(Expr*); int sqlite3ExprIsInteger(Expr*, int*); int sqlite3IsRowid(const char*); void sqlite3GenerateRowDelete(sqlite3*, Vdbe*, Table*, int, int); void sqlite3GenerateRowIndexDelete(sqlite3*, Vdbe*, Table*, int, char*); void sqlite3GenerateIndexKey(Vdbe*, Index*, int); void sqlite3GenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); void sqlite3CompleteInsertion(Parse*, Table*, int, char*, int, int, int); void sqlite3OpenTableAndIndices(Parse*, Table*, int, int); void sqlite3BeginWriteOperation(Parse*, int, int); Expr *sqlite3ExprDup(Expr*); void sqlite3TokenCopy(Token*, Token*); ................................................................................ void sqlite3ChangeCookie(sqlite3*, Vdbe*, int); #ifndef SQLITE_OMIT_TRIGGER void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, int,Expr*,int); void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); void sqlite3DropTrigger(Parse*, SrcList*); void sqlite3DropTriggerPtr(Parse*, Trigger*, int); int sqlite3TriggersExist(Parse*, Table*, int, ExprList*); int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, int, int); void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); void sqlite3DeleteTriggerStep(TriggerStep*); TriggerStep *sqlite3TriggerSelectStep(Select*); TriggerStep *sqlite3TriggerInsertStep(Token*, IdList*, ExprList*,Select*,int); ................................................................................ TriggerStep *sqlite3TriggerUpdateStep(Token*, ExprList*, Expr*, int); TriggerStep *sqlite3TriggerDeleteStep(Token*, Expr*); void sqlite3DeleteTrigger(Trigger*); void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*); #else # define sqlite3TriggersExist(A,B,C,D,E,F) 0 # define sqlite3DeleteTrigger(A) # define sqlite3DropTriggerPtr(A,B,C) # define sqlite3UnlinkAndDeleteTrigger(A,B,C) # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) 0 #endif int sqlite3JoinType(Parse*, Token*, Token*, Token*); void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); void sqlite3DeferForeignKey(Parse*, int); ................................................................................ int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*)); int sqlite3ApiExit(sqlite3 *db, int); int sqlite3MallocFailed(void); void sqlite3FailedMalloc(void); void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *); #ifndef SQLITE_OMIT_SHARED_CACHE void sqlite3TableLock(Parse *, int, int, u8, const char *); #else #define sqlite3TableLock(v,w,x,y,z) #endif ................................................................................ void sqlite3MallocAllow(void); int sqlite3TestMallocFail(void); #else #define sqlite3TestMallocFail() 0 #define sqlite3MallocDisallow() #define sqlite3MallocAllow() #endif #ifdef SQLITE_SSE #include "sseInt.h" #endif #endif |
| < < < < < < < < < < < < > > > > > > > > > > < < < < < < < | < < < < < < < | | > | | > > > | | | | | | | | | > > > > > > > > > |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 108 109 110 111 112 113 114 115 116 117 118 119 120 121 ... 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 ... 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 ... 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 ... 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 .... 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 .... 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 .... 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 .... 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 .... 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 .... 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 .... 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 .... 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 .... 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 |
** 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.20 2006/04/11 18:06:58 rmsimpson Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Extra interface definitions for those who need them */ ................................................................................ */ #ifdef SQLITE_OMIT_TEMPDB #define OMIT_TEMPDB 1 #else #define OMIT_TEMPDB 0 #endif /* ** If the following macro is set to 1, then NULL values are considered ** distinct when determining whether or not two entries are the same ** in a UNIQUE index. This is the way PostgreSQL, Oracle, DB2, MySQL, ** OCELOT, and Firebird all work. The SQL92 spec explicitly says this ** is the way things are suppose to work. ** ................................................................................ ** GCC does not define the offsetof() macro so we'll have to do it ** ourselves. */ #ifndef offsetof #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) #endif /* ** Check to see if this machine uses EBCDIC. (Yes, believe it or ** not, there are still machines out there that use EBCDIC.) */ #if 'A' == '\301' # define SQLITE_EBCDIC 1 #else # define SQLITE_ASCII 1 #endif /* ** Integers of known sizes. These typedefs might change for architectures ** where the sizes very. Preprocessor macros are available so that the ** types can be conveniently redefined at compile-type. Like this: ** ** cc '-DUINTPTR_TYPE=long long int' ... */ #ifndef UINT32_TYPE # define UINT32_TYPE unsigned int #endif #ifndef UINT16_TYPE # define UINT16_TYPE unsigned short int #endif #ifndef INT16_TYPE ................................................................................ #ifndef INT8_TYPE # define INT8_TYPE signed char #endif #ifndef LONGDOUBLE_TYPE # define LONGDOUBLE_TYPE long double #endif typedef sqlite_int64 i64; /* 8-byte signed integer */ typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ typedef UINT8_TYPE i8; /* 1-byte signed integer */ /* ................................................................................ ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler typedefs. */ #include "vdbe.h" #include "btree.h" #include "pager.h" #ifdef SQLITE_MEMDEBUG /* ** The following global variables are used for testing and debugging ** only. They only work if SQLITE_MEMDEBUG is defined. */ extern int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */ extern int sqlite3_nFree; /* Number of sqliteFree() calls */ extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */ extern int sqlite3_iMallocReset; /* Set iMallocFail to this when it reaches 0 */ extern void *sqlite3_pFirst; /* Pointer to linked list of allocations */ extern int sqlite3_nMaxAlloc; /* High water mark of ThreadData.nAlloc */ extern int sqlite3_mallocDisallowed; /* assert() in sqlite3Malloc() if set */ extern int sqlite3_isFail; /* True if all malloc calls should fail */ extern const char *sqlite3_zFile; /* Filename to associate debug info with */ extern int sqlite3_iLine; /* Line number for debug info */ #define ENTER_MALLOC (sqlite3_zFile = __FILE__, sqlite3_iLine = __LINE__) #define sqliteMalloc(x) (ENTER_MALLOC, sqlite3Malloc(x,1)) #define sqliteMallocRaw(x) (ENTER_MALLOC, sqlite3MallocRaw(x,1)) #define sqliteRealloc(x,y) (ENTER_MALLOC, sqlite3Realloc(x,y)) #define sqliteStrDup(x) (ENTER_MALLOC, sqlite3StrDup(x)) #define sqliteStrNDup(x,y) (ENTER_MALLOC, sqlite3StrNDup(x,y)) #define sqliteReallocOrFree(x,y) (ENTER_MALLOC, sqlite3ReallocOrFree(x,y)) #else #define ENTER_MALLOC 0 #define sqliteMalloc(x) sqlite3Malloc(x,1) #define sqliteMallocRaw(x) sqlite3MallocRaw(x,1) #define sqliteRealloc(x,y) sqlite3Realloc(x,y) #define sqliteStrDup(x) sqlite3StrDup(x) #define sqliteStrNDup(x,y) sqlite3StrNDup(x,y) #define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y) #endif ................................................................................ int busyTimeout; /* Busy handler timeout, in msec */ Db aDbStatic[2]; /* Static space for the 2 default backends */ #ifdef SQLITE_SSE sqlite3_stmt *pFetch; /* Used by SSE to fetch stored statements */ #endif }; /* ** A macro to discover the encoding of a database. */ #define ENC(db) ((db)->aDb[0].pSchema->enc) /* ** Possible values for the sqlite.flags and or Db.flags fields. ** ** On sqlite.flags, the SQLITE_InTrans value means that we have ** executed a BEGIN. On Db.flags, SQLITE_InTrans means a statement ................................................................................ Select *pSelect; /* Valid for SELECT and sometimes INSERT steps (when pExprList == 0) */ Token target; /* Valid for DELETE, UPDATE, INSERT steps */ Expr *pWhere; /* Valid for DELETE, UPDATE steps */ ExprList *pExprList; /* Valid for UPDATE statements and sometimes INSERT steps (when pSelect == 0) */ IdList *pIdList; /* Valid for INSERT statements only */ TriggerStep *pNext; /* Next in the link-list */ TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */ }; /* * An instance of struct TriggerStack stores information required during code * generation of a single trigger program. While the trigger program is being * coded, its associated TriggerStack instance is pointed to by the * "pTriggerStack" member of the Parse structure. ................................................................................ int sqlite3StrNICmp(const char *, const char *, int); int sqlite3HashNoCase(const char *, int); int sqlite3IsNumber(const char*, int*, u8); int sqlite3Compare(const char *, const char *); int sqlite3SortCompare(const char *, const char *); void sqlite3RealToSortable(double r, char *); void *sqlite3Malloc(int,int); void *sqlite3MallocRaw(int,int); void sqlite3Free(void*); void *sqlite3Realloc(void*,int); char *sqlite3StrDup(const char*); char *sqlite3StrNDup(const char*, int); # define sqlite3CheckMemory(a,b) void sqlite3ReallocOrFree(void**,int); void sqlite3FreeX(void*); ................................................................................ void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); void sqlite3ResetInternalSchema(sqlite3*, int); void sqlite3BeginParse(Parse*,int); void sqlite3RollbackInternalChanges(sqlite3*); void sqlite3CommitInternalChanges(sqlite3*); Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*); void sqlite3OpenMasterTable(Parse *, int); void sqlite3StartTable(Parse*,Token*,Token*,int,int,int); void sqlite3AddColumn(Parse*,Token*); void sqlite3AddNotNull(Parse*, int); void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); void sqlite3AddCheckConstraint(Parse*, Expr*); void sqlite3AddColumnType(Parse*,Token*); void sqlite3AddDefaultValue(Parse*,Expr*); void sqlite3AddCollateType(Parse*, const char*, int); ................................................................................ void sqlite3ExprIfFalse(Parse*, Expr*, int, int); void sqlite3NextedParse(Parse*, const char*, ...); Table *sqlite3FindTable(sqlite3*,const char*, const char*); Table *sqlite3LocateTable(Parse*,const char*, const char*); Index *sqlite3FindIndex(sqlite3*,const char*, const char*); void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); void sqlite3Vacuum(Parse*); int sqlite3RunVacuum(char**, sqlite3*); char *sqlite3NameFromToken(Token*); int sqlite3ExprCheck(Parse*, Expr*, int, int*); int sqlite3ExprCompare(Expr*, Expr*); int sqliteFuncId(Token*); int sqlite3ExprResolveNames(NameContext *, Expr *); int sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); ................................................................................ void sqlite3CommitTransaction(Parse*); void sqlite3RollbackTransaction(Parse*); int sqlite3ExprIsConstant(Expr*); int sqlite3ExprIsConstantOrFunction(Expr*); int sqlite3ExprIsInteger(Expr*, int*); int sqlite3IsRowid(const char*); void sqlite3GenerateRowDelete(sqlite3*, Vdbe*, Table*, int, int); void sqlite3GenerateRowIndexDelete(Vdbe*, Table*, int, char*); void sqlite3GenerateIndexKey(Vdbe*, Index*, int); void sqlite3GenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); void sqlite3CompleteInsertion(Parse*, Table*, int, char*, int, int, int); void sqlite3OpenTableAndIndices(Parse*, Table*, int, int); void sqlite3BeginWriteOperation(Parse*, int, int); Expr *sqlite3ExprDup(Expr*); void sqlite3TokenCopy(Token*, Token*); ................................................................................ void sqlite3ChangeCookie(sqlite3*, Vdbe*, int); #ifndef SQLITE_OMIT_TRIGGER void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*, int,Expr*,int); void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); void sqlite3DropTrigger(Parse*, SrcList*); void sqlite3DropTriggerPtr(Parse*, Trigger*); int sqlite3TriggersExist(Parse*, Table*, int, ExprList*); int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, int, int); void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); void sqlite3DeleteTriggerStep(TriggerStep*); TriggerStep *sqlite3TriggerSelectStep(Select*); TriggerStep *sqlite3TriggerInsertStep(Token*, IdList*, ExprList*,Select*,int); ................................................................................ TriggerStep *sqlite3TriggerUpdateStep(Token*, ExprList*, Expr*, int); TriggerStep *sqlite3TriggerDeleteStep(Token*, Expr*); void sqlite3DeleteTrigger(Trigger*); void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*); #else # define sqlite3TriggersExist(A,B,C,D,E,F) 0 # define sqlite3DeleteTrigger(A) # define sqlite3DropTriggerPtr(A,B) # define sqlite3UnlinkAndDeleteTrigger(A,B,C) # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) 0 #endif int sqlite3JoinType(Parse*, Token*, Token*, Token*); void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); void sqlite3DeferForeignKey(Parse*, int); ................................................................................ int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*)); int sqlite3ApiExit(sqlite3 *db, int); int sqlite3MallocFailed(void); void sqlite3FailedMalloc(void); void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *); int sqlite3OpenTempDatabase(Parse *); #ifndef SQLITE_OMIT_SHARED_CACHE void sqlite3TableLock(Parse *, int, int, u8, const char *); #else #define sqlite3TableLock(v,w,x,y,z) #endif ................................................................................ void sqlite3MallocAllow(void); int sqlite3TestMallocFail(void); #else #define sqlite3TestMallocFail() 0 #define sqlite3MallocDisallow() #define sqlite3MallocAllow() #endif #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT void *sqlite3ThreadSafeMalloc(int); void sqlite3ThreadSafeFree(void *); #else #define sqlite3ThreadSafeMalloc sqlite3MallocX #define sqlite3ThreadSafeFree sqlite3FreeX #endif #ifdef SQLITE_SSE #include "sseInt.h" #endif #endif |
Changes to SQLite.Interop/src/tclsqlite.c.
7 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 39 40 41 .... 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 .... 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 .... 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 .... 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 |
** 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. ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "sqliteInt.h" #include "hash.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #include <assert.h> #include <ctype.h> /* * Windows needs to know which symbols to export. Unix does not. * BUILD_sqlite should be undefined for Unix. */ #ifdef BUILD_sqlite #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT #endif /* BUILD_sqlite */ #define NUM_PREPARED_STMTS 10 #define MAX_PREPARED_STMTS 100 /* ** If TCL uses UTF-8 and SQLite is configured to use iso8859, then we ** have to do a translation when going between the two. Set the ................................................................................ Tcl_AppendResult(interp, "Error: cannot open file: ", zFile, NULL); sqlite3_finalize(pStmt); return TCL_ERROR; } azCol = malloc( sizeof(azCol[0])*(nCol+1) ); if( azCol==0 ) { Tcl_AppendResult(interp, "Error: can't malloc()", 0); return TCL_ERROR; } sqlite3_exec(pDb->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; while( (zLine = local_getline(0, in))!=0 ){ char *z; i = 0; lineno++; azCol[0] = zLine; for(i=0, z=zLine; *z; z++){ ................................................................................ zCommit = "ROLLBACK"; break; } } free(azCol); fclose(in); sqlite3_finalize(pStmt); sqlite3_exec(pDb->db, zCommit, 0, 0, 0); if( zCommit[0] == 'C' ){ /* success, set result as number of lines processed */ pResult = Tcl_GetObjResult(interp); Tcl_SetIntObj(pResult, lineno); rc = TCL_OK; }else{ ................................................................................ case TTYPE_EXCLUSIVE: zBegin = "BEGIN EXCLUSIVE"; break; case TTYPE_IMMEDIATE: zBegin = "BEGIN IMMEDIATE"; break; } pScript = objv[3]; } inTrans = !sqlite3_get_autocommit(pDb->db); if( !inTrans ){ sqlite3_exec(pDb->db, zBegin, 0, 0, 0); } rc = Tcl_EvalObjEx(interp, pScript, 0); if( !inTrans ){ const char *zEnd; if( rc==TCL_ERROR ){ zEnd = "ROLLBACK"; } else { zEnd = "COMMIT"; } sqlite3_exec(pDb->db, zEnd, 0, 0, 0); } break; } /* ** $db update_hook ?script? ** $db rollback_hook ?script? ................................................................................ ** ** This Tcl module contains only a single new Tcl command named "sqlite". ** (Hence there is no namespace. There is no point in using a namespace ** if the extension only supplies one new name!) The "sqlite" command is ** used to open a new SQLite database. See the DbMain() routine above ** for additional information. */ EXTERN int Sqlite3_Init(Tcl_Interp *interp){ Tcl_InitStubs(interp, "8.4", 0); Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0); Tcl_PkgProvide(interp, "sqlite3", PACKAGE_VERSION); Tcl_CreateObjCommand(interp, "sqlite", (Tcl_ObjCmdProc*)DbMain, 0, 0); Tcl_PkgProvide(interp, "sqlite", PACKAGE_VERSION); return TCL_OK; } EXTERN int Tclsqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } EXTERN int Sqlite3_SafeInit(Tcl_Interp *interp){ return TCL_OK; } EXTERN int Tclsqlite3_SafeInit(Tcl_Interp *interp){ return TCL_OK; } #ifndef SQLITE_3_SUFFIX_ONLY EXTERN int Sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } EXTERN int Tclsqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } EXTERN int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; } EXTERN int Tclsqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; } #endif #ifdef TCLSH /***************************************************************************** ** The code that follows is used to build standalone TCL interpreters */ |
| < < < < < < < < < > | | | | | | | | | | | | |
7 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 .... 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 .... 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 .... 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 .... 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 |
** 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. ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.20 2006/04/11 18:06:58 rmsimpson Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "sqliteInt.h" #include "hash.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #include <assert.h> #include <ctype.h> #define NUM_PREPARED_STMTS 10 #define MAX_PREPARED_STMTS 100 /* ** If TCL uses UTF-8 and SQLite is configured to use iso8859, then we ** have to do a translation when going between the two. Set the ................................................................................ Tcl_AppendResult(interp, "Error: cannot open file: ", zFile, NULL); sqlite3_finalize(pStmt); return TCL_ERROR; } azCol = malloc( sizeof(azCol[0])*(nCol+1) ); if( azCol==0 ) { Tcl_AppendResult(interp, "Error: can't malloc()", 0); fclose(in); return TCL_ERROR; } (void)sqlite3_exec(pDb->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; while( (zLine = local_getline(0, in))!=0 ){ char *z; i = 0; lineno++; azCol[0] = zLine; for(i=0, z=zLine; *z; z++){ ................................................................................ zCommit = "ROLLBACK"; break; } } free(azCol); fclose(in); sqlite3_finalize(pStmt); (void)sqlite3_exec(pDb->db, zCommit, 0, 0, 0); if( zCommit[0] == 'C' ){ /* success, set result as number of lines processed */ pResult = Tcl_GetObjResult(interp); Tcl_SetIntObj(pResult, lineno); rc = TCL_OK; }else{ ................................................................................ case TTYPE_EXCLUSIVE: zBegin = "BEGIN EXCLUSIVE"; break; case TTYPE_IMMEDIATE: zBegin = "BEGIN IMMEDIATE"; break; } pScript = objv[3]; } inTrans = !sqlite3_get_autocommit(pDb->db); if( !inTrans ){ (void)sqlite3_exec(pDb->db, zBegin, 0, 0, 0); } rc = Tcl_EvalObjEx(interp, pScript, 0); if( !inTrans ){ const char *zEnd; if( rc==TCL_ERROR ){ zEnd = "ROLLBACK"; } else { zEnd = "COMMIT"; } (void)sqlite3_exec(pDb->db, zEnd, 0, 0, 0); } break; } /* ** $db update_hook ?script? ** $db rollback_hook ?script? ................................................................................ ** ** This Tcl module contains only a single new Tcl command named "sqlite". ** (Hence there is no namespace. There is no point in using a namespace ** if the extension only supplies one new name!) The "sqlite" command is ** used to open a new SQLite database. See the DbMain() routine above ** for additional information. */ extern int Sqlite3_Init(Tcl_Interp *interp){ Tcl_InitStubs(interp, "8.4", 0); Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0); Tcl_PkgProvide(interp, "sqlite3", PACKAGE_VERSION); Tcl_CreateObjCommand(interp, "sqlite", (Tcl_ObjCmdProc*)DbMain, 0, 0); Tcl_PkgProvide(interp, "sqlite", PACKAGE_VERSION); return TCL_OK; } extern int Tclsqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } extern int Sqlite3_SafeInit(Tcl_Interp *interp){ return TCL_OK; } extern int Tclsqlite3_SafeInit(Tcl_Interp *interp){ return TCL_OK; } #ifndef SQLITE_3_SUFFIX_ONLY extern int Sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } extern int Tclsqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } extern int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; } extern int Tclsqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; } #endif #ifdef TCLSH /***************************************************************************** ** The code that follows is used to build standalone TCL interpreters */ |
Changes to SQLite.Interop/src/tokenize.c.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
33
34
35
36
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
|
************************************************************************* ** 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.22 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include <stdlib.h> /* ** The sqlite3KeywordCode function looks up an identifier to determine if ** it is a keyword. If it is a keyword, the token code of that keyword is ** returned. If the input is not a keyword, TK_ID is returned. ** ** The implementation of this routine was generated by a program, ** mkkeywordhash.h, located in the tool subdirectory of the distribution. ................................................................................ ** named keywordhash.h and then included into this source file by ** the #include below. */ #include "keywordhash.h" /* ** If X is a character that can be used in an identifier and ** X&0x80==0 then sqlite3IsIdChar[X] will be 1. If X&0x80==0x80 then ** X is always an identifier character. (Hence all UTF-8 ** characters can be part of an identifier). sqlite3IsIdChar[X] will ** be 0 for every character in the lower 128 ASCII characters ** that cannot be used as part of an identifier. ** ** In this implementation, an identifier can be a string of ** alphabetic characters, digits, and "_" plus any character ** with the high-order bit set. The latter rule means that ** any sequence of UTF-8 characters or characters taken from ** an extended ISO8859 character set can form an identifier. ** ** Ticket #1066. the SQL standard does not allow '$' in the ** middle of identfiers. But many SQL implementations do. ** SQLite will allow '$' in identifiers for compatibility. ** But the feature is undocumented. */ const char sqlite3IsIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 3x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */ }; #define IdChar(C) (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsIdChar[c-0x20])) /* ** Return the length of the token that begins at z[0]. ** Store the token type in *tokenType before returning. */ static int getToken(const unsigned char *z, int *tokenType){ int i, c; |
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
<
<
<
>
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
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
..
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
************************************************************************* ** 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.23 2006/04/11 18:06:58 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include <stdlib.h> /* ** The charMap() macro maps alphabetic characters into their ** lower-case ASCII equivalent. On ASCII machines, this is just ** an upper-to-lower case map. On EBCDIC machines we also need ** to adjust the encoding. Only alphabetic characters and underscores ** need to be translated. */ #ifdef SQLITE_ASCII # define charMap(X) sqlite3UpperToLower[(unsigned char)X] #endif #ifdef SQLITE_EBCDIC # define charMap(X) ebcdicToAscii[(unsigned char)X] const unsigned char ebcdicToAscii[] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ }; #endif /* ** The sqlite3KeywordCode function looks up an identifier to determine if ** it is a keyword. If it is a keyword, the token code of that keyword is ** returned. If the input is not a keyword, TK_ID is returned. ** ** The implementation of this routine was generated by a program, ** mkkeywordhash.h, located in the tool subdirectory of the distribution. ................................................................................ ** named keywordhash.h and then included into this source file by ** the #include below. */ #include "keywordhash.h" /* ** If X is a character that can be used in an identifier then ** IdChar(X) will be true. Otherwise it is false. ** ** For ASCII, any character with the high-order bit set is ** allowed in an identifier. For 7-bit characters, ** sqlite3IsIdChar[X] must be 1. ** ** For EBCDIC, the rules are more complex but have the same ** end result. ** ** Ticket #1066. the SQL standard does not allow '$' in the ** middle of identfiers. But many SQL implementations do. ** SQLite will allow '$' in identifiers for compatibility. ** But the feature is undocumented. */ #ifdef SQLITE_ASCII const char sqlite3IsIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 3x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */ }; #define IdChar(C) (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsIdChar[c-0x20])) #endif #ifdef SQLITE_EBCDIC const char sqlite3IsIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ }; #define IdChar(C) (((c=C)>=0x42 && sqlite3IsIdChar[c-0x40])) #endif /* ** Return the length of the token that begins at z[0]. ** Store the token type in *tokenType before returning. */ static int getToken(const unsigned char *z, int *tokenType){ int i, c; |
Changes to SQLite.Interop/src/trigger.c.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 ... 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 ... 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 ... 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 490 491 492 493 494 495 496 497 498 499 500 ... 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 ... 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 ... 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 ... 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
char *zName = 0; /* Name of the trigger */ sqlite3 *db = pParse->db; int iDb; /* The database to store the trigger in */ Token *pName; /* The unqualified db name */ DbFixer sFix; int iTabDb; if( isTemp ){ /* If TEMP was specified, then the trigger name may not be qualified. */ if( pName2 && pName2->n>0 ){ sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name"); goto trigger_cleanup; } iDb = 1; pName = pName1; }else{ /* Figure out the db that the the trigger will be created in */ ................................................................................ /* Check that the trigger name is not reserved and that no trigger of the ** specified name exists */ zName = sqlite3NameFromToken(pName); if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto trigger_cleanup; } if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,pName->n+1) ){ sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); goto trigger_cleanup; } /* Do not create a trigger on a system table */ if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){ sqlite3ErrorMsg(pParse, "cannot create trigger on system table"); ................................................................................ } if( db->init.busy ){ int n; Table *pTab; Trigger *pDel; pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash, pTrig->name, strlen(pTrig->name)+1, pTrig); if( pDel ){ assert( sqlite3MallocFailed() && pDel==pTrig ); goto triggerfinish_cleanup; } n = strlen(pTrig->table) + 1; pTab = sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n); assert( pTab!=0 ); ................................................................................ assert( pName->nSrc==1 ); zDb = pName->a[0].zDatabase; zName = pName->a[0].zName; nName = strlen(zName); for(i=OMIT_TEMPDB; i<db->nDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue; pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName+1); if( pTrigger ) break; } if( !pTrigger ){ sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); goto drop_trigger_cleanup; } sqlite3DropTriggerPtr(pParse, pTrigger, 0); drop_trigger_cleanup: sqlite3SrcListDelete(pName); } /* ** Return a pointer to the Table structure for the table that a trigger ** is set on. */ static Table *tableOfTrigger(sqlite3 *db, Trigger *pTrigger){ int n = strlen(pTrigger->table) + 1; return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n); } /* ** Drop a trigger given a pointer to that trigger. If nested is false, ** then also generate code to remove the trigger from the SQLITE_MASTER ** table. */ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger, int nested){ Table *pTable; Vdbe *v; sqlite3 *db = pParse->db; int iDb; iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema); assert( iDb>=0 && iDb<db->nDb ); pTable = tableOfTrigger(db, pTrigger); assert(pTable); assert( pTable->pSchema==pTrigger->pSchema || iDb==1 ); #ifndef SQLITE_OMIT_AUTHORIZATION { int code = SQLITE_DROP_TRIGGER; const char *zDb = db->aDb[iDb].zName; const char *zTab = SCHEMA_TABLE(iDb); if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER; ................................................................................ return; } } #endif /* Generate code to destroy the database record of the trigger. */ if( pTable!=0 && (v = sqlite3GetVdbe(pParse))!=0 ){ int base; static const VdbeOpList dropTrigger[] = { { OP_Rewind, 0, ADDR(9), 0}, { OP_String8, 0, 0, 0}, /* 1 */ { OP_Column, 0, 1, 0}, { OP_Ne, 0, ADDR(8), 0}, { OP_String8, 0, 0, "trigger"}, ................................................................................ /* ** Remove a trigger from the hash tables of the sqlite* pointer. */ void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){ Trigger *pTrigger; int nName = strlen(zName); pTrigger = sqlite3HashInsert(&(db->aDb[iDb].pSchema->trigHash), zName, nName+1, 0); if( pTrigger ){ Table *pTable = tableOfTrigger(db, pTrigger); assert( pTable!=0 ); if( pTable->pTrigger == pTrigger ){ pTable->pTrigger = pTrigger->pNext; }else{ Trigger *cc = pTable->pTrigger; while( cc ){ if( cc->pNext == pTrigger ){ ................................................................................ ExprList *pChanges /* Columns that change in an UPDATE statement */ ){ Trigger *pTrigger = pTab->pTrigger; int mask = 0; while( pTrigger ){ if( pTrigger->op==op && checkColumnOverLap(pTrigger->pColumns, pChanges) ){ TriggerStack *ss; ss = pParse->trigStack; while( ss && ss->pTrigger!=pTab->pTrigger ){ ss = ss->pNext; } if( ss==0 ){ mask |= pTrigger->tr_tm; } } pTrigger = pTrigger->pNext; } return mask; } /* ................................................................................ if( p->op==op && p->tr_tm==tr_tm && (p->pSchema==p->pTabSchema || p->pSchema==pParse->db->aDb[1].pSchema) && (op!=TK_UPDATE||!p->pColumns||checkColumnOverLap(p->pColumns,pChanges)) ){ TriggerStack *pS; /* Pointer to trigger-stack entry */ for(pS=pParse->trigStack; pS && p!=pS->pTrigger; pS=pS->pNext); if( !pS ){ fire_this = 1; } } if( fire_this ){ int endTrigger; Expr * whenExpr; AuthContext sContext; NameContext sNC; |
> > | | | | | | | < < | | | > | | > | < < < < < < | < | > > > > > > > |
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 ... 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 ... 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 ... 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 490 491 492 493 494 495 496 497 498 499 500 ... 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 ... 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 ... 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 ... 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
char *zName = 0; /* Name of the trigger */ sqlite3 *db = pParse->db; int iDb; /* The database to store the trigger in */ Token *pName; /* The unqualified db name */ DbFixer sFix; int iTabDb; assert( pName1!=0 ); /* pName1->z might be NULL, but not pName1 itself */ assert( pName2!=0 ); if( isTemp ){ /* If TEMP was specified, then the trigger name may not be qualified. */ if( pName2->n>0 ){ sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name"); goto trigger_cleanup; } iDb = 1; pName = pName1; }else{ /* Figure out the db that the the trigger will be created in */ ................................................................................ /* Check that the trigger name is not reserved and that no trigger of the ** specified name exists */ zName = sqlite3NameFromToken(pName); if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto trigger_cleanup; } if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,strlen(zName)) ){ sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); goto trigger_cleanup; } /* Do not create a trigger on a system table */ if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){ sqlite3ErrorMsg(pParse, "cannot create trigger on system table"); ................................................................................ } if( db->init.busy ){ int n; Table *pTab; Trigger *pDel; pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash, pTrig->name, strlen(pTrig->name), pTrig); if( pDel ){ assert( sqlite3MallocFailed() && pDel==pTrig ); goto triggerfinish_cleanup; } n = strlen(pTrig->table) + 1; pTab = sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n); assert( pTab!=0 ); ................................................................................ assert( pName->nSrc==1 ); zDb = pName->a[0].zDatabase; zName = pName->a[0].zName; nName = strlen(zName); for(i=OMIT_TEMPDB; i<db->nDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue; pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName); if( pTrigger ) break; } if( !pTrigger ){ sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); goto drop_trigger_cleanup; } sqlite3DropTriggerPtr(pParse, pTrigger); drop_trigger_cleanup: sqlite3SrcListDelete(pName); } /* ** Return a pointer to the Table structure for the table that a trigger ** is set on. */ static Table *tableOfTrigger(Trigger *pTrigger){ int n = strlen(pTrigger->table) + 1; return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n); } /* ** Drop a trigger given a pointer to that trigger. */ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ Table *pTable; Vdbe *v; sqlite3 *db = pParse->db; int iDb; iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema); assert( iDb>=0 && iDb<db->nDb ); pTable = tableOfTrigger(pTrigger); assert( pTable ); assert( pTable->pSchema==pTrigger->pSchema || iDb==1 ); #ifndef SQLITE_OMIT_AUTHORIZATION { int code = SQLITE_DROP_TRIGGER; const char *zDb = db->aDb[iDb].zName; const char *zTab = SCHEMA_TABLE(iDb); if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER; ................................................................................ return; } } #endif /* Generate code to destroy the database record of the trigger. */ assert( pTable!=0 ); if( (v = sqlite3GetVdbe(pParse))!=0 ){ int base; static const VdbeOpList dropTrigger[] = { { OP_Rewind, 0, ADDR(9), 0}, { OP_String8, 0, 0, 0}, /* 1 */ { OP_Column, 0, 1, 0}, { OP_Ne, 0, ADDR(8), 0}, { OP_String8, 0, 0, "trigger"}, ................................................................................ /* ** Remove a trigger from the hash tables of the sqlite* pointer. */ void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){ Trigger *pTrigger; int nName = strlen(zName); pTrigger = sqlite3HashInsert(&(db->aDb[iDb].pSchema->trigHash), zName, nName, 0); if( pTrigger ){ Table *pTable = tableOfTrigger(pTrigger); assert( pTable!=0 ); if( pTable->pTrigger == pTrigger ){ pTable->pTrigger = pTrigger->pNext; }else{ Trigger *cc = pTable->pTrigger; while( cc ){ if( cc->pNext == pTrigger ){ ................................................................................ ExprList *pChanges /* Columns that change in an UPDATE statement */ ){ Trigger *pTrigger = pTab->pTrigger; int mask = 0; while( pTrigger ){ if( pTrigger->op==op && checkColumnOverLap(pTrigger->pColumns, pChanges) ){ mask |= pTrigger->tr_tm; } pTrigger = pTrigger->pNext; } return mask; } /* ................................................................................ if( p->op==op && p->tr_tm==tr_tm && (p->pSchema==p->pTabSchema || p->pSchema==pParse->db->aDb[1].pSchema) && (op!=TK_UPDATE||!p->pColumns||checkColumnOverLap(p->pColumns,pChanges)) ){ TriggerStack *pS; /* Pointer to trigger-stack entry */ for(pS=pParse->trigStack; pS && p!=pS->pTrigger; pS=pS->pNext){} if( !pS ){ fire_this = 1; } #if 0 /* Give no warning for recursive triggers. Just do not do them */ else{ sqlite3ErrorMsg(pParse, "recursive triggers not supported (%s)", p->name); return SQLITE_ERROR; } #endif } if( fire_this ){ int endTrigger; Expr * whenExpr; AuthContext sContext; NameContext sNC; |
Changes to SQLite.Interop/src/update.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
** 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.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** The most recently coded instruction was an OP_Column to retrieve the ** i-th column of table pTab. This routine sets the P3 parameter of the ** OP_Column to the default value, if any. ................................................................................ /* Do constraint checks */ sqlite3GenerateConstraintChecks(pParse, pTab, iCur, aIdxUsed, chngRowid, 1, onError, addr); /* Delete the old indices for the current record. */ sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, aIdxUsed); /* If changing the record number, delete the old record. */ if( chngRowid ){ sqlite3VdbeAddOp(v, OP_Delete, iCur, 0); } |
|
|
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
** 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.20 2006/04/11 18:06:58 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** The most recently coded instruction was an OP_Column to retrieve the ** i-th column of table pTab. This routine sets the P3 parameter of the ** OP_Column to the default value, if any. ................................................................................ /* Do constraint checks */ sqlite3GenerateConstraintChecks(pParse, pTab, iCur, aIdxUsed, chngRowid, 1, onError, addr); /* Delete the old indices for the current record. */ sqlite3GenerateRowIndexDelete(v, pTab, iCur, aIdxUsed); /* If changing the record number, delete the old record. */ if( chngRowid ){ sqlite3VdbeAddOp(v, OP_Delete, iCur, 0); } |
Changes to SQLite.Interop/src/utf.c.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 ... 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.18 2006/02/11 14:43:40 rmsimpson Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx ................................................................................ assert( pMem->enc!=desiredEnc ); assert( pMem->enc!=0 ); assert( pMem->n>=0 ); #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { char zBuf[100]; sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100); fprintf(stderr, "INPUT: %s\n", zBuf); } #endif /* If the translation is between UTF-16 little and big endian, then ** all that is required is to swap the byte order. This case is handled ** differently from the others. ................................................................................ } pMem->z = (char*)zOut; translate_out: #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { char zBuf[100]; sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100); fprintf(stderr, "OUTPUT: %s\n", zBuf); } #endif return SQLITE_OK; } /* |
| | | |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 ... 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.19 2006/04/11 18:06:58 rmsimpson Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx ................................................................................ assert( pMem->enc!=desiredEnc ); assert( pMem->enc!=0 ); assert( pMem->n>=0 ); #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { char zBuf[100]; sqlite3VdbeMemPrettyPrint(pMem, zBuf); fprintf(stderr, "INPUT: %s\n", zBuf); } #endif /* If the translation is between UTF-16 little and big endian, then ** all that is required is to swap the byte order. This case is handled ** differently from the others. ................................................................................ } pMem->z = (char*)zOut; translate_out: #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { char zBuf[100]; sqlite3VdbeMemPrettyPrint(pMem, zBuf); fprintf(stderr, "OUTPUT: %s\n", zBuf); } #endif return SQLITE_OK; } /* |
Changes to SQLite.Interop/src/util.c.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 ... 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 ... 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 ... 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 ... 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 ... 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 ... 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 ... 847 848 849 850 851 852 853 854 855 856 857 858 859 860 ... 862 863 864 865 866 867 868 869 870 871 872 873 874 875 ... 935 936 937 938 939 940 941 942 943 944 945 946 947 948 .... 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** ** $Id: util.c,v 1.20 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <stdarg.h> #include <ctype.h> /* ................................................................................ } #endif /* ** This is the test layer's wrapper around sqlite3OsMalloc(). */ static void * OSMALLOC(int n){ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT sqlite3_nMaxAlloc = MAX(sqlite3_nMaxAlloc, sqlite3ThreadDataReadOnly()->nAlloc); #endif assert( !sqlite3_mallocDisallowed ); if( !sqlite3TestMallocFail() ){ u32 *p; p = (u32 *)sqlite3OsMalloc(n + TESTALLOC_OVERHEAD); assert(p); sqlite3_nMalloc++; applyGuards(p); linkAlloc(p); return (void *)(&p[TESTALLOC_NGUARD + 2*sizeof(void *)/sizeof(u32)]); } return 0; } static int OSSIZEOF(void *p){ if( p ){ u32 *pOs = (u32 *)getOsPointer(p); return sqlite3OsAllocationSize(pOs) - TESTALLOC_OVERHEAD; ................................................................................ } /* ** This is the test layer's wrapper around sqlite3OsFree(). The argument is a ** pointer to the space allocated for the application to use. */ static void OSFREE(void *pFree){ u32 *p = (u32 *)getOsPointer(pFree); /* p points to Os level allocation */ checkGuards(p); unlinkAlloc(p); memset(pFree, 0x55, OSSIZEOF(pFree)); sqlite3OsFree(p); sqlite3_nFree++; } /* ** This is the test layer's wrapper around sqlite3OsRealloc(). */ static void * OSREALLOC(void *pRealloc, int n){ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT ................................................................................ static int enforceSoftLimit(int n){ ThreadData *pTsd = sqlite3ThreadData(); if( pTsd==0 ){ return 0; } assert( pTsd->nAlloc>=0 ); if( n>0 && pTsd->nSoftHeapLimit>0 ){ while( pTsd->nAlloc+n>pTsd->nSoftHeapLimit && sqlite3_release_memory(n) ); } return 1; } #else # define enforceSoftLimit(X) 1 #endif ................................................................................ #endif /* ** Allocate and return N bytes of uninitialised memory by calling ** sqlite3OsMalloc(). If the Malloc() call fails, attempt to free memory ** by calling sqlite3_release_memory(). */ void *sqlite3MallocRaw(int n){ void *p = 0; if( n>0 && !sqlite3MallocFailed() && enforceSoftLimit(n) ){ while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) ); if( !p ){ sqlite3FailedMalloc(); OSMALLOC_FAILED(); }else{ updateMemoryUsedCount(OSSIZEOF(p)); } } return p; } /* ................................................................................ */ void *sqlite3Realloc(void *p, int n){ if( sqlite3MallocFailed() ){ return 0; } if( !p ){ return sqlite3Malloc(n); }else{ void *np = 0; #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT int origSize = OSSIZEOF(p); #endif if( enforceSoftLimit(n - origSize) ){ while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) ); if( !np ){ sqlite3FailedMalloc(); OSMALLOC_FAILED(); }else{ updateMemoryUsedCount(OSSIZEOF(np) - origSize); } } ................................................................................ /* ** sqlite3Malloc ** sqlite3ReallocOrFree ** ** These two are implemented as wrappers around sqlite3MallocRaw(), ** sqlite3Realloc() and sqlite3Free(). */ void *sqlite3Malloc(int n){ void *p = sqlite3MallocRaw(n); if( p ){ memset(p, 0, n); } return p; } void sqlite3ReallocOrFree(void **pp, int n){ void *p = sqlite3Realloc(*pp, n); if( !p ){ sqlite3FreeX(*pp); } *pp = p; } /* ** Return the number of bytes allocated at location p. p must be either ** a NULL pointer (in which case 0 is returned) or a pointer returned by ** sqlite3Malloc(), sqlite3Realloc() or sqlite3ReallocOrFree(). ** ** The number of bytes allocated does not include any overhead inserted by ................................................................................ ** is because when memory debugging is turned on, these two functions are ** called via macros that record the current file and line number in the ** ThreadData structure. */ char *sqlite3StrDup(const char *z){ char *zNew; if( z==0 ) return 0; zNew = sqlite3MallocRaw(strlen(z)+1); if( zNew ) strcpy(zNew, z); return zNew; } char *sqlite3StrNDup(const char *z, int n){ char *zNew; if( z==0 ) return 0; zNew = sqlite3MallocRaw(n+1); if( zNew ){ memcpy(zNew, z, n); zNew[n] = 0; } return zNew; } ................................................................................ } } /* An array to map all upper-case characters into their corresponding ** lower-case character. */ const unsigned char sqlite3UpperToLower[] = { 0, 1, 2, 3, 4, 5, 6, 7, 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, 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, 97, 98, 99,100,101,102,103, 104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, 122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, ................................................................................ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, 162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, 180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, 252,253,254,255 }; #define UpperToLower sqlite3UpperToLower /* ** Some systems have stricmp(). Others have strcasecmp(). Because ** there is no consistency, we will define our own. */ ................................................................................ ** for SQL. So this routine always uses "." regardless of locale. */ int sqlite3AtoF(const char *z, double *pResult){ #ifndef SQLITE_OMIT_FLOATING_POINT int sign = 1; const char *zBegin = z; LONGDOUBLE_TYPE v1 = 0.0; if( *z=='-' ){ sign = -1; z++; }else if( *z=='+' ){ z++; } while( isdigit(*(u8*)z) ){ ................................................................................ ** 32-bit numbers. At that time, it was much faster than the ** atoi() library routine in RedHat 7.2. */ int sqlite3atoi64(const char *zNum, i64 *pNum){ i64 v = 0; int neg; int i, c; if( *zNum=='-' ){ neg = 1; zNum++; }else if( *zNum=='+' ){ neg = 0; zNum++; }else{ |
| > > > > > | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 ... 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 ... 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 ... 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 ... 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 ... 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 ... 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 ... 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 ... 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 ... 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 .... 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 |
** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** ** $Id: util.c,v 1.21 2006/04/11 18:06:58 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <stdarg.h> #include <ctype.h> /* ................................................................................ } #endif /* ** This is the test layer's wrapper around sqlite3OsMalloc(). */ static void * OSMALLOC(int n){ sqlite3OsEnterMutex(); #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT sqlite3_nMaxAlloc = MAX(sqlite3_nMaxAlloc, sqlite3ThreadDataReadOnly()->nAlloc); #endif assert( !sqlite3_mallocDisallowed ); if( !sqlite3TestMallocFail() ){ u32 *p; p = (u32 *)sqlite3OsMalloc(n + TESTALLOC_OVERHEAD); assert(p); sqlite3_nMalloc++; applyGuards(p); linkAlloc(p); sqlite3OsLeaveMutex(); return (void *)(&p[TESTALLOC_NGUARD + 2*sizeof(void *)/sizeof(u32)]); } sqlite3OsLeaveMutex(); return 0; } static int OSSIZEOF(void *p){ if( p ){ u32 *pOs = (u32 *)getOsPointer(p); return sqlite3OsAllocationSize(pOs) - TESTALLOC_OVERHEAD; ................................................................................ } /* ** This is the test layer's wrapper around sqlite3OsFree(). The argument is a ** pointer to the space allocated for the application to use. */ static void OSFREE(void *pFree){ sqlite3OsEnterMutex(); u32 *p = (u32 *)getOsPointer(pFree); /* p points to Os level allocation */ checkGuards(p); unlinkAlloc(p); memset(pFree, 0x55, OSSIZEOF(pFree)); sqlite3OsFree(p); sqlite3_nFree++; sqlite3OsLeaveMutex(); } /* ** This is the test layer's wrapper around sqlite3OsRealloc(). */ static void * OSREALLOC(void *pRealloc, int n){ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT ................................................................................ static int enforceSoftLimit(int n){ ThreadData *pTsd = sqlite3ThreadData(); if( pTsd==0 ){ return 0; } assert( pTsd->nAlloc>=0 ); if( n>0 && pTsd->nSoftHeapLimit>0 ){ while( pTsd->nAlloc+n>pTsd->nSoftHeapLimit && sqlite3_release_memory(n) ){} } return 1; } #else # define enforceSoftLimit(X) 1 #endif ................................................................................ #endif /* ** Allocate and return N bytes of uninitialised memory by calling ** sqlite3OsMalloc(). If the Malloc() call fails, attempt to free memory ** by calling sqlite3_release_memory(). */ void *sqlite3MallocRaw(int n, int doMemManage){ void *p = 0; if( n>0 && !sqlite3MallocFailed() && (!doMemManage || enforceSoftLimit(n)) ){ while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) ){} if( !p ){ sqlite3FailedMalloc(); OSMALLOC_FAILED(); }else if( doMemManage ){ updateMemoryUsedCount(OSSIZEOF(p)); } } return p; } /* ................................................................................ */ void *sqlite3Realloc(void *p, int n){ if( sqlite3MallocFailed() ){ return 0; } if( !p ){ return sqlite3Malloc(n, 1); }else{ void *np = 0; #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT int origSize = OSSIZEOF(p); #endif if( enforceSoftLimit(n - origSize) ){ while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) ){} if( !np ){ sqlite3FailedMalloc(); OSMALLOC_FAILED(); }else{ updateMemoryUsedCount(OSSIZEOF(np) - origSize); } } ................................................................................ /* ** sqlite3Malloc ** sqlite3ReallocOrFree ** ** These two are implemented as wrappers around sqlite3MallocRaw(), ** sqlite3Realloc() and sqlite3Free(). */ void *sqlite3Malloc(int n, int doMemManage){ void *p = sqlite3MallocRaw(n, doMemManage); if( p ){ memset(p, 0, n); } return p; } void sqlite3ReallocOrFree(void **pp, int n){ void *p = sqlite3Realloc(*pp, n); if( !p ){ sqlite3FreeX(*pp); } *pp = p; } /* ** sqlite3ThreadSafeMalloc() and sqlite3ThreadSafeFree() are used in those ** rare scenarios where sqlite may allocate memory in one thread and free ** it in another. They are exactly the same as sqlite3Malloc() and ** sqlite3Free() except that: ** ** * The allocated memory is not included in any calculations with ** respect to the soft-heap-limit, and ** ** * sqlite3ThreadSafeMalloc() must be matched with ThreadSafeFree(), ** not sqlite3Free(). Calling sqlite3Free() on memory obtained from ** ThreadSafeMalloc() will cause an error somewhere down the line. */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT void *sqlite3ThreadSafeMalloc(int n){ ENTER_MALLOC; return sqlite3Malloc(n, 0); } void sqlite3ThreadSafeFree(void *p){ ENTER_MALLOC; if( p ){ OSFREE(p); } } #endif /* ** Return the number of bytes allocated at location p. p must be either ** a NULL pointer (in which case 0 is returned) or a pointer returned by ** sqlite3Malloc(), sqlite3Realloc() or sqlite3ReallocOrFree(). ** ** The number of bytes allocated does not include any overhead inserted by ................................................................................ ** is because when memory debugging is turned on, these two functions are ** called via macros that record the current file and line number in the ** ThreadData structure. */ char *sqlite3StrDup(const char *z){ char *zNew; if( z==0 ) return 0; zNew = sqlite3MallocRaw(strlen(z)+1, 1); if( zNew ) strcpy(zNew, z); return zNew; } char *sqlite3StrNDup(const char *z, int n){ char *zNew; if( z==0 ) return 0; zNew = sqlite3MallocRaw(n+1, 1); if( zNew ){ memcpy(zNew, z, n); zNew[n] = 0; } return zNew; } ................................................................................ } } /* An array to map all upper-case characters into their corresponding ** lower-case character. */ const unsigned char sqlite3UpperToLower[] = { #ifdef SQLITE_ASCII 0, 1, 2, 3, 4, 5, 6, 7, 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, 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, 97, 98, 99,100,101,102,103, 104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, 122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, ................................................................................ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, 162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, 180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, 252,253,254,255 #endif #ifdef SQLITE_EBCDIC 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ 96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ 112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ 160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ 192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ 208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ 224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ 239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ #endif }; #define UpperToLower sqlite3UpperToLower /* ** Some systems have stricmp(). Others have strcasecmp(). Because ** there is no consistency, we will define our own. */ ................................................................................ ** for SQL. So this routine always uses "." regardless of locale. */ int sqlite3AtoF(const char *z, double *pResult){ #ifndef SQLITE_OMIT_FLOATING_POINT int sign = 1; const char *zBegin = z; LONGDOUBLE_TYPE v1 = 0.0; while( isspace(*z) ) z++; if( *z=='-' ){ sign = -1; z++; }else if( *z=='+' ){ z++; } while( isdigit(*(u8*)z) ){ ................................................................................ ** 32-bit numbers. At that time, it was much faster than the ** atoi() library routine in RedHat 7.2. */ int sqlite3atoi64(const char *zNum, i64 *pNum){ i64 v = 0; int neg; int i, c; while( isspace(*zNum) ) zNum++; if( *zNum=='-' ){ neg = 1; zNum++; }else if( *zNum=='+' ){ neg = 0; zNum++; }else{ |
Changes to SQLite.Interop/src/vacuum.c.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 .. 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 .. 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
** ************************************************************************* ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** ** $Id: vacuum.c,v 1.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" #include "os.h" #ifndef SQLITE_OMIT_VACUUM /* ................................................................................ ** Execute zSql on database db. Return an error code. */ static int execSql(sqlite3 *db, const char *zSql){ sqlite3_stmt *pStmt; if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ return sqlite3_errcode(db); } while( SQLITE_ROW==sqlite3_step(pStmt) ); return sqlite3_finalize(pStmt); } /* ** Execute zSql on database db. The statement returns exactly ** one column. Execute this as SQL on the same database. */ ................................................................................ ** in PostgreSQL. ** ** In version 1.0.x of SQLite, the VACUUM command would call ** gdbm_reorganize() on all the database tables. But beginning ** with 2.0.0, SQLite no longer uses GDBM so this command has ** become a no-op. */ void sqlite3Vacuum(Parse *pParse, Token *pTableName){ Vdbe *v = sqlite3GetVdbe(pParse); if( v ){ sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0); } return; } |
| | | |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 .. 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 .. 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
** ************************************************************************* ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** ** $Id: vacuum.c,v 1.20 2006/04/11 18:06:58 rmsimpson Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" #include "os.h" #ifndef SQLITE_OMIT_VACUUM /* ................................................................................ ** Execute zSql on database db. Return an error code. */ static int execSql(sqlite3 *db, const char *zSql){ sqlite3_stmt *pStmt; if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ return sqlite3_errcode(db); } while( SQLITE_ROW==sqlite3_step(pStmt) ){} return sqlite3_finalize(pStmt); } /* ** Execute zSql on database db. The statement returns exactly ** one column. Execute this as SQL on the same database. */ ................................................................................ ** in PostgreSQL. ** ** In version 1.0.x of SQLite, the VACUUM command would call ** gdbm_reorganize() on all the database tables. But beginning ** with 2.0.0, SQLite no longer uses GDBM so this command has ** become a no-op. */ void sqlite3Vacuum(Parse *pParse){ Vdbe *v = sqlite3GetVdbe(pParse); if( v ){ sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0); } return; } |
Changes to SQLite.Interop/src/vdbe.c.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 ... 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 .... 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 .... 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 .... 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 .... 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 .... 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 .... 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 .... 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 .... 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 .... 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 .... 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 .... 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 .... 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 .... 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 .... 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 .... 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 .... 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 .... 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 |
** ** 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.21 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* ................................................................................ } #ifdef SQLITE_DEBUG /* ** Write a nice string representation of the contents of cell pMem ** into buffer zBuf, length nBuf. */ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf, int nBuf){ char *zCsr = zBuf; int f = pMem->flags; static const char *const encnames[] = {"(X)", "(8)", "(16LE)", "(16BE)"}; if( f&MEM_Blob ){ int i; ................................................................................ ** information about the format of the data.) Push onto the stack the value ** of the P2-th column contained in the data. If there are less that (P2+1) ** values in the record, push a NULL onto the stack. ** ** If the KeyAsData opcode has previously executed on this cursor, then the ** field might be extracted from the key rather than the data. ** ** If P1 is negative, then the record is stored on the stack rather than in ** a table. For P1==-1, the top of the stack is used. For P1==-2, the ** next on the stack is used. And so forth. The value pushed is always ** just a pointer into the record which is stored further down on the ** stack. The column value is not copied. The number of columns in the ** record is stored on the stack just above the record itself. ** ** If the column contains fewer than P2 fields, then push a NULL. Or ** if P3 is of type P3_MEM, then push the P3 value. The P3 value will ** be default value for a column that has been added using the ALTER TABLE ** ADD COLUMN command. If P3 is an ordinary string, just push a NULL. ** When P3 is a string it is really just a comment describing the value ** to be pushed, not a default value. */ ................................................................................ pTos++; pTos->flags = MEM_Null; /* This block sets the variable payloadSize to be the total number of ** bytes in the record. ** ** zRec is set to be the complete text of the record if it is available. ** The complete record text is always available for pseudo-tables and ** when we are decoded a record from the stack. If the record is stored ** in a cursor, the complete record text might be available in the ** pC->aRow cache. Or it might not be. If the data is unavailable, ** zRec is set to NULL. ** ** We also compute the number of columns in the record. For cursors, ** the number of columns is stored in the Cursor.nField element. For ** records on the stack, the next entry down on the stack is an integer ** which is the number of records. */ assert( p1<0 || p->apCsr[p1]!=0 ); if( p1<0 ){ /* Take the record off of the stack */ Mem *pRec = &pTos[p1]; Mem *pCnt = &pRec[-1]; assert( pRec>=p->aStack ); assert( pRec->flags & MEM_Blob ); payloadSize = pRec->n; zRec = pRec->z; assert( pCnt>=p->aStack ); assert( pCnt->flags & MEM_Int ); nField = pCnt->i; pCrsr = 0; }else if( (pC = p->apCsr[p1])->pCursor!=0 ){ /* The record is stored in a B-Tree */ rc = sqlite3VdbeCursorMoveto(pC); if( rc ) goto abort_due_to_error; zRec = 0; pCrsr = pC->pCursor; if( pC->nullRow ){ payloadSize = 0; ................................................................................ i64 payloadSize64; sqlite3BtreeKeySize(pCrsr, &payloadSize64); payloadSize = payloadSize64; }else{ sqlite3BtreeDataSize(pCrsr, &payloadSize); } nField = pC->nField; #ifndef SQLITE_OMIT_TRIGGER }else if( pC->pseudoTable ){ /* The record is the sole entry of a pseudo-table */ payloadSize = pC->nData; zRec = pC->pData; pC->cacheStatus = CACHE_STALE; assert( payloadSize==0 || zRec!=0 ); nField = pC->nField; pCrsr = 0; #endif }else{ zRec = 0; payloadSize = 0; pCrsr = 0; nField = 0; } ................................................................................ aOffset = pC->aOffset; }else{ u8 *zIdx; /* Index into header */ u8 *zEndHdr; /* Pointer to first byte after the header */ u32 offset; /* Offset into the data */ int szHdrSz; /* Size of the header size field at start of record */ int avail; /* Number of bytes of available data */ if( pC && pC->aType ){ aType = pC->aType; }else{ aType = sqliteMallocRaw( 2*nField*sizeof(aType) ); } aOffset = &aType[nField]; if( aType==0 ){ goto no_mem; } /* Figure out how many bytes are in the header */ if( zRec ){ zData = zRec; }else{ if( pC->isIndex ){ zData = (char*)sqlite3BtreeKeyFetch(pCrsr, &avail); ................................................................................ ** or if the end of the last field appears to be past the end of the ** record, then we must be dealing with a corrupt database. */ if( zIdx>zEndHdr || offset>payloadSize ){ rc = SQLITE_CORRUPT_BKPT; goto op_column_out; } /* Remember all aType and aColumn information if we have a cursor ** to remember it in. */ if( pC ){ pC->payloadSize = payloadSize; pC->aType = aType; pC->aOffset = aOffset; pC->cacheStatus = p->cacheCtr; } } /* Get the column information. If aOffset[p2] is non-zero, then ** deserialize the value from the record. If aOffset[p2] is zero, ** then there are not enough fields in the record to satisfy the ** request. In this case, set the value NULL or to P3 if P3 is ** a pointer to a Mem object. ................................................................................ }else{ pTos->flags = MEM_Null; } } /* If we dynamically allocated space to hold the data (in the ** sqlite3VdbeMemFromBtree() call above) then transfer control of that ** dynamically allocated space over to the pTos structure rather. ** This prevents a memory copy. */ if( (sMem.flags & MEM_Dyn)!=0 ){ assert( pTos->flags & MEM_Ephem ); assert( pTos->flags & (MEM_Str|MEM_Blob) ); assert( pTos->z==sMem.z ); assert( sMem.flags & MEM_Term ); ................................................................................ } /* pTos->z might be pointing to sMem.zShort[]. Fix that so that we ** can abandon sMem */ rc = sqlite3VdbeMemMakeWriteable(pTos); op_column_out: /* Release the aType[] memory if we are not dealing with cursor */ if( !pC || !pC->aType ){ sqliteFree(aType); } break; } /* Opcode: MakeRecord P1 P2 P3 ** ** Convert the top abs(P1) entries of the stack into a single entry ** suitable for use as a data record in a database table or as a key ................................................................................ } } pCx->nField = pOp->p2; pCx->isIndex = !pCx->isTable; break; } #ifndef SQLITE_OMIT_TRIGGER /* Opcode: OpenPseudo P1 * * ** ** Open a new cursor that points to a fake table that contains a single ** row of data. Any attempt to write a second row of data causes the ** first row to be deleted. All data is deleted when the cursor is ** closed. ** ** A pseudo-table created by this opcode is useful for holding the ** NEW or OLD tables in a trigger. */ case OP_OpenPseudo: { /* no-push */ int i = pOp->p1; Cursor *pCx; assert( i>=0 ); pCx = allocateCursor(p, i, -1); if( pCx==0 ) goto no_mem; ................................................................................ pCx->nullRow = 1; pCx->pseudoTable = 1; pCx->pIncrKey = &pCx->bogusIncrKey; pCx->isTable = 1; pCx->isIndex = 0; break; } #endif /* Opcode: Close P1 * * ** ** Close a cursor previously opened as P1. If P1 is not ** currently open, this instruction is a no-op. */ case OP_Close: { /* no-push */ ................................................................................ /* Make sure K is a string and make zKey point to K */ Stringify(pNos, encoding); zKey = pNos->z; nKey = pNos->n; szRowid = sqlite3VdbeIdxRowidLen(nKey, (u8*)zKey); len = nKey-szRowid; /* Search for an entry in P1 where all but the last four bytes match K. ** If there is no such entry, jump immediately to P2. */ assert( pCx->deferredMoveto==0 ); pCx->cacheStatus = CACHE_STALE; ................................................................................ } if( pTos->flags & MEM_Null ){ pTos->z = 0; pTos->n = 0; }else{ assert( pTos->flags & (MEM_Blob|MEM_Str) ); } #ifndef SQLITE_OMIT_TRIGGER if( pC->pseudoTable ){ sqliteFree(pC->pData); pC->iKey = iKey; pC->nData = pTos->n; if( pTos->flags & MEM_Dyn ){ pC->pData = pTos->z; pTos->flags = MEM_Null; ................................................................................ if( !pC->pData ) goto no_mem; memcpy(pC->pData, pTos->z, pC->nData); pC->pData[pC->nData] = 0; pC->pData[pC->nData+1] = 0; } pC->nullRow = 0; }else{ #endif rc = sqlite3BtreeInsert(pC->pCursor, 0, iKey, pTos->z, pTos->n); #ifndef SQLITE_OMIT_TRIGGER } #endif pC->rowidIsValid = 0; pC->deferredMoveto = 0; pC->cacheStatus = CACHE_STALE; /* Invoke the update-hook if required. */ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p3 ){ ................................................................................ pTos->z = z; } if( pC->isIndex ){ sqlite3BtreeKey(pCrsr, 0, n, pTos->z); }else{ sqlite3BtreeData(pCrsr, 0, n, pTos->z); } #ifndef SQLITE_OMIT_TRIGGER }else if( pC->pseudoTable ){ pTos->n = pC->nData; pTos->z = pC->pData; pTos->flags = MEM_Blob|MEM_Ephem; #endif }else{ pTos->flags = MEM_Null; } pTos->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ break; } ................................................................................ if( rc==SQLITE_NOMEM ){ sqlite3FailedMalloc(); goto no_mem; } break; } #ifndef SQLITE_OMIT_ANALYZE /* Opcode: LoadAnalysis P1 * * ** ** Read the sqlite_stat1 table for database P1 and load the content ** of that table into the internal index hash table. This will cause ** the analysis to be used when preparing all subsequent queries. */ case OP_LoadAnalysis: { /* no-push */ int iDb = pOp->p1; assert( iDb>=0 && iDb<db->nDb ); sqlite3AnalysisLoad(db, iDb); break; } #endif /* SQLITE_OMIT_ANALYZE */ /* Opcode: DropTable P1 * P3 ** ** Remove the internal (in-memory) data structures that describe ** the table named P3 in database P1. This is called after a table ** is dropped in order to keep the internal representation of the ** schema consistent with what is on disk. ................................................................................ #ifndef SQLITE_OMIT_SHARED_CACHE /* Opcode: TableLock P1 P2 P3 ** ** Obtain a lock on a particular table. This instruction is only used when ** the shared-cache feature is enabled. ** ** If P1 is not negative, then it is the index of the index of the database ** in sqlite3.aDb[] and a read-lock is required. If P1 is negative, a ** write-lock is required. In this case the index of the database is the ** absolute value of P1 minus one (iDb = abs(P1) - 1;) and a write-lock is ** required. ** ** P2 contains the root-page of the table to lock. ** ................................................................................ ** of the program. It is only here for testing and debugging. ** On the other hand, it does burn CPU cycles every time through ** the evaluator loop. So we can leave it out when NDEBUG is defined. */ #ifndef NDEBUG /* Sanity checking on the top element of the stack */ if( pTos>=p->aStack ){ sqlite3VdbeMemSanity(pTos, encoding); } assert( pc>=-1 && pc<p->nOp ); #ifdef SQLITE_DEBUG /* Code for tracing the vdbe stack. */ if( p->trace && pTos>=p->aStack ){ int i; fprintf(p->trace, "Stack:"); ................................................................................ fprintf(p->trace, " si:%lld", pTos[i].i); }else if( pTos[i].flags & MEM_Int ){ fprintf(p->trace, " i:%lld", pTos[i].i); }else if( pTos[i].flags & MEM_Real ){ fprintf(p->trace, " r:%g", pTos[i].r); }else{ char zBuf[100]; sqlite3VdbeMemPrettyPrint(&pTos[i], zBuf, 100); fprintf(p->trace, " "); fprintf(p->trace, "%s", zBuf); } } if( rc!=0 ) fprintf(p->trace," rc=%d",rc); fprintf(p->trace,"\n"); } |
| | < < < < < < < | < | | | | < < < < < < < < | < < < | < < < > | | | < > > > < < < < < < < < < | < < < < < | > > < | < < < < < < | | | | | |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 ... 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 .... 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 .... 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 .... 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 .... 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 .... 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 .... 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 .... 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 .... 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 .... 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 .... 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 .... 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 .... 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 .... 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 .... 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 .... 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 .... 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 .... 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 |
** ** 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.22 2006/04/11 18:06:58 rmsimpson Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* ................................................................................ } #ifdef SQLITE_DEBUG /* ** Write a nice string representation of the contents of cell pMem ** into buffer zBuf, length nBuf. */ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){ char *zCsr = zBuf; int f = pMem->flags; static const char *const encnames[] = {"(X)", "(8)", "(16LE)", "(16BE)"}; if( f&MEM_Blob ){ int i; ................................................................................ ** information about the format of the data.) Push onto the stack the value ** of the P2-th column contained in the data. If there are less that (P2+1) ** values in the record, push a NULL onto the stack. ** ** If the KeyAsData opcode has previously executed on this cursor, then the ** field might be extracted from the key rather than the data. ** ** If the column contains fewer than P2 fields, then push a NULL. Or ** if P3 is of type P3_MEM, then push the P3 value. The P3 value will ** be default value for a column that has been added using the ALTER TABLE ** ADD COLUMN command. If P3 is an ordinary string, just push a NULL. ** When P3 is a string it is really just a comment describing the value ** to be pushed, not a default value. */ ................................................................................ pTos++; pTos->flags = MEM_Null; /* This block sets the variable payloadSize to be the total number of ** bytes in the record. ** ** zRec is set to be the complete text of the record if it is available. ** The complete record text is always available for pseudo-tables ** If the record is stored in a cursor, the complete record text ** might be available in the pC->aRow cache. Or it might not be. ** If the data is unavailable, zRec is set to NULL. ** ** We also compute the number of columns in the record. For cursors, ** the number of columns is stored in the Cursor.nField element. For ** records on the stack, the next entry down on the stack is an integer ** which is the number of records. */ pC = p->apCsr[p1]; assert( pC!=0 ); if( pC->pCursor!=0 ){ /* The record is stored in a B-Tree */ rc = sqlite3VdbeCursorMoveto(pC); if( rc ) goto abort_due_to_error; zRec = 0; pCrsr = pC->pCursor; if( pC->nullRow ){ payloadSize = 0; ................................................................................ i64 payloadSize64; sqlite3BtreeKeySize(pCrsr, &payloadSize64); payloadSize = payloadSize64; }else{ sqlite3BtreeDataSize(pCrsr, &payloadSize); } nField = pC->nField; }else if( pC->pseudoTable ){ /* The record is the sole entry of a pseudo-table */ payloadSize = pC->nData; zRec = pC->pData; pC->cacheStatus = CACHE_STALE; assert( payloadSize==0 || zRec!=0 ); nField = pC->nField; pCrsr = 0; }else{ zRec = 0; payloadSize = 0; pCrsr = 0; nField = 0; } ................................................................................ aOffset = pC->aOffset; }else{ u8 *zIdx; /* Index into header */ u8 *zEndHdr; /* Pointer to first byte after the header */ u32 offset; /* Offset into the data */ int szHdrSz; /* Size of the header size field at start of record */ int avail; /* Number of bytes of available data */ aType = pC->aType; if( aType==0 ){ pC->aType = aType = sqliteMallocRaw( 2*nField*sizeof(aType) ); } if( aType==0 ){ goto no_mem; } pC->aOffset = aOffset = &aType[nField]; pC->payloadSize = payloadSize; pC->cacheStatus = p->cacheCtr; /* Figure out how many bytes are in the header */ if( zRec ){ zData = zRec; }else{ if( pC->isIndex ){ zData = (char*)sqlite3BtreeKeyFetch(pCrsr, &avail); ................................................................................ ** or if the end of the last field appears to be past the end of the ** record, then we must be dealing with a corrupt database. */ if( zIdx>zEndHdr || offset>payloadSize ){ rc = SQLITE_CORRUPT_BKPT; goto op_column_out; } } /* Get the column information. If aOffset[p2] is non-zero, then ** deserialize the value from the record. If aOffset[p2] is zero, ** then there are not enough fields in the record to satisfy the ** request. In this case, set the value NULL or to P3 if P3 is ** a pointer to a Mem object. ................................................................................ }else{ pTos->flags = MEM_Null; } } /* If we dynamically allocated space to hold the data (in the ** sqlite3VdbeMemFromBtree() call above) then transfer control of that ** dynamically allocated space over to the pTos structure. ** This prevents a memory copy. */ if( (sMem.flags & MEM_Dyn)!=0 ){ assert( pTos->flags & MEM_Ephem ); assert( pTos->flags & (MEM_Str|MEM_Blob) ); assert( pTos->z==sMem.z ); assert( sMem.flags & MEM_Term ); ................................................................................ } /* pTos->z might be pointing to sMem.zShort[]. Fix that so that we ** can abandon sMem */ rc = sqlite3VdbeMemMakeWriteable(pTos); op_column_out: break; } /* Opcode: MakeRecord P1 P2 P3 ** ** Convert the top abs(P1) entries of the stack into a single entry ** suitable for use as a data record in a database table or as a key ................................................................................ } } pCx->nField = pOp->p2; pCx->isIndex = !pCx->isTable; break; } /* Opcode: OpenPseudo P1 * * ** ** Open a new cursor that points to a fake table that contains a single ** row of data. Any attempt to write a second row of data causes the ** first row to be deleted. All data is deleted when the cursor is ** closed. ** ** A pseudo-table created by this opcode is useful for holding the ** NEW or OLD tables in a trigger. Also used to hold the a single ** row output from the sorter so that the row can be decomposed into ** individual columns using the OP_Column opcode. */ case OP_OpenPseudo: { /* no-push */ int i = pOp->p1; Cursor *pCx; assert( i>=0 ); pCx = allocateCursor(p, i, -1); if( pCx==0 ) goto no_mem; ................................................................................ pCx->nullRow = 1; pCx->pseudoTable = 1; pCx->pIncrKey = &pCx->bogusIncrKey; pCx->isTable = 1; pCx->isIndex = 0; break; } /* Opcode: Close P1 * * ** ** Close a cursor previously opened as P1. If P1 is not ** currently open, this instruction is a no-op. */ case OP_Close: { /* no-push */ ................................................................................ /* Make sure K is a string and make zKey point to K */ Stringify(pNos, encoding); zKey = pNos->z; nKey = pNos->n; szRowid = sqlite3VdbeIdxRowidLen((u8*)zKey); len = nKey-szRowid; /* Search for an entry in P1 where all but the last four bytes match K. ** If there is no such entry, jump immediately to P2. */ assert( pCx->deferredMoveto==0 ); pCx->cacheStatus = CACHE_STALE; ................................................................................ } if( pTos->flags & MEM_Null ){ pTos->z = 0; pTos->n = 0; }else{ assert( pTos->flags & (MEM_Blob|MEM_Str) ); } if( pC->pseudoTable ){ sqliteFree(pC->pData); pC->iKey = iKey; pC->nData = pTos->n; if( pTos->flags & MEM_Dyn ){ pC->pData = pTos->z; pTos->flags = MEM_Null; ................................................................................ if( !pC->pData ) goto no_mem; memcpy(pC->pData, pTos->z, pC->nData); pC->pData[pC->nData] = 0; pC->pData[pC->nData+1] = 0; } pC->nullRow = 0; }else{ rc = sqlite3BtreeInsert(pC->pCursor, 0, iKey, pTos->z, pTos->n); } pC->rowidIsValid = 0; pC->deferredMoveto = 0; pC->cacheStatus = CACHE_STALE; /* Invoke the update-hook if required. */ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p3 ){ ................................................................................ pTos->z = z; } if( pC->isIndex ){ sqlite3BtreeKey(pCrsr, 0, n, pTos->z); }else{ sqlite3BtreeData(pCrsr, 0, n, pTos->z); } }else if( pC->pseudoTable ){ pTos->n = pC->nData; pTos->z = pC->pData; pTos->flags = MEM_Blob|MEM_Ephem; }else{ pTos->flags = MEM_Null; } pTos->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ break; } ................................................................................ if( rc==SQLITE_NOMEM ){ sqlite3FailedMalloc(); goto no_mem; } break; } #if !defined(SQLITE_OMIT_ANALYZE) && !defined(SQLITE_OMIT_PARSER) /* Opcode: LoadAnalysis P1 * * ** ** Read the sqlite_stat1 table for database P1 and load the content ** of that table into the internal index hash table. This will cause ** the analysis to be used when preparing all subsequent queries. */ case OP_LoadAnalysis: { /* no-push */ int iDb = pOp->p1; assert( iDb>=0 && iDb<db->nDb ); sqlite3AnalysisLoad(db, iDb); break; } #endif /* !defined(SQLITE_OMIT_ANALYZE) && !defined(SQLITE_OMIT_PARSER) */ /* Opcode: DropTable P1 * P3 ** ** Remove the internal (in-memory) data structures that describe ** the table named P3 in database P1. This is called after a table ** is dropped in order to keep the internal representation of the ** schema consistent with what is on disk. ................................................................................ #ifndef SQLITE_OMIT_SHARED_CACHE /* Opcode: TableLock P1 P2 P3 ** ** Obtain a lock on a particular table. This instruction is only used when ** the shared-cache feature is enabled. ** ** If P1 is not negative, then it is the index of the database ** in sqlite3.aDb[] and a read-lock is required. If P1 is negative, a ** write-lock is required. In this case the index of the database is the ** absolute value of P1 minus one (iDb = abs(P1) - 1;) and a write-lock is ** required. ** ** P2 contains the root-page of the table to lock. ** ................................................................................ ** of the program. It is only here for testing and debugging. ** On the other hand, it does burn CPU cycles every time through ** the evaluator loop. So we can leave it out when NDEBUG is defined. */ #ifndef NDEBUG /* Sanity checking on the top element of the stack */ if( pTos>=p->aStack ){ sqlite3VdbeMemSanity(pTos); } assert( pc>=-1 && pc<p->nOp ); #ifdef SQLITE_DEBUG /* Code for tracing the vdbe stack. */ if( p->trace && pTos>=p->aStack ){ int i; fprintf(p->trace, "Stack:"); ................................................................................ fprintf(p->trace, " si:%lld", pTos[i].i); }else if( pTos[i].flags & MEM_Int ){ fprintf(p->trace, " i:%lld", pTos[i].i); }else if( pTos[i].flags & MEM_Real ){ fprintf(p->trace, " r:%g", pTos[i].r); }else{ char zBuf[100]; sqlite3VdbeMemPrettyPrint(&pTos[i], zBuf); fprintf(p->trace, " "); fprintf(p->trace, "%s", zBuf); } } if( rc!=0 ) fprintf(p->trace," rc=%d",rc); fprintf(p->trace,"\n"); } |
Changes to SQLite.Interop/src/vdbe.h.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** ** $Id: vdbe.h,v 1.19 2006/02/11 14:43:40 rmsimpson Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ #include <stdio.h> /* ** A single VDBE is an opaque structure named "Vdbe". Only routines ................................................................................ void sqlite3VdbeCreateCallback(Vdbe*, int*); int sqlite3VdbeAddOp(Vdbe*,int,int,int); int sqlite3VdbeOp3(Vdbe*,int,int,int,const char *zP3,int); int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); void sqlite3VdbeJumpHere(Vdbe*, int addr); void sqlite3VdbeChangeP3(Vdbe*, int addr, const char *zP1, int N); VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); int sqlite3VdbeMakeLabel(Vdbe*); void sqlite3VdbeDelete(Vdbe*); void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int); int sqlite3VdbeFinalize(Vdbe*); void sqlite3VdbeResolveLabel(Vdbe*, int); |
|
>
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** ** $Id: vdbe.h,v 1.20 2006/04/11 18:06:58 rmsimpson Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ #include <stdio.h> /* ** A single VDBE is an opaque structure named "Vdbe". Only routines ................................................................................ void sqlite3VdbeCreateCallback(Vdbe*, int*); int sqlite3VdbeAddOp(Vdbe*,int,int,int); int sqlite3VdbeOp3(Vdbe*,int,int,int,const char *zP3,int); int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); void sqlite3VdbeJumpHere(Vdbe*, int addr); void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); void sqlite3VdbeChangeP3(Vdbe*, int addr, const char *zP1, int N); VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); int sqlite3VdbeMakeLabel(Vdbe*); void sqlite3VdbeDelete(Vdbe*); void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int); int sqlite3VdbeFinalize(Vdbe*); void sqlite3VdbeResolveLabel(Vdbe*, int); |
Changes to SQLite.Interop/src/vdbeInt.h.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 ... 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 ... 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 aborted; /* True if ROLLBACK in another VM causes an abort */ u8 expired; /* True if the VM needs to be recompiled */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */ }; /* ** The following are allowed values for Vdbe.magic */ #define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ #define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ ................................................................................ void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); int sqlite3VdbeIdxKeyCompare(Cursor*, int , const unsigned char*, int*); int sqlite3VdbeIdxRowid(BtCursor *, i64 *); int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); int sqlite3VdbeRecordCompare(void*,int,const void*,int, const void*); int sqlite3VdbeIdxRowidLen(int,const u8*); int sqlite3VdbeExec(Vdbe*); int sqlite3VdbeList(Vdbe*); int sqlite3VdbeHalt(Vdbe*); int sqlite3VdbeChangeEncoding(Mem *, int); int sqlite3VdbeMemCopy(Mem*, const Mem*); void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); int sqlite3VdbeMemMove(Mem*, Mem*); ................................................................................ void sqlite3VdbeIntegerAffinity(Mem*); int sqlite3VdbeMemRealify(Mem*); int sqlite3VdbeMemNumerify(Mem*); int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*); void sqlite3VdbeMemRelease(Mem *p); int sqlite3VdbeMemFinalize(Mem*, FuncDef*); #ifndef NDEBUG void sqlite3VdbeMemSanity(Mem*, u8); int sqlite3VdbeOpcodeNoPush(u8); #endif int sqlite3VdbeMemTranslate(Mem*, u8); void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf, int nBuf); int sqlite3VdbeMemHandleBom(Mem *pMem); void sqlite3VdbeFifoInit(Fifo*); int sqlite3VdbeFifoPush(Fifo*, i64); int sqlite3VdbeFifoPop(Fifo*, i64*); void sqlite3VdbeFifoClear(Fifo*); |
> > > > | | | |
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 ... 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 ... 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 aborted; /* True if ROLLBACK in another VM causes an abort */ u8 expired; /* True if the VM needs to be recompiled */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */ #ifdef SQLITE_SSE int fetchId; /* Statement number used by sqlite3_fetch_statement */ int lru; /* Counter used for LRU cache replacement */ #endif }; /* ** The following are allowed values for Vdbe.magic */ #define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ #define VDBE_MAGIC_RUN 0xbdf20da3 /* VDBE is ready to execute */ ................................................................................ void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); int sqlite3VdbeIdxKeyCompare(Cursor*, int , const unsigned char*, int*); int sqlite3VdbeIdxRowid(BtCursor *, i64 *); int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); int sqlite3VdbeRecordCompare(void*,int,const void*,int, const void*); int sqlite3VdbeIdxRowidLen(const u8*); int sqlite3VdbeExec(Vdbe*); int sqlite3VdbeList(Vdbe*); int sqlite3VdbeHalt(Vdbe*); int sqlite3VdbeChangeEncoding(Mem *, int); int sqlite3VdbeMemCopy(Mem*, const Mem*); void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); int sqlite3VdbeMemMove(Mem*, Mem*); ................................................................................ void sqlite3VdbeIntegerAffinity(Mem*); int sqlite3VdbeMemRealify(Mem*); int sqlite3VdbeMemNumerify(Mem*); int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*); void sqlite3VdbeMemRelease(Mem *p); int sqlite3VdbeMemFinalize(Mem*, FuncDef*); #ifndef NDEBUG void sqlite3VdbeMemSanity(Mem*); int sqlite3VdbeOpcodeNoPush(u8); #endif int sqlite3VdbeMemTranslate(Mem*, u8); void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); int sqlite3VdbeMemHandleBom(Mem *pMem); void sqlite3VdbeFifoInit(Fifo*); int sqlite3VdbeFifoPush(Fifo*, i64); int sqlite3VdbeFifoPop(Fifo*, i64*); void sqlite3VdbeFifoClear(Fifo*); |
Changes to SQLite.Interop/src/vdbeaux.c.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 ... 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 ... 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 ... 388 389 390 391 392 393 394 395 396 397 398 399 400 401 ... 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 ... 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 .... 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 .... 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 |
int sqlite3VdbeAddOp(Vdbe *p, int op, int p1, int p2){ int i; VdbeOp *pOp; i = p->nOp; p->nOp++; assert( p->magic==VDBE_MAGIC_INIT ); resizeOpArray(p, i+1); if( sqlite3MallocFailed() ){ return 0; } pOp = &p->aOp[i]; pOp->opcode = op; pOp->p1 = p1; pOp->p2 = p2; pOp->p3 = 0; pOp->p3type = P3_NOTUSED; ................................................................................ ** 16-bit bitmasks (rather than 32-bit) are specified in opcodes.h ** because the file is generated by an awk program. Awk manipulates ** all numbers as floating-point and we don't want to risk a rounding ** error if someone builds with an awk that uses (for example) 32-bit ** IEEE floats. */ static const u32 masks[5] = { NOPUSH_MASK_0 + (NOPUSH_MASK_1<<16), NOPUSH_MASK_2 + (NOPUSH_MASK_3<<16), NOPUSH_MASK_4 + (NOPUSH_MASK_5<<16), NOPUSH_MASK_6 + (NOPUSH_MASK_7<<16), NOPUSH_MASK_8 + (NOPUSH_MASK_9<<16) }; assert( op<32*5 ); return (masks[op>>5] & (1<<(op&0x1F))); } #ifndef NDEBUG int sqlite3VdbeOpcodeNoPush(u8 op){ ................................................................................ /* ** Change the value of the P1 operand for a specific instruction. ** This routine is useful when a large program is loaded from a ** static array using sqlite3VdbeAddOpList but we want to make a ** few minor changes to the program. */ void sqlite3VdbeChangeP1(Vdbe *p, int addr, int val){ assert( p->magic==VDBE_MAGIC_INIT ); if( p && addr>=0 && p->nOp>addr && p->aOp ){ p->aOp[addr].p1 = val; } } /* ** Change the value of the P2 operand for a specific instruction. ** This routine is useful for setting a jump destination. */ void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){ assert( val>=0 ); assert( p->magic==VDBE_MAGIC_INIT ); if( p && addr>=0 && p->nOp>addr && p->aOp ){ p->aOp[addr].p2 = val; } } /* ** Change teh P2 operand of instruction addr so that it points to ** the address of the next instruction to be coded. */ void sqlite3VdbeJumpHere(Vdbe *p, int addr){ sqlite3VdbeChangeP2(p, addr, p->nOp); } /* ................................................................................ sqlite3ValueFree((sqlite3_value*)p3); break; } } } } /* ** Change the value of the P3 operand for a specific instruction. ** This routine is useful when a large program is loaded from a ** static array using sqlite3VdbeAddOpList but we want to make a ** few minor changes to the program. ** ................................................................................ ** to a string or structure that is guaranteed to exist for the lifetime of ** the Vdbe. In these cases we can just copy the pointer. ** ** If addr<0 then change P3 on the most recently inserted instruction. */ void sqlite3VdbeChangeP3(Vdbe *p, int addr, const char *zP3, int n){ Op *pOp; assert( p->magic==VDBE_MAGIC_INIT ); if( p==0 || p->aOp==0 || sqlite3MallocFailed() ){ if (n != P3_KEYINFO) { freeP3(n, (void*)*(char**)&zP3); } return; } if( addr<0 || addr>=p->nOp ){ ................................................................................ pMem++; pMem->flags = MEM_Int; pMem->i = pOp->p2; /* P2 */ pMem->type = SQLITE_INTEGER; pMem++; pMem->flags = MEM_Short|MEM_Str|MEM_Term; /* P3 */ pMem->z = displayP3(pOp, pMem->zShort, sizeof(pMem->zShort)); pMem->type = SQLITE_TEXT; pMem->enc = SQLITE_UTF8; p->nResColumn = 5 - 2*(p->explain-1); p->pTos = pMem; p->rc = SQLITE_OK; p->resOnStack = 1; ................................................................................ /* ** The argument is an index entry composed using the OP_MakeRecord opcode. ** The last entry in this record should be an integer (specifically ** an integer rowid). This routine returns the number of bytes in ** that integer. */ int sqlite3VdbeIdxRowidLen(int nKey, const u8 *aKey){ u32 szHdr; /* Size of the header */ u32 typeRowid; /* Serial type of the rowid */ sqlite3GetVarint32(aKey, &szHdr); sqlite3GetVarint32(&aKey[szHdr-1], &typeRowid); return sqlite3VdbeSerialTypeLen(typeRowid); } ................................................................................ *res = 0; return SQLITE_OK; } rc = sqlite3VdbeMemFromBtree(pC->pCursor, 0, nCellKey, 1, &m); if( rc ){ return rc; } lenRowid = sqlite3VdbeIdxRowidLen(m.n, (u8*)m.z); *res = sqlite3VdbeRecordCompare(pC->pKeyInfo, m.n-lenRowid, m.z, nKey, pKey); sqlite3VdbeMemRelease(&m); return SQLITE_OK; } /* ** This routine sets the value to be returned by subsequent calls to |
> | | | > | | | | | | | | > > > > > > > > > > > > > | | > | | |
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 ... 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 ... 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 ... 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 ... 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 ... 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 .... 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 .... 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 |
int sqlite3VdbeAddOp(Vdbe *p, int op, int p1, int p2){ int i; VdbeOp *pOp; i = p->nOp; p->nOp++; assert( p->magic==VDBE_MAGIC_INIT ); if( p->nOpAlloc<=i ){ resizeOpArray(p, i+1); if( sqlite3MallocFailed() ){ return 0; } } pOp = &p->aOp[i]; pOp->opcode = op; pOp->p1 = p1; pOp->p2 = p2; pOp->p3 = 0; pOp->p3type = P3_NOTUSED; ................................................................................ ** 16-bit bitmasks (rather than 32-bit) are specified in opcodes.h ** because the file is generated by an awk program. Awk manipulates ** all numbers as floating-point and we don't want to risk a rounding ** error if someone builds with an awk that uses (for example) 32-bit ** IEEE floats. */ static const u32 masks[5] = { NOPUSH_MASK_0 + (((unsigned)NOPUSH_MASK_1)<<16), NOPUSH_MASK_2 + (((unsigned)NOPUSH_MASK_3)<<16), NOPUSH_MASK_4 + (((unsigned)NOPUSH_MASK_5)<<16), NOPUSH_MASK_6 + (((unsigned)NOPUSH_MASK_7)<<16), NOPUSH_MASK_8 + (((unsigned)NOPUSH_MASK_9)<<16) }; assert( op<32*5 ); return (masks[op>>5] & (1<<(op&0x1F))); } #ifndef NDEBUG int sqlite3VdbeOpcodeNoPush(u8 op){ ................................................................................ /* ** Change the value of the P1 operand for a specific instruction. ** This routine is useful when a large program is loaded from a ** static array using sqlite3VdbeAddOpList but we want to make a ** few minor changes to the program. */ void sqlite3VdbeChangeP1(Vdbe *p, int addr, int val){ assert( p==0 || p->magic==VDBE_MAGIC_INIT ); if( p && addr>=0 && p->nOp>addr && p->aOp ){ p->aOp[addr].p1 = val; } } /* ** Change the value of the P2 operand for a specific instruction. ** This routine is useful for setting a jump destination. */ void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){ assert( val>=0 ); assert( p==0 || p->magic==VDBE_MAGIC_INIT ); if( p && addr>=0 && p->nOp>addr && p->aOp ){ p->aOp[addr].p2 = val; } } /* ** Change the P2 operand of instruction addr so that it points to ** the address of the next instruction to be coded. */ void sqlite3VdbeJumpHere(Vdbe *p, int addr){ sqlite3VdbeChangeP2(p, addr, p->nOp); } /* ................................................................................ sqlite3ValueFree((sqlite3_value*)p3); break; } } } } /* ** Change N opcodes starting at addr to No-ops. */ void sqlite3VdbeChangeToNoop(Vdbe *p, int addr, int N){ VdbeOp *pOp = &p->aOp[addr]; while( N-- ){ freeP3(pOp->p3type, pOp->p3); memset(pOp, 0, sizeof(pOp[0])); pOp->opcode = OP_Noop; pOp++; } } /* ** Change the value of the P3 operand for a specific instruction. ** This routine is useful when a large program is loaded from a ** static array using sqlite3VdbeAddOpList but we want to make a ** few minor changes to the program. ** ................................................................................ ** to a string or structure that is guaranteed to exist for the lifetime of ** the Vdbe. In these cases we can just copy the pointer. ** ** If addr<0 then change P3 on the most recently inserted instruction. */ void sqlite3VdbeChangeP3(Vdbe *p, int addr, const char *zP3, int n){ Op *pOp; assert( p==0 || p->magic==VDBE_MAGIC_INIT ); if( p==0 || p->aOp==0 || sqlite3MallocFailed() ){ if (n != P3_KEYINFO) { freeP3(n, (void*)*(char**)&zP3); } return; } if( addr<0 || addr>=p->nOp ){ ................................................................................ pMem++; pMem->flags = MEM_Int; pMem->i = pOp->p2; /* P2 */ pMem->type = SQLITE_INTEGER; pMem++; pMem->flags = MEM_Ephem|MEM_Str|MEM_Term; /* P3 */ pMem->z = displayP3(pOp, pMem->zShort, sizeof(pMem->zShort)); pMem->n = strlen(pMem->z); pMem->type = SQLITE_TEXT; pMem->enc = SQLITE_UTF8; p->nResColumn = 5 - 2*(p->explain-1); p->pTos = pMem; p->rc = SQLITE_OK; p->resOnStack = 1; ................................................................................ /* ** The argument is an index entry composed using the OP_MakeRecord opcode. ** The last entry in this record should be an integer (specifically ** an integer rowid). This routine returns the number of bytes in ** that integer. */ int sqlite3VdbeIdxRowidLen(const u8 *aKey){ u32 szHdr; /* Size of the header */ u32 typeRowid; /* Serial type of the rowid */ sqlite3GetVarint32(aKey, &szHdr); sqlite3GetVarint32(&aKey[szHdr-1], &typeRowid); return sqlite3VdbeSerialTypeLen(typeRowid); } ................................................................................ *res = 0; return SQLITE_OK; } rc = sqlite3VdbeMemFromBtree(pC->pCursor, 0, nCellKey, 1, &m); if( rc ){ return rc; } lenRowid = sqlite3VdbeIdxRowidLen((u8*)m.z); *res = sqlite3VdbeRecordCompare(pC->pKeyInfo, m.n-lenRowid, m.z, nKey, pKey); sqlite3VdbeMemRelease(&m); return SQLITE_OK; } /* ** This routine sets the value to be returned by subsequent calls to |
Changes to SQLite.Interop/src/vdbemem.c.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 ... 114 115 116 117 118 119 120 121 122 123 124 125 126 127 ... 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 ... 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 ... 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
int rc; if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ return SQLITE_OK; } #ifdef SQLITE_OMIT_UTF16 return SQLITE_ERROR; #else /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, ** then the encoding of the value may not have changed. */ rc = sqlite3VdbeMemTranslate(pMem, desiredEnc); assert(rc==SQLITE_OK || rc==SQLITE_NOMEM); assert(rc==SQLITE_OK || pMem->enc!=desiredEnc); ................................................................................ pMem->xDel = 0; } memcpy(z, pMem->z, n ); z[n] = 0; z[n+1] = 0; pMem->z = (char*)z; pMem->flags &= ~(MEM_Ephem|MEM_Static); return SQLITE_OK; } /* ** Make sure the given Mem is \u0000 terminated. */ int sqlite3VdbeMemNulTerminate(Mem *pMem){ ................................................................................ ** the user deletes the collation sequence after the vdbe program is ** compiled (this was not always the case). */ assert( !pColl || pColl->xCmp ); if( pColl ){ if( pMem1->enc==pColl->enc ){ return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); }else{ u8 origEnc = pMem1->enc; rc = pColl->xCmp( pColl->pUser, sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc), sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc), sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc), sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc) ); sqlite3ValueBytes((sqlite3_value*)pMem1, origEnc); sqlite3ValueText((sqlite3_value*)pMem1, origEnc); sqlite3ValueBytes((sqlite3_value*)pMem2, origEnc); sqlite3ValueText((sqlite3_value*)pMem2, origEnc); return rc; } } /* If a NULL pointer was passed as the collate function, fall through ** to the blob case and use memcmp(). */ } ................................................................................ } #ifndef NDEBUG /* ** Perform various checks on the memory cell pMem. An assert() will ** fail if pMem is internally inconsistent. */ void sqlite3VdbeMemSanity(Mem *pMem, u8 db_enc){ int flags = pMem->flags; assert( flags!=0 ); /* Must define some type */ if( pMem->flags & (MEM_Str|MEM_Blob) ){ int x = pMem->flags & (MEM_Static|MEM_Dyn|MEM_Ephem|MEM_Short); assert( x!=0 ); /* Strings must define a string subtype */ assert( (x & (x-1))==0 ); /* Only one string subtype can be defined */ assert( pMem->z!=0 ); /* Strings must have a value */ ................................................................................ #endif /* This function is only available internally, it is not part of the ** external API. It works in a similar way to sqlite3_value_text(), ** except the data returned is in the encoding specified by the second ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or ** SQLITE_UTF8. */ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){ if( !pVal ) return 0; assert( enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE || enc==SQLITE_UTF8); if( pVal->flags&MEM_Null ){ return 0; } assert( (MEM_Blob>>3) == MEM_Str ); pVal->flags |= (pVal->flags & MEM_Blob)>>3; if( pVal->flags&MEM_Str ){ sqlite3VdbeChangeEncoding(pVal, enc); }else if( !(pVal->flags&MEM_Blob) ){ sqlite3VdbeMemStringify(pVal, enc); } assert(pVal->enc==enc || sqlite3MallocFailed() ); return (const void *)(pVal->enc==enc ? (pVal->z) : 0); } /* ** Create a new sqlite3_value object. */ sqlite3_value* sqlite3ValueNew(void){ Mem *p = sqliteMalloc(sizeof(*p)); |
> > > > | | | > | > | | < > | > > > < | > > > > | | > > > > > > > | < > > > > > |
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 ... 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 ... 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 ... 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 ... 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
int rc; if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ return SQLITE_OK; } #ifdef SQLITE_OMIT_UTF16 return SQLITE_ERROR; #else /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, ** then the encoding of the value may not have changed. */ rc = sqlite3VdbeMemTranslate(pMem, desiredEnc); assert(rc==SQLITE_OK || rc==SQLITE_NOMEM); assert(rc==SQLITE_OK || pMem->enc!=desiredEnc); ................................................................................ pMem->xDel = 0; } memcpy(z, pMem->z, n ); z[n] = 0; z[n+1] = 0; pMem->z = (char*)z; pMem->flags &= ~(MEM_Ephem|MEM_Static); assert(0==(1&(int)pMem->z)); return SQLITE_OK; } /* ** Make sure the given Mem is \u0000 terminated. */ int sqlite3VdbeMemNulTerminate(Mem *pMem){ ................................................................................ ** the user deletes the collation sequence after the vdbe program is ** compiled (this was not always the case). */ assert( !pColl || pColl->xCmp ); if( pColl ){ if( pMem1->enc==pColl->enc ){ /* The strings are already in the correct encoding. Call the ** comparison function directly */ return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); }else{ u8 origEnc = pMem1->enc; const void *v1, *v2; int n1, n2; /* Convert the strings into the encoding that the comparison ** function expects */ v1 = sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc); n1 = v1==0 ? 0 : pMem1->n; assert( n1==sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc) ); v2 = sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc); n2 = v2==0 ? 0 : pMem2->n; assert( n2==sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc) ); /* Do the comparison */ rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2); /* Convert the strings back into the database encoding */ sqlite3ValueText((sqlite3_value*)pMem1, origEnc); sqlite3ValueText((sqlite3_value*)pMem2, origEnc); return rc; } } /* If a NULL pointer was passed as the collate function, fall through ** to the blob case and use memcmp(). */ } ................................................................................ } #ifndef NDEBUG /* ** Perform various checks on the memory cell pMem. An assert() will ** fail if pMem is internally inconsistent. */ void sqlite3VdbeMemSanity(Mem *pMem){ int flags = pMem->flags; assert( flags!=0 ); /* Must define some type */ if( pMem->flags & (MEM_Str|MEM_Blob) ){ int x = pMem->flags & (MEM_Static|MEM_Dyn|MEM_Ephem|MEM_Short); assert( x!=0 ); /* Strings must define a string subtype */ assert( (x & (x-1))==0 ); /* Only one string subtype can be defined */ assert( pMem->z!=0 ); /* Strings must have a value */ ................................................................................ #endif /* This function is only available internally, it is not part of the ** external API. It works in a similar way to sqlite3_value_text(), ** except the data returned is in the encoding specified by the second ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or ** SQLITE_UTF8. ** ** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED. ** If that is the case, then the result must be aligned on an even byte ** boundary. */ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){ if( !pVal ) return 0; assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) ); if( pVal->flags&MEM_Null ){ return 0; } assert( (MEM_Blob>>3) == MEM_Str ); pVal->flags |= (pVal->flags & MEM_Blob)>>3; if( pVal->flags&MEM_Str ){ sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED); if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&(int)pVal->z) ){ assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 ); if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){ return 0; } } }else if( !(pVal->flags&MEM_Blob) ){ sqlite3VdbeMemStringify(pVal, enc); assert( 0==(1&(int)pVal->z) ); } assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || sqlite3MallocFailed() ); if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){ return pVal->z; }else{ return 0; } } /* ** Create a new sqlite3_value object. */ sqlite3_value* sqlite3ValueNew(void){ Mem *p = sqliteMalloc(sizeof(*p)); |
Changes to SQLite.Interop/src/where.c.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ... 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 ... 923 924 925 926 927 928 929 930 931 932 933 934 935 936 ... 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 .... 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 .... 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 |
** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** ** $Id: where.c,v 1.21 2006/02/11 14:43:40 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". */ #define BMS (sizeof(Bitmask)*8) ................................................................................ ** index do not need to satisfy this constraint.) The *pbRev value is ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if ** the ORDER BY clause is all ASC. */ static int isSortingIndex( Parse *pParse, /* Parsing context */ Index *pIdx, /* The index we are testing */ Table *pTab, /* The table to be sorted */ int base, /* Cursor number for pTab */ ExprList *pOrderBy, /* The ORDER BY clause */ int nEqCol, /* Number of index columns with == constraints */ int *pbRev /* Set to 1 if ORDER BY is DESC */ ){ int i, j; /* Loop counters */ int sortOrder = 0; /* XOR of index and ORDER BY sort direction */ int nTerm; /* Number of ORDER BY terms */ ................................................................................ int rev; /* True to scan in reverse order */ int flags; /* Flags associated with pProbe */ int nEq; /* Number of == or IN constraints */ double cost; /* Cost of using pProbe */ TRACE(("bestIndex: tbl=%s notReady=%x\n", pSrc->pTab->zName, notReady)); lowestCost = SQLITE_BIG_DBL; /* Check for a rowid=EXPR or rowid IN (...) constraints */ pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0); if( pTerm ){ Expr *pExpr; *ppIndex = 0; ................................................................................ } TRACE(("... rowid IN cost: %.9g\n", lowestCost)); } /* Estimate the cost of a table scan. If we do not know how many ** entries are in the table, use 1 million as a guess. */ pProbe = pSrc->pTab->pIndex; cost = pProbe ? pProbe->aiRowEst[0] : 1000000; TRACE(("... table scan base cost: %.9g\n", cost)); flags = WHERE_ROWID_RANGE; /* Check for constraints on a range of rowids in a table scan. */ pTerm = findTerm(pWC, iCur, -1, notReady, WO_LT|WO_LE|WO_GT|WO_GE, 0); ................................................................................ } } /* Add the additional cost of sorting if that is a factor. */ if( pOrderBy ){ if( (flags & WHERE_COLUMN_IN)==0 && isSortingIndex(pParse,pProbe,pSrc->pTab,iCur,pOrderBy,nEq,&rev) ){ if( flags==0 ){ flags = WHERE_COLUMN_RANGE; } flags |= WHERE_ORDERBY; if( rev ){ flags |= WHERE_REVERSE; } ................................................................................ iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); if( pTab->isTransient || pTab->pSelect ) continue; if( (pLevel->flags & WHERE_IDX_ONLY)==0 ){ sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, OP_OpenRead); if( pTab->nCol<(sizeof(Bitmask)*8) ){ Bitmask b = pTabItem->colUsed; int n = 0; for(; b; b=b>>1, n++); sqlite3VdbeChangeP2(v, sqlite3VdbeCurrentAddr(v)-1, n); assert( n<=pTab->nCol ); } }else{ sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); } pLevel->iTabCur = pTabItem->iCursor; |
| < | > > > > > > > > > > > > > > > > < | | |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ... 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 ... 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 ... 970 971 972 973 974 975 976 977 978 979 980 981 982 983 .... 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 .... 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 |
** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** ** $Id: where.c,v 1.22 2006/04/11 18:06:58 rmsimpson Exp $ */ #include "sqliteInt.h" /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". */ #define BMS (sizeof(Bitmask)*8) ................................................................................ ** index do not need to satisfy this constraint.) The *pbRev value is ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if ** the ORDER BY clause is all ASC. */ static int isSortingIndex( Parse *pParse, /* Parsing context */ Index *pIdx, /* The index we are testing */ int base, /* Cursor number for the table to be sorted */ ExprList *pOrderBy, /* The ORDER BY clause */ int nEqCol, /* Number of index columns with == constraints */ int *pbRev /* Set to 1 if ORDER BY is DESC */ ){ int i, j; /* Loop counters */ int sortOrder = 0; /* XOR of index and ORDER BY sort direction */ int nTerm; /* Number of ORDER BY terms */ ................................................................................ int rev; /* True to scan in reverse order */ int flags; /* Flags associated with pProbe */ int nEq; /* Number of == or IN constraints */ double cost; /* Cost of using pProbe */ TRACE(("bestIndex: tbl=%s notReady=%x\n", pSrc->pTab->zName, notReady)); lowestCost = SQLITE_BIG_DBL; pProbe = pSrc->pTab->pIndex; /* If the table has no indices and there are no terms in the where ** clause that refer to the ROWID, then we will never be able to do ** anything other than a full table scan on this table. We might as ** well put it first in the join order. That way, perhaps it can be ** referenced by other tables in the join. */ if( pProbe==0 && findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IN|WO_LT|WO_LE|WO_GT|WO_GE,0)==0 && (pOrderBy==0 || !sortableByRowid(iCur, pOrderBy, &rev)) ){ *pFlags = 0; *ppIndex = 0; *pnEq = 0; return 0.0; } /* Check for a rowid=EXPR or rowid IN (...) constraints */ pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0); if( pTerm ){ Expr *pExpr; *ppIndex = 0; ................................................................................ } TRACE(("... rowid IN cost: %.9g\n", lowestCost)); } /* Estimate the cost of a table scan. If we do not know how many ** entries are in the table, use 1 million as a guess. */ cost = pProbe ? pProbe->aiRowEst[0] : 1000000; TRACE(("... table scan base cost: %.9g\n", cost)); flags = WHERE_ROWID_RANGE; /* Check for constraints on a range of rowids in a table scan. */ pTerm = findTerm(pWC, iCur, -1, notReady, WO_LT|WO_LE|WO_GT|WO_GE, 0); ................................................................................ } } /* Add the additional cost of sorting if that is a factor. */ if( pOrderBy ){ if( (flags & WHERE_COLUMN_IN)==0 && isSortingIndex(pParse,pProbe,iCur,pOrderBy,nEq,&rev) ){ if( flags==0 ){ flags = WHERE_COLUMN_RANGE; } flags |= WHERE_ORDERBY; if( rev ){ flags |= WHERE_REVERSE; } ................................................................................ iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); if( pTab->isTransient || pTab->pSelect ) continue; if( (pLevel->flags & WHERE_IDX_ONLY)==0 ){ sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, OP_OpenRead); if( pTab->nCol<(sizeof(Bitmask)*8) ){ Bitmask b = pTabItem->colUsed; int n = 0; for(; b; b=b>>1, n++){} sqlite3VdbeChangeP2(v, sqlite3VdbeCurrentAddr(v)-1, n); assert( n<=pTab->nCol ); } }else{ sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); } pLevel->iTabCur = pTabItem->iCursor; |