Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change all instances of "it's" in comments to either "its" or "it is", as appropriate, in case the comments are ever again read by a pedantic grammarian. Ticket #2840. (CVS 4629) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4e91a267febda572e7239f0f1cc66b31 |
User & Date: | drh 2007-12-13 21:54:10.000 |
Context
2007-12-14
| ||
15:12 | Fix an out-of-memory NULL pointer defer in the code generator. Ticket #2843. (CVS 4630) (check-in: b821b6ed17 user: drh tags: trunk) | |
2007-12-13
| ||
21:54 | Change all instances of "it's" in comments to either "its" or "it is", as appropriate, in case the comments are ever again read by a pedantic grammarian. Ticket #2840. (CVS 4629) (check-in: 4e91a267fe user: drh tags: trunk) | |
19:15 | Fix a memory leak that can occur following a malloc() failure. (CVS 4628) (check-in: 993a213024 user: danielk1977 tags: trunk) | |
Changes
Changes to ext/fts1/fts1.c.
︙ | ︙ | |||
873 874 875 876 877 878 879 | char *str = malloc(n + 1); memcpy(str, s, n); str[n] = '\0'; return str; } /* Duplicate a string; the caller must free() the returned string. | | | 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | char *str = malloc(n + 1); memcpy(str, s, n); str[n] = '\0'; return str; } /* Duplicate a string; the caller must free() the returned string. * (We don't use strdup() since it is not part of the standard C library and * may not be available everywhere.) */ static char *string_dup(const char *s){ return string_dup_n(s, strlen(s)); } /* Format a string, replacing each occurrence of the % character with * zDb.zName. This may be more convenient than sqlite_mprintf() |
︙ | ︙ | |||
3142 3143 3144 3145 3146 3147 3148 | rc = content_update(v, pValues, iRow); /* execute an SQL UPDATE */ if( rc!=SQLITE_OK ) return rc; /* Now add positions for terms which appear in the updated row. */ return insertTerms(v, pTerms, iRow, pValues); } | | | 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 | rc = content_update(v, pValues, iRow); /* execute an SQL UPDATE */ if( rc!=SQLITE_OK ) return rc; /* Now add positions for terms which appear in the updated row. */ return insertTerms(v, pTerms, iRow, pValues); } /* This function implements the xUpdate callback; it is the top-level entry * point for inserting, deleting or updating a row in a full-text table. */ static int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg, sqlite_int64 *pRowid){ fulltext_vtab *v = (fulltext_vtab *) pVtab; fts1Hash terms; /* maps term string -> PosList */ int rc; fts1HashElem *e; |
︙ | ︙ |
Changes to ext/fts2/README.tokenizers.
︙ | ︙ | |||
71 72 73 74 75 76 77 | The ICU tokenizer implementation is very simple. It splits the input text according to the ICU rules for finding word boundaries and discards any tokens that consist entirely of white-space. This may be suitable for some applications in some locales, but not all. If more complex processing is required, for example to implement stemming or discard punctuation, this can be done by creating a tokenizer | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | The ICU tokenizer implementation is very simple. It splits the input text according to the ICU rules for finding word boundaries and discards any tokens that consist entirely of white-space. This may be suitable for some applications in some locales, but not all. If more complex processing is required, for example to implement stemming or discard punctuation, this can be done by creating a tokenizer implementation that uses the ICU tokenizer as part of its implementation. When using the ICU tokenizer this way, it is safe to overwrite the contents of the strings returned by the xNext() method (see fts2_tokenizer.h). 4. Sample code. |
︙ | ︙ | |||
127 128 129 130 131 132 133 | if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){ memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); } } return sqlite3_finalize(pStmt); } | < | 127 128 129 130 131 132 133 | if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){ memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); } } return sqlite3_finalize(pStmt); } |
Changes to ext/fts2/fts2.c.
︙ | ︙ | |||
270 271 272 273 274 275 276 | ** ** This appears to have only a moderate impact on queries for very ** frequent terms (which are somewhat dominated by segment merge ** costs), and infrequent and non-existent terms still seem to be fast ** even with many segments. ** ** TODO(shess) That said, it would be nice to have a better query-side | | | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | ** ** This appears to have only a moderate impact on queries for very ** frequent terms (which are somewhat dominated by segment merge ** costs), and infrequent and non-existent terms still seem to be fast ** even with many segments. ** ** TODO(shess) That said, it would be nice to have a better query-side ** argument for MERGE_COUNT of 16. Also, it is possible/likely that ** optimizations to things like doclist merging will swing the sweet ** spot around. ** ** ** **** Handling of deletions and updates **** ** Since we're using a segmented structure, with no docid-oriented |
︙ | ︙ | |||
690 691 692 693 694 695 696 | } static void dlrDestroy(DLReader *pReader){ SCRAMBLE(pReader); } #ifndef NDEBUG /* Verify that the doclist can be validly decoded. Also returns the | | | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | } static void dlrDestroy(DLReader *pReader){ SCRAMBLE(pReader); } #ifndef NDEBUG /* Verify that the doclist can be validly decoded. Also returns the ** last docid found because it is convenient in other assertions for ** DLWriter. */ static void docListValidate(DocListType iType, const char *pData, int nData, sqlite_int64 *pLastDocid){ sqlite_int64 iPrevDocid = 0; assert( nData>0 ); assert( pData!=0 ); |
︙ | ︙ | |||
1053 1054 1055 1056 1057 1058 1059 | DLWriter dlw; PLWriter plw; } DLCollector; /* TODO(shess) This could also be done by calling plwTerminate() and ** dataBufferAppend(). I tried that, expecting nominal performance ** differences, but it seemed to pretty reliably be worth 1% to code | | | 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 | DLWriter dlw; PLWriter plw; } DLCollector; /* TODO(shess) This could also be done by calling plwTerminate() and ** dataBufferAppend(). I tried that, expecting nominal performance ** differences, but it seemed to pretty reliably be worth 1% to code ** it this way. I suspect it is the incremental malloc overhead (some ** percentage of the plwTerminate() calls will cause a realloc), so ** this might be worth revisiting if the DataBuffer implementation ** changes. */ static void dlcAddDoclist(DLCollector *pCollector, DataBuffer *b){ if( pCollector->dlw.iType>DL_DOCIDS ){ char c[VARINT_MAX]; |
︙ | ︙ | |||
1611 1612 1613 1614 1615 1616 1617 | char *str = malloc(n + 1); memcpy(str, s, n); str[n] = '\0'; return str; } /* Duplicate a string; the caller must free() the returned string. | | | 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 | char *str = malloc(n + 1); memcpy(str, s, n); str[n] = '\0'; return str; } /* Duplicate a string; the caller must free() the returned string. * (We don't use strdup() since it is not part of the standard C library and * may not be available everywhere.) */ static char *string_dup(const char *s){ return string_dup_n(s, strlen(s)); } /* Format a string, replacing each occurrence of the % character with * zDb.zName. This may be more convenient than sqlite_mprintf() |
︙ | ︙ | |||
5299 5300 5301 5302 5303 5304 5305 | ** interior node terms logically come between the blocks, so there is ** one more blockid than there are terms (that block contains terms >= ** the last interior-node term). */ /* TODO(shess) The calling code may already know that the end child is ** not worth calculating, because the end may be in a later sibling ** node. Consider whether breaking symmetry is worthwhile. I suspect | | | 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 | ** interior node terms logically come between the blocks, so there is ** one more blockid than there are terms (that block contains terms >= ** the last interior-node term). */ /* TODO(shess) The calling code may already know that the end child is ** not worth calculating, because the end may be in a later sibling ** node. Consider whether breaking symmetry is worthwhile. I suspect ** it is not worthwhile. */ static void getChildrenContaining(const char *pData, int nData, const char *pTerm, int nTerm, int isPrefix, sqlite_int64 *piStartChild, sqlite_int64 *piEndChild){ InteriorReader reader; |
︙ | ︙ | |||
5642 5643 5644 5645 5646 5647 5648 | fts2HashInit(&v->pendingTerms, FTS2_HASH_STRING, 1); v->nPendingData = 0; } v->iPrevDocid = iDocid; return SQLITE_OK; } | | | 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 | fts2HashInit(&v->pendingTerms, FTS2_HASH_STRING, 1); v->nPendingData = 0; } v->iPrevDocid = iDocid; return SQLITE_OK; } /* This function implements the xUpdate callback; it is the top-level entry * point for inserting, deleting or updating a row in a full-text table. */ static int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg, sqlite_int64 *pRowid){ fulltext_vtab *v = (fulltext_vtab *) pVtab; int rc; TRACE(("FTS2 Update %p\n", pVtab)); |
︙ | ︙ |
Changes to ext/fts3/README.tokenizers.
︙ | ︙ | |||
71 72 73 74 75 76 77 | The ICU tokenizer implementation is very simple. It splits the input text according to the ICU rules for finding word boundaries and discards any tokens that consist entirely of white-space. This may be suitable for some applications in some locales, but not all. If more complex processing is required, for example to implement stemming or discard punctuation, this can be done by creating a tokenizer | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | The ICU tokenizer implementation is very simple. It splits the input text according to the ICU rules for finding word boundaries and discards any tokens that consist entirely of white-space. This may be suitable for some applications in some locales, but not all. If more complex processing is required, for example to implement stemming or discard punctuation, this can be done by creating a tokenizer implementation that uses the ICU tokenizer as part of its implementation. When using the ICU tokenizer this way, it is safe to overwrite the contents of the strings returned by the xNext() method (see fts3_tokenizer.h). 4. Sample code. |
︙ | ︙ | |||
127 128 129 130 131 132 133 | if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){ memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); } } return sqlite3_finalize(pStmt); } | < | 127 128 129 130 131 132 133 | if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){ memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); } } return sqlite3_finalize(pStmt); } |
Changes to ext/fts3/fts3.c.
︙ | ︙ | |||
246 247 248 249 250 251 252 | ** ** This appears to have only a moderate impact on queries for very ** frequent terms (which are somewhat dominated by segment merge ** costs), and infrequent and non-existent terms still seem to be fast ** even with many segments. ** ** TODO(shess) That said, it would be nice to have a better query-side | | | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | ** ** This appears to have only a moderate impact on queries for very ** frequent terms (which are somewhat dominated by segment merge ** costs), and infrequent and non-existent terms still seem to be fast ** even with many segments. ** ** TODO(shess) That said, it would be nice to have a better query-side ** argument for MERGE_COUNT of 16. Also, it is possible/likely that ** optimizations to things like doclist merging will swing the sweet ** spot around. ** ** ** **** Handling of deletions and updates **** ** Since we're using a segmented structure, with no docid-oriented |
︙ | ︙ | |||
678 679 680 681 682 683 684 | } static void dlrDestroy(DLReader *pReader){ SCRAMBLE(pReader); } #ifndef NDEBUG /* Verify that the doclist can be validly decoded. Also returns the | | | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | } static void dlrDestroy(DLReader *pReader){ SCRAMBLE(pReader); } #ifndef NDEBUG /* Verify that the doclist can be validly decoded. Also returns the ** last docid found because it is convenient in other assertions for ** DLWriter. */ static void docListValidate(DocListType iType, const char *pData, int nData, sqlite_int64 *pLastDocid){ sqlite_int64 iPrevDocid = 0; assert( nData>0 ); assert( pData!=0 ); |
︙ | ︙ | |||
1041 1042 1043 1044 1045 1046 1047 | DLWriter dlw; PLWriter plw; } DLCollector; /* TODO(shess) This could also be done by calling plwTerminate() and ** dataBufferAppend(). I tried that, expecting nominal performance ** differences, but it seemed to pretty reliably be worth 1% to code | | | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | DLWriter dlw; PLWriter plw; } DLCollector; /* TODO(shess) This could also be done by calling plwTerminate() and ** dataBufferAppend(). I tried that, expecting nominal performance ** differences, but it seemed to pretty reliably be worth 1% to code ** it this way. I suspect it is the incremental malloc overhead (some ** percentage of the plwTerminate() calls will cause a realloc), so ** this might be worth revisiting if the DataBuffer implementation ** changes. */ static void dlcAddDoclist(DLCollector *pCollector, DataBuffer *b){ if( pCollector->dlw.iType>DL_DOCIDS ){ char c[VARINT_MAX]; |
︙ | ︙ | |||
1716 1717 1718 1719 1720 1721 1722 | char *str = sqlite3_malloc(n + 1); memcpy(str, s, n); str[n] = '\0'; return str; } /* Duplicate a string; the caller must free() the returned string. | | | 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 | char *str = sqlite3_malloc(n + 1); memcpy(str, s, n); str[n] = '\0'; return str; } /* Duplicate a string; the caller must free() the returned string. * (We don't use strdup() since it is not part of the standard C library and * may not be available everywhere.) */ static char *string_dup(const char *s){ return string_dup_n(s, strlen(s)); } /* Format a string, replacing each occurrence of the % character with * zDb.zName. This may be more convenient than sqlite_mprintf() |
︙ | ︙ | |||
1799 1800 1801 1802 1803 1804 1805 | ** of the same phrase, or connected by the NEAR operator. ** ** If the QueryTerm.nNear variable is non-zero, then the token is followed ** by a NEAR operator with span set to (nNear-1). For example, the ** following query: ** ** The QueryTerm.iPhrase variable stores the index of the token within | | | 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 | ** of the same phrase, or connected by the NEAR operator. ** ** If the QueryTerm.nNear variable is non-zero, then the token is followed ** by a NEAR operator with span set to (nNear-1). For example, the ** following query: ** ** The QueryTerm.iPhrase variable stores the index of the token within ** its phrase, indexed starting at 1, or 1 if the token is not part ** of any phrase. ** ** For example, the data structure used to represent the following query: ** ** ... MATCH 'sqlite NEAR/5 google NEAR/2 "search engine"' ** ** is: |
︙ | ︙ | |||
5744 5745 5746 5747 5748 5749 5750 | ** interior node terms logically come between the blocks, so there is ** one more blockid than there are terms (that block contains terms >= ** the last interior-node term). */ /* TODO(shess) The calling code may already know that the end child is ** not worth calculating, because the end may be in a later sibling ** node. Consider whether breaking symmetry is worthwhile. I suspect | | | 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 | ** interior node terms logically come between the blocks, so there is ** one more blockid than there are terms (that block contains terms >= ** the last interior-node term). */ /* TODO(shess) The calling code may already know that the end child is ** not worth calculating, because the end may be in a later sibling ** node. Consider whether breaking symmetry is worthwhile. I suspect ** it is not worthwhile. */ static void getChildrenContaining(const char *pData, int nData, const char *pTerm, int nTerm, int isPrefix, sqlite_int64 *piStartChild, sqlite_int64 *piEndChild){ InteriorReader reader; |
︙ | ︙ | |||
6087 6088 6089 6090 6091 6092 6093 | fts3HashInit(&v->pendingTerms, FTS3_HASH_STRING, 1); v->nPendingData = 0; } v->iPrevDocid = iDocid; return SQLITE_OK; } | | | 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 | fts3HashInit(&v->pendingTerms, FTS3_HASH_STRING, 1); v->nPendingData = 0; } v->iPrevDocid = iDocid; return SQLITE_OK; } /* This function implements the xUpdate callback; it is the top-level entry * point for inserting, deleting or updating a row in a full-text table. */ static int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg, sqlite_int64 *pRowid){ fulltext_vtab *v = (fulltext_vtab *) pVtab; int rc; FTSTRACE(("FTS3 Update %p\n", pVtab)); |
︙ | ︙ |
Changes to ext/icu/icu.c.
1 2 3 4 5 6 7 8 9 10 11 | /* ** 2007 May 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* ** 2007 May 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** $Id: icu.c,v 1.7 2007/12/13 21:54:11 drh Exp $ ** ** This file implements an integration between the ICU library ** ("International Components for Unicode", an open-source library ** for handling unicode data) and SQLite. The integration uses ** ICU to provide the following to SQLite: ** ** * An implementation of the SQL regexp() function (and hence REGEXP |
︙ | ︙ | |||
294 295 296 297 298 299 300 | /* Return 1 or 0. */ sqlite3_result_int(p, res ? 1 : 0); } /* ** Implementations of scalar functions for case mapping - upper() and | | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | /* Return 1 or 0. */ sqlite3_result_int(p, res ? 1 : 0); } /* ** Implementations of scalar functions for case mapping - upper() and ** lower(). Function upper() converts its input to upper-case (ABC). ** Function lower() converts to lower-case (abc). ** ** ICU provides two types of case mapping, "general" case mapping and ** "language specific". Refer to ICU documentation for the differences ** between the two. ** ** To utilise "general" case mapping, the upper() or lower() scalar |
︙ | ︙ |
Changes to src/alter.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** | | | 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.35 2007/12/13 21:54:11 drh 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. |
︙ | ︙ | |||
65 66 67 68 69 70 71 | } /* Store the token that zCsr points to in tname. */ tname.z = zCsr; tname.n = len; /* Advance zCsr to the next token. Store that token type in 'token', | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | } /* Store the token that zCsr points to in tname. */ tname.z = zCsr; tname.n = len; /* Advance zCsr to the next token. Store that token type in 'token', ** and its length in 'len' (to be used next iteration of this loop). */ do { zCsr += len; len = sqlite3GetToken(zCsr, &token); } while( token==TK_SPACE ); assert( len>0 ); } while( token!=TK_LP && token!=TK_USING ); |
︙ | ︙ | |||
123 124 125 126 127 128 129 | } /* Store the token that zCsr points to in tname. */ tname.z = zCsr; tname.n = len; /* Advance zCsr to the next token. Store that token type in 'token', | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | } /* Store the token that zCsr points to in tname. */ tname.z = zCsr; tname.n = len; /* Advance zCsr to the next token. Store that token type in 'token', ** and its length in 'len' (to be used next iteration of this loop). */ do { zCsr += len; len = sqlite3GetToken(zCsr, &token); }while( token==TK_SPACE ); assert( len>0 ); |
︙ | ︙ |
Changes to src/btree.c.
1 2 3 4 5 6 7 8 9 10 11 | /* ** 2004 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* ** 2004 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** $Id: btree.c,v 1.433 2007/12/13 21:54:11 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. ** Including a description of file format and an overview of operation. */ #include "btreeInt.h" |
︙ | ︙ | |||
346 347 348 349 350 351 352 | ** Restore the cursor to the position it was in (or as close to as possible) ** when saveCursorPosition() was called. Note that this call deletes the ** saved position info stored by saveCursorPosition(), so there can be ** at most one effective restoreOrClearCursorPosition() call after each ** saveCursorPosition(). ** ** If the second argument argument - doSeek - is false, then instead of | | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | ** Restore the cursor to the position it was in (or as close to as possible) ** when saveCursorPosition() was called. Note that this call deletes the ** saved position info stored by saveCursorPosition(), so there can be ** at most one effective restoreOrClearCursorPosition() call after each ** saveCursorPosition(). ** ** If the second argument argument - doSeek - is false, then instead of ** returning the cursor to its saved position, any saved position is deleted ** and the cursor state set to CURSOR_INVALID. */ int sqlite3BtreeRestoreOrClearCursorPosition(BtCursor *pCur){ int rc; assert( cursorHoldsMutex(pCur) ); assert( pCur->eState>=CURSOR_REQUIRESEEK ); if( pCur->eState==CURSOR_FAULT ){ |
︙ | ︙ | |||
2019 2020 2021 2022 2023 2024 2025 | int rc; assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ); assert( sqlite3_mutex_held(pBt->mutex) ); assert( pDbPage->pBt==pBt ); | | | 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | int rc; assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ); assert( sqlite3_mutex_held(pBt->mutex) ); assert( pDbPage->pBt==pBt ); /* Move page iDbPage from its current location to page number iFreePage */ TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n", iDbPage, iFreePage, iPtrPage, eType)); rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage); if( rc!=SQLITE_OK ){ return rc; } pDbPage->pgno = iFreePage; |
︙ | ︙ | |||
2893 2894 2895 2896 2897 2898 2899 | ** linked list of overflow pages. If possible, it uses the auto-vacuum ** pointer-map data instead of reading the content of page ovfl to do so. ** ** If an error occurs an SQLite error code is returned. Otherwise: ** ** Unless pPgnoNext is NULL, the page number of the next overflow ** page in the linked list is written to *pPgnoNext. If page ovfl | | | 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 | ** linked list of overflow pages. If possible, it uses the auto-vacuum ** pointer-map data instead of reading the content of page ovfl to do so. ** ** If an error occurs an SQLite error code is returned. Otherwise: ** ** Unless pPgnoNext is NULL, the page number of the next overflow ** page in the linked list is written to *pPgnoNext. If page ovfl ** is the last page in its linked list, *pPgnoNext is set to zero. ** ** If ppPage is not NULL, *ppPage is set to the MemPage* handle ** for page ovfl. The underlying pager page may have been requested ** with the noContent flag set, so the page data accessable via ** this handle may not be trusted. */ static int getOverflowPage( |
︙ | ︙ | |||
5216 5217 5218 5219 5220 5221 5222 | pTemp = 0; }else{ pCell -= 4; pTemp = &aSpace[iSpace]; iSpace += sz; assert( iSpace<=pBt->pageSize*5 ); /* Obscure case for non-leaf-data trees: If the cell at pCell was | | | | 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 | pTemp = 0; }else{ pCell -= 4; pTemp = &aSpace[iSpace]; iSpace += sz; assert( iSpace<=pBt->pageSize*5 ); /* Obscure case for non-leaf-data trees: If the cell at pCell was ** previously stored on a leaf node, and its reported size was 4 ** bytes, then it may actually be smaller than this ** (see sqlite3BtreeParseCellPtr(), 4 bytes is the minimum size of ** any cell). But it is important to pass the correct size to ** insertCell(), so reparse the cell now. ** ** Note that this can never happen in an SQLite data file, as all ** cells are at least 4 bytes. It only happens in b-trees used ** to evaluate "IN (SELECT ...)" and similar clauses. */ if( szCell[j]==4 ){ |
︙ | ︙ | |||
5671 5672 5673 5674 5675 5676 5677 | (rc = restoreOrClearCursorPosition(pCur))!=0 || (rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur))!=0 || (rc = sqlite3PagerWrite(pPage->pDbPage))!=0 ){ return rc; } | | | 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 | (rc = restoreOrClearCursorPosition(pCur))!=0 || (rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur))!=0 || (rc = sqlite3PagerWrite(pPage->pDbPage))!=0 ){ return rc; } /* Locate the cell within its page and leave pCell pointing to the ** data. The clearCell() call frees any overflow pages associated with the ** cell. The cell itself is still intact. */ pCell = findCell(pPage, pCur->idx); if( !pPage->leaf ){ pgnoChild = get4byte(pCell); } |
︙ | ︙ | |||
6786 6787 6788 6789 6790 6791 6792 | int sqlite3BtreeIsInReadTrans(Btree *p){ assert( sqlite3_mutex_held(p->db->mutex) ); return (p && (p->inTrans!=TRANS_NONE)); } /* ** This function returns a pointer to a blob of memory associated with | | | 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 | int sqlite3BtreeIsInReadTrans(Btree *p){ assert( sqlite3_mutex_held(p->db->mutex) ); return (p && (p->inTrans!=TRANS_NONE)); } /* ** This function returns a pointer to a blob of memory associated with ** a single shared-btree. The memory is used by client code for its own ** purposes (for example, to store a high-level schema associated with ** the shared-btree). The btree layer manages reference counting issues. ** ** The first time this is called on a shared-btree, nBytes bytes of memory ** are allocated, zeroed, and returned to the caller. For each subsequent ** call the nBytes parameter is ignored and a pointer to the same blob ** of memory returned. |
︙ | ︙ |
Changes to src/expr.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: expr.c,v 1.319 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Return the 'affinity' of the expression pExpr if any. ** |
︙ | ︙ | |||
1528 1529 1530 1531 1532 1533 1534 | #define sqlite3_enable_in_opt 1 #endif /* ** This function is used by the implementation of the IN (...) operator. ** It's job is to find or create a b-tree structure that may be used ** either to test for membership of the (...) set or to iterate through | | | | 1528 1529 1530 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 1559 1560 1561 | #define sqlite3_enable_in_opt 1 #endif /* ** This function is used by the implementation of the IN (...) operator. ** It's job is to find or create a b-tree structure that may be used ** either to test for membership of the (...) set or to iterate through ** its members, skipping duplicates. ** ** The cursor opened on the structure (database table, database index ** or ephermal table) is stored in pX->iTable before this function returns. ** The returned value indicates the structure type, as follows: ** ** IN_INDEX_ROWID - The cursor was opened on a database table. ** IN_INDEX_INDEX - The cursor was opened on a database indec. ** IN_INDEX_EPH - The cursor was opened on a specially created and ** populated epheremal table. ** ** An existing structure may only be used if the SELECT is of the simple ** form: ** ** SELECT <column> FROM <table> ** ** If the mustBeUnique parameter is false, the structure will be used ** for fast set membership tests. In this case an epheremal table must ** be used unless <column> is an INTEGER PRIMARY KEY or an index can ** be found with <column> as its left-most column. ** ** If mustBeUnique is true, then the structure will be used to iterate ** through the set members, skipping any duplicates. In this case an ** epheremal table must be used unless the selected <column> is guaranteed ** to be unique - either because it is an INTEGER PRIMARY KEY or it ** is unique by virtue of a constraint or implicit index. */ |
︙ | ︙ |
Changes to src/func.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** 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. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** 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.181 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include <stdlib.h> #include <assert.h> #include "vdbeInt.h" |
︙ | ︙ | |||
1168 1169 1170 1171 1172 1173 1174 | sqlite3_result_text(pCtx, zRet, 2*nArg-1, free_test_auxdata); } #endif /* SQLITE_TEST */ #ifdef SQLITE_TEST /* ** A function to test error reporting from user functions. This function | | | 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 | sqlite3_result_text(pCtx, zRet, 2*nArg-1, free_test_auxdata); } #endif /* SQLITE_TEST */ #ifdef SQLITE_TEST /* ** A function to test error reporting from user functions. This function ** returns a copy of its first argument as an error. */ static void test_error( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ sqlite3_result_error(pCtx, (char*)sqlite3_value_text(argv[0]), 0); |
︙ | ︙ |
Changes to src/os_os2.c.
︙ | ︙ | |||
538 539 540 541 542 543 544 | /* ** Return the sector size in bytes of the underlying block device for ** the specified file. This is almost always 512 bytes, but may be ** larger for some devices. ** ** SQLite code assumes this function cannot fail. It also assumes that ** if two files are created in the same file-system directory (i.e. | | | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | /* ** Return the sector size in bytes of the underlying block device for ** the specified file. This is almost always 512 bytes, but may be ** larger for some devices. ** ** SQLite code assumes this function cannot fail. It also assumes that ** if two files are created in the same file-system directory (i.e. ** a database and its journal file) that the sector size will be the ** same for both. */ static int os2SectorSize(sqlite3_file *id){ return SQLITE_DEFAULT_SECTOR_SIZE; } /* |
︙ | ︙ |
Changes to src/os_unix.c.
︙ | ︙ | |||
124 125 126 127 128 129 130 | # define O_BINARY 0 #endif /* ** The DJGPP compiler environment looks mostly like Unix, but it ** lacks the fcntl() system call. So redefine fcntl() to be something ** that always succeeds. This means that locking does not occur under | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # define O_BINARY 0 #endif /* ** The DJGPP compiler environment looks mostly like Unix, but it ** lacks the fcntl() system call. So redefine fcntl() to be something ** that always succeeds. This means that locking does not occur under ** DJGPP. But it is DOS - what did you expect? */ #ifdef __DJGPP__ # define fcntl(A,B,C) 0 #endif /* ** The threadid macro resolves to the thread-id or to 0. Used for |
︙ | ︙ | |||
563 564 565 566 567 568 569 | */ return dotlockLockingStyle; } /* ** Examines the f_fstypename entry in the statfs structure as returned by ** stat() for the file system hosting the database file, assigns the | | | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | */ return dotlockLockingStyle; } /* ** Examines the f_fstypename entry in the statfs structure as returned by ** stat() for the file system hosting the database file, assigns the ** appropriate locking style based on its value. These values and ** assignments are based on Darwin/OSX behavior and have not been tested on ** other systems. */ static sqlite3LockingStyle sqlite3DetectLockingStyle( const char *filePath, int fd ){ |
︙ | ︙ | |||
2031 2032 2033 2034 2035 2036 2037 | /* ** Return the sector size in bytes of the underlying block device for ** the specified file. This is almost always 512 bytes, but may be ** larger for some devices. ** ** SQLite code assumes this function cannot fail. It also assumes that ** if two files are created in the same file-system directory (i.e. | | | 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 | /* ** Return the sector size in bytes of the underlying block device for ** the specified file. This is almost always 512 bytes, but may be ** larger for some devices. ** ** SQLite code assumes this function cannot fail. It also assumes that ** if two files are created in the same file-system directory (i.e. ** a database and its journal file) that the sector size will be the ** same for both. */ static int unixSectorSize(sqlite3_file *id){ return SQLITE_DEFAULT_SECTOR_SIZE; } /* |
︙ | ︙ |
Changes to src/os_win.c.
︙ | ︙ | |||
1005 1006 1007 1008 1009 1010 1011 | /* ** Return the sector size in bytes of the underlying block device for ** the specified file. This is almost always 512 bytes, but may be ** larger for some devices. ** ** SQLite code assumes this function cannot fail. It also assumes that ** if two files are created in the same file-system directory (i.e. | | | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 | /* ** Return the sector size in bytes of the underlying block device for ** the specified file. This is almost always 512 bytes, but may be ** larger for some devices. ** ** SQLite code assumes this function cannot fail. It also assumes that ** if two files are created in the same file-system directory (i.e. ** a database and its journal file) that the sector size will be the ** same for both. */ static int winSectorSize(sqlite3_file *id){ return SQLITE_DEFAULT_SECTOR_SIZE; } /* |
︙ | ︙ |
Changes to src/pager.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | ** 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. ** | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** 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.400 2007/12/13 21:54:11 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include <assert.h> #include <string.h> /* |
︙ | ︙ | |||
43 44 45 46 47 48 49 | #define PAGERTRACE5(X,Y,Z,W,V) #endif /* ** The following two macros are used within the PAGERTRACEX() macros above ** to print out file-descriptors. ** | | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #define PAGERTRACE5(X,Y,Z,W,V) #endif /* ** The following two macros are used within the PAGERTRACEX() macros above ** to print out file-descriptors. ** ** PAGERID() takes a pointer to a Pager struct as its argument. The ** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file ** struct as its 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: |
︙ | ︙ | |||
141 142 143 144 145 146 147 | ** pager structure for this purpose (variable Pager.lru). ** ** Additionally, if memory-management is enabled, all unreferenced pages ** are stored in a global LRU list (global variable sqlite3LruPageList). ** ** In both cases, the PagerLruList.pFirstSynced variable points to ** the first page in the corresponding list that does not require an | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | ** pager structure for this purpose (variable Pager.lru). ** ** Additionally, if memory-management is enabled, all unreferenced pages ** are stored in a global LRU list (global variable sqlite3LruPageList). ** ** In both cases, the PagerLruList.pFirstSynced variable points to ** the first page in the corresponding list that does not require an ** fsync() operation before its memory can be reclaimed. If no such ** page exists, PagerLruList.pFirstSynced is set to NULL. */ typedef struct PagerLruList PagerLruList; struct PagerLruList { PgHdr *pFirst; /* First page in LRU list */ PgHdr *pLast; /* Last page in LRU list (the most recently used) */ PgHdr *pFirstSynced; /* First page in list with PgHdr.needSync==0 */ |
︙ | ︙ | |||
1818 1819 1820 1821 1822 1823 1824 | */ if( nRec==0 && !isHot && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){ nRec = (szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager); } /* If this is the first header read from the journal, truncate the | | | 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 | */ if( nRec==0 && !isHot && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){ nRec = (szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager); } /* If this is the first header read from the journal, truncate the ** database file back to its original size. */ if( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ){ rc = pager_truncate(pPager, mxPg); if( rc!=SQLITE_OK ){ goto end_playback; } } |
︙ | ︙ | |||
2482 2483 2484 2485 2486 2487 2488 | /* ** Forward declaration */ static int syncJournal(Pager*); /* | | | 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 | /* ** Forward declaration */ static int syncJournal(Pager*); /* ** Unlink pPg from its 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 ** sqlite3PagerMovepage() routine can leave a page in the ** pNextFree/pPrevFree list that is not a part of any hash-chain. */ static void unlinkHashChain(Pager *pPager, PgHdr *pPg){ if( pPg->pgno==0 ){ assert( pPg->pNextHash==0 && pPg->pPrevHash==0 ); |
︙ | ︙ | |||
3339 3340 3341 3342 3343 3344 3345 | ** EXCLUSIVE lock. If it were, another process might open the ** database file, detect the RESERVED lock, and conclude that the ** database is safe to read while this process is still rolling it ** back. ** ** Because the intermediate RESERVED lock is not requested, the ** second process will get to this point in the code and fail to | | | 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 | ** EXCLUSIVE lock. If it were, another process might open the ** database file, detect the RESERVED lock, and conclude that the ** database is safe to read while this process is still rolling it ** back. ** ** Because the intermediate RESERVED lock is not requested, the ** second process will get to this point in the code and fail to ** obtain its own EXCLUSIVE lock on the database file. */ if( pPager->state<EXCLUSIVE_LOCK ){ rc = sqlite3OsLock(pPager->fd, EXCLUSIVE_LOCK); if( rc!=SQLITE_OK ){ pager_unlock(pPager); return pager_error(pPager, rc); } |
︙ | ︙ | |||
4582 4583 4584 4585 4586 4587 4588 | rc = sqlite3PagerTruncate(pPager, nTrunc); } sync_exit: if( rc==SQLITE_IOERR_BLOCKED ){ /* pager_incr_changecounter() may attempt to obtain an exclusive * lock to spill the cache and return IOERR_BLOCKED. But since | | | 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 | rc = sqlite3PagerTruncate(pPager, nTrunc); } sync_exit: if( rc==SQLITE_IOERR_BLOCKED ){ /* pager_incr_changecounter() may attempt to obtain an exclusive * lock to spill the cache and return IOERR_BLOCKED. But since * there is no chance the cache is inconsistent, it is * better to return SQLITE_BUSY. */ rc = SQLITE_BUSY; } pagerLeave(pPager); return rc; } |
︙ | ︙ | |||
4997 4998 4999 5000 5001 5002 5003 | if( pPg->needSync ){ needSyncPgno = pPg->pgno; assert( pPg->inJournal || (int)pgno>pPager->origDbSize ); assert( pPg->dirty ); assert( pPager->needSync ); } | | | | 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 | if( pPg->needSync ){ needSyncPgno = pPg->pgno; assert( pPg->inJournal || (int)pgno>pPager->origDbSize ); assert( pPg->dirty ); assert( pPager->needSync ); } /* Unlink pPg from its hash-chain */ unlinkHashChain(pPager, pPg); /* If the cache contains a page with page-number pgno, remove it ** from its hash chain. Also, if the PgHdr.needSync was set for ** page pgno before the 'move' operation, it needs to be retained ** for the page moved there. */ pPg->needSync = 0; pPgOld = pager_lookup(pPager, pgno); if( pPgOld ){ assert( pPgOld->nRef==0 ); |
︙ | ︙ |
Changes to src/pragma.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2003 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2003 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** ** $Id: pragma.c,v 1.152 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* Ignore this whole file if pragmas are disabled */ #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER) |
︙ | ︙ | |||
952 953 954 955 956 957 958 | #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ #ifndef SQLITE_OMIT_UTF16 /* ** PRAGMA encoding ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" ** | | | 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 | #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ #ifndef SQLITE_OMIT_UTF16 /* ** PRAGMA encoding ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" ** ** In its first form, this pragma returns the encoding of the main ** database. If the database is not initialized, it is initialized now. ** ** The second form of this pragma is a no-op if the main database file ** has not already been initialized. In this case it sets the default ** encoding that will be used for the main database file if a new file ** is created. If an existing main database file is opened, then the ** default text encoding for the existing database is used. |
︙ | ︙ |
Changes to src/prepare.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** 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. ** | | | 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 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.66 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Fill the InitData structure with an error message that indicates ** that the database is corrupt. |
︙ | ︙ | |||
338 339 340 341 342 343 344 | if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){ /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider ** the schema loaded, even if errors occured. In this situation the ** current sqlite3_prepare() operation will fail, but the following one ** will attempt to compile the supplied statement against whatever subset ** of the schema was loaded before the error occured. The primary ** purpose of this is to allow access to the sqlite_master table | | | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){ /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider ** the schema loaded, even if errors occured. In this situation the ** current sqlite3_prepare() operation will fail, but the following one ** will attempt to compile the supplied statement against whatever subset ** of the schema was loaded before the error occured. The primary ** purpose of this is to allow access to the sqlite_master table ** even when its contents have been corrupted. */ DbSetProperty(db, iDb, DB_SchemaLoaded); rc = SQLITE_OK; } sqlite3BtreeLeave(pDb->pBt); error_out: |
︙ | ︙ |
Changes to src/select.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** ** $Id: select.c,v 1.370 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. |
︙ | ︙ | |||
956 957 958 959 960 961 962 | for(i=0; i<pEList->nExpr; i++){ Expr *p = pEList->a[i].pExpr; const char *zOrigDb = 0; const char *zOrigTab = 0; const char *zOrigCol = 0; const char *zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol); | | | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | for(i=0; i<pEList->nExpr; i++){ Expr *p = pEList->a[i].pExpr; const char *zOrigDb = 0; const char *zOrigTab = 0; const char *zOrigCol = 0; const char *zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol); /* The vdbe must make its own copy of the column-type and other ** column specific strings, in case the schema is reset before this ** virtual machine is deleted. */ sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, P3_TRANSIENT); sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, P3_TRANSIENT); sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, P3_TRANSIENT); sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, P3_TRANSIENT); |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
26 27 28 29 30 31 32 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** ** @(#) $Id: sqlite.h.in,v 1.278 2007/12/13 21:54:11 drh 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++. |
︙ | ︙ | |||
2329 2330 2331 2332 2333 2334 2335 | int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object {F13330} ** ** The sqlite3_reset() function is called to reset a ** [sqlite3_stmt | compiled SQL statement] object. | | | 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 | int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object {F13330} ** ** The sqlite3_reset() function is called to reset a ** [sqlite3_stmt | compiled SQL statement] object. ** back to its initial state, ready to be re-executed. ** Any SQL statement variables that had values bound to them using ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. ** Use [sqlite3_clear_bindings()] to reset the bindings. */ int sqlite3_reset(sqlite3_stmt *pStmt); /* |
︙ | ︙ |
Changes to src/sqliteLimit.h.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file defines various limits of what SQLite can process. ** | | | 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 defines various limits of what SQLite can process. ** ** @(#) $Id: sqliteLimit.h,v 1.5 2007/12/13 21:54:11 drh Exp $ */ /* ** The maximum length of a TEXT or BLOB in bytes. This also ** limits the size of a row in a table or index. ** ** The hard limit is the ability of a 32-bit signed integer |
︙ | ︙ | |||
144 145 146 147 148 149 150 | #endif /* ** Ordinarily, if no value is explicitly provided, SQLite creates databases ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain ** device characteristics (sector-size and atomic write() support), ** SQLite may choose a larger value. This constant is the maximum value | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | #endif /* ** Ordinarily, if no value is explicitly provided, SQLite creates databases ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain ** device characteristics (sector-size and atomic write() support), ** SQLite may choose a larger value. This constant is the maximum value ** SQLite will choose on its own. */ #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192 #endif #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE # undef SQLITE_MAX_DEFAULT_PAGE_SIZE # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 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. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.281 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> /* |
︙ | ︙ | |||
775 776 777 778 779 780 781 | /* ** Implementation of tkt2213func(), a scalar function that takes exactly ** one argument. It has two interesting features: ** ** * It calls sqlite3_value_text() 3 times on the argument sqlite3_value*. ** If the three pointers returned are not the same an SQL error is raised. ** | | | 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | /* ** Implementation of tkt2213func(), a scalar function that takes exactly ** one argument. It has two interesting features: ** ** * It calls sqlite3_value_text() 3 times on the argument sqlite3_value*. ** If the three pointers returned are not the same an SQL error is raised. ** ** * Otherwise it returns a copy of the text representation of its ** argument in such a way as the VDBE representation is a Mem* cell ** with the MEM_Term flag clear. ** ** Ticket #2213 can therefore be tested by evaluating the following ** SQL expression: ** ** tkt2213func(tkt2213func('a string')); |
︙ | ︙ |
Changes to src/test8.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 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. ** ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test8.c,v 1.58 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #ifndef SQLITE_OMIT_VIRTUALTABLE |
︙ | ︙ | |||
693 694 695 696 697 698 699 | ** real table. For example, if the real table is declared as: ** ** CREATE TABLE real(a, b, c); ** CREATE INDEX real_index ON real(b); ** ** then the echo module handles WHERE or ORDER BY clauses that refer ** to the column "b", but not "a" or "c". If a multi-column index is | | | 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | ** real table. For example, if the real table is declared as: ** ** CREATE TABLE real(a, b, c); ** CREATE INDEX real_index ON real(b); ** ** then the echo module handles WHERE or ORDER BY clauses that refer ** to the column "b", but not "a" or "c". If a multi-column index is ** present, only its left most column is considered. ** ** This xBestIndex method encodes the proposed search strategy as ** an SQL query on the real table underlying the virtual echo module ** table and stores the query in sqlite3_index_info.idxStr. The SQL ** statement is of the form: ** ** SELECT rowid, * FROM <real-table> ?<where-clause>? ?<order-by-clause>? |
︙ | ︙ |
Changes to src/test_md5.c.
︙ | ︙ | |||
265 266 267 268 269 270 271 | /* Append length in bits and transform */ ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0]; ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1]; MD5Transform(ctx->buf, (uint32 *)ctx->in); byteReverse((unsigned char *)ctx->buf, 4); memcpy(digest, ctx->buf, 16); | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | /* Append length in bits and transform */ ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0]; ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1]; MD5Transform(ctx->buf, (uint32 *)ctx->in); byteReverse((unsigned char *)ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it is sensitive */ } /* ** Convert a digest into base-16. digest should be declared as ** "unsigned char digest[16]" in the calling function. The MD5 ** digest is stored in the first 16 bytes. zBuf should ** be "char zBuf[33]". |
︙ | ︙ |
Changes to src/test_thread.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** ** This file contains the implementation of some Tcl commands used to ** test that sqlite3 database handles may be concurrently accessed by ** multiple threads. Right now this only works on unix. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** ** This file contains the implementation of some Tcl commands used to ** test that sqlite3 database handles may be concurrently accessed by ** multiple threads. Right now this only works on unix. ** ** $Id: test_thread.c,v 1.6 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include <tcl.h> #if SQLITE_THREADSAFE && defined(TCL_THREADS) |
︙ | ︙ | |||
127 128 129 130 131 132 133 | Tcl_DeleteInterp(interp); return; } /* ** sqlthread spawn VARNAME SCRIPT ** | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | Tcl_DeleteInterp(interp); return; } /* ** sqlthread spawn VARNAME SCRIPT ** ** Spawn a new thread with its own Tcl interpreter and run the ** specified SCRIPT(s) in it. The thread terminates after running ** the script. The result of the script is stored in the variable ** VARNAME. ** ** The caller can wait for the script to terminate using [vwait VARNAME]. */ static int sqlthread_spawn( |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** 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. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** 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.660 2007/12/13 21:54:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" /* ** The following global variable is incremented every time a cursor |
︙ | ︙ | |||
3473 3474 3475 3476 3477 3478 3479 | ** entry is overwritten. The data is the value on the top of the ** stack. The key is the next value down on the stack. The key must ** be an integer. The stack is popped twice by this instruction. ** ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P2 is set, ** then rowid is stored for subsequent return by the | | | 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 | ** entry is overwritten. The data is the value on the top of the ** stack. The key is the next value down on the stack. The key must ** be an integer. The stack is popped twice by this instruction. ** ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P2 is set, ** then rowid is stored for subsequent return by the ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). ** ** Parameter P3 may point to a string containing the table-name, or ** may be NULL. If it is not NULL, then the update-hook ** (sqlite3.xUpdateCallback) is invoked following a successful insert. ** ** This instruction only works on tables. The equivalent instruction ** for indices is OP_IdxInsert. |
︙ | ︙ |
Changes to test/attach2.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # # $Id: attach2.test,v 1.38 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !attach { finish_test |
︙ | ︙ | |||
155 156 157 158 159 160 161 | } # A procedure to verify the status of locks on a database. # proc lock_status {testnum db expected_result} { # If the database was compiled with OMIT_TEMPDB set, then # the lock_status list will not contain an entry for the temp | | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | } # A procedure to verify the status of locks on a database. # proc lock_status {testnum db expected_result} { # If the database was compiled with OMIT_TEMPDB set, then # the lock_status list will not contain an entry for the temp # db. But the test code doesn't know this, so its easiest # to filter it out of the $expected_result list here. ifcapable !tempdb { set expected_result [concat \ [lrange $expected_result 0 1] \ [lrange $expected_result 4 end] \ ] } |
︙ | ︙ |
Changes to test/capi3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # # $Id: capi3.test,v 1.57 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
913 914 915 916 917 918 919 | COMMIT; } } {0 {}} do_test capi3-11.21 { sqlite3_finalize $STMT } {SQLITE_OK} | | | | 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | COMMIT; } } {0 {}} do_test capi3-11.21 { sqlite3_finalize $STMT } {SQLITE_OK} # The following tests - capi3-12.* - check that its Ok to start a # transaction while other VMs are active, and that its Ok to execute # atomic updates in the same situation # do_test capi3-12.1 { set STMT [sqlite3_prepare $DB "SELECT a FROM t2" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} do_test capi3-12.2 { |
︙ | ︙ |
Changes to test/capi3c.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This is a copy of the capi3.test file that has been adapted to # test the new sqlite3_prepare_v2 interface. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This is a copy of the capi3.test file that has been adapted to # test the new sqlite3_prepare_v2 interface. # # $Id: capi3c.test,v 1.13 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
908 909 910 911 912 913 914 | COMMIT; } } {0 {}} do_test capi3c-11.21 { sqlite3_finalize $STMT } {SQLITE_OK} | | | | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | COMMIT; } } {0 {}} do_test capi3c-11.21 { sqlite3_finalize $STMT } {SQLITE_OK} # The following tests - capi3c-12.* - check that its Ok to start a # transaction while other VMs are active, and that its Ok to execute # atomic updates in the same situation # do_test capi3c-12.1 { set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t2" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} do_test capi3c-12.2 { |
︙ | ︙ |
Changes to test/fts1k.test.
1 2 3 4 5 6 7 8 | # 2007 March 28 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements regression tests for SQLite library. The focus # of this script is testing isspace/isalnum/tolower problems with the # FTS1 module. Unfortunately, this code isn't a really principled set | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2007 March 28 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements regression tests for SQLite library. The focus # of this script is testing isspace/isalnum/tolower problems with the # FTS1 module. Unfortunately, this code isn't a really principled set # of tests, because it is impossible to know where new uses of these # functions might appear. # # $Id: fts1k.test,v 1.2 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_ENABLE_FTS1 is defined, omit this file. ifcapable !fts1 { |
︙ | ︙ |
Changes to test/fts2l.test.
1 2 3 4 5 6 7 8 | # 2007 March 28 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements regression tests for SQLite library. The focus # of this script is testing isspace/isalnum/tolower problems with the # FTS2 module. Unfortunately, this code isn't a really principled set | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2007 March 28 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements regression tests for SQLite library. The focus # of this script is testing isspace/isalnum/tolower problems with the # FTS2 module. Unfortunately, this code isn't a really principled set # of tests, because it is impossible to know where new uses of these # functions might appear. # # $Id: fts2l.test,v 1.2 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_ENABLE_FTS2 is defined, omit this file. ifcapable !fts2 { |
︙ | ︙ |
Changes to test/fts2n.test.
1 2 3 4 5 6 7 8 | # 2007 April 26 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements tests for prefix-searching in the fts2 # component of the SQLite library. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 2007 April 26 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements tests for prefix-searching in the fts2 # component of the SQLite library. # # $Id: fts2n.test,v 1.2 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_ENABLE_FTS2 is defined, omit this file. ifcapable !fts2 { |
︙ | ︙ | |||
186 187 188 189 190 191 192 | } $ret # TODO(shess) It would be useful to test a couple edge cases, but I # don't know if we have the precision to manage it from here at this # time. Prefix hits can cross leaves, which the code above _should_ # hit by virtue of size. There are two variations on this. If the # tree is 2 levels high, the code will find the leaf-node extent | | | 186 187 188 189 190 191 192 193 194 195 196 | } $ret # TODO(shess) It would be useful to test a couple edge cases, but I # don't know if we have the precision to manage it from here at this # time. Prefix hits can cross leaves, which the code above _should_ # hit by virtue of size. There are two variations on this. If the # tree is 2 levels high, the code will find the leaf-node extent # directly, but if its higher, the code will have to follow two # separate interior branches down the tree. Both should be tested. finish_test |
Changes to test/fts3al.test.
1 2 3 4 5 6 7 8 | # 2007 March 28 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements regression tests for SQLite library. The focus # of this script is testing isspace/isalnum/tolower problems with the # FTS3 module. Unfortunately, this code isn't a really principled set | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2007 March 28 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements regression tests for SQLite library. The focus # of this script is testing isspace/isalnum/tolower problems with the # FTS3 module. Unfortunately, this code isn't a really principled set # of tests, because it is impossible to know where new uses of these # functions might appear. # # $Id: fts3al.test,v 1.2 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_ENABLE_FTS3 is defined, omit this file. ifcapable !fts3 { |
︙ | ︙ |
Changes to test/fts3an.test.
1 2 3 4 5 6 7 8 | # 2007 April 26 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements tests for prefix-searching in the fts3 # component of the SQLite library. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 2007 April 26 # # The author disclaims copyright to this source code. # #************************************************************************* # This file implements tests for prefix-searching in the fts3 # component of the SQLite library. # # $Id: fts3an.test,v 1.2 2007/12/13 21:54:11 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_ENABLE_FTS3 is defined, omit this file. ifcapable !fts3 { |
︙ | ︙ | |||
186 187 188 189 190 191 192 | } $ret # TODO(shess) It would be useful to test a couple edge cases, but I # don't know if we have the precision to manage it from here at this # time. Prefix hits can cross leaves, which the code above _should_ # hit by virtue of size. There are two variations on this. If the # tree is 2 levels high, the code will find the leaf-node extent | | | 186 187 188 189 190 191 192 193 194 195 196 | } $ret # TODO(shess) It would be useful to test a couple edge cases, but I # don't know if we have the precision to manage it from here at this # time. Prefix hits can cross leaves, which the code above _should_ # hit by virtue of size. There are two variations on this. If the # tree is 2 levels high, the code will find the leaf-node extent # directly, but if it is higher, the code will have to follow two # separate interior branches down the tree. Both should be tested. finish_test |
Changes to test/incrvacuum.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the incremental vacuum feature. # # Note: There are also some tests for incremental vacuum and IO # errors in incrvacuum_ioerr.test. # | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the incremental vacuum feature. # # Note: There are also some tests for incremental vacuum and IO # errors in incrvacuum_ioerr.test. # # $Id: incrvacuum.test,v 1.16 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build of the library does not support auto-vacuum, omit this # whole file. ifcapable {!autovacuum || !pragma} { |
︙ | ︙ | |||
294 295 296 297 298 299 300 | INSERT INTO t3 VALUES('hello', 'world'); ROLLBACK; } { INSERT INTO t3 VALUES('hello', 'world'); } ] | | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | INSERT INTO t3 VALUES('hello', 'world'); ROLLBACK; } { INSERT INTO t3 VALUES('hello', 'world'); } ] # If this build omits subqueries, step 2 in the above list will not # work. Replace it with "" in this case. # ifcapable !subquery { lset TestScriptList 2 "" } # Compare the contents of databases $A and $B. # proc compare_dbs {A B tname} { |
︙ | ︙ |
Changes to test/lock2.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is database locks between competing processes. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is database locks between competing processes. # # $Id: lock2.test,v 1.9 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Launch another testfixture process to be controlled by this one. A # channel name is returned that may be passed as the first argument to proc |
︙ | ︙ | |||
45 46 47 48 49 50 51 | append r $line } } # Write the main loop for the child testfixture processes into file # tf_main.tcl. The parent (this script) interacts with the child processes # via a two way pipe. The parent writes a script to the stdin of the child | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | append r $line } } # Write the main loop for the child testfixture processes into file # tf_main.tcl. The parent (this script) interacts with the child processes # via a two way pipe. The parent writes a script to the stdin of the child # process, followed by the word "OVER" on a line of its own. The child # process evaluates the script and writes the results to stdout, followed # by an "OVER" of its own. set f [open tf_main.tcl w] puts $f { set l [open log w] set script "" while {![eof stdin]} { |
︙ | ︙ |
Changes to test/malloc3.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # # This file contains tests to ensure that the library handles malloc() failures # correctly. The emphasis of these tests are the _prepare(), _step() and # _finalize() calls. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # # This file contains tests to ensure that the library handles malloc() failures # correctly. The emphasis of these tests are the _prepare(), _step() and # _finalize() calls. # # $Id: malloc3.test,v 1.18 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { |
︙ | ︙ | |||
100 101 102 103 104 105 106 | # NOTES ON TEST IMPLEMENTATION # # The tests in this file are implemented differently from those in other # files. Instead, tests are specified using three primitives: SQL, PREP and # TEST. Each primitive has a single argument. Primitives are processed in # the order they are specified in the file. # | | | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | # NOTES ON TEST IMPLEMENTATION # # The tests in this file are implemented differently from those in other # files. Instead, tests are specified using three primitives: SQL, PREP and # TEST. Each primitive has a single argument. Primitives are processed in # the order they are specified in the file. # # A TEST primitive specifies a TCL script as its argument. When a TEST # directive is encountered the Tcl script is evaluated. Usually, this Tcl # script contains one or more calls to [do_test]. # # A PREP primitive specifies an SQL script as its argument. When a PREP # directive is encountered the SQL is evaluated using database connection # [db]. # # The SQL primitives are where the action happens. An SQL primitive must # contain a single, valid SQL statement as its argument. When an SQL # primitive is encountered, it is evaluated one or more times to test the # behaviour of the system when malloc() fails during preparation or # execution of said statement. The Nth time the statement is executed, # the Nth malloc is said to fail. The statement is executed until it # succeeds, i.e. (M+1) times, where M is the number of mallocs() required # to prepare and execute the statement. # |
︙ | ︙ | |||
199 200 201 202 203 204 205 | } TEST 2 { do_test $testid.1 { execsql {SELECT tbl_name FROM sqlite_master;} } {abc} } | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | } TEST 2 { do_test $testid.1 { execsql {SELECT tbl_name FROM sqlite_master;} } {abc} } # Insert a couple of rows into the table. each insert is in its own # transaction. test that the table is unpopulated before running the inserts # (and hence after each failure of the first insert), and that it has been # populated correctly after the final insert succeeds. # TEST 3 { do_test $testid.2 { execsql {SELECT * FROM abc} |
︙ | ︙ |
Changes to test/misc7.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2006 September 4 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2006 September 4 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # $Id: misc7.test,v 1.17 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl #do_test misc7-1 { # c_misuse_test #} {} |
︙ | ︙ | |||
34 35 36 37 38 39 40 | file mkdir mydir set rc [catch { sqlite3 db2 ./mydir } msg] list $rc $msg } {1 {unable to open database file}} | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | file mkdir mydir set rc [catch { sqlite3 db2 ./mydir } msg] list $rc $msg } {1 {unable to open database file}} # Try to open a file with a directory where its journal file should be. # do_test misc7-5 { file delete mydir file mkdir mydir-journal sqlite3 db2 ./mydir catchsql { CREATE TABLE abc(a, b, c); |
︙ | ︙ |
Changes to test/shared.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2005 December 30 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2005 December 30 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # $Id: shared.test,v 1.29 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl db close # These tests cannot be run without the ATTACH command. # |
︙ | ︙ | |||
570 571 572 573 574 575 576 | execsql { INSERT INTO t2 SELECT * FROM t1; COMMIT; } } {} do_test shared-$av.7.2 { # This test case deletes the contents of table t1 (the one at the start of | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | execsql { INSERT INTO t2 SELECT * FROM t1; COMMIT; } } {} do_test shared-$av.7.2 { # This test case deletes the contents of table t1 (the one at the start of # the file) while many cursors are open on table t2 and its index. All of # the non-root pages will be moved from the end to the start of the file # when the DELETE is committed - this test verifies that moving the pages # does not disturb the open cursors. # proc lockrow {db tbl oids body} { set ret [list] |
︙ | ︙ |
Changes to test/vtab1.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2006 June 10 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is creating and dropping virtual tables. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2006 June 10 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is creating and dropping virtual tables. # # $Id: vtab1.test,v 1.50 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !vtab||!schema_pragmas { finish_test return |
︙ | ︙ | |||
949 950 951 952 953 954 955 | execsql { SELECT * FROM c } } {3 G H} # At one point (ticket #2759), a WHERE clause of the form "<column> IS NULL" # on a virtual table was causing an assert() to fail in the compiler. # # "IS NULL" clauses should not be passed through to the virtual table | | | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | execsql { SELECT * FROM c } } {3 G H} # At one point (ticket #2759), a WHERE clause of the form "<column> IS NULL" # on a virtual table was causing an assert() to fail in the compiler. # # "IS NULL" clauses should not be passed through to the virtual table # implementation. They are handled by SQLite after the vtab returns its # data. # do_test vtab1.13-1 { execsql { SELECT * FROM echo_c WHERE a IS NULL } } {} |
︙ | ︙ |
Changes to test/vtab_alter.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the ALTER TABLE ... RENAME TO # command on virtual tables. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the ALTER TABLE ... RENAME TO # command on virtual tables. # # $Id: vtab_alter.test,v 1.3 2007/12/13 21:54:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !vtab { finish_test return |
︙ | ︙ | |||
58 59 60 61 62 63 64 | do_test vtab_alter-1.5 { catchsql { SELECT * FROM t1echo } } {1 {no such table: t1echo}} do_test vtab_alter-1.6 { catchsql { SELECT * FROM new } } {0 {}} | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | do_test vtab_alter-1.5 { catchsql { SELECT * FROM t1echo } } {1 {no such table: t1echo}} do_test vtab_alter-1.6 { catchsql { SELECT * FROM new } } {0 {}} # Try to rename an echo table that renames its base table. Make # sure nothing terrible happens. # do_test vtab_alter-2.1 { execsql { DROP TABLE new; DROP TABLE t1; CREATE TABLE t1_base(a, b, c); |
︙ | ︙ | |||
85 86 87 88 89 90 91 | do_test vtab_alter-2.4 { execsql { SELECT * FROM x; } } {1 2 3} do_test vtab_alter-2.5 { execsql { SELECT * FROM x_base; } } {1 2 3} | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | do_test vtab_alter-2.4 { execsql { SELECT * FROM x; } } {1 2 3} do_test vtab_alter-2.5 { execsql { SELECT * FROM x_base; } } {1 2 3} # Cause an error to occur when the echo module renames its # backing store table. # do_test vtab_alter-3.1 { execsql { CREATE TABLE y_base(a, b, c) } catchsql { ALTER TABLE x RENAME TO y } } {1 {SQL logic error or missing database}} do_test vtab_alter-3.2 { execsql { SELECT * FROM x } } {1 2 3} finish_test |