Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Handle out-of-memory situations inside the query flattener. Ticket #2784. (CVS 4549) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2655a3f2d18fe16a36a6cf3776261ee0 |
User & Date: | drh 2007-11-21 15:24:01.000 |
Context
2007-11-22
| ||
00:47 | Change to sqlite3.pc.in recommended by ticket #2786. (CVS 4550) (check-in: 247fa2eac0 user: drh tags: trunk) | |
2007-11-21
| ||
15:24 | Handle out-of-memory situations inside the query flattener. Ticket #2784. (CVS 4549) (check-in: 2655a3f2d1 user: drh tags: trunk) | |
2007-11-17
| ||
22:23 | Fix a bug in the grammar. We were giving the ones-complement operator ~ the same precedence as the NOT operator, which is incorrect. (CVS 4548) (check-in: b48a4bfd32 user: drh tags: trunk) | |
Changes
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.362 2007/11/21 15:24:01 drh Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. |
︙ | ︙ | |||
2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 | int nSubSrc = pSubSrc->nSrc; int jointype = pSubitem->jointype; sqlite3DeleteTable(pSubitem->pTab); sqlite3_free(pSubitem->zDatabase); sqlite3_free(pSubitem->zName); sqlite3_free(pSubitem->zAlias); if( nSubSrc>1 ){ int extra = nSubSrc - 1; for(i=1; i<nSubSrc; i++){ pSrc = sqlite3SrcListAppend(db, pSrc, 0, 0); } p->pSrc = pSrc; for(i=pSrc->nSrc-1; i-extra>=iFrom; i--){ pSrc->a[i] = pSrc->a[i-extra]; } } for(i=0; i<nSubSrc; i++){ | > > > > > > > > | 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 | int nSubSrc = pSubSrc->nSrc; int jointype = pSubitem->jointype; sqlite3DeleteTable(pSubitem->pTab); sqlite3_free(pSubitem->zDatabase); sqlite3_free(pSubitem->zName); sqlite3_free(pSubitem->zAlias); pSubitem->pTab = 0; pSubitem->zDatabase = 0; pSubitem->zName = 0; pSubitem->zAlias = 0; if( nSubSrc>1 ){ int extra = nSubSrc - 1; for(i=1; i<nSubSrc; i++){ pSrc = sqlite3SrcListAppend(db, pSrc, 0, 0); if( pSrc==0 ){ p->pSrc = 0; return 1; } } p->pSrc = pSrc; for(i=pSrc->nSrc-1; i-extra>=iFrom; i--){ pSrc->a[i] = pSrc->a[i-extra]; } } for(i=0; i<nSubSrc; i++){ |
︙ | ︙ | |||
3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 | ** more conservative than necessary, but much easier than enforcing ** an exact limit. */ pParse->nHeight += sqlite3SelectExprHeight(p); #endif sqlite3Select(pParse, pItem->pSelect, SRT_EphemTab, pItem->iCursor, p, i, &isAgg, 0); #if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0 pParse->nHeight -= sqlite3SelectExprHeight(p); #endif if( needRestoreContext ){ pParse->zAuthContext = zSavedAuthContext; } pTabList = p->pSrc; | > > > | 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 | ** more conservative than necessary, but much easier than enforcing ** an exact limit. */ pParse->nHeight += sqlite3SelectExprHeight(p); #endif sqlite3Select(pParse, pItem->pSelect, SRT_EphemTab, pItem->iCursor, p, i, &isAgg, 0); if( db->mallocFailed ){ goto select_end; } #if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0 pParse->nHeight -= sqlite3SelectExprHeight(p); #endif if( needRestoreContext ){ pParse->zAuthContext = zSavedAuthContext; } pTabList = p->pSrc; |
︙ | ︙ |
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.271 2007/11/21 15:24:01 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++. |
︙ | ︙ | |||
2936 2937 2938 2939 2940 2941 2942 | ** ** Duplicate extensions are detected so calling this routine multiple ** times with the same extension is harmless. ** ** This routine stores a pointer to the extension in an array ** that is obtained from malloc(). If you run a memory leak ** checker on your program and it reports a leak because of this | | | 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 | ** ** Duplicate extensions are detected so calling this routine multiple ** times with the same extension is harmless. ** ** This routine stores a pointer to the extension in an array ** that is obtained from malloc(). If you run a memory leak ** checker on your program and it reports a leak because of this ** array, then invoke [sqlite3_reset_auto_extension()] prior ** to shutdown to free the memory. ** ** Automatic extensions apply across all threads. ** ** This interface is experimental and is subject to change or ** removal in future releases of SQLite. */ |
︙ | ︙ |
Added test/mallocE.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # 2007 Aug 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 test script checks that ticket #2784 has been fixed. # # $Id: mallocE.test,v 1.1 2007/11/21 15:24:01 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { puts "Skipping mallocE tests: not compiled with -DSQLITE_MEMDEBUG..." finish_test return } source $testdir/malloc_common.tcl set PREP { PRAGMA page_size = 1024; CREATE TABLE t1(a, b, c); CREATE TABLE t2(x, y, z); } do_malloc_test mallocE-1 -sqlprep $PREP -sqlbody { SELECT p, q FROM (SELECT a+b AS p, b+c AS q FROM t1, t2 WHERE c>5) LEFT JOIN t2 ON p=x; } finish_test |