Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Issue an error message and quit (rather than overflowing a reference counter) if the number of references to a table exceeds the maximum due to nested UNION views. Fix for ticket [d58ccbb3f1]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c2462a95ed8e1e69886681400d673207 |
User & Date: | drh 2013-01-28 19:00:20.786 |
Context
2013-01-28
| ||
22:52 | Fix an issue with the SQLITE_TESTCTRL_EXPLAIN_STMT and compound queries with multiple terms. (check-in: a6499c2521 user: drh tags: trunk) | |
19:00 | Issue an error message and quit (rather than overflowing a reference counter) if the number of references to a table exceeds the maximum due to nested UNION views. Fix for ticket [d58ccbb3f1]. (check-in: c2462a95ed user: drh tags: trunk) | |
18:18 | Cause the command-line shell to issue an error message if you give something that does not look like a boolean value to a dot-command that wants a boolean argument. (check-in: b4d94947fc user: drh tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 | pTab->tabFlags |= TF_Ephemeral; #endif }else{ /* An ordinary table or view name in the FROM clause */ assert( pFrom->pTab==0 ); pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom); if( pTab==0 ) return WRC_Abort; pTab->nRef++; #if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE) if( pTab->pSelect || IsVirtual(pTab) ){ /* We reach here if the named table is a really a view */ if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; assert( pFrom->pSelect==0 ); pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0); | > > > > > > | 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 | pTab->tabFlags |= TF_Ephemeral; #endif }else{ /* An ordinary table or view name in the FROM clause */ assert( pFrom->pTab==0 ); pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom); if( pTab==0 ) return WRC_Abort; if( pTab->nRef==0xffff ){ sqlite3ErrorMsg(pParse, "too many references to \"%s\": max 65535", pTab->zName); pFrom->pTab = 0; return WRC_Abort; } pTab->nRef++; #if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE) if( pTab->pSelect || IsVirtual(pTab) ){ /* We reach here if the named table is a really a view */ if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; assert( pFrom->pSelect==0 ); pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0); |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
119 120 121 122 123 124 125 | VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */ Op *aOp; /* Program instructions for parent frame */ Mem *aMem; /* Array of memory cells for parent frame */ u8 *aOnceFlag; /* Array of OP_Once flags for parent frame */ VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */ void *token; /* Copy of SubProgram.token */ i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */ Op *aOp; /* Program instructions for parent frame */ Mem *aMem; /* Array of memory cells for parent frame */ u8 *aOnceFlag; /* Array of OP_Once flags for parent frame */ VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */ void *token; /* Copy of SubProgram.token */ i64 lastRowid; /* Last insert rowid (sqlite3.lastRowid) */ u32 nCursor; /* Number of entries in apCsr */ int pc; /* Program Counter in parent (calling) frame */ int nOp; /* Size of aOp array */ int nMem; /* Number of entries in aMem */ int nOnceFlag; /* Number of entries in aOnceFlag */ int nChildMem; /* Number of memory cells for child frame */ int nChildCsr; /* Number of cursors for child frame */ int nChange; /* Statement changes (Vdbe.nChanges) */ |
︙ | ︙ | |||
305 306 307 308 309 310 311 | Mem *pResultSet; /* Pointer to an array of results */ int nMem; /* Number of memory locations currently allocated */ int nOp; /* Number of instructions in the program */ int nOpAlloc; /* Number of slots allocated for aOp[] */ int nLabel; /* Number of labels used */ int *aLabel; /* Space to hold the labels */ u16 nResColumn; /* Number of columns in one row of the result set */ | | | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | Mem *pResultSet; /* Pointer to an array of results */ int nMem; /* Number of memory locations currently allocated */ int nOp; /* Number of instructions in the program */ int nOpAlloc; /* Number of slots allocated for aOp[] */ int nLabel; /* Number of labels used */ int *aLabel; /* Space to hold the labels */ u16 nResColumn; /* Number of columns in one row of the result set */ u32 nCursor; /* Number of slots in apCsr[] */ u32 magic; /* Magic number for sanity checking */ char *zErrMsg; /* Error message written here */ Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ VdbeCursor **apCsr; /* One element of this array for each open cursor */ Mem *aVar; /* Values for the OP_Variable opcode. */ char **azVar; /* Name of variables */ ynVar nVar; /* Number of entries in aVar[] */ |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
1534 1535 1536 1537 1538 1539 1540 | if( nByte ){ p->pFree = sqlite3DbMallocZero(db, nByte); } zCsr = p->pFree; zEnd = &zCsr[nByte]; }while( nByte && !db->mallocFailed ); | | | 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 | if( nByte ){ p->pFree = sqlite3DbMallocZero(db, nByte); } zCsr = p->pFree; zEnd = &zCsr[nByte]; }while( nByte && !db->mallocFailed ); p->nCursor = nCursor; p->nOnceFlag = nOnce; if( p->aVar ){ p->nVar = (ynVar)nVar; for(n=0; n<nVar; n++){ p->aVar[n].flags = MEM_Null; p->aVar[n].db = db; } |
︙ | ︙ |
Changes to test/view.test.
︙ | ︙ | |||
571 572 573 574 575 576 577 578 579 | execsql { DROP TABLE IF EXISTS t1; DROP VIEW IF EXISTS v1; CREATE TABLE t1(c1); CREATE VIEW v1 AS SELECT c1 FROM (SELECT t1.c1 FROM t1); } } {} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | execsql { DROP TABLE IF EXISTS t1; DROP VIEW IF EXISTS v1; CREATE TABLE t1(c1); CREATE VIEW v1 AS SELECT c1 FROM (SELECT t1.c1 FROM t1); } } {} # Ticket [d58ccbb3f1b]: Prevent Table.nRef overflow. db close sqlite3 db :memory: do_test view-21.1 { catchsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(5); CREATE VIEW v1 AS SELECT x*2 FROM t1; CREATE VIEW v2 AS SELECT * FROM v1 UNION SELECT * FROM v1; CREATE VIEW v4 AS SELECT * FROM v2 UNION SELECT * FROM v2; CREATE VIEW v8 AS SELECT * FROM v4 UNION SELECT * FROM v4; CREATE VIEW v16 AS SELECT * FROM v8 UNION SELECT * FROM v8; CREATE VIEW v32 AS SELECT * FROM v16 UNION SELECT * FROM v16; CREATE VIEW v64 AS SELECT * FROM v32 UNION SELECT * FROM v32; CREATE VIEW v128 AS SELECT * FROM v64 UNION SELECT * FROM v64; CREATE VIEW v256 AS SELECT * FROM v128 UNION SELECT * FROM v128; CREATE VIEW v512 AS SELECT * FROM v256 UNION SELECT * FROM v256; CREATE VIEW v1024 AS SELECT * FROM v512 UNION SELECT * FROM v512; CREATE VIEW v2048 AS SELECT * FROM v1024 UNION SELECT * FROM v1024; CREATE VIEW v4096 AS SELECT * FROM v2048 UNION SELECT * FROM v2048; CREATE VIEW v8192 AS SELECT * FROM v4096 UNION SELECT * FROM v4096; CREATE VIEW v16384 AS SELECT * FROM v8192 UNION SELECT * FROM v8192; CREATE VIEW v32768 AS SELECT * FROM v16384 UNION SELECT * FROM v16384; CREATE VIEW vx AS SELECT * FROM v32768 UNION SELECT * FROM v32768; } } {1 {too many references to "v1": max 65535}} do_test view-21.2 { db progress 1000 {expr 1} catchsql { SELECT * FROM v32768; } } {1 interrupted} finish_test |